From 228f10669d366ffe7462b4743680823afb523a65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Mar 2012 14:48:27 +0100 Subject: [PATCH] Fix: Use bad language --- htdocs/expedition/fiche.php | 2068 ++++++++++++++++++----------------- 1 file changed, 1037 insertions(+), 1031 deletions(-) diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index e275178d8ae..f5e62b60043 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -1,29 +1,29 @@ * Copyright (C) 2005-2010 Laurent Destailleur - * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2012 Juanjo Menent - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +* Copyright (C) 2005 Simon TOSSER +* Copyright (C) 2005-2012 Regis Houssin +* Copyright (C) 2011-2012 Juanjo Menent +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ /** * \file htdocs/expedition/fiche.php - * \ingroup expedition - * \brief Fiche descriptive d'une expedition - */ +* \ingroup expedition +* \brief Fiche descriptive d'une expedition +*/ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); @@ -65,183 +65,183 @@ $object = new Expedition($db); /* * Actions - */ +*/ if ($action == 'add') { $error=0; - $db->begin(); + $db->begin(); - $object->note = GETPOST('note','alpha'); - $object->origin = $origin; - $object->origin_id = $origin_id; - $object->weight = GETPOST('weight','int')==''?"NULL":GETPOST('weight','int'); - $object->sizeH = GETPOST('sizeH','int')==''?"NULL":GETPOST('sizeH','int'); - $object->sizeW = GETPOST('sizeW','int')==''?"NULL":GETPOST('sizeW','int'); - $object->sizeS = GETPOST('sizeS','int')==''?"NULL":GETPOST('sizeS','int'); - $object->size_units = GETPOST('size_units','int'); - $object->weight_units = GETPOST('weight_units','int'); + $object->note = GETPOST('note','alpha'); + $object->origin = $origin; + $object->origin_id = $origin_id; + $object->weight = GETPOST('weight','int')==''?"NULL":GETPOST('weight','int'); + $object->sizeH = GETPOST('sizeH','int')==''?"NULL":GETPOST('sizeH','int'); + $object->sizeW = GETPOST('sizeW','int')==''?"NULL":GETPOST('sizeW','int'); + $object->sizeS = GETPOST('sizeS','int')==''?"NULL":GETPOST('sizeS','int'); + $object->size_units = GETPOST('size_units','int'); + $object->weight_units = GETPOST('weight_units','int'); - $date_delivery = dol_mktime(GETPOST('date_deliveryhour','int'), GETPOST('date_deliverymin','int'), 0, GETPOST('date_deliverymonth','int'), GETPOST('date_deliveryday','int'), GETPOST('date_deliveryyear','int')); + $date_delivery = dol_mktime(GETPOST('date_deliveryhour','int'), GETPOST('date_deliverymin','int'), 0, GETPOST('date_deliverymonth','int'), GETPOST('date_deliveryday','int'), GETPOST('date_deliveryyear','int')); - // On va boucler sur chaque ligne du document d'origine pour completer objet expedition - // avec info diverses + qte a livrer - $classname = ucfirst($object->origin); - $objectsrc = new $classname($db); - $objectsrc->fetch($object->origin_id); - //$object->fetch_lines(); + // On va boucler sur chaque ligne du document d'origine pour completer objet expedition + // avec info diverses + qte a livrer + $classname = ucfirst($object->origin); + $objectsrc = new $classname($db); + $objectsrc->fetch($object->origin_id); + //$object->fetch_lines(); - $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 = GETPOST('expedition_method_id','int'); - $object->tracking_number = GETPOST('tracking_number','alpha'); - $object->ref_int = GETPOST('ref_int','alpha'); + $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 = GETPOST('expedition_method_id','int'); + $object->tracking_number = GETPOST('tracking_number','alpha'); + $object->ref_int = GETPOST('ref_int','alpha'); $num=count($objectsrc->lines); - $totalqty=0; - for ($i = 0; $i < $num; $i++) - { - $qty = "qtyl".$i; - if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); - } + $totalqty=0; + for ($i = 0; $i < $num; $i++) + { + $qty = "qtyl".$i; + if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); + } - if ($totalqty > 0) - { - //var_dump($_POST);exit; - for ($i = 0; $i < $num; $i++) - { - $qty = "qtyl".$i; - if (GETPOST($qty,'int') > 0) - { - $ent = "entl".$i; - $idl = "idl".$i; - $entrepot_id = GETPOST($ent,'int')?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); + if ($totalqty > 0) + { + //var_dump($_POST);exit; + for ($i = 0; $i < $num; $i++) + { + $qty = "qtyl".$i; + if (GETPOST($qty,'int') > 0) + { + $ent = "entl".$i; + $idl = "idl".$i; + $entrepot_id = GETPOST($ent,'int')?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); - $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); - if ($ret < 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } - } + $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); + if ($ret < 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } - if (! $error) - { - $ret=$object->create($user); - if ($ret <= 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } - } - else - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")).'
'; - $error++; - } + if (! $error) + { + $ret=$object->create($user); + if ($ret <= 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } + else + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")).'
'; + $error++; + } - if (! $error) - { - $db->commit(); - Header("Location: fiche.php?id=".$object->id); - exit; - } - else - { - $db->rollback(); - $_GET["commande_id"]=GETPOST('commande_id','int'); - $action='create'; - } + if (! $error) + { + $db->commit(); + Header("Location: fiche.php?id=".$object->id); + exit; + } + else + { + $db->rollback(); + $_GET["commande_id"]=GETPOST('commande_id','int'); + $action='create'; + } } /* * Build a receiving receipt - */ +*/ else if ($action == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) { - $object->fetch($id); - $result = $object->create_delivery($user); - if ($result > 0) - { - Header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); - exit; - } - else - { - $mesg=$object->error; - } + $object->fetch($id); + $result = $object->create_delivery($user); + if ($result > 0) + { + Header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); + exit; + } + else + { + $mesg=$object->error; + } } else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->valider) { - $object->fetch($id); - $object->fetch_thirdparty(); + $object->fetch($id); + $object->fetch_thirdparty(); - $result = $object->valid($user); + $result = $object->valid($user); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { $ret=$object->fetch($id); // Reload to get new records - $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); - } - if ($result < 0) - { - dol_print_error($db,$result); - exit; - } + $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); + } + if ($result < 0) + { + dol_print_error($db,$result); + exit; + } } else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) { - $object->fetch($id); - $result = $object->delete(); - if ($result > 0) - { - Header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); - exit; - } - else - { - $mesg = $object->error; - } + $object->fetch($id); + $result = $object->delete(); + if ($result > 0) + { + Header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); + exit; + } + else + { + $mesg = $object->error; + } } else if ($action == 'reopen' && $user->rights->expedition->valider) { - $object->fetch($id); - $result = $object->setStatut(0); - if ($result < 0) - { - $mesg = $object->error; - } + $object->fetch($id); + $result = $object->setStatut(0); + if ($result < 0) + { + $mesg = $object->error; + } } else if ($action == 'setdate_livraison' && $user->rights->expedition->creer) { - //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datedelivery=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'), GETPOST('liv_year','int')); + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datedelivery=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'), GETPOST('liv_year','int')); - $object->fetch($id); - $result=$object->set_date_livraison($user,$datedelivery); - if ($result < 0) - { - $mesg='
'.$object->error.'
'; - } + $object->fetch($id); + $result=$object->set_date_livraison($user,$datedelivery); + if ($result < 0) + { + $mesg='
'.$object->error.'
'; + } } // Action update description of emailing @@ -252,72 +252,72 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl' || $action == 'settrueDepth' || $action == 'setexpedition_method_id') { - $error=0; + $error=0; - $shipping = new Expedition($db); - $result=$shipping->fetch($id); - if ($result < 0) dol_print_error($db,$shipping->error); + $shipping = new Expedition($db); + $result=$shipping->fetch($id); + if ($result < 0) dol_print_error($db,$shipping->error); - if ($action == 'settrackingnumber') $shipping->tracking_number = trim(GETPOST('trackingnumber','alpha')); - if ($action == 'settrackingurl') $shipping->tracking_url = trim(GETPOST('trackingurl','int')); - if ($action == 'settrueWeight') $shipping->trueWeight = trim(GETPOST('trueWeight','int')); - if ($action == 'settrueWidth') $shipping->trueWidth = trim(GETPOST('trueWidth','int')); - if ($action == 'settrueHeight') $shipping->trueHeight = trim(GETPOST('trueHeight','int')); - if ($action == 'settrueDepth') $shipping->trueDepth = trim(GETPOST('trueDepth','int')); - if ($action == 'setexpedition_method_id') $shipping->expedition_method_id = trim(GETPOST('expedition_method_id','int')); + if ($action == 'settrackingnumber') $shipping->tracking_number = trim(GETPOST('trackingnumber','alpha')); + if ($action == 'settrackingurl') $shipping->tracking_url = trim(GETPOST('trackingurl','int')); + if ($action == 'settrueWeight') $shipping->trueWeight = trim(GETPOST('trueWeight','int')); + if ($action == 'settrueWidth') $shipping->trueWidth = trim(GETPOST('trueWidth','int')); + if ($action == 'settrueHeight') $shipping->trueHeight = trim(GETPOST('trueHeight','int')); + if ($action == 'settrueDepth') $shipping->trueDepth = trim(GETPOST('trueDepth','int')); + if ($action == 'setexpedition_method_id') $shipping->expedition_method_id = trim(GETPOST('expedition_method_id','int')); - if (! $error) - { - if ($shipping->update($user) >= 0) - { - Header("Location: fiche.php?id=".$shipping->id); - exit; - } - $mesg=$shipping->error; - } + if (! $error) + { + if ($shipping->update($user) >= 0) + { + Header("Location: fiche.php?id=".$shipping->id); + exit; + } + $mesg=$shipping->error; + } - $mesg='
'.$mesg.'
'; - $action=""; + $mesg='
'.$mesg.'
'; + $action=""; } /* * Build doc - */ +*/ else if ($action == 'builddoc') // En get ou en post { - // Sauvegarde le dernier modele choisi pour generer un document - $shipment = new Expedition($db); - $shipment->fetch($id); - $shipment->fetch_thirdparty(); + // Sauvegarde le dernier modele choisi pour generer un document + $shipment = new Expedition($db); + $shipment->fetch($id); + $shipment->fetch_thirdparty(); - if (GETPOST('model','alpha')) - { - $shipment->setDocModel($user, GETPOST('model','alpha')); - } + if (GETPOST('model','alpha')) + { + $shipment->setDocModel($user, GETPOST('model','alpha')); + } - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=expedition_pdf_create($db,$shipment,GETPOST('model','alpha'),$outputlangs); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=expedition_pdf_create($db,$shipment,GETPOST('model','alpha'),$outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } } /* * Add file in email form - */ +*/ if (GETPOST('addfile','alpha')) { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); @@ -333,7 +333,7 @@ if (GETPOST('addfile','alpha')) /* * Remove file in email form - */ +*/ if (GETPOST('removedfile','alpha')) { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); @@ -342,7 +342,7 @@ if (GETPOST('removedfile','alpha')) $vardir=$conf->user->dir_output."/".$user->id; $upload_dir_tmp = $vardir.'/temp'; - // TODO Delete only files that was uploaded from email form + // TODO Delete only files that was uploaded from email form $mesg=dol_remove_file_process(GETPOST('removedfile','int'),0); $action ='presend'; @@ -350,7 +350,7 @@ if (GETPOST('removedfile','alpha')) /* * Send mail - */ +*/ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile','alpha') && ! GETPOST('cancel','alpha')) { $langs->load('mails'); @@ -442,13 +442,15 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile' $object->actionmsg = $actionmsg; $object->actionmsg2 = $actionmsg2; $object->fk_element = $object->id; - $object->elementtype = $object->element; + $object->elementtype = $object->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($db); $result=$interface->run_triggers('SHIPPING_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } // Fin appel triggers if ($error) @@ -505,21 +507,21 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile' else if ($action == 'classifybilled') { - $object->fetch($id); - $object->set_billed(); + $object->fetch($id); + $object->set_billed(); } else if ($action == 'setaddress' && $user->rights->expedition->creer) { - $object->fetch($id); - $result=$object->setDeliveryAddress($_POST['fk_address']); - if ($result < 0) dol_print_error($db,$object->error); + $object->fetch($id); + $result=$object->setDeliveryAddress($_POST['fk_address']); + if ($result < 0) dol_print_error($db,$object->error); } /* * View - */ +*/ llxHeader('',$langs->trans('Sending'),'Expedition'); @@ -530,7 +532,7 @@ $formproduct = new FormProduct($db); if ($action == 'create2') { - print_fiche_titre($langs->trans("CreateASending")).'
'; + print_fiche_titre($langs->trans("CreateASending")).'
'; print $langs->trans("ShipmentCreationIsDoneFromOrder"); $action=''; $id=''; $ref=''; } @@ -538,322 +540,322 @@ if ($action == 'create2') // Mode creation if ($action == 'create') { - $expe = new Expedition($db); + $expe = new Expedition($db); - print_fiche_titre($langs->trans("CreateASending")); - if (! $origin) - { - $mesg='
'.$langs->trans("ErrorBadParameters").'
'; - } + print_fiche_titre($langs->trans("CreateASending")); + if (! $origin) + { + $mesg='
'.$langs->trans("ErrorBadParameters").'
'; + } - dol_htmloutput_mesg($mesg); + dol_htmloutput_mesg($mesg); - if ($origin) - { - $classname = ucfirst($origin); + if ($origin) + { + $classname = ucfirst($origin); - $object = new $classname($db); + $object = new $classname($db); - if ($object->fetch($origin_id)) // This include the fetch_lines - { - //var_dump($object); + if ($object->fetch($origin_id)) // This include the fetch_lines + { + //var_dump($object); - $soc = new Societe($db); - $soc->fetch($object->socid); + $soc = new Societe($db); + $soc->fetch($object->socid); - $author = new User($db); - $author->fetch($object->user_author_id); + $author = new User($db); + $author->fetch($object->user_author_id); - if ($conf->stock->enabled) $entrepot = new Entrepot($db); + if ($conf->stock->enabled) $entrepot = new Entrepot($db); - /* - * Document source - */ - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - if (GETPOST('entrepot_id','int')) - { - print ''; - } + /* + * Document source + */ + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (GETPOST('entrepot_id','int')) + { + print ''; + } - print ''; + print '
'; - // Ref - print ''; - print "\n"; + // Ref + print ''; + print "\n"; - // Ref client - print ''; - print ''; + // Ref client + print ''; + print ''; - // Tiers - print ''; - print ''; - print ''; + // Tiers + print ''; + print ''; + print ''; - // Date delivery planned - print ''; - print '\n"; - print ''; + // Date delivery planned + print ''; + print '\n"; + print ''; - // Delivery address - if (($origin == 'commande' && $conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) - || ($origin == 'propal' && $conf->global->PROPAL_ADD_DELIVERY_ADDRESS)) - { - print ''; - print ''."\n"; - } + // Delivery address + if (($origin == 'commande' && $conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) + || ($origin == 'propal' && $conf->global->PROPAL_ADD_DELIVERY_ADDRESS)) + { + print ''; + print ''."\n"; + } - // Note - if ($object->note && ! $user->societe_id) - { - print ''; - print '"; - } + // Note + if ($object->note && ! $user->societe_id) + { + print ''; + print '"; + } - // Weight - print ''; - print ''; - print ''; + // Weight + print ''; + print ''; + print ''; - // Delivery method - print ""; - print '\n"; + // Delivery method + print ""; + print '\n"; - // Tracking number - print ""; - print '\n"; + // Tracking number + print ""; + print '\n"; - print "
'; - if ($origin == 'commande' && $conf->commande->enabled) - { - print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref; - } - if ($origin == 'propal' && $conf->propal->enabled) - { - print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref; - } - print '
'; + if ($origin == 'commande' && $conf->commande->enabled) + { + print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref; + } + if ($origin == 'propal' && $conf->propal->enabled) + { + print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref; + } + print '
'; - print $langs->trans('RefCustomer').''; - print $object->ref_client; - print '
'; + print $langs->trans('RefCustomer').''; + print $object->ref_client; + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans("DateDeliveryPlanned").''; - //print dol_print_date($object->date_livraison,"day"); // date_livraison come from order and will be stored into date_delivery planed. - print $form->select_date($object->date_livraison?$object->date_livraison:-1,'date_delivery',1,1); - print "
'.$langs->trans("DateDeliveryPlanned").''; + //print dol_print_date($object->date_livraison,"day"); // date_livraison come from order and will be stored into date_delivery planed. + print $form->select_date($object->date_livraison?$object->date_livraison:-1,'date_delivery',1,1); + print "
'.$langs->trans('DeliveryAddress').''; - if (!empty($object->fk_delivery_address)) - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id); - } - print '
'.$langs->trans('DeliveryAddress').''; + if (!empty($object->fk_delivery_address)) + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id); + } + print '
'.$langs->trans("NotePrivate").''.nl2br($object->note)."
'.$langs->trans("NotePrivate").''.nl2br($object->note)."
'; - print $langs->trans("Weight"); - print ''; - print $formproduct->select_measuring_units("weight_units","weight",GETPOST('weight_units','int')); - print '
'; - print $langs->trans("Width"); - print ' '; - print $formproduct->select_measuring_units("size_units","size"); - print '
'; - print $langs->trans("Height"); - print '
'; - print $langs->trans("Depth"); - print '
'; + print $langs->trans("Weight"); + print ''; + print $formproduct->select_measuring_units("weight_units","weight",GETPOST('weight_units','int')); + print '
'; + print $langs->trans("Width"); + print ' '; + print $formproduct->select_measuring_units("size_units","size"); + print '
'; + print $langs->trans("Height"); + print '
'; + print $langs->trans("Depth"); + print '
".$langs->trans("DeliveryMethod")."'; - $expe->fetch_delivery_methods(); - print $form->selectarray("expedition_method_id",$expe->meths,GETPOST('expedition_method_id','int'),1,0,0,"",1); - print "
".$langs->trans("DeliveryMethod")."'; + $expe->fetch_delivery_methods(); + print $form->selectarray("expedition_method_id",$expe->meths,GETPOST('expedition_method_id','int'),1,0,0,"",1); + print "
".$langs->trans("TrackingNumber")."'; - print ''; - print "
".$langs->trans("TrackingNumber")."'; + print ''; + print "
"; + print ""; - /* - * Lignes de commandes - * - */ - print '
'; + /* + * Lignes de commandes + * + */ + print '
'; - //$lines = $object->fetch_lines(1); - $numAsked = count($object->lines); + //$lines = $object->fetch_lines(1); + $numAsked = count($object->lines); - /* Lecture des expeditions deja effectuees */ - $object->loadExpeditions(); + /* Lecture des expeditions deja effectuees */ + $object->loadExpeditions(); - if ($numAsked) - { - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->stock->enabled) - { - print ''; - } - print "\n"; - } + if ($numAsked) + { + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->stock->enabled) + { + print ''; + } + print "\n"; + } - $product_static = new Product($db); + $product_static = new Product($db); - $var=true; - $indiceAsked = 0; - while ($indiceAsked < $numAsked) - { - $product = new Product($db); + $var=true; + $indiceAsked = 0; + while ($indiceAsked < $numAsked) + { + $product = new Product($db); - $line = $object->lines[$indiceAsked]; - $var=!$var; + $line = $object->lines[$indiceAsked]; + $var=!$var; - // Show product and description - $type=$line->product_type?$line->product_type:$line->fk_product_type; - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($line->date_start)) $type=1; - if (! empty($line->date_end)) $type=1; + // Show product and description + $type=$line->product_type?$line->product_type:$line->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($line->date_start)) $type=1; + if (! empty($line->date_end)) $type=1; - print "\n"; + print "\n"; - // Product label - if ($line->fk_product > 0) - { - $product->fetch($line->fk_product); - $product->load_stock(); + // Product label + if ($line->fk_product > 0) + { + $product->fetch($line->fk_product); + $product->load_stock(); - print ''; - } - else - { - print "'; + } + else + { + print "\n"; - } + // Show range + print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); + print "\n"; + } - // Qty - print ''; - $qtyProdCom=$line->qty; + // Qty + print ''; + $qtyProdCom=$line->qty; - // Qty already sent - print ''; + // Qty already sent + print ''; - $quantityAsked = $line->qty; - $quantityToBeDelivered = $quantityAsked - $quantityDelivered; + $quantityAsked = $line->qty; + $quantityToBeDelivered = $quantityAsked - $quantityDelivered; - $defaultqty=0; - if (GETPOST('entrepot_id','int')) - { - //var_dump($product); - $stock = $product->stock_warehouse[GETPOST('entrepot_id','int')]->real; - $stock+=0; // Convertit en numerique - $defaultqty=min($quantityToBeDelivered, $stock); - if (($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) || $defaultqty < 0) $defaultqty=0; - } + $defaultqty=0; + if (GETPOST('entrepot_id','int')) + { + //var_dump($product); + $stock = $product->stock_warehouse[GETPOST('entrepot_id','int')]->real; + $stock+=0; // Convertit en numerique + $defaultqty=min($quantityToBeDelivered, $stock); + if (($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) || $defaultqty < 0) $defaultqty=0; + } - // Quantity to send - print ''; + // Quantity to send + print ''; - // Stock - if ($conf->stock->enabled) - { - print ''; - } + // Stock + if ($conf->stock->enabled) + { + print ''; + } - print "\n"; + print "\n"; - // Show subproducts of product - if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) - { - $product->get_sousproduits_arbo(); - $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); - if(count($prods_arbo) > 0) - { - foreach($prods_arbo as $key => $value) - { - //print $value[0]; - $img=''; - if ($value['stock'] < $value['stock_alert']) - { - $img=img_warning($langs->trans("StockTooLow")); - } - print ""; - } - } - } + } + } + } - $indiceAsked++; - } + $indiceAsked++; + } - print ''; - print "
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip").''.$langs->trans("Warehouse").' / '.$langs->trans("Stock").'
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip").''.$langs->trans("Warehouse").' / '.$langs->trans("Stock").'
'; - print ''; // ancre pour retourner sur la ligne + print ''; + print ''; // ancre pour retourner sur la ligne - // Show product and description - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $product_static->libelle=$line->product_label; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$line->product_label; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc)); - print $form->textwithtooltip($text,$description,3,'','',$i); + // Show product and description + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $product_static->libelle=$line->product_label; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$line->product_label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc)); + print $form->textwithtooltip($text,$description,3,'','',$i); - // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); + // Show range + print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); - // Add description in form - if ($conf->global->PRODUIT_DESC_IN_FORM) - { - print ($line->desc && $line->desc!=$line->product_label)?'
'.dol_htmlentitiesbr($line->desc):''; - } + // Add description in form + if ($conf->global->PRODUIT_DESC_IN_FORM) + { + print ($line->desc && $line->desc!=$line->product_label)?'
'.dol_htmlentitiesbr($line->desc):''; + } - print '
"; - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($line->desc); + print '"; + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.nl2br($line->desc); - // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); - print "'.$line->qty.''.$line->qty.''; - $quantityDelivered = $object->expeditions[$line->id]; - print $quantityDelivered; - print ''; + $quantityDelivered = $object->expeditions[$line->id]; + print $quantityDelivered; + print ''; - if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - print ''; - print ''; - } - else print '0'; - print ''; + if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + print ''; + print ''; + } + else print '0'; + print ''; - if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - // Show warehous - if (GETPOST('entrepot_id','int')) - { - print $formproduct->selectWarehouses(GETPOST('entrepot_id','int'),'entl'.$indiceAsked,'',1,0,$line->fk_product); - //print $stock.' '.$quantityToBeDelivered; - //if ($stock >= 0 && $stock < $quantityToBeDelivered) - if ($stock < $quantityToBeDelivered) - { - print ' '.img_warning($langs->trans("StockTooLow")); - } - } - else - { - print $formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product); - } - } - else - { - print $langs->trans("Service"); - } - print ''; + if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + // Show warehous + if (GETPOST('entrepot_id','int')) + { + print $formproduct->selectWarehouses(GETPOST('entrepot_id','int'),'entl'.$indiceAsked,'',1,0,$line->fk_product); + //print $stock.' '.$quantityToBeDelivered; + //if ($stock >= 0 && $stock < $quantityToBeDelivered) + if ($stock < $quantityToBeDelivered) + { + print ' '.img_warning($langs->trans("StockTooLow")); + } + } + else + { + print $formproduct->selectWarehouses('','entl'.$indiceAsked,'',1,0,$line->fk_product); + } + } + else + { + print $langs->trans("Service"); + } + print '
      -> + // Show subproducts of product + if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) + { + $product->get_sousproduits_arbo(); + $prods_arbo = $product->get_arbo_each_prod($qtyProdCom); + if(count($prods_arbo) > 0) + { + foreach($prods_arbo as $key => $value) + { + //print $value[0]; + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print "
      -> ".$value['fullpath']." (".$value['nb'].") ".$value['nb_total']."   ".$value['stock']." ".$img."

