diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 18a3c38e012..be31bb80508 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1567,7 +1567,7 @@ class Commande extends CommonObject } /** - * \brief Definit une date de livraison + * \brief Set the planned delivery date * \param user Objet utilisateur qui modifie * \param date_livraison Date de livraison * \return int <0 si ko, >0 si ok @@ -1577,10 +1577,10 @@ class Commande extends CommonObject if ($user->rights->commande->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET date_livraison = ".($date_livraison ? $this->db->idate($date_livraison) : 'null'); - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql.= " WHERE rowid = ".$this->id; - dol_syslog("Commande::set_date_livraison sql=$sql",LOG_DEBUG); + dol_syslog("Commande::set_date_livraison sql=".$sql,LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index d854ba11901..a990dec1a2e 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1489,13 +1489,13 @@ else print ''; print ''; - // Delivery date + // Delivery date planed print ''; print ''; - if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; + if ($_GET['action'] != 'editdate_livraison') print ''; print '
'; - print $langs->trans('DeliveryDate'); + print $langs->trans('DateDeliveryPlanned'); print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; print ''; if ($_GET['action'] == 'editdate_livraison') @@ -1503,7 +1503,7 @@ else print '
'; print ''; print ''; - $html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison"); + $html->select_date($commande->date_livraison?$commande->date_livraison:-1,'liv_','','','',"setdate_livraison"); print ''; print '
'; } diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php index 3dfff074c56..e5d51e7e8aa 100644 --- a/htdocs/compta/commande/fiche.php +++ b/htdocs/compta/commande/fiche.php @@ -240,13 +240,13 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // Date de livraison + // Delivery date planed print ''; print ''; - if (1 == 2 && $_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; + if (1 == 2 && $_GET['action'] != 'editdate_livraison') print ''; print '
'; - print $langs->trans('DeliveryDate'); + print $langs->trans('DateDeliveryPlanned'); print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; print ''; if ($_GET['action'] == 'editdate_livraison') @@ -254,7 +254,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; print ''; - $html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison"); + $html->select_date($commande->date_livraison>0?$commande->date_livraison:-1,'liv_','','','',"setdate_livraison"); print ''; print '
'; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3db82ce3f7c..c05c70cb1ad 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1022,7 +1022,7 @@ class CommonObject function setStatut($statut,$elementId='',$elementType='') { $elementId = (!empty($elementId)?$elementId:$this->id); - $elementTable = (!empty($elementType)?$elementType:$this->element); + $elementTable = (!empty($elementType)?$elementType:$this->table_element); $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql.= " SET fk_statut = ".$statut; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 44ed0726358..607e0573967 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -32,7 +32,7 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/co /** * \class Expedition - * \brief Classe de gestion des expeditions + * \brief Class to manage shippings */ class Expedition extends CommonObject { @@ -53,7 +53,19 @@ class Expedition extends CommonObject var $lignes; var $meths; - var $date_delivery; + var $trueWeight; + var $weight_units; + var $trueWidth; + var $width_units; + var $trueHeight; + var $height_units; + var $trueDepth; + var $depth_units; + // A denormalized value + var $trueSize; + + var $date_delivery; // Date delivery planed + var $date_expedition; // Date delivery real var $date_creation; var $date_valid; @@ -115,14 +127,14 @@ class Expedition extends CommonObject $sql.= "'(PROV)'"; $sql.= ", '".$this->ref_customer."'"; $sql.= ", ".$conf->entity; - $sql.= ", ".$this->db->idate(gmmktime()); + $sql.= ", '".$this->db->idate(gmmktime())."'"; $sql.= ", ".$user->id; - $sql.= ", ".$this->db->idate($this->date_expedition); - $sql.= ", ".$this->db->idate($this->date_delivery); + $sql.= ", ".($this->date_expedition>0?"'".$this->db->idate($this->date_expedition)."'":"null"); + $sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null"); $sql.= ", ".$this->socid; $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null"); $sql.= ", ".($this->expedition_method_id>0?$this->expedition_method_id:"null"); - $sql.= ", '". $this->tracking_number."'"; + $sql.= ", '".addslashes($this->tracking_number)."'"; $sql.= ", ".$this->weight; $sql.= ", ".$this->sizeS; $sql.= ", ".$this->sizeW; @@ -258,9 +270,11 @@ class Expedition extends CommonObject $this->ref_customer = $obj->ref_customer; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; + $this->date_creation = $this->db->jdate($obj->date_creation); $this->date = $this->db->jdate($obj->date_expedition); // TODO obsolete - $this->date_shipping = $this->db->jdate($obj->date_expedition); - $this->date_delivery = $this->db->jdate($obj->date_delivery); + $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO obsolete + $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real + $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_adresse_livraison; $this->modelpdf = $obj->model_pdf; $this->expedition_method_id = $obj->fk_expedition_methode; @@ -624,12 +638,13 @@ class Expedition extends CommonObject $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_asked"; $sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref, p.fk_product_type, p.label, p.weight, p.weight_units, p.volume, p.volume_units"; - $sql.= " FROM (".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = cd.fk_product)"; + $sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,"; + $sql.= " ".MAIN_DB_PREFIX."commandedet as cd)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; $sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " AND ed.fk_origin_line = cd.rowid"; + dol_syslog("Expedition::fetch_lines sql=".$sql); $resql = $this->db->query($sql); if ($resql) { @@ -803,6 +818,40 @@ class Expedition extends CommonObject } + /** + * \brief Set the planned delivery date + * \param user Objet utilisateur qui modifie + * \param date_livraison Date de livraison + * \return int <0 si ko, >0 si ok + */ + function set_date_livraison($user, $date_livraison) + { + if ($user->rights->expedition->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; + $sql.= " SET date_delivery = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog("Expedition::set_date_livraison sql=".$sql,LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->date_delivery = $date_livraison; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Commande::set_date_livraison ".$this->error,LOG_ERR); + return -1; + } + } + else + { + return -2; + } + } + /** * \brief Fetch deliveries method and return an array. Load array this->meths(rowid=>label). */ diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 2eed76bf0c3..b819e0036cb 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2005-2010 Regis Houssin * @@ -72,7 +72,6 @@ if ($_POST["action"] == 'add') // Creation de l'objet expedition $expedition = new Expedition($db); - $expedition->date_expedition = time(); $expedition->note = $_POST["note"]; $expedition->origin = $origin; $expedition->origin_id = $origin_id; @@ -83,8 +82,8 @@ if ($_POST["action"] == 'add') $expedition->size_units = $_POST["size_units"]; $expedition->weight_units = $_POST["weight_units"]; - // On boucle sur chaque ligne du document d'origine pour completer objet expedition - // avec qte a livrer + // 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); @@ -92,7 +91,7 @@ if ($_POST["action"] == 'add') $expedition->socid = $object->socid; $expedition->ref_customer = $object->ref_client; - $expedition->date_delivery = $object->date_livraison; + $expedition->date_delivery = $object->date_livraison; // 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"]; @@ -189,6 +188,34 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') } } +if ($_REQUEST["action"] == 'open') +{ + if ($user->rights->expedition->valider ) + { + $expedition = new Expedition($db); + $expedition->fetch($_GET["id"]); + $result = $expedition->setStatut(0); + if ($result < 0) + { + $mesg = $expedition->error; + } + } +} + +if ($_POST['action'] == 'setdate_livraison' && $user->rights->expedition->creer) +{ + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datelivraison=dol_mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); + + $shipping = new Expedition($db); + $shipping->fetch($_GET['id']); + $result=$shipping->set_date_livraison($user,$datelivraison); + if ($result < 0) + { + $mesg='
'.$shipping->error.'
'; + } +} + /* * Build doc */ @@ -275,7 +302,7 @@ if ($_GET["action"] == 'create') /* * Document source */ - print '
'; + print ''; print ''; print ''; print ''; @@ -318,7 +345,10 @@ if ($_GET["action"] == 'create') // Date delivery planned print ''.$langs->trans("DateDeliveryPlanned").''; - print ''.dol_print_date($object->date_livraison,'day')."\n"; + print ''; + print dol_print_date($object->date_livraison,"day"); + //$html->select_date($object->date_livraison,'date_delivery'); + print "\n"; print ''; // Delivery address @@ -351,31 +381,31 @@ if ($_GET["action"] == 'create') print ''; print $langs->trans("Weight"); - print ''; - print $formproduct->select_measuring_units("weight_units","weight"); + print ''; + print $formproduct->select_measuring_units("weight_units","weight",$_POST["weight_units"]); print ''; print $langs->trans("Width"); - print ' '; - print ' '; - print $langs->trans("Height"); - print ''; + print ' '; print $formproduct->select_measuring_units("size_units","size"); print ''; + print $langs->trans("Height"); + print ''; + print ''; print $langs->trans("Depth"); - print ''; - print ' '; + print ''; + print ''; // Delivery method print "".$langs->trans("DeliveryMethod").""; print ''; $expe->fetch_delivery_methods(); - $html->select_array("expedition_method_id",$expe->meths,'',1,0,0,0,"",1); + $html->select_array("expedition_method_id",$expe->meths,$_POST["expedition_method_id"],1,0,0,0,"",1); print "\n"; // Tracking number print "".$langs->trans("TrackingNumber").""; print ''; - print ''; + print ''; print "\n"; print ""; @@ -709,13 +739,33 @@ else print ''; // Date - print ''.$langs->trans("Date").''; - print ''.dol_print_date($expedition->date,"daytext")."\n"; + print ''.$langs->trans("DateCreation").''; + print ''.dol_print_date($expedition->date_creation,"daytext")."\n"; print ''; - // Date delivery planned - print ''.$langs->trans("DateDeliveryPlanned").''; - print ''.dol_print_date($expedition->date_delivery,'daytext')."\n"; + // Delivery date planed + print ''; + print ''; + + if ($_GET['action'] != 'editdate_livraison' && $expedition->brouillon) print ''; + print '
'; + print $langs->trans('DateDeliveryPlanned'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; + print ''; + if ($_GET['action'] == 'editdate_livraison') + { + print ''; + print ''; + print ''; + $html->select_date($expedition->date_delivery?$expedition->date_delivery:-1,'liv_','','','',"setdate_livraison"); + print ''; + print '
'; + } + else + { + print $expedition->date_delivery ? dol_print_date($expedition->date_delivery,'daytext') : ' '; + } + print ''; print ''; // Delivery address @@ -882,9 +932,14 @@ else // Entrepot source if ($conf->stock->enabled) { - $entrepot = new Entrepot($db); - $entrepot->fetch($lignes[$i]->entrepot_id); - print ''.$entrepot->getNomUrl(1).''; + print ''; + if ($lignes[$i]->entrepot_id > 0) + { + $entrepot = new Entrepot($db); + $entrepot->fetch($lignes[$i]->entrepot_id); + print $entrepot->getNomUrl(1); + } + print ''; } @@ -907,6 +962,11 @@ else { print '
'; + if ($expedition->statut > 0 && $user->rights->expedition->valider) + { + print ''.$langs->trans("Modify").''; + } + if ($expedition->statut == 0 && $num_prod > 0) { if ($user->rights->expedition->valider) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index d5ae1747752..518ed55c149 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -247,13 +247,13 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // Date de livraison + // Delivery date planed print ''; print ''; - if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; + if ($_GET['action'] != 'editdate_livraison') print ''; print '
'; - print $langs->trans('DeliveryDate'); + print $langs->trans('DateDeliveryPlanned'); print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; print ''; if ($_GET['action'] == 'editdate_livraison') @@ -261,7 +261,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; print ''; - $html->select_date($commande->date_livraison,'liv_','','','',"setdatedelivery"); + $html->select_date($commande->date_livraison>0?$commande->date_livraison:-1,'liv_','','','',"setdatedelivery"); print ''; print '
'; } diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 1c2c104c6eb..bc0787439a2 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -46,6 +46,8 @@ Enlevement=Gotten by customer DocumentModelSimple=Simple document model WarningNoQtyLeftToSend=Warning, no products waiting to be shipped. StatsOnShipmentsOnlyValidated=Statistics conducted on shipments only validated +DateDeliveryPlanned=Planed date of delivery +DateReceived=Date delivery received # Sending methods SendingMethodCATCH=Catch by customer diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index de8ff729f57..224fafea46f 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -46,6 +46,8 @@ Enlevement=Enlèvement sur place par le client DocumentModelSimple=Modèle simple WarningNoQtyLeftToSend=Alerte, aucun produit en attente de livraison. StatsOnShipmentsOnlyValidated=Statistiques effectuées sur les expéditions validées uniquement +DateDeliveryPlanned=Date livraison prévue +DateReceived=Date réception réelle # Sending methods SendingMethodCATCH=Enlèvement par le client diff --git a/htdocs/lib/sendings.lib.php b/htdocs/lib/sendings.lib.php index ada8c789ca1..d8e111dd8aa 100644 --- a/htdocs/lib/sendings.lib.php +++ b/htdocs/lib/sendings.lib.php @@ -221,13 +221,19 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='') print ''.$objp->qty_shipped.''; + // Date shipping was planed print ''.dol_print_date($db->jdate($objp->date_expedition),'day').''; + + if ($conf->livraison_bon->enabled) { if ($objp->livraison_id) { + // Ref print ''.img_object($langs->trans("ShowSending"),'sending').' '.$objp->livraison_ref.''; + // Qty received print ''.$objp->qty_received.''; + // Date shipping real print ''.dol_print_date($objp->date_delivery,'day').''; } else diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index 97a19259cac..ffa036457f5 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2005-2010 Regis Houssin @@ -470,12 +470,12 @@ else print ''; // Date - print ''.$langs->trans("Date").''; + print ''.$langs->trans("DateCreation").''; print ''.dol_print_date($delivery->date_creation,'daytext')."\n"; print ''; - // Date delivery planned - print ''.$langs->trans("DateDeliveryPlanned").''; + // Date delivery real / Received + print ''.$langs->trans("DateReceived").''; print ''.dol_print_date($delivery->date_delivery,'daytext')."\n"; print ''; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 2a3a6db5759..e6258ec2163 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -117,31 +117,33 @@ class FormProduct } print ''; } - + /** - * \brief Selection des unites de mesure - * \param name Nom champ html - * \param measuring_style Le style de mesure : weight, volume,... - * \param default Forcage de l'unite + * \brief Output a combo box with list of units + * \param name Name of HTML field + * \param measuring_style Unit to show: weight, size, surface, volume + * \param default Force unit + * \param adddefault Add empty unit called "Default" * \remarks pour l'instant on ne definit pas les unites dans la base */ function select_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0) { print $this->load_measuring_units($name, $measuring_style, $default, $adddefault); } - + /** - * \brief Selection des unites de mesure - * \param name Nom champ html - * \param measuring_style Le style de mesure : weight, volume,... - * \param default Forcage de l'unite + * \brief Return a combo box with list of units + * \param name Name of HTML field + * \param measuring_style Unit to show: weight, size, surface, volume + * \param default Force unit + * \param adddefault Add empty unit called "Default" * \remarks pour l'instant on ne definit pas les unites dans la base */ function load_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0) { global $langs,$conf,$mysoc; $langs->load("other"); - + $return=''; if ($measuring_style == 'weight') @@ -186,7 +188,7 @@ class FormProduct $return.= '>'.$value.''; } $return.= ''; - + return $return; }