本文整理汇总了PHP中Commande::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Commande::fetch方法的具体用法?PHP Commande::fetch怎么用?PHP Commande::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commande
的用法示例。
在下文中一共展示了Commande::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Commande
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("YourEMail");
print ' ('.$langs->trans("ToComplete").')';
print '</td><td class="CTableRow'.($var?'1':'2').'"><input class="flat" type="text" name="email" size="48" value="'.GETPOST("email").'"></td></tr>'."\n";
}
// Payment on customer order
if (GETPOST("source") == 'order')
{
$found=true;
$langs->load("orders");
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
$order=new Commande($db);
$result=$order->fetch('',$_REQUEST["ref"]);
if ($result < 0)
{
$mesg=$order->error;
$error++;
}
else
{
$result=$order->fetch_thirdparty($order->socid);
}
$amount=$order->total_ttc;
if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
$amount=price2num($amount);
$fulltag='IR='.$order->ref.'.TPID='.$order->client->id.'.TP='.strtr($order->client->nom,"-"," ");
示例3: Commande
$var = !$var;
print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("PaymentCode");
print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $fulltag . '</b>';
print '<input type="hidden" name="tag" value="' . $tag . '">';
print '<input type="hidden" name="fulltag" value="' . $fulltag . '">';
print '</td></tr>' . "\n";
// We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum
// as they don't exists (buyer is unknown, tag is free).
}
// Payment on customer order
if (GETPOST("source") == 'order' && $valid) {
$found = true;
$langs->load("orders");
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
$order = new Commande($db);
$result = $order->fetch('', $ref);
if ($result < 0) {
$mesg = $order->error;
$error++;
} else {
$result = $order->fetch_thirdparty($order->socid);
}
$amount = $order->total_ttc;
if (GETPOST("amount", 'int')) {
$amount = GETPOST("amount", 'int');
}
$amount = price2num($amount);
$fulltag = 'ORD=' . $order->ref . '.CUS=' . $order->thirdparty->id;
//$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," ");
if (!empty($TAG)) {
$tag = $TAG;
示例4: foreach
/**
* Show top header of page.
*
* @param PDF &$pdf Object PDF
* @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @return void
*/
function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
global $langs, $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
$posx = $this->page_largeur - $this->marge_droite - 100;
$posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
$logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
if ($mysoc->logo) {
if (is_readable($logo)) {
$height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
// width=0 (auto)
} else {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
}
} else {
$pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
}
$pdf->SetFont('', 'B', $default_font_size + 2);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
$pdf->SetFont('', '', $default_font_size + 2);
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
if ($object->date_valid) {
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery ? $object->date_delivery : $date->valid, "%d %b %Y", false, $outputlangs, true), '', 'R');
} else {
$pdf->SetTextColor(255, 0, 0);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
$pdf->SetTextColor(0, 0, 60);
}
if ($object->client->code_client) {
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
}
$pdf->SetTextColor(0, 0, 60);
// Add origin linked objects
// TODO extend to other objects
$object->fetchObjectLinked('', '', $object->id, 'delivery');
if (!empty($object->linkedObjects)) {
$outputlangs->load('orders');
foreach ($object->linkedObjects as $elementtype => $objects) {
$object->fetchObjectLinked('', '', $objects[0]->id, $objects[0]->element);
foreach ($object->linkedObjects as $elementtype => $objects) {
$num = count($objects);
for ($i = 0; $i < $num; $i++) {
$order = new Commande($this->db);
$result = $order->fetch($objects[$i]->id);
if ($result >= 0) {
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
$text = $order->ref;
if ($order->ref_client) {
$text .= ' (' . $order->ref_client . ')';
}
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
}
}
}
}
}
if ($showaddress) {
// Emetteur
$posy = 42;
$hautcadre = 40;
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy - 5);
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":");
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFillColor(230, 230, 230);
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
$pdf->SetXY($this->marge_gauche + 2, $posy + 3);
// Nom emetteur
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
// Sender properties
//.........这里部分代码省略.........
示例5: _genInfoEtiquette
function _genInfoEtiquette(&$db, &$PDOdb, &$TPrintTicket)
{
global $conf;
$TInfoEtiquette = array();
if (empty($TPrintTicket)) {
return $TInfoEtiquette;
}
dol_include_once('/commande/class/commande.class.php');
$assetOf = new TAssetOF();
$cmd = new Commande($db);
$product = new Product($db);
$pos = 1;
$cpt = 0;
foreach ($TPrintTicket as $fk_assetOf => $qty) {
if ($qty <= 0) {
continue;
}
$load = $assetOf->load($PDOdb, $fk_assetOf);
if ($load === true) {
$cmd->fetch($assetOf->fk_commande);
foreach ($assetOf->TAssetOFLine as &$assetOfLine) {
if ($assetOfLine->type == 'TO_MAKE' && $product->fetch($assetOfLine->fk_product) > 0) {
for ($i = 0; $i < $qty; $i++) {
$cpt++;
if ($cpt % 2 == 0) {
$div = 'pair';
} else {
$div = 'impair';
}
$TInfoEtiquette[] = array('numOf' => $assetOf->numero, 'float' => $div, 'refCmd' => $cmd->ref, 'refCliCmd' => $cmd->ref_client, 'refProd' => $product->ref, 'qty_to_print' => $qty, 'qty_to_make' => $assetOfLine->qty, 'label' => wordwrap(preg_replace('/\\s\\s+/', ' ', $product->label), 20, $conf->global->DEFAULT_ETIQUETTES == 2 ? "\n" : "</br>"), 'pos' => ceil($pos / 8));
//var_dump($TInfoEtiquette);exit;
$pos++;
//var_dump($TInfoEtiquette);
}
}
}
}
}
//exit;
return $TInfoEtiquette;
}
示例6: testCommandeDelete
/**
* testCommandeDelete
*
* @param int $id Id of order
* @return void
*
* @depends testCommandeOther
* The depends says test is run only if previous is ok
*/
public function testCommandeDelete($id)
{
global $conf, $user, $langs, $db;
$conf = $this->savconf;
$user = $this->savuser;
$langs = $this->savlangs;
$db = $this->savdb;
$localobject = new Commande($this->savdb);
$result = $localobject->fetch($id);
$result = $localobject->delete($user);
print __METHOD__ . " id=" . $id . " result=" . $result . "\n";
$this->assertLessThan($result, 0);
return $result;
}
示例7: HookManager
/**
* Function to build a document on disk using the generic odt module.
*
* @param Commande $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO
*/
function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath)) {
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
// Add odtgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
$sav_charset_output = $outputlangs->charset_output;
$outputlangs->charset_output = 'UTF-8';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
if ($conf->commande->dir_output) {
// If $object is id instead of object
if (!is_object($object)) {
$id = $object;
$object = new Commande($this->db);
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error($this->db, $object->error);
return -1;
}
}
$dir = $conf->commande->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/" . $objectref;
}
$file = $dir . "/" . $objectref . ".odt";
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
}
if (file_exists($dir)) {
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile = basename($srctemplatepath);
$newfiletmp = preg_replace('/\\.od(t|s)/i', '', $newfile);
$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
$newfiletmp = $objectref . '_' . $newfiletmp;
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
$filename = $newfiletmp . '.' . dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '.' . $newfileformat;
} else {
$filename = $newfiletmp . '.' . $newfileformat;
}
$file = $dir . '/' . $filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
dol_mkdir($conf->commande->dir_temp);
// If BILLING contact defined on invoice, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'BILLING');
if (count($arrayidcontact) > 0) {
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
if (!empty($usecontact)) {
// On peut utiliser le nom de la societe du contact
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$socobject = $object->contact;
} else {
$socobject = $object->client;
}
} else {
$socobject = $object->client;
}
// Make substitution
$substitutionarray = array('__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, '__TOTAL_VAT__' => $object->total_vat);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
//.........这里部分代码省略.........
示例8: commande_delete_preview
/**
* Supprime l'image de previsualitation, pour le cas de regeneration de commande
* @param db data base object
* @param commandeid id de la commande a effacer
* @param commanderef reference de la commande si besoin
*/
function commande_delete_preview($db, $commandeid, $commanderef='')
{
global $langs,$conf;
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (!$commanderef)
{
$com = new Commande($db,"",$commandeid);
$com->fetch($commandeid);
$commanderef = $com->ref;
}
if ($conf->commande->dir_output)
{
$comref = dol_sanitizeFileName($commanderef);
$dir = $conf->commande->dir_output . "/" . $comref ;
$file = $dir . "/" . $comref . ".pdf.png";
$multiple = $file . ".";
if ( file_exists( $file ) && is_writable( $file ) )
{
if ( ! dol_delete_file($file,1) )
{
$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
return 0;
}
}
else
{
for ($i = 0; $i < 20; $i++)
{
$preview = $multiple.$i;
if ( file_exists( $preview ) && is_writable( $preview ) )
{
if ( ! dol_delete_file($preview,1) )
{
$this->error=$langs->trans("ErrorFailedToOpenFile",$preview);
return 0;
}
}
}
}
}
return 1;
}
示例9: show_actions_done
/**
* Show html area with actions done
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Object db
* @param Adherent|Societe $object Object third party or member
* @param Contact $objcon Object contact
* @param int $noprint Return string but does not output it
* @return mixed Return html part or void if noprint is 1
* TODO change function to be able to list event linked to an object.
*/
function show_actions_done($conf, $langs, $db, $object, $objcon = '', $noprint = 0)
{
global $bc, $user, $conf;
// Check parameters
if (!is_object($object)) {
dol_print_error('', 'BadParameter');
}
$out = '';
$histo = array();
$numaction = 0;
$now = dol_now('tzuser');
if (!empty($conf->agenda->enabled)) {
// Recherche histo sur actioncomm
$sql = "SELECT a.id, a.label,";
$sql .= " a.datep as dp,";
$sql .= " a.datep2 as dp2,";
$sql .= " a.note, a.percent,";
$sql .= " a.fk_element, a.elementtype,";
$sql .= " a.fk_user_author, a.fk_contact,";
$sql .= " c.code as acode, c.libelle,";
$sql .= " u.login, u.rowid as user_id";
if (get_class($object) == 'Societe') {
$sql .= ", sp.lastname, sp.firstname";
}
if (get_class($object) == 'Adherent') {
$sql .= ", m.lastname, m.firstname";
}
$sql .= " FROM " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_actioncomm as c ON a.fk_action = c.id";
if (get_class($object) == 'Societe') {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid";
}
if (get_class($object) == 'Adherent') {
$sql .= ", " . MAIN_DB_PREFIX . "adherent as m";
}
$sql .= " WHERE u.rowid = a.fk_user_author";
$sql .= " AND a.entity IN (" . getEntity('agenda', 1) . ")";
if (get_class($object) == 'Societe' && $object->id) {
$sql .= " AND a.fk_soc = " . $object->id;
}
if (get_class($object) == 'Adherent') {
$sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
}
if (get_class($object) == 'Adherent' && $object->id) {
$sql .= " AND a.fk_element = " . $object->id;
}
if (is_object($objcon) && $objcon->id) {
$sql .= " AND a.fk_contact = " . $objcon->id;
}
$sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '" . $db->idate($now) . "'))";
$sql .= " ORDER BY a.datep DESC, a.id DESC";
dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
$var = true;
while ($i < $num) {
$obj = $db->fetch_object($resql);
$histo[$numaction] = array('type' => 'action', 'id' => $obj->id, 'datestart' => $db->jdate($obj->dp), 'dateend' => $db->jdate($obj->dp2), 'note' => $obj->label, 'percent' => $obj->percent, 'acode' => $obj->acode, 'libelle' => $obj->libelle, 'userid' => $obj->user_id, 'login' => $obj->login, 'contact_id' => $obj->fk_contact, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'fk_element' => $obj->fk_element, 'elementtype' => $obj->elementtype);
$numaction++;
$i++;
}
} else {
dol_print_error($db);
}
}
if (!empty($conf->mailing->enabled) && !empty($objcon->email)) {
$langs->load("mails");
// Recherche histo sur mailing
$sql = "SELECT m.rowid as id, mc.date_envoi as da, m.titre as note, '100' as percentage,";
$sql .= " 'AC_EMAILING' as acode,";
$sql .= " u.rowid as user_id, u.login";
// User that valid action
$sql .= " FROM " . MAIN_DB_PREFIX . "mailing as m, " . MAIN_DB_PREFIX . "mailing_cibles as mc, " . MAIN_DB_PREFIX . "user as u";
$sql .= " WHERE mc.email = '" . $db->escape($objcon->email) . "'";
// Search is done on email.
$sql .= " AND mc.statut = 1";
$sql .= " AND u.rowid = m.fk_user_valid";
$sql .= " AND mc.fk_mailing=m.rowid";
$sql .= " ORDER BY mc.date_envoi DESC, m.rowid DESC";
dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
$var = true;
while ($i < $num) {
//.........这里部分代码省略.........
示例10: accessforbidden
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/order.lib.php';
if (!$user->rights->commande->lire) {
accessforbidden();
}
$langs->load("orders");
$langs->load("sendings");
// Security check
$socid = 0;
$comid = GETPOST("id", 'int');
if ($user->societe_id) {
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande', $comid, '');
/*
* View
*/
llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
$commande = new Commande($db);
$commande->fetch($comid);
$commande->info($comid);
$soc = new Societe($db);
$soc->fetch($commande->socid);
$head = commande_prepare_head($commande);
dol_fiche_head($head, 'info', $langs->trans("CustomerOrder"), 0, 'order');
print '<table width="100%"><tr><td>';
dol_print_object_info($commande);
print '</td></tr></table>';
print '</div>';
$db->close();
llxFooter();
示例11: Commande
<?php
if (is_object($mc)) {
$conf->entity = $entity;
$user->fetch($userid);
}
$sql = "SELECT fk_soc, fk_paycash, fk_modepaycash, fk_paybank, fk_modepaybank, fk_warehouse FROM " . MAIN_DB_PREFIX . "pos_cash where rowid={$terminal}";
$resql = $db->query($sql);
$rowterminal = $db->fetch_array($resql);
if ($placenoid != "") {
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "commande where ref='Place-{$placenoid}' and entity={$entity}";
$resql = $db->query($sql);
$row = $db->fetch_array($resql);
$place = $row[0];
}
$object = new Commande($db);
$res = $object->fetch($place);
$user = new User($db);
$user->fetch($userid);
if (is_object($mc)) {
$facture = new Facture($db);
} else {
$facture = new Facturesim($db);
}
if ($pay == "cash") {
$object->mode_reglement_id = $rowterminal[2];
} else {
$object->mode_reglement_id = $rowterminal[4];
}
$facture->createFromOrder($object);
$user->getrights();
if ($conf->stock->enabled) {
示例12: Commande
$page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new Commande($db);
/*
* Actions
*/
if ($object->fetch($id)) {
$object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
* View
*/
llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
$form = new Form($db);
if ($id > 0 || !empty($ref)) {
if ($object->fetch($id, $ref)) {
$object->fetch_thirdparty();
$upload_dir = $conf->commande->dir_output . '/' . dol_sanitizeFileName($object->ref);
$head = commande_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), 0, 'order');
示例13: 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;
}
示例14: foreach
/**
* Show top header of page.
*
* @param PDF &$pdf Object PDF
* @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @return void
*/
function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
global $langs, $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$outputlangs->load("companies");
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
$posx = $this->page_largeur - $this->marge_droite - 100;
$posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy);
if ($conf->global->MAIN_INFO_SOCIETE_NOM) {
$pdf->SetTextColor(0, 0, 200);
$pdf->SetFont('', 'B', $default_font_size + 2);
$pdf->MultiCell(76, 4, $outputlangs->convToOutputCharset(MAIN_INFO_SOCIETE_NOM), 0, 'L');
}
// Sender properties
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetXY($this->marge_gauche, $posy + 4);
$pdf->MultiCell(80, 3, $carac_emetteur, 0, 'L');
/*
* Adresse Client
*/
// If SHIPPING contact defined on invoice, we use it
$usecontact = false;
$arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
if (count($arrayidcontact) > 0) {
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
if (!empty($usecontact)) {
// On peut utiliser le nom de la societe du contact
if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
$socname = $object->contact->socname;
} else {
$socname = $object->client->nom;
}
$carac_client_name = $outputlangs->convToOutputCharset($socname);
} else {
$carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
}
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', 'B', $default_font_size + 1);
$pdf->SetXY(102, 42);
$pdf->MultiCell(96, 5, $carac_client_name, 0, 'L');
$pdf->SetFont('', 'B', $default_font_size);
$pdf->SetXY(102, 47);
$pdf->MultiCell(96, 5, $carac_client, 0, 'L');
$pdf->Rect(100, 40, 100, 40);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 1);
$pdf->SetXY($posx, 86);
$pdf->MultiCell(100, 2, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery ? $object->date_delivery : $date->valid, "day", false, $outputlangs, true), 0, 'R');
$pdf->SetXY($posx, 92);
$pdf->MultiCell(100, 2, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), 0, 'R');
if ($object->client->code_client) {
$posy += 7;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
}
$pdf->SetFont('', 'B', $default_font_size - 1);
// Add origin linked objects
// TODO extend to other objects
$object->fetchObjectLinked('', '', $object->id, 'delivery');
if (!empty($object->linkedObjects)) {
$outputlangs->load('orders');
foreach ($object->linkedObjects as $elementtype => $objects) {
$object->fetchObjectLinked('', '', $objects[0]->id, $objects[0]->element);
foreach ($object->linkedObjects as $elementtype => $objects) {
$num = count($objects);
for ($i = 0; $i < $num; $i++) {
$order = new Commande($this->db);
$result = $order->fetch($objects[$i]->id);
if ($result >= 0) {
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
$text = $order->ref;
if ($order->ref_client) {
$text .= ' (' . $order->ref_client . ')';
}
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
}
}
}
}
}
//.........这里部分代码省略.........
示例15: HookManager
/**
* Function to build pdf onto disk
*
* @param Object $object Object to generate
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @return int 1=OK, 0=KO
*/
function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $user, $langs, $conf, $mysoc, $hookmanager;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("products");
$outputlangs->load("deliveries");
$outputlangs->load("sendings");
if ($conf->expedition->dir_output) {
$object->fetch_thirdparty();
// Definition of $dir and $file
if ($object->specimen) {
$dir = $conf->expedition->dir_output . "/receipt";
$file = $dir . "/SPECIMEN.pdf";
} else {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition->dir_output . "/receipt/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf";
}
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir)) {
// Add pdfgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
$nblines = count($object->lines);
// Create pdf instance
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
// Must be after pdf_getInstance
$heightforinfotot = 30;
// Height reserved to output the info and total part
$heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5;
// Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8;
// Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
// We get the shipment that is the origin of delivery receipt
$expedition = new Expedition($this->db);
$result = $expedition->fetch($object->origin_id);
// Now we get the order that is origin of shipment
$commande = new Commande($this->db);
if ($expedition->origin == 'commande') {
$commande->fetch($expedition->origin_id);
}
$object->commande = $commande;
// We set order of shipment onto delivery.
$object->commande->loadExpeditions();
$pdf->Open();
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder"));
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("DeliveryOrder"));
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
$pdf->SetCompression(false);
}
//.........这里部分代码省略.........