From 4fd00c50be31aa69fe4c984882180f1d7fec5ed1 Mon Sep 17 00:00:00 2001 From: FHenry Date: Fri, 27 Apr 2012 10:32:01 +0200 Subject: [PATCH 1/5] Feature Clone project (357) Fix variable date property name, to be compliant with varaible naming convention (create) Add feature to shift task date when change project start date (option) Add project start/end date on Project->Task View --- htdocs/langs/en_US/projects.lang | 4 ++++ htdocs/langs/fr_FR/projects.lang | 4 ++++ htdocs/projet/class/project.class.php | 4 ++-- htdocs/projet/class/task.class.php | 5 +++-- htdocs/projet/fiche.php | 32 ++++++++++++++++++++++----- htdocs/projet/tasks/document.php | 4 +--- 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index ead787d3d84..75082f8012c 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -85,6 +85,10 @@ TaskIsNotAffectedToYou=Task not allocated to you ErrorTimeSpentIsEmpty=Time spent is empty ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (%s tasks at the moment) and all inputs of time spent. IfNeedToUseOhterObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties. +CloneProject=Clone project (associated task will be duplicated too) +ConfirmCloneProject=Are you sure to clone this project ? +ProjectReportDate=Change task date according project start date +ErrorShiftTaskDate=Impossible to shift task date according to new project start date ##### Types de contacts ##### TypeContact_project_internal_PROJECTLEADER=Project leader TypeContact_project_external_PROJECTLEADER=Project leader diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 6722ac6bb1d..0c3a21e4cdb 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -85,6 +85,10 @@ TaskIsNotAffectedToYou=Tâche qui ne vous est pas affectée ErrorTimeSpentIsEmpty=Le temps consommé n'est pas renseigné ThisWillAlsoRemoveTasks=Cette opération détruira également les tâches du projet (%s tâches actuellement) et le suivi des consommés. IfNeedToUseOhterObjectKeepEmpty=Si des objets (facture, commande, ...), appartenant à un autre tiers que celui choisi, doivent être liés au projet à créer, laisser vide afin de laisser le projet multi-tiers. +CloneProject=Cloner le projet (les taches associées sont dupliquées également) +ConfirmCloneProject=Êtes-vous sûr de vouloir cloner ce projet ? +ProjectReportDate=Reporter les dates des taches en fonction de la date de départ. +ErrorShiftTaskDate=Une erreur c'est produite dans le report des dates des taches. ##### Types de contacts ##### TypeContact_project_internal_PROJECTLEADER=Chef de projet TypeContact_project_external_PROJECTLEADER=Chef de projet diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 435c59d395d..d838f61b869 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -52,7 +52,7 @@ class Project extends CommonObject /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $DB Database handler */ function __construct($db) { @@ -707,7 +707,7 @@ class Project extends CommonObject { global $user, $langs, $conf; - $now = dol_now(); + $now = mktime(); // Charge tableau des produits prodids $prodids = array(); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 6aefb92ec6c..b93598b600f 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -64,7 +64,7 @@ class Task extends CommonObject /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $DB Database handler */ function __construct($db) { @@ -305,6 +305,7 @@ class Task extends CommonObject */ function delete($user, $notrigger=0) { + global $conf, $langs; $error=0; @@ -391,7 +392,7 @@ class Task extends CommonObject $this->db->commit(); - return 1; + return 1; } } diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index f84dca56cbe..e57f24c5878 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -117,7 +117,6 @@ if ($action == 'add' && $user->rights->projet->creer) $db->begin(); $project = new Project($db); - $project->ref = GETPOST('ref','alpha'); $project->title = GETPOST('title','alpha'); $project->socid = GETPOST('socid','int'); @@ -246,6 +245,7 @@ if ($action == 'builddoc' && $user->rights->projet->creer) } } + if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes') { $project = new Project($db); @@ -315,6 +315,24 @@ if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confi } } +if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes') +{ + $idtoclone=$id; + $project = new Project($db); + $project->fetch($idtoclone); + $result=$project->createFromClone($idtoclone,true,true,true,true); + if ($result <= 0) + { + $mesg='
'.$project->error.'
'; + } + else + { + $id=$result; + $action='edit'; + $comefromclone=true; + } +} + /* * View @@ -353,7 +371,7 @@ if ($action == 'create' && $user->rights->projet->creer) { require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php"); $modProject = new $obj; - $defaultref = $modProject->getNextValue($soc,$project); + $defaultref = $modProject->getNextValue($soc,$project); } if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; @@ -459,7 +477,11 @@ else $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$text,"confirm_delete",'','',1); if ($ret == 'html') print '
'; } +<<<<<<< OURS // Clone confirmation +======= + // Clone confirmation +>>>>>>> THEIRS if ($action == 'clone') { $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloneProject"),$langs->trans("ConfirmCloneProject"),"confirm_clone",'','',1); @@ -486,9 +508,7 @@ else // Customer print ''.$langs->trans("Company").''; - $text=$form->select_company($project->societe->id,'socid','',1,1); - $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty"); - print $form->textwithtooltip($text.' '.img_help(),$texthelp,1); + print $form->select_company($project->societe->id,'socid','',1,1); print ''; // Visibility @@ -562,7 +582,7 @@ else // Date start print ''.$langs->trans("DateStart").''; - print dol_print_date($project->date_start,'day'); + print dol_print_date($project->date_start,'day'); print ''; // Date end diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 8762f3cf271..ae5ce5a0b9c 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -125,7 +125,6 @@ if (! empty($project_ref) && ! empty($withproject)) } } -// Find upload dir after retreive is task if necessary if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) @@ -141,7 +140,6 @@ if ($id > 0 || ! empty($ref)) dol_print_error($db); } } - /* * View */ @@ -283,4 +281,4 @@ else llxFooter(); $db->close(); -?> \ No newline at end of file +?> From 7aada2c44264e37531fda24ed07225054a71f4ad Mon Sep 17 00:00:00 2001 From: FHenry Date: Fri, 27 Apr 2012 10:54:18 +0200 Subject: [PATCH 2/5] correct debug code and alfa --- htdocs/projet/fiche.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index e57f24c5878..8b0146a08f1 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -117,6 +117,7 @@ if ($action == 'add' && $user->rights->projet->creer) $db->begin(); $project = new Project($db); + $project->ref = GETPOST('ref','alpha'); $project->title = GETPOST('title','alpha'); $project->socid = GETPOST('socid','int'); @@ -477,11 +478,8 @@ else $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$text,"confirm_delete",'','',1); if ($ret == 'html') print '
'; } -<<<<<<< OURS + // Clone confirmation -======= - // Clone confirmation ->>>>>>> THEIRS if ($action == 'clone') { $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloneProject"),$langs->trans("ConfirmCloneProject"),"confirm_clone",'','',1); From dc42e16ff1f079ba134fb3486c683a20698195be Mon Sep 17 00:00:00 2001 From: FHenry Date: Mon, 30 Apr 2012 13:49:29 +0200 Subject: [PATCH 3/5] Secure URL use to CheckRead and Unsubcribe with security key in configuration screen --- htdocs/admin/mailing.php | 44 ++++++++++++++++--- htdocs/comm/mailing/fiche.php | 4 +- .../modules/mailings/modules_mailings.php | 7 ++- htdocs/langs/en_US/mails.lang | 1 + htdocs/langs/fr_FR/mails.lang | 1 + 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index a0f0f095019..bab078a418c 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -34,6 +34,8 @@ if (!$user->admin) $action = GETPOST('action','alpha'); + + /* * Actions */ @@ -45,13 +47,36 @@ if ($action == 'setvalue' && $user->admin) $mailfrom = GETPOST('MAILING_EMAIL_FROM','alpha'); $mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha'); $checkread = GETPOST('value','alpha'); + $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha'); + + $res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; $res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; - //$res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",$checkread,'chaine',0,'',$conf->entity); - //if (! $res > 0) $error++; + if ($checkread=='on') + { + $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",1,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + else if ($checkread=='off') + { + $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",0,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + + //Create temporary encryption key if nedded + if (($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1) && (empty($checkread_key))) + { + $chars = "abcdef(ghijklmnopqrstuvwxyz;!ABCDEFGH,IJKLMNOPQRSTUVWXYZ01_23456789"; + mt_srand(10000000*(double)microtime()); + for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < 30; $i++) { + $checkread_key .= $chars[mt_rand(0, $lc)]; + } + } + $res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY",$checkread_key,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; if (! $error) { @@ -104,24 +129,31 @@ print ''; -/* + $var=!$var; print ''; print $langs->trans("ActivateCheckRead").''; if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1) { - print ''; + print ''; print img_picto($langs->trans("Enabled"),'switch_on'); print ''; + $readonly=''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"),'switch_off'); print ''; + $readonly='disabled="disabled"'; } print ''; -*/ + +$var=!$var; +print ''; +print $langs->trans("ActivateCheckReadKey").''; +print ''; +print ''; print ''; diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index bcea8ad2a22..b2f875583f4 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -64,7 +64,7 @@ if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE) $substitutionarray, array( '__CHECK_READ__' => 'CheckMail', - '__UNSUSCRIBE__' => 'Unsuscribe' + '__UNSUSCRIBE__' => 'Unsubscribe' ) ); } @@ -89,7 +89,7 @@ if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE) $substitutionarrayfortest, array( '__CHECK_READ__' => 'TESTCheckMail', - '__UNSUSCRIBE__' => 'TESTCheckMail' + '__UNSUSCRIBE__' => 'TESTUnsubscribe' ) ); } diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 75032bbab9e..53729e812e3 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -143,6 +143,8 @@ class MailingTargets // This can't be abstract as it is used for some method */ function add_to_target($mailing_id, $cibles) { + global $conf; + $this->db->begin(); // Insert emailing targest from array into database @@ -162,7 +164,10 @@ class MailingTargets // This can't be abstract as it is used for some method $sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; - $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id))."',"; + if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1) + { + $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; + } $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; $result=$this->db->query($sql); if ($result) diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index d5deed6ec64..a252859f964 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -77,6 +77,7 @@ CheckRead=Read Receipt YourMailUnsubcribeOK=The email %s is correctly unsubcribe from mailing list MailtoEMail=Hyper link to email ActivateCheckRead=Activate Read receipt and unsubcribe tag +ActivateCheckReadKey=Key use to encrypt URL use for Read Receipt and unsubcribe function # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Contacts of all third parties (customer, prospect, supplier, ...) diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 45b5dd24263..11b0aa4e0e1 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -77,6 +77,7 @@ CheckRead=Accusé de lecture YourMailUnsubcribeOK=L'adresse e-mail %s est bien désincrite de la liste. MailtoEMail=Ecrire a e-mail (lien) ActivateCheckRead=Activer les tags d'accusé de lecture et de désincription +ActivateCheckReadKey=Clef de sécurité utilisée pour l'encryption des URL utilisées dans les fonctions d'accusé de lecture et de désincription # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Contacts de tiers (prospects, clients, fournisseurs...) From fca02bf91847a10b6912853a13d5d8e63be6516d Mon Sep 17 00:00:00 2001 From: FHenry Date: Mon, 30 Apr 2012 13:53:16 +0200 Subject: [PATCH 4/5] Remove space --- htdocs/admin/mailing.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index bab078a418c..da844ed9934 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -49,8 +49,6 @@ if ($action == 'setvalue' && $user->admin) $checkread = GETPOST('value','alpha'); $checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha'); - - $res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; $res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity); From 73487a6aec48e39fa65db7e9fb62541a72e7ebd3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 30 Apr 2012 15:01:25 +0200 Subject: [PATCH 5/5] Fix: replace mktime() by dol_now() --- htdocs/accountancy/class/accountancysystem.class.php | 4 +++- htdocs/adherents/card_subscriptions.php | 4 ++-- htdocs/adherents/class/adherent.class.php | 3 ++- htdocs/adherents/class/cotisation.class.php | 5 ++++- htdocs/adherents/htpasswd.php | 4 +++- htdocs/adherents/type.php | 6 ++++-- htdocs/boutique/index.php | 4 +++- htdocs/boutique/promotion/class/promotion.class.php | 6 ++++-- htdocs/comm/index.php | 3 ++- htdocs/comm/mailing/class/mailing.class.php | 4 +++- htdocs/comm/propal/class/propal.class.php | 6 ++++-- htdocs/compta/bank/rappro.php | 5 +++-- htdocs/compta/facture/class/facture-rec.class.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 4 +++- htdocs/compta/facture/impayees.php | 3 ++- htdocs/compta/index.php | 4 +++- .../compta/prelevement/class/bon-prelevement.class.php | 10 +++++++--- .../prelevement/class/rejet-prelevement.class.php | 3 ++- htdocs/compta/stats/index.php | 5 +++-- htdocs/contrat/class/contrat.class.php | 6 ++++-- htdocs/contrat/fiche.php | 2 +- htdocs/core/class/notify.class.php | 3 ++- htdocs/core/datepicker.php | 2 +- htdocs/core/lib/functions.lib.php | 3 ++- htdocs/core/lib/functions2.lib.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 4 +++- htdocs/fichinter/fiche.php | 3 ++- htdocs/fourn/class/paiementfourn.class.php | 4 +++- htdocs/livraison/class/livraison.class.php | 4 +++- htdocs/product/class/product.class.php | 6 ++++-- htdocs/projet/class/project.class.php | 2 +- htdocs/projet/class/task.class.php | 6 ++++-- htdocs/societe/class/address.class.php | 4 +++- htdocs/societe/class/societe.class.php | 4 +++- 34 files changed, 96 insertions(+), 45 deletions(-) diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 0dbad6754b1..2c278030a62 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -58,9 +58,11 @@ class AccountancySystem */ function create($user) { + $now=dol_now(); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingsystem"; $sql.= " (date_creation, fk_user_author, numero,intitule)"; - $sql.= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')"; + $sql.= " VALUES (".$this->db->idate($now).",".$user->id.",'".$this->numero."','".$this->intitule."')"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index d7b4390890e..e5aae08ca3c 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -816,7 +816,7 @@ if ($rowid) print ''; print "\n"; - $today=mktime(); + $today=dol_now(); $datefrom=0; $dateto=0; $paymentdate=-1; @@ -841,7 +841,7 @@ if ($rowid) } else { - $datefrom=mktime(); + $datefrom=dol_now(); } } $form->select_date($datefrom,'','','','',"cotisation"); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index da6bc37bd87..b841ff04419 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1250,6 +1250,7 @@ class Adherent extends CommonObject global $langs,$conf; $error=0; + $now=dol_now(); // Check parameters if ($this->statut == 1) @@ -1262,7 +1263,7 @@ class Adherent extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql.= " statut = 1"; - $sql.= ", datevalid = ".$this->db->idate(mktime()); + $sql.= ", datevalid = ".$this->db->idate($now); $sql.= ", fk_user_valid=".$user->id; $sql.= " WHERE rowid = ".$this->id; diff --git a/htdocs/adherents/class/cotisation.class.php b/htdocs/adherents/class/cotisation.class.php index f53eb509657..4a07b5dd9c9 100644 --- a/htdocs/adherents/class/cotisation.class.php +++ b/htdocs/adherents/class/cotisation.class.php @@ -65,6 +65,9 @@ class Cotisation extends CommonObject function create($userid) { global $langs; + + $now=dol_now(); + // Check parameters if ($this->datef <= $this->dateh) { @@ -73,7 +76,7 @@ class Cotisation extends CommonObject } $sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, datef, cotisation, note)"; - $sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate(mktime())."',"; + $sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->dateh)."',"; $sql.= " '".$this->db->idate($this->datef)."',"; $sql.= " ".$this->amount.",'".$this->db->escape($this->note)."')"; diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index e2f2bacc853..02c505ebfb0 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -37,6 +37,8 @@ if (! $user->rights->adherent->export) accessforbidden(); llxHeader(); +$now=dol_now(); + if ($sortorder == "") { $sortorder="ASC"; } if ($sortfield == "") { $sortfield="d.login"; } if (! isset($statut)) @@ -56,7 +58,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d "; $sql .= " WHERE d.statut = $statut "; if ($cotis==1) { - $sql .= " AND datefin > '".$db->idate(mktime())."'"; + $sql .= " AND datefin > '".$db->idate($now)."'"; } $sql.= $db->order($sortfield,$sortorder); //$sql.=$db->plimit($conf->liste_limit, $offset); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index eb93f7d44a3..16203fecde3 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -336,6 +336,8 @@ if ($rowid > 0) // Show list of members (nearly same code than in page liste.php) $membertypestatic=new AdherentType($db); + + $now=dol_now(); $sql = "SELECT d.rowid, d.login, d.prenom as firstname, d.nom as lastname, d.societe, "; $sql.= " d.datefin,"; @@ -376,11 +378,11 @@ if ($rowid > 0) } if ($filter == 'uptodate') { - $sql.=" AND datefin >= ".$db->idate(mktime()); + $sql.=" AND datefin >= ".$db->idate($now); } if ($filter == 'outofdate') { - $sql.=" AND datefin < ".$db->idate(mktime()); + $sql.=" AND datefin < ".$db->idate($now); } // Count total nb of records $nbtotalofrecords = 0; diff --git a/htdocs/boutique/index.php b/htdocs/boutique/index.php index b3391f05d91..e44533e007e 100644 --- a/htdocs/boutique/index.php +++ b/htdocs/boutique/index.php @@ -49,10 +49,12 @@ print '
'; print ''; print ''; +$now=dol_now(); + $sql = "SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois"; $sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders_total as t"; $sql .= " JOIN ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders as o ON o.orders_id = t.orders_id"; -$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(".$dbosc->idate(mktime()).")"; +$sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(".$dbosc->idate($now).")"; $sql .= " GROUP BY mois ORDER BY mois"; $result=$dbosc->query($sql); diff --git a/htdocs/boutique/promotion/class/promotion.class.php b/htdocs/boutique/promotion/class/promotion.class.php index 5ee5a743a3f..5631f30207c 100644 --- a/htdocs/boutique/promotion/class/promotion.class.php +++ b/htdocs/boutique/promotion/class/promotion.class.php @@ -73,11 +73,13 @@ class Promotion $newprice = $percent * $this->price_init; - $date_exp = "2003-05-01"; + $date_exp = "2003-05-01"; // TODO ???? + + $now=dol_now(); $sql = "INSERT INTO ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."specials "; $sql .= " (products_id, specials_new_products_price, specials_date_added, specials_last_modified, expires_date, date_status_change, status) "; - $sql .= " VALUES ($pid, $newprice, '".$this->db->idate(mktime())."', NULL, '".$this->db->idate(mktime()+3600*24*365)."', NULL, 1)"; + $sql .= " VALUES ($pid, $newprice, '".$this->db->idate($now)."', NULL, '".$this->db->idate($now+3600*24*365)."', NULL, 1)"; if ($this->db->query($sql) ) { diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index accc3314bd0..14545c7ae84 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -46,6 +46,7 @@ if ($user->societe_id > 0) } $max=5; +$now=dol_now(); /* * Actions @@ -58,7 +59,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark') { dol_print_error($db); } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$_GET["socid"].", ".$db->idate(mktime()).",".$user->id.");"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$_GET["socid"].", ".$db->idate($now).",".$user->id.");"; if (! $db->query($sql) ) { dol_print_error($db); diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 44aaea758a2..9df558ac901 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -95,10 +95,12 @@ class Mailing extends CommonObject $this->error = $langs->trans("ErrorMailFromRequired"); return -1; } + + $now=dol_now(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing"; $sql .= " (date_creat, fk_user_creat, entity)"; - $sql .= " VALUES (".$this->db->idate(mktime()).", ".$user->id.", ".$conf->entity.")"; + $sql .= " VALUES (".$this->db->idate($now).", ".$user->id.", ".$conf->entity.")"; if (! $this->titre) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9d20775a287..d5a0afc3043 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1468,11 +1468,12 @@ class Propal extends CommonObject $this->statut = $statut; $error=0; + $now=dol_now(); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate(mktime()).", fk_user_cloture=".$user->id; + $sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate($now).", fk_user_cloture=".$user->id; $sql.= " WHERE rowid = ".$this->id; $resql=$this->db->query($sql); @@ -1497,11 +1498,12 @@ class Propal extends CommonObject $this->statut = $statut; $error=0; + $now=dol_now(); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate(mktime()).", fk_user_cloture=".$user->id; + $sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate($now).", fk_user_cloture=".$user->id; $sql.= " WHERE rowid = ".$this->id; $resql=$this->db->query($sql); diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index dd7f10677c8..bd7926bfeac 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -380,8 +380,9 @@ if ($resql) print ''; print img_edit(); print '  '; - - if ($db->jdate($objp->do) <= mktime()) { + + $now=dol_now(); + if ($db->jdate($objp->do) <= $now) { print ''; print img_delete(); print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 6a976f9ea4a..df946ca345d 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -88,6 +88,7 @@ class FactureRec extends Facture global $conf, $langs; $error=0; + $now=dol_now(); // Clean parameters $this->titre=trim($this->titre); @@ -125,7 +126,7 @@ class FactureRec extends Facture $sql.= "'".$this->titre."'"; $sql.= ", '".$facsrc->socid."'"; $sql.= ", ".$conf->entity; - $sql.= ", ".$this->db->idate(mktime()); + $sql.= ", ".$this->db->idate($now); $sql.= ", '".$facsrc->amount."'"; $sql.= ", '".$facsrc->remise."'"; $sql.= ", '".$this->db->escape($this->note)."'"; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 27dca55e1e4..1efc6c41d10 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2897,11 +2897,13 @@ class Facture extends CommonObject $row = $this->db->fetch_row($resql); if ($row[0] == 0) { + $now=dol_now(); + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande'; $sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)'; $sql .= ' VALUES ('.$this->id; $sql .= ",'".price2num($this->total_ttc)."'"; - $sql .= ",".$this->db->idate(mktime()).",".$user->id; + $sql .= ",".$this->db->idate($now).",".$user->id; $sql .= ",'".$soc->bank_account->code_banque."'"; $sql .= ",'".$soc->bank_account->code_guichet."'"; $sql .= ",'".$soc->bank_account->number."'"; diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index 24bf6de375e..272096348f9 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -112,7 +112,8 @@ if ($action == "builddoc" && $user->rights->facture->lire) if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); if ($pagecount) { - $file=$diroutputpdf.'/'.$filename.'_'.dol_print_date(mktime(),'dayhourlog').'.pdf'; + $now=dol_now(); + $file=$diroutputpdf.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; $pdf->Output($file,'F'); if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index bd40daa6780..872f5474da6 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -57,12 +57,14 @@ if ($user->societe_id > 0) if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark') { + $now=dol_now(); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socid." AND fk_user=".$user->id; if (! $db->query($sql) ) { dol_print_error($db); } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$socid.", ".$db->idate(mktime()).",".$user->id.");"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$socid.", ".$db->idate($now).",".$user->id.");"; if (! $db->query($sql) ) { dol_print_error($db); diff --git a/htdocs/compta/prelevement/class/bon-prelevement.class.php b/htdocs/compta/prelevement/class/bon-prelevement.class.php index aecebcba263..557f72771f2 100644 --- a/htdocs/compta/prelevement/class/bon-prelevement.class.php +++ b/htdocs/compta/prelevement/class/bon-prelevement.class.php @@ -864,6 +864,8 @@ class BonPrelevement extends CommonObject * We create withdraw receipt and build withdraw into disk */ $this->db->begin(); + + $now=dol_now(); /* * Traitements @@ -900,7 +902,7 @@ class BonPrelevement extends CommonObject $sql.= ") VALUES ("; $sql.= "'".$ref."'"; $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->idate(mktime())."'"; + $sql.= ", '".$this->db->idate($now)."'"; $sql.= ")"; dol_syslog("Bon-Prelevement::Create sql=".$sql, LOG_DEBUG); @@ -960,7 +962,7 @@ class BonPrelevement extends CommonObject */ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande"; $sql.= " SET traite = 1"; - $sql.= ", date_traite = ".$this->db->idate(mktime()); + $sql.= ", date_traite = ".$this->db->idate($now); $sql.= ", fk_prelevement_bons = ".$prev_id; $sql.= " WHERE rowid = ".$fac[1]; @@ -1137,8 +1139,10 @@ class BonPrelevement extends CommonObject if ($this->DeleteNotification($user, $action) == 0) { + $now=dol_now(); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_soc, fk_contact, fk_action)"; - $sql .= " VALUES (".$db->idate(mktime()).",".$user.", 'NULL', 'NULL', '".$action."')"; + $sql .= " VALUES (".$db->idate($now).",".$user.", 'NULL', 'NULL', '".$action."')"; dol_syslog("adnotiff: ".$sql); if ($this->db->query($sql)) diff --git a/htdocs/compta/prelevement/class/rejet-prelevement.class.php b/htdocs/compta/prelevement/class/rejet-prelevement.class.php index fcdb9dab703..1d8737d6cff 100644 --- a/htdocs/compta/prelevement/class/rejet-prelevement.class.php +++ b/htdocs/compta/prelevement/class/rejet-prelevement.class.php @@ -84,6 +84,7 @@ class RejetPrelevement $error = 0; $this->id = $id; $this->bon_id = $bonid; + $now=dol_now(); dol_syslog("RejetPrelevement::Create id $id"); $bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; @@ -104,7 +105,7 @@ class RejetPrelevement $sql.= ", '".$this->db->idate($date_rejet)."'"; $sql.= ", ".$motif; $sql.= ", ".$user->id; - $sql.= ", ".$this->db->idate(mktime()); + $sql.= ", ".$this->db->idate($now); $sql.= ", ".$facturation; $sql.= ")"; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 8fef71e5ff8..bab35674fab 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -216,9 +216,10 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) print ""; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { + $now=dol_now(); $annee_decalage=$annee; - if($mois>12) {$annee_decalage=$annee+1;} - $casenow = dol_print_date(mktime(),"%Y-%m"); + if ($mois>12) {$annee_decalage=$annee+1;} + $casenow = dol_print_date($now,"%Y-%m"); $case = dol_print_date(dol_mktime(1,1,1,$mois_modulo,1,$annee_decalage),"%Y-%m"); $caseprev = dol_print_date(dol_mktime(1,1,1,$mois_modulo,1,$annee_decalage-1),"%Y-%m"); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 2a16039a351..ff9496898bf 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -244,7 +244,7 @@ class Contrat extends CommonObject // Close line not already closed if ($contratline->statut != 5) { - $contratline->date_cloture=mktime(); + $contratline->date_cloture=dol_now(); $contratline->fk_user_cloture=$user->id; $contratline->statut='5'; $result=$contratline->update($user); @@ -618,12 +618,14 @@ class Contrat extends CommonObject if (! $paramsok) return -1; $this->db->begin(); + + $now=dol_now(); // Insert contract $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,"; $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; $sql.= " ref)"; - $sql.= " VALUES (".$this->db->idate(mktime()).",".$this->socid.",".$user->id; + $sql.= " VALUES (".$this->db->idate($now).",".$this->socid.",".$user->id; $sql.= ",".$this->db->idate($this->date_contrat); $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); $sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL"); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 70726cde310..081b89e26c6 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -1195,7 +1195,7 @@ else $dateactend = dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit); } } - $now=mktime(); + $now=dol_now(); if ($dateactend > $now) $dateactend=$now; print '
'.$langs->trans("Description").''.$langs->trans("Total").'
".dol_print_date(dol_mktime(12,0,0,$mois_modulo,1,2000),"%B")."
'; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 90aaa6082fd..0c5fe3db50e 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -217,10 +217,11 @@ class Notify if ($mailfile->sendfile()) { + $now=dol_now(); $sendto = htmlentities($sendto); $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_contact, objet_type, objet_id, email)"; - $sql.= " VALUES (".$this->db->idate(mktime()).", ".$actiondefid.", ".$obj->cid.", '".$objet_type."', ".$objet_id.", '".$this->db->escape($obj->email)."')"; + $sql.= " VALUES (".$this->db->idate($now).", ".$actiondefid.", ".$obj->cid.", '".$objet_type."', ".$objet_id.", '".$this->db->escape($obj->email)."')"; dol_syslog("Notify::send sql=".$sql); if (! $this->db->query($sql) ) { diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index 54f811ef3e8..4db6de685ac 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -145,7 +145,7 @@ function displayBox($selectedDate,$month,$year) //print "$selectedDate,$month,$year"; $thedate=dol_mktime(12,0,0,$month,1,$year); //print "thedate=$thedate"; - $today=mktime(); + $today=dol_now(); $todayArray=dol_getdate($today); if($selectedDate != "00000000") { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 14c511385f2..78f584773c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2190,7 +2190,8 @@ function dol_print_error_email() global $langs,$conf; $langs->load("errors"); - print '
'.$langs->trans("ErrorContactEMail",$conf->global->MAIN_INFO_SOCIETE_MAIL,'ERRORNEWPAYMENT'.dol_print_date(mktime(),'%Y%m%d')).'
'; + $now=dol_now(); + print '
'.$langs->trans("ErrorContactEMail",$conf->global->MAIN_INFO_SOCIETE_MAIL,'ERRORNEWPAYMENT'.dol_print_date($now,'%Y%m%d')).'
'; } /** diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 6d5c71f2410..48928163f9c 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -410,7 +410,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m else $valueforccc=$objsoc->code_client; // Clean parameters - if ($date == '') $date=mktime(); // We use local year and month of PHP server to search numbers + if ($date == '') $date=dol_now(); // We use local year and month of PHP server to search numbers // but we should use local year and month of user // Extract value for mask counter, mask raz and mask offset diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 4d43f0cd416..810aacb78cc 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -321,10 +321,12 @@ class Fichinter extends CommonObject if ($this->statut != 1) { $this->db->begin(); + + $now=dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql.= " SET fk_statut = 1"; - $sql.= ", date_valid = ".$this->db->idate(mktime()); + $sql.= ", date_valid = ".$this->db->idate($now); $sql.= ", fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; $sql.= " AND entity = ".$conf->entity; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 3ea68f6b3d5..0956980ce9c 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1097,7 +1097,8 @@ else if ($id > 0 || ! empty($ref)) // Date intervention print '
'; - $timearray=dol_getdate(mktime()); + $now=dol_now(); + $timearray=dol_getdate($now); if (!GETPOST('diday','int')) $timewithnohour=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']); else $timewithnohour=dol_mktime(GETPOST('dihour','int'),GETPOST('dimin','int'),GETPOST('disec','int'),GETPOST('dimonth','int'),GETPOST('diday','int'),GETPOST('diyear','int')); $form->select_date($timewithnohour,'di',1,1,0,"addinter"); diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 79650676cc1..d212b70c4b0 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -142,9 +142,11 @@ class PaiementFourn extends Paiement if ($this->total <> 0) // On accepte les montants negatifs { + $now=dol_now(); + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn ('; $sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; - $sql.= ' VALUES ('.$this->db->idate(mktime()).','; + $sql.= ' VALUES ('.$this->db->idate($now).','; $sql.= " ".$this->db->idate($this->datepaye).", '".$this->total."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.", 0)"; dol_syslog("PaiementFourn::create sql=".$sql); diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index e709dc4d6db..b63fdba5302 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -345,6 +345,8 @@ class Livraison extends CommonObject if (is_readable(DOL_DOCUMENT_ROOT .'/core/modules/livraison/'.$modName.'.php')) { require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/'.$modName.'.php'; + + $now=dol_now(); // Recuperation de la nouvelle reference $objMod = new $modName($this->db); @@ -379,7 +381,7 @@ class Livraison extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; $sql.= " ref='".$this->db->escape($this->ref)."'"; $sql.= ", fk_statut = 1"; - $sql.= ", date_valid = ".$this->db->idate(mktime()); + $sql.= ", date_valid = ".$this->db->idate($now); $sql.= ", fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; $sql.= " AND fk_statut = 0"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 8380d390a96..2b80ce5360b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1897,11 +1897,13 @@ class Product extends CommonObject function clone_fournisseurs($fromId, $toId) { $this->db->begin(); + + $now=dol_now(); // les fournisseurs /*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur (" . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" - . " SELECT '".$this->db->idate(mktime())."', ".$toId.", fk_soc, ref_fourn, fk_user_author" + . " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, ref_fourn, fk_user_author" . " FROM ".MAIN_DB_PREFIX."product_fournisseur" . " WHERE fk_product = ".$fromId; @@ -1914,7 +1916,7 @@ class Product extends CommonObject // les prix de fournisseurs. $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("; $sql.= " datec, fk_product, fk_soc, price, quantity, fk_user)"; - $sql.= " SELECT '".$this->db->idate(mktime())."', ".$toId. ", fk_soc, price, quantity, fk_user"; + $sql.= " SELECT '".$this->db->idate($now)."', ".$toId. ", fk_soc, price, quantity, fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE fk_product = ".$fromId; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d838f61b869..58c3ad97ca8 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -707,7 +707,7 @@ class Project extends CommonObject { global $user, $langs, $conf; - $now = mktime(); + $now=dol_now(); // Charge tableau des produits prodids $prodids = array(); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index b93598b600f..59c6325dd3b 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -956,7 +956,9 @@ class Task extends CommonObject $error=0; - $now = dol_mktime(0,0,0,idate('m',mktime()),idate('d',mktime()),idate('Y',mktime())); + $now=dol_now(); + + $datec = dol_mktime(0,0,0,idate('m',$now),idate('d',$now),idate('Y',$now)); $clone_task=new Task($this->db); @@ -970,7 +972,7 @@ class Task extends CommonObject $clone_task->id = 0; $clone_task->fk_project = $project_id; $clone_task->fk_task_parent = $parent_task_id; - $clone_task->date_c = $now; + $clone_task->date_c = $datec; //Manage Task Date if ($clone_change_dt) diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php index b4c456a1b05..819ee46d0c3 100644 --- a/htdocs/societe/class/address.class.php +++ b/htdocs/societe/class/address.class.php @@ -85,8 +85,10 @@ class Address if ($result >= 0) { + $now=dol_now(); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) "; - $sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', ".$this->db->idate(mktime()).", '".$user->id."')"; + $sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', ".$this->db->idate($now).", '".$user->id."')"; $result=$this->db->query($sql); if ($result) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c1ed2932d70..b385f4970b7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1000,6 +1000,8 @@ class Societe extends CommonObject if ($this->id) { $this->db->begin(); + + $now=dol_now(); // Positionne remise courante $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; @@ -1016,7 +1018,7 @@ class Societe extends CommonObject // Ecrit trace dans historique des remises $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise "; $sql.= " (datec, fk_soc, remise_client, note, fk_user_author)"; - $sql.= " VALUES (".$this->db->idate(mktime()).", ".$this->id.", '".$remise."',"; + $sql.= " VALUES (".$this->db->idate($now).", ".$this->id.", '".$remise."',"; $sql.= " '".$this->db->escape($note)."',"; $sql.= " ".$user->id; $sql.= ")";