本文整理汇总了PHP中Commande::valid方法的典型用法代码示例。如果您正苦于以下问题:PHP Commande::valid方法的具体用法?PHP Commande::valid怎么用?PHP Commande::valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commande
的用法示例。
在下文中一共展示了Commande::valid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validOrder
/**
* Validate an order
*
* @param int $id Order ID
* @param int $idwarehouse Warehouse ID
*
* @url GET order/{id}/validate
* @url POST order/{id}/validate
*
* @return array
*
*/
function validOrder($id, $idwarehouse = 0)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if (!$result) {
throw new RestException(404, 'Order not found');
}
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
}
if (!$this->commande->valid(DolibarrApiAccess::$user, $idwarehouse)) {
throw new RestException(500, 'Error when validate order');
}
return array('success' => array('code' => 200, 'message' => 'Order validated'));
}
示例2: mktime
$com->socid = 4;
// Put id of third party (rowid in llx_societe table)
$com->date_commande = mktime();
$com->note = 'A comment';
$com->source = 1;
$com->remise_percent = 0;
$orderline1 = new OrderLine($db);
$orderline1->tva_tx = 10.0;
$orderline1->remise_percent = 0;
$orderline1->qty = 1;
$com->lines[] = $orderline1;
// Create order
$idobject = $com->create($user);
if ($idobject > 0) {
// Change status to validated
$result = $com->valid($user);
if ($result > 0) {
print "OK Object created with id " . $idobject . "\n";
} else {
$error++;
dol_print_error($db, $com->error);
}
} else {
$error++;
dol_print_error($db, $com->error);
}
// -------------------- END OF YOUR CODE --------------------
if (!$error) {
$db->commit();
print '--- end ok' . "\n";
} else {
示例3: updateOrder
/**
* Update an order
*
* @param array $authentication Array of authentication information
* @param array $order Order info
* @return array Array result
*/
function updateOrder($authentication, $order)
{
global $db, $conf, $langs;
$now = dol_now();
dol_syslog("Function: updateOrder login=" . $authentication['login']);
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
// Init and check authentication
$objectresp = array();
$errorcode = '';
$errorlabel = '';
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
// Check parameters
if (empty($order['id']) && empty($order['ref']) && empty($order['ref_ext'])) {
$error++;
$errorcode = 'KO';
$errorlabel = "Order id or ref or ref_ext is mandatory.";
}
if (!$error) {
$objectfound = false;
include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$object = new Commande($db);
$result = $object->fetch($order['id'], empty($order['id']) ? $order['ref'] : '', empty($order['id']) && empty($order['ref']) ? $order['ref_ext'] : '');
if (!empty($object->id)) {
$objectfound = true;
$db->begin();
if (isset($order['status'])) {
if ($order['status'] == -1) {
$result = $object->cancel($fuser);
}
if ($order['status'] == 1) {
$result = $object->valid($fuser);
}
if ($order['status'] == 0) {
$result = $object->set_reopen($fuser);
}
if ($order['status'] == 3) {
$result = $object->cloture($fuser);
}
}
if (isset($order['billed'])) {
if ($order['billed']) {
$result = $object->classifyBilled($fuser);
}
if (!$order['billed']) {
$result = $object->classifyBilled($fuser);
}
}
//Retreive all extrafield for object
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label('commande', true);
foreach ($extrafields->attribute_label as $key => $label) {
$key = 'options_' . $key;
if (isset($order[$key])) {
$result = $object->setValueFrom($key, $order[$key], 'commande_extrafields');
}
}
if ($result <= 0) {
$error++;
}
}
if (!$error && $objectfound) {
$db->commit();
$objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id);
} elseif ($objectfound) {
$db->rollback();
$error++;
$errorcode = 'KO';
$errorlabel = $object->error;
} else {
$error++;
$errorcode = 'NOT_FOUND';
$errorlabel = 'Order id=' . $order['id'] . ' ref=' . $order['ref'] . ' ref_ext=' . $order['ref_ext'] . ' cannot be found';
}
}
if ($error) {
$objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;
}
示例4: validOrder
/**
* Valid an order
*
* @param array $authentication Array of authentication information
* @param int $id Id of order to validate
* @return array Array result
*/
function validOrder($authentication, $id = '')
{
global $db, $conf, $langs;
dol_syslog("Function: validOrder login=" . $authentication['login'] . " id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext);
// Init and check authentication
$objectresp = array();
$errorcode = '';
$errorlabel = '';
$error = 0;
if ($authentication['entity']) {
$conf->entity = $authentication['entity'];
}
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if (!$error) {
$fuser->getrights();
if ($fuser->rights->commande->lire) {
$order = new Commande($db);
$result = $order->fetch($id, $ref, $ref_ext);
$order->fetch_thirdparty();
$db->begin();
if ($result > 0) {
$result = $order->valid($fuser);
if ($result >= 0) {
// Define output language
$outputlangs = $langs;
commande_pdf_create($db, $order, $order->modelpdf, $outputlangs, 0, 0, 0);
} else {
$db->rollback();
$error++;
$errorcode = 'KO';
$errorlabel = $newobject->error;
}
} else {
$db->rollback();
$error++;
$errorcode = 'KO';
$errorlabel = $newobject->error;
}
} else {
$db->rollback();
$error++;
$errorcode = 'KO';
$errorlabel = $newobject->error;
}
}
if ($error) {
$objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
} else {
$db->commit();
$objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''));
}
return $objectresp;
}