From 2b5f7aac4e24e44b706bb19e0ef754e433726a7b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 26 May 2011 15:33:33 +0000 Subject: [PATCH] Fix: uniformize code --- htdocs/expedition/class/expedition.class.php | 64 +++-- htdocs/expedition/fiche.php | 265 +++++++++---------- 2 files changed, 173 insertions(+), 156 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 0e66300a0bf..7de77f966cf 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2006-2008 Laurent Destailleur * Copyright (C) 2011 Juanjo Menent @@ -46,6 +46,8 @@ class Expedition extends CommonObject var $id; var $socid; var $ref_customer; + var $ref_ext; + var $ref_int; var $brouillon; var $entrepot_id; var $modelpdf; @@ -155,8 +157,9 @@ class Expedition extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition ("; $sql.= "ref"; - $sql.= ", ref_customer"; $sql.= ", entity"; + $sql.= ", ref_customer"; + $sql.= ", ref_int"; $sql.= ", date_creation"; $sql.= ", fk_user_author"; $sql.= ", date_expedition"; @@ -173,8 +176,9 @@ class Expedition extends CommonObject $sql.= ", size_units"; $sql.= ") VALUES ("; $sql.= "'(PROV)'"; - $sql.= ", '".$this->ref_customer."'"; $sql.= ", ".$conf->entity; + $sql.= ", ".($this->ref_customer?"'".$this->ref_customer."'":"null"); + $sql.= ", ".($this->ref_int?"'".$this->ref_int."'":"null"); $sql.= ", '".$this->db->idate(gmmktime())."'"; $sql.= ", ".$user->id; $sql.= ", ".($this->date_expedition>0?"'".$this->db->idate($this->date_expedition)."'":"null"); @@ -288,25 +292,32 @@ class Expedition extends CommonObject } /** - * \brief Lit une expedition - * \param id Id of object - * \param ref Ref of object + * Get object and lines from database + * @param id Id of object to load + * @param ref Ref of object + * @param ref_ext External reference of object + * @param ref_int Internal reference of other object + * @return int >0 if OK, <0 if KO */ - function fetch($id,$ref='') + function fetch($id, $ref='', $ref_ext='', $ref_int='') { global $conf; - if (empty($id) && empty($ref)) return -1; + // Check parameters + if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.fk_user_author, e.fk_statut"; + $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut"; $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; $sql.= ", e.fk_expedition_methode, e.tracking_number"; $sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->element."'"; - if ($id) $sql.= " WHERE e.rowid = ".$id; - if ($ref) $sql.= " WHERE e.ref = '".$ref."'"; + $sql.= " WHERE e.entity = ".$conf->entity; + if ($id) $sql.= " AND e.rowid=".$id; + if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'"; dol_syslog("Expedition::fetch sql=".$sql); $result = $this->db->query($sql) ; @@ -320,6 +331,8 @@ class Expedition extends CommonObject $this->ref = $obj->ref; $this->socid = $obj->socid; $this->ref_customer = $obj->ref_customer; + $this->ref_ext = $obj->ref_ext; + $this->ref_int = $obj->ref_int; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); @@ -863,23 +876,25 @@ class Expedition extends CommonObject * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * \return string Chaine avec URL */ - function getNomUrl($withpicto=0) + function getNomUrl($withpicto=0,$option=0,$max=0,$short=0) { global $langs; $result=''; - $urlOption=''; + + $url = DOL_URL_ROOT.'/expedition/fiche.php?id='.$this->id; + + if ($short) return $url; - - $lien = ''; - $lienfin=''; + $linkstart = ''; + $linkend=''; $picto='sending'; $label=$langs->trans("ShowSending").': '.$this->ref; - if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); + if ($withpicto) $result.=($linkstart.img_object($label,$picto).$linkend); if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$lien.$this->ref.$lienfin; + $result.=$linkstart.$this->ref.$linkend; return $result; } @@ -909,13 +924,18 @@ class Expedition extends CommonObject } if ($mode==1) { - if ($statut==0) return $langs->trans($this->statuts[$statut]); - if ($statut==1) return $langs->trans($this->statuts[$statut]); + if ($statut==0) return $langs->trans('StatusSendingDraftShort'); + if ($statut==1) return $langs->trans('StatusSendingValidatedShort'); + } + if ($mode == 3) + { + if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0'); + if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4'); } if ($mode == 4) { - if ($statut==0) return img_picto($this->statuts[$statut],'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut==1) return img_picto($this->statuts[$statut],'statut4').' '.$langs->trans($this->statuts[$statut]); + if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); + if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); } if ($mode == 5) { diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index f76e12b85d4..4d67a251533 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2008 Rodolphe Quiedeville * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -49,57 +49,58 @@ $langs->load('stocks'); $langs->load('other'); $langs->load('propal'); -$origin = GETPOST("origin")?GETPOST("origin"):'expedition'; // Example: commande, propal -$origin_id = isset($_REQUEST["id"])?$_REQUEST["id"]:''; -if (empty($origin_id)) $origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"]; // Id of order or propal -if (empty($origin_id)) $origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal -$id = $origin_id; +$action = GETPOST("action"); + +$origin = GETPOST("origin")?GETPOST("origin"):'expedition'; // Example: commande, propal +$origin_id = GETPOST("id")?GETPOST("id"):''; +if (empty($origin_id)) $origin_id = GETPOST("origin_id"); // Id of order or propal +if (empty($origin_id)) $origin_id = GETPOST("object_id"); // Id of order or propal +$id = $origin_id; // Security check if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,$origin,$origin_id,''); +$result=restrictedArea($user,$origin,$origin_id); +$object = new Expedition($db); /* * Actions */ -if ($_POST["action"] == 'add') +if ($action == 'add') { $db->begin(); - // Creation de l'objet expedition - $expedition = new Expedition($db); - - $expedition->note = $_POST["note"]; - $expedition->origin = $origin; - $expedition->origin_id = $origin_id; - $expedition->weight = $_POST["weight"]==""?"NULL":$_POST["weight"]; - $expedition->sizeH = $_POST["sizeH"]==""?"NULL":$_POST["sizeH"]; - $expedition->sizeW = $_POST["sizeW"]==""?"NULL":$_POST["sizeW"]; - $expedition->sizeS = $_POST["sizeS"]==""?"NULL":$_POST["sizeS"]; - $expedition->size_units = $_POST["size_units"]; - $expedition->weight_units = $_POST["weight_units"]; + $object->note = $_POST["note"]; + $object->origin = $origin; + $object->origin_id = $origin_id; + $object->weight = $_POST["weight"]==""?"NULL":$_POST["weight"]; + $object->sizeH = $_POST["sizeH"]==""?"NULL":$_POST["sizeH"]; + $object->sizeW = $_POST["sizeW"]==""?"NULL":$_POST["sizeW"]; + $object->sizeS = $_POST["sizeS"]==""?"NULL":$_POST["sizeS"]; + $object->size_units = $_POST["size_units"]; + $object->weight_units = $_POST["weight_units"]; $date_delivery = dol_mktime($_POST["date_deliveryhour"], $_POST["date_deliverymin"], 0, $_POST["date_deliverymonth"], $_POST["date_deliveryday"], $_POST["date_deliveryyear"]); // On va boucler sur chaque ligne du document d'origine pour completer objet expedition // avec info diverses + qte a livrer - $classname = ucfirst($expedition->origin); - $object = new $classname($db); - $object->fetch($expedition->origin_id); + $classname = ucfirst($object->origin); + $objectsrc = new $classname($db); + $objectsrc->fetch($object->origin_id); //$object->fetch_lines(); - $expedition->socid = $object->socid; - $expedition->ref_customer = $object->ref_client; - $expedition->date_delivery = $date_delivery; // Date delivery planed - $expedition->fk_delivery_address = $object->fk_delivery_address; - $expedition->expedition_method_id = $_POST["expedition_method_id"]; - $expedition->tracking_number = $_POST["tracking_number"]; + $object->socid = $objectsrc->socid; + $object->ref_customer = $objectsrc->ref_client; + $object->date_delivery = $date_delivery; // Date delivery planed + $object->fk_delivery_address = $objectsrc->fk_delivery_address; + $object->expedition_method_id = $_POST["expedition_method_id"]; + $object->tracking_number = $_POST["tracking_number"]; + $object->ref_int = $_POST["ref_int"]; //var_dump($_POST);exit; - for ($i = 0 ; $i < sizeof($object->lines) ; $i++) + for ($i = 0 ; $i < sizeof($objectsrc->lines) ; $i++) { $qty = "qtyl".$i; if ($_POST[$qty] > 0) @@ -108,21 +109,21 @@ if ($_POST["action"] == 'add') $idl = "idl".$i; $entrepot_id = isset($_POST[$ent])?$_POST[$ent]:$_POST["entrepot_id"]; - $expedition->addline($entrepot_id,$_POST[$idl],$_POST[$qty]); + $object->addline($entrepot_id,$_POST[$idl],$_POST[$qty]); } } - $ret=$expedition->create($user); + $ret=$object->create($user); if ($ret > 0) { $db->commit(); - Header("Location: fiche.php?id=".$expedition->id); + Header("Location: fiche.php?id=".$object->id); exit; } else { $db->rollback(); - $mesg='
'.$expedition->error.'
'; + $mesg='
'.$object->error.'
'; $_GET["commande_id"]=$_POST["commande_id"]; $_GET["action"]='create'; } @@ -131,11 +132,10 @@ if ($_POST["action"] == 'add') /* * Build a receiving receipt */ -if ($_GET["action"] == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) +if ($action == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) { - $expedition = new Expedition($db); - $expedition->fetch($_GET["id"]); - $result = $expedition->create_delivery($user); + $object->fetch($_GET["id"]); + $result = $object->create_delivery($user); if ($result > 0) { Header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); @@ -143,29 +143,28 @@ if ($_GET["action"] == 'create_delivery' && $conf->livraison_bon->enabled && $us } else { - $mesg=$expedition->error; + $mesg=$object->error; } } -if ($_REQUEST["action"] == 'confirm_valid' && $_REQUEST["confirm"] == 'yes' && $user->rights->expedition->valider) +if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->valider) { - $expedition = new Expedition($db); - $expedition->fetch($_GET["id"]); - $expedition->fetch_thirdparty(); + $object->fetch($_GET["id"]); + $object->fetch_thirdparty(); - $result = $expedition->valid($user); + $result = $object->valid($user); // Define output language $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$expedition->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=expedition_pdf_create($db,$expedition,$expedition->modelpdf,$outputlangs); + $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -173,13 +172,12 @@ if ($_REQUEST["action"] == 'confirm_valid' && $_REQUEST["confirm"] == 'yes' && $ } } -if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') +if ($action == 'confirm_delete' && $confirm == 'yes') { if ($user->rights->expedition->supprimer ) { - $expedition = new Expedition($db); - $expedition->fetch($_GET["id"]); - $result = $expedition->delete(); + $object->fetch($_GET["id"]); + $result = $object->delete(); if ($result > 0) { Header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); @@ -187,21 +185,20 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') } else { - $mesg = $expedition->error; + $mesg = $object->error; } } } -if ($_REQUEST["action"] == 'open') +if ($action == 'open') { if ($user->rights->expedition->valider ) { - $expedition = new Expedition($db); - $expedition->fetch($_GET["id"]); - $result = $expedition->setStatut(0); + $object->fetch($_GET["id"]); + $result = $object->setStatut(0); if ($result < 0) { - $mesg = $expedition->error; + $mesg = $object->error; } } } @@ -350,6 +347,7 @@ if ($_GET["action"] == 'create') print ''; print ''; print ''; + print ''; if ($_GET["entrepot_id"]) { print ''; @@ -646,39 +644,38 @@ else /* */ /* *************************************************************************** */ { - if (! empty($_REQUEST["id"]) || ! empty($_REQUEST["ref"])) + if (! empty($id) || ! empty($ref)) { - $expedition = new Expedition($db); - $result = $expedition->fetch($_REQUEST["id"],$_REQUEST["ref"]); + $result = $object->fetch($id,$ref); if ($result < 0) { - dol_print_error($db,$expedition->error); + dol_print_error($db,$object->error); exit -1; } - $lines = $expedition->lines; + $lines = $object->lines; $num_prod = sizeof($lines); - if ($expedition->id > 0) + if ($object->id > 0) { if ($mesg) { print '
'.$mesg.'
'; } - if (!empty($expedition->origin)) + if (!empty($object->origin)) { - $typeobject = $expedition->origin; - $origin = $expedition->origin; - $expedition->fetch_origin(); + $typeobject = $object->origin; + $origin = $object->origin; + $object->fetch_origin(); } $soc = new Societe($db); - $soc->fetch($expedition->socid); + $soc->fetch($object->socid); // delivery link - $expedition->fetchObjectLinked($expedition->id,$expedition->element,-1,-1); + $object->fetchObjectLinked($object->id,$object->element,-1,-1); - $head=shipping_prepare_head($expedition); + $head=shipping_prepare_head($object); dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending'); if ($mesg) print $mesg; @@ -686,35 +683,35 @@ else /* * Confirmation de la suppression */ - if ($_GET["action"] == 'delete') + if ($action == 'delete') { - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('DeleteSending'),$langs->trans("ConfirmDeleteSending",$expedition->ref),'confirm_delete','',0,1); + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteSending'),$langs->trans("ConfirmDeleteSending",$object->ref),'confirm_delete','',0,1); if ($ret == 'html') print '
'; } /* * Confirmation de la validation */ - if ($_GET["action"] == 'valid') + if ($action == 'valid') { - $objectref = substr($expedition->ref, 1, 4); + $objectref = substr($object->ref, 1, 4); if ($objectref == 'PROV') { - $numref = $expedition->getNextNumRef($soc); + $numref = $object->getNextNumRef($soc); } else { - $numref = $expedition->ref; + $numref = $object->ref; } - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('ValidateSending'),$langs->trans("ConfirmValidateSending",$numref),'confirm_valid','',0,1); + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('ValidateSending'),$langs->trans("ConfirmValidateSending",$numref),'confirm_valid','',0,1); if ($ret == 'html') print '
'; } /* * Confirmation de l'annulation */ - if ($_GET["action"] == 'annuler') + if ($action == 'annuler') { - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('CancelSending'),$langs->trans("ConfirmCancelSending",$expedition->ref),'confirm_cancel','',0,1); + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('CancelSending'),$langs->trans("ConfirmCancelSending",$object->ref),'confirm_cancel','',0,1); if ($ret == 'html') print '
'; } @@ -762,7 +759,7 @@ else // Ref print ''.$langs->trans("Ref").''; print ''; - print $html->showrefnav($expedition,'ref','',1,'ref','ref'); + print $html->showrefnav($object,'ref','',1,'ref','ref'); print ''; // Customer @@ -771,37 +768,37 @@ else print ""; // Linked documents - if ($typeobject == 'commande' && $expedition->$typeobject->id && $conf->commande->enabled) + if ($typeobject == 'commande' && $object->$typeobject->id && $conf->commande->enabled) { print ''; - $object=new Commande($db); - $object->fetch($expedition->$typeobject->id); + $objectsrc=new Commande($db); + $objectsrc->fetch($object->$typeobject->id); print $langs->trans("RefOrder").''; print ''; - print $object->getNomUrl(1,'commande'); + print $objectsrc->getNomUrl(1,'commande'); print "\n"; print ''; } - if ($typeobject == 'propal' && $expedition->$typeobject->id && $conf->propal->enabled) + if ($typeobject == 'propal' && $object->$typeobject->id && $conf->propal->enabled) { print ''; - $object=new Propal($db); - $object->fetch($expedition->$typeobject->id); + $objectsrc=new Propal($db); + $objectsrc->fetch($object->$typeobject->id); print $langs->trans("RefProposal").''; print ''; - print $object->getNomUrl(1,'expedition'); + print $objectsrc->getNomUrl(1,'expedition'); print "\n"; print ''; } // Ref customer print ''.$langs->trans("RefCustomer").''; - print ''.$expedition->ref_customer."\n"; + print ''.$object->ref_customer."\n"; print ''; // Date creation print ''.$langs->trans("DateCreation").''; - print ''.dol_print_date($expedition->date_creation,"daytext")."\n"; + print ''.dol_print_date($object->date_creation,"daytext")."\n"; print ''; // Delivery date planed @@ -810,21 +807,21 @@ else print $langs->trans('DateDeliveryPlanned'); print ''; - if ($_GET['action'] != 'editdate_livraison') print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).''; + if ($_GET['action'] != 'editdate_livraison') print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).''; print ''; print ''; if ($_GET['action'] == 'editdate_livraison') { - print '
'; + print ''; print ''; print ''; - $html->select_date($expedition->date_delivery?$expedition->date_delivery:-1,'liv_',1,1,'',"setdate_livraison"); + $html->select_date($object->date_delivery?$object->date_delivery:-1,'liv_',1,1,'',"setdate_livraison"); print ''; print '
'; } else { - print $expedition->date_delivery ? dol_print_date($expedition->date_delivery,'dayhourtext') : ' '; + print $object->date_delivery ? dol_print_date($object->date_delivery,'dayhourtext') : ' '; } print ''; print ''; @@ -835,26 +832,26 @@ else { print ''.$langs->trans('DeliveryAddress').''; print ''; - if (!empty($expedition->fk_delivery_address)) + if (!empty($object->fk_delivery_address)) { - $html->form_address($_SERVER['PHP_SELF'].'?id='.$expedition->id,$expedition->fk_delivery_address,$expedition->deliveryaddress->socid,'none','shipment',$expedition->id); + $html->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->deliveryaddress->socid,'none','shipment',$object->id); } print ''."\n"; } // Weight - print ''.$html->editfieldkey("Weight",'trueWeight',$expedition->trueWeight,'id',$expedition->id,$user->rights->expedition->creer).''; - print $html->editfieldval("Weight",'trueWeight',$expedition->trueWeight,'id',$expedition->id,$user->rights->expedition->creer); - print $expedition->weight_units?measuring_units_string($expedition->weight_units,"weight"):''; + print ''.$html->editfieldkey("Weight",'trueWeight',$object->trueWeight,'id',$object->id,$user->rights->expedition->creer).''; + print $html->editfieldval("Weight",'trueWeight',$object->trueWeight,'id',$object->id,$user->rights->expedition->creer); + print $object->weight_units?measuring_units_string($object->weight_units,"weight"):''; print ''; // Volume Total print ''.$langs->trans("Volume").''; print ''; - if ($expedition->trueVolume) + if ($object->trueVolume) { // If sending volume defined - print $expedition->trueVolume.' '.measuring_units_string($expedition->volumeUnit,"volume"); + print $object->trueVolume.' '.measuring_units_string($object->volumeUnit,"volume"); } else { @@ -871,26 +868,26 @@ else print ''; // Width - print ''.$html->editfieldkey("Width",'trueWidth',$expedition->trueWidth,'id',$expedition->id,$user->rights->expedition->creer).''; - print $html->editfieldval("Width",'trueWidth',$expedition->trueWidth,'id',$expedition->id,$user->rights->expedition->creer); - print $expedition->trueWidth?measuring_units_string($expedition->width_units,"size"):''; + print ''.$html->editfieldkey("Width",'trueWidth',$object->trueWidth,'id',$object->id,$user->rights->expedition->creer).''; + print $html->editfieldval("Width",'trueWidth',$object->trueWidth,'id',$object->id,$user->rights->expedition->creer); + print $object->trueWidth?measuring_units_string($object->width_units,"size"):''; print ''; // Height - print ''.$html->editfieldkey("Height",'trueHeight',$expedition->trueHeight,'id',$expedition->id,$user->rights->expedition->creer).''; - print $html->editfieldval("Height",'trueHeight',$expedition->trueHeight,'id',$expedition->id,$user->rights->expedition->creer); - print $expedition->trueHeight?measuring_units_string($expedition->height_units,"size"):''; + print ''.$html->editfieldkey("Height",'trueHeight',$object->trueHeight,'id',$object->id,$user->rights->expedition->creer).''; + print $html->editfieldval("Height",'trueHeight',$object->trueHeight,'id',$object->id,$user->rights->expedition->creer); + print $object->trueHeight?measuring_units_string($object->height_units,"size"):''; print ''; // Depth - print ''.$html->editfieldkey("Depth",'trueDepth',$expedition->trueDepth,'id',$expedition->id,$user->rights->expedition->creer).''; - print $html->editfieldval("Depth",'trueDepth',$expedition->trueDepth,'id',$expedition->id,$user->rights->expedition->creer); - print $expedition->trueDepth?measuring_units_string($expedition->depth_units,"size"):''; + print ''.$html->editfieldkey("Depth",'trueDepth',$object->trueDepth,'id',$object->id,$user->rights->expedition->creer).''; + print $html->editfieldval("Depth",'trueDepth',$object->trueDepth,'id',$object->id,$user->rights->expedition->creer); + print $object->trueDepth?measuring_units_string($object->depth_units,"size"):''; print ''; // Status print ''.$langs->trans("Status").''; - print ''.$expedition->getLibStatut(4)."\n"; + print ''.$object->getLibStatut(4)."\n"; print ''; // Sending method @@ -899,25 +896,25 @@ else print $langs->trans('SendingMethod'); print ''; - if ($_GET['action'] != 'editexpedition_method_id') print 'id.'">'.img_edit($langs->trans('SetSendingMethod'),1).''; + if ($_GET['action'] != 'editexpedition_method_id') print 'id.'">'.img_edit($langs->trans('SetSendingMethod'),1).''; print ''; print ''; if ($_GET['action'] == 'editexpedition_method_id') { - print '
'; + print ''; print ''; print ''; - $expedition->fetch_delivery_methods(); - print $html->selectarray("expedition_method_id",$expedition->meths,$expedition->expedition_method_id,1,0,0,"",1); + $object->fetch_delivery_methods(); + print $html->selectarray("expedition_method_id",$object->meths,$object->expedition_method_id,1,0,0,"",1); print ''; print '
'; } else { - if ($expedition->expedition_method_id > 0) + if ($object->expedition_method_id > 0) { // Get code using getLabelFromKey - $code=$langs->getLabelFromKey($db,$expedition->expedition_method_id,'c_shipment_mode','rowid','code'); + $code=$langs->getLabelFromKey($db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); print $langs->trans("SendingMethod".strtoupper($code)); } } @@ -925,9 +922,9 @@ else print ''; // Tracking Number - $expedition->GetUrlTrackingStatus($expedition->tracking_number); - print ''.$html->editfieldkey("TrackingNumber",'trackingnumber',$expedition->tracking_number,'id',$expedition->id,$user->rights->expedition->creer).''; - print $html->editfieldval("TrackingNumber",'trackingnumber',$expedition->tracking_url,'id',$expedition->id,$user->rights->expedition->creer,'string',$expedition->tracking_number); + $object->GetUrlTrackingStatus($object->tracking_number); + print ''.$html->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,'id',$object->id,$user->rights->expedition->creer).''; + print $html->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,'id',$object->id,$user->rights->expedition->creer,'string',$object->tracking_number); print ''; print "\n"; @@ -939,7 +936,7 @@ else print ''; print ''.$langs->trans("Products").''; print ''.$langs->trans("QtyOrdered").''; - if ($expedition->fk_statut <= 1) + if ($object->fk_statut <= 1) { print ''.$langs->trans("QtyToShip").''; } @@ -1048,16 +1045,16 @@ else { print '
'; - /*if ($expedition->statut > 0 && $user->rights->expedition->valider) + /*if ($object->statut > 0 && $user->rights->expedition->valider) { - print ''.$langs->trans("Modify").''; + print ''.$langs->trans("Modify").''; }*/ - if ($expedition->statut == 0 && $num_prod > 0) + if ($object->statut == 0 && $num_prod > 0) { if ($user->rights->expedition->valider) { - print ''.$langs->trans("Validate").''; + print ''.$langs->trans("Validate").''; } else { @@ -1065,14 +1062,14 @@ else } } - if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && empty($expedition->linkedObjectsIds)) + if ($conf->livraison_bon->enabled && $object->statut == 1 && $user->rights->expedition->livraison->creer && empty($object->linkedObjectsIds)) { - print ''.$langs->trans("DeliveryOrder").''; + print ''.$langs->trans("DeliveryOrder").''; } if ($user->rights->expedition->supprimer) { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } print '
'; @@ -1087,17 +1084,17 @@ else */ if ($conf->expedition_bon->enabled) { - $expeditionref = dol_sanitizeFileName($expedition->ref); - $filedir = $conf->expedition->dir_output . "/sending/" .$expeditionref; + $objectref = dol_sanitizeFileName($object->ref); + $filedir = $conf->expedition->dir_output . "/sending/" .$objectref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed=$user->rights->expedition->lire; $delallowed=$user->rights->expedition->supprimer; //$genallowed=1; //$delallowed=0; - $somethingshown=$formfile->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); + $somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); if ($genallowed && ! $somethingshown) $somethingshown=1; } @@ -1107,11 +1104,11 @@ else print ''; - if (!empty($origin) && $expedition->$origin->id) + if (!empty($origin) && $object->$origin->id) { print '
'; - //show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id); - show_list_sending_receive($expedition->origin,$expedition->origin_id); + //show_list_sending_receive($object->origin,$object->origin_id," AND e.rowid <> ".$object->id); + show_list_sending_receive($object->origin,$object->origin_id); } }