INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:13:16";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 09:43:16", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 09:43:16', '4', '', '41.44.122.147', '', 'DESKTOP');
UPDATE programsettings SET companyname = 'GT4', address = 'المنصورة', specializtion = 'jh', phone = '01002019235', faxnumber = '0502232923', email = 'mrabozied@gt4it.com', website = 'www.gt4host.com', logo = '471502e62c0be89a8d90663028144a83.jpg', roundnumbers = '0', saveprinting = '1', deptprinting = '1', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '1', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = '0', taxcard = '332', commercialregistration = '3213123312', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '0', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2021-11-13',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',allowdateedit = '0', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '0' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '0' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='0',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='0' WHERE programsettingsid = '1';
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:13:17";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:13:20";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 09:43:20", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 09:43:20', '4', 'addsellBill', '41.44.122.147', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:13:52";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 09:43:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 09:43:52', '4', 'addsellBill', '41.44.122.147', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:55:33";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:25:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 10:25:33', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:55:34";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:56:05";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:26:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storeController.php', '2021-11-13 10:26:06', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:56:10";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:26:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storeController.php', '2021-11-13 10:26:10', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 06:59:16";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:29:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('buyBillController.php', '2021-11-13 10:29:16', '1', 'bill', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:00:10";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:30:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 10:30:10', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:00:32";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:30:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesNumbersReport.php', '2021-11-13 10:30:32', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:01:01";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:31:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesNumbersReport.php', '2021-11-13 10:31:01', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:02:09";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:32:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-13 10:32:09', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:02:23";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:32:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 10:32:23', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:19:49";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:49:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreport.php', '2021-11-13 10:49:49', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:20:06";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:50:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreport.php', '2021-11-13 10:50:06', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:20:19";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:50:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 10:50:19', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:20:36";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:50:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 10:50:36', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:21:16";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:51:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientsAndProductsReportController.php', '2021-11-13 10:51:16', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:21:27";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:51:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientsAndProductsReportController.php', '2021-11-13 10:51:27', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:21:31";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:51:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientsAndProductsReportController.php', '2021-11-13 10:51:31', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:21:42";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:51:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 10:51:42', '1', 'all', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:21:52";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:51:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 10:51:52', '1', 'all', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:22:25";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:52:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 10:52:25', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:22:41";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:52:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 10:52:41', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:23:44";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:53:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientdebt.php', '2021-11-13 10:53:44', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:23:46";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:53:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientdebt.php', '2021-11-13 10:53:46', '1', 'showallajax', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:24:06";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:54:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreport.php', '2021-11-13 10:54:07', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:24:20";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:54:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreport.php', '2021-11-13 10:54:20', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:24:33";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:54:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 10:54:33', '1', 'addsellBill', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:24:46";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:54:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillandruternController.php', '2021-11-13 10:54:47', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:25:03";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:55:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillandruternController.php', '2021-11-13 10:55:04', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:25:41";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:55:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillandruternController.php', '2021-11-13 10:55:41', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:26:04";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:56:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellBillReportsController.php', '2021-11-13 10:56:04', '1', 'sellandreturnreport?do=show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:26:22";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:56:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellBillReportsController.php', '2021-11-13 10:56:22', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:26:31";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:56:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellBillReportsController.php', '2021-11-13 10:56:31', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:26:58";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:56:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientsAndProductsReportController.php', '2021-11-13 10:56:58', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:27:06";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:57:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientsAndProductsReportController.php', '2021-11-13 10:57:06', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:28:09";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:58:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsbyareabytypeClientController.php', '2021-11-13 10:58:09', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:28:35";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:58:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreportofclientsbyproduct.php', '2021-11-13 10:58:35', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:28:43";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:58:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreportofclientsbyproduct.php', '2021-11-13 10:58:43', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:28:51";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:58:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreport.php', '2021-11-13 10:58:51', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:29:06";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:59:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 10:59:06', '1', 'all', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:29:15";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:59:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 10:59:15', '1', 'all', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:29:23";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:59:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 10:59:23', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:29:56";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 10:59:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellreportpricetype.php', '2021-11-13 10:59:56', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 07:30:09";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 11:00:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellreportpricetype.php', '2021-11-13 11:00:09', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:01:18";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:31:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('usergroupController.php', '2021-11-13 12:31:18', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:01:56";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:31:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('usergroupController.php', '2021-11-13 12:31:56', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:03:05";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:33:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 12:33:05', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:03:41";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:33:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 12:33:41', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:03:54";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:33:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 12:33:54', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:04:29";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:34:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 12:34:29', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:04:51";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:34:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 12:34:51', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:05:20";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:35:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 12:35:20', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:05:36";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:35:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 12:35:36', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:06:41";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:36:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 12:36:41', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:07:24";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:37:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 12:37:24', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:07:58";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:37:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 12:37:58', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:08:23";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 12:38:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 12:38:23', '4', 'addAndRetuen', '41.44.122.147', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0618f6cb8d9a32
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2021-11-13 09:43:52', '0618f6cb8d9a32', '1', '0.00', '0', '0', '1', '880', '880', '880', '0', '7', '2021-11-13 12:38:24', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','880','0','','0','0','880','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '4' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','6', '0', '2021-11-13 12:38:24', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '880', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 1514;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('195','00126', '6', '1', '126', '3', '220', '660', '0', '', '0', '2021-11-13 12:38:24', '126', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','1514-3,');
UPDATE sellbilldetail SET  lastbuyprice = 195.00 , meanbuyprice = 195.00, lastbuyprice_withDiscount = 195.00, meanbuyprice_withDiscount = 195.00
                where sellbilldetailid = 6;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (126, '2021-11-13', 660, 585, 585
                    , 585, 585, 585, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2021-11-13', 660, 585, 585
                    , 585, 585, 585, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+585
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+585, sellCostMeanBuyPrice = sellCostMeanBuyPrice+585
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+585, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+585
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '4', storedetaildate = '2021-11-13 12:38:24' WHERE storedetailid = '1308';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('126', '7', '3', '1', '6', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20.00', '17', '4', '2021-11-13 12:38:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 1520;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('205','00214', '6', '1', '214', '1', '220', '220', '0', '', '0', '2021-11-13 12:38:24', '214', '0.00', '0', '7','0','','','0','0','0','0','0','0','0','0','','1520-1,');
UPDATE sellbilldetail SET  lastbuyprice = 205.00 , meanbuyprice = 205.00, lastbuyprice_withDiscount = 205.00, meanbuyprice_withDiscount = 205.00
                where sellbilldetailid = 7;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (214, '2021-11-13', 220, 205, 205
                    , 205, 205, 205, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+205
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+205, sellCostMeanBuyPrice = sellCostMeanBuyPrice+205
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+205, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2021-11-13', 220, 205, 205
                    , 205, 205, 205, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+205
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+205, sellCostMeanBuyPrice = sellCostMeanBuyPrice+205
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+205, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+205
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '45', userid = '4', storedetaildate = '2021-11-13 12:38:24' WHERE storedetailid = '1311';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('214', '7', '1', '1', '6', 'اضافة فاتورة مبيعات', 'sellbillController.php', '46.00', '45', '4', '2021-11-13 12:38:24','0','0');
UPDATE save SET  savecurrentvalue = '880',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('0.00','880', '0', '7', 'اضافة فاتورة مبيعات', '6', '880', '2021-11-13 12:38:24', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2021-11-13', 880, 790, 790
                    , 790, 790, 790, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+880, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2021-11-13', 880, 790, 790
                    , 790, 790, 790, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+880, sellCostBuyPrice =sellCostBuyPrice+790
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+790, sellCostMeanBuyPrice = sellCostMeanBuyPrice+790
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+790, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+790
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 880, 790, 790
                    , 790, 790, 790, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+880, netSellCostBuyPrice = netSellCostBuyPrice+790
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+790
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+790
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+790
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+790
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0618f6cb8d9a32 and sellbillId = 6 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:08:24";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 12:38:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 12:38:24', '4', 'addsellBill', '41.44.122.147', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:08:40";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 12:38:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2021-11-13 12:38:40', '4', '', '41.44.122.147', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:08:51";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:38:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 12:38:51', '1', 'add', '41.238.108.117', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =95
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(16,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '86370.8' , clientdate = '2021-11-13 12:38:52', userid = '1' WHERE clientid = '16';
UPDATE client SET  inUse = 0 where clientid = 16;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('16','96370.80','10000','1','ايصال تحصيل (( قبض من عميل ))','95', '86370.8', '2021-11-12  12:35:58', '1', 'clientPayedDeptController.php', '   ', '10000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '26000',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('16000.00','10000', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '96', '26000', '2021-11-13 12:38:52', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '10000', '10000', '2021-11-13', '1', '0', '0', '2021-11-13 12:38:52','اضافة ايصال سداد للعميل ميدو','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('641', '54', '10000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '26000', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('641', '69', '10000', '','0');
UPDATE accountstree SET name = 'ميدو', customName = 'ميدو', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-10000', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '69';
UPDATE clientdebtchange SET clientid = '16', clientdebtchangebefore = '96370.80', clientdebtchangeamount = '10000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '95', clientdebtchangeafter = '86370.80', clientdebtchangedate = '2021-11-12 12:35:58', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '10000.00',discount='', reciptid=null, dailyentryid = '641',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '96';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =95 -clientdebtchangeId = 96
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:08:52";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:38:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 12:38:52', '1', 'sucess', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:08:54";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:38:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 12:38:54', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:09:06";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:39:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2021-11-13 12:39:06', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:09:36";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 12:39:36", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 12:39:36', '4', 'showDetail', '41.44.122.147', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:09:48";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 12:39:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 12:39:48', '4', 'addsellBill', '41.44.122.147', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:10:00";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 12:40:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2021-11-13 12:40:00', '4', '', '41.44.122.147', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:13:12";
UPDATE user SET loginip = "156.160.220.34", lastactivetime = "2021-11-13 12:43:12", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 12:43:12', '7', '', '156.160.220.34', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:13:12";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:16:42";
UPDATE user SET loginip = "156.160.220.34", lastactivetime = "2021-11-13 12:46:42", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 12:46:42', '7', 'addsellBill', '156.160.220.34', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:26:04";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:56:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 12:56:05', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:26:17";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:56:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 12:56:17', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:26:56";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:56:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 12:56:57', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:27:14";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:57:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 12:57:14', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:27:28";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:57:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 12:57:28', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:27:36";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:57:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 12:57:36', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:28:06";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:58:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storeController.php', '2021-11-13 12:58:07', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:28:54";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:58:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 12:58:54', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:29:31";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 12:59:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 12:59:31', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:29:34";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 12:59:34", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 12:59:34', '4', 'addsellBill', '41.44.122.147', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:30:05";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:00:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-13 13:00:05', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:30:54";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:00:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 13:00:54', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:31:09";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:01:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storereportController.php', '2021-11-13 13:01:09', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:31:16";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 13:01:16", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 13:01:16', '4', 'addsellBill', '41.44.122.147', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:31:36";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:01:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 13:01:36', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:31:45";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:01:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 13:01:45', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:32:28";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:02:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 13:02:28', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:32:41";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:02:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 13:02:41', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:35:05";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:05:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 13:05:05', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:35:18";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:05:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 13:05:18', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:37:46";
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:39:12";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:09:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 13:09:12', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:39:29";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:09:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 13:09:29', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE product SET productName = ' 12 كريشه', productDescription = '', productCatId = '1', productBuyPrice = '150.00', productSellAllPrice = '155.00', productSellUnitPrice = '155.00', productSellHalfPrice = '155.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00134',type ='0', expireDate = '0' , dailyentryId = '134',isService = '0',isOptic = '0',lastbuyprice = '150.00',lastbuyprice_withDiscount = '150',meanbuyprice = '150.00',meanbuyprice_withDiscount = '150' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '134';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (134, 1,'2021-11-13 13:10:28',1)
                ON DUPLICATE KEY UPDATE productid = 134, edited = 1, sysdate = '2021-11-13 13:10:28', userid = 1;
UPDATE product SET productName = ' 12 كريشه', productDescription = '', productCatId = '1', productBuyPrice = '150.00', productSellAllPrice = '165.00', productSellUnitPrice = '165.00', productSellHalfPrice = '165.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00134',type ='0', expireDate = '0' , dailyentryId = '134',isService = '0',isOptic = '0',lastbuyprice = '150.00',lastbuyprice_withDiscount = '150',meanbuyprice = '150.00',meanbuyprice_withDiscount = '150' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '134';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (134, 1,'2021-11-13 13:10:34',1)
                ON DUPLICATE KEY UPDATE productid = 134, edited = 1, sysdate = '2021-11-13 13:10:34', userid = 1;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:41:23";
UPDATE user SET loginip = "197.55.181.170", lastactivetime = "2021-11-13 13:11:23", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 13:11:23', '5', '', '197.55.181.170', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:41:23";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:41:29";
UPDATE user SET loginip = "197.55.181.170", lastactivetime = "2021-11-13 13:11:29", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 13:11:29', '5', 'addsellBill', '197.55.181.170', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:42:18";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:12:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2021-11-13 13:12:18', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:42:32";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:12:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2021-11-13 13:12:32', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
INSERT INTO notics (productno, productnotsellno, kempilano, clientcheckno, suppliercheckno) VALUES ('41', '548', '0', '0', '0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:43:11";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:13:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2021-11-13 13:13:11', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:43:32";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:13:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2021-11-13 13:13:32', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:44:00";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:14:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('programsettingsController.php', '2021-11-13 13:14:00', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:44:15";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:14:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('branchesController.php', '2021-11-13 13:14:15', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:44:48";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:14:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 13:14:48', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:44:48";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:45:51";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:15:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 13:15:51', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:45:59";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:15:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 13:15:59', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:46:51";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:16:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('buyBillController.php', '2021-11-13 13:16:51', '1', 'bill', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:50:33";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:20:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2021-11-13 13:20:33', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:54:00";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:24:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 13:24:00', '1', 'addsellBill', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:59:39";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:29:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 13:29:39', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 09:59:55";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 13:29:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 13:29:55', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:35:09";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:05:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 14:05:09', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:35:09";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:37:15";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:07:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:07:15', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:37:28";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:07:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:07:28', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:39:25";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:09:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:09:25', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:45:25";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:15:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 14:15:25', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:45:25";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:46:32";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:16:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:16:32', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:47:38";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:17:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:17:38', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '225.00', productSellHalfPrice = '225.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:17:56',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:17:56', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '225.00', productSellHalfPrice = '235', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:18:04',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:18:04', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '225.02550', productSellHalfPrice = '235.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:18:10',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:18:10', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '255', productSellHalfPrice = '235.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:18:22',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:18:22', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '255.00', productSellHalfPrice = '235.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:18:27',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:18:27', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '255.00', productSellHalfPrice = '235.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:18:30',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:18:30', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '420', productSellAllPrice = '225.00', productSellUnitPrice = '255.00', productSellHalfPrice = '235.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '315',meanbuyprice_withDiscount = '315' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:24',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:24', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '420.00', productSellAllPrice = '225.00', productSellUnitPrice = '255.00', productSellHalfPrice = '470', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '315.00',meanbuyprice_withDiscount = '315' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:24',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:24', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '420.00', productSellAllPrice = '450', productSellUnitPrice = '450', productSellHalfPrice = '450', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '315.00',meanbuyprice_withDiscount = '315' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:24',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:24', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '420.00', productSellAllPrice = '450.00', productSellUnitPrice = '510', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '315.00',meanbuyprice_withDiscount = '315' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:25',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:25', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '630', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '472.5',meanbuyprice_withDiscount = '472.5' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:41',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:41', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '840', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '656.25',meanbuyprice_withDiscount = '656.25' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:43',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:43', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '1050', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '853.13',meanbuyprice_withDiscount = '853.13' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:43',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:43', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '1260', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1056.57',meanbuyprice_withDiscount = '1056.57' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:43',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:43', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '1470', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1263.29',meanbuyprice_withDiscount = '1263.29' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:44',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:44', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '1890', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1576.65',meanbuyprice_withDiscount = '1576.65' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:44',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:44', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '1680', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1628.33',meanbuyprice_withDiscount = '1628.33' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:44',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:44', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '2100', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1864.17',meanbuyprice_withDiscount = '1864.17' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:44',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:44', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '2310', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '2087.09',meanbuyprice_withDiscount = '2087.09' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:44',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:44', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210', productSellAllPrice = '450.00', productSellUnitPrice = '510.00', productSellHalfPrice = '450.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1148.55',meanbuyprice_withDiscount = '1148.55' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:19:54',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:19:54', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '225.00', productSellHalfPrice = '225.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1148.55',meanbuyprice_withDiscount = '1148.55' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:20:00',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:20:00', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '225.00', productSellHalfPrice = '235.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1148.55',meanbuyprice_withDiscount = '1148.55' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:20:07',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:20:07', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '225.00', productSellUnitPrice = '255.00', productSellHalfPrice = '235.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1148.55',meanbuyprice_withDiscount = '1148.55' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:20:14',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:20:14', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '220.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1148.55',meanbuyprice_withDiscount = '1148.55' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:21:11',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:21:11', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '220.00', productSellUnitPrice = '220.00', productSellHalfPrice = '230.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1148.55',meanbuyprice_withDiscount = '1148.55' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:21:20',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:21:20', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '220.00', productSellUnitPrice = '250.00', productSellHalfPrice = '230.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00127',type ='0', expireDate = '0' , dailyentryId = '127',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '1148.55',meanbuyprice_withDiscount = '1148.55' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '127';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (127, 1,'2021-11-13 14:21:24',1)
                ON DUPLICATE KEY UPDATE productid = 127, edited = 1, sysdate = '2021-11-13 14:21:24', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:54:39";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:24:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 14:24:39', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:55:37";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:25:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:25:37', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:56:48";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:26:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:26:48', '1', 'add', '41.238.108.117', '', 'DESKTOP');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('812','','2','210','220', '250','230', '2021-11-13', '0', '1', '100', '', '0', '0', '0', '0', '0', '210','210','210','210','210','0','4.76','9.52','19.05','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '812', productDescription = '', productCatId = '2', productBuyPrice = '210', productSellAllPrice = '220', productSellUnitPrice = '250', productSellHalfPrice = '230', productDate = '2021-11-13', conditions = '0', userId = '1', limitamount = '100', parcode = '00554',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210',lastbuyprice_withDiscount = '210',meanbuyprice = '210',meanbuyprice_withDiscount = '210' , productbuypricereal = '210' , buypricereal_precentage = '0' , buytotal_precentage = '4.76' , buyhalf_precentage = '9.52' , buypart_precentage = '19.05',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '554';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '554', '1', '2021-11-13', '1', '0','0055401','220','230','250','210');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('554', '1', '0', '1', '2021-11-13');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('554', '1', '0', '0', '554', 'إضافة منتج', 'productController.php', '0', '0', '1', '2021-11-13','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (554, 1,'2021-11-13 14:26:48',1)
                ON DUPLICATE KEY UPDATE productid = 554, edited = 1, sysdate = '2021-11-13 14:26:48', userid = 1;
UPDATE product SET productName = '812', productDescription = '', productCatId = '2', productBuyPrice = '210.00', productSellAllPrice = '220.00', productSellUnitPrice = '250.00', productSellHalfPrice = '230.00', productDate = '2021-11-13', conditions = '0', userId = '1', limitamount = '100', parcode = '00554',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210',lastbuyprice_withDiscount = '210',meanbuyprice = '210',meanbuyprice_withDiscount = '210' , productbuypricereal = '210' , buypricereal_precentage = '0' , buytotal_precentage = '4.76' , buyhalf_precentage = '9.52' , buypart_precentage = '19.05',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '554';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:56:51";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:26:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:26:52', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 10:56:52";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:26:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 14:26:53', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:00:04";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:30:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:30:05', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:00:23";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:30:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:30:24', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:01:01";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:31:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:31:01', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:01:58";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:31:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:31:58', '1', 'update', '41.238.108.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 465;
UPDATE productunit SET unitid = '1', productid = '465', productnumber = '1.00', productunitdate = '2021-11-13', userid = '1', conditions = '0',proUnitParcode='0046501',proUnitSellAllPrice='220',proUnitSellHalfPrice='250',proUnitSellUnitPrice ='250',proUnitBuyPrice='210' WHERE productunitid = '465';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (465, 1,'2021-11-13 14:31:59',1)
                ON DUPLICATE KEY UPDATE productid = 465, edited = 1, sysdate = '2021-11-13 14:31:59', userid = 1;
UPDATE product SET productName = 'قطيفه812', productDescription = '', productCatId = '1', productBuyPrice = '210', productSellAllPrice = '220', productSellUnitPrice = '250', productSellHalfPrice = '250', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00465',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '465';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:02:03";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:32:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:32:03', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:02:47";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:32:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:32:47', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE product SET productName = 'قطيفه812', productDescription = '', productCatId = '1', productBuyPrice = '210.00', productSellAllPrice = '220.00', productSellUnitPrice = '250.00', productSellHalfPrice = '230.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00465',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '465';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (465, 1,'2021-11-13 14:33:04',1)
                ON DUPLICATE KEY UPDATE productid = 465, edited = 1, sysdate = '2021-11-13 14:33:04', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:03:20";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:33:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:33:20', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:03:51";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:33:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:33:51', '1', 'update', '41.238.108.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 465;
UPDATE productunit SET unitid = '1', productid = '465', productnumber = '1.00', productunitdate = '2021-11-13', userid = '1', conditions = '0',proUnitParcode='0046501',proUnitSellAllPrice='220',proUnitSellHalfPrice='250',proUnitSellUnitPrice ='250',proUnitBuyPrice='210' WHERE productunitid = '465';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (465, 1,'2021-11-13 14:33:51',1)
                ON DUPLICATE KEY UPDATE productid = 465, edited = 1, sysdate = '2021-11-13 14:33:51', userid = 1;
UPDATE product SET productName = 'قطيفه812', productDescription = '', productCatId = '1', productBuyPrice = '210', productSellAllPrice = '220', productSellUnitPrice = '210', productSellHalfPrice = '230', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00465',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '465';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:03:56";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:33:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:33:56', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:04:06";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:34:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:34:08', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:04:18";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:34:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:34:18', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:04:47";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:34:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:34:47', '1', 'update', '41.238.108.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 465;
UPDATE productunit SET unitid = '1', productid = '465', productnumber = '1.00', productunitdate = '2021-11-13', userid = '1', conditions = '0',proUnitParcode='0046501',proUnitSellAllPrice='220',proUnitSellHalfPrice='250',proUnitSellUnitPrice ='250',proUnitBuyPrice='210' WHERE productunitid = '465';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (465, 1,'2021-11-13 14:34:47',1)
                ON DUPLICATE KEY UPDATE productid = 465, edited = 1, sysdate = '2021-11-13 14:34:47', userid = 1;
UPDATE product SET productName = 'قطيفه812', productDescription = '', productCatId = '1', productBuyPrice = '210', productSellAllPrice = '220', productSellUnitPrice = '250', productSellHalfPrice = '230', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00465',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '210.00',lastbuyprice_withDiscount = '210',meanbuyprice = '210.00',meanbuyprice_withDiscount = '210' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '0' , buypart_precentage = '19.05',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '465';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:04:50";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:34:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 14:34:50', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:04:52";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:34:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 14:34:52', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:06:34";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:36:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 14:36:34', '1', 'add', '41.238.108.117', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(22,1,2,465,18,'2021-11-13',1,0, '' ,0,0,0,0,0,'2021-11-13 14:36:34',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '-18', userid = '1', storedetaildate = '2021-11-13' WHERE storedetailid = '465';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-13', 1, 465, 0, 0
                    , 210.00, -18, 0, 0, 1, '2021-11-13 14:36:34')
                ON DUPLICATE KEY UPDATE buyprice = 210.00,
                        buyQuantity =buyQuantity+-18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2021-11-13 14:36:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2021-11-13*210.00," WHERE transferproductid = 915;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('465', '1', '18', '1', '915', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-18', '1', '2021-11-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('465', '2', '18', '1', '2021-11-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-13', 2, 465, 0, 0
                    , 210.00, 18, 0, 0, 1, '2021-11-13 14:36:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2021-11-13 14:36:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('465', '2', '18', '0', '915', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '18', '1', '2021-11-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:06:35";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:36:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 14:36:35', '1', 'sucess', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:06:38";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:36:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 14:36:38', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 11:07:06";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 14:37:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 14:37:06', '1', 'editorder', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 12:41:52";
UPDATE user SET loginip = "41.44.122.147", lastactivetime = "2021-11-13 16:11:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 16:11:52', '4', 'addsellBill', '41.44.122.147', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:18:38";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:18:55";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:48:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 16:48:55', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:18:55";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:19:07";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:49:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 16:49:07', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:20:18";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:50:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 16:50:18', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:22:13";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:52:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('usergroupController.php', '2021-11-13 16:52:13', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:24:35";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:54:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 16:54:35', '1', 'addsellBill', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:24:53";
UPDATE user SET loginip = "41.36.8.178", lastactivetime = "2021-11-13 16:54:53", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-13 16:54:53', '4', 'addsellBill', '41.36.8.178', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:25:09";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:55:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 16:55:09', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:26:14";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:56:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 16:56:14', '1', 'add', '41.238.108.117', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(23,2,7,465,1,'2021-11-13',1,0, '' ,0,0,0,0,0,'2021-11-13 16:56:14',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2021-11-13' WHERE storedetailid = '1466';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-13', 2, 465, 0, 0
                    , 210.00, 1, 0, 0, 1, '2021-11-13 16:56:14')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2021-11-13 16:56:14' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2021-11-13*210.00," WHERE transferproductid = 916;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('465', '2', '1', '1', '916', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '17', '1', '2021-11-13','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('465', '7', '1', '1', '2021-11-13');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-13', 7, 465, 0, 0
                    , 210.00, 1, 0, 0, 1, '2021-11-13 16:56:14')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2021-11-13 16:56:14' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('465', '7', '1', '0', '916', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2021-11-13','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:26:15";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:56:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 16:56:15', '1', 'sucess', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:26:20";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:56:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 16:56:20', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:26:27";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:56:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 16:56:27', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:26:46";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:56:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 16:56:46', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:28:31";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:58:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 16:58:31', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:28:51";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:58:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 16:58:51', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:29:11";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:59:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 16:59:11', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:29:41";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 16:59:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 16:59:41', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:30:03";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:00:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 17:00:03', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:30:14";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:00:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:00:14', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:30:59";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:00:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:00:59', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:31:42";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:01:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('supplierReportsController.php', '2021-11-13 17:01:43', '1', 'all', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:33:01";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:03:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:03:01', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:33:31";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:03:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:03:31', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:34:35";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:04:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 17:04:35', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:35:02";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:05:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 17:05:02', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '265.00', productSellUnitPrice = '265.00', productSellHalfPrice = '265.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '225.00',meanbuyprice_withDiscount = '225' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:05:28',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:05:28', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '265.00', productSellUnitPrice = '265.00', productSellHalfPrice = '275.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '225.00',meanbuyprice_withDiscount = '225' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:05:35',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:05:35', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '265.00', productSellUnitPrice = '295.00', productSellHalfPrice = '275.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '225.00',meanbuyprice_withDiscount = '225' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:05:47',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:05:47', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '265.00', productSellUnitPrice = '295.00', productSellHalfPrice = '275.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '225.00',meanbuyprice_withDiscount = '225' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:11:11',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:11:11', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '265.00', productSellUnitPrice = '295.00', productSellHalfPrice = '275.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '225.00',meanbuyprice_withDiscount = '225' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:16:06',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:16:06', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '', productSellAllPrice = '265.00', productSellUnitPrice = '295.00', productSellHalfPrice = '275.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '112.5',meanbuyprice_withDiscount = '112.5' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:17:41',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:17:41', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '0.00', productSellAllPrice = '', productSellUnitPrice = '', productSellHalfPrice = '', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '112.50',meanbuyprice_withDiscount = '112.5' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:17:43',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:17:43', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '0.00', productSellAllPrice = '0.00', productSellUnitPrice = '0.00', productSellHalfPrice = '', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '112.50',meanbuyprice_withDiscount = '112.5' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:17:43',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:17:43', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225', productSellAllPrice = '0.00', productSellUnitPrice = '0.00', productSellHalfPrice = '0.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '168.75',meanbuyprice_withDiscount = '168.75' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:17:45',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:17:45', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '0.00', productSellUnitPrice = '295', productSellHalfPrice = '0.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '168.75',meanbuyprice_withDiscount = '168.75' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:17:45',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:17:45', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '265', productSellUnitPrice = '265', productSellHalfPrice = '265', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '168.75',meanbuyprice_withDiscount = '168.75' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:17:45',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:17:45', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '265.00', productSellUnitPrice = '265.00', productSellHalfPrice = '275', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '168.75',meanbuyprice_withDiscount = '168.75' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:17:45',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:17:45', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '450', productSellAllPrice = '265.00', productSellUnitPrice = '265.00', productSellHalfPrice = '275.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '309.38',meanbuyprice_withDiscount = '309.38' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:26:26',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:26:26', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '450.00', productSellAllPrice = '265.00', productSellUnitPrice = '265.00', productSellHalfPrice = '550', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '309.38',meanbuyprice_withDiscount = '309.38' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:26:26',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:26:26', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '450.00', productSellAllPrice = '530', productSellUnitPrice = '530', productSellHalfPrice = '530', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '309.38',meanbuyprice_withDiscount = '309.38' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:26:27',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:26:27', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '450.00', productSellAllPrice = '530.00', productSellUnitPrice = '590', productSellHalfPrice = '530.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '309.38',meanbuyprice_withDiscount = '309.38' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:26:27',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:26:27', userid = 1;
UPDATE user SET loginip = "" WHERE userid = 1;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:56:48";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:26:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 17:26:48', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:56:49";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 13:56:59";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:26:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 17:26:59', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:04:10";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:34:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-13 17:34:11', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:05:36";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:35:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:35:36', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:05:55";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:35:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 17:35:55', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:09:07";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:39:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 17:39:07', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:09:35";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:39:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 17:39:35', '1', 'showNew', '41.238.108.117', '', 'DESKTOP');
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '0.00', productSellAllPrice = '530.00', productSellUnitPrice = '590.00', productSellHalfPrice = '530.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '154.69',meanbuyprice_withDiscount = '154.69' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:39:49',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:39:49', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '0.00', productSellAllPrice = '0.00', productSellUnitPrice = '0.00', productSellHalfPrice = '0.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '154.69',meanbuyprice_withDiscount = '154.69' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:39:56',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:39:56', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '0.00', productSellAllPrice = '0.00', productSellUnitPrice = '0.00', productSellHalfPrice = '0.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '154.69',meanbuyprice_withDiscount = '154.69' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:39:57',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:39:57', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225', productSellAllPrice = '0.00', productSellUnitPrice = '0.00', productSellHalfPrice = '0.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '189.85',meanbuyprice_withDiscount = '189.85' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:40:56',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:40:56', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '0.00', productSellUnitPrice = '0.00', productSellHalfPrice = '275', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '189.85',meanbuyprice_withDiscount = '189.85' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:40:56',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:40:56', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '0.00', productSellUnitPrice = '295', productSellHalfPrice = '275.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '189.85',meanbuyprice_withDiscount = '189.85' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:40:56',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:40:56', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225.00', productSellAllPrice = '265', productSellUnitPrice = '265', productSellHalfPrice = '265', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '253',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '189.85',meanbuyprice_withDiscount = '189.85' , productbuypricereal = '0.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '0.00' , buypart_precentage = '0.00',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-13 17:40:56',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-13 17:40:56', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:11:43";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:41:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:41:43', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:12:13";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:42:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:42:13', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:12:19";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:42:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:42:19', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:12:20";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:42:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:42:20', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:12:20";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:42:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:42:20', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:12:20";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:42:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:42:20', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:12:21";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:42:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:42:21', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:12:36";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:42:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:42:36', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:14:07";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:44:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:44:07', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:14:54";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:44:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 17:44:54', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:18:10";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:48:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 17:48:10', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:18:40";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:48:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 17:48:40', '1', 'add', '41.238.108.117', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =97
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(16,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '88220.8' , clientdate = '2021-11-13 17:48:40', userid = '1' WHERE clientid = '16';
UPDATE client SET  inUse = 0 where clientid = 16;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('16','86370.80','-1850','1','ايصال تحصيل (( قبض من عميل ))','97', '88220.8', '2021-11-13 17:48:10', '1', 'clientPayedDeptController.php', '   ', '-1850', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '24150',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('26000.00','-1850', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '97', '24150', '2021-11-13 17:48:40', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '-1850', '-1850', '2021-11-13', '1', '0', '0', '2021-11-13 17:48:40','اضافة ايصال سداد للعميل ميدو','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('642', '54', '-1850', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '24150', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('642', '69', '-1850', '','0');
UPDATE accountstree SET name = 'ميدو', customName = 'ميدو', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-8150', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '69';
UPDATE clientdebtchange SET clientid = '16', clientdebtchangebefore = '86370.80', clientdebtchangeamount = '-1850.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '97', clientdebtchangeafter = '88220.80', clientdebtchangedate = '2021-11-13 17:48:10', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '-1850.00',discount='', reciptid=null, dailyentryid = '642',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '97';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =97 -clientdebtchangeId = 97
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:18:40";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:48:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 17:48:40', '1', 'sucess', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 14:18:42";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 17:48:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 17:48:42', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:21:45";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 18:51:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientdebt.php', '2021-11-13 18:51:45', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:21:47";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 18:51:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientdebt.php', '2021-11-13 18:51:47', '1', 'showallajax', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:33:32";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:03:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 19:03:32', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:34:13";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:04:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2021-11-13 19:04:13', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:35:12";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:05:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2021-11-13 19:05:12', '1', 'add', '41.238.108.117', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2021-11-13' WHERE storedetailid = '1467';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('465', '7', '17', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '1.00', '18', '1', '2021-11-13','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:35:14";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:05:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2021-11-13 19:05:14', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:37:19";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:07:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('menuurController.php', '2021-11-13 19:07:19', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:37:48";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:07:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('usergroupController.php', '2021-11-13 19:07:49', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:37:58";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:07:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('usergroupController.php', '2021-11-13 19:07:58', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:39:03";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:09:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('branchesController.php', '2021-11-13 19:09:03', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:39:28";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:09:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2021-11-13 19:09:28', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:39:56";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:09:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2021-11-13 19:09:56', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:40:23";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:10:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2021-11-13 19:10:23', '1', 'edit', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 15:40:33";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:10:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2021-11-13 19:10:33', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:14:53";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:44:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 19:44:53', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:14:53";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:20:44";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:50:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 19:50:44', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:21:25";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:51:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientController.php', '2021-11-13 19:51:25', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:22:09";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:52:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientController.php', '2021-11-13 19:52:09', '1', 'add', '41.238.108.117', '', 'DESKTOP');
INSERT INTO client (clientname, clientaddress, clientphone, clientmobile, clientdebt, clientdetails, conditions, clientdate, userid,clientareaid,clientcode,dailyentryid ,rondomtxt,clientStoreIds,obygyPatientId,debtLimit,typeclientid,priceTypeId,card_number,file_faida,specialDiscount,specialDiscountVal,file,addDate,mandobCollectRatio,webApiId,clientRFID,linkedSupplierId,postponeDays,studentid) VALUES ('ايمن الكاشف طنطا' , 'طنطا', '', '', '22000', '', '0', '2021-11-13 19:52:09', '1', '0','','0','','-10','0','10000',',-20,','-1','0','','0','0','.','2021-11-13','0','0','','0','0','0');
INSERT INTO tamweenclientdetail (clientid, noOfPersonsTamween, noOfPersonsDa3m, cardNum, cardPassword) VALUES ('84', '0', '0', '', '');
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('84','0','22000','0','إضافة عميل جديد','84', '22000', '2021-11-13 19:52:09', '0', 'clientController.php', '', '22000', '0', null, '0', null, null,'', '0','1','1','22000','1');
INSERT INTO accountstree (name, customName, parent, itemtype, itemfrom, notes, del, userid, mydate, itemtype2, theValue, theOrder, layingOrder,reportid) VALUES ('ايمن الكاشف طنطا', 'ايمن الكاشف طنطا', '23', '3', '0', '', '0', '1', '2021-11-13', '1', '0', '0', '','2');
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '22000', '22000', '2021-11-13', '1', '0', '0', '2021-11-13 19:52:09','تم اضافة عميل ايمن الكاشف طنطا','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('643', '158', '22000', '','0');
UPDATE accountstree SET name = 'ايمن الكاشف طنطا', customName = 'ايمن الكاشف طنطا', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-13', itemtype2 = '1', theValue = '22000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '158';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('643', '7', '22000', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '6402545.8', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
COMMIT;
UPDATE client SET clientname = 'ايمن الكاشف طنطا', clientaddress = 'طنطا', clientphone = '', clientmobile = '', clientdebt = '22000.00', clientdetails = '', conditions = '0', clientdate = '2021-11-13', userid = '1'  , clientareaid = '0'  ,clientcode = '',dailyentryid = '643' , rondomtxt = '',clientStoreIds = '-10', obygyPatientId = '0' , debtLimit='10000' , typeclientid=',-20,',priceTypeId='-1',lastEditUser = '0',card_number = '0',file_faida = '',specialDiscount = '0',specialDiscountVal = '0',file = '.',mandobCollectRatio='0',clientRFID = '',linkedSupplierId = '0',postponeDays='0', studentid='0' WHERE clientid = '84';
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:22:10";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:52:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientController.php', '2021-11-13 19:52:10', '1', 'sucess', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:22:12";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:52:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientController.php', '2021-11-13 19:52:12', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:22:18";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:52:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 19:52:18', '1', '', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:22:37";
UPDATE user SET loginip = "41.238.108.117", lastactivetime = "2021-11-13 19:52:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 19:52:37', '1', 'show', '41.238.108.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:29:56";
UPDATE user SET loginip = "102.43.134.221", lastactivetime = "2021-11-13 19:59:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 19:59:56', '1', '', '102.43.134.221', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:30:21";
UPDATE user SET loginip = "102.43.134.221", lastactivetime = "2021-11-13 20:00:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 20:00:21', '1', 'show', '102.43.134.221', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:30:29";
UPDATE user SET loginip = "102.43.134.221", lastactivetime = "2021-11-13 20:00:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 20:00:29', '1', '', '102.43.134.221', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:30:37";
UPDATE user SET loginip = "102.43.134.221", lastactivetime = "2021-11-13 20:00:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 20:00:37', '1', 'show', '102.43.134.221', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:45:04";
UPDATE user SET loginip = "102.43.134.221", lastactivetime = "2021-11-13 20:15:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 20:15:04', '1', '', '102.43.134.221', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:45:46";
UPDATE user SET loginip = "102.43.134.221", lastactivetime = "2021-11-13 20:15:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 20:15:47', '1', 'add', '102.43.134.221', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =99
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(16,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '88240.8' , clientdate = '2021-11-13 20:15:47', userid = '1' WHERE clientid = '16';
UPDATE client SET  inUse = 0 where clientid = 16;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('16','88220.80','-20','1','ايصال تحصيل (( قبض من عميل ))','99', '88240.8', '2021-11-13 20:15:04', '1', 'clientPayedDeptController.php', '   ', '-20', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '24130',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('24150.00','-20', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '99', '24130', '2021-11-13 20:15:47', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '-20', '-20', '2021-11-13', '1', '0', '0', '2021-11-13 20:15:47','اضافة ايصال سداد للعميل ميدو','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('644', '54', '-20', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '24130', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('644', '69', '-20', '','0');
UPDATE accountstree SET name = 'ميدو', customName = 'ميدو', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-8130', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '69';
UPDATE clientdebtchange SET clientid = '16', clientdebtchangebefore = '88220.80', clientdebtchangeamount = '-20.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '99', clientdebtchangeafter = '88240.80', clientdebtchangedate = '2021-11-13 20:15:04', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '-20.00',discount='', reciptid=null, dailyentryid = '644',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '99';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =99 -clientdebtchangeId = 99
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:45:47";
UPDATE user SET loginip = "102.43.134.221", lastactivetime = "2021-11-13 20:15:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 20:15:47', '1', 'sucess', '102.43.134.221', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 16:45:49";
UPDATE user SET loginip = "102.43.134.221", lastactivetime = "2021-11-13 20:15:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-13 20:15:49', '1', 'show', '102.43.134.221', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:24:21";
UPDATE user SET loginip = "197.56.253.124", lastactivetime = "2021-11-13 20:54:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-13 20:54:22', '1', '', '197.56.253.124', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:24:22";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:24:28";
UPDATE user SET loginip = "197.56.253.124", lastactivetime = "2021-11-13 20:54:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 20:54:28', '1', '', '197.56.253.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:26:53";
UPDATE user SET loginip = "197.56.253.124", lastactivetime = "2021-11-13 20:56:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 20:56:53', '1', 'add', '197.56.253.124', '', 'DESKTOP');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('تايجر816','','1','195','230', '260','240', '2021-11-13', '0', '1', '0', '', '0', '0', '0', '0', '0', '195','195','195','195','195','0','17.95','23.08','33.33','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'تايجر816', productDescription = '', productCatId = '1', productBuyPrice = '195', productSellAllPrice = '230', productSellUnitPrice = '260', productSellHalfPrice = '240', productDate = '2021-11-13', conditions = '0', userId = '1', limitamount = '0', parcode = '00555',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195',lastbuyprice_withDiscount = '195',meanbuyprice = '195',meanbuyprice_withDiscount = '195' , productbuypricereal = '195' , buypricereal_precentage = '0' , buytotal_precentage = '17.95' , buyhalf_precentage = '23.08' , buypart_precentage = '33.33',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '555';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '555', '1', '2021-11-13', '1', '0','0055501','230','240','260','195');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('555', '1', '160', '1', '2021-11-13');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('555', '1', '160', '0', '555', 'إضافة منتج', 'productController.php', '0', '160', '1', '2021-11-13','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (555, 1,'2021-11-13 20:56:54',1)
                ON DUPLICATE KEY UPDATE productid = 555, edited = 1, sysdate = '2021-11-13 20:56:54', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '31200', '31200', '2021-11-13', '1', '0', '0', '2021-11-13 20:56:54','إضافة منتج تايجر816 الكمية 160','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('645', '19', '31200', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '5578800', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('645', '7', '31200', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '6433745.8', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'تايجر816', productDescription = '', productCatId = '1', productBuyPrice = '195.00', productSellAllPrice = '230.00', productSellUnitPrice = '260.00', productSellHalfPrice = '240.00', productDate = '2021-11-13', conditions = '0', userId = '1', limitamount = '0', parcode = '00555',type ='0', expireDate = '0' , dailyentryId = '645',isService = '0',isOptic = '0',lastbuyprice = '195',lastbuyprice_withDiscount = '195',meanbuyprice = '195',meanbuyprice_withDiscount = '195' , productbuypricereal = '195' , buypricereal_precentage = '0' , buytotal_precentage = '17.95' , buyhalf_precentage = '23.08' , buypart_precentage = '33.33',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '555';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('سويد815','','1','195','240', '270','250', '2021-11-13', '0', '1', '0', '', '0', '0', '0', '0', '0', '195','195','195','195','195','0','23.08','28.21','38.46','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'سويد815', productDescription = '', productCatId = '1', productBuyPrice = '195', productSellAllPrice = '240', productSellUnitPrice = '270', productSellHalfPrice = '250', productDate = '2021-11-13', conditions = '0', userId = '1', limitamount = '0', parcode = '00556',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '195',lastbuyprice_withDiscount = '195',meanbuyprice = '195',meanbuyprice_withDiscount = '195' , productbuypricereal = '195' , buypricereal_precentage = '0' , buytotal_precentage = '23.08' , buyhalf_precentage = '28.21' , buypart_precentage = '38.46',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '556';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '556', '1', '2021-11-13', '1', '0','0055601','240','250','270','195');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('556', '1', '105', '1', '2021-11-13');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('556', '1', '105', '0', '556', 'إضافة منتج', 'productController.php', '0', '105', '1', '2021-11-13','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (556, 1,'2021-11-13 20:56:54',1)
                ON DUPLICATE KEY UPDATE productid = 556, edited = 1, sysdate = '2021-11-13 20:56:54', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20475', '20475', '2021-11-13', '1', '0', '0', '2021-11-13 20:56:54','إضافة منتج سويد815 الكمية 105','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('646', '19', '20475', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '5599275', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('646', '7', '20475', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '6454220.8', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'سويد815', productDescription = '', productCatId = '1', productBuyPrice = '195.00', productSellAllPrice = '240.00', productSellUnitPrice = '270.00', productSellHalfPrice = '250.00', productDate = '2021-11-13', conditions = '0', userId = '1', limitamount = '0', parcode = '00556',type ='0', expireDate = '0' , dailyentryId = '646',isService = '0',isOptic = '0',lastbuyprice = '195',lastbuyprice_withDiscount = '195',meanbuyprice = '195',meanbuyprice_withDiscount = '195' , productbuypricereal = '195' , buypricereal_precentage = '0' , buytotal_precentage = '23.08' , buyhalf_precentage = '28.21' , buypart_precentage = '38.46',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '556';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:26:56";
UPDATE user SET loginip = "197.56.253.124", lastactivetime = "2021-11-13 20:56:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-13 20:56:56', '1', '', '197.56.253.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:27:20";
UPDATE user SET loginip = "197.56.253.124", lastactivetime = "2021-11-13 20:57:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-13 20:57:20', '1', '', '197.56.253.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:27:41";
UPDATE user SET loginip = "197.56.253.124", lastactivetime = "2021-11-13 20:57:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-13 20:57:41', '1', '', '197.56.253.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:58:58";
UPDATE user SET loginip = "197.56.253.124", lastactivetime = "2021-11-13 21:28:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 21:28:58', '1', '', '197.56.253.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-13 17:59:11";
UPDATE user SET loginip = "197.56.253.124", lastactivetime = "2021-11-13 21:29:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-13 21:29:11', '1', 'show', '197.56.253.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
