/** * 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="******" 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; $order->generateDocument($order->modelpdf, $outputlangs); } 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; }
/** * Create a document onto disk accordign to template module. * * @param DoliDB $db Database handler * @param Object $object Object order * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref * @return int 0 if KO, 1 if OK * @deprecated Use the new function generateDocument of Commande class */ function commande_pdf_create(DoliDB $db, Commande $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); }
/** * Create a document onto disk accordign to template module. * * @param DoliDB $db Database handler * @param Commande $object Object order * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref * @return int 0 if KO, 1 if OK * @deprecated Use the new function generateDocument of Commande class * @see Commande::generateDocument() */ function commande_pdf_create(DoliDB $db, Commande $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); }
/** * testCommandeBuild * * @return int */ public function testCommandeBuild() { global $conf, $user, $langs, $db; $conf = $this->savconf; $user = $this->savuser; $langs = $this->savlangs; $db = $this->savdb; $conf->commande->dir_output .= '/temp'; $localobject = new Commande($this->savdb); $localobject->initAsSpecimen(); // Einstein $localobject->modelpdf = 'einstein'; $result = $localobject->generateDocument($localobject->modelpdf, $langs); $this->assertLessThan($result, 0); print __METHOD__ . " result=" . $result . "\n"; return 0; }