src/EventListener/WorkflowEvents.php line 619

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Pimcore\Controller\FrontendController;
  4. use \Pimcore\Model\DataObject;
  5. use App\Library\EmailLibrary;
  6. use Symfony\Component\Workflow\Event\EnteredEvent;
  7. use Symfony\Component\Workflow\Event\EnterEvent;
  8. use Symfony\Component\Workflow\Event\AnnounceEvent;
  9. use Pimcore\Model\Comment;
  10. use Symfony\Component\Workflow\Event\CompletedEvent;
  11. use Symfony\Component\Workflow\Event\LeaveEvent;
  12. class WorkflowEvents extends FrontendController {
  13.     private $executePreviousEvents true;
  14.     private $team '';
  15.     private $sendComment false;
  16.     private $commonId '';
  17.     public function demandPlanningEmail($objectData) {
  18.         $division $objectData->getdivision();
  19.         $productName $objectData->getname();
  20.         $escalationEmail = new DataObject\EscalationEmails\Listing();
  21.         $escalationEmail->setCondition(" division = '$division' ");
  22.         $escalationEmail $escalationEmail->getdata();
  23.         if(count($escalationEmail) && !empty($escalationEmail[0])) {
  24.             $escalationEmail $escalationEmail[0];
  25.             $productId $objectData->getId();
  26.             $emailIds $escalationEmail->getdemandPlanningTeam();
  27.             if(!empty($emailIds)) {
  28.                 $emailParam = array();
  29.                 $emailParam['to'] = $emailIds;
  30.                 $emailParam['subject'] = 'ITC - Product YVBYMARA';
  31.                 // $emailParam['isDebug'] = true;
  32.                 $templateData['product'] = $objectData;
  33.                 $templateData['url'] = \Pimcore\Tool::getHostUrl().'/admin/login/deeplink?object_'.$productId.'_object';
  34.                 $user \Pimcore\Tool\Session::getReadonly()->get("user");
  35.                 if (empty($user)) {
  36.                     $templateData['userInfo'] = \Pimcore\Model\User::getById($user->getId());
  37.                 }
  38.                 $templateData['productName'] = $productName;
  39.                 $emailParam['message'] = $this->render('default/email/demand_planning/yvbymara.html.twig'$templateData)->getContent();
  40.                 $emailLib = new EmailLibrary();
  41.                 $sendEmail $emailLib->sendEmailNotification($emailParam);
  42.             }
  43.         }
  44.     }
  45.     public function sendEmail($team,$objectData,$wfPlace 'correction') {
  46.         $division $objectData->getdivision();
  47.         $productName $objectData->getname();
  48.         $escalationEmail = new DataObject\EscalationEmails\Listing();
  49.         $escalationEmail->setCondition(" division = '$division' ");
  50.         $escalationEmail $escalationEmail->getdata();
  51.         if(count($escalationEmail) && !empty($escalationEmail[0])) {
  52.             $escalationEmail $escalationEmail[0];
  53.             $productId $objectData->getId();
  54.             $attachment = array();
  55.             if($team == 'snop') {
  56.                 $emailIds $escalationEmail->getsnopTeam();
  57.             } else if($team == 'finance') {
  58.                 $emailIds $escalationEmail->getfinanceTeam();
  59.             } else if($team == 'brand') {
  60.                 $emailIds $escalationEmail->getbrandTeam();
  61.             } else if($team == 'packaging') {
  62.                 $emailIds $escalationEmail->getpackagingTeam();
  63.             } else if($team == 'indirectTax') {
  64.                 $emailIds $escalationEmail->getindirecttaxTeam();
  65.             } else if($team == 'operationsTeam') {
  66.                 $emailIds $escalationEmail->getoperationsTeam();
  67.             } else if($team == 'demandPlanningTeam') {
  68.                 $emailIds $escalationEmail->getdemandPlanningTeam();
  69.             } else if($team == 'smisTeam') {
  70.                 $emailIds $escalationEmail->getsmisTeam();
  71.             } else if($team == 'sapTeam') {
  72.                 $emailIds $escalationEmail->getsapTeam();
  73.             }
  74.             if(!empty($emailIds)) {
  75.                 $emailParam = array();
  76.                 $emailParam['to'] = $emailIds;
  77.                 $emailParam['subject'] = 'ITC - Product Approval';
  78.                 // $emailParam['isDebug'] = true;
  79.                 $templateData['product'] = $objectData;
  80.                 $templateData['teamEmail'] = $team;
  81.                 $correction false;
  82.                 $sendBackToSnop false;
  83.                 if($wfPlace == 'correction') {
  84.                     $correction true;
  85.                     $this->sendComment true;
  86.                 } else if ($wfPlace == 'sendBackToSnop') {
  87.                     $sendBackToSnop true;
  88.                 }
  89.                 $projectId '';
  90.                 $productId '';
  91.                 $projectTitle '';
  92.                 if (!empty($this->commonId)) {
  93.                     $projectId $this->commonId;
  94.                 } else {
  95.                     $projectId $objectData->getprojectName();
  96.                 }
  97.                 if (!empty($projectId)) {
  98.                     $projectData DataObject\ProductByName::getById($projectId);
  99.                     if (!empty($projectData)) {
  100.                         $projectId $projectData->getId();
  101.                         $projectTitle $projectData->getproductName();
  102.                     } else {
  103.                         $projectId '';
  104.                     }
  105.                 } else {
  106.                     $productId $objectData->getId();
  107.                 }
  108.                 if($team == 'sapTeam' && (!empty($projectId) || !empty($productId))) {
  109.                     $objId = (!empty($projectId)) ? $projectId $productId;
  110.                     $isProduct = (!empty($projectId)) ? false true;
  111.                     $lsmw $this->saveLsmwSheetAction($objId,$isProduct);
  112.                     if (!empty($lsmw)) {
  113.                         $attachment[] = $lsmw;
  114.                     }
  115.                     $adtional $this->saveAdditionalDataAction($objId,$isProduct);
  116.                     if (!empty($adtional)) {
  117.                         $attachment[] = $adtional;
  118.                     }
  119.                     $yvbymara $this->saveYvbymaraAction($objId,$isProduct);
  120.                     if (!empty($yvbymara)) {
  121.                         $attachment[] = $yvbymara;
  122.                     }
  123.                 }
  124.                 $templateData['url'] = \Pimcore\Tool::getHostUrl().'/admin/login/deeplink?object_'.$productId.'_object';
  125.                 $templateData['projectUrl'] = (!empty($projectId)) ? \Pimcore\Tool::getHostUrl().'/admin/login/deeplink?object_'.$projectId.'_object' '';
  126.                 $templateData['productUrl'] = (!empty($productId)) ? \Pimcore\Tool::getHostUrl().'/admin/login/deeplink?object_'.$productId.'_object' '';
  127.                 $templateData['downloadUrl'] = (!empty($projectId)) ? \Pimcore\Tool::getHostUrl().'/export/teamdata?t='.md5($team).'&i='.md5($projectId) : '';
  128.                 if (!empty($this->sendComment)) {
  129.                     $cid = (!empty($this->commonId)) ? $this->commonId $productId;
  130.                     $dbConnection \Pimcore\Db::get();
  131.                     $notes $dbConnection->fetchAssoc("SELECT * FROM `notes` WHERE cid = '$cid' ORDER BY `id` DESC LIMIT 1");
  132.                     if(!empty($notes['description'])) {
  133.                         $templateData['notes'] = nl2br($notes['description']);
  134.                     }
  135.                 }
  136.                 $user \Pimcore\Tool\Session::getReadonly()->get("user");
  137.                 if (empty($user)) {
  138.                     $templateData['userInfo'] = \Pimcore\Model\User::getById($user->getId());
  139.                 }
  140.                 $templateData['correction'] = $correction;
  141.                 $templateData['sendBackToSnop'] = $sendBackToSnop;
  142.                 $templateData['productName'] = $productName;
  143.                 $templateData['team'] = $this->team;
  144.                 $templateData['projectTitle'] = $projectTitle;
  145.                 $emailParam['message'] = $this->render('default/escalation_email_template.html.twig'$templateData)->getContent();
  146.                 $emailParam['attachment'] = (count($attachment)) ? $attachment : array();
  147.                 $emailLib = new EmailLibrary();
  148.                 $sendEmail $emailLib->sendEmailNotification($emailParam);
  149.             }
  150.         }
  151.         $objectData->save();
  152.     }
  153.     public function snopCorrection($objectData) {
  154.         if ($this->executePreviousEvents) {
  155.             $this->sendEmail('snop',$objectData);
  156.         }
  157.     }
  158.     public function financeCorrection($objectData) {
  159.         if ($this->executePreviousEvents) {
  160.             $this->sendEmail('finance',$objectData);
  161.         }
  162.     }
  163.     public function brandCorrection($objectData) {
  164.         if ($this->executePreviousEvents) {
  165.             $this->sendEmail('brand',$objectData,'correction');
  166.         }
  167.     }
  168.     public function packagingCorrection($objectData) {
  169.         if ($this->executePreviousEvents) {
  170.             $this->sendEmail('packaging',$objectData);
  171.         }
  172.     }
  173.     public function indirectTaxCorrection($objectData) {
  174.         if ($this->executePreviousEvents) {
  175.             $this->sendEmail('indirectTax',$objectData);
  176.         }
  177.     }
  178.     public function operationteamCorrection($objectData) {
  179.         if ($this->executePreviousEvents) {
  180.             $this->sendEmail('operationsTeam',$objectData);
  181.         }
  182.     }
  183.     public function demandPlanningTeam($objectData) {
  184.         if ($this->executePreviousEvents) {
  185.             $this->sendEmail('demandPlanningTeam',$objectData);
  186.         }
  187.     }
  188.     public function smisTeam($objectData) {
  189.         if ($this->executePreviousEvents) {
  190.             $this->sendEmail('smisTeam',$objectData);
  191.         }
  192.     }
  193.     public function financeAction($objectData) {
  194.         if ($this->executePreviousEvents) {
  195.             $this->sendEmail('finance',$objectData,'Finance');
  196.         }
  197.     }
  198.     public function brandAction($objectData) {
  199.         if ($this->executePreviousEvents) {
  200.             $this->sendEmail('brand',$objectData,'Brand');
  201.         }
  202.     }
  203.     public function packagingAction($objectData) {
  204.         if ($this->executePreviousEvents) {
  205.             $this->sendEmail('packaging',$objectData,'Packaging');
  206.         }
  207.     }
  208.     public function indirectTaxAction($objectData) {
  209.         if ($this->executePreviousEvents) {
  210.             $this->sendEmail('indirectTax',$objectData,'Indirect Tax');
  211.         }
  212.     }
  213.     public function operationsAction($objectData) {
  214.         if ($this->executePreviousEvents) {
  215.             $this->sendEmail('operationsTeam',$objectData,'Operations Team');
  216.         }
  217.     }
  218.     public function demandPlanningAction($objectData) {
  219.         if ($this->executePreviousEvents) {
  220.             $this->sendEmail('demandPlanningTeam',$objectData,'Demand Planning Team');
  221.         }
  222.     }
  223.     public function smisAction($objectData) {
  224.         if ($this->executePreviousEvents) {
  225.             $this->sendEmail('smisTeam',$objectData,'SMIS');
  226.         }
  227.     }
  228.     public function sapAction($objectData) {
  229.         if ($this->executePreviousEvents) {
  230.             $this->sendEmail('sapTeam',$objectData,'sap');
  231.             $this->demandPlanningEmail($objectData);
  232.         }
  233.     }
  234.     public function packagingToSnop($objectData) {
  235.         if ($this->executePreviousEvents) {
  236.             $this->team 'Packaging Team';
  237.             $this->sendEmail('snop',$objectData,'sendBackToSnop');
  238.         }
  239.     }
  240.     public function financeToSnop($objectData) {
  241.         if ($this->executePreviousEvents) {
  242.             $this->team 'Finance Team';
  243.             $this->sendEmail('snop',$objectData,'sendBackToSnop');
  244.         }
  245.     }
  246.     public function brandToSnop($objectData) {
  247.         if ($this->executePreviousEvents) {
  248.             $this->team 'Brand Team';
  249.             $this->sendEmail('snop',$objectData,'sendBackToSnop');
  250.         }
  251.     }
  252.     public function indirectTaxToSnop($objectData) {
  253.         if ($this->executePreviousEvents) {
  254.             $this->team 'Indirect Tax Team';
  255.             $this->sendEmail('snop',$objectData,'sendBackToSnop');
  256.         }
  257.     }
  258.     public function operationsToSnop($objectData) {
  259.         if ($this->executePreviousEvents) {
  260.             $this->team 'Operations Team';
  261.             $this->sendEmail('snop',$objectData,'sendBackToSnop');
  262.         }
  263.     }
  264.     public function demandPlanningToSnop($objectData) {
  265.         if ($this->executePreviousEvents) {
  266.             $this->team 'Demand Planning Team';
  267.             $this->sendEmail('snop',$objectData,'sendBackToSnop');
  268.         }
  269.     }
  270.     public function smisToSnop($objectData) {
  271.         if ($this->executePreviousEvents) {
  272.             $this->team 'SMIS Team';
  273.             $this->sendEmail('snop',$objectData,'sendBackToSnop');
  274.         }
  275.     }
  276.     public function sapApproved($objectData) {
  277.         $folder DataObject\Service::createFolderByPath('/Products/SAP/Approved/');
  278.         $folderId $folder->getId();
  279.         $objectData->setParentId($folderId);
  280.         $objectData->setisProductApproved('yes');
  281.         $objectData->save();
  282.         $this->createMarketPlaceProduct($objectData);
  283.     }
  284.     public function createMarketPlaceProduct($productObj) {
  285.         $key $productObj->getkey();
  286.         // Create Amazon DataObject
  287.         // $size = $productObj->getsize();
  288.         // $product_type = $productObj->getproduct_type();
  289.         $newObject = new DataObject\ProductAmazon();
  290.         $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey('A_'.$key'object'));
  291.         // $newObject->setproduct_type($size);
  292.         // $newObject->setsize($product_type);
  293.         $newObject->setstoreProduct($productObj);
  294.         $newObject->seto_parentId('1');
  295.         $newObject->save(["versionNote" => "Product created from SAP"]);
  296.         // Create Big Basket DataObject
  297.         // $how_to_use = $productObj->gethow_to_use();
  298.         // $product_description = $productObj->getproduct_description();
  299.         $hsn_code $productObj->gethsn_code();
  300.         if (!empty($hsn_code)) {
  301.             $hsn_code floatval($hsn_code);
  302.         }
  303.         $newObject = new DataObject\ProductBigBasket();
  304.         $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey('BB_'.$key'object'));
  305.         // $newObject->sethow_to_use($how_to_use);
  306.         // $newObject->setproduct_description($product_description);
  307.         $newObject->sethsn_code($hsn_code);
  308.         $newObject->seto_parentId('1');
  309.         $newObject->setstoreProduct($productObj);
  310.         $newObject->save(["versionNote" => "Product created from SAP"]);
  311.         // Create Blinkit DataObject
  312.         // $key_features = $productObj->getkey_features();
  313.         // $product_type = $productObj->getproduct_type();
  314.         // $price = $productObj->getprice();
  315.         // $ingredients = $productObj->getingredients();
  316.         $newObject = new DataObject\ProductBlinkit();
  317.         $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey('BI_'.$key'object'));
  318.         // $newObject->setkey_features($key_features);
  319.         // $newObject->setproduct_type($product_type);
  320.         // $newObject->setprice($price);
  321.         // $newObject->setingredients($ingredients);
  322.         $newObject->seto_parentId('1');
  323.         $newObject->setstoreProduct($productObj);
  324.         $newObject->save(["versionNote" => "Product created from SAP"]);
  325.         $newObject = new DataObject\ProductFlipkart();
  326.         $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey('FK_'.$key'object'));
  327.         $newObject->seto_parentId('1');
  328.         $newObject->setstoreProduct($productObj);
  329.         $newObject->save(["versionNote" => "Product created from SAP"]);
  330.         // Create JioMart DataObject
  331.         $hsn_code $productObj->gethsn_code();
  332.         // $how_to_use = $productObj->gethow_to_use();
  333.         // $product_type = $productObj->getproduct_type();
  334.         // $ingredients = $productObj->getingredients();
  335.         // $size = $productObj->getsize();
  336.         // $food_type = $productObj->getfood_type();
  337.         $newObject = new DataObject\ProductJioMart();
  338.         $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey('JM_'.$key'object'));
  339.         $newObject->sethsn_code($hsn_code);
  340.         // $newObject->sethow_to_use($how_to_use);
  341.         // $newObject->setproduct_type($product_type);
  342.         // $newObject->setingredients($ingredients);
  343.         // $newObject->setsize($size);
  344.         // $newObject->setfood_type($food_type);
  345.         $newObject->seto_parentId('1');
  346.         $newObject->setstoreProduct($productObj);
  347.         $newObject->save(["versionNote" => "Product created from SAP"]);
  348.         // Create Swiggy DataObject
  349.         $sku_name $productObj->getmaterial_number();
  350.         $weight $productObj->getpack_weight();
  351.         if (!empty($weight)) {
  352.             $weight floatval($weight);
  353.         }
  354.         $newObject = new DataObject\ProductSwiggy();
  355.         $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey('SG_'.$key'object'));
  356.         $newObject->setsku_name($sku_name);
  357.         $newObject->setweight($weight);
  358.         $newObject->seto_parentId('1');
  359.         $newObject->setstoreProduct($productObj);
  360.         $newObject->save(["versionNote" => "Product created from SAP"]);
  361.         // Create Zepto DataObject
  362.         $newObject = new DataObject\ProductZepto();
  363.         $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey('Zepto_'.$key'object'));
  364.         $newObject->sethsn_code($hsn_code);
  365.         $newObject->seto_parentId('1');
  366.         $newObject->setstoreProduct($productObj);
  367.         $newObject->save(["versionNote" => "Product created from SAP"]);
  368.         $msku $productObj->getold_material_number();
  369.         $sku_name $productObj->getname();
  370.         if (!empty($msku)) {
  371.             $msku floatval($msku);
  372.         }
  373.         $newObject = new DataObject\ProductITCStore();
  374.         $newObject->setKey(\Pimcore\Model\Element\Service::getValidKey('Store_'.$key'object'));
  375.         $newObject->seto_parentId('1');
  376.         $newObject->setmsku_itcstore($msku);
  377.         $newObject->setsku_name($sku_name);
  378.         $newObject->setproduct_title($sku_name);
  379.         $newObject->setstoreProduct($productObj);
  380.         $newObject->save(["versionNote" => "Product created from SAP"]);
  381.         // $productSyncKey = "enlwq7pkg6t2od9blt93coomo7g6p9p0"; // Live Integration
  382.         $productSyncKey "qzgg1vbpgwk6pjctbv6ku2a65906ocpb"// Local
  383.         // $productUpdatedUrl = 'https://integration-5ojmyuq-23txbi6folvo6.ap-3.magentosite.cloud/rest/V1/bridge/catalog/product/add';
  384.         // $productUpdatedUrl = 'http://local.itc.com/rest/V1/bridge/catalog/product/add';
  385.         // $data = array( "product_id" => $productObj->getId(),"store_view_id" => "0", );
  386.         // $data_json = json_encode(array("data" => $data));
  387.         // $curl = curl_init();
  388.         // curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
  389.         // curl_setopt($curl, CURLOPT_POSTFIELDS, $data_json);
  390.         // curl_setopt($curl, CURLOPT_URL, $productUpdatedUrl);
  391.         // curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $productSyncKey, 'Accept: application/json', 'Content-Type:application/json', ));
  392.         // curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  393.         // curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  394.         // $result = curl_exec($curl);
  395.         // $resultArray = json_decode($result);
  396.         // curl_close($curl);
  397.     }
  398.     public function snopEmailNotification(EnterEvent $e) {
  399.         $objectData $e->getSubject();
  400.         $productId $objectData->getId();
  401.         $transition $e->getTransition();
  402.         $toPlace $transition->getTos();
  403.         foreach ($toPlace as $key => $value) {
  404.             if($objectData->getpreviousWorkflowPlace() != 'sap_action') {
  405.                 $objectData->setpreviousWorkflowPlace($value);
  406.             }
  407.             switch ($value) {
  408.                 case 'packaging_to_snop':
  409.                     $this->packagingToSnop($objectData);
  410.                     break;
  411.                 case 'finance_to_snop':
  412.                     $this->financeToSnop($objectData);
  413.                     break;
  414.                 case 'brand_to_snop':
  415.                     $this->brandToSnop($objectData);
  416.                     break;
  417.                 case 'indirectTax_to_snop':
  418.                     $this->indirectTaxToSnop($objectData);
  419.                     break;
  420.                 case 'operations_to_snop':
  421.                     $this->operationsToSnop($objectData);
  422.                     break;
  423.                 case 'demandPlanning_to_snop':
  424.                     $this->demandPlanningToSnop($objectData);
  425.                     break;
  426.                 case 'smis_to_snop':
  427.                     $this->smisToSnop($objectData);
  428.                     break;
  429.     
  430.                 default:
  431.                     # code...
  432.                     break;
  433.             }
  434.         }
  435.     }
  436.     public function sapCorrectionEmails(AnnounceEvent $e) {
  437.         if ($this->executePreviousEvents) {
  438.             $this->sendComment true;
  439.             $objectData $e->getSubject();
  440.             $className $objectData->getClassName();
  441.             $objectId $objectData->getId();
  442.             $transition $e->getTransition();
  443.             $toPlace $transition->getTos();
  444.             if ($className == 'ProductByName') {
  445.                 $products $objectData->getproducts();
  446.                 $this->commonId $objectId;
  447.                 foreach ($products as $key => $value) {
  448.                     if ($key == 0) {
  449.                         $this->applyTransition($value,$toPlace,true);
  450.                     }
  451.                     $value->setpreviousWorkflowPlace(implode(',',$toPlace));
  452.                     $value->save();
  453.                     $objectData->setpreviousPlace(implode(',',$toPlace));
  454.                 }
  455.             } else {
  456.                 $this->applyTransition($objectData,$toPlace,true);
  457.             }
  458.             $this->executePreviousEvents false;
  459.         }
  460.     }
  461.     public function correctionEmails(CompletedEvent $e) {
  462.         if ($this->executePreviousEvents) {
  463.             $this->sendComment true;
  464.             $objectData $e->getSubject();
  465.             $className $objectData->getClassName();
  466.             $objectId $objectData->getId();
  467.             $transition $e->getTransition();
  468.             $toPlace $transition->getTos();
  469.             if ($className == 'ProductByName') {
  470.                 $products $objectData->getproducts();
  471.                 $this->commonId $objectId;
  472.                 foreach ($products as $key => $value) {
  473.                     if ($key == 0) {
  474.                         $this->applyTransition($value,$toPlace,true);
  475.                     }
  476.                     $value->setpreviousWorkflowPlace(implode(',',$toPlace));
  477.                     $value->save();
  478.                     $objectData->setpreviousPlace(implode(',',$toPlace));
  479.                 }
  480.             } else {
  481.                 $this->applyTransition($objectData,$toPlace,true);
  482.             }
  483.             $this->executePreviousEvents false;
  484.         }
  485.     }
  486.     public function emailNotification(EnterEvent $e) {
  487.         if ($this->executePreviousEvents) {
  488.             $objectData $e->getSubject();
  489.             $className $objectData->getClassName();
  490.             $transition $e->getTransition();
  491.             $toPlace $transition->getTos();
  492.             if ($className == 'ProductByName') {
  493.                 $products $objectData->getproducts();
  494.                 $this->commonId $objectData->getId();
  495.                 foreach ($products as $key => $value) {
  496.                     if ($key == 0) {
  497.                         $this->applyTransition($value,$toPlace,true);
  498.                     }
  499.                     $value->setpreviousWorkflowPlace(implode(',',$toPlace));
  500.                     $value->save();
  501.                     $objectData->setpreviousPlace(implode(',',$toPlace));
  502.                 }
  503.             } else {
  504.                 $this->applyTransition($objectData,$toPlace,true);
  505.             }
  506.             $this->executePreviousEvents false;
  507.         }
  508.     }
  509.     public function saveLsmwSheetAction($projectId false,$isProduct false) {
  510.         require_once('third_party/vendor/autoload.php');
  511.         $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
  512.         $sheet $spreadsheet->getActiveSheet();
  513.         $xlsHead = array('Material Number','Industry sector','Material type','Plant','Storage location','Sales Organization','Distribution Channel','Indicator: include first Work Schedu','Include Accounting View','Indicator: consider MRP 1 view','Indicator: consider "MRP 2"','Indicator: Consider Purchasing view','Indicator: consider Purchase Order T','Include Basic Data View','Indicator: consider "Storage" view','Indicator: consider "forecasting" vi','Include "Warehouse Management" View','Indicator: consider Sales 1 view','Indicator: consider Sales Text view','Indicator: consider Sales/Plant Data view','Indicator: take Production Resources/Tools view into acc','Indicator: consider "quality assurance" view','Indicator: Take "Costing" view into account','Indicator: take Classification view into account','Indicator: Take "Work Scheduling 2" View into Account','Indicator: Take "MRP 3" view into account','UOM','Material description','Material group','product hieararchy','Old material number','Gross weight (BTCI)','Net weight','Weight Unit','Volume','Volume unit','Ind.Std.Descr','basic material','Size/dimensions','Division','Delivering Plant','Minimum order quantity in base unit of measure (B','Cash discount indicator','Material statistics group','Item category group from material master','Product hierarchy','material group1','material group2','material group3','material group4','material group5','Pricing reference material','Material Pricing Group','Account assignment group for this material','Tax category (sales tax, federal sales tax,...)','Tax classification material','Batch management','Transportation group','Loading group','Text','Order unit','Purchasing value key','Purchasing group','Tax indicator for material (Purchasing)','Control code','Post to inspection stock','Spcial procurement key','MRP group','Valid from','MRP Type','Procurement type','Backflush','Prod. stor. location','In-house production','SchedMargin key','Planning strategy group','Consumption mode','Bwd consumption per.','MRP controller','Planned delivery time','Fiscal year variant','Safety stock','ss days','Lot size (materials planning)','Minimum lot size','Maximum lot size','Fixed lot size','Rounding value for purchase order quantity','Checking Group for Availability Check','material freight group','Period indicator','Selection method','Dependent requirements ind. for individual and coll.','prod sched profile','Under delivery','Over delivery','unltd over delivery','Production scheduler','Processing time (BTCI)','Setup time (BTCI)','Interoperation time (BTCI)','Base quantity (BTCI)','STORAGE CONDITION','Unit of issue','Price control indicator','Moving average price (BTCI)','Standard price','Price unit (BTCI)','Valuation Class','Profit Center','Origin Group as Subdivision of Cost Element','Lot Size of Product Cost Estimate (BTCI)','Material Is Costed with Quantity Structure','QM in Procurement is Active','Ind.: Repetitive mfg allowed','Certificate Type','Control Key for Quality Management in Procurement','Documentation required indicator','Variance Key','Repetitive manufacturing profile','GR processing time','Catalog Profile','Minimum Remaining Shelf Life (BTCI)','Total shelf life in days (BTCI)','Discontinuation indicator','Effective-Out Date (BTCI)','Follow-up material','Material-related origin','Interval to next periodic inspection (BTCI)','Fair share rule','Period indicator for shelf life expiration date','Selection method','Component Scrap %');
  514.         $projectName '';
  515.         if ($projectId) {
  516.             if ($isProduct) {
  517.                 $products DataObject\Products::getById($projectId);
  518.                 if (!empty($products)) {
  519.                     $projectName $products->getname().'_';
  520.                     $products = array($products);
  521.                 } else {
  522.                     return '';
  523.                 }
  524.             } else {
  525.                 $products = new DataObject\ProductByName\Listing();
  526.                 $products->setCondition(" o_id = $projectId ");
  527.                 if (!empty($products->getdata())) {
  528.                     $products $products->getdata()[0];
  529.                     $projectName $products->getproductName().'_';
  530.                     $products $products->getproducts();
  531.                 } else {
  532.                     return '';
  533.                 }
  534.             }
  535.         }
  536.         $col 'A';
  537.         foreach ($xlsHead as $key => $value) {
  538.             $colIndex $col;
  539.             $sheet->setCellValue($col++.'1'$value);
  540.             $sheet->getColumnDimension($colIndex)->setWidth(30);
  541.         }
  542.         $index 2;
  543.         $col 'A';
  544.         $saldistData = new DataObject\SalesAndDistribution\Listing();
  545.         $so = array(); $ds = array();
  546.         foreach ($saldistData as $key => $value) {
  547.             $so[] = $value->getsalesOrganization();
  548.             $ds[] = $value->getdistributionChannel();
  549.         }
  550.         foreach ($products as $key => $value) {
  551.             // $so = (!empty($value->getsales_organization())) ? $value->getsales_organization() : array();
  552.             // $ds = (!empty($value->getdistribution_channel())) ? $value->getdistribution_channel() : array();
  553.             $plants = array();
  554.             if (is_array($value->getplant())) {
  555.                 $plants $value->getplant();
  556.             } else {
  557.                 $plants[] = $value->getplant();
  558.             }
  559.             $division trim(strtolower($value->getdivision()));
  560.             $arrayLength count($plants);
  561.             for ($i 0$i $arrayLength$i++) {
  562.                 $plantValue $plants[$i count($plants)];
  563.                 $soValue $so[$i count($so)];
  564.                 $dsValue $ds[$i count($ds)];
  565.                 $sheet->setCellValue('A'.$index$value->getmaterial_number());
  566.                 $sheet->setCellValue('B'.$index, (!empty($value->getindustry_sector()) ? $value->getindustry_sector() : 'F'));
  567.                 $sheet->setCellValue('C'.$index$value->getmaterial_type());
  568.                 $sheet->setCellValue('D'.$index$plantValue);
  569.                 $storage_location = (!empty($value->getstorage_location())) ? implode(',',$value->getstorage_location()) : 'BRND';
  570.                 $sheet->setCellValue('E'.$index$storage_location);
  571.                 $sheet->setCellValue('F'.$index$soValue);
  572.                 $sheet->setCellValue('G'.$index$dsValue);
  573.                 $sheet->setCellValue('H'.$index'X');
  574.                 $sheet->setCellValue('I'.$index'X');
  575.                 $sheet->setCellValue('J'.$index'X');
  576.                 $sheet->setCellValue('K'.$index'X');
  577.                 $sheet->setCellValue('L'.$index'X');
  578.                 $sheet->setCellValue('M'.$index'X');
  579.                 $sheet->setCellValue('N'.$index'X');
  580.                 $sheet->setCellValue('O'.$index'X');
  581.                 $sheet->setCellValue('P'.$index'X');
  582.                 $sheet->setCellValue('Q'.$index'X');
  583.                 $sheet->setCellValue('R'.$index'X');
  584.                 $sheet->setCellValue('S'.$index'X');
  585.                 $sheet->setCellValue('T'.$index'X');
  586.                 $sheet->setCellValue('U'.$index'X');
  587.                 $sheet->setCellValue('V'.$index'X');
  588.                 $sheet->setCellValue('W'.$index'X');
  589.                 $sheet->setCellValue('X'.$index'X');
  590.                 $sheet->setCellValue('Y'.$index'X');
  591.                 $sheet->setCellValue('Z'.$index'X');
  592.                 $sheet->setCellValue('AA'.$index$value->getuom());
  593.                 $sheet->setCellValue('AB'.$index$value->getmaterial_description());
  594.                 $sheet->setCellValue('AC'.$index$value->getmaterial_group());
  595.                 $sheet->setCellValue('AD'.$index$value->getproduct_hieararchy());
  596.                 $sheet->setCellValue('AE'.$index$value->getold_material_number());
  597.                 $net_weight = (!empty($value->getnet_weight())) ? $value->getnet_weight() : 1.000;
  598.                 $wu $net_weight;
  599.                 if ($division == 'ss') {
  600.                     $sheet->setCellValue('AF'.$index$value->getpack_weight());
  601.                     $sheet->setCellValue('AG'.$index$value->getpack_weight());
  602.                 } else {
  603.                     $sheet->setCellValue('AF'.$index$wu);
  604.                     $sheet->setCellValue('AG'.$index$net_weight);
  605.                 }
  606.                 $sheet->setCellValue('AH'.$index, (!empty($value->getweight_unit()) ? $value->getweight_unit() : 'KG'));
  607.                 $vlume '';
  608.                 if(!empty($value->getlength()) && !empty($value->getbreadth()) && !empty($value->getheight()) && !empty($value->getcfcweightgross())) {
  609.                     $vlume = ($value->getlength() * $value->getbreadth() * $value->getheight()) / $value->getcfcweightgross();
  610.                     $vlume round($vlume,3);
  611.                 }
  612.                 $sheet->setCellValue('AI'.$index$vlume);
  613.                 $sheet->setCellValue('AJ'.$index, (!empty($value->getvolume_unit()) ? $value->getvolume_unit() : 'M3'));
  614.                 $sheet->setCellValue('AK'.$index'');
  615.                 $sheet->setCellValue('AL'.$index'');
  616.                 $sheet->setCellValue('AM'.$index'');
  617.                 $sheet->setCellValue('AN'.$index$value->getdivision());
  618.                 $sheet->setCellValue('AO'.$index'');
  619.                 $gw $value->getcfcweightgross();
  620.                 if(!empty($gw)) {
  621.                     $gw number_format((float)$gw3'.''');
  622.                 }
  623.                 if ($division == 'ss') {
  624.                     $sheet->setCellValue('AP'.$index'');
  625.                 } else {
  626.                     $sheet->setCellValue('AP'.$index$gw);
  627.                 }
  628.                 $sheet->setCellValue('AQ'.$index, (!empty($value->getcash_discount_indicator()) ? $value->getcash_discount_indicator() : "X"));
  629.                 $sheet->setCellValue('AR'.$index, (!empty($value->getmaterial_statistics_group()) ? $value->getmaterial_statistics_group() : '1'));
  630.                 $sheet->setCellValue('AS'.$index, (!empty($value->getitem_category_group()) ? $value->getitem_category_group() : 'NORM'));
  631.                 $sheet->setCellValue('AT'.$index$value->getproduct_hieararchy());
  632.                 $sheet->setCellValue('AU'.$index, (!empty($value->getmaterial_group1()) ? $value->getmaterial_group1() : 'GFP'));
  633.                 $sheet->setCellValue('AV'.$index$value->getmaterial_group2());
  634.                 $sheet->setCellValue('AW'.$index$value->getmaterial_group3());
  635.                 $sheet->setCellValue('AX'.$index$value->getmaterial_group4());
  636.                 $sheet->setCellValue('AY'.$index$value->getmaterial_group5());
  637.                 $sheet->setCellValue('AZ'.$index'');
  638.                 $sheet->setCellValue('BA'.$index$value->getmaterial_pricing_group());
  639.                 $sheet->setCellValue('BB'.$index$value->getaccount_assignment());
  640.                 $sheet->setCellValue('BC'.$index, (!empty($value->gettax_category()) ? $value->gettax_category() : 'JOIG'));
  641.                 $sheet->setCellValue('BD'.$index, (!empty($value->gettax_classification_material()) ? $value->gettax_classification_material() : '0'));
  642.                 $sheet->setCellValue('BE'.$index, (!empty($value->getbatch_management()) ? $value->getbatch_management() : 'X'));
  643.                 $sheet->setCellValue('BF'.$index, (!empty($value->gettransportation_group()) ? $value->gettransportation_group() : 'Z001'));
  644.                 $sheet->setCellValue('BG'.$index, (!empty($value->getloading_group()) ? $value->getloading_group() : '0001'));
  645.                 $sheet->setCellValue('BH'.$index'');
  646.                 $sheet->setCellValue('BI'.$index'');
  647.                 $sheet->setCellValue('BJ'.$index'');
  648.                 $sheet->setCellValue('BK'.$index$value->getpurchasing_group());
  649.                 $sheet->setCellValue('BL'.$index'');
  650.                 $sheet->setCellValue('BM'.$index$value->gethsn_code());
  651.                 $sheet->setCellValue('BN'.$index'');
  652.                 $sheet->setCellValue('BO'.$index'');
  653.                 $sheet->setCellValue('BP'.$index'');
  654.                 $sheet->setCellValue('BQ'.$index'');
  655.                 $sheet->setCellValue('BR'.$index, (!empty($value->getmrp_type()) ? $value->getmrp_type() : 'X0'));
  656.                 if ($division == 'ss') {
  657.                     $sheet->setCellValue('BS'.$index'');
  658.                     $sheet->setCellValue('BU'.$index'');
  659.                 } else {
  660.                     $sheet->setCellValue('BS'.$index$value->getprocurement_type());
  661.                     $sheet->setCellValue('BU'.$index$value->getproduction_storage_location());
  662.                 }
  663.                 $sheet->setCellValue('BT'.$index'');
  664.                 $sheet->setCellValue('BV'.$index'');
  665.                 $sheet->setCellValue('BW'.$index, (!empty($value->getschedmargin_key()) ? $value->getschedmargin_key() : '000'));
  666.                 $sheet->setCellValue('BX'.$index'');
  667.                 $sheet->setCellValue('BY'.$index'');
  668.                 $sheet->setCellValue('BZ'.$index'');
  669.                 $sheet->setCellValue('CA'.$index$value->getmrp_controller());
  670.                 $sheet->setCellValue('CB'.$index'');
  671.                 $sheet->setCellValue('CC'.$index'');
  672.                 $sheet->setCellValue('CD'.$index'');
  673.                 if ($division == 'ss') {
  674.                     $sheet->setCellValue('CE'.$index'');
  675.                 } else {
  676.                     $sheet->setCellValue('CE'.$index, (!empty($value->getss_days()) ? $value->getss_days() : '4'));
  677.                 }
  678.                 $sheet->setCellValue('CF'.$index, (!empty($value->getlot_size()) ? $value->getlot_size() : 'EX'));
  679.                 $minimum_lot_size = (!empty($value->getminimum_lot_size()) ? $value->getminimum_lot_size() : $value->getcfcweightgross());
  680.                 if ($division == 'ss') {
  681.                     $sheet->setCellValue('CG'.$index'');
  682.                 } else {
  683.                     $sheet->setCellValue('CG'.$index$minimum_lot_size); // fixed value = CFC wt
  684.                 }
  685.                 $mls = (!empty($value->getmaximum_lot_size()) ? $value->getmaximum_lot_size() : $value->getcfcweightgross()*10000);
  686.                 if ($division == 'ss') {
  687.                     $sheet->setCellValue('CH'.$index'');
  688.                 } else {
  689.                     $sheet->setCellValue('CH'.$index$mls); // fixed value = CFC wt *10000
  690.                 }
  691.                 $sheet->setCellValue('CI'.$index'');
  692.                 $rv = (!empty($value->getrounding_value()) ? $value->getrounding_value() : $value->getcfcweightgross());
  693.                 if ($division == 'ss') {
  694.                     $sheet->setCellValue('CJ'.$index'');
  695.                 } else {
  696.                     $sheet->setCellValue('CJ'.$index$rv); //fixed value = CFC wt
  697.                 }
  698.                 $sheet->setCellValue('CK'.$index'02');
  699.                 $sheet->setCellValue('CL'.$index, (!empty($value->getmaterial_freight_group()) ? $value->getmaterial_freight_group() : '0'));
  700.                 $sheet->setCellValue('CM'.$index, (!empty($value->getperiod_indicator()) ? $value->getperiod_indicator() : 'M'));
  701.                 $sheet->setCellValue('CN'.$index, (!empty($value->getselection_method()) ? $value->getselection_method() : '2'));
  702.                 $sheet->setCellValue('CO'.$index'');
  703.                 $sheet->setCellValue('CP'.$index'');
  704.                 $sheet->setCellValue('CQ'.$index'');
  705.                 $sheet->setCellValue('CR'.$index'');
  706.                 $sheet->setCellValue('CS'.$index'');
  707.                 $sheet->setCellValue('CT'.$index'');
  708.                 $sheet->setCellValue('CU'.$index'');
  709.                 $sheet->setCellValue('CV'.$index'');
  710.                 $sheet->setCellValue('CW'.$index'');
  711.                 $sheet->setCellValue('CX'.$index'');
  712.                 $sheet->setCellValue('CY'.$index'01');
  713.                 $sheet->setCellValue('CZ'.$index'');
  714.                 $sheet->setCellValue('DA'.$index'V');
  715.                 $sheet->setCellValue('DB'.$index'');
  716.                 $sheet->setCellValue('DC'.$index'');
  717.                 $sheet->setCellValue('DD'.$index'1');
  718.                 $sheet->setCellValue('DE'.$index$value->getvaluation_class());
  719.                 $sheet->setCellValue('DF'.$index$value->getprofit_center());
  720.                 $sheet->setCellValue('DG'.$index$value->getvaluation_class());
  721.                 $sheet->setCellValue('DH'.$index'1000'); //$value->getlot_size_of_product_cost()
  722.                 $sheet->setCellValue('DI'.$index'X'); //$value->getmaterial_cost()
  723.                 $sheet->setCellValue('DJ'.$index'');
  724.                 $sheet->setCellValue('DK'.$index'');
  725.                 $sheet->setCellValue('DL'.$index'');
  726.                 $sheet->setCellValue('DM'.$index'');
  727.                 $sheet->setCellValue('DN'.$index'X');
  728.                 $sheet->setCellValue('DO'.$index'000001'); //$value->getvariance_key()
  729.                 $sheet->setCellValue('DP'.$index'');
  730.                 $sheet->setCellValue('DQ'.$index'');
  731.                 $sheet->setCellValue('DR'.$index'FBD000001'); //$value->getcatalog_profile()
  732.                 $sheet->setCellValue('DS'.$index$value->getminimum_remaining_shelf_life());
  733.                 $sheet->setCellValue('DT'.$index$value->gettotal_shelf_life());
  734.                 $sheet->setCellValue('DU'.$index'');
  735.                 $sheet->setCellValue('DV'.$index'');
  736.                 $sheet->setCellValue('DW'.$index'');
  737.                 $mro = (!empty($value->getmaterial_related_origin())) ? implode(',',$value->getmaterial_related_origin()) : 'X';
  738.                 $sheet->setCellValue('DX'.$index$mro);
  739.                 $sheet->setCellValue('DY'.$index'');
  740.                 $sheet->setCellValue('DZ'.$index'');
  741.                 $sheet->setCellValue('EA'.$index'D');
  742.                 $sheet->setCellValue('EB'.$index'2');
  743.                 $sheet->setCellValue('EC'.$index'');
  744.                 // $sheet->setCellValue('ED'.$index, $value->getpack_weight());
  745.                 // $sheet->setCellValue('EE'.$index, $value->getcfcweight());
  746.                 $index++;
  747.                 $col++;
  748.             }
  749.         }
  750.         $xlsName $projectName.'LSMW_';
  751.         $fileName = (!empty($xlsName)) ? $xlsName.date('d M').'.xlsx' 'Products'.date('d M').'.xlsx';
  752.         $folderName '';
  753.         try {
  754.             if (!is_dir('product')) {
  755.                 mkdir('product/',0777);
  756.                 $folderName 'product/';
  757.             } else if (is_dir('product')) {
  758.                 $folderName 'product/';
  759.             } else {
  760.                 $folderName '';
  761.             }
  762.         } catch (\Throwable $th) {
  763.             $folderName '';
  764.         }
  765.         try {
  766.             unlink($folderName.$fileName);
  767.         } catch (\Throwable $th) {
  768.         }
  769.         $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
  770.         $writer->save($folderName.$fileName);
  771.         return $folderName.$fileName;
  772.     }
  773.     public function saveYvbymaraAction($projectId,$isProduct false) {
  774.         require_once('third_party/vendor/autoload.php');
  775.         $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
  776.         $sheet $spreadsheet->getActiveSheet();
  777.         if ($projectId) {
  778.             if ($isProduct) {
  779.                 $products DataObject\Products::getById($projectId);
  780.                 if (!empty($products)) {
  781.                     $projectName $products->getname().'_';
  782.                     $products = array($products);
  783.                 } else {
  784.                     return '';
  785.                 }
  786.             } else {
  787.                 $products = new DataObject\ProductByName\Listing();
  788.                 $products->setCondition(" o_id = $projectId ");
  789.                 if (!empty($products->getdata())) {
  790.                     $products $products->getdata()[0];
  791.                     $projectName $products->getproductName().'_';
  792.                     $products $products->getproducts();
  793.                 } else {
  794.                     return '';
  795.                 }
  796.             }
  797.         }
  798.         $xlsHead = array('MSKU','Material','DISCRIPTION','VARIANT','VARIANT_DESCR','SUBCAT','SUBCAT_DESCR','BRAND','CROSSPROMOITC','CROSSPROMONON_ITC','NICHE_NON_NICHE','ATTRIBUTE_Y');
  799.         $col 'A';
  800.         foreach ($xlsHead as $key => $value) {
  801.             $colIndex $col;
  802.             $sheet->setCellValue($col++.'1'$value);
  803.             $sheet->getColumnDimension($colIndex)->setWidth(30);
  804.         }
  805.         $index 2;
  806.         $col 'A';
  807.         foreach ($products as $key => $value) {
  808.             $sheet->setCellValue('A'.$index$value->getold_material_number());
  809.             $sheet->setCellValue('B'.$index$value->getmaterial_number());
  810.             $sheet->setCellValue('C'.$index$value->getmaterial_description());
  811.             $sheet->setCellValue('D'.$index$value->getvariant());
  812.             $sheet->setCellValue('E'.$index$value->getvariant_description());
  813.             $sheet->setCellValue('F'.$index$value->getsubcat());
  814.             $sheet->setCellValue('G'.$index$value->getsubcat_descr());
  815.             $sheet->setCellValue('H'.$index$value->getbrand());
  816.             $sheet->setCellValue('I'.$index$value->getcross_promo_itc());
  817.             $sheet->setCellValue('J'.$index$value->getcross_promo_nonitc());
  818.             $sheet->setCellValue('K'.$index$value->getniche_non_niche());
  819.             $sheet->setCellValue('L'.$index$value->getattribute_y());
  820.             $index++;
  821.         }
  822.         $xlsName $projectName.'YVBYMARA_'.date('d M').'.xlsx';
  823.         $fileName $xlsName;
  824.         $folderName '';
  825.         try {
  826.             if (!is_dir('product')) {
  827.                 mkdir('product/',0777);
  828.                 $folderName 'product/';
  829.             } else if (is_dir('product')) {
  830.                 $folderName 'product/';
  831.             } else {
  832.                 $folderName '';
  833.             }
  834.         } catch (\Throwable $th) {
  835.             $folderName '';
  836.         }
  837.         try {
  838.             unlink($folderName.$fileName);
  839.         } catch (\Throwable $th) {
  840.             //echo $th; exit;
  841.         }
  842.         $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
  843.         $writer->save($folderName.$fileName);
  844.         return $folderName.$fileName;
  845.     }
  846.     public function saveAdditionalDataAction($projectId false$isProduct false) {
  847.         require_once('third_party/vendor/autoload.php');
  848.         $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
  849.         $sheet $spreadsheet->getActiveSheet();
  850.         $xlsHead = array('Material','view','EAN','Z1','BG','Z1 DISC','BG DISC','ST Denominator','PAC Denominator','CFC Denominator','ST','PAC','CFC','ST Numerator','PAC Numerator','CFC Numerator','L','B','H','M','M3','M3/KG  Denominator','M3/KG','M3/KG  Numerator','HE','vajra');
  851.         if ($projectId) {
  852.             if ($isProduct) {
  853.                 $products DataObject\Products::getById($projectId);
  854.                 if (!empty($products)) {
  855.                     $projectName $products->getname().'_';
  856.                     $products = array($products);
  857.                 } else {
  858.                     return '';
  859.                 }
  860.             } else {
  861.                 $products = new DataObject\ProductByName\Listing();
  862.                 $products->setCondition(" o_id = $projectId ");
  863.                 if (!empty($products->getdata())) {
  864.                     $products $products->getdata()[0];
  865.                     $projectName $products->getproductName().'_';
  866.                     $products $products->getproducts();
  867.                 } else {
  868.                     return '';
  869.                 }
  870.             }
  871.         }
  872.         $col 'A';
  873.         foreach ($xlsHead as $key => $value) {
  874.             $colIndex $col;
  875.             $sheet->setCellValue($col++.'1'$value);
  876.             $sheet->getColumnDimension($colIndex)->setWidth(30);
  877.         }
  878.         $index 2;
  879.         $col 'A';
  880.         foreach ($products as $key => $value) {
  881.             $sheet->setCellValue('A'.$index$value->getmaterial_number());
  882.             $sheet->setCellValue('B'.$index'X');
  883.             $sheet->setCellValue('C'.$index$value->getean_number());
  884.             $sheet->setCellValue('D'.$index'Z1');
  885.             $sheet->setCellValue('E'.$index"BG");
  886.             $sheet->setCellValue('F'.$index$value->getzi_disc());
  887.             $sheet->setCellValue('G'.$index$value->getbg_disc());
  888.             $sheet->setCellValue('H'.$index'1');
  889.             $sheet->setCellValue('I'.$index'1000');
  890.             $sheet->setCellValue('J'.$index'1000');
  891.             $sheet->setCellValue('K'.$index'ST');
  892.             $sheet->setCellValue('L'.$index'PAC');
  893.             $sheet->setCellValue('M'.$index'CFC');
  894.             $sheet->setCellValue('N'.$index'1');
  895.             $sheet->setCellValue('O'.$index$value->getpack_weight());
  896.             $gw $value->getcfcweightgross();
  897.             if(!empty($gw)) {
  898.                 $gw number_format((float)$gw3'.''');
  899.             }
  900.             $sheet->setCellValue('P'.$index$gw);
  901.             $sheet->setCellValue('Q'.$index$value->getlength());
  902.             $sheet->setCellValue('R'.$index$value->getbreadth());
  903.             $sheet->setCellValue('S'.$index$value->getheight());
  904.             $sheet->setCellValue('T'.$index'M');
  905.             $sheet->setCellValue('U'.$index'M3');
  906.             $v '';
  907.             if(!empty($value->getlength()) && !empty($value->getbreadth()) * !empty($value->getheight())) {
  908.                 $v round(($value->getlength()*$value->getbreadth()*$value->getheight()),3);
  909.             }
  910.             $sheet->setCellValue('V'.$index$v);
  911.             $sheet->setCellValue('W'.$index'M3');
  912.             $sheet->setCellValue('X'.$index$gw);
  913.             $sheet->setCellValue('Y'.$index'HE');
  914.             $sheet->setCellValue('Z'.$index$value->getvajra_description());
  915.             $index++;
  916.         }
  917.         $xlsName $projectName.'Additional_Data_';
  918.         $fileName = (!empty($xlsName)) ? $xlsName.date('d M').'.xlsx' 'Additional_Data'.date('d M').'.xlsx';
  919.         $folderName '';
  920.         try {
  921.             if (!is_dir('product')) {
  922.                 mkdir('product/',0777);
  923.                 $folderName 'product/';
  924.             } else if (is_dir('product')) {
  925.                 $folderName 'product/';
  926.             } else {
  927.                 $folderName '';
  928.             }
  929.         } catch (\Throwable $th) {
  930.             $folderName '';
  931.         }
  932.         try {
  933.             unlink($folderName.$fileName);
  934.         } catch (\Throwable $th) {
  935.             //echo $th; exit;
  936.         }
  937.         $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
  938.         $writer->save($folderName.$fileName);
  939.         return $folderName.$fileName;
  940.     }
  941.     public function applyTransition($objectData,$toPlace,$isProductClass true) {
  942.         foreach ($toPlace as $key => $value) {
  943.             if ($isProductClass) {
  944.                 // if($objectData->getpreviousWorkflowPlace() != 'sap_action' || $value != 'sap_action') {
  945.                     $objectData->setpreviousWorkflowPlace($value);
  946.                 // }
  947.             }
  948.             switch ($value) {
  949.                 case 'finance_action':
  950.                     $this->financeAction($objectData);
  951.                     break;
  952.                 case 'brand_action':
  953.                     $this->brandAction($objectData);
  954.                     break;
  955.                 case 'packaging_action':
  956.                     $this->packagingAction($objectData);
  957.                     break;
  958.                 case 'indirect_tax_action':
  959.                     $this->indirectTaxAction($objectData);
  960.                     break;
  961.                 case 'operations_action':
  962.                     $this->operationsAction($objectData);
  963.                     break;
  964.                 case 'demand_planning_action':
  965.                     $this->demandPlanningAction($objectData);
  966.                     break;
  967.                 case 'smis_action':
  968.                     $this->smisAction($objectData);
  969.                     break;
  970.                 case 'sap_action':
  971.                     $this->sapAction($objectData);
  972.                     break;
  973.                 case 'packaging_to_snop':
  974.                     $this->packagingToSnop($objectData);
  975.                     break;
  976.                 case 'finance_to_snop':
  977.                     $this->financeToSnop($objectData);
  978.                     break;
  979.                 case 'brand_to_snop':
  980.                     $this->brandToSnop($objectData);
  981.                     break;
  982.                 case 'indirectTax_to_snop':
  983.                     $this->indirectTaxToSnop($objectData);
  984.                     break;
  985.                 case 'operations_to_snop':
  986.                     $this->operationsToSnop($objectData);
  987.                     break;
  988.                 case 'demandPlanning_to_snop':
  989.                     $this->demandPlanningToSnop($objectData);
  990.                     break;
  991.                 case 'smis_to_snop':
  992.                     $this->smisToSnop($objectData);
  993.                     break;
  994.                 case 'packaging_correction':
  995.                     $this->packagingCorrection($objectData);
  996.                     break;
  997.                 case 'finance_correction':
  998.                     $this->financeCorrection($objectData);
  999.                     break;
  1000.                 case 'brand_correction':
  1001.                     $this->brandCorrection($objectData);
  1002.                     break;
  1003.                 
  1004.                 case 'indirectTax_correction':
  1005.                     $this->indirectTaxCorrection($objectData);
  1006.                     break;
  1007.                 
  1008.                 case 'operations_correction':
  1009.                     $this->operationteamCorrection($objectData);
  1010.                     break;
  1011.                 
  1012.                 case 'demandPlanning_correction':
  1013.                     $this->demandPlanningTeam($objectData);
  1014.                     break;
  1015.                 
  1016.                 case 'smis_correction':
  1017.                     $this->smisTeam($objectData);
  1018.                     break;
  1019.                 case 'snop_correction':
  1020.                     $this->snopCorrection($objectData);
  1021.                     break;
  1022.                 case 'sap_approved':
  1023.                     $this->sapApproved($objectData);
  1024.                     break;
  1025.    
  1026.                 case 'snop_packaging_correction':
  1027.                     $this->packagingCorrection($objectData);
  1028.                     break;
  1029.                 case 'snop_finance_correction':
  1030.                     $this->financeCorrection($objectData);
  1031.                     break;
  1032.                 case 'snop_brand_correction':
  1033.                     $this->brandCorrection($objectData);
  1034.                     break;
  1035.                 case 'snop_indirectTax_correction':
  1036.                     $this->indirectTaxCorrection($objectData);
  1037.                     break;
  1038.                 case 'snop_operations_correction':
  1039.                     $this->operationteamCorrection($objectData);
  1040.                     break;
  1041.                 case 'snop_demandPlanning_correction':
  1042.                     $this->demandPlanningTeam($objectData);
  1043.                     break;
  1044.                 case 'snop_smis_correction':
  1045.                     $this->smisTeam($objectData);
  1046.                     break;
  1047.                     
  1048.                 default:
  1049.                     # code...
  1050.                     break;
  1051.             }
  1052.         }
  1053.     }
  1054. }