From 57b546650a81f004c1f48da93cdce8b332b27147 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Jun 2014 19:03:52 +0200 Subject: [PATCH 01/21] Fix: Hide title of event when agenda module disabled. --- ChangeLog | 1 + htdocs/contact/fiche.php | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72cc7bbcede..cfe4950e2f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- ***** ChangeLog for 3.5.4 compared to 3.5.3 ***** +Fix: Hide title of event when agenda module disabled. Fix: When using option MAIN_MAIL_ALLOW_SENDMAIL_F, a mail was sent to sender. Fix: Question about warehouse must not be done when module stock is disabled. Fix: Option STOCK_SUPPORTS_SERVICES was not correctly implemented diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 0becec81abb..3519583d96c 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -749,7 +749,7 @@ else $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); print ''; - + // Note Private print ''.$langs->trans("NotePrivate").''; $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); @@ -971,7 +971,7 @@ else print ''.$langs->trans("NotePublic").''; print nl2br($object->note_public); print ''; - + // Note Private print ''.$langs->trans("NotePrivate").''; print nl2br($object->note_private); @@ -1068,11 +1068,14 @@ else print "
"; } - print load_fiche_titre($langs->trans("TasksHistoryForThisContact"),'',''); + if (! empty($conf->agenda->enabled)) + { + print load_fiche_titre($langs->trans("TasksHistoryForThisContact"),'',''); - print show_actions_todo($conf,$langs,$db,$objsoc,$object); + print show_actions_todo($conf,$langs,$db,$objsoc,$object); - print show_actions_done($conf,$langs,$db,$objsoc,$object); + print show_actions_done($conf,$langs,$db,$objsoc,$object); + } } } From b70a090de2fcb031c17f5e155e2ff9c1d217156c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 2 Jul 2014 19:10:17 +0200 Subject: [PATCH 02/21] Corrected English typo --- htdocs/langs/en_US/users.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 2c797b7ac97..c4742cc87e3 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -86,7 +86,7 @@ MyInformations=My data ExportDataset_user_1=Dolibarr's users and properties DomainUser=Domain user %s Reactivate=Reactivate -CreateInternalUserDesc=This form allows you to creat an user internal to your company/foundation. To creat an external user (customer, supplier, ...), use button 'Create Dolibarr user' from third party's contact card. +CreateInternalUserDesc=This form allows you to create an user internal to your company/foundation. To create an external user (customer, supplier, ...), use the button 'Create Dolibarr user' from third party's contact card. InternalExternalDesc=An internal user is a user that is part of your company/foundation.
An external user is a customer, supplier or other.