"; - print '
'; - } - else - { - dol_print_error($db); - } - } + print '
'; + print ""; + print ''; + } + else + { + dol_print_error($db); + } + } } else /* *************************************************************************** */ @@ -862,602 +864,606 @@ else /* */ /* *************************************************************************** */ { - if (! empty($id) || ! empty($ref)) - { - $result = $object->fetch($id,$ref); - if ($result < 0) - { - dol_print_error($db,$object->error); - exit -1; - } - $lines = $object->lines; - $num_prod = count($lines); + if (! empty($id) || ! empty($ref)) + { + $result = $object->fetch($id,$ref); + if ($result < 0) + { + dol_print_error($db,$object->error); + exit -1; + } + $lines = $object->lines; + $num_prod = count($lines); - if ($object->id > 0) - { - dol_htmloutput_mesg($mesg); + if ($object->id > 0) + { + dol_htmloutput_mesg($mesg); - if (!empty($object->origin)) - { - $typeobject = $object->origin; - $origin = $object->origin; - $object->fetch_origin(); - } - - $soc = new Societe($db); - $soc->fetch($object->socid); - - // delivery link - $object->fetchObjectLinked($object->id,$object->element,-1,-1); - - $head=shipping_prepare_head($object); - dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending'); - - dol_htmloutput_mesg($mesg); - - /* - * Confirmation de la suppression - */ - if ($action == 'delete') - { - $ret=$form->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 ($action == 'valid') - { - $objectref = substr($object->ref, 1, 4); - if ($objectref == 'PROV') - { - $numref = $object->getNextNumRef($soc); - } - else - { - $numref = $object->ref; - } - $ret=$form->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 ($action == 'annuler') - { - $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('CancelSending'),$langs->trans("ConfirmCancelSending",$object->ref),'confirm_cancel','',0,1); - if ($ret == 'html') print '
'; - } - - // Calculate ture totalVeight and totalVolume for all products - // by adding weight and volume of each line. - $totalWeight = ''; - $totalVolume = ''; - $weightUnit=0; - $volumeUnit=0; - for ($i = 0 ; $i < $num_prod ; $i++) - { - $weightUnit=0; - $volumeUnit=0; - if (! empty($lines[$i]->weight_units)) $weightUnit = $lines[$i]->weight_units; - if (! empty($lines[$i]->volume_units)) $volumeUnit = $lines[$i]->volume_units; - // TODO Use a function addvalueunits(val1,unit1,val2,unit2)=>(val,unit) - if ($lines[$i]->weight_units < 50) - { - $trueWeightUnit=pow(10,$weightUnit); - $totalWeight += $lines[$i]->weight*$lines[$i]->qty_shipped*$trueWeightUnit; - } - else - { - $trueWeightUnit=$weightUnit; - $totalWeight += $lines[$i]->weight*$lines[$i]->qty_shipped; - } - if ($lines[$i]->volume_units < 50) - { - //print $lines[$i]->volume."x".$lines[$i]->volume_units."x".($lines[$i]->volume_units < 50)."x".$volumeUnit; - $trueVolumeUnit=pow(10,$volumeUnit); - //print $lines[$i]->volume; - $totalVolume += $lines[$i]->volume*$lines[$i]->qty_shipped*$trueVolumeUnit; - } - else - { - $trueVolumeUnit=$volumeUnit; - $totalVolume += $lines[$i]->volume*$lines[$i]->qty_shipped; - } - } - $totalVolume=$totalVolume; - //print "totalVolume=".$totalVolume." volumeUnit=".$volumeUnit; - - print ''; - - // Ref - print ''; - print ''; - - // Customer - print ''; - print ''; - print ""; - - // Linked documents - if ($typeobject == 'commande' && $object->$typeobject->id && $conf->commande->enabled) - { - print ''; - print '\n"; - print ''; - } - if ($typeobject == 'propal' && $object->$typeobject->id && $conf->propal->enabled) - { - print ''; - print '\n"; - print ''; - } - - // Ref customer - print ''; - print '\n"; - print ''; - - // Date creation - print ''; - print '\n"; - print ''; - - // Delivery date planed - print ''; - print ''; - - // Delivery address - if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS || $conf->global->PROPAL_ADD_DELIVERY_ADDRESS) - { - print ''; - } - - // Weight - print ''; - - // Volume Total - print ''; - print '\n"; - print ''; - - // Width - print ''; - - // Height - print ''; - - // Depth - print ''; - - // Status - print ''; - print '\n"; - print ''; - - // Sending method - print ''; - print ''; - - // Tracking Number - print ''; - - print "
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref','ref'); - print '
'.$langs->trans("Customer").''.$soc->getNomUrl(1).'
'; - $objectsrc=new Commande($db); - $objectsrc->fetch($object->$typeobject->id); - print $langs->trans("RefOrder").''; - print $objectsrc->getNomUrl(1,'commande'); - print "
'; - $objectsrc=new Propal($db); - $objectsrc->fetch($object->$typeobject->id); - print $langs->trans("RefProposal").''; - print $objectsrc->getNomUrl(1,'expedition'); - print "
'.$langs->trans("RefCustomer").''.$object->ref_customer."
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation,"day")."
'; - print ''; - - if ($action != 'editdate_livraison') print ''; - print '
'; - print $langs->trans('DateDeliveryPlanned'); - print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; - print '
'; - if ($action == 'editdate_livraison') - { - print '
'; - print ''; - print ''; - $form->select_date($object->date_delivery?$object->date_delivery:-1,'liv_',1,1,'',"setdate_livraison"); - print ''; - print '
'; - } - else - { - print $object->date_delivery ? dol_print_date($object->date_delivery,'dayhourtext') : ' '; - } - print '
'; - print ''; - - if ($action != 'editdelivery_address' && $object->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; - print '
'; - - if ($action == 'editdelivery_address') - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipment',$object->id); - } - else - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipment',$object->id); - } - print '
'.$form->editfieldkey("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer).''; - print $form->editfieldval("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer); - print $object->weight_units?measuring_units_string($object->weight_units,"weight"):''; - print '
'.$langs->trans("Volume").''; - if ($object->trueVolume) - { - // If sending volume defined - print $object->trueVolume.' '.measuring_units_string($object->volumeUnit,"volume"); - } - else - { - // If sending volume not defined we use sum of products - if ($totalVolume > 0) - { - print $totalVolume.' '; - if ($volumeUnit < 50) print measuring_units_string(0,"volume"); - else print measuring_units_string($volumeUnit,"volume"); - } - else print ' '; - } - print "
'.$form->editfieldkey("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer).''; - print $form->editfieldval("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer); - print $object->trueWidth?measuring_units_string($object->width_units,"size"):''; - print '
'.$form->editfieldkey("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer).''; - print $form->editfieldval("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer); - print $object->trueHeight?measuring_units_string($object->height_units,"size"):''; - print '
'.$form->editfieldkey("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer).''; - print $form->editfieldval("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer); - print $object->trueDepth?measuring_units_string($object->depth_units,"size"):''; - print '
'.$langs->trans("Status").''.$object->getLibStatut(4)."
'; - print ''; - - if ($action != 'editexpedition_method_id') print ''; - print '
'; - print $langs->trans('SendingMethod'); - print 'id.'">'.img_edit($langs->trans('SetSendingMethod'),1).'
'; - print '
'; - if ($action == 'editexpedition_method_id') - { - print '
'; - print ''; - print ''; - $object->fetch_delivery_methods(); - print $form->selectarray("expedition_method_id",$object->meths,$object->expedition_method_id,1,0,0,"",1); - print ''; - print '
'; - } - else - { - if ($object->expedition_method_id > 0) - { - // Get code using getLabelFromKey - $code=$langs->getLabelFromKey($db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); - print $langs->trans("SendingMethod".strtoupper($code)); - } - } - print '
'.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,$object,$user->rights->expedition->creer).''; - print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number); - print '
\n"; - - /* - * Lignes produits - */ - print '
'; - print ''; - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - { - print ''; - } - print ''; - print ''; - if ($object->fk_statut <= 1) - { - print ''; - } - else - { - print ''; - } - - print ''; - print ''; - //print ''; - - if ($conf->stock->enabled) - { - print ''; - } - - print "\n"; - - $var=false; - - for ($i = 0 ; $i < $num_prod ; $i++) - { - print ""; - - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - { - print ''; - } - - // Predefined product or service - if ($lines[$i]->fk_product > 0) - { - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $object->fetch_thirdparty(); - $prod = new Product($db, $lines[$i]->fk_product); - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! GETPOST('lang_id','int')) $newlang=GETPOST('lang_id','int'); - if (empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (!empty($object->origin)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + $typeobject = $object->origin; + $origin = $object->origin; + $object->fetch_origin(); } - $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; - } - else - $label = $lines[$i]->product_label; + $soc = new Societe($db); + $soc->fetch($object->socid); - print '\n"; - } + $head=shipping_prepare_head($object); + dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending'); - // Qte commande - print ''; + dol_htmloutput_mesg($mesg); - // Qte a expedier ou expedier - print ''; + /* + * Confirmation de la suppression + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteSending'),$langs->trans("ConfirmDeleteSending",$object->ref),'confirm_delete','',0,1); + if ($ret == 'html') print '
'; + } - // Weight - print ''; + /* + * Confirmation de la validation + */ + if ($action == 'valid') + { + $objectref = substr($object->ref, 1, 4); + if ($objectref == 'PROV') + { + $numref = $object->getNextNumRef($soc); + } + else + { + $numref = $object->ref; + } + $ret=$form->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 ($action == 'annuler') + { + $ret=$form->form_confirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('CancelSending'),$langs->trans("ConfirmCancelSending",$object->ref),'confirm_cancel','',0,1); + if ($ret == 'html') print '
'; + } - // Volume - print ''; + // Calculate ture totalVeight and totalVolume for all products + // by adding weight and volume of each line. + $totalWeight = ''; + $totalVolume = ''; + $weightUnit=0; + $volumeUnit=0; + for ($i = 0 ; $i < $num_prod ; $i++) + { + $weightUnit=0; + $volumeUnit=0; + if (! empty($lines[$i]->weight_units)) $weightUnit = $lines[$i]->weight_units; + if (! empty($lines[$i]->volume_units)) $volumeUnit = $lines[$i]->volume_units; + // TODO Use a function addvalueunits(val1,unit1,val2,unit2)=>(val,unit) + if ($lines[$i]->weight_units < 50) + { + $trueWeightUnit=pow(10,$weightUnit); + $totalWeight += $lines[$i]->weight*$lines[$i]->qty_shipped*$trueWeightUnit; + } + else + { + $trueWeightUnit=$weightUnit; + $totalWeight += $lines[$i]->weight*$lines[$i]->qty_shipped; + } + if ($lines[$i]->volume_units < 50) + { + //print $lines[$i]->volume."x".$lines[$i]->volume_units."x".($lines[$i]->volume_units < 50)."x".$volumeUnit; + $trueVolumeUnit=pow(10,$volumeUnit); + //print $lines[$i]->volume; + $totalVolume += $lines[$i]->volume*$lines[$i]->qty_shipped*$trueVolumeUnit; + } + else + { + $trueVolumeUnit=$volumeUnit; + $totalVolume += $lines[$i]->volume*$lines[$i]->qty_shipped; + } + } + $totalVolume=$totalVolume; + //print "totalVolume=".$totalVolume." volumeUnit=".$volumeUnit; - // Size - //print ''; + print '
 '.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").''.$langs->trans("WarehouseSource").'
