UPDATE user SET loginip = "" WHERE userid = 3;
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-16 07:19:48";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:49:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 10:49:48', '1', '', '197.56.63.80', '', '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-16',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-16 07:19: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-16 07:19:57";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:49:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 10:49:57', '1', '', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:20:17";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:50:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 10:50:18', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:21:16";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:51:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 10:51:16', '1', 'addsellBill', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:22:01";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:52:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 10:52:01', '1', '', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:22:30";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:52:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 10:52:30', '1', 'addsellBill', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:23:49";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:53:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 10:53:49', '1', '', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:24:03";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:54:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 10:54:03', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:24:50";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:54:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 10:54:50', '1', 'addsellBill', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:26:30";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:56:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 10:56:30', '1', 'addAndRetuen', '197.56.63.80', '', '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

;

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0619371dad28d0
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(13,@clientdebt,@clientname);
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2021-11-16 10:54:50', '0619371dad28d0', '13', '28570.00', '23630', '0', '1', '4940', '4940', '0', '-4940', '1', '2021-11-16 10:56:30', '', '1', '0', 'سنتر المجد','1', '1', '5', '0', 'سنتر المجد', '19', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '23630', userid = '1' WHERE clientid = '13';
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 ('13','28570.00','4940','1','اضافة فاتورة مردوات مبيعات','2', '23630', '2021-11-16 10:56:30', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '4940', '0', null, '0', null, null,'', '0','1','1','4940','1');
UPDATE client SET  inUse = 0 where clientid = 13;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('210.00', '00518', '2', '1', '518', '19', '260', '4940', '0', '', '1', '0', '518', '0.00', '0','1','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where returnsellbilldetailid = 3;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (518, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4940, 3990, 3990, 3990
                    , 3990, 3990, 0, 0, 19)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4940, returnSellCostBuyPrice = returnSellCostBuyPrice+3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3990
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+19;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4940, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4940, returnSellCostBuyPrice = returnSellCostBuyPrice+3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2021-11-16 10:56:30' WHERE storedetailid = '518';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '1', '19', '0', '2', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '19', '1', '2021-11-16 10:56:30','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4940, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4940, returnSellCostBuyPrice = returnSellCostBuyPrice+3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (13, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4940, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4940, returnSellCostBuyPrice = returnSellCostBuyPrice+3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -4940, -3990, -3990
                    , -3990, -3990, -3990, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-4940, netSellCostBuyPrice = netSellCostBuyPrice+-3990
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-3990
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-3990
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-3990
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-3990
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0619371dad28d0 and sellbillId = 2 and returnsellbillId = 2
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:26:30";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 10:56:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 10:56:31', '1', 'addsellBill', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:33:06";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:03:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 11:03:06', '1', '', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:33:17";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:03:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 11:03:17', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:56:28";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:26:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2021-11-16 11:26:28', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:57:06";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:27:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2021-11-16 11:27:06', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:57:18";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:27:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2021-11-16 11:27:19', '1', 'edit', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:57:43";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:27:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2021-11-16 11:27:43', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:58:06";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:28:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 11:28:06', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:58:50";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:28:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2021-11-16 11:28:50', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:59:06";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:29:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2021-11-16 11:29:06', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:59:16";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:29:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 11:29:16', '1', 'editreturnsellBill', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:59:30";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:29:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 11:29:31', '1', 'update', '197.56.63.80', '', 'DESKTOP');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 2 and  = returnsellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 2 and controlname = returnsellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 1) and  modelid = 2;
UPDATE returnsellbill SET returnsellbillsysdate = '2021-11-16', userid = '1',delbyuserid = '1', conditions = '1'  WHERE returnsellbillid = '2';
UPDATE returnsellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where returnsellbilldetailid = 3;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (518, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4940, 3990, 3990, 3990
                    , 3990, 3990, 0,0,19)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-0, sellCostBuyPrice =sellCostBuyPrice-0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-0, sellCostMeanBuyPrice = sellCostMeanBuyPrice-0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-4940, returnSellCostBuyPrice = returnSellCostBuyPrice-3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-3990
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-0
                        , netQuantityRet = netQuantityRet-19;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4940, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-0, sellCostBuyPrice =sellCostBuyPrice-0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-0, sellCostMeanBuyPrice = sellCostMeanBuyPrice-0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-4940, returnSellCostBuyPrice = returnSellCostBuyPrice-3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2021-11-16 11:29:31' WHERE storedetailid = '518';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '1', '19', '1', '2', 'تعديل فاتورة مردودات مبيعات', 'returnsellbillController.php', '19.00', '0', '1', '2021-11-16 10:54:50','0','0');