In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display) PermissionInheritedFromAGroup=Permission granted because inherited from one of a user's group. Inherited=Inherited From c2f0d84e454a0deca35c8653081d2ddd77885e7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jul 2014 19:35:02 +0200 Subject: [PATCH 03/21] =?UTF-8?q?Fix:=20[=20bug=20#1512=20]=20Manque=20des?= =?UTF-8?q?=20produits=20dans=20la=20page=20r=C3=A9approvisionement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/langs/en_US/stocks.lang | 4 +- htdocs/product/stock/replenish.php | 182 ++++++++--------------------- 2 files changed, 52 insertions(+), 134 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 08992207628..7a08148c9ce 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -62,8 +62,8 @@ OrderStatusNotReadyToDispatch=Order has not yet or no more a status that allows StockDiffPhysicTeoric=Reason for difference stock physical and theoretical NoPredefinedProductToDispatch=No predefined products for this object. So no dispatching in stock is required. DispatchVerb=Dispatch -StockLimitShort=Limit -StockLimit=Stock limit for alerts +StockLimitShort=Limit for alert +StockLimit=Stock limit for alert PhysicalStock=Physical stock RealStock=Real Stock VirtualStock=Virtual stock diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index fc3591efc71..6aee0bada53 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -64,7 +64,7 @@ if (!$sortorder) { $limit = $conf->liste_limit; $offset = $limit * $page ; -// Force limit to non (currently solution to solve loosing selection when using pagination. No pagination on this page) +// Force limit to no (currently solution to solve loosing selection when using pagination. No pagination on this page) $limit = 0; @@ -190,9 +190,10 @@ if ($action == 'order' && isset($_POST['valid'])) $form = new Form($db); $virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) - || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) - ) $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. +if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) +{ + $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. +} $usevirtualstock=-1; if ($virtualdiffersfromphysical) @@ -206,8 +207,8 @@ $title = $langs->trans('Status'); $sql = 'SELECT p.rowid, p.ref, p.label, p.price,'; $sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; -$sql.= ' p.tms as datem, p.duration, p.tobuy, p.seuil_stock_alerte,'; -$sql.= ' p.desiredstock,'; +$sql.= ' p.tms as datem, p.duration, p.tobuy,'; +$sql.= ' p.desiredstock, p.seuil_stock_alerte as alertstock,'; $sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; $sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s'; @@ -245,10 +246,12 @@ $sql.= ' AND p.tobuy = 1'; if (!empty($canvas)) $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"'; $sql.= ' GROUP BY p.rowid, p.ref, p.label, p.price'; $sql.= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; -$sql.= ', p.duration, p.tobuy, p.seuil_stock_alerte'; -$sql.= ', p.desiredstock, s.fk_product'; +$sql.= ', p.duration, p.tobuy'; +$sql.= ', p.desiredstock, p.seuil_stock_alerte'; +$sql.= ', s.fk_product'; -if($usevirtualstock) { +if ($usevirtualstock) +{ $sqlCommandesCli = "(SELECT SUM(cd.qty) as qty"; $sqlCommandesCli.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sqlCommandesCli.= ", ".MAIN_DB_PREFIX."commande as c"; @@ -265,11 +268,14 @@ if($usevirtualstock) { $sqlCommandesFourn.= " AND cd.fk_product = p.rowid"; $sqlCommandesFourn.= " AND c.fk_statut in (3))"; - $sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - '.$db->ifsql($sqlCommandesCli.' IS NULL', '0', $sqlCommandesCli).' + '.$db->ifsql($sqlCommandesFourn.' IS NULL', '0', $sqlCommandesFourn); + $sql.= ' HAVING ((p.desiredstock > 0 AND p.desiredstock > (SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' - '.$db->ifsql($sqlCommandesCli.' IS NULL', '0', $sqlCommandesCli).' + '.$db->ifsql($sqlCommandesFourn.' IS NULL', '0', $sqlCommandesFourn).'))'; + + $sql.= ' OR (p.seuil_stock_alerte > 0 AND p.seuil_stock_alerte > (SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' - '.$db->ifsql($sqlCommandesCli.' IS NULL', '0', $sqlCommandesCli).' + '.$db->ifsql($sqlCommandesFourn.' IS NULL', '0', $sqlCommandesFourn).'))'; + $sql.= " )"; } else { - $sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' AND p.desiredstock > 0'; + $sql.= ' HAVING ((p.desiredstock > 0 AND (p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))) OR (p.seuil_stock_alerte > 0 AND (seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; } if ($salert == 'on') // Option to see when stock is lower than alert { @@ -277,8 +283,9 @@ if ($salert == 'on') // Option to see when stock is lower than alert $alertchecked = 'checked="checked"'; } $sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit + 1, $offset); +$sql.= $db->plimit($limit, $offset); +//print $sql; dol_syslog('Execute request sql='.$sql); $resql = $db->query($sql); if (empty($resql)) @@ -286,6 +293,7 @@ if (empty($resql)) dol_print_error($db); exit; } +//print $sql; $num = $db->num_rows($resql); $i = 0; @@ -339,7 +347,7 @@ if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) { $filters = '&sref=' . $sref . '&snom=' . $snom; $filters .= '&fourn_id=' . $fourn_id; $filters .= (isset($type)?'&type=' . $type:''); - $filters .= '&salert=' . $salert; + $filters .= '&=' . $salert; $filters .= '&mode=' . $mode; print_barre_liste( $texte, @@ -368,121 +376,42 @@ $param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&salert=' . $salert; $param .= '&sref=' . $sref; $param .= '&mode=' . $mode; -// Lines of title -print ''; - -print_liste_field_titre( - $langs->trans('Ref'), - $_SERVER["PHP_SELF"], - 'p.ref', - $param, - '', - '', - $sortfield, - $sortorder -); -print_liste_field_titre( - $langs->trans('Label'), - $_SERVER["PHP_SELF"], - 'p.label', - $param, - '', - '', - $sortfield, - $sortorder -); -if (!empty($conf->service->enabled) && $type == 1) -{ - print_liste_field_titre( - $langs->trans('Duration'), - $_SERVER["PHP_SELF"], - 'p.duration', - $param, - '', - 'align="center"', - $sortfield, - $sortorder - ); -} -print_liste_field_titre( - $langs->trans('DesiredStock'), - $_SERVER["PHP_SELF"], - 'p.desiredstock', - $param, - '', - 'align="right"', - $sortfield, - $sortorder -); - $stocklabel = $langs->trans('Stock'); if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock'); if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock'); -print_liste_field_titre( - $stocklabel, - $_SERVER["PHP_SELF"], - 'stock_physique', - $param, - '', - 'align="right"', - $sortfield, - $sortorder -); -print_liste_field_titre( - $langs->trans('Ordered'), - $_SERVER["PHP_SELF"], - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder -); -print_liste_field_titre( - $langs->trans('StockToBuy'), - $_SERVER["PHP_SELF"], - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder -); -print_liste_field_titre( - $langs->trans('Supplier'), - $_SERVER["PHP_SELF"], - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder -); + +// Lines of title +print ''; + +print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], 'p.ref', $param, '', '', $sortfield, $sortorder); +print_liste_field_titre($langs->trans('Label'), $_SERVER["PHP_SELF"], 'p.label', $param, '', '', $sortfield, $sortorder); +if (!empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans('Duration'), $_SERVER["PHP_SELF"], 'p.duration', $param, '', 'align="center"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans('DesiredStock'), $_SERVER["PHP_SELF"], 'p.desiredstock', $param, '', 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans('StockLimitShort'), $_SERVER["PHP_SELF"], 'p.seuil_stock_alerte', $param, '', 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($stocklabel, $_SERVER["PHP_SELF"], 'stock_physique', $param, '', 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans('Ordered'), $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans('StockToBuy'), $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans('Supplier'), $_SERVER["PHP_SELF"], '', $param, '', 'align="right"', $sortfield, $sortorder); + print ''; // Lignes des champs de filtre print ''. ' '. -''. -''. -''. -''. -''. -''; -if (!empty($conf->service->enabled) && $type == 1) -{ - print ' '; -} +''. +''; +if (!empty($conf->service->enabled) && $type == 1) print ' '; print ' '. - '' . $langs->trans('AlertOnly') . ' '. + ' '. + '' . $langs->trans('AlertOnly') . ' '. ' '. ' '. ''. ''. ''. - ''. - ''; + ''; +print ''; $prod = new Product($db); @@ -533,35 +462,21 @@ while ($i < ($limit ? min($num, $limit) : $num)) } $stock_commande_fournisseur = $prod->stats_commande_fournisseur['qty']; $stock = $objp->stock_physique - $stock_commande_client + $stock_commande_fournisseur; + var_dump($stock_commande_fournisseur); } else { $stock = $objp->stock_physique; } $warning=''; - if ($objp->seuil_stock_alerte && ($stock < $objp->seuil_stock_alerte)) + if ($objp->alertstock && ($stock < $objp->alertstock)) { $warning = img_warning($langs->trans('StockTooLow')) . ' '; } //depending on conf, use either physical stock or //virtual stock to compute the stock to buy value - $stocktobuy = max($objp->desiredstock - $stock - $ordered, 0); - /* - $disabled = ''; - if($ordered > 0) - { - if ($ordered + $stock >= $objp->desiredstock) - { - $picto = img_picto('', 'ok', ''); - $disabled = 'disabled="disabled"'; - } - else { - $picto = img_picto($langs->trans("NotEnough"), 'warning', ''); - } - } else { - $picto = img_picto('', 'info', ''); - }*/ + $stocktobuy = max(max($objp->desiredstock, $objp->alertstock) - $stock - $ordered, 0); print ''; @@ -590,6 +505,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) // Desired stock print '' . $objp->desiredstock . ''; + // Limit stock for alerr + print '' . $objp->alertstock . ''; + // Current stock print ''. $warning . $stock. ''; From 2537a9d35fd2f4414c01a592487d571583e21ca5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jul 2014 19:44:25 +0200 Subject: [PATCH 04/21] Fix: Error if module multicompany was removed without being disabled. --- htdocs/user/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 359b42856ab..f71cd7565fb 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -909,7 +909,7 @@ if (($action == 'create') || ($action == 'adduserldap')) // Multicompany if (! empty($conf->multicompany->enabled)) { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity && is_object($mc)) { print "".''.$langs->trans("Entity").''; print "".$mc->select_entities($conf->entity); From ea310efba50308f657dfe80d2148c2bdba10dd08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jul 2014 19:57:18 +0200 Subject: [PATCH 05/21] Fix: [ bug #1471 ] Several PHP warnings when intercepting USER_CREATE trigger --- ChangeLog | 1 + htdocs/user/fiche.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c908243a5fb..df3198a7bf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -68,6 +68,7 @@ For users: - Fix: [ bug #1478 ] BILL_PAYED trigger action does not intercept failure under some circumstances - Fix: [ bug #1479 ] Several customer invoice triggers do not intercept trigger action - Fix: [ bug #1477 ] Several customer invoice triggers do not show trigger error messages +- Fix: [ bug #1471 ] Several PHP warnings when intercepting USER_CREATE trigger. TODO - New: Predefined product and free product use same form. diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index f71cd7565fb..13f890c6013 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -238,8 +238,8 @@ if ($action == 'add' && $canadduser) { $langs->load("errors"); $db->rollback(); - if (is_array($object->errors) && count($object->errors)) $message='
'.join('
',$langs->trans($object->errors)).'
'; - else $message='
'.$langs->trans($object->error).'
'; + if (is_array($object->errors) && count($object->errors)) setEventMessage($object->errors,'errors'); + else setEventMessage($object->error); $action="create"; // Go back to create page } From de527365a8bc4dc6cd4966d2981eadb7d8ef8ebc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jul 2014 20:10:44 +0200 Subject: [PATCH 06/21] Fix: [ bug #1517 ] Packages sizes --- htdocs/install/mysql/migration/3.5.0-3.6.0.sql | 11 ++++++++++- htdocs/install/mysql/tables/llx_expedition.sql | 10 +++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index e9d24685027..b3d71fe5af7 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -18,6 +18,15 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); + + + +ALTER TABLE llx_expedition MODIFY COLUMN height float; +ALTER TABLE llx_expedition MODIFY COLUMN width float; +ALTER TABLE llx_expedition MODIFY COLUMN size float; +ALTER TABLE llx_expedition MODIFY COLUMN weight float; + + ALTER TABLE llx_societe DROP COLUMN datea; ALTER TABLE llx_holiday ADD COLUMN fk_user_create integer; @@ -1663,4 +1672,4 @@ INSERT INTO llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, -- Fix: Missing instruction not correctly done into 3.5 -- VPGSQL8.2 ALTER TABLE llx_facture_fourn ALTER fk_mode_reglement DROP NOT NULL; -- VPGSQL8.2 ALTER TABLE llx_facture_fourn ALTER fk_cond_reglement DROP NOT NULL; - + \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_expedition.sql b/htdocs/install/mysql/tables/llx_expedition.sql index 08ea9683281..0a152b13069 100644 --- a/htdocs/install/mysql/tables/llx_expedition.sql +++ b/htdocs/install/mysql/tables/llx_expedition.sql @@ -41,13 +41,13 @@ create table llx_expedition fk_shipping_method integer, tracking_number varchar(50), fk_statut smallint DEFAULT 0, - - height integer, -- height - width integer, -- with + + height float, -- height + width float, -- with size_units integer, -- unit of all sizes (height, width, depth) - size integer, -- depth + size float, -- depth weight_units integer, -- unit of weight - weight integer, -- weight + weight float, -- weight note_private text, note_public text, model_pdf varchar(255) From c1d33af50d3f968976778c03374e245389c4c8d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jul 2014 20:11:08 +0200 Subject: [PATCH 07/21] - Fix: [ bug #1517 ] Packages sizes. --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index df3198a7bf5..fbc13e8ba77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -69,6 +69,7 @@ For users: - Fix: [ bug #1479 ] Several customer invoice triggers do not intercept trigger action - Fix: [ bug #1477 ] Several customer invoice triggers do not show trigger error messages - Fix: [ bug #1471 ] Several PHP warnings when intercepting USER_CREATE trigger. +- Fix: [ bug #1517 ] Packages sizes. TODO - New: Predefined product and free product use same form. From 959c41e8db19c8577233042c9b2617630fc68f2d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 10:24:29 +0200 Subject: [PATCH 08/21] Fix : virtual stock was not correctly calculated because reception was not included. --- htdocs/product/class/product.class.php | 83 ++++++++++++++++++++++++++ htdocs/product/stock/product.php | 21 +------ 2 files changed, 85 insertions(+), 19 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cee5c72abea..61b885f02c7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1709,6 +1709,48 @@ class Product extends CommonObject } } + /** + * Charge tableau des stats réception fournisseur pour le produit/service + * + * @param int $socid Id societe pour filtrer sur une societe + * @param int $filtrestatut Id statut pour filtrer sur un statut + * @return array Tableau des stats + */ + function load_stats_reception($socid=0,$filtrestatut='') + { + global $conf,$user; + + $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; + $sql.= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd"; + $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE cf.rowid = fd.fk_commande"; + $sql.= " AND cf.fk_soc = s.rowid"; + $sql.= " AND cf.entity = ".$conf->entity; + $sql.= " AND fd.fk_product = ".$this->id; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid > 0) $sql.= " AND cf.fk_soc = ".$socid; + if ($filtrestatut <> '') $sql.= " AND cf.fk_statut in (".$filtrestatut.")"; + + $result = $this->db->query($sql); + if ( $result ) + { + $obj=$this->db->fetch_object($result); + $this->stats_reception['suppliers']=$obj->nb_customers; + $this->stats_reception['nb']=$obj->nb; + $this->stats_reception['rows']=$obj->nb_rows; + $this->stats_reception['qty']=$obj->qty?$obj->qty:0; + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + /** * Charge tableau des stats contrat pour le produit/service * @@ -2872,6 +2914,7 @@ class Product extends CommonObject } } $this->db->free($result); + $this->load_virtual_stock(); return 1; } else @@ -2881,6 +2924,46 @@ class Product extends CommonObject } } + /** + * Load information about virtual stock of a product + * + * @return int < 0 if KO, > 0 if OK + */ + function load_virtual_stock() + { + global $conf; + + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) + { + $stock_commande_client=$stock_commande_fournisseur=0; + $stock_sending_client=$stock_reception_fournisseur=0; + + if (! empty($conf->commande->enabled)) + { + $result=$this->load_stats_commande(0,'1,2'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_commande_client=$this->stats_commande['qty']; + } + if (! empty($conf->expedition->enabled)) + { + $result=$this->load_stats_sending(0,''); + if ($result < 0) dol_print_error($db,$this->error); + $stock_sending_client=$this->stats_expedition['qty']; + } + if (! empty($conf->fournisseur->enabled)) + { + $result=$this->load_stats_commande_fournisseur(0,'3'); + if ($result < 0) dol_print_error($db,$this->error); + $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; + + $result=$this->load_stats_reception(0,''); + if ($result < 0) dol_print_error($db,$this->error); + $stock_reception_fournisseur=$this->stats_reception['qty']; + } + + $this->stock_theorique=$this->stock_reel-($stock_commande_client-$stock_sending_client)+($stock_commande_fournisseur-$stock_reception_fournisseur); + } + } /** * Deplace fichier uploade sous le nom $files dans le repertoire sdir diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 3f26d8c0980..338169a6154 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -321,23 +321,6 @@ if ($id > 0 || $ref) // If stock if stock increment is done on real sending if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { - $stock_commande_client=$stock_commande_fournisseur=0; - - if (! empty($conf->commande->enabled)) - { - $result=$product->load_stats_commande(0,'1,2'); - if ($result < 0) dol_print_error($db,$product->error); - $stock_commande_client=$product->stats_commande['qty']; - } - if (! empty($conf->fournisseur->enabled)) - { - $result=$product->load_stats_commande_fournisseur(0,'3'); - if ($result < 0) dol_print_error($db,$product->error); - $stock_commande_fournisseur=$product->stats_commande_fournisseur['qty']; - } - - $product->stock_theorique=$product->stock_reel-($stock_commande_client+$stock_sending_client)+$stock_commande_fournisseur; - // Stock theorique print ''.$langs->trans("VirtualStock").''; print "".$product->stock_theorique; @@ -360,7 +343,7 @@ if ($id > 0 || $ref) if (! empty($conf->commande->enabled)) { if ($found) print '
'; else $found=1; - print $langs->trans("CustomersOrdersRunning").': '.($stock_commande_client+$stock_sending_client); + print $langs->trans("CustomersOrdersRunning").': '.($product->stats_commande['qty']-$product->stats_sendings['qty']); $result=$product->load_stats_commande(0,'0'); if ($result < 0) dol_print_error($db,$product->error); print ' ('.$langs->trans("Draft").': '.$product->stats_commande['qty'].')'; @@ -372,7 +355,7 @@ if ($id > 0 || $ref) if (! empty($conf->fournisseur->enabled)) { if ($found) print '
'; else $found=1; - print $langs->trans("SuppliersOrdersRunning").': '.$stock_commande_fournisseur; + print $langs->trans("SuppliersOrdersRunning").': '.($product->stats_commande_fournisseur['qty']-$product->stats_reception['qty']); $result=$product->load_stats_commande_fournisseur(0,'0,1,2'); if ($result < 0) dol_print_error($db,$product->error); print ' ('.$langs->trans("DraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')'; From b115e9b943c24a2408aedb8db3c835eddb19dfd4 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 12:07:34 +0200 Subject: [PATCH 09/21] Fix : replenish function was not working with virtual stock --- htdocs/product/stock/replenish.php | 78 ++++++++++++++++++------------ 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 6aee0bada53..0bfdbfb9159 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -252,36 +252,58 @@ $sql.= ', s.fk_product'; if ($usevirtualstock) { - $sqlCommandesCli = "(SELECT SUM(cd.qty) as qty"; + $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; $sqlCommandesCli.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sqlCommandesCli.= ", ".MAIN_DB_PREFIX."commande as c"; - $sqlCommandesCli.= " WHERE c.rowid = cd.fk_commande"; - $sqlCommandesCli.= " AND c.entity = ".$conf->entity; + $sqlCommandesCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; + $sqlCommandesCli.= " WHERE c.entity = ".$conf->entity; $sqlCommandesCli.= " AND cd.fk_product = p.rowid"; $sqlCommandesCli.= " AND c.fk_statut in (1,2))"; - - $sqlCommandesFourn = "(SELECT SUM(cd.qty) as qty"; + + $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed.qty) IS NULL", "0", "SUM(ed.qty)")." as qty"; + $sqlExpeditionsCli.= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)"; + $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)"; + $sqlExpeditionsCli.= " WHERE e.entity = ".$conf->entity; + $sqlExpeditionsCli.= " AND cd.fk_product = p.rowid"; + $sqlExpeditionsCli.= " AND e.fk_statut > 0)"; + + $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; $sqlCommandesFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; $sqlCommandesFourn.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sqlCommandesFourn.= " WHERE c.rowid = cd.fk_commande"; $sqlCommandesFourn.= " AND c.entity = ".$conf->entity; $sqlCommandesFourn.= " AND cd.fk_product = p.rowid"; - $sqlCommandesFourn.= " AND c.fk_statut in (3))"; - - $sql.= ' HAVING ((p.desiredstock > 0 AND p.desiredstock > (SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - '.$db->ifsql($sqlCommandesCli.' IS NULL', '0', $sqlCommandesCli).' + '.$db->ifsql($sqlCommandesFourn.' IS NULL', '0', $sqlCommandesFourn).'))'; - - $sql.= ' OR (p.seuil_stock_alerte > 0 AND p.seuil_stock_alerte > (SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; - $sql.= ' - '.$db->ifsql($sqlCommandesCli.' IS NULL', '0', $sqlCommandesCli).' + '.$db->ifsql($sqlCommandesFourn.' IS NULL', '0', $sqlCommandesFourn).'))'; - $sql.= " )"; + $sqlCommandesFourn.= " AND c.fk_statut in (2,3))"; + + $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd.qty) IS NULL", "0", "SUM(fd.qty)")." as qty"; + $sqlReceptionFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)"; + $sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)"; + $sqlReceptionFourn.= " WHERE cf.entity = ".$conf->entity; + $sqlReceptionFourn.= " AND fd.fk_product = p.rowid)"; + + $sql.= ' HAVING ((p.desiredstock > 0 AND (p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; + $sql.= ' OR (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.'))))'; + + if ($salert == 'on') // Option to see when stock is lower than alert + { + $sql.= ' AND (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; + $alertchecked = 'checked="checked"'; + } } else { - $sql.= ' HAVING ((p.desiredstock > 0 AND (p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))) OR (p.seuil_stock_alerte > 0 AND (seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; -} -if ($salert == 'on') // Option to see when stock is lower than alert -{ - $sql .= ' AND SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL'; - $alertchecked = 'checked="checked"'; + $sql.= ' HAVING ((p.desiredstock > 0 AND (p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql.= ' OR (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + + if ($salert == 'on') // Option to see when stock is lower than alert + { + $sql.= ' AND (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $alertchecked = 'checked="checked"'; + } } + $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit, $offset); @@ -368,6 +390,7 @@ print '
' ''. ''. ''. + ''. ''; @@ -451,18 +474,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock. $prod->fetch($prod->id); - $result=$prod->load_stats_commande(0, '1,2'); - if ($result < 0) { - dol_print_error($db, $prod->error); - } - $stock_commande_client = $prod->stats_commande['qty']; - $result=$prod->load_stats_commande_fournisseur(0, '3'); - if ($result < 0) { - dol_print_error($db,$prod->error); - } - $stock_commande_fournisseur = $prod->stats_commande_fournisseur['qty']; - $stock = $objp->stock_physique - $stock_commande_client + $stock_commande_fournisseur; - var_dump($stock_commande_fournisseur); + $prod->load_stock(); + + $stock = $prod->stock_theorique; } else { From 830cc30f802c0569ac16a8e2bdf574724f5a6f36 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 12:31:55 +0200 Subject: [PATCH 10/21] Fix : sendings and reception stock calculation must be on the same status than order and oreder supplier calculation --- htdocs/product/class/product.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 61b885f02c7..2bdc950495e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1680,17 +1680,19 @@ class Product extends CommonObject $sql.= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; $sql.= ", ".MAIN_DB_PREFIX."commandedet as cd"; + $sql.= ", ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE e.rowid = ed.fk_expedition"; + $sql.= " AND c.rowid = cd.fk_commande"; $sql.= " AND e.fk_soc = s.rowid"; $sql.= " AND e.entity = ".$conf->entity; $sql.= " AND ed.fk_origin_line = cd.rowid"; $sql.= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND e.fk_soc = ".$socid; - if ($filtrestatut <> '') $sql.= " AND e.fk_statut in (".$filtrestatut.")"; + if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")"; $result = $this->db->query($sql); if ( $result ) @@ -2946,7 +2948,7 @@ class Product extends CommonObject } if (! empty($conf->expedition->enabled)) { - $result=$this->load_stats_sending(0,''); + $result=$this->load_stats_sending(0,'1,2'); if ($result < 0) dol_print_error($db,$this->error); $stock_sending_client=$this->stats_expedition['qty']; } @@ -2956,12 +2958,13 @@ class Product extends CommonObject if ($result < 0) dol_print_error($db,$this->error); $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; - $result=$this->load_stats_reception(0,''); + $result=$this->load_stats_reception(0,'3'); if ($result < 0) dol_print_error($db,$this->error); $stock_reception_fournisseur=$this->stats_reception['qty']; } $this->stock_theorique=$this->stock_reel-($stock_commande_client-$stock_sending_client)+($stock_commande_fournisseur-$stock_reception_fournisseur); + //echo $this->stock_theorique.' = '.$this->stock_reel.' - ('.$stock_commande_client.' - '.$stock_sending_client.') + ('.$stock_commande_fournisseur.' - '.$stock_reception_fournisseur.')'; } } From a22963e4329cf73be2a22874fbfd9c4ca02a1ec6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 14:37:30 +0200 Subject: [PATCH 11/21] Fix : filter by status + was not working if desiredstock not defined --- htdocs/product/stock/replenish.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 0bfdbfb9159..ec4a98d3d2e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -257,15 +257,16 @@ if ($usevirtualstock) $sqlCommandesCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; $sqlCommandesCli.= " WHERE c.entity = ".$conf->entity; $sqlCommandesCli.= " AND cd.fk_product = p.rowid"; - $sqlCommandesCli.= " AND c.fk_statut in (1,2))"; + $sqlCommandesCli.= " AND c.fk_statut IN (1,2))"; $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed.qty) IS NULL", "0", "SUM(ed.qty)")." as qty"; $sqlExpeditionsCli.= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)"; $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)"; + $sqlExpeditionsCli.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; $sqlExpeditionsCli.= " WHERE e.entity = ".$conf->entity; $sqlExpeditionsCli.= " AND cd.fk_product = p.rowid"; - $sqlExpeditionsCli.= " AND e.fk_statut > 0)"; + $sqlExpeditionsCli.= " AND c.fk_statut IN (1,2))"; $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; $sqlCommandesFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; @@ -273,18 +274,18 @@ if ($usevirtualstock) $sqlCommandesFourn.= " WHERE c.rowid = cd.fk_commande"; $sqlCommandesFourn.= " AND c.entity = ".$conf->entity; $sqlCommandesFourn.= " AND cd.fk_product = p.rowid"; - $sqlCommandesFourn.= " AND c.fk_statut in (2,3))"; + $sqlCommandesFourn.= " AND c.fk_statut IN (3,4))"; $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd.qty) IS NULL", "0", "SUM(fd.qty)")." as qty"; $sqlReceptionFourn.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)"; $sqlReceptionFourn.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)"; $sqlReceptionFourn.= " WHERE cf.entity = ".$conf->entity; - $sqlReceptionFourn.= " AND fd.fk_product = p.rowid)"; + $sqlReceptionFourn.= " AND fd.fk_product = p.rowid"; + $sqlReceptionFourn.= " AND cf.fk_statut IN (3,4))"; - $sql.= ' HAVING ((p.desiredstock > 0 AND (p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' HAVING ((('.$db->ifsql("p.desiredstock IS NULL", "0", "p.desiredstock").' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; - $sql.= ' OR (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' OR (p.seuil_stock_alerte >= 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.'))))'; if ($salert == 'on') // Option to see when stock is lower than alert From a26db9ab524010e9ddf6b2da1aa9f10353584bf4 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 14:47:28 +0200 Subject: [PATCH 12/21] Fix : qty ordered was not including qty already received --- htdocs/product/stock/replenish.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index ec4a98d3d2e..ca014e50cf0 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -446,6 +446,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) if (! empty($conf->global->STOCK_SUPPORTS_SERVICES) || $objp->fk_product_type == 0) { + $prod->fetch($objp->rowid); + $prod->load_stock(); + // Multilangs if (! empty($conf->global->MAIN_MULTILANGS)) { @@ -462,27 +465,21 @@ while ($i < ($limit ? min($num, $limit) : $num)) if (!empty($objtp->label)) $objp->label = $objtp->label; } } + $form = new Form($db); $var =! $var; - $prod->ref = $objp->ref; - $prod->id = $objp->rowid; - $prod->type = $objp->fk_product_type; - // Get number already ordered. - $ordered = ordered($prod->id); - - // Defined current stock number and warning if required if ($usevirtualstock) { // If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock. - $prod->fetch($prod->id); - $prod->load_stock(); - $stock = $prod->stock_theorique; } else { - $stock = $objp->stock_physique; + $stock = $prod->stock_reel; } + + $ordered = $prod->stats_commande_fournisseur['qty']-$prod->stats_reception['qty']; + $warning=''; if ($objp->alertstock && ($stock < $objp->alertstock)) { From 51e4fa0d3613629347a7df1a51c06441584412c2 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 15:31:51 +0200 Subject: [PATCH 13/21] Fix : picto for already ordered product was missing --- htdocs/product/stock/replenish.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index ca014e50cf0..817ec5cbf7a 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -489,6 +489,19 @@ while ($i < ($limit ? min($num, $limit) : $num)) //depending on conf, use either physical stock or //virtual stock to compute the stock to buy value $stocktobuy = max(max($objp->desiredstock, $objp->alertstock) - $stock - $ordered, 0); + $disabled = ''; + if($ordered > 0) { + $compare = $usevirtualstock ? $stock : $stock + $ordered; + if($compare >= $objp->desiredstock) { + $picto = img_picto('', './img/yes', '', 1); + $disabled = 'disabled="disabled"'; + } + else { + $picto = img_picto('', './img/no', '', 1); + } + } else { + $picto = img_picto('', './img/no', '', 1); + } print ''; From f2248d5bc887b66b9254f315992d5c8eadc19952 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 17:57:36 +0200 Subject: [PATCH 14/21] Fix : ordered should display qty in supplier order not yet send --- htdocs/product/stock/replenish.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 817ec5cbf7a..590260a7c99 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -478,21 +478,21 @@ while ($i < ($limit ? min($num, $limit) : $num)) $stock = $prod->stock_reel; } - $ordered = $prod->stats_commande_fournisseur['qty']-$prod->stats_reception['qty']; + $ordered = $prod->stats_commande_fournisseur['qty']; $warning=''; - if ($objp->alertstock && ($stock < $objp->alertstock)) + + if ($objp->seuil_stock_alerte && ($stock < $objp->seuil_stock_alerte)) { $warning = img_warning($langs->trans('StockTooLow')) . ' '; } - //depending on conf, use either physical stock or //virtual stock to compute the stock to buy value - $stocktobuy = max(max($objp->desiredstock, $objp->alertstock) - $stock - $ordered, 0); + //echo $objp->desiredstock." * ".$stock." * ".$ordered."
"; + $stocktobuy = max($objp->desiredstock - $stock - $ordered, 0); $disabled = ''; if($ordered > 0) { - $compare = $usevirtualstock ? $stock : $stock + $ordered; - if($compare >= $objp->desiredstock) { + if($stock + $ordered >= $objp->desiredstock) { $picto = img_picto('', './img/yes', '', 1); $disabled = 'disabled="disabled"'; } From 8eb8f33f28850a8f8be69c0d61540c33caf475ce Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 18:14:26 +0200 Subject: [PATCH 15/21] =?UTF-8?q?Ajout=20qt=C3=A9=20dans=20=C3=A9cran=20co?= =?UTF-8?q?nsommation=20produit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product/stats/commande.php | 4 +++- htdocs/product/stats/commande_fournisseur.php | 4 +++- htdocs/product/stats/facture.php | 4 +++- htdocs/product/stats/facture_fournisseur.php | 4 +++- htdocs/product/stats/propal.php | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index b19c3c7fd68..97e9a612ae1 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -118,7 +118,7 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, c.rowid, c.total_ht as total_ht, c.ref,"; - $sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid"; + $sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.qty"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande as c"; @@ -148,6 +148,7 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"c.date_commande","","&id=".$product->id,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$product->id,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.total_ht","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print "
\n"; @@ -170,6 +171,7 @@ if ($id > 0 || ! empty($ref)) print "\n"; print ""; + print "\n"; print "\n"; print ''; print "\n"; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 69845b4b264..22e3e2b30ba 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -111,7 +111,7 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; $sql.= " c.rowid, c.total_ht as total_ht, c.ref,"; - $sql.= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid"; + $sql.= " c.date_commande, c.fk_statut as statut, c.rowid as commandeid, d.qty"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; @@ -141,6 +141,7 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"c.date_commande","","&id=".$product->id,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$product->id,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"c.total_ht","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"c.fk_statut","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print "\n"; @@ -165,6 +166,7 @@ if ($id > 0 || ! empty($ref)) print ''; print "\n"; print '"; + print "\n"; print '\n"; print ''; print "\n"; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index cac2bccc45b..dc65764defd 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -122,7 +122,7 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.total as total_ht,"; - $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; + $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; @@ -152,6 +152,7 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$product->id,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$product->id,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total_ht","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print "\n"; @@ -174,6 +175,7 @@ if ($id > 0 || ! empty($ref)) print "\n"; print ""; + print "\n"; print "\n"; print ''; print "\n"; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 2a06c30a496..4cbeaec7e76 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -123,7 +123,7 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, f.ref, f.total_ht as total_ht,"; - $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; + $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid, d.qty"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; @@ -153,6 +153,7 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$product->id,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$product->id,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total_ht","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print "\n"; @@ -175,6 +176,7 @@ if ($id > 0 || ! empty($ref)) print "\n"; print ""; + print "\n"; print "\n"; print ''; print "\n"; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index a55673c62b0..e9a78f18b05 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -113,7 +113,7 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT DISTINCT s.nom, s.rowid as socid, p.rowid as propalid, p.ref, p.total_ht as amount,"; - $sql.= "p.datep, p.fk_statut as statut"; + $sql.= "p.datep, p.fk_statut as statut, d.qty"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ",".MAIN_DB_PREFIX."propal as p"; @@ -141,6 +141,7 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.rowid","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$product->id,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePropal"),$_SERVER["PHP_SELF"],"p.datep","","&id=".$product->id,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$product->id,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"p.total","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.fk_statut","","&id=".$product->id,'align="right"',$sortfield,$sortorder); print "\n"; @@ -162,6 +163,7 @@ if ($id > 0 || ! empty($ref)) print ''; print '"; + print "\n"; print ''."\n"; print ''; print ''."\n"; From db0fa0afd0ab803122f13b8172a72b552d18feea Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 3 Jul 2014 18:17:34 +0200 Subject: [PATCH 16/21] Revert "Fix : ordered should display qty in supplier order not yet send" This reverts commit f2248d5bc887b66b9254f315992d5c8eadc19952. --- htdocs/product/stock/replenish.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 590260a7c99..817ec5cbf7a 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -478,21 +478,21 @@ while ($i < ($limit ? min($num, $limit) : $num)) $stock = $prod->stock_reel; } - $ordered = $prod->stats_commande_fournisseur['qty']; + $ordered = $prod->stats_commande_fournisseur['qty']-$prod->stats_reception['qty']; $warning=''; - - if ($objp->seuil_stock_alerte && ($stock < $objp->seuil_stock_alerte)) + if ($objp->alertstock && ($stock < $objp->alertstock)) { $warning = img_warning($langs->trans('StockTooLow')) . ' '; } + //depending on conf, use either physical stock or //virtual stock to compute the stock to buy value - //echo $objp->desiredstock." * ".$stock." * ".$ordered."
"; - $stocktobuy = max($objp->desiredstock - $stock - $ordered, 0); + $stocktobuy = max(max($objp->desiredstock, $objp->alertstock) - $stock - $ordered, 0); $disabled = ''; if($ordered > 0) { - if($stock + $ordered >= $objp->desiredstock) { + $compare = $usevirtualstock ? $stock : $stock + $ordered; + if($compare >= $objp->desiredstock) { $picto = img_picto('', './img/yes', '', 1); $disabled = 'disabled="disabled"'; } From 47cff4d407ed00389fe719af78d181b13289a4fd Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 4 Jul 2014 10:04:30 +0200 Subject: [PATCH 17/21] Fix: Unable to add lines in supplier orders --- htdocs/fourn/commande/fiche.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 5a0a77f3212..1cfc3e23e01 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1753,24 +1753,20 @@ elseif (! empty($object->id)) } // Form to add new line - if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action <> 'edit_line') + if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action != 'edit_line') { // Add free products/services form global $forceall, $senderissupplier, $dateSelector; $forceall=1; $senderissupplier=1; $dateSelector=0; - if ($object->statut == 0 && $user->rights->propal->creer) - { - if ($action != 'editline') - { - $var = true; + + $var = true; - // Add free products/services - $object->formAddObjectLine(1, $societe, $mysoc); + // Add free products/services + $object->formAddObjectLine(1, $societe, $mysoc); - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - } - } + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } print '
".$objp->code_client.""; print dol_print_date($db->jdate($objp->date_commande))."".$objp->qty."".price($objp->total_ht)."'.$commandestatic->LibStatut($objp->statut,$objp->facture,5).'
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).'".$objp->code_client."'.dol_print_date($db->jdate($objp->date_commande))."".$objp->qty."'.price($objp->total_ht)."'.$commandestatic->getLibStatut(4).'
".$objp->code_client.""; print dol_print_date($db->jdate($objp->datef),'day')."".$objp->qty."".price($objp->total_ht)."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'
".$objp->code_client.""; print dol_print_date($db->jdate($objp->datef))."".$objp->qty."".price($objp->total_ht)."'.$supplierinvoicestatic->LibStatut($objp->paye,$objp->statut,5).'
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,44).''; print dol_print_date($db->jdate($objp->datep))."".$objp->qty."'.price($objp->amount).''.$propalstatic->LibStatut($objp->statut,5).'
'; From 11abba30b38041d96a2fa71b293d9db9983be067 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Jul 2014 11:58:41 +0200 Subject: [PATCH 18/21] Fix: Add information to help debug pb with TZ. --- htdocs/admin/system/dolibarr.php | 21 ++++++++++++++------- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 59f3b3f3856..675638bf000 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -177,13 +177,20 @@ $var=!$var; print '  => dol_get_first_day(1970,1,false)'.dol_get_first_day(1970,1,false).'     (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,false),'dayhour').')'; $var=!$var; print '  => dol_get_first_day(1970,1,true)'.dol_get_first_day(1970,1,true).'     (=> dol_print_date() or idate() of this value = '.dol_print_date(dol_get_first_day(1970,1,true),'dayhour').')'; -// Parent company -/* -$var=!$var; -print ''.$langs->trans("CompanyTZ").''.$langs->trans("FeatureNotYetAvailable").''."\n"; -$var=!$var; -print '  => '.$langs->trans("CompanyHour").''.$langs->trans("FeatureNotYetAvailable").''."\n"; -*/ +// Database timezone +if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') +{ + $var=!$var; + print ''.$langs->trans("MySQLTimeZone").' (database)'; // Timezone server base + $sql="SHOW VARIABLES where variable_name = 'system_time_zone'"; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + print $form->textwithtooltip($obj->Value,$langs->trans('TZHasNoEffect'),2,1,img_info('')); + } + print ''."\n"; +} // Client $var=!$var; $tz=(int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b46f2c57be4..a5c2d1e19fe 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -63,6 +63,8 @@ ShowPreview=Show preview PreviewNotAvailable=Preview not available ThemeCurrentlyActive=Theme currently active CurrentTimeZone=TimeZone PHP (server) +MySQLTimeZone=TimeZone MySql (database) +TZHasNoEffect=Dates are stored and returned by database server as if they were kept as submited string. The timezone has effect only when using UNIX_TIMESTAMP function (that should not be used by Dolibarr, so database TZ should have no effect, even if changed after data was entered). Space=Space Table=Table Fields=Fields From bf96a78f630afe772a821ee063a37d9ace66c269 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Jul 2014 13:07:53 +0200 Subject: [PATCH 19/21] Try a fix when timezone string is not standard --- htdocs/core/js/dst.js | 21 +- htdocs/core/lib/functions.lib.php | 20 +- htdocs/includes/adodbtime/adodb-time.inc.php | 560 +++++++++---------- htdocs/main.inc.php | 3 + 4 files changed, 308 insertions(+), 296 deletions(-) diff --git a/htdocs/core/js/dst.js b/htdocs/core/js/dst.js index 5335906dc77..c22f83aec21 100644 --- a/htdocs/core/js/dst.js +++ b/htdocs/core/js/dst.js @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2012 Laurent Destailleur +// Copyright (C) 2011-2014 Laurent Destailleur // Copyright (C) 2011-2012 Regis Houssin // // This program is free software; you can redistribute it and/or modify @@ -18,7 +18,8 @@ // // \file htdocs/core/js/dst.js -// \brief File that include javascript functions for detect user tz, dst_observed, dst_first, dst_second +// \brief File that include javascript functions for detect user tz, tz_string, dst_observed, dst_first, dst_second, +// screenwidth and screenheight // $(document).ready(function () { @@ -39,22 +40,22 @@ $(document).ready(function () { dst = "1"; // daylight savings time is observed } var now=new Date(); - var tz=now.toTimeString().match(/\(.*\)/); + var tz=now.toTimeString().match(/\(.*\)/); // now.toTimeString may return "12:39:59 GMT+0200 (CEST)" //alert('date=' + now + ' string=' + now.toTimeString()); var dst_first=DisplayDstSwitchDates('first'); var dst_second=DisplayDstSwitchDates('second'); //alert(dst); - $('#tz').val(std_time_offset); // returns TZ - // tz is null with IE + $('#tz').val(std_time_offset); // returns TZ + // tz is null with IE if (tz != null) { $('#tz_string').val(tz[0].replace('(','').replace(')','')); // returns TZ string } - $('#dst_observed').val(dst); // returns if DST is observed on summer - $('#dst_first').val(dst_first); // returns DST first switch in year - $('#dst_second').val(dst_second); // returns DST second switch in year + $('#dst_observed').val(dst); // returns if DST is observed on summer + $('#dst_first').val(dst_first); // returns DST first switch in year + $('#dst_second').val(dst_second); // returns DST second switch in year // Detect and save screen resolution - $('#screenwidth').val($(window).width()); // returns width of browser viewport - $('#screenheight').val($(window).height()); // returns width of browser viewport + $('#screenwidth').val($(window).width()); // returns width of browser viewport + $('#screenheight').val($(window).height()); // returns width of browser viewport }); function DisplayDstSwitchDates(firstsecond) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e81c8b3b2d9..e450650549e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -886,7 +886,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$time,$reg) || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i',$time,$reg)) { - // This part of code should not be used. + // This part of code should not be used. TODO Remove this. dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' $syear = (! empty($reg[1]) ? $reg[1] : ''); @@ -904,7 +904,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e // Date is a timestamps if ($time < 100000000000) // Protection against bad date values { - $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); + $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); // TODO Remove this } else $ret='Bad value '.$time.' for date'; } @@ -912,7 +912,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e if (preg_match('/__b__/i',$format)) { // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. - $month=adodb_strftime('%m',$time+$offsettz+$offsetdst); + $month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Remove this if ($encodetooutput) { $monthtext=$outputlangs->transnoentities('Month'.$month); @@ -931,7 +931,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e } if (preg_match('/__a__/i',$format)) { - $w=adodb_strftime('%w',$time+$offsettz+$offsetdst); + $w=adodb_strftime('%w',$time+$offsettz+$offsetdst); // TODO Remove this $dayweek=$outputlangs->transnoentitiesnoconv('Day'.$w); $ret=str_replace('__A__',$dayweek,$ret); $ret=str_replace('__a__',dol_substr($dayweek,0,3),$ret); @@ -1037,8 +1037,16 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) } else if ($gm === 'user') { - $default_timezone=(empty($_SESSION["dol_tz_string"])?'UTC':$_SESSION["dol_tz_string"]); - $localtz = new DateTimeZone($default_timezone); + // We use dol_tz_string first because it contains dst. + $default_timezone=(empty($_SESSION["dol_tz_string"])?@date_default_timezone_get():$_SESSION["dol_tz_string"]); + try { + $localtz = new DateTimeZone($default_timezone); + } + catch(Exception $e) + { + dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING); + $default_timezone=@date_default_timezone_get(); + } } else $localtz = new DateTimeZone('UTC'); $dt = new DateTime(null,$localtz); diff --git a/htdocs/includes/adodbtime/adodb-time.inc.php b/htdocs/includes/adodbtime/adodb-time.inc.php index 1ae50767c67..1be5f4cd607 100644 --- a/htdocs/includes/adodbtime/adodb-time.inc.php +++ b/htdocs/includes/adodbtime/adodb-time.inc.php @@ -4,33 +4,33 @@ ADOdb Date Library, part of the ADOdb abstraction library Download: http://phplens.com/phpeverywhere/ PHP native date functions use integer timestamps for computations. -Because of this, dates are restricted to the years 1901-2038 on Unix -and 1970-2038 on Windows due to integer overflow for dates beyond -those years. This library overcomes these limitations by replacing the -native function's signed integers (normally 32-bits) with PHP floating +Because of this, dates are restricted to the years 1901-2038 on Unix +and 1970-2038 on Windows due to integer overflow for dates beyond +those years. This library overcomes these limitations by replacing the +native function's signed integers (normally 32-bits) with PHP floating point numbers (normally 64-bits). Dates from 100 A.D. to 3000 A.D. and later have been tested. The minimum is 100 A.D. as <100 will invoke the -2 => 4 digit year conversion. The maximum is billions of years in the -future, but this is a theoretical limit as the computation of that year +2 => 4 digit year conversion. The maximum is billions of years in the +future, but this is a theoretical limit as the computation of that year would take too long with the current implementation of adodb_mktime(). This library replaces native functions as follows: -
	