'.($i+1).''; + // delivery link + $object->fetchObjectLinked($object->id,$object->element,-1,-1); - // Affiche ligne produit - $text = ''; - if ($lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service'); - else $text.= img_object($langs->trans('ShowProduct'),'product'); - $text.= ' '.$lines[$i]->ref.''; - $text.= ' - '.$label; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($lines[$i]->description)); - //print $description; - print $form->textwithtooltip($text,$description,3,'','',$i); - print_date_range($lines[$i]->date_start,$lines[$i]->date_end); - if ($conf->global->PRODUIT_DESC_IN_FORM) - { - print ($lines[$i]->description && $lines[$i]->description!=$lines[$i]->product)?'
'.dol_htmlentitiesbr($lines[$i]->description):''; - } - } - else - { - print "
"; - if ($lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($lines[$i]->description); - print_date_range($lines[$i]->date_start,$lines[$i]->date_end); - print "'.$lines[$i]->qty_asked.''.$lines[$i]->qty_shipped.''; - if ($lines[$i]->fk_product_type == 0) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight"); - else print ' '; - print ''; - if ($lines[$i]->fk_product_type == 0) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume"); - else print ' '; - print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").'
'; - // Entrepot source - if ($conf->stock->enabled) - { - print ''; - } + // Ref + print ''; + print ''; - print ""; + // Customer + print ''; + print ''; + print ""; - $var=!$var; - } - } + // Linked documents + if ($typeobject == 'commande' && $object->$typeobject->id && $conf->commande->enabled) + { + print ''; + print '\n"; + print ''; + } + if ($typeobject == 'propal' && $object->$typeobject->id && $conf->propal->enabled) + { + print ''; + print '\n"; + print ''; + } - print "
'; - if ($lines[$i]->entrepot_id > 0) - { - $entrepot = new Entrepot($db); - $entrepot->fetch($lines[$i]->entrepot_id); - print $entrepot->getNomUrl(1); - } - print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); + print '
'.$langs->trans("Customer").''.$soc->getNomUrl(1).'
'; + $objectsrc=new Commande($db); + $objectsrc->fetch($object->$typeobject->id); + print $langs->trans("RefOrder").''; + print $objectsrc->getNomUrl(1,'commande'); + print "
'; + $objectsrc=new Propal($db); + $objectsrc->fetch($object->$typeobject->id); + print $langs->trans("RefProposal").''; + print $objectsrc->getNomUrl(1,'expedition'); + print "
\n"; + // Ref customer + print ''.$langs->trans("RefCustomer").''; + print ''.$object->ref_customer."\n"; + print ''; - print "\n\n"; + // Date creation + print ''.$langs->trans("DateCreation").''; + print ''.dol_print_date($object->date_creation,"day")."\n"; + print ''; + + // Delivery date planed + print ''; + print ''; + + if ($action != 'editdate_livraison') print ''; + print '
'; + print $langs->trans('DateDeliveryPlanned'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; + print ''; + if ($action == 'editdate_livraison') + { + print '
'; + print ''; + print ''; + $form->select_date($object->date_delivery?$object->date_delivery:-1,'liv_',1,1,'',"setdate_livraison"); + print ''; + print '
'; + } + else + { + print $object->date_delivery ? dol_print_date($object->date_delivery,'dayhourtext') : ' '; + } + print ''; + print ''; + + // Delivery address + if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS || $conf->global->PROPAL_ADD_DELIVERY_ADDRESS) + { + print ''; + print ''; + + if ($action != 'editdelivery_address' && $object->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; + print ''; + + if ($action == 'editdelivery_address') + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipment',$object->id); + } + else + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipment',$object->id); + } + print ''; + } + + // Weight + print ''.$form->editfieldkey("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer).''; + print $form->editfieldval("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer); + print $object->weight_units?measuring_units_string($object->weight_units,"weight"):''; + print ''; + + // Volume Total + print ''.$langs->trans("Volume").''; + print ''; + if ($object->trueVolume) + { + // If sending volume defined + print $object->trueVolume.' '.measuring_units_string($object->volumeUnit,"volume"); + } + else + { + // If sending volume not defined we use sum of products + if ($totalVolume > 0) + { + print $totalVolume.' '; + if ($volumeUnit < 50) print measuring_units_string(0,"volume"); + else print measuring_units_string($volumeUnit,"volume"); + } + else print ' '; + } + print "\n"; + print ''; + + // Width + print ''.$form->editfieldkey("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer).''; + print $form->editfieldval("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer); + print $object->trueWidth?measuring_units_string($object->width_units,"size"):''; + print ''; + + // Height + print ''.$form->editfieldkey("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer).''; + print $form->editfieldval("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer); + print $object->trueHeight?measuring_units_string($object->height_units,"size"):''; + print ''; + + // Depth + print ''.$form->editfieldkey("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer).''; + print $form->editfieldval("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer); + print $object->trueDepth?measuring_units_string($object->depth_units,"size"):''; + print ''; + + // Status + print ''.$langs->trans("Status").''; + print ''.$object->getLibStatut(4)."\n"; + print ''; + + // Sending method + print ''; + print ''; + + if ($action != 'editexpedition_method_id') print ''; + print '
'; + print $langs->trans('SendingMethod'); + print 'id.'">'.img_edit($langs->trans('SetSendingMethod'),1).'
'; + print ''; + if ($action == 'editexpedition_method_id') + { + print '
'; + print ''; + print ''; + $object->fetch_delivery_methods(); + print $form->selectarray("expedition_method_id",$object->meths,$object->expedition_method_id,1,0,0,"",1); + print ''; + print '
'; + } + else + { + if ($object->expedition_method_id > 0) + { + // Get code using getLabelFromKey + $code=$langs->getLabelFromKey($db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); + print $langs->trans("SendingMethod".strtoupper($code)); + } + } + print ''; + print ''; + + // Tracking Number + print ''.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,$object,$user->rights->expedition->creer).''; + print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number); + print ''; + + print "\n"; + + /* + * Lignes produits + */ + print '
'; + print ''; + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + { + print ''; + } + print ''; + print ''; + if ($object->fk_statut <= 1) + { + print ''; + } + else + { + print ''; + } + + print ''; + print ''; + //print ''; + + if ($conf->stock->enabled) + { + print ''; + } + + print "\n"; + + $var=false; + + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $object->fetch_thirdparty(); + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + } + + for ($i = 0 ; $i < $num_prod ; $i++) + { + print ""; + + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + { + print ''; + } + + // Predefined product or service + if ($lines[$i]->fk_product > 0) + { + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $prod = new Product($db); + $prod->fetch($lines[$i]->fk_product); + $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; + } + else + $label = $lines[$i]->product_label; + + print '\n"; + } + + // Qte commande + print ''; + + // Qte a expedier ou expedier + print ''; + + // Weight + print ''; + + // Volume + print ''; + + // Size + //print ''; + + // Entrepot source + if ($conf->stock->enabled) + { + print ''; + } + + print ""; + + $var=!$var; + } + } + + print "
 '.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").''.$langs->trans("WarehouseSource").'