CALL clientInUse(13,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '28570', userid = '1' WHERE clientid = '13';
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 ('13','23630.00','4940','0','تعديل فاتورة مردودات مبيعات','2', '28570', '2021-11-16 10:54:50', '1', 'returnsellbillController.php', 'تعديل فاتورة مردودات مبيعات', '4940', '0', null, '0', null, null,'', '0','1','1','4940','1');
UPDATE client SET  inUse = 0 where clientid = 13;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4940, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-0, sellCostBuyPrice =sellCostBuyPrice-0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-0, sellCostMeanBuyPrice = sellCostMeanBuyPrice-0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-4940, returnSellCostBuyPrice = returnSellCostBuyPrice-3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (13, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4940, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-0, sellCostBuyPrice =sellCostBuyPrice-0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-0, sellCostMeanBuyPrice = sellCostMeanBuyPrice-0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-4940, returnSellCostBuyPrice = returnSellCostBuyPrice-3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -4940, -3990, -3990
                    , -3990, -3990, -3990, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal--4940, netSellCostBuyPrice = netSellCostBuyPrice--3990
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice--3990
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice--3990
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount--3990
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount--3990
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-0;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 2 and controlname = returnsellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 2 and controlname = returnsellbillController
-- ----------------------------------------------------------------------------------------------------

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

;
CALL clientInUse(13,@clientdebt,@clientname);
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2021-11-16 10:54:50', '0619371dad28d0', '13', '28570.00', '24390', '0', '1', '4180', '4180', '0', '-4180', '1', '2021-11-16 10:54:50', '', '1', '0','سنتر المجد', '1', '1', '5', '0', 'سنتر المجد', '19', '2', 'returnsellbillController', '0' ,'','','','','-1','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '24390', userid = '1' WHERE clientid = '13';
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 ('13','28570.00','4180','1','اضافة فاتورة مردوات مبيعات (معدله)','3', '24390', '2021-11-16 11:29:31', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات (معدله)', '4180', '0', null, '0', null, null,'', '0','1','1','1','1');
UPDATE client SET  inUse = 0 where clientid = 13;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('210.00', '00518', '3', '1', '518', '19.00', '220.00', '4180', '0', '', '1', '0.00', '518', '0.00', '0','1','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 210.00 , meanbuyprice = 210.00, lastbuyprice_withDiscount = 210.00, meanbuyprice_withDiscount = 210.00
                where returnsellbilldetailid = 4;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (518, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4180, 3990, 3990, 3990
                    , 3990, 3990, 0, 0, 19)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4180, returnSellCostBuyPrice = returnSellCostBuyPrice+3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3990
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+19;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4180, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4180, returnSellCostBuyPrice = returnSellCostBuyPrice+3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2021-11-16 11:29:31' WHERE storedetailid = '518';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('518', '1', '19', '0', '3', 'اضافة فاتورة مردودات مبيعات (معدله)', 'returnsellbillController.php', '0.00', '19', '1', '2021-11-16 11:29:31','0','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '-4180', '-4180', '2021-11-16', '1', '0', '0', '2021-11-16 11:29:31','تم اضافة فاتورة مبيعات ( اجل )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('652', '66', '-4180', '','0');
UPDATE accountstree SET name = 'سنتر المجد', customName = 'سنتر المجد', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-9180', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '66';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('652', '16', '-4180', '','0');
UPDATE accountstree SET name = 'المبيعات', customName = 'المبيعات', parent = '4', itemtype = '2', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '6738', theOrder = '0', layingOrder = '41',reportid = '2' WHERE id = '16';
UPDATE sellbill SET sellbilldate = '2021-11-10 14:43:47', sellbillserial = '0618bbe83ddd00', sellbillclientid = '1', sellbilltotaldeptbefor = '0.00', sellbilltotaldeptafter = '0.00', sellbilldiscount = '0', sellbilldiscounttype = '1', sellbilltotalbill = '440.00', sellbillaftertotalbill = '440.00', sellbilltotalpayed = '440.00', sellbillfinalbill = '0.00', sellbillstoreid = '4', sellbillsysdate = '2021-11-10 14:46:11',comment = '', userid = '6', conditions = '0', sellbillclientname = 'نقدي', sellbillsaveid = '4', sellbildirectpayment = '0', billnameid = '3', sellerid = '0', tempclientName = 'نقدي', sellQuantity = '2.00' , dailyentryid = '652',obygyVisitId = '0',onlineOrderId = '0',delbyuserid = '0',delivery = '0',totalafterdelivery = '0',billReservation='0',billReservationDate='',visaAccountId = '0',cashPayed = '0',visaPayed = '0',isBankAccountTransfer = '0',extraDiscountPer='0',extraDiscountVal='0',taxOfDiscountPer='0',taxOfDiscountVal='0',taxBillNumber='0',collectionType = '0',collectionDate='' WHERE sellbillid = null;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4180, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4180, returnSellCostBuyPrice = returnSellCostBuyPrice+3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (13, '2021-11-16', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4180, 3990, 3990, 3990
                    , 3990, 3990, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4180, returnSellCostBuyPrice = returnSellCostBuyPrice+3990, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+3990
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+3990, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+3990
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+3990
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -4180, -3990, -3990
                    , -3990, -3990, -3990, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-4180, netSellCostBuyPrice = netSellCostBuyPrice+-3990
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-3990
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-3990
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-3990
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-3990
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 2 and newid=3 and controlname = returnsellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 07:59:32";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:29:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2021-11-16 11:29:32', '1', 'editprint', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 08:00:31";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:30:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 11:30:32', '1', '', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 08:00:41";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:30:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2021-11-16 11:30:41', '1', 'show', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 08:05:40";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:35:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 11:35:40', '1', 'addsellBill', '197.56.63.80', '', '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-16 08:12:43";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:42:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 11:42:44', '1', '', '197.56.63.80', '', '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-16 08:12:44";
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-16 08:12:59";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:42:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 11:42:59', '1', 'addsellBill', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 08:14:24";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:44:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 11:44:24', '1', 'addsellBill', '197.56.63.80', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 08:15:04";
UPDATE user SET loginip = "197.56.63.80", lastactivetime = "2021-11-16 11:45:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 11:45:04', '1', 'addsellBill', '197.56.63.80', '', '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-16 09:32:41";
UPDATE user SET loginip = "156.164.153.102", lastactivetime = "2021-11-16 13:02:42", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 13:02:42', '7', '', '156.164.153.102', '', '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-16 09:32:42";
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-16 09:33:22";
UPDATE user SET loginip = "156.164.153.102", lastactivetime = "2021-11-16 13:03:22", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 13:03:22', '7', 'addsellBill', '156.164.153.102', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 09:43:39";
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-16 09:43:49";
UPDATE user SET loginip = "154.180.88.192", lastactivetime = "2021-11-16 13:13:49", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 13:13:49', '5', '', '154.180.88.192', '', '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-16 09:43:50";
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-16 09:44:06";
UPDATE user SET loginip = "154.180.88.192", lastactivetime = "2021-11-16 13:14:06", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 13:14:06', '5', 'addsellBill', '154.180.88.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 09:44:06";
UPDATE user SET loginip = "154.180.88.192", lastactivetime = "2021-11-16 13:14:06", deviceType = "DESKTOP" WHERE userid = 5;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 13:14:06', '5', 'addsellBill', '154.180.88.192', '', '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-16 10:01:03";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 13:31:03", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 13:31:03', '6', '', '102.41.164.81', '', '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-16 10:01:03";
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-16 10:01:13";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 13:31:13", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 13:31:13', '6', '', '102.41.164.81', '', '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-16 10:01:13";
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-16 10:01:29";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 13:31:29", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 13:31:29', '6', 'addsellBill', '102.41.164.81', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 10:02:11";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 13:32:11", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 13:32:11', '6', 'addsellBill', '102.41.164.81', '', '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-16 10:10:59";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 13:40:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 13:40:59', '1', '', '197.56.233.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-16 10:11:00";
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-16 10:11:04";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 13:41:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-16 13:41:04', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 10:11:40";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 13:41:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-16 13:41:40', '1', 'add', '197.56.233.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(27,8,7,556,1,'2021-11-16',1,0, '' ,0,0,0,0,0,'2021-11-16 13:41:40',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2021-11-16' WHERE storedetailid = '1477';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-14', 8, 556, 0, 0
                    , 195.00, 1, 0, 0, 1, '2021-11-16 13:41:40')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2021-11-16 13:41:40' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2021-11-14*195.00," WHERE transferproductid = 923;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('556', '8', '1', '1', '923', 'تحويل منتجات من المخزن', 'storemovementController.php', '16.00', '15', '1', '2021-11-16','0','0');
UPDATE storedetail SET  productquantity = '21', userid = '1', storedetaildate = '2021-11-16' WHERE storedetailid = '1473';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2021-11-14', 7, 556, 0, 0
                    , 195.00, 1, 0, 0, 1, '2021-11-16 13:41:40')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2021-11-16 13:41:40' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('556', '7', '1', '0', '923', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '20.00', '21', '1', '2021-11-16','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 10:11:40";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 13:41:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-16 13:41:41', '1', 'sucess', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 10:11:42";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 13:41:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2021-11-16 13:41:42', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 11:07:24";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 14:37:24", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 14:37:24', '6', '', '102.41.164.81', '', '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-16 11:07:24";
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-16 11:07:27";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 14:37:27", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 14:37:27', '6', 'addsellBill', '102.41.164.81', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 11:07:33";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 14:37:33", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 14:37:33', '6', 'addsellBill', '102.41.164.81', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 11:08:51";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 14:38:51", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 14:38:51', '6', 'addsellBill', '102.41.164.81', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 11:09:33";
UPDATE user SET loginip = "102.41.164.81", lastactivetime = "2021-11-16 14:39:33", deviceType = "DESKTOP" WHERE userid = 6;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 14:39:33', '6', 'addsellBill', '102.41.164.81', '', '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-16 11:38:32";
UPDATE user SET loginip = "41.35.189.5", lastactivetime = "2021-11-16 15:08:32", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 15:08:32', '8', '', '41.35.189.5', '', '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-16 11:38:32";
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

;
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-16 13:34:39";
UPDATE user SET loginip = "156.164.153.102", lastactivetime = "2021-11-16 17:04:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 17:04:39', '7', '', '156.164.153.102', '', '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-16 13:34:39";
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-16 13:35:05";
UPDATE user SET loginip = "156.164.153.102", lastactivetime = "2021-11-16 17:05:05", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 17:05:05', '7', 'addsellBill', '156.164.153.102', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:35:06";
UPDATE user SET loginip = "156.164.153.102", lastactivetime = "2021-11-16 17:05:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 17:05:06', '7', 'addsellBill', '156.164.153.102', '', '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-16 13:45:33";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:15:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 17:15:34', '1', '', '197.56.233.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-16 13:45: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-16 13:45:38";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:15:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:15:38', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:45:43";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:15:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:15:43', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:45:46";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:15:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:15:46', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:45:48";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:15:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:15:48', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:45:53";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:15:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:15:53', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:46:09";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:16:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:16:09', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:46:14";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:16:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:16:15', '1', 'show', '197.56.233.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-16 13:46:30";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:16:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 17:16:31', '1', '', '197.56.233.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-16 13:46:31";
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-16 13:46:38";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:16:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:16:38', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:46:43";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:16:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:16:43', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:46:51";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:16:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:16:51', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:47:01";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:17:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:17:01', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:47:05";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:17:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:17:05', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:47:13";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:17:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productCatController.php', '2021-11-16 17:17:13', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:47:36";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:17:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:17:36', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:47:42";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:17:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:17:42', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE product SET productName = 'قطيفه814', productDescription = '', productCatId = '1', productBuyPrice = '240.00', productSellAllPrice = '250.00', productSellUnitPrice = '280.00', productSellHalfPrice = '280.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00466',type ='0', expireDate = '0' , dailyentryId = '466',isService = '0',isOptic = '0',lastbuyprice = '240.00',lastbuyprice_withDiscount = '240',meanbuyprice = '240.00',meanbuyprice_withDiscount = '240' , 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 = '466';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (466, 1,'2021-11-16 17:19:07',1)
                ON DUPLICATE KEY UPDATE productid = 466, edited = 1, sysdate = '2021-11-16 17:19:07', userid = 1;
UPDATE product SET productName = '814', productDescription = '', productCatId = '1', productBuyPrice = '235.00', productSellAllPrice = '250.00', productSellUnitPrice = '280.00', productSellHalfPrice = '265.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00129',type ='0', expireDate = '0' , dailyentryId = '129',isService = '0',isOptic = '0',lastbuyprice = '235.00',lastbuyprice_withDiscount = '235',meanbuyprice = '235.00',meanbuyprice_withDiscount = '235' , 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 = '129';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (129, 1,'2021-11-16 17:20:38',1)
                ON DUPLICATE KEY UPDATE productid = 129, edited = 1, sysdate = '2021-11-16 17:20:38', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:50:38";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:20:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:20:39', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:51:01";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:21:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:21:01', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 129;
UPDATE productunit SET unitid = '1', productid = '129', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0012901',proUnitSellAllPrice='250',proUnitSellHalfPrice='265',proUnitSellUnitPrice ='280',proUnitBuyPrice='235' WHERE productunitid = '129';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (129, 1,'2021-11-16 17:21:01',1)
                ON DUPLICATE KEY UPDATE productid = 129, edited = 1, sysdate = '2021-11-16 17:21:01', userid = 1;
UPDATE product SET productName = '814', productDescription = '', productCatId = '1', productBuyPrice = '235', productSellAllPrice = '250', productSellUnitPrice = '280', productSellHalfPrice = '260', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00129',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '235.00',lastbuyprice_withDiscount = '235',meanbuyprice = '235.00',meanbuyprice_withDiscount = '235' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '10.64' , buypart_precentage = '0',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '129';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:51:03";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:21:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:21:03', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:51:22";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:21:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:21:23', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE product SET productName = 'كريشه شتوي802', productDescription = '', productCatId = '1', productBuyPrice = '220.00', productSellAllPrice = '230.00', productSellUnitPrice = '270.00', productSellHalfPrice = '240.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00515',type ='0', expireDate = '0' , dailyentryId = '515',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '220.00',meanbuyprice_withDiscount = '220' , 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 = '515';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (515, 1,'2021-11-16 17:22:12',1)
                ON DUPLICATE KEY UPDATE productid = 515, edited = 1, sysdate = '2021-11-16 17:22:12', userid = 1;
UPDATE product SET productName = 'كريشه شتوي802', productDescription = '', productCatId = '1', productBuyPrice = '220.00', productSellAllPrice = '230.00', productSellUnitPrice = '260.00', productSellHalfPrice = '240.00', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00515',type ='0', expireDate = '0' , dailyentryId = '515',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '220.00',meanbuyprice_withDiscount = '220' , 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 = '515';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (515, 1,'2021-11-16 17:22:22',1)
                ON DUPLICATE KEY UPDATE productid = 515, edited = 1, sysdate = '2021-11-16 17:22:22', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:56:26";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:26:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:26:26', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:56:34";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:26:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:26:35', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 515;
UPDATE productunit SET unitid = '1', productid = '515', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0051501',proUnitSellAllPrice='230',proUnitSellHalfPrice='240',proUnitSellUnitPrice ='260',proUnitBuyPrice='220' WHERE productunitid = '515';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (515, 1,'2021-11-16 17:26:35',1)
                ON DUPLICATE KEY UPDATE productid = 515, edited = 1, sysdate = '2021-11-16 17:26:35', userid = 1;
UPDATE product SET productName = 'كريشه شتوي802', productDescription = '', productCatId = '1', productBuyPrice = '220', productSellAllPrice = '230', productSellUnitPrice = '260', productSellHalfPrice = '240', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00515',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '220.00',meanbuyprice_withDiscount = '220' , 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 = '515';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:56:37";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:26:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:26:37', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:56:47";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:26:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:26:47', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:57:07";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:27:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:27:07', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:57:20";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:27:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:27:20', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 516;
UPDATE productunit SET unitid = '1', productid = '516', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0051601',proUnitSellAllPrice='230',proUnitSellHalfPrice='270',proUnitSellUnitPrice ='270',proUnitBuyPrice='220' WHERE productunitid = '516';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (516, 1,'2021-11-16 17:27:20',1)
                ON DUPLICATE KEY UPDATE productid = 516, edited = 1, sysdate = '2021-11-16 17:27:20', userid = 1;
UPDATE product SET productName = 'كريشه شتوي803', productDescription = '', productCatId = '1', productBuyPrice = '220', productSellAllPrice = '230', productSellUnitPrice = '260', productSellHalfPrice = '240', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00516',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '220.00',lastbuyprice_withDiscount = '220',meanbuyprice = '220.00',meanbuyprice_withDiscount = '220' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '9.09' , buypart_precentage = '18.18',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '516';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:57:22";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:27:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:27:22', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:57:34";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:27:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:27:34', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:57:53";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:27:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:27:53', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:58:13";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:28:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:28:13', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 514;
UPDATE productunit SET unitid = '1', productid = '514', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0051401',proUnitSellAllPrice='220',proUnitSellHalfPrice='260',proUnitSellUnitPrice ='260',proUnitBuyPrice='210' WHERE productunitid = '514';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (514, 1,'2021-11-16 17:28:13',1)
                ON DUPLICATE KEY UPDATE productid = 514, edited = 1, sysdate = '2021-11-16 17:28:13', userid = 1;
UPDATE product SET productName = 'كريشه شتوي801', productDescription = '', productCatId = '1', productBuyPrice = '210', productSellAllPrice = '220', productSellUnitPrice = '250', productSellHalfPrice = '230', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00514',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 = '9.52' , 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 = '514';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:58:15";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:28:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:28:15', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:58:24";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:28:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:28:24', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:58:54";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:28:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 17:28:54', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:59:18";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:29:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 17:29:18', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 13:59:40";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:29:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 17:29:40', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:00:31";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:30:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 17:30:31', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:00:42";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:30:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:30:42', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:00:47";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:30:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:30:47', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:01:10";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:31:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:31:10', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:01:24";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:31:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:31:24', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 518;
UPDATE productunit SET unitid = '1', productid = '518', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0051801',proUnitSellAllPrice='220',proUnitSellHalfPrice='260',proUnitSellUnitPrice ='260',proUnitBuyPrice='210' WHERE productunitid = '518';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (518, 1,'2021-11-16 17:31:24',1)
                ON DUPLICATE KEY UPDATE productid = 518, edited = 1, sysdate = '2021-11-16 17:31:24', userid = 1;
UPDATE product SET productName = 'كريشه شتوي805', productDescription = '', productCatId = '1', productBuyPrice = '210', productSellAllPrice = '220', productSellUnitPrice = '250', productSellHalfPrice = '230', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00518',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 = '9.52' , 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 = '518';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:01:26";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:31:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:31:26', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:01:38";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:31:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:31:38', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:02:41";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:32:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:32:41', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:03:28";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:33:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:33:28', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 513;
UPDATE productunit SET unitid = '1', productid = '513', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0051301',proUnitSellAllPrice='220',proUnitSellHalfPrice='260',proUnitSellUnitPrice ='260',proUnitBuyPrice='210' WHERE productunitid = '513';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (513, 1,'2021-11-16 17:33:28',1)
                ON DUPLICATE KEY UPDATE productid = 513, edited = 1, sysdate = '2021-11-16 17:33:28', userid = 1;
UPDATE product SET productName = 'كريشه شتوي800', productDescription = '', productCatId = '1', productBuyPrice = '210', productSellAllPrice = '220', productSellUnitPrice = '250', productSellHalfPrice = '230', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00513',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 = '9.52' , 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 = '513';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:03:31";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:33:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:33:31', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:03:39";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:33:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:33:39', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:04:33";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:34:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:34:34', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:04:47";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:34:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:34:47', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 517;
UPDATE productunit SET unitid = '1', productid = '517', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0051701',proUnitSellAllPrice='220',proUnitSellHalfPrice='260',proUnitSellUnitPrice ='260',proUnitBuyPrice='210' WHERE productunitid = '517';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (517, 1,'2021-11-16 17:34:47',1)
                ON DUPLICATE KEY UPDATE productid = 517, edited = 1, sysdate = '2021-11-16 17:34:47', userid = 1;
UPDATE product SET productName = 'كريشه شتوي804', productDescription = '', productCatId = '1', productBuyPrice = '210', productSellAllPrice = '220', productSellUnitPrice = '250', productSellHalfPrice = '230', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00517',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 = '9.52' , 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 = '517';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:04:49";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:34:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:34:49', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:05:02";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:35:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:35:02', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:06:01";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:36:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:36:01', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:06:18";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:36:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:36:18', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 253;
UPDATE productunit SET unitid = '1', productid = '253', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0025301',proUnitSellAllPrice='265',proUnitSellHalfPrice='265',proUnitSellUnitPrice ='265',proUnitBuyPrice='225' WHERE productunitid = '253';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (253, 1,'2021-11-16 17:36:18',1)
                ON DUPLICATE KEY UPDATE productid = 253, edited = 1, sysdate = '2021-11-16 17:36:18', userid = 1;
UPDATE product SET productName = '3034نواره الشام', productDescription = '', productCatId = '1', productBuyPrice = '225', productSellAllPrice = '265', productSellUnitPrice = '295', productSellHalfPrice = '275', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00253',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '225.00',lastbuyprice_withDiscount = '225',meanbuyprice = '189.85',meanbuyprice_withDiscount = '189.85' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '22.22' , buypart_precentage = '31.11',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '253';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:06:21";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:36:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:36:21', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:06:28";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:36:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:36:28', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:08:00";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:38:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:38:00', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:08:31";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:38:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:38:31', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 120;
UPDATE productunit SET unitid = '1', productid = '120', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0012001',proUnitSellAllPrice='185',proUnitSellHalfPrice='195',proUnitSellUnitPrice ='215',proUnitBuyPrice='175' WHERE productunitid = '120';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (120, 1,'2021-11-16 17:38:31',1)
                ON DUPLICATE KEY UPDATE productid = 120, edited = 1, sysdate = '2021-11-16 17:38:31', userid = 1;
UPDATE product SET productName = '631', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '190', productSellUnitPrice = '220', productSellHalfPrice = '200', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00120',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '175.00',meanbuyprice_withDiscount = '175' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '8.57' , buyhalf_precentage = '14.29' , buypart_precentage = '25.71',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '120';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:08:33";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:38:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:38:33', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:08:39";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:38:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:38:39', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:09:04";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:39:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:39:04', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:09:36";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:39:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:39:36', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 383;
UPDATE productunit SET unitid = '1', productid = '383', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0038301',proUnitSellAllPrice='210',proUnitSellHalfPrice='210',proUnitSellUnitPrice ='250',proUnitBuyPrice='185' WHERE productunitid = '383';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (383, 1,'2021-11-16 17:39:36',1)
                ON DUPLICATE KEY UPDATE productid = 383, edited = 1, sysdate = '2021-11-16 17:39:36', userid = 1;
UPDATE product SET productName = 'ديجيتال 634', productDescription = '', productCatId = '1', productBuyPrice = '185', productSellAllPrice = '200', productSellUnitPrice = '230', productSellHalfPrice = '210', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00383',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '185.00',meanbuyprice_withDiscount = '185' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '8.11' , buyhalf_precentage = '13.51' , buypart_precentage = '24.32',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '383';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:09:39";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:39:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:39:39', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:09:49";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:39:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:39:50', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:10:07";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:40:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:40:07', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:10:26";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:40:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:40:26', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 384;
UPDATE productunit SET unitid = '1', productid = '384', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0038401',proUnitSellAllPrice='200',proUnitSellHalfPrice='200',proUnitSellUnitPrice ='250',proUnitBuyPrice='185' WHERE productunitid = '384';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (384, 1,'2021-11-16 17:40:27',1)
                ON DUPLICATE KEY UPDATE productid = 384, edited = 1, sysdate = '2021-11-16 17:40:27', userid = 1;
UPDATE product SET productName = 'ديجيتال 635', productDescription = '', productCatId = '1', productBuyPrice = '185', productSellAllPrice = '190', productSellUnitPrice = '220', productSellHalfPrice = '200', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00384',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '185.00',meanbuyprice_withDiscount = '185' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '2.7' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '384';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:10:29";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:40:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:40:29', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:10:37";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:40:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:40:37', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:10:52";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:40:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:40:52', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:11:14";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:41:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:41:15', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 385;
UPDATE productunit SET unitid = '1', productid = '385', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0038501',proUnitSellAllPrice='200',proUnitSellHalfPrice='200',proUnitSellUnitPrice ='250',proUnitBuyPrice='185' WHERE productunitid = '385';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (385, 1,'2021-11-16 17:41:15',1)
                ON DUPLICATE KEY UPDATE productid = 385, edited = 1, sysdate = '2021-11-16 17:41:15', userid = 1;
UPDATE product SET productName = 'ديجيتال 636', productDescription = '', productCatId = '1', productBuyPrice = '185', productSellAllPrice = '190', productSellUnitPrice = '220', productSellHalfPrice = '200', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00385',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '185.00',meanbuyprice_withDiscount = '185' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '2.7' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '385';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:11:18";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:41:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:41:18', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:11:25";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:41:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:41:25', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:11:38";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:41:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:41:38', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:11:57";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:41:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:41:57', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 386;
UPDATE productunit SET unitid = '1', productid = '386', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0038601',proUnitSellAllPrice='200',proUnitSellHalfPrice='200',proUnitSellUnitPrice ='250',proUnitBuyPrice='185' WHERE productunitid = '386';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (386, 1,'2021-11-16 17:41:57',1)
                ON DUPLICATE KEY UPDATE productid = 386, edited = 1, sysdate = '2021-11-16 17:41:57', userid = 1;
UPDATE product SET productName = 'ديجيتال 637', productDescription = '', productCatId = '1', productBuyPrice = '185', productSellAllPrice = '190', productSellUnitPrice = '220', productSellHalfPrice = '200', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00386',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '185.00',lastbuyprice_withDiscount = '185',meanbuyprice = '185.00',meanbuyprice_withDiscount = '185' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '2.7' , buyhalf_precentage = '8.11' , buypart_precentage = '18.92',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '386';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:11:59";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:41:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:41:59', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:12:06";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:42:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:42:06', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:12:29";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:42:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:42:29', '1', 'edit', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:12:47";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:42:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:42:47', '1', 'update', '197.56.233.117', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 387;
UPDATE productunit SET unitid = '1', productid = '387', productnumber = '1.00', productunitdate = '2021-11-16', userid = '1', conditions = '0',proUnitParcode='0038701',proUnitSellAllPrice='190',proUnitSellHalfPrice='190',proUnitSellUnitPrice ='240',proUnitBuyPrice='175' WHERE productunitid = '387';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (387, 1,'2021-11-16 17:42:47',1)
                ON DUPLICATE KEY UPDATE productid = 387, edited = 1, sysdate = '2021-11-16 17:42:47', userid = 1;
UPDATE product SET productName = 'ديجيتال 638', productDescription = '', productCatId = '1', productBuyPrice = '175', productSellAllPrice = '190', productSellUnitPrice = '220', productSellHalfPrice = '200', productDate = '2021-11-07', conditions = '0', userId = '1', limitamount = '0', parcode = '00387',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '175.00',lastbuyprice_withDiscount = '175',meanbuyprice = '175.00',meanbuyprice_withDiscount = '175' , productbuypricereal = '0' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '14.29' , buypart_precentage = '25.71',logo = '',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '387';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:12:49";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:42:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:42:49', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:12:57";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:42:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 17:42:57', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:15:05";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:45:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2021-11-16 17:45:06', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:15:57";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:45:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementstoreController.php', '2021-11-16 17:45:57', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:17:18";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:47:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreport.php', '2021-11-16 17:47:18', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:17:40";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:47:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('salesreport.php', '2021-11-16 17:47:40', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:18:32";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:48:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2021-11-16 17:48:32', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:18:41";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:48:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2021-11-16 17:48:41', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:23:49";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 17:53:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 17:53:49', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:49:18";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:19:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 18:19:18', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:49:57";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:19:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 18:19:57', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:50:33";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:20:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storeController.php', '2021-11-16 18:20:33', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:50:40";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:20:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storeController.php', '2021-11-16 18:20:40', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:50:54";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:20:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 18:20:54', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:51:06";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:21:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 18:21:06', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:51:21";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:21:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 18:21:21', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:51:56";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:21:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storeController.php', '2021-11-16 18:21:56', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:52:12";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:22:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 18:22:12', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:52:34";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:22:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2021-11-16 18:22:34', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:53:03";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:23:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 18:23:03', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:53:20";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:23:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2021-11-16 18:23:21', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 14:57:32";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:27:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2021-11-16 18:27:32', '1', '', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 15:00:09";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:30:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2021-11-16 18:30:10', '1', 'add', '197.56.233.117', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '21940', userid = '1', storedetaildate = '2021-11-16' WHERE storedetailid = '554';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('544', '2', '120', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '21820.00', '21940', '1', '2021-11-16','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 15:00:11";
UPDATE user SET loginip = "197.56.233.117", lastactivetime = "2021-11-16 18:30:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2021-11-16 18:30:12', '1', 'show', '197.56.233.117', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 16:09:05";
UPDATE user SET loginip = "197.56.205.96", lastactivetime = "2021-11-16 19:39:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-16 19:39:05', '1', '', '197.56.205.96', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 16:10:38";
UPDATE user SET loginip = "197.56.205.96", lastactivetime = "2021-11-16 19:40:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-16 19:40:38', '1', 'add', '197.56.205.96', '', '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 =114
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(15,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '24793' , clientdate = '2021-11-16 19:40:38', userid = '1' WHERE clientid = '15';
UPDATE client SET  inUse = 0 where clientid = 15;
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 ('15','24893.00','100','1','ايصال تحصيل (( قبض من عميل ))','114', '24793', '2021-11-16 19:39:05', '1', 'clientPayedDeptController.php', '   ', '100', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '39650',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('39550.00','100', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '114', '39650', '2021-11-16 19:40:38', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '100', '100', '2021-11-16', '1', '0', '0', '2021-11-16 19:40:38','اضافة ايصال سداد للعميل حمادة العرينى','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('653', '54', '100', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '39130', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('653', '68', '100', '','0');
UPDATE accountstree SET name = 'حمادة العرينى', customName = 'حمادة العرينى', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-5000', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '68';
UPDATE clientdebtchange SET clientid = '15', clientdebtchangebefore = '24893.00', clientdebtchangeamount = '100.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '114', clientdebtchangeafter = '24793.00', clientdebtchangedate = '2021-11-16 19:39:05', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '100.00',discount='', reciptid=null, dailyentryid = '653',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '114';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 16:10:38";
UPDATE user SET loginip = "197.56.205.96", lastactivetime = "2021-11-16 19:40:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-16 19:40:38', '1', 'sucess', '197.56.205.96', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 16:10:41";
UPDATE user SET loginip = "197.56.205.96", lastactivetime = "2021-11-16 19:40:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2021-11-16 19:40:41', '1', 'show', '197.56.205.96', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
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-16 17:51:46";
UPDATE user SET loginip = "156.164.153.102", lastactivetime = "2021-11-16 21:21:46", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2021-11-16 21:21:46', '7', '', '156.164.153.102', '', '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-16 17:51:47";
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-16 17:51:58";
UPDATE user SET loginip = "156.164.153.102", lastactivetime = "2021-11-16 21:21:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 21:21:58', '7', 'addsellBill', '156.164.153.102', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2021-11-16 17:51:58";
UPDATE user SET loginip = "156.164.153.102", lastactivetime = "2021-11-16 21:21:59", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2021-11-16 21:21:59', '7', 'addsellBill', '156.164.153.102', '', 'DESKTOP');
