diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 118e451ba30..4ee82891e2c 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -546,7 +546,14 @@ class Commande extends CommonObject $this->lines[$i]->fk_product, $this->lines[$i]->remise_percent, $this->lines[$i]->fk_remise_except, - $this->lines[$i]->info_bits + $this->lines[$i]->info_bits, + 0, + 'HT', + 0, + // Added by Matelli (http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Add start and end dates to the new line + $this->lines[$i]->date_start, + $this->lines[$i]->date_end ); if ($resql < 0) @@ -627,6 +634,8 @@ class Commande extends CommonObject * \param fk_remise_exscept Id remise * \param price_base_type HT or TTC * \param pu_ttc Prix unitaire TTC + * \param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + * \param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * \return int >0 si ok, <0 si ko * \see add_product * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel @@ -634,9 +643,9 @@ class Commande extends CommonObject * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0) + function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='') { - dolibarr_syslog("Commande::addline commandeid=$commandeid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc"); + dolibarr_syslog("Commande::addline commandeid=$commandeid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end", LOG_DEBUG); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); // Clean parameters @@ -700,6 +709,11 @@ class Commande extends CommonObject // \TODO Ne plus utiliser $ligne->price=$price; $ligne->remise=$remise; + + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Save the start and end date of the new line in the object + $ligne->date_start=$date_start; + $ligne->date_end=$date_end; $result=$ligne->insert(); if ($result > 0) @@ -734,13 +748,15 @@ class Commande extends CommonObject * \brief Ajoute une ligne dans tableau lines * \param idproduct Id du produit a ajouter * \param qty Quantite + * \param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + * \param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * \remise_percent remise_percent Remise relative effectuee sur le produit * \return void * \remarks $this->client doit etre charge * \TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ - function add_product($idproduct, $qty, $remise_percent=0) + function add_product($idproduct, $qty, $remise_percent=0, $date_start='', $date_end='') { global $conf, $mysoc; @@ -768,6 +784,11 @@ class Commande extends CommonObject $line->ref=$prod->ref; $line->libelle=$prod->libelle; $line->product_desc=$prod->description; + + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Save the start and end date of the line in the object + if ($date_start) { $line->date_start = $date_start; } + if ($date_end) { $line->date_end = $date_end; } $this->lines[] = $line; @@ -987,6 +1008,9 @@ class Commande extends CommonObject $sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.rang, l.info_bits,'; $sql.= ' l.total_ht, l.total_ttc, l.total_tva,'; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label'; + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Load from the database the start and end date + $sql.= ','.$this->db->pdate('l.date_start').' as date_start,'.$this->db->pdate('l.date_end').' as date_end'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)'; $sql.= ' WHERE l.fk_commande = '.$this->id; @@ -1029,6 +1053,11 @@ class Commande extends CommonObject $ligne->libelle = $objp->label; $ligne->product_desc = $objp->product_desc; // Description produit $ligne->fk_product_type = $objp->fk_product_type; // Produit ou service + + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Save the start and end date of the line in the object + $ligne->date_start = $objp->date_start; + $ligne->date_end = $objp->date_end; $this->lignes[$i] = $ligne; $i++; @@ -1581,11 +1610,13 @@ class Commande extends CommonObject * \param tva_tx Taux TVA * \param price_base_type HT or TTC * \param info_bits Miscellanous informations on line + * \param date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + * \param date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * \return int < 0 si erreur, > 0 si ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT', $info_bits=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='') { - dolibarr_syslog("Commande::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits"); + dolibarr_syslog("Commande::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $date_start, $date_end"); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); if ($this->brouillon) @@ -1641,6 +1672,14 @@ class Commande extends CommonObject $sql.= ",total_ht='".price2num($total_ht)."'"; $sql.= ",total_tva='".price2num($total_tva)."'"; $sql.= ",total_ttc='".price2num($total_ttc)."'"; + + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Save the start and end date in the database + if ($date_start) { $sql.= ",date_start='".$date_start."'"; } + else { $sql.=',date_start=null'; } + if ($date_end) { $sql.= ",date_end='".$date_end."'"; } + else { $sql.=',date_end=null'; } + $sql.= " WHERE rowid = ".$rowid; $result = $this->db->query($sql); @@ -2127,6 +2166,11 @@ class CommandeLigne var $ref; // Reference produit var $product_libelle; // Label produit var $product_desc; // Description produit + + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Start and end date of the line + var $date_start; + var $date_end; /** @@ -2148,6 +2192,9 @@ class CommandeLigne $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc, cd.marge_tx, cd.marque_tx, cd.rang,'; $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Load start and end dates from the database + $sql.= ','.$this->db->pdate('cd.date_start').' as date_start,'.$this->db->pdate('cd.date_end').' as date_end'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; $sql.= ' WHERE cd.rowid = '.$rowid; @@ -2177,6 +2224,11 @@ class CommandeLigne $this->ref = $objp->product_ref; $this->product_libelle = $objp->product_libelle; $this->product_desc = $objp->product_desc; + + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Save the start and end dates of the line in the object + $this->date_start = $objp->date_start; + $this->date_end = $objp->date_end; $this->db->free($result); } @@ -2255,7 +2307,9 @@ class CommandeLigne $sql.= ' (fk_commande, description, qty, tva_tx,'; $sql.= ' fk_product, remise_percent, subprice, price, remise, fk_remise_except,'; $sql.= ' rang, marge_tx, marque_tx,'; - $sql.= ' info_bits, total_ht, total_tva, total_ttc)'; + // Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Insert in the database the start and end dates + $sql.= ' info_bits, total_ht, total_tva, total_ttc, date_start, date_end)'; $sql.= " VALUES (".$this->fk_commande.","; $sql.= " '".addslashes($this->desc)."',"; $sql.= " '".price2num($this->qty)."',"; @@ -2276,7 +2330,13 @@ class CommandeLigne $sql.= " '".$this->info_bits."',"; $sql.= " '".price2num($this->total_ht)."',"; $sql.= " '".price2num($this->total_tva)."',"; - $sql.= " '".price2num($this->total_ttc)."'"; + // Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Insert in the database the start and end dates + $sql.= " '".price2num($this->total_ttc)."',"; + if ($this->date_start) { $sql.= "'".$this->date_start."',"; } + else { $sql.='null,'; } + if ($this->date_end) { $sql.= "'".$this->date_end."'"; } + else { $sql.='null'; } $sql.= ')'; if ($this->fk_product) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 18a892bd53d..0ae84ac997a 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -48,20 +48,13 @@ $langs->load('products'); if (!$user->rights->commande->lire) accessforbidden(); -// Securite acces client +// Security check $socid=0; -if ($user->societe_id > 0) -{ - $socid = $user->societe_id; -} -if ($user->societe_id >0 && isset($_GET["id"]) && $_GET["id"]>0) -{ - $commande = new Commande($db); - $commande->fetch((int)$_GET['id']); - if ($user->societe_id != $commande->socid) { - accessforbidden(); - } -} +$contratid = isset($_GET["id"])?$_GET["id"]:''; +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,'commande',$contratid,'commande'); + +$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; // Recuperation de l'id de projet $projetid = 0; @@ -303,6 +296,26 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) exit; } $ret=$commande->fetch_client(); + + $suffixe = $_POST['idprod'] ? '_prod' : ''; + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Retrieve start and end date (for product/service lines or customizable lines) + $date_start=''; + $date_end=''; + if ($_POST['date_start'.$suffixe.'year'] && $_POST['date_start'.$suffixe.'month'] && $_POST['date_start'.$suffixe.'day']) + { + $date_start=$_POST['date_start'.$suffixe.'year'].'-'.$_POST['date_start'.$suffixe.'month'].'-'.$_POST['date_start'.$suffixe.'day']; + // If hour/minute are specified, append them + if (($_POST['date_start'.$suffixe.'hour']) && ($_POST['date_start'.$suffixe.'min'])) + $date_start.=' '.$_POST['date_start'.$suffixe.'hour'].':'.$_POST['date_start'.$suffixe.'min']; + } + if ($_POST['date_end'.$suffixe.'year'] && $_POST['date_end'.$suffixe.'month'] && $_POST['date_end'.$suffixe.'day']) + { + $date_end=$_POST['date_end'.$suffixe.'year'].'-'.$_POST['date_end'.$suffixe.'month'].'-'.$_POST['date_end'.$suffixe.'day']; + // If hour/minute are specified, append them + if (($_POST['date_end'.$suffixe.'hour']) && ($_POST['date_end'.$suffixe.'min'])) + $date_end.=' '.$_POST['date_end'.$suffixe.'hour'].':'.$_POST['date_end'.$suffixe.'min']; + } $price_base_type = 'HT'; @@ -376,9 +389,13 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) $_POST['idprod'], $_POST['remise_percent'], $info_bits, - '', + 0, $price_base_type, - $pu_ttc + $pu_ttc, + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Add the start and end dates + $date_start, + $date_end ); if ($result > 0) @@ -405,6 +422,26 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS { $commande = new Commande($db,'',$_POST['id']); if (! $commande->fetch($_POST['id']) > 0) dolibarr_print_error($db); + + + $date_start=''; + $date_end=''; + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Retrieve start and end date (for product/service lines or customizable lines) + if ($_POST['date_startyear'] && $_POST['date_startmonth'] && $_POST['date_startday']) + { + $date_start=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday']; + // If hour/minute are specified, append them + if (($_POST['date_starthour']) && ($_POST['date_startmin'])) + $date_start.=' '.$_POST['date_starthour'].':'.$_POST['date_startmin']; + } + if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday']) + { + $date_end=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday']; + // If hour/minute are specified, append them + if (($_POST['date_endhour']) && ($_POST['date_endmin'])) + $date_end.=' '.$_POST['date_endhour'].':'.$_POST['date_endmin']; + } // Define info_bits $info_bits=0; @@ -426,8 +463,12 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS $_POST['qty'], $_POST['elremise_percent'], $vat_rate, - 'HT', - $info_bits + 'HT', + $info_bits, + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Add the start and end dates + $date_start, + $date_end ); if ($result >= 0) @@ -1393,6 +1434,10 @@ else $sql.= ' l.total_ht, l.total_tva, l.total_ttc,'; $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid, '; $sql.= ' p.description as product_desc'; + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Load start and end dates + $sql.= ','.$db->pdate('l.date_start').' as date_start,'; + $sql.= ' '.$db->pdate('l.date_end').' as date_end'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; $sql.= ' WHERE l.fk_commande = '.$commande->id; @@ -1440,8 +1485,9 @@ else $text.= ' - '.$objp->product; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)); print $html->textwithtooltip($text,$description,3,'','',$i); - // Todo: voir si on insert ou pas en option les dates de debut et de fin de service - //print_date_range($objp->date_start,$objp->date_end); + // Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Print the start and end dates + print_date_range($objp->date_start,$objp->date_end); if ($conf->global->PRODUIT_DESC_IN_FORM) { print ($objp->description && $objp->description!=$objp->product)?'
'.dol_htmlentitiesbr($objp->description):''; @@ -1476,6 +1522,9 @@ else else { print nl2br($objp->description); + // Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Print the start and end dates + print_date_range($objp->date_start,$objp->date_end,'dayhour'); } print ''; } @@ -1614,6 +1663,17 @@ else print ''; print '
'; print ''; + + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Start and end dates selector + print ''; + print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + print $html->select_date($objp->date_start,'date_start',$usehm,$usehm,$objp->date_start?0:1,"updateligne"); + print ' '.$langs->trans('to').' '; + print $html->select_date($objp->date_end,'date_end',$usehm,$usehm,$objp->date_end?0:1,"updateligne"); + print ''; + print ''; + print ''; } @@ -1676,7 +1736,19 @@ else print '%'; print ''; print ''; - + + if ($conf->service->enabled) + { + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Start and end dates selector + print ''; + print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + print $html->select_date('','date_start',$usehm,$usehm,1,"addligne"); + print ' '.$langs->trans('to').' '; + print $html->select_date('','date_end',$usehm,$usehm,1,"addligne"); + print ''; + print ''; + } print ''; // Ajout de produits/services predefinis @@ -1734,7 +1806,19 @@ else print '%'; print ''; print ''; - + + if ($conf->service->enabled) + { + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Start and end dates selector + print ''; + print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + print $html->select_date('','date_start_prod',$usehm,$usehm,1,"addligne"); + print ' '.$langs->trans('to').' '; + print $html->select_date('','date_end_prod',$usehm,$usehm,1,"addligne"); + print ''; + print ''; + } print ''; } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 42ecf7f7342..582ecd89a08 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -55,6 +55,7 @@ $socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid']; $projetid=isset($_GET['projetid'])?$_GET['projetid']:0; // Security check +$socid=0; $facid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'facture', $facid,''); @@ -62,6 +63,8 @@ $result = restrictedArea($user, 'facture', $facid,''); // Nombre de ligne pour choix de produit/service prédéfinis $NBLINES=4; +$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; + /******************************************************************************/ /* Actions */ @@ -793,31 +796,22 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && } $ret=$fac->fetch_client(); + $suffixe = $_POST['idprod'] ? '_predef' : ''; $date_start=''; $date_end=''; - // Si ajout champ produit libre - if ($_POST['action'] == 'addligne') + if ($_POST['date_start'.$suffixe.'year'] && $_POST['date_start'.$suffixe.'month'] && $_POST['date_start'.$suffixe.'day']) { - if ($_POST['date_startyear'] && $_POST['date_startmonth'] && $_POST['date_startday']) - { - $date_start=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday']; - } - if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday']) - { - $date_end=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday']; - } + $date_start=$_POST['date_start'.$suffixe.'year'].'-'.$_POST['date_start'.$suffixe.'month'].'-'.$_POST['date_start'.$suffixe.'day']; + // If hour/minute are specified, append them + if (($_POST['date_start'.$suffixe.'hour']) && ($_POST['date_start'.$suffixe.'min'])) + $date_start.=' '.$_POST['date_start'.$suffixe.'hour'].':'.$_POST['date_start'.$suffixe.'min']; } - // Si ajout champ produit prédéfini - if ($_POST['action'] == 'addligne_predef') + if ($_POST['date_end'.$suffixe.'year'] && $_POST['date_end'.$suffixe.'month'] && $_POST['date_end'.$suffixe.'day']) { - if ($_POST['date_start_predefyear'] && $_POST['date_start_predefmonth'] && $_POST['date_start_predefday']) - { - $date_start=$_POST['date_start_predefyear'].'-'.$_POST['date_start_predefmonth'].'-'.$_POST['date_start_predefday']; - } - if ($_POST['date_end_predefyear'] && $_POST['date_end_predefmonth'] && $_POST['date_end_predefday']) - { - $date_end=$_POST['date_end_predefyear'].'-'.$_POST['date_end_predefmonth'].'-'.$_POST['date_end_predefday']; - } + $date_end=$_POST['date_end'.$suffixe.'year'].'-'.$_POST['date_end'.$suffixe.'month'].'-'.$_POST['date_end'.$suffixe.'day']; + // If hour/minute are specified, append them + if (($_POST['date_end'.$suffixe.'hour']) && ($_POST['date_end'.$suffixe.'min'])) + $date_end.=' '.$_POST['date_end'.$suffixe.'hour'].':'.$_POST['date_end'.$suffixe.'min']; } $price_base_type = 'HT'; @@ -929,11 +923,21 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST $date_start=''; $date_end=''; - if ($_POST['date_startyear'] && $_POST['date_startmonth'] && $_POST['date_startday']) { + // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) + // Retrieve start and end date (for product/service lines or customizable lines) + if ($_POST['date_startyear'] && $_POST['date_startmonth'] && $_POST['date_startday']) + { $date_start=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday']; + // If hour/minute are specified, append them + if (($_POST['date_starthour']) && ($_POST['date_startmin'])) + $date_start.=' '.$_POST['date_starthour'].':'.$_POST['date_startmin']; } - if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday']) { + if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday']) + { $date_end=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday']; + // If hour/minute are specified, append them + if (($_POST['date_endhour']) && ($_POST['date_endmin'])) + $date_end.=' '.$_POST['date_endhour'].':'.$_POST['date_endmin']; } // Define info_bits @@ -1623,12 +1627,12 @@ if ($_GET['action'] == 'create') print ''; print $langs->trans('From').' '; print ''; - print $html->select_date('','date_start'.$i,0,0,1,"add"); + print $html->select_date('','date_start'.$i,$usehm,$usehm,1,"add"); print ''; print ''; print $langs->trans('to').' '; print ''; - print $html->select_date('','date_end'.$i,0,0,1,"add"); + print $html->select_date('','date_end'.$i,$usehm,$usehm,1,"add"); print ''; print ''; } @@ -2652,9 +2656,9 @@ else { print ''; print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date($objp->date_start,'date_start',0,0,$objp->date_start?0:1,"updateligne"); + print $html->select_date($objp->date_start,'date_start',$usehm,$usehm,$objp->date_start?0:1,"updateligne"); print ' '.$langs->trans('to').' '; - print $html->select_date($objp->date_end,'date_end',0,0,$objp->date_end?0:1,"updateligne"); + print $html->select_date($objp->date_end,'date_end',$usehm,$usehm,$objp->date_end?0:1,"updateligne"); print ''; print ''; } @@ -2721,9 +2725,9 @@ else { print ''; print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date('','date_start',0,0,1,"addligne"); + print $html->select_date('','date_start',$usehm,$usehm,1,"addligne"); print ' '.$langs->trans('to').' '; - print $html->select_date('','date_end',0,0,1,"addligne"); + print $html->select_date('','date_end',$usehm,$usehm,1,"addligne"); print ''; print ''; } @@ -2788,9 +2792,9 @@ else { print ''; print ''.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $html->select_date('','date_start_predef',0,0,1,"addligne_predef"); + print $html->select_date('','date_start_predef',$usehm,$usehm,1,"addligne_predef"); print ' '.$langs->trans('to').' '; - print $html->select_date('','date_end_predef',0,0,1,"addligne_predef"); + print $html->select_date('','date_end_predef',$usehm,$usehm,1,"addligne_predef"); print ''; print ''; } diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index da17170cc77..abf3072f113 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -37,10 +37,12 @@ $langs->load("bills"); $langs->load("products"); // Security check +$socid=0; +$contratid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'contrat',$contratid,'contrat'); - +$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; /* * Actions @@ -86,11 +88,11 @@ if ($_POST["mode"]=='predefined') $date_end=''; if ($_POST["date_startmonth"] && $_POST["date_startday"] && $_POST["date_startyear"]) { - $date_start=dolibarr_mktime(12, 0 , 0, $_POST["date_startmonth"], $_POST["date_startday"], $_POST["date_startyear"]); + $date_start=dolibarr_mktime($_POST["date_starthour"], $_POST["date_startmin"], 0, $_POST["date_startmonth"], $_POST["date_startday"], $_POST["date_startyear"]); } if ($_POST["date_endmonth"] && $_POST["date_endday"] && $_POST["date_endyear"]) { - $date_end=dolibarr_mktime(12, 0 , 0, $_POST["date_endmonth"], $_POST["date_endday"], $_POST["date_endyear"]); + $date_end=dolibarr_mktime($_POST["date_endhour"], $_POST["date_endmin"], 0, $_POST["date_endmonth"], $_POST["date_endday"], $_POST["date_endyear"]); } } @@ -101,11 +103,11 @@ if ($_POST["mode"]=='libre') $date_end_sl=''; if ($_POST["date_start_slmonth"] && $_POST["date_start_slday"] && $_POST["date_start_slyear"]) { - $date_start_sl=dolibarr_mktime(12, 0 , 0, $_POST["date_start_slmonth"], $_POST["date_start_slday"], $_POST["date_start_slyear"]); + $date_start_sl=dolibarr_mktime($_POST["date_start_slhour"], $_POST["date_start_slmin"], 0, $_POST["date_start_slmonth"], $_POST["date_start_slday"], $_POST["date_start_slyear"]); } if ($_POST["date_end_slmonth"] && $_POST["date_end_slday"] && $_POST["date_end_slyear"]) { - $date_end_sl=dolibarr_mktime(12, 0 , 0, $_POST["date_end_slmonth"], $_POST["date_end_slday"], $_POST["date_end_slyear"]); + $date_end_sl=dolibarr_mktime($_POST["date_end_slhour"], $_POST["date_end_slmin"], 0, $_POST["date_end_slmonth"], $_POST["date_end_slday"], $_POST["date_end_slyear"]); } } @@ -116,24 +118,24 @@ $date_start_real_update=''; $date_end_real_update=''; if ($_POST["date_start_updatemonth"] && $_POST["date_start_updateday"] && $_POST["date_start_updateyear"]) { - $date_start_update=dolibarr_mktime(12, 0 , 0, $_POST["date_start_updatemonth"], $_POST["date_start_updateday"], $_POST["date_start_updateyear"]); + $date_start_update=dolibarr_mktime($_POST["date_start_updatehour"], $_POST["date_start_updatemin"], 0, $_POST["date_start_updatemonth"], $_POST["date_start_updateday"], $_POST["date_start_updateyear"]); } if ($_POST["date_end_updatemonth"] && $_POST["date_end_updateday"] && $_POST["date_end_updateyear"]) { - $date_end_update=dolibarr_mktime(12, 0 , 0, $_POST["date_end_updatemonth"], $_POST["date_end_updateday"], $_POST["date_end_updateyear"]); + $date_end_update=dolibarr_mktime($_POST["date_end_updatehour"], $_POST["date_end_updatemin"], 0, $_POST["date_end_updatemonth"], $_POST["date_end_updateday"], $_POST["date_end_updateyear"]); } if ($_POST["date_start_real_updatemonth"] && $_POST["date_start_real_updateday"] && $_POST["date_start_real_updateyear"]) { - $date_start_real_update=dolibarr_mktime(12, 0 , 0, $_POST["date_start_real_updatemonth"], $_POST["date_start_real_updateday"], $_POST["date_start_real_updateyear"]); + $date_start_real_update=dolibarr_mktime($_POST["date_start_real_updatehour"], $_POST["date_start_real_updatemin"], 0, $_POST["date_start_real_updatemonth"], $_POST["date_start_real_updateday"], $_POST["date_start_real_updateyear"]); } if ($_POST["date_end_real_updatemonth"] && $_POST["date_end_real_updateday"] && $_POST["date_end_real_updateyear"]) { - $date_end_real_update=dolibarr_mktime(12, 0 , 0, $_POST["date_end_real_updatemonth"], $_POST["date_end_real_updateday"], $_POST["date_end_real_updateyear"]); + $date_end_real_update=dolibarr_mktime($_POST["date_end_real_updatehour"], $_POST["date_end_real_updatemin"], 0, $_POST["date_end_real_updatemonth"], $_POST["date_end_real_updateday"], $_POST["date_end_real_updateyear"]); } if ($_POST["action"] == 'add') { - $datecontrat = dolibarr_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datecontrat = dolibarr_mktime($_POST["rehour"], $_POST["remin"], 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $contrat = new Contrat($db); @@ -187,25 +189,25 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer) // Si ajout champ produit libre if ($_POST['mode'] == 'libre') { - if ($_POST['date_start_slyear'] && $_POST['date_start_slmonth'] && $_POST['date_start_slday']) + if ($_POST["date_start_slmonth"] && $_POST["date_start_slday"] && $_POST["date_start_slyear"]) { - $date_start=dolibarr_mktime(12,0,0,$_POST['date_start_slmonth'],$_POST['date_start_slday'],$_POST['date_start_slyear']); + $date_start=dolibarr_mktime($_POST["date_start_slhour"], $_POST["date_start_slmin"], 0, $_POST["date_start_slmonth"], $_POST["date_start_slday"], $_POST["date_start_slyear"]); } - if ($_POST['date_end_slyear'] && $_POST['date_end_slmonth'] && $_POST['date_end_slday']) + if ($_POST["date_end_slmonth"] && $_POST["date_end_slday"] && $_POST["date_end_slyear"]) { - $date_end=dolibarr_mktime(12,0,0,$_POST['date_end_slmonth'],$_POST['date_end_slday'],$_POST['date_end_slyear']); + $date_end=dolibarr_mktime($_POST["date_end_slhour"], $_POST["date_end_slmin"], 0, $_POST["date_end_slmonth"], $_POST["date_end_slday"], $_POST["date_end_slyear"]); } } - // Si ajout champ produit pr�d�fini + // Si ajout champ produit predefini if ($_POST['mode'] == 'predefined') { - if ($_POST['date_startyear'] && $_POST['date_startmonth'] && $_POST['date_startday']) + if ($_POST["date_startmonth"] && $_POST["date_startday"] && $_POST["date_startyear"]) { - $date_start=dolibarr_mktime(12,0,0,$_POST['date_startmonth'],$_POST['date_startday'],$_POST['date_startyear']); + $date_start=dolibarr_mktime($_POST["date_starthour"], $_POST["date_startmin"], 0, $_POST["date_startmonth"], $_POST["date_startday"], $_POST["date_startyear"]); } - if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday']) + if ($_POST["date_endmonth"] && $_POST["date_endday"] && $_POST["date_endyear"]) { - $date_end=dolibarr_mktime(12,0,0,$_POST['date_endmonth'],$_POST['date_endday'],$_POST['date_endyear']); + $date_end=dolibarr_mktime($_POST["date_endhour"], $_POST["date_endmin"], 0, $_POST["date_endmonth"], $_POST["date_endday"], $_POST["date_endyear"]); } } @@ -492,7 +494,7 @@ if ($_GET["action"] == 'create') print ''; print ''.$langs->trans("Date").''; - $form->select_date('','','','','',"contrat"); + $form->select_date('','',0,0,'',"contrat"); print ""; if ($conf->projet->enabled) @@ -911,9 +913,9 @@ else print ""; print ''; print $langs->trans("DateStartPlanned").' '; - $form->select_date($objp->date_debut,"date_start_update",0,0,($objp->date_debut>0?0:1),"update"); - print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date($objp->date_fin,"date_end_update",0,0,($objp->date_fin>0?0:1),"update"); + $form->select_date($objp->date_debut,"date_start_update",$usehm,$usehm,($objp->date_debut>0?0:1),"update"); + print '
'.$langs->trans("DateEndPlanned").' '; + $form->select_date($objp->date_fin,"date_end_update",$usehm,$usehm,($objp->date_fin>0?0:1),"update"); print ''; print ''; @@ -1064,11 +1066,11 @@ else } print ''.$langs->trans("DateServiceActivate").''; - print $html->select_date($dateactstart,'','','','',"active"); + print $html->select_date($dateactstart,'',$usehm,$usehm,'',"active"); print ''; print ''.$langs->trans("DateEndPlanned").''; - print $html->select_date($dateactend,"end",'','','',"active"); + print $html->select_date($dateactend,"end",$usehm,$usehm,'',"active"); print ''; print ''; @@ -1119,7 +1121,7 @@ else if ($objp->statut == 4) { print $langs->trans("DateEndReal").' '; - $form->select_date($dateactend,"end",0,0,($objp->date_fin_reelle>0?0:1),"closeline"); + $form->select_date($dateactend,"end",$usehm,$usehm,($objp->date_fin_reelle>0?0:1),"closeline"); } } print ''; @@ -1188,9 +1190,9 @@ else print ""; print ''; print $langs->trans("DateStartPlanned").' '; - $form->select_date('',"date_start",0,0,1,"addligne"); + $form->select_date('',"date_start",$usehm,$usehm,1,"addligne"); print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end",0,0,1,"addligne"); + $form->select_date('',"date_end",$usehm,$usehm,1,"addligne"); print ''; print ''; @@ -1220,9 +1222,9 @@ else print ""; print ''; print $langs->trans("DateStartPlanned").' '; - $form->select_date('',"date_start_sl",0,0,1,"addligne_sl"); + $form->select_date('',"date_start_sl",$usehm,$usehm,1,"addligne_sl"); print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end_sl",0,0,1,"addligne_sl"); + $form->select_date('',"date_end_sl",$usehm,$usehm,1,"addligne_sl"); print ''; print ''; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 1ff83e98972..50acef6bebe 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -2627,19 +2627,19 @@ class Form /** - * \brief Affiche zone de selection de date - * Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes - * Les champs sont pré-sélectionnés avec: + * Affiche zone de selection de date + * Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes + * Les champs sont pré-sélectionnés avec: * - La date set_time (timestamps ou date au format YYYY-MM-DD ou YYYY-MM-DD HH:MM) * - La date du jour si set_time vaut '' * - Aucune date (champs vides) si set_time vaut -1 (dans ce cas empty doit valoir 1) - * \param set_time Date de pré-sélection - * \param prefix Prefix pour nom champ - * \param h 1=Affiche aussi les heures - * \param m 1=Affiche aussi les minutes - * \param empty 0=Champ obligatoire, 1=Permet une saisie vide - * \param form_name Nom du formulaire de provenance. Utilisé pour les dates en popup style andre. - * \param d 1=Affiche aussi les jours, mois, annees + * @param set_time Date de pré-sélection + * @param prefix Prefix pour nom champ + * @param h 1=Affiche aussi les heures + * @param m 1=Affiche aussi les minutes + * @param empty 0=Champ obligatoire, 1=Permet une saisie vide + * @param form_name Nom du formulaire de provenance. Utilisé pour les dates en popup style andre. + * @param d 1=Affiche aussi les jours, mois, annees */ function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1) { diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index b144918b7d5..9a1b908801f 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -542,32 +542,37 @@ function dolibarr_getdate($timestamp,$fast=false) } /** - \brief Retourne une date fabriquee depuis infos. - Remplace la fonction mktime non implementee sous Windows si annee < 1970 - \param hour Hour - \param minute Minute - \param second Second - \param month Month - \param day Day - \param year Year - \param gm Time gm - \param check No check on parameters (Can use day 32, etc...) - \return timestamp Date en timestamp, '' if error - \remarks PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows + * Retourne une date fabriquee depuis infos. + * Remplace la fonction mktime non implementee sous Windows si annee < 1970 + * @param hour Hour (can be -1 for undefined) + * @param minute Minute (can be -1 for undefined) + * @param second Second (can be -1 for undefined) + * @param month Month + * @param day Day + * @param year Year + * @param gm Time gm + * @param check No check on parameters (Can use day 32, etc...) + * @return timestamp Date en timestamp, '' if error + * @remarks PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows */ function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=0,$check=1) { //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; + // Clean parameters + if ($hour == -1) $hour=0; + if ($minute == -1) $minute=0; + if ($second == -1) $second=0; + // Check parameters if ($check) { if (! $month || ! $day) return ''; if ($day > 31) return ''; if ($month > 12) return ''; - if ($min < 0 || $min > 60) return ''; - if ($hour < 0 || $hour > 24) return ''; - if ($min < 0 || $min > 60) return ''; + if ($hour < 0 || $hour > 24) return ''; + if ($minute< 0 || $minute > 60) return ''; + if ($second< 0 || $second > 60) return ''; } $usealternatemethod=false; @@ -1431,7 +1436,7 @@ function restrictedArea($user, $feature='societe', $objectid=0, $dbtablename='', } else { - if (!$dbtablename) $dbtablename = $feature; // Si dbtable non d�fini, meme nom que le module + if (!$dbtablename) $dbtablename = $feature; // Si dbtable non defini, meme nom que le module $sql = "SELECT sc.fk_soc"; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; diff --git a/mysql/migration/2.4.0-2.5.0.sql b/mysql/migration/2.4.0-2.5.0.sql index 34691577ec5..287282a5d62 100644 --- a/mysql/migration/2.4.0-2.5.0.sql +++ b/mysql/migration/2.4.0-2.5.0.sql @@ -16,7 +16,7 @@ alter table llx_societe add column gencod varchar(255); delete from llx_user_param where page <> ''; -alter table llx_expedition add tracking_number varchar(50) after fk_expedition_methode; +alter table llx_expedition add column tracking_number varchar(50) after fk_expedition_methode; alter table llx_actioncomm add column location varchar(128) after percent; @@ -32,5 +32,6 @@ alter table llx_projet_task_actors modify column role varchar(5) DEFAU alter table llx_projet_task modify column statut varchar(6) DEFAULT 'open'; alter table llx_rights_def modify column type varchar(1); +ALTER TABLE `llx_commandedet` ADD column `date_start` DATETIME DEFAULT NULL, ADD `date_end` DATETIME DEFAULT NULL ; diff --git a/mysql/tables/llx_commandedet.sql b/mysql/tables/llx_commandedet.sql index dae1ff6e51a..5ab2caa902b 100644 --- a/mysql/tables/llx_commandedet.sql +++ b/mysql/tables/llx_commandedet.sql @@ -25,7 +25,7 @@ create table llx_commandedet fk_commande integer, fk_product integer, description text, - tva_tx double(6,3), -- taux tva + tva_tx double(6,3), -- taux tva qty real, -- quantité remise_percent real DEFAULT 0, -- pourcentage de remise remise real DEFAULT 0, -- montant de la remise @@ -35,7 +35,9 @@ create table llx_commandedet total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantité et incluant remise ligne et globale total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale - info_bits integer DEFAULT 0, -- TVA NPR ou non + date_start datetime DEFAULT NULL, -- date debut si service + date_end datetime DEFAULT NULL, -- date fin si service + info_bits integer DEFAULT 0, -- TVA NPR ou non marge_tx double(6,3) DEFAULT 0, -- taux de marge (marge sur prix d'achat) marque_tx double(6,3) DEFAULT 0, -- taux de marque (marge sur prix de vente) special_code tinyint(4) UNSIGNED DEFAULT 0, -- code pour les lignes speciales diff --git a/mysql/tables/llx_facturedet.sql b/mysql/tables/llx_facturedet.sql index 44dbaacfd8c..83d84cea930 100644 --- a/mysql/tables/llx_facturedet.sql +++ b/mysql/tables/llx_facturedet.sql @@ -36,10 +36,10 @@ create table llx_facturedet total_ht real, -- Total HT de la ligne toute quantité et incluant remise ligne et globale total_tva real, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale total_ttc real, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale - product_type integer DEFAULT 0, - date_start datetime, -- date debut si service - date_end datetime, -- date fin si service - info_bits integer DEFAULT 0, -- TVA NPR ou non + product_type integer DEFAULT 0, + date_start datetime DEFAULT NULL, -- date debut si service + date_end datetime DEFAULT NULL, -- date fin si service + info_bits integer DEFAULT 0, -- TVA NPR ou non fk_code_ventilation integer DEFAULT 0 NOT NULL, fk_export_compta integer DEFAULT 0 NOT NULL, special_code tinyint(4) UNSIGNED DEFAULT 0, -- code pour les lignes speciales