Exemplo n.º 1
0
						$object->gps = array(0, 0);
					}
				}

				// To not set code if third party is not concerned. But if it had values, we keep them.
				if (empty($object->client) && empty($oldcopy->code_client))
					$object->code_client = '';
				if (empty($object->fournisseur) && empty($oldcopy->code_fournisseur))
					$object->code_fournisseur = '';
				//var_dump($object);exit;
				$soc = new Societe($db);
				// For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts)
				if ($object->Accounting->CustomCode == -1)
					$object->Accounting->CustomCode = $soc->get_codeclient($object->prefix_comm, 0);
				if ($object->Accounting->SupplierCode == -1)
					$object->Accounting->SupplierCode = $soc->get_codefournisseur($object->prefix_comm, 1);

				//$object->update($socid,$user,1,$oldcopy->codeclient_modifiable(),$oldcopy->codefournisseur_modifiable());

				try {
					$couchdb->clean($object);
					$couchdb->storeDoc($object);
					$result = 1;
				} catch (Exception $e) {
					$error = "Something weird happened: " . $e->getMessage() . " (errcode=" . $e->getCode() . ")\n";
					print $error;
					exit;
				}

				if ($result <= 0) {
					$error = $object->error;