'.($i+1).''; + + // Affiche ligne produit + $text = ''; + if ($lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service'); + else $text.= img_object($langs->trans('ShowProduct'),'product'); + $text.= ' '.$lines[$i]->ref.''; + $text.= ' - '.$label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($lines[$i]->description)); + //print $description; + print $form->textwithtooltip($text,$description,3,'','',$i); + print_date_range($lines[$i]->date_start,$lines[$i]->date_end); + if ($conf->global->PRODUIT_DESC_IN_FORM) + { + print ($lines[$i]->description && $lines[$i]->description!=$lines[$i]->product)?'
'.dol_htmlentitiesbr($lines[$i]->description):''; + } + } + else + { + print "
"; + if ($lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.nl2br($lines[$i]->description); + print_date_range($lines[$i]->date_start,$lines[$i]->date_end); + print "'.$lines[$i]->qty_asked.''.$lines[$i]->qty_shipped.''; + if ($lines[$i]->fk_product_type == 0) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight"); + else print ' '; + print ''; + if ($lines[$i]->fk_product_type == 0) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume"); + else print ' '; + print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").''; + if ($lines[$i]->entrepot_id > 0) + { + $entrepot = new Entrepot($db); + $entrepot->fetch($lines[$i]->entrepot_id); + print $entrepot->getNomUrl(1); + } + print '
\n"; + + print "\n\n"; - /* - * Boutons actions - */ + /* + * Boutons actions + */ - if ($user->societe_id == 0) - { - print '
'; + if ($user->societe_id == 0) + { + print '
'; - if ($object->statut == 0 && $num_prod > 0) - { - if ($user->rights->expedition->valider) - { - print ''.$langs->trans("Validate").''; - } - else - { - print ''.$langs->trans("Validate").''; - } - } + if ($object->statut == 0 && $num_prod > 0) + { + if ($user->rights->expedition->valider) + { + print ''.$langs->trans("Validate").''; + } + else + { + print ''.$langs->trans("Validate").''; + } + } - // TODO add alternative status - /* if ($object->statut == 1 && $user->rights->expedition->valider) - { - print ''.$langs->trans("ReOpen").''; - }*/ + // TODO add alternative status + /* if ($object->statut == 1 && $user->rights->expedition->valider) + { + print ''.$langs->trans("ReOpen").''; + }*/ - // Send - if ($object->statut > 0) - { - $ref = dol_sanitizeFileName($object->ref); - $file = $conf->expedition->dir_output . '/sending/'.$ref.'/'.$ref.'.pdf'; - if (file_exists($file)) - { + // Send + if ($object->statut > 0) + { + $ref = dol_sanitizeFileName($object->ref); + $file = $conf->expedition->dir_output . '/sending/'.$ref.'/'.$ref.'.pdf'; + if (file_exists($file)) + { if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) { - print ''.$langs->trans('SendByMail').''; + print ''.$langs->trans('SendByMail').''; } else print ''.$langs->trans('SendByMail').''; - } - } + } + } - // Create bill and Classify billed - if ($conf->facture->enabled && $object->statut > 0 && ! $object->billed) - { - if ($user->rights->facture->creer) - { - // TODO until the module is autonomous - print ''.$langs->trans("CreateBill").''; - //print ''.$langs->trans("CreateBill").''; - } + // Create bill and Classify billed + if ($conf->facture->enabled && $object->statut > 0 && ! $object->billed) + { + if ($user->rights->facture->creer) + { + // TODO until the module is autonomous + print ''.$langs->trans("CreateBill").''; + //print ''.$langs->trans("CreateBill").''; + } - // TODO add alternative status - if ($user->rights->expedition->creer && $object->statut > 0) - { - print ''.$langs->trans("ClassifyBilled").''; - } - } + // TODO add alternative status + if ($user->rights->expedition->creer && $object->statut > 0) + { + print ''.$langs->trans("ClassifyBilled").''; + } + } - if ($conf->livraison_bon->enabled && $object->statut == 1 && $user->rights->expedition->livraison->creer && empty($object->linkedObjectsIds)) - { - print ''.$langs->trans("DeliveryOrder").''; - } + if ($conf->livraison_bon->enabled && $object->statut == 1 && $user->rights->expedition->livraison->creer && empty($object->linkedObjectsIds)) + { + print ''.$langs->trans("DeliveryOrder").''; + } - if ($user->rights->expedition->supprimer) - { - print ''.$langs->trans("Delete").''; - } + if ($user->rights->expedition->supprimer) + { + print ''.$langs->trans("Delete").''; + } - print '
'; - print "
\n"; - } + print '
'; + print "
\n"; + } - print '
'; + print '
'; - /* - * Documents generated - */ - if ($action != 'presend') - { - $objectref = dol_sanitizeFileName($object->ref); - $filedir = $conf->expedition->dir_output . "/sending/" .$objectref; + /* + * Documents generated + */ + if ($action != 'presend') + { + $objectref = dol_sanitizeFileName($object->ref); + $filedir = $conf->expedition->dir_output . "/sending/" .$objectref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->expedition->lire; - $delallowed=$user->rights->expedition->supprimer; - //$genallowed=1; - //$delallowed=0; + $genallowed=$user->rights->expedition->lire; + $delallowed=$user->rights->expedition->supprimer; + //$genallowed=1; + //$delallowed=0; - $somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); - - /* - * Linked object block - */ - $somethingshown=$object->showLinkedObjectBlock(); - - if ($genallowed && ! $somethingshown) $somethingshown=1; + $somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); - print ''; + /* + * Linked object block + */ + $somethingshown=$object->showLinkedObjectBlock(); - // List of actions on element - include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'shipping',$socid); + if ($genallowed && ! $somethingshown) $somethingshown=1; - print '
'; - } + print '
'; - /* - * Action presend - * - */ - if ($action == 'presend') - { - $ref = dol_sanitizeFileName($object->ref); - $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; + // List of actions on element + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'shipping',$socid); - print '
'; - print_titre($langs->trans('SendShippingByEMail')); + print '
'; + } - // Cree l'objet formulaire mail - include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); - $formmail = new FormMail($db); - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - $formmail->withfrom=1; - $formmail->withto=GETPOST('sendto','int')?GETPOST('sendto','int'):1; - $formmail->withtosocid=$soc->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtocccsocid=0; - $formmail->withtopic=$langs->trans('SendShippingRef','__SHIPPINGREF__'); - $formmail->withfile=2; - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__SHIPPINGREF__']=$object->ref; - // Tableau des parametres complementaires - $formmail->param['action']='send'; - $formmail->param['models']='shipping_send'; - $formmail->param['shippingid']=$object->id; - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + /* + * Action presend + * + */ + if ($action == 'presend') + { + $ref = dol_sanitizeFileName($object->ref); + $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; - // Init list of files - if (GETPOST('mode','alpha')=='init') - { - $formmail->clear_attached_files(); - $formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf'); - } + print '
'; + print_titre($langs->trans('SendShippingByEMail')); - // Show form - $formmail->show_form(); + // Cree l'objet formulaire mail + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $formmail->withto=GETPOST('sendto','int')?GETPOST('sendto','int'):1; + $formmail->withtosocid=$soc->id; + $formmail->withtocc=1; + $formmail->withtoccsocid=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtocccsocid=0; + $formmail->withtopic=$langs->trans('SendShippingRef','__SHIPPINGREF__'); + $formmail->withfile=2; + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + // Tableau des substitutions + $formmail->substit['__SHIPPINGREF__']=$object->ref; + // Tableau des parametres complementaires + $formmail->param['action']='send'; + $formmail->param['models']='shipping_send'; + $formmail->param['shippingid']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - print '
'; - } + // Init list of files + if (GETPOST('mode','alpha')=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf'); + } - if ($action != 'presend' && ! empty($origin) && $object->$origin->id) - { - print '
'; - //show_list_sending_receive($object->origin,$object->origin_id," AND e.rowid <> ".$object->id); - show_list_sending_receive($object->origin,$object->origin_id); - } - } + // Show form + $formmail->show_form(); + + print '
'; + } + + if ($action != 'presend' && ! empty($origin) && $object->$origin->id) + { + print '
'; + //show_list_sending_receive($object->origin,$object->origin_id," AND e.rowid <> ".$object->id); + show_list_sending_receive($object->origin,$object->origin_id); + } + } } $db->close();