Ejemplo n.º 1
0
 function toSoftone()
 {
     $softone = new Softone();
     $params["fSQL"] = "SELECT * FROM MTRMANFCTR where MTRMANFCTR = " . $this->id;
     $datas = $softone->createSql($params);
     //print_r($datas);
     if (@count($datas->data)) {
         return;
     }
     $params["fSQL"] = 'Insert INTO MTRMANFCTR (MTRMANFCTR,NAME,CODE,COMPANY) VALUES (' . $this->id . ',\'' . $this->title . '\', \'' . $this->code . '\',1000)';
     $softone->createSql($params);
 }
Ejemplo n.º 2
0
 function toSoftone()
 {
     $softone = new Softone();
     $params["fSQL"] = "SELECT * FROM MTRMARK where MTRMARK = " . $this->id;
     $datas = $softone->createSql($params);
     if (@count($datas->data)) {
         return;
     }
     $params["fSQL"] = 'Insert INTO MTRMARK (MTRMARK,NAME,CODE,COMPANY,SODTYPE) VALUES (' . $this->id . ',\'' . $this->supplier . '\', \'' . $this->id . '\',1000,51)';
     print_r($softone->createSql($params));
 }
Ejemplo n.º 3
0
 function retrieve($params = array())
 {
     $object = $params["object"];
     $em = $this->getDoctrine()->getManager();
     $fields = $em->getClassMetadata($params["object"])->getFieldNames();
     //print_r($fields);
     $itemfield = array();
     $itemfield[] = "M." . $params["softone_table"];
     foreach ($fields as $field) {
         $ffield = " " . $field;
         if (strpos($ffield, $params["softone_object"]) == true) {
             $itemfield[] = "M." . strtoupper(str_replace($params["softone_object"], "", $field));
         }
     }
     foreach ($params["extra"] as $field => $extra) {
         //if (@$data[$extra] AND in_array($field, $fields)) {
         if ($field == $extra) {
             $itemfield[] = "M." . strtoupper($field);
         } else {
             $itemfield[] = "M." . strtoupper($field) . " as {$extra}";
         }
         //}
     }
     $selfields = implode(",", $itemfield);
     $params["fSQL"] = 'SELECT ' . $selfields . ' FROM ' . $params["softone_table"] . ' M ' . $params["filter"];
     //echo $params["fSQL"];
     //$params["fSQL"] = 'SELECT M.* FROM ' . $params["softone_table"] . ' M ' . $params["filter"];
     //echo $params["fSQL"];
     //return;
     $softone = new Softone();
     $datas = $softone->createSql($params);
     //print_r($datas);
     //return;
     foreach ($datas->data as $data) {
         $data = (array) $data;
         $entity = $this->getDoctrine()->getRepository($params["repository"])->findOneBy(array("reference" => (int) $data[$params["softone_table"]]));
         $dt = new \DateTime("now");
         if (@$entity->id == 0) {
             $entity = new $object();
             $entity->setTs($dt);
             $entity->setCreated($dt);
             $entity->setModified($dt);
         } else {
             $entity->setRepositories();
         }
         @print_r($entity->repositories);
         foreach ($params["relation"] as $field => $extra) {
             //echo $field." - ".@$data[$extra]."<BR>";
             if (@$data[$extra] and in_array($field, $fields)) {
                 $entity->setField($field, @$data[$extra]);
             }
             //echo @$entity->repositories[$field];
             if (@$data[$extra] and @$entity->repositories[$field]) {
                 $rel = $this->getDoctrine()->getRepository($entity->repositories[$field])->findOneById($data[$extra]);
                 $entity->setField($field, $rel);
             }
         }
         $imporetedData = array();
         $entity->setReference($data[$params["softone_table"]]);
         $this->flushpersist($entity);
         $q = array();
         foreach ($data as $identifier => $val) {
             $imporetedData[strtolower($params["softone_object"] . "_" . $identifier)] = addslashes($val);
             $ad = strtolower($identifier);
             $baz = $params["softone_object"] . ucwords(str_replace("_", " ", $ad));
             if (in_array($baz, $fields)) {
                 $q[] = "`" . strtolower($params["softone_object"] . "_" . $identifier) . "` = '" . addslashes($val) . "'";
                 //$entity->setField($baz, $val);
             }
         }
         @($entity_id = (int) $entity->id);
         if (@$entity_id > 0) {
             $sql = "update " . strtolower($params["table"]) . " set " . implode(",", $q) . " where id = '" . $entity_id . "'";
             $em->getConnection()->exec($sql);
             foreach ($params["extrafunction"] as $field => $func) {
                 $entity->{$func}();
             }
         }
         //if (@$i++ > 500)
         //    break;
     }
 }
