-- --------------------------------------------------------
-- Host:                         127.0.0.1
-- Server version:               5.7.33 - MySQL Community Server (GPL)
-- Server OS:                    Win64
-- HeidiSQL Version:             11.2.0.6213
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

-- Dumping structure for view hgagent.ptl_bal_qty_view
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `ptl_bal_qty_view` (
	`promoter_task_list_product_id` BIGINT(20) UNSIGNED NULL,
	`list_promoter_task_data_id` BIGINT(20) UNSIGNED NULL,
	`list_promoter_task_id` BIGINT(20) UNSIGNED NULL,
	`promoter_task_list_id` BIGINT(20) UNSIGNED NOT NULL,
	`product_id` BIGINT(20) UNSIGNED NULL,
	`product_name` VARCHAR(191) NULL COLLATE 'utf8mb4_unicode_ci',
	`promoter_id` BIGINT(20) UNSIGNED NOT NULL,
	`t_qty` INT(11) NULL,
	`o_qty` INT(11) NULL,
	`l_qty` INT(11) NULL,
	`remark` VARCHAR(191) NULL COLLATE 'utf8mb4_unicode_ci'
) ENGINE=MyISAM;

-- Dumping structure for view hgagent.ptl_bal_qty_view
-- Removing temporary table and create final VIEW structure
DROP TABLE IF EXISTS `ptl_bal_qty_view`;
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `ptl_bal_qty_view` AS SELECT lptd.`promoter_task_list_product_id`, lptd.`id` as list_promoter_task_data_id, lptd.`list_promoter_task_id` as list_promoter_task_id, lpt.`promoter_task_list_id` as promoter_task_list_id, ptlp.`product_id`, ptlp.`name` AS product_name, lpt.`promoter_id`, ptlp.`t_qty` as t_qty, ptlp.`o_qty` AS o_qty, ptlp.`l_qty` as l_qty, lptd.`remark`
    FROM `list_promoter_task` lpt LEFT JOIN list_promoter_task_data lptd on lpt.id=lptd.list_promoter_task_id LEFT JOIN promoter_task_list_products ptlp on ptlp.id=lptd.promoter_task_list_product_id ;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