+
 	getdate()  with  adodb_getdate()
-	date()     with  adodb_date() 
+	date()     with  adodb_date()
 	gmdate()   with  adodb_gmdate()
 	mktime()   with  adodb_mktime()
 	gmmktime() with  adodb_gmmktime()
 	strftime() with  adodb_strftime()
 	strftime() with  adodb_gmstrftime()
 
- + The parameters are identical, except that adodb_date() accepts a subset -of date()'s field formats. Mktime() will convert from local time to GMT, -and date() will convert from GMT to local time, but daylight savings is +of date()'s field formats. Mktime() will convert from local time to GMT, +and date() will convert from GMT to local time, but daylight savings is not handled currently. This library is independant of the rest of ADOdb, and can be used @@ -39,25 +39,25 @@ as standalone code. PERFORMANCE For high speed, this library uses the native date functions where -possible, and only switches to PHP code when the dates fall outside +possible, and only switches to PHP code when the dates fall outside the 32-bit signed integer range. GREGORIAN CORRECTION -Pope Gregory shortened October of A.D. 1582 by ten days. Thursday, -October 4, 1582 (Julian) was followed immediately by Friday, October 15, -1582 (Gregorian). +Pope Gregory shortened October of A.D. 1582 by ten days. Thursday, +October 4, 1582 (Julian) was followed immediately by Friday, October 15, +1582 (Gregorian). Since 0.06, we handle this correctly, so: -adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582) +adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582) == 24 * 3600 (1 day) ============================================================================= COPYRIGHT -(c) 2003-2005 John Lim and released under BSD-style license except for code by +(c) 2003-2005 John Lim and released under BSD-style license except for code by jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year and originally found at http://www.php.net/manual/en/function.mktime.php @@ -77,10 +77,10 @@ FUNCTION DESCRIPTIONS ** FUNCTION adodb_getdate($date=false) Returns an array containing date information, as getdate(), but supports -dates greater than 1901 to 2038. The local date/time format is derived from a -heuristic the first time adodb_getdate is called. - - +dates greater than 1901 to 2038. The local date/time format is derived from a +heuristic the first time adodb_getdate is called. + + ** FUNCTION adodb_date($fmt, $timestamp = false) Convert a timestamp to a formatted local date. If $timestamp is not defined, the @@ -90,45 +90,45 @@ outside the 1901 to 2038 range. The format fields that adodb_date supports:
-	a - "am" or "pm" 
-	A - "AM" or "PM" 
-	d - day of the month, 2 digits with leading zeros; i.e. "01" to "31" 
-	D - day of the week, textual, 3 letters; e.g. "Fri" 
-	F - month, textual, long; e.g. "January" 
-	g - hour, 12-hour format without leading zeros; i.e. "1" to "12" 
-	G - hour, 24-hour format without leading zeros; i.e. "0" to "23" 
-	h - hour, 12-hour format; i.e. "01" to "12" 
-	H - hour, 24-hour format; i.e. "00" to "23" 
-	i - minutes; i.e. "00" to "59" 
-	j - day of the month without leading zeros; i.e. "1" to "31" 
-	l (lowercase 'L') - day of the week, textual, long; e.g. "Friday"  
-	L - boolean for whether it is a leap year; i.e. "0" or "1" 
-	m - month; i.e. "01" to "12" 
-	M - month, textual, 3 letters; e.g. "Jan" 
-	n - month without leading zeros; i.e. "1" to "12" 
-	O - Difference to Greenwich time in hours; e.g. "+0200" 
-	Q - Quarter, as in 1, 2, 3, 4 
-	r - RFC 2822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200" 
-	s - seconds; i.e. "00" to "59" 
-	S - English ordinal suffix for the day of the month, 2 characters; 
-	   			i.e. "st", "nd", "rd" or "th" 
+	a - "am" or "pm"
+	A - "AM" or "PM"
+	d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"
+	D - day of the week, textual, 3 letters; e.g. "Fri"
+	F - month, textual, long; e.g. "January"
+	g - hour, 12-hour format without leading zeros; i.e. "1" to "12"
+	G - hour, 24-hour format without leading zeros; i.e. "0" to "23"
+	h - hour, 12-hour format; i.e. "01" to "12"
+	H - hour, 24-hour format; i.e. "00" to "23"
+	i - minutes; i.e. "00" to "59"
+	j - day of the month without leading zeros; i.e. "1" to "31"
+	l (lowercase 'L') - day of the week, textual, long; e.g. "Friday"
+	L - boolean for whether it is a leap year; i.e. "0" or "1"
+	m - month; i.e. "01" to "12"
+	M - month, textual, 3 letters; e.g. "Jan"
+	n - month without leading zeros; i.e. "1" to "12"
+	O - Difference to Greenwich time in hours; e.g. "+0200"
+	Q - Quarter, as in 1, 2, 3, 4
+	r - RFC 2822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200"
+	s - seconds; i.e. "00" to "59"
+	S - English ordinal suffix for the day of the month, 2 characters;
+	   			i.e. "st", "nd", "rd" or "th"
 	t - number of days in the given month; i.e. "28" to "31"
