public function create($elementType, $element)
 {
     $element = $this->restrictFields($element);
     $taxName = $this->getNewTaxName();
     $element['taxname'] = $taxName;
     $element['deleted'] = 0;
     $createdElement = parent::create($elementType, $element);
     $sql = "alter table vtiger_inventoryproductrel add column {$taxName} decimal(7,3)";
     $result = $this->pearDB->pquery($sql, array());
     if (!is_object($result)) {
         list($typeId, $id) = vtws_getIdComponents($element['id']);
         $this->dropRow($id);
         throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, "Database error while adding tax column({$taxName}) for inventory lineitem table");
     }
     return $createdElement;
 }
 public function create($elementType, $element)
 {
     $db = PearDatabase::getInstance();
     $sql = 'select * from vtiger_organizationdetails';
     $result = $db->pquery($sql, $params);
     $rowCount = $db->num_rows($result);
     if ($rowCount > 0) {
         $id = $db->query_result($result, 0, 'organization_id');
         $meta = $this->getMeta();
         $element['id'] = vtws_getId($meta->getEntityId(), $id);
         return $this->revise($element);
     } else {
         $element = $this->handleFileUpload($element);
         return parent::create($elementType, $element);
     }
 }
 public function create($elementType, $element)
 {
     $db = PearDatabase::getInstance();
     $sql = 'SELECT * FROM vtiger_producttaxrel WHERE productid =? AND taxid=?';
     list($typeId, $productId) = vtws_getIdComponents($element['productid']);
     list($typeId, $taxId) = vtws_getIdComponents($element['taxid']);
     $params = array($productId, $taxId);
     $result = $db->pquery($sql, $params);
     $rowCount = $db->num_rows($result);
     if ($rowCount > 0) {
         $id = $db->query_result($result, 0, $this->meta->getObectIndexColumn());
         $meta = $this->getMeta();
         $element['id'] = vtws_getId($meta->getEntityId(), $id);
         return $this->update($element);
     } else {
         unset($element['id']);
         return parent::create($elementType, $element);
     }
 }
 public function _create($elementType, $element)
 {
     $createdElement = parent::create($elementType, $element);
     $productId = vtws_getIdComponents($element['productid']);
     $productId = $productId[1];
     $parentTypeHandler = vtws_getModuleHandlerFromId($element['parent_id'], $this->user);
     $parentTypeMeta = $parentTypeHandler->getMeta();
     $parentType = $parentTypeMeta->getEntityName();
     $parent = $this->getParentById($element['parent_id']);
     if ($parentType != 'PurchaseOrder') {
         //update the stock with existing details
         updateStk($productId, $element['quantity'], '', array(), $parentType);
     }
     $this->initTax($element, $parent);
     $this->updateTaxes($createdElement);
     $createdElement['incrementondel'] = '1';
     if (strcasecmp($parent['hdnTaxType'], $this->Individual) === 0) {
         $createdElement = $this->appendTaxInfo($createdElement);
     }
     return $createdElement;
 }