UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:33:44";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:03:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2024-08-02 00:03:44', '1', 'show', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:33:48";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:03:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-08-02 00:03:48', '1', 'all', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:34:02";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:04:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-08-02 00:04:02', '1', 'all', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:34:43";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:04:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientController.php', '2024-08-02 00:04:43', '1', '', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:35:13";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:05:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-08-02 00:05:13', '1', '', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:36:18";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:06:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientController.php', '2024-08-02 00:06:18', '1', 'showByType', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:38:03";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:08:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('comentclientController.php', '2024-08-02 00:08:03', '1', '', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:38:24";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:08:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('comentclientController.php', '2024-08-02 00:08:24', '1', '', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 20:49:21";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:19:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('comentclientController.php', '2024-08-02 00:19:21', '1', '', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 21:23:43";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:53:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-08-02 00:53:43', '1', 'all', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 21:23:48";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:53:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-08-02 00:53:48', '1', 'all', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-01 21:24:40";
UPDATE user SET loginip = "156.210.109.69", lastactivetime = "2024-08-02 00:54:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-08-02 00:54:41', '1', 'all', '156.210.109.69', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:48:58";
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 < "2024-08-02 11:49:28";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:19:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-08-02 15:19:28', '7', '', '197.192.205.201', '', '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 = '0', 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 = '2024-08-02',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 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 = '0', 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 = '2024-08-02',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 < "2024-08-02 11:49: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 < "2024-08-02 11:49:34";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:19:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 15:19:34', '7', 'addsellBill', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:50:40";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:20:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 15:20:40', '7', 'addsellBill', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:51:01";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:21:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 15:21:01', '7', 'addsellBill', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:51:54";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:21:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 15:21:54', '7', 'addsellBill', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:52:41";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:22:41", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 15:22:41', '7', 'addAndRetuen', '197.192.205.201', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066accf629efdc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-08-02 15:21:54', '066accf629efdc', '1', '0.00', '0', '0', '1', '750', '750', '750', '0', '5', '2024-08-02 15:22:41', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','750','0','','0','0','750','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17956', '0', '2024-08-02 15:22:41', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '750', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 19707;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('185','00622', '17956', '1', '622', '3', '250', '750', '0', '', '0', '2024-08-02 15:22:41', '622', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','19707-3,');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 202.50, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 202.50
                where sellbilldetailid = 53140;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (622, '2024-08-02', 750, 660, 555
                    , 607.5, 555, 607.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+555, sellCostMeanBuyPrice = sellCostMeanBuyPrice+607.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+555, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+607.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-08-02', 750, 660, 555
                    , 607.5, 555, 607.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+555, sellCostMeanBuyPrice = sellCostMeanBuyPrice+607.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+555, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+607.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '7', storedetaildate = '2024-08-02 15:22:41' WHERE storedetailid = '4040';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('622', '5', '3', '1', '17956', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '6', '7', '2024-08-02 15:22:41','0','0');
UPDATE save SET  savecurrentvalue = '5305',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4555.00','750', '0', '5', 'اضافة فاتورة مبيعات', '17956', '5305', '2024-08-02 15:22:41', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-08-02', 750, 660, 555
                    , 607.5, 555, 607.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+555, sellCostMeanBuyPrice = sellCostMeanBuyPrice+607.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+555, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+607.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-08-02', 750, 660, 555
                    , 607.5, 555, 607.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+750, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+555, sellCostMeanBuyPrice = sellCostMeanBuyPrice+607.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+555, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+607.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 750, 660, 555
                    , 607.5, 555, 607.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+750, netSellCostBuyPrice = netSellCostBuyPrice+660
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+555
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+607.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+555
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+607.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066accf629efdc and sellbillId = 17956 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:52:42";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:22:42", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 15:22:42', '7', 'addsellBill', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:52:47";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:22:47", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 15:22:47', '7', '', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:53:35";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:23:35", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 15:23:35', '7', 'add', '197.192.205.201', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'جهاد', '', '20', '2024-08-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '5285',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5305.00','20', '1', '5', 'إضافة مصروف', '5273', '5285', '2024-08-02 15:23:35', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20', '20', '2024-08-02', '7', '0', '0', '2024-08-02 15:23:35','اضافة اسم مصروف( جهاد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10787', '145', '20', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '548125', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10787', '139', '20', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3333053', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'جهاد', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-08-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10787', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5273';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:53:36";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:23:36", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 15:23:36', '7', 'sucess', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:53:38";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:23:38", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 15:23:38', '7', 'show', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:53:45";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:23:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 15:23:45', '7', '', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:55:50";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:25:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 15:25:50', '7', 'add', '197.192.205.201', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('3', 'ايجار المحل باقي اجار', '', '4600', '2024-08-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '685',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('5285.00','4600', '1', '5', 'إضافة مصروف', '5274', '685', '2024-08-02 15:25:50', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '4600', '4600', '2024-08-02', '7', '0', '0', '2024-08-02 15:25:50','اضافة اسم مصروف( ايجار المحل باقي اجار )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10788', '146', '4600', '','0');
UPDATE accountstree SET name = 'ايجار', customName = 'ايجار', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '469385', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '146';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10788', '139', '4600', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3337653', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '3', expensesname = 'ايجار المحل باقي اجار', expensesdetails = '', expensesValue = '4600.00', expensesdate = '2024-08-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10788', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5274';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:55:51";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:25:51", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 15:25:51', '7', 'sucess', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:55:53";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:25:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 15:25:53', '7', 'show', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 11:56:01";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 15:26:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 15:26:01', '7', 'addsellBill', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 13:53:20";
UPDATE user SET loginip = "197.192.205.201", lastactivetime = "2024-08-02 17:23:20", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 17:23:20', '7', 'addsellBill', '197.192.205.201', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 16:09:05";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 16:09:08";
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 < "2024-08-02 16:09:27";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 19:39:27", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-08-02 19:39:27', '7', '', '197.192.204.91', '', '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 < "2024-08-02 16:09:28";
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 < "2024-08-02 16:09:40";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 19:39:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 19:39:40', '7', 'addsellBill', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 17:42:33";
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 < "2024-08-02 17:42:46";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 21:12:46", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-08-02 21:12:46', '7', '', '197.192.204.91', '', '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 < "2024-08-02 17:42: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 < "2024-08-02 17:42:54";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 21:12:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 21:12:54', '7', 'addsellBill', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 17:44:31";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 21:14:31", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 21:14:31', '7', 'addsellBill', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 17:45:31";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 21:15:31", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 21:15:31', '7', 'addAndRetuen', '197.192.204.91', '', '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 066ad22075fb2d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(69,@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 ('2024-08-02 21:14:31', '066ad22075fb2d', '69', '41665.00', '40435', '0', '1', '1230', '1230', '0', '-1230', '5', '2024-08-02 21:15:31', '', '7', '0', 'سنتر مكه','5', '1', '5', '0', 'سنتر مكه', '3', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '40435', userid = '7' WHERE clientid = '69';
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 ('69','41665.00','1230','1','اضافة فاتورة مردوات مبيعات','6096', '40435', '2024-08-02 21:15:31', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '1230', '0', null, '0', null, null,'', '0','1','1','1230','1');
UPDATE client SET  inUse = 0 where clientid = 69;
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 ('400.00', '01750', '6096', '1', '1750', '3', '410.00', '1230', '0', '', '2', '0', '1750', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
                where returnsellbilldetailid = 13132;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1750, '2024-08-02', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1230, 1200, 1200, 1200
                    , 1200, 1200, 0, 0, 3)
                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+1230, returnSellCostBuyPrice = returnSellCostBuyPrice+1200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1200
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+3;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-08-02', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1230, 1200, 1200, 1200
                    , 1200, 1200, 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+1230, returnSellCostBuyPrice = returnSellCostBuyPrice+1200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '42', userid = '7', storedetaildate = '2024-08-02 21:15:31' WHERE storedetailid = '6287';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1750', '5', '3', '0', '6096', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '39.00', '42', '7', '2024-08-02 21:15:31','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-08-02', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1230, 1200, 1200, 1200
                    , 1200, 1200, 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+1230, returnSellCostBuyPrice = returnSellCostBuyPrice+1200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (69, '2024-08-02', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1230, 1200, 1200, 1200
                    , 1200, 1200, 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+1230, returnSellCostBuyPrice = returnSellCostBuyPrice+1200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -1230, -1200, -1200
                    , -1200, -1200, -1200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-1230, netSellCostBuyPrice = netSellCostBuyPrice+-1200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-1200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-1200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-1200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-1200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066ad22075fb2d and sellbillId = 6096 and returnsellbillId = 6096
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 17:45:32";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 21:15:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 21:15:32', '7', 'addsellBill', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 17:45:40";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 21:15:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-08-02 21:15:40', '7', '', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 17:47:45";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 21:17:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 21:17:45', '7', 'addsellBill', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 17:56:26";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 21:26:27", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 21:26:27', '7', 'addsellBill', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:45:00";
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 < "2024-08-02 19:45:13";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:15:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-08-02 23:15:13', '7', '', '197.192.204.91', '', '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 < "2024-08-02 19:45: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 < "2024-08-02 19:45:22";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:15:22", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:15:22', '7', '', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:45:36";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:15:37", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:15:37', '7', 'add', '197.192.204.91', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('2', 'مرتب احمد', '', '150', '2024-08-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '535',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('685.00','150', '1', '5', 'إضافة مصروف', '5275', '535', '2024-08-02 23:15:37', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '150', '150', '2024-08-02', '7', '0', '0', '2024-08-02 23:15:37','اضافة اسم مصروف( مرتب احمد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10789', '145', '150', '','0');
UPDATE accountstree SET name = 'مرتبات', customName = 'مرتبات', parent = '14', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-08', itemtype2 = '0', theValue = '548275', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '145';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10789', '139', '150', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3337803', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '2', expensesname = 'مرتب احمد', expensesdetails = '', expensesValue = '150.00', expensesdate = '2024-08-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10789', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5275';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:45:37";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:15:37", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:15:37', '7', 'sucess', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:45:39";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:15:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:15:39', '7', 'show', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:45:40";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:15:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:15:40', '7', '', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:46:00";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:16:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:16:00', '7', 'add', '197.192.204.91', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'جهاد', '', '10', '2024-08-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '525',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('535.00','10', '1', '5', 'إضافة مصروف', '5276', '525', '2024-08-02 23:16:00', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '10', '10', '2024-08-02', '7', '0', '0', '2024-08-02 23:16:00','اضافة اسم مصروف( جهاد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10790', '160', '10', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4597635', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10790', '139', '10', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3337813', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'جهاد', expensesdetails = '', expensesValue = '10.00', expensesdate = '2024-08-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10790', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5276';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:46:00";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:16:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:16:00', '7', 'sucess', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:46:02";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:16:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:16:02', '7', 'show', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:46:03";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:16:03", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:16:03', '7', '', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:47:00";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:17:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:17:00', '7', 'add', '197.192.204.91', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'غفير المحل', '', '50', '2024-08-02', '7', '0','-1','5','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '475',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('525.00','50', '1', '5', 'إضافة مصروف', '5277', '475', '2024-08-02 23:17:00', '7',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '50', '50', '2024-08-02', '7', '0', '0', '2024-08-02 23:17:00','اضافة اسم مصروف( غفير المحل )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10791', '160', '50', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4597685', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10791', '139', '50', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3337863', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'غفير المحل', expensesdetails = '', expensesValue = '50.00', expensesdate = '2024-08-02', userid = '7', conditions = '0',saveid = '5' , dailyentryid = '10791', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5277';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:47:01";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:17:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:17:01', '7', 'sucess', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:47:02";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:17:03", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-08-02 23:17:03', '7', 'show', '197.192.204.91', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-08-02 19:47:34";
UPDATE user SET loginip = "197.192.204.91", lastactivetime = "2024-08-02 23:17:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-08-02 23:17:34', '7', 'addsellBill', '197.192.204.91', '', 'DESKTOP');