-	T - Timezone setting of this machine; e.g. "EST" or "MDT" 
-	U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)  
-	w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday) 
-	Y - year, 4 digits; e.g. "1999" 
-	y - year, 2 digits; e.g. "99" 
-	z - day of the year; i.e. "0" to "365" 
-	Z - timezone offset in seconds (i.e. "-43200" to "43200"). 
-	   			The offset for timezones west of UTC is always negative, 
-				and for those east of UTC is always positive. 
+	T - Timezone setting of this machine; e.g. "EST" or "MDT"
+	U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
+	w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
+	Y - year, 4 digits; e.g. "1999"
+	y - year, 2 digits; e.g. "99"
+	z - day of the year; i.e. "0" to "365"
+	Z - timezone offset in seconds (i.e. "-43200" to "43200").
+	   			The offset for timezones west of UTC is always negative,
+				and for those east of UTC is always positive.
 
Unsupported:
-	B - Swatch Internet time 
+	B - Swatch Internet time
 	I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
-	W - ISO-8601 week number of year, weeks starting on Monday 
+	W - ISO-8601 week number of year, weeks starting on Monday
 
 
@@ -138,7 +138,7 @@ Same as adodb_date, but 2nd parameter accepts iso date, eg. adodb_date2('d-M-Y H:i','2003-12-25 13:01:34'); - + ** FUNCTION adodb_gmdate($fmt, $timestamp = false) Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the @@ -163,7 +163,7 @@ Convert a timestamp to a formatted GMT date. ** FUNCTION adodb_strftime($fmt, $timestamp = false) -Convert a timestamp to a formatted local date. Internally converts $fmt into +Convert a timestamp to a formatted local date. Internally converts $fmt into adodb_date format, then echo result. For best results, you can define the local date format yourself. Define a global @@ -171,56 +171,56 @@ variable $ADODB_DATE_LOCALE which is an array, 1st element is date format using adodb_date syntax, and 2nd element is the time format, also in adodb_date syntax. eg. $ADODB_DATE_LOCALE = array('d/m/Y','H:i:s'); - + Supported format codes:
-	%a - abbreviated weekday name according to the current locale 
-	%A - full weekday name according to the current locale 
-	%b - abbreviated month name according to the current locale 
-	%B - full month name according to the current locale 
-	%c - preferred date and time representation for the current locale 
-	%d - day of the month as a decimal number (range 01 to 31) 
-	%D - same as %m/%d/%y 
-	%e - day of the month as a decimal number, a single digit is preceded by a space (range ' 1' to '31') 
+	%a - abbreviated weekday name according to the current locale
+	%A - full weekday name according to the current locale
+	%b - abbreviated month name according to the current locale
+	%B - full month name according to the current locale
+	%c - preferred date and time representation for the current locale
+	%d - day of the month as a decimal number (range 01 to 31)
+	%D - same as %m/%d/%y
+	%e - day of the month as a decimal number, a single digit is preceded by a space (range ' 1' to '31')
 	%h - same as %b
