Ejemplo n.º 1
0
 function toSoftone()
 {
     //if ($this->reference)
     global $kernel;
     if ('AppCache' == get_class($kernel)) {
         $kernel = $kernel->getKernel();
     }
     $em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
     $object = "ITEM";
     $softone = new Softone();
     //$fields = $softone->retrieveFields($object, $params["list"]);
     echo $softone->appId;
     $fields[] = "item_code";
     $fields[] = "item_name";
     $fields[] = "item_code1";
     $fields[] = "item_code2";
     $fields[] = "item_name1";
     $fields[] = "item_mtrunit1";
     $fields[] = "item_pricew";
     $fields[] = "item_pricer";
     $fields[] = "item_pricew01";
     $fields[] = "item_pricer01";
     $fields[] = "item_pricew02";
     $fields[] = "item_pricew03";
     $fields[] = "item_pricer02";
     $fields[] = "item_vat";
     $fields[] = "item_mtrmanfctr";
     $fields[] = "item_mtrplace";
     $fields[] = "item_apvcode";
     $fields[] = "item_isactive";
     //$fields[] = "item_mtrsup";
     $fields[] = "item_mtrcategory";
     $fields[] = "item_markupw";
     $fields[] = "item_isactive";
     $fields[] = "item_mtrmark";
     $fields[] = "item_cccfxreltdcode";
     $fields[] = "item_cccfxrelbrand";
     //print_r($fields);
     //return;
     $objectArr = array();
     $objectArr2 = array();
     if ($this->reference > 0) {
         $data = $softone->getData($object, $this->reference);
         $objectArr = $data->data->{$object};
         $objectArr2 = (array) $objectArr[0];
     } else {
         $filters = $object . ".CODE=" . $this->itemCode . "&" . $object . ".CODE_TO=" . $this->itemCode;
         $datas = $softone->retrieveData($object, "partsbox", $filters);
         foreach ($datas as $data) {
             $data = (array) $data;
             $zoominfo = $data["zoominfo"];
             $info = explode(";", $zoominfo);
             $this->reference = $info[1];
             break;
         }
         $data = $softone->getData($object, $this->reference);
         $objectArr = $data->data->{$object};
         $objectArr2 = (array) $objectArr[0];
     }
     foreach ($fields as $field) {
         $field1 = strtoupper(str_replace(strtolower($object) . "_", "", $field));
         $field2 = lcfirst($this->createName($field));
         //echo $field2 . "<BR>";
         @($objectArr2[$field1] = $this->{$field2});
         //}
     }
     $objectArr2["MTRUNIT1"] = 101;
     $objectArr2["VAT"] = 1310;
     $objectArr2["CODE2"] = $this->supplierCode;
     $objectArr2["ISACTIVE"] = $this->itemIsactive;
     $objectArr2["MTRMANFCTR"] = $this->itemMtrmanfctr > 0 ? $this->itemMtrmanfctr : 1000;
     $objectArr[0] = $objectArr2;
     $dataOut[$object] = (array) $objectArr;
     //@$dataOut["ITEEXTRA"][0] = array("NUM02" => $this->item_mtrl_iteextra_num02);
     //print_r(@$dataOut);
     $out = $softone->setData((array) $dataOut, $object, (int) $this->reference);
     //print_r($out);
     if (@$out->id > 0) {
         $this->reference = $out->id;
         $em->persist($this);
         $em->flush();
         $this->itemMtrmark = $this->itemMtrmark > 0 ? $this->itemMtrmark : 1000;
         $this->itemMtrmanfctr = $this->itemMtrmanfctr > 0 ? $this->itemMtrmanfctr : 1000;
         $params["fSQL"] = "UPDATE MTRL SET MTRMANFCTR=" . $this->itemMtrmanfctr . " , MTRMARK=" . $this->itemMtrmark . " WHERE MTRL = " . $this->reference;
         print_r($softone->createSql($params));
     }
 }