Ejemplo n.º 4
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.º 5
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.º 6
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();
         }
     }
 }
 /**
  * @Route("/customer/retrieve")
  */
 function retrieveSoftoneData($params = array())
 {
     $this->retrieveCustomer();
     $params["list"] = 'partsbox';
     $params = array("softone_object" => "CUSTOMER", "eav_model" => "customer", "model" => "Customer", "list" => "monitor");
     set_time_limit(100000);
     ini_set('memory_limit', '2256M');
     $softone = new Softone();
     $em = $this->getDoctrine()->getManager();
     $fields = $em->getClassMetadata('SoftoneBundle\\Entity\\Customer')->getFieldNames();
     $date = "2016-02-01";
     $filters = "CUSTOMER.UPDDATE=" . $date . "&CUSTOMER.UPDDATE_TO=" . date("Y-m-d");
     $datas = $softone->retrieveData($params["softone_object"], $params["list"], $filters);
     foreach ($datas as $data) {
         $data = (array) $data;
         $zoominfo = $data["zoominfo"];
         $info = explode(";", $zoominfo);
         $entity = $this->getDoctrine()->getRepository($this->repository)->findOneBy(array("reference" => (int) $info[1]));
         if (@$entity->id == 0) {
             $entity = new Customer();
             $dt = new \DateTime("now");
             $entity->setTs($dt);
             $entity->setField("reference", (int) $info[1]);
             //$entity->setCustomerInsdate($dt);
             //$entity->setCustomerUpddate($dt);
             $entity->setCreated($dt);
             $entity->setModified($dt);
         }
         $this->flushpersist($entity);
         $q = array();
         foreach ($data as $identifier => $val) {
             $imporetedData[strtolower($identifier)] = addslashes($val);
             $ad = strtolower(str_replace(strtolower($params["softone_object"]) . "_", "", $identifier));
             $baz = strtolower($params["softone_object"]) . ucwords(str_replace("_", " ", $ad));
             //echo $baz."<BR>";
             if (in_array($baz, $fields)) {
                 $q[] = "`" . strtolower($identifier) . "` = '" . addslashes($val) . "'";
                 //$entity->setField($baz, $val);
             }
         }
         @($entity_id = (int) $entity->id);
         if (@$entity_id > 0) {
             $sql = "update softone_customer set " . implode(",", $q) . " where id = '" . $entity_id . "'";
             //echo $sql."<BR>";
             $em->getConnection()->exec($sql);
         }
         //break;
     }
     $datas = $softone->getCustomerAddresses();
     $sql = "truncate softone_customeraddress";
     $em->getConnection()->exec($sql);
     $fields = $em->getClassMetadata('SoftoneBundle\\Entity\\Customeraddress')->getFieldNames();
     //print_r($datas);
     if (@$datas->data) {
         foreach ($datas->data as $data) {
             $data = (array) $data;
             $customer = $this->getDoctrine()->getRepository($this->repository)->findOneBy(array("reference" => (int) $data["TRDR"]));
             $entity = new \SoftoneBundle\Entity\Customeraddress();
             $entity->setCustomer($customer);
             $entity->setReference($data["TRDR"]);
             $this->flushpersist($entity);
             $q = array();
             foreach ($data as $identifier => $val) {
                 if (in_array(strtolower($identifier), $fields)) {
                     $q[] = "`" . strtolower($identifier) . "` = '" . addslashes($val) . "'";
                     //$entity->setField($baz, $val);
                 }
             }
             @($entity_id = (int) $entity->id);
             $sql = "update softone_customeraddress set " . implode(",", $q) . " where id = '" . $entity_id . "'";
             $em->getConnection()->exec($sql);
             //echo $sql . "<BR>";
         }
     }
     exit;
 }