-	%H - hour as a decimal number using a 24-hour clock (range 00 to 23) 
-	%I - hour as a decimal number using a 12-hour clock (range 01 to 12) 
-	%m - month as a decimal number (range 01 to 12) 
-	%M - minute as a decimal number 
-	%n - newline character 
-	%p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale 
-	%r - time in a.m. and p.m. notation 
-	%R - time in 24 hour notation 
-	%S - second as a decimal number 
-	%t - tab character 
-	%T - current time, equal to %H:%M:%S 
-	%x - preferred date representation for the current locale without the time 
-	%X - preferred time representation for the current locale without the date 
-	%y - year as a decimal number without a century (range 00 to 99) 
-	%Y - year as a decimal number including the century 
-	%Z - time zone or name or abbreviation 
-	%% - a literal `%' character 
-
+ %H - hour as a decimal number using a 24-hour clock (range 00 to 23) + %I - hour as a decimal number using a 12-hour clock (range 01 to 12) + %m - month as a decimal number (range 01 to 12) + %M - minute as a decimal number + %n - newline character + %p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale + %r - time in a.m. and p.m. notation + %R - time in 24 hour notation + %S - second as a decimal number + %t - tab character + %T - current time, equal to %H:%M:%S + %x - preferred date representation for the current locale without the time + %X - preferred time representation for the current locale without the date + %y - year as a decimal number without a century (range 00 to 99) + %Y - year as a decimal number including the century + %Z - time zone or name or abbreviation + %% - a literal `%' character +
Unsupported codes:
-	%C - century number (the year divided by 100 and truncated to an integer, range 00 to 99) 
-	%g - like %G, but without the century. 
-	%G - The 4-digit year corresponding to the ISO week number (see %V). 
-	     This has the same format and value as %Y, except that if the ISO week number belongs 
-		 to the previous or next year, that year is used instead. 
-	%j - day of the year as a decimal number (range 001 to 366) 
-	%u - weekday as a decimal number [1,7], with 1 representing Monday 
-	%U - week number of the current year as a decimal number, starting 
-	    with the first Sunday as the first day of the first week 
-	%V - The ISO 8601:1988 week number of the current year as a decimal number, 
-	     range 01 to 53, where week 1 is the first week that has at least 4 days in the 
-		 current year, and with Monday as the first day of the week. (Use %G or %g for 
-		 the year component that corresponds to the week number for the specified timestamp.) 
-	%w - day of the week as a decimal, Sunday being 0 
-	%W - week number of the current year as a decimal number, starting with the 
-	     first Monday as the first day of the first week 
+	%C - century number (the year divided by 100 and truncated to an integer, range 00 to 99)
+	%g - like %G, but without the century.
+	%G - The 4-digit year corresponding to the ISO week number (see %V).
+	     This has the same format and value as %Y, except that if the ISO week number belongs
+		 to the previous or next year, that year is used instead.
+	%j - day of the year as a decimal number (range 001 to 366)
+	%u - weekday as a decimal number [1,7], with 1 representing Monday
+	%U - week number of the current year as a decimal number, starting
+	    with the first Sunday as the first day of the first week
+	%V - The ISO 8601:1988 week number of the current year as a decimal number,
+	     range 01 to 53, where week 1 is the first week that has at least 4 days in the
+		 current year, and with Monday as the first day of the week. (Use %G or %g for
+		 the year component that corresponds to the week number for the specified timestamp.)
+	%w - day of the week as a decimal, Sunday being 0
+	%W - week number of the current year as a decimal number, starting with the
+	     first Monday as the first day of the first week
 