Ejemplo n.º 2
0
 function saveProductSoftone($model)
 {
     $object = "ITEM";
     $softone = new Softone();
     //$fields = $softone->retrieveFields($object, $params["list"]);
     $fields[] = "item_code";
     $fields[] = "item_name";
     $fields[] = "item_code1";
     $fields[] = "item_code2";
     $fields[] = "item_name1";
     $fields[] = "item_mtrunit1";
     $fields[] = "item_pricew";
     $fields[] = "item_pricer";
     $fields[] = "item_pricew01";
     $fields[] = "item_pricer01";
     $fields[] = "item_pricew02";
     $fields[] = "item_pricew03";
     $fields[] = "item_pricer02";
     $fields[] = "item_vat";
     $fields[] = "item_mtrmanfctr";
     $fields[] = "item_mtrplace";
     $fields[] = "item_isactive";
     //$fields[] = "item_mtrsup";
     $fields[] = "item_mtrcategory";
     $fields[] = "item_markupw";
     $fields[] = "item_isactive";
     $fields[] = "item_cccfxreltdcode";
     $fields[] = "item_cccfxrelbrand";
     //print_r($fields);
     //return;
     //echo 'sss';
     if ($model->reference) {
         $data = $softone->getData($object, $model->reference);
         $objectArr = $data->data->{$object};
         $objectArr2 = (array) $objectArr[0];
         foreach ($fields as $field) {
             $field1 = strtoupper(str_replace(strtolower($object) . "_", "", $field));
             $objectArr2[$field1] = $model->getField($field);
             //}
         }
         $objectArr2["CODE2"] = $model->supplier_code;
         $objectArr2["ISACTIVE"] = $model->item_isactive;
         $objectArr2["PRICER01"] = $objectArr2["PRICEW01"] * 1.23;
         $objectArr2["PRICER02"] = $objectArr2["PRICEW02"] * 1.23;
         $objectArr[0] = $objectArr2;
         $dataOut[$object] = (array) $objectArr;
         $dataOut["ITEEXTRA"][0] = array("NUM02" => $model->item_mtrl_iteextra_num02);
         //print_r($dataOut);
         $out = $softone->setData((array) $dataOut, $object, $model->reference);
         //print_r($out);
     } else {
         $objectArr = array();
         foreach ($fields as $field) {
             $field1 = strtoupper(str_replace(strtolower($object) . "_", "", $field));
             $as = explode("_", $field);
             $asf = $as[0] . ucfirst($as[1]);
             $objectArr2[$field1] = $model->getField($asf);
         }
         $objectArr2["MTRUNIT1"] = 101;
         //$model->supplierCode;
         //$objectArr2["ISACTIVE"] = $model->item_isactive;
         $objectArr2["PRICER01"] = $objectArr2["PRICEW01"] * 1.23;
         $objectArr2["PRICER02"] = $objectArr2["PRICEW02"] * 1.23;
         $objectArr[0] = $objectArr2;
         $dataOut[$object] = (array) $objectArr;
         //$dataOut["ITEEXTRA"][0] = array("NUM02" => $model->item_mtrl_iteextra_num02);
         //print_r($dataOut);
         $out = $softone->setData((array) $dataOut, $object, (int) $model->reference);
         if ($out->id > 0) {
             $model->setField("reference", $out->id);
             @$this->flushpersist($model);
         }
         //print_r($out);
     }
     return $model;
 }
Ejemplo n.º 3
0
 function toSoftone()
 {
     //if ($this->reference)
     global $kernel;
     if ('AppCache' == get_class($kernel)) {
         $kernel = $kernel->getKernel();
     }
     $em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
     $object = "CUSTOMER";
     $softone = new Softone();
     $fields = $softone->retrieveFields($object, "partsbox");
     //echo $this->reference . "\n";
     //print_r($fields);
     $objectArr = array();
     $objectArr2 = array();
     if ((int) $this->reference > 0) {
         $data = $softone->getData($object, $this->reference);
         //print_r($data);
         $objectArr = $data->data->{$object};
         //print_r($objectArr);
         $objectArr2 = (array) $objectArr[0];
     } else {
         $filters = "CUSTOMER.CODE=" . $this->customerCode . "&CUSTOMER.CODE_TO=" . $this->customerCode;
         $datas = $softone->retrieveData($object, "partsbox", $filters);
         foreach ($datas as $data) {
             $data = (array) $data;
             $zoominfo = $data["zoominfo"];
             $info = explode(";", $zoominfo);
             $this->reference = $info[1];
             break;
         }
         $data = $softone->getData($object, $this->reference);
         $objectArr = $data->data->{$object};
         $objectArr2 = (array) $objectArr[0];
     }
     foreach ($fields as $field) {
         $field1 = strtoupper(str_replace(strtolower($object) . "_", "", $field));
         $field2 = lcfirst($this->createName($field));
         //echo $field2 . "<BR>";
         @($objectArr2[$field1] = $this->{$field2});
         //}
     }
     $objectArr[0] = $objectArr2;
     $dataOut[$object] = (array) $objectArr;
     //@$dataOut["ITEEXTRA"][0] = array("NUM02" => $this->item_mtrl_iteextra_num02);
     //print_r(@$dataOut);
     $out = $softone->setData((array) $dataOut, $object, (int) $this->reference);
     //print_r($out);
     if (@$out->id > 0) {
         $filters = "CUSTOMER.CODE=" . $this->customerCode . "&CUSTOMER.CODE_TO=" . $this->customerCode;
         $datas = $softone->retrieveData($object, "partsbox", $filters);
         foreach ($datas as $data) {
             $data = (array) $data;
             $zoominfo = $data["zoominfo"];
             $info = explode(";", $zoominfo);
             $this->reference = $info[1];
             break;
         }
         if ($this->reference > 0) {
             $em->persist($this);
             $em->flush();
         }
     }
 }