============================================================================= @@ -230,10 +230,10 @@ NOTES Useful url for generating test timestamps: http://www.4webhelp.net/us/timestamp.php -Possible future optimizations include +Possible future optimizations include -a. Using an algorithm similar to Plauger's in "The Standard C Library" -(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not +a. Using an algorithm similar to Plauger's in "The Standard C Library" +(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not work outside 32-bit signed range, so i decided not to implement it. b. Implement daylight savings, which looks awfully complicated, see @@ -246,24 +246,24 @@ CHANGELOG * Bug in 0.32 fix for hour handling. Fixed. - 1 Feb 2008 0.32 -* Now adodb_mktime(0,0,0,12+$m,20,2040) works properly. +* Now adodb_mktime(0,0,0,12+$m,20,2040) works properly. - 10 Jan 2008 0.31 * Now adodb_mktime(0,0,0,24,1,2037) works correctly. - 15 July 2007 0.30 -Added PHP 5.2.0 compatability fixes. +Added PHP 5.2.0 compatability fixes. * gmtime behaviour for 1970 has changed. We use the actual date if it is between 1970 to 2038 to get the * timezone, otherwise we use the current year as the baseline to retrieve the timezone. - * Also the timezone's in php 5.2.* support historical data better, eg. if timezone today was +8, but + * Also the timezone's in php 5.2.* support historical data better, eg. if timezone today was +8, but in 1970 it was +7:30, then php 5.2 return +7:30, while this library will use +8. - * - + * + - 19 March 2006 0.24 Changed strftime() locale detection, because some locales prepend the day of week to the date when %c is used. - 10 Feb 2006 0.23 -PHP5 compat: when we detect PHP5, the RFC2822 format for gmt 0000hrs is changed from -0000 to +0000. +PHP5 compat: when we detect PHP5, the RFC2822 format for gmt 0000hrs is changed from -0000 to +0000. In PHP4, we will still use -0000 for 100% compat with PHP4. - 08 Sept 2005 0.22 @@ -277,7 +277,7 @@ Added support for negative months in adodb_mktime(). Added limited strftime/gmstrftime support. x10 improvement in performance of adodb_date(). - 21 Dec 2004 0.17 -In adodb_getdate(), the timestamp was accidentally converted to gmt when $is_gmt is false. +In adodb_getdate(), the timestamp was accidentally converted to gmt when $is_gmt is false. Also adodb_mktime(0,0,0) did not work properly. Both fixed thx Mauro. - 17 Nov 2004 0.16 @@ -286,7 +286,7 @@ Removed intval typecast in adodb_mktime() for secs, allowing: Suggested by Ryan. - 18 July 2004 0.15 -All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory. +All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory. This brings it more in line with mktime (still not identical). - 23 June 2004 0.14 @@ -304,21 +304,21 @@ function adodb_daylight_sv(&$arr, $is_gmt) if ($m == 6 || $m == 7) $arr['hours'] += 1; } -This is only called by adodb_date() and not by adodb_mktime(). +This is only called by adodb_date() and not by adodb_mktime(). The format of $arr is -Array ( - [seconds] => 0 - [minutes] => 0 - [hours] => 0 +Array ( + [seconds] => 0 + [minutes] => 0 + [hours] => 0 [mday] => 1 # day of month, eg 1st day of the month [mon] => 2 # month (eg. Feb) - [year] => 2102 + [year] => 2102 [yday] => 31 # days in current year [leap] => # true if leap year [ndays] => 28 # no of days in current month - ) - + ) + - 28 Apr 2004 0.13 Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov. @@ -327,11 +327,11 @@ Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov. Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32. - 26 Oct 2003 0.11 -Because of daylight savings problems (some systems apply daylight savings to +Because of daylight savings problems (some systems apply daylight savings to January!!!), changed adodb_get_gmt_diff() to ignore daylight savings. - 9 Aug 2003 0.10 -Fixed bug with dates after 2038. +Fixed bug with dates after 2038. See http://phplens.com/lens/lensforum/msgs.php?id=6980 - 1 July 2003 0.09 @@ -361,14 +361,14 @@ Day overflow for less than one month's days is supported. - 28 Jan 2003 0.04 -Gregorian correction handled. In PHP5, we might throw an error if +Gregorian correction handled. In PHP5, we might throw an error if mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10. Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582. - 27 Jan 2003 0.03 Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION. -Fixed calculation of days since start of year for <1970. +Fixed calculation of days since start of year for <1970. - 27 Jan 2003 0.02 @@ -391,13 +391,13 @@ define('ADODB_DATE_VERSION',0.33); $ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2); /* - This code was originally for windows. But apparently this problem happens + This code was originally for windows. But apparently this problem happens also with Linux, RH 7.3 and later! - + glibc-2.2.5-34 and greater has been changed to return -1 for dates < 1970. This used to work. The problem exists with RedHat 7.3 and 8.0 echo (mktime(0, 0, 0, 1, 1, 1960)); // prints -1 - + References: http://bugs.php.net/bug.php?id=20048&edit=2 http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html @@ -411,7 +411,7 @@ function adodb_date_test_date($y1,$m,$d=13) $t = adodb_mktime($h,0,0,$m,$d,$y1); $rez = adodb_date('Y-n-j H:i:s',$t); if ($h == 0) $h = '00'; - else if ($h < 10) $h = '0'.$h; + else if ($h < 10) $h = '0'.$h; if ("$y1-$m-$d $h:00:00" != $rez) { print "$y1 error, expected=$y1-$m-$d $h:00:00, adodb=$rez
"; return false; @@ -423,74 +423,74 @@ function adodb_date_test_strftime($fmt) { $s1 = strftime($fmt); $s2 = adodb_strftime($fmt); - + if ($s1 == $s2) return true; - + echo "error for $fmt, strftime=$s1, adodb=$s2
"; return false; } /** Test Suite -*/ +*/ function adodb_date_test() { - + for ($m=-24; $m<=24; $m++) echo "$m :",adodb_date('d-m-Y',adodb_mktime(0,0,0,1+$m,20,2040)),"
"; - + error_reporting(E_ALL); print "

Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION.' PHP='.PHP_VERSION."

"; @set_time_limit(0); $fail = false; - + // This flag disables calling of PHP native functions, so we can properly test the code if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1); - + $t = time(); - - + + $fmt = 'Y-m-d H:i:s'; echo '
';
 	echo 'adodb: ',adodb_date($fmt,$t),'
'; echo 'php : ',date($fmt,$t),'
'; echo '
'; - + adodb_date_test_strftime('%Y %m %x %X'); adodb_date_test_strftime("%A %d %B %Y"); adodb_date_test_strftime("%H %M S"); - + $t = adodb_mktime(0,0,0); if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).'
'; - + $t = adodb_mktime(0,0,0,6,1,2102); if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'
'; - + $t = adodb_mktime(0,0,0,2,1,2102); if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).'
'; - - + + print "

Testing gregorian <=> julian conversion

"; $t = adodb_mktime(0,0,0,10,11,1492); //http://www.holidayorigins.com/html/columbus_day.html - Friday check if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing
'; - + $t = adodb_mktime(0,0,0,2,29,1500); if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years
'; - + $t = adodb_mktime(0,0,0,2,29,1700); if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years
'; - + print adodb_mktime(0,0,0,10,4,1582).' '; print adodb_mktime(0,0,0,10,15,1582); $diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)); if ($diff != 3600*24) print " Error in gregorian correction = ".($diff/3600/24)." days
"; - + print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : 'Error')."
"; print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : 'Error')."
"; - + print "

Testing overflow

"; - + $t = adodb_mktime(0,0,0,3,33,1965); if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1
'; $t = adodb_mktime(0,0,0,4,33,1971); @@ -503,7 +503,7 @@ function adodb_date_test() if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).'
'; $t = adodb_mktime(0,0,0,13,3,1965); if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1
'; - + print "Testing 2-digit => 4-digit year conversion

"; if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000
"; if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010
"; @@ -512,10 +512,10 @@ function adodb_date_test() if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940
"; if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950
"; if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990
"; - + // Test string formating print "

Testing date formating

"; - + $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C2822 r s t U w y Y z Z 2003'; $s1 = date($fmt,0); $s2 = adodb_date($fmt,0); @@ -538,12 +538,12 @@ function adodb_date_test() break; } } - print "Error date(): $ts
 
+			print "Error date(): $ts
   \"$s1\" (date len=".strlen($s1).")
   \"$s2\" (adodb_date len=".strlen($s2).")

"; $fail = true; } - + $a1 = getdate($ts); $a2 = adodb_getdate($ts); $rez = array_diff($a1,$a2); @@ -556,7 +556,7 @@ function adodb_date_test() $fail = true; } } - + // Test generation of dates outside 1901-2038 print "

Testing random dates between 100 and 4000

"; adodb_date_test_date(100,1); @@ -564,7 +564,7 @@ function adodb_date_test() $y1 = 100+rand(0,1970-100); $m = rand(1,12); adodb_date_test_date($y1,$m); - + $y1 = 3000-rand(0,3000-1970); adodb_date_test_date($y1,$m); } @@ -575,7 +575,7 @@ function adodb_date_test() $offset = 36000+rand(10000,60000); $max = 365*$yrs*86400; $lastyear = 0; - + // we generate a timestamp, convert it to a date, and convert it back to a timestamp // and check if the roundtrip broke the original timestamp value. print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: "; @@ -602,58 +602,58 @@ function adodb_date_test() } /** - Returns day of week, 0 = Sunday,... 6=Saturday. + Returns day of week, 0 = Sunday,... 6=Saturday. Algorithm from PEAR::Date_Calc */ function adodb_dow($year, $month, $day) { /* -Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and -proclaimed that from that time onwards 3 days would be dropped from the calendar +Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and +proclaimed that from that time onwards 3 days would be dropped from the calendar every 400 years. -Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). +Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). */ if ($year <= 1582) { - if ($year < 1582 || + if ($year < 1582 || ($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3; else $greg_correction = 0; } else $greg_correction = 0; - + if($month > 2) $month -= 2; else { $month += 10; $year--; } - + $day = floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77 + $greg_correction; - + return $day - 7 * floor($day / 7); } /** - Checks for leap year, returns true if it is. No 2-digit year check. Also + Checks for leap year, returns true if it is. No 2-digit year check. Also handles julian calendar correctly. */ -function _adodb_is_leap_year($year) +function _adodb_is_leap_year($year) { if ($year % 4 != 0) return false; - + if ($year % 400 == 0) { return true; // if gregorian calendar (>1582), century not-divisible by 400 is not leap } else if ($year > 1582 && $year % 100 == 0 ) { return false; - } - + } + return true; } @@ -661,7 +661,7 @@ function _adodb_is_leap_year($year) /** checks for leap year, returns true if it is. Has 2-digit year check */ -function adodb_is_leap_year($year) +function adodb_is_leap_year($year) { return _adodb_is_leap_year(adodb_year_digit_check($year)); } @@ -670,13 +670,13 @@ function adodb_is_leap_year($year) Fix 2-digit years. Works for any century. Assumes that if 2-digit is more than 30 years in future, then previous century. */ -function adodb_year_digit_check($y) +function adodb_year_digit_check($y) { if ($y < 100) { - + $yr = (integer) date("Y"); $century = (integer) ($yr /100); - + if ($yr%100 > 50) { $c1 = $century + 1; $c0 = $century; @@ -693,24 +693,24 @@ function adodb_year_digit_check($y) return $y; } -function adodb_get_gmt_diff_ts($ts) +function adodb_get_gmt_diff_ts($ts) { if (0 <= $ts && $ts <= 0x7FFFFFFF) { // check if number in 32-bit signed range) { $arr = getdate($ts); $y = $arr['year']; $m = $arr['mon']; $d = $arr['mday']; - return adodb_get_gmt_diff($y,$m,$d); + return adodb_get_gmt_diff($y,$m,$d); } else { return adodb_get_gmt_diff(false,false,false); } - + } /** get local time zone offset from GMT. Does not handle historical timezones before 1970. */ -function adodb_get_gmt_diff($y,$m,$d) +function adodb_get_gmt_diff($y,$m,$d) { static $TZ,$tzo; global $ADODB_DATETIME_CLASS; @@ -729,9 +729,9 @@ global $ADODB_DATETIME_CLASS; } else { if (isset($TZ)) return $TZ; $y = date('Y'); - $TZ = mktime(0,0,0,12,2,$y,0) - gmmktime(0,0,0,12,2,$y,0); + $TZ = mktime(0,0,0,12,2,$y) - gmmktime(0,0,0,12,2,$y); } - + return $TZ; } @@ -757,7 +757,7 @@ function adodb_date_gentable($out=true) for ($i=1970; $i >= 1600; $i-=10) { $s = adodb_gmmktime(0,0,0,1,1,$i); - echo "$i => $s,
"; + echo "$i => $s,
"; } } adodb_date_gentable(); @@ -773,22 +773,22 @@ echo "
$i "; $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); - + function adodb_validdate($y,$m,$d) { global $_month_table_normal,$_month_table_leaf; if (_adodb_is_leap_year($y)) $marr = $_month_table_leaf; else $marr = $_month_table_normal; - + if ($m > 12 || $m < 1) return false; - + if ($d > 31 || $d < 1) return false; - + if ($marr[$m] < $d) return false; - + if ($y < 1000 && $y > 3000) return false; - + return true; } @@ -806,17 +806,17 @@ global $_month_table_normal,$_month_table_leaf; $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; - - if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction - + + if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction + $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); - + $d366 = $_day_power * 366; $d365 = $_day_power * 365; - + if ($d < 0) { - + if (empty($YRS)) $YRS = array( 1970 => 0, 1960 => -315619200, @@ -858,28 +858,28 @@ global $_month_table_normal,$_month_table_leaf; 1600 => -11676096000); if ($is_gmt) $origd = $d; - // The valid range of a 32bit signed timestamp is typically from + // The valid range of a 32bit signed timestamp is typically from // Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT // - + # old algorithm iterates through all years. new algorithm does it in # 10 year blocks - + /* # old algo for ($a = 1970 ; --$a >= 0;) { $lastd = $d; - + if ($leaf = _adodb_is_leap_year($a)) $d += $d366; else $d += $d365; - + if ($d >= 0) { $year = $a; break; } } */ - + $lastsecs = 0; $lastyear = 1970; foreach($YRS as $year => $secs) { @@ -890,27 +890,27 @@ global $_month_table_normal,$_month_table_leaf; $lastsecs = $secs; $lastyear = $year; } - + $d -= $lastsecs; if (!isset($a)) $a = $lastyear; - + //echo ' yr=',$a,' ', $d,'.'; - + for (; --$a >= 0;) { $lastd = $d; - + if ($leaf = _adodb_is_leap_year($a)) $d += $d366; else $d += $d365; - + if ($d >= 0) { $year = $a; break; } } /**/ - + $secsInYear = 86400 * ($leaf ? 366 : 365) + $lastd; - + $d = $lastd; $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal; for ($a = 13 ; --$a > 0;) { @@ -922,17 +922,17 @@ global $_month_table_normal,$_month_table_leaf; break; } } - + $d = $lastd; $day = $ndays + ceil(($d+1) / ($_day_power)); $d += ($ndays - $day+1)* $_day_power; $hour = floor($d/$_hour_power); - + } else { for ($a = 1970 ;; $a++) { $lastd = $d; - + if ($leaf = _adodb_is_leap_year($a)) $d -= $d366; else $d -= $d365; if ($d < 0) { @@ -957,7 +957,7 @@ global $_month_table_normal,$_month_table_leaf; $d = $d - ($day-1) * $_day_power; $hour = floor($d /$_hour_power); } - + $d -= $hour * $_hour_power; $min = floor($d/$_min_power); $secs = $d - $min * $_min_power; @@ -974,8 +974,8 @@ global $_month_table_normal,$_month_table_leaf; 'ndays' => $ndays ); } - - + + $dow = adodb_dow($year,$month,$day); return array( @@ -994,18 +994,18 @@ global $_month_table_normal,$_month_table_leaf; } /* if ($isphp5) - $dates .= sprintf('%s%04d',($gmt<=0)?'+':'-',abs($gmt)/36); + $dates .= sprintf('%s%04d',($gmt<=0)?'+':'-',abs($gmt)/36); else - $dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); + $dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;*/ function adodb_tz_offset($gmt,$isphp5) { $zhrs = abs($gmt)/3600; $hrs = floor($zhrs); - if ($isphp5) - return sprintf('%s%02d%02d',($gmt<=0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); + if ($isphp5) + return sprintf('%s%02d%02d',($gmt<=0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); else - return sprintf('%s%02d%02d',($gmt<0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); + return sprintf('%s%02d%02d',($gmt<0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); break; } @@ -1019,17 +1019,17 @@ function adodb_gmdate($fmt,$d=false) function adodb_date2($fmt, $d=false, $is_gmt=false) { if ($d !== false) { - if (!preg_match( - "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", ($d), $rr)) return adodb_date($fmt,false,$is_gmt); if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt); - + // h-m-s-MM-DD-YY if (!isset($rr[5])) $d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1],false,$is_gmt); else $d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1],false,$is_gmt); } - + return adodb_date($fmt,$d,$is_gmt); } @@ -1051,31 +1051,31 @@ global $ADODB_DATETIME_CLASS; } } $_day_power = 86400; - + $arr = _adodb_getdate($d,true,$is_gmt); - + if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv'); if ($daylight) adodb_daylight_sv($arr, $is_gmt); - + $year = $arr['year']; $month = $arr['mon']; $day = $arr['mday']; $hour = $arr['hours']; $min = $arr['minutes']; $secs = $arr['seconds']; - + $max = strlen($fmt); $dates = ''; - + $isphp5 = PHP_VERSION >= 5; - + /* at this point, we have the following integer vars to manipulate: $year, $month, $day, $hour, $min, $secs */ for ($i=0; $i < $max; $i++) { switch($fmt[$i]) { - case 'T': + case 'T': if ($ADODB_DATETIME_CLASS) { $dt = new DateTime(); $dt->SetDate($year,$month,$day); @@ -1086,23 +1086,23 @@ global $ADODB_DATETIME_CLASS; // YEAR case 'L': $dates .= $arr['leap'] ? '1' : '0'; break; case 'r': // Thu, 21 Dec 2000 16:01:07 +0200 - + // 4.3.11 uses '04 Jun 2004' // 4.3.8 uses ' 4 Jun 2004' - $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', ' + $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', ' . ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' '; - - if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; - + + if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; + if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min; - + if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs; - + $gmt = adodb_get_gmt_diff($year,$month,$day); - + $dates .= ' '.adodb_tz_offset($gmt,$isphp5); break; - + case 'Y': $dates .= $year; break; case 'y': $dates .= substr($year,strlen($year)-2,2); break; // MONTH @@ -1119,47 +1119,47 @@ global $ADODB_DATETIME_CLASS; case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break; case 'j': $dates .= $day; break; case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break; - case 'S': + case 'S': $d10 = $day % 10; if ($d10 == 1) $dates .= 'st'; else if ($d10 == 2 && $day != 12) $dates .= 'nd'; else if ($d10 == 3) $dates .= 'rd'; else $dates .= 'th'; break; - + // HOUR case 'Z': $dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff($year,$month,$day); break; - case 'O': + case 'O': $gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff($year,$month,$day); - + $dates .= adodb_tz_offset($gmt,$isphp5); break; - - case 'H': - if ($hour < 10) $dates .= '0'.$hour; - else $dates .= $hour; + + case 'H': + if ($hour < 10) $dates .= '0'.$hour; + else $dates .= $hour; break; - case 'h': - if ($hour > 12) $hh = $hour - 12; + case 'h': + if ($hour > 12) $hh = $hour - 12; else { - if ($hour == 0) $hh = '12'; + if ($hour == 0) $hh = '12'; else $hh = $hour; } - + if ($hh < 10) $dates .= '0'.$hh; else $dates .= $hh; break; - - case 'G': + + case 'G': $dates .= $hour; break; - + case 'g': - if ($hour > 12) $hh = $hour - 12; + if ($hour > 12) $hh = $hour - 12; else { - if ($hour == 0) $hh = '12'; - else $hh = $hour; + if ($hour == 0) $hh = '12'; + else $hh = $hour; } $dates .= $hh; break; @@ -1181,7 +1181,7 @@ global $ADODB_DATETIME_CLASS; default: $dates .= $fmt[$i]; break; // ESCAPE - case "\\": + case "\\": $i++; if ($i < $max) $dates .= $fmt[$i]; break; @@ -1191,7 +1191,7 @@ global $ADODB_DATETIME_CLASS; } /** - Returns a timestamp given a GMT/UTC time. + Returns a timestamp given a GMT/UTC time. Note that $is_dst is not implemented and is ignored. */ function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false) @@ -1202,33 +1202,33 @@ function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst= /** Return a timestamp given a local time. Originally by jackbbs. Note that $is_dst is not implemented and is ignored. - + Not a very fast algorithm - O(n) operation. Could be optimized to O(1). */ -function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false) +function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false) { if (!defined('ADODB_TEST_DATES')) { if ($mon === false) { return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec); } - - // for windows, we don't check 1970 because with timezone differences, + + // for windows, we don't check 1970 because with timezone differences, // 1 Jan 1970 could generate negative timestamp, which is illegal $usephpfns = (1971 < $year && $year < 2038 || !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038) - ); - - + ); + + if ($usephpfns && ($year + $mon/12+$day/365.25+$hr/(24*365.25) >= 2038)) $usephpfns = false; - + if ($usephpfns) { return $is_gmt ? @gmmktime($hr,$min,$sec,$mon,$day,$year): @mktime($hr,$min,$sec,$mon,$day,$year); } } - + $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff($year,$mon,$day); /* @@ -1241,8 +1241,8 @@ function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=fa $mon = intval($mon); $day = intval($day); $year = intval($year); - - + + $year = adodb_year_digit_check($year); if ($mon > 12) { @@ -1254,14 +1254,14 @@ function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=fa $year -= $y; $mon += $y*12; } - + $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; - + $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); - + $_total_date = 0; if ($year >= 1970) { for ($a = 1970 ; $a <= $year; $a++) { @@ -1273,7 +1273,7 @@ function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=fa $loop_table = $_month_table_normal; $_add_date = 365; } - if ($a < $year) { + if ($a < $year) { $_total_date += $_add_date; } else { for($b=1;$b<$mon;$b++) { @@ -1283,7 +1283,7 @@ function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=fa } $_total_date +=$day-1; $ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different; - + } else { for ($a = 1969 ; $a >= $year; $a--) { $leaf = _adodb_is_leap_year($a); @@ -1302,13 +1302,13 @@ function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=fa } } $_total_date += $loop_table[$mon] - $day; - + $_day_time = $hr * $_hour_power + $min * $_min_power + $sec; $_day_time = $_day_power - $_day_time; $ret = -( $_total_date * $_day_power + $_day_time - $gmt_different); if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582. - } + } //print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret; return $ret; } @@ -1330,7 +1330,7 @@ global $ADODB_DATE_LOCALE; } } - + if (empty($ADODB_DATE_LOCALE)) { /* $tstr = strtoupper(gmstrftime('%c',31366800)); // 30 Dec 1970, 1 am @@ -1342,11 +1342,11 @@ global $ADODB_DATE_LOCALE; $sep = substr($dstr,2,1); $tstr = strtoupper(gmstrftime('%X',31366800)); // 30 Dec 1970, 1 am $hasAM = strrpos($tstr,'M') !== false; - + $ADODB_DATE_LOCALE = array(); - $ADODB_DATE_LOCALE[] = strncmp($tstr,'30',2) == 0 ? 'd'.$sep.'m'.$sep.'y' : 'm'.$sep.'d'.$sep.'y'; + $ADODB_DATE_LOCALE[] = strncmp($tstr,'30',2) == 0 ? 'd'.$sep.'m'.$sep.'y' : 'm'.$sep.'d'.$sep.'y'; $ADODB_DATE_LOCALE[] = ($hasAM) ? 'h:i:s a' : 'H:i:s'; - + } $inpct = false; $fmtdate = ''; @@ -1359,7 +1359,7 @@ global $ADODB_DATE_LOCALE; } else $inpct = true; } else if ($inpct) { - + $inpct = false; switch($ch) { case '0': @@ -1375,9 +1375,9 @@ global $ADODB_DATE_LOCALE; case 'E': case 'O': /* ignore format modifiers */ - $inpct = true; + $inpct = true; break; - + case 'a': $fmtdate .= 'D'; break; case 'A': $fmtdate .= 'l'; break; case 'h': diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 948f200349c..e1cb471b58d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -447,6 +447,9 @@ if (! defined('NOLOGIN')) $dol_authmode=$conf->authmode; // This properties is defined only when logged, to say what mode was successfully used $dol_tz=$_POST["tz"]; $dol_tz_string=$_POST["tz_string"]; + $dol_tz_string=preg_replace('\s*\(.+\)$','',$dol_tz_string); + $dol_tz_string=preg_replace(',','/',$dol_tz_string); + $dol_tz_string=preg_replace('\s','_',$dol_tz_string); $dol_dst=0; if (isset($_POST["dst_first"]) && isset($_POST["dst_second"])) { From 105e7189ecd2e5abbbb3454d5fbca97b19dd8880 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Jul 2014 13:08:31 +0200 Subject: [PATCH 20/21] Add -p on phpcs to avoid timeout --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4de657bbe31..2366201ce2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -97,9 +97,9 @@ script: # - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml --coverage-text test/phpunit/AllTests.php # - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml --coverage-text test/phpunit/BuildDocTest.php # - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/WebservicesOtherTest.php -# - phpcs --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ htdocs/core/class/dolgraph.class.php - - phpcs --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ . -# - phpcs --warning-severity=0 -s --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ . +# - phpcs -p --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ htdocs/core/class/dolgraph.class.php + - phpcs -p --warning-severity=0 -s --report-checkstyle --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ . +# - phpcs -p --warning-severity=0 -s --report-summary --standard=dev/codesniffer/ruleset.xml --tab-width=4 --ignore=/build/html/,/documents/,/includes/,/test/report/ . - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php after_script: From cdfe8818da728aa7a81fed118e54a79cd42af26a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 4 Jul 2014 13:16:48 +0200 Subject: [PATCH 21/21] avoid message Delimiter must not be alphanumeric or backslash in /home/bobby/Eclipse/workspace/dolibarr/htdocs/main.inc.php on line 450 on preg_replace --- htdocs/main.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e1cb471b58d..c24f9fc2036 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -447,9 +447,9 @@ if (! defined('NOLOGIN')) $dol_authmode=$conf->authmode; // This properties is defined only when logged, to say what mode was successfully used $dol_tz=$_POST["tz"]; $dol_tz_string=$_POST["tz_string"]; - $dol_tz_string=preg_replace('\s*\(.+\)$','',$dol_tz_string); - $dol_tz_string=preg_replace(',','/',$dol_tz_string); - $dol_tz_string=preg_replace('\s','_',$dol_tz_string); + $dol_tz_string=preg_replace('/\s*\(.+\)$/','',$dol_tz_string); + $dol_tz_string=preg_replace('/,/' ,'/',$dol_tz_string); + $dol_tz_string=preg_replace('/\s/','_',$dol_tz_string); $dol_dst=0; if (isset($_POST["dst_first"]) && isset($_POST["dst_second"])) {