From f60489b76651f45597ee6aed0a8372082618bdd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Sun, 17 Dec 2017 23:06:26 +0100 Subject: [PATCH 01/26] FIX #4875 Dolimail thirdparty code is integrated into Dolibarr core code Close #4875 --- htdocs/core/actions_sendmails.inc.php | 99 --------------------------- 1 file changed, 99 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 5a8d32efde5..423c81ab0ca 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -105,7 +105,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $trackid = GETPOST('trackid','aZ09'); $subject='';$actionmsg='';$actionmsg2=''; - if (! empty($conf->dolimail->enabled)) $langs->load("dolimail@dolimail"); $langs->load('mails'); if (is_object($object)) @@ -129,36 +128,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $thirdparty=$object; if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; - elseif (! empty($conf->dolimail->enabled)) - { - $dolimail = new Dolimail($db); - $possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1"); - $possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople - if (!$possibleaccounts && !$possibleuser) - { - setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors'); - } - elseif (count($possibleaccounts)>1) - { - $sendtosocid=$possibleaccounts[1]['id']; - $result=$object->fetch($sendtosocid); - - setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); - } - else - { - if($possibleaccounts){ - $sendtosocid=$possibleaccounts[1]['id']; - $result=$object->fetch($sendtosocid); - }elseif($possibleuser){ - $sendtosocid=$possibleuser[0]['id']; - - $result=$uobject->fetch($sendtosocid); - $object=$uobject; - } - - } - } } else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); } @@ -318,49 +287,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $filename = $attachedfiles['names']; $mimetype = $attachedfiles['mimes']; - - // Feature to push mail sent into Sent folder - if (! empty($conf->dolimail->enabled)) - { - $mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# ' // TODO Use a better way to define Sent dir. - if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - else - { - $mbid = $mailfromid[1]; - - /*IMAP Postbox*/ - $mailboxconfig = new IMAP($db); - $mailboxconfig->fetch($mbid); - if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref(); - - $mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox; - $mailboxconfig->userfolder_fetch(); - - if ($mailboxconfig->mailbox_save_sent_mails == 1) - { - - $folder=str_replace($ref, '', $mailboxconfig->folder_cache_key); - if (!$folder) $folder = "Sent"; // Default Sent folder - - $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password); - if (FALSE === $mailboxconfig->mbox) - { - $info = FALSE; - $err = $langs->trans('Error3_Imap_Connection_Error'); - setEventMessages($err,$mailboxconfig->element, null, 'errors'); - } - else - { - $mailboxconfig->mailboxid=$_POST['frommail']; - $mailboxconfig->foldername=$folder; - $from = $mailfromid[0] . $mailfromid[2]; - $imap=1; - } - - } - } - } - // Make substitution in email content $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray['__EMAIL__'] = $sendto; @@ -394,26 +320,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $error=0; - // FIXME This must be moved into the trigger for action $trigger_name - if (! empty($conf->dolimail->enabled)) - { - $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ? - if ($mid) - { - // set imap flag answered if it is an answered mail - $dolimail=new DoliMail($db); - $dolimail->id = $mid; - $res=$dolimail->set_prop($user, 'answered',1); - } - if ($imap==1) - { - // write mail to IMAP Server - $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); - if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs'); - else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); - } - } - // Initialisation of datas if (is_object($object)) { @@ -453,11 +359,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) - { - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); - exit; - } header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'')); exit; } From 77d410708538a8c15e79340862e9c620cc4c71b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2018 17:44:37 +0100 Subject: [PATCH 02/26] Update actions_sendmails.inc.php --- htdocs/core/actions_sendmails.inc.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 629e80e5a82..ff567803ae4 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -416,22 +416,15 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } - if ($error) - { - dol_print_error($db); - } - else - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessages($mesg, null, 'mesgs'); + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + setEventMessages($mesg, null, 'mesgs'); $moreparam=''; if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); exit; - } } else { From 5dde72e3dd12d53b5ae45c4f6496d102f518d563 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2018 17:45:05 +0100 Subject: [PATCH 03/26] Update actions_sendmails.inc.php --- htdocs/core/actions_sendmails.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index ff567803ae4..d478dc6bc06 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -364,8 +364,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $result=$mailfile->sendfile(); if ($result) { - $error=0; - // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required /* if (! empty($conf->dolimail->enabled)) From dc6f4c1f4d51a9a46516953ddf34adf74607884d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 11:48:30 +0100 Subject: [PATCH 04/26] NEW : option to send email to salaries --- htdocs/admin/mails.php | 10 ++ htdocs/core/actions_sendmails.inc.php | 31 ++++- htdocs/core/class/html.formmail.class.php | 49 +++++++- htdocs/core/tpl/card_presend.tpl.php | 18 +++ htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/mails.lang | 2 + .../modulebuilder/template/myobject_list.php | 1 + htdocs/user/class/user.class.php | 106 +++++++++++++++++- 8 files changed, 214 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 7d4e382723c..71b1487ab44 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -71,6 +71,7 @@ if ($action == 'update' && empty($_POST["cancel"])) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"),'chaine',0,'',$conf->entity); // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity); @@ -271,6 +272,12 @@ if ($action == 'edit') print ''; print ''; + + //Add user to select destinaries list + print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''; + print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT',$conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT,1); + print ''; + // Separator print ' '; @@ -541,6 +548,9 @@ else if (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO) && ! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); print ''; + //Add user to select destinaries list + print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).''; + // Separator print ' '; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 9f5224a71d3..3498bbc132c 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -170,6 +170,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $sendtocc=''; $sendtobcc=''; $sendtoid = array(); + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $sendtouserid=array(); + } // Define $sendto $receiver=$_POST['receiver']; @@ -192,14 +195,25 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($val == 'thirdparty') // Id of third party { $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; - } - elseif ($val) // Id du contact + } elseif ($val) // Id du contact { $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); $sendtoid[] = $val; } } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $receiveruser=$_POST['receiveruser']; + if (is_array($receiveruser) && count($receiveruser)>0) + { + $fuserdest = new User($db); + foreach($receiveruser as $key=>$val) + { + $tmparray[] = $fuserdest->user_get_property($key,'email'); + $sendtouserid[] = $key; + } + } + } $sendto=implode(',',$tmparray); // Define $sendtocc @@ -230,6 +244,19 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $receiveruser=$_POST['receiveccruser']; + + if (is_array($receiveruser) && count($receiveruser)>0) + { + $fuserdest = new User($db); + foreach($receiveruser as $key=>$val) + { + $tmparray[] = $fuserdest->user_get_property($key,'email'); + $sendtouserid[] = $key; + } + } + } $sendtocc=implode(',',$tmparray); if (dol_strlen($sendto)) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 5ff93994e73..b2f64f4298d 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -81,6 +81,9 @@ class FormMail extends Form var $substit_lines=array(); var $param=array(); + public $withtouser=array(); + public $withtoccuser=array(); + var $error; public $lines_model; @@ -332,7 +335,7 @@ class FormMail extends Form $out.= "\n".'
'."\n"; if ($this->withform == 1) { - $out.= '
'."\n"; + $out.= ''."\n"; $out.= ''; $out.= ''; @@ -623,6 +626,28 @@ class FormMail extends Form $out.= "\n"; } + // To User + if (! empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) + { + $out.= ''; + $out.= $langs->trans("MailToSalaries"); + $out.= ''; + + // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray = $this->withtouser; + foreach($tmparray as $key => $val) + { + $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + } + $withtoselected=GETPOST("receiveruser",'none'); // Array of selected value + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') + { + $withtoselected = array_keys($tmparray); + } + $out.= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); + $out.= "\n"; + } + // withoptiononeemailperrecipient if (! empty($this->withoptiononeemailperrecipient)) { @@ -667,6 +692,28 @@ class FormMail extends Form $out.= "\n"; } + // To User cc + if (! empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) + { + $out.= ''; + $out.= $langs->trans("MailToCCSalaries"); + $out.= ''; + + // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray = $this->withtoccuser; + foreach($tmparray as $key => $val) + { + $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + } + $withtoselected=GETPOST("receiverccuser",'none'); // Array of selected value + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') + { + $withtoselected = array_keys($tmparray); + } + $out.= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); + $out.= "\n"; + } + // CCC if (! empty($this->withtoccc) || is_array($this->withtoccc)) { diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 43cacab0e1c..ca852a46499 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -147,6 +147,24 @@ if ($action == 'presend') $liste[$key] = $value; } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $listeuser=array(); + $fuserdest = new User($db); + + $result= $fuserdest->fetchAll('ASC', 't.lastname', 0, 0, array('customsql'=>'t.statut=1 AND t.employee=1 AND t.email IS NOT NULL AND t.email<>\'\'')); + if ($result>0 && is_array($fuserdest->users) && count($fuserdest->users)>0) { + foreach($fuserdest->users as $uuserdest) { + $listeuser[$uuserdest->id] = $uuserdest->user_get_property($uuserdest->id,'email'); + } + } elseif ($result<0) { + setEventMessages(null, $fuserdest->errors,'errors'); + } + if (count($listeuser)>0) { + $formmail->withtouser = $listeuser; + $formmail->withtoccuser = $listeuser; + } + + } $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; $formmail->withtocc = $liste; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3a7e8a7d14a..71ade0f2058 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -273,6 +273,7 @@ MAIN_MAIL_ERRORS_TO=Email used as 'Errors-To' field in emails sent MAIN_MAIL_AUTOCOPY_TO= Send systematically a hidden carbon-copy of all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all emails sendings (for test purposes or demos) MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes) +MAIN_MAIL_ENABLED_USER_DEST_SELECT=Add salaries users with email into allowed destinaries list MAIN_MAIL_SENDMODE=Method to use to send EMails MAIN_MAIL_SMTPS_ID=SMTP ID if authentication required MAIN_MAIL_SMTPS_PW=SMTP Password if authentication required diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 3c512ca7286..3425ea7d603 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -11,7 +11,9 @@ MailFrom=Sender MailErrorsTo=Errors to MailReply=Reply to MailTo=Receiver(s) +MailToSalaries=To salarie(s) MailCC=Copy to +MailToCCSalaries=Copy to salarie(s) MailCCC=Cached copy to MailTopic=EMail topic MailText=Message diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index c1867fb87f7..70a07002955 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -202,6 +202,7 @@ $help_url=''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects")); +// TODO : move this SQL request into fetchAll class method // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f3c8f03329f..10091853134 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1,4 +1,6 @@ * Copyright (c) 2002-2003 Jean-Louis Bergamo * Copyright (c) 2004-2012 Laurent Destailleur @@ -115,7 +117,7 @@ class User extends CommonObject public $lastsearch_values_tmp; // To store current search criterias for user public $lastsearch_values; // To store last saved search criterias for user - public $users; // To store all tree of users hierarchy + public $users = array(); // To store all tree of users hierarchy public $parentof; // To store an array of all parents for all ids. private $cache_childids; @@ -135,6 +137,7 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; + /** * Constructor de la classe * @@ -3011,5 +3014,106 @@ class User extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } + /** + * Return property of contact from its id + * + * @param int $rowid id of contact + * @param string $mode 'email' or 'mobile' + * @return string Email of contact with format: "Full name " + */ + function user_get_property($rowid,$mode) + { + $user_property=''; + + if (empty($rowid)) return ''; + + $sql = "SELECT rowid, email, user_mobile, civility, lastname, firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."user"; + $sql.= " WHERE rowid = '".$rowid."'"; + + $resql=$this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + + if ($nump) + { + $obj = $this->db->fetch_object($resql); + + if ($mode == 'email') $user_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; + else if ($mode == 'mobile') $user_property = $obj->user_mobile; + } + return $user_property; + } + else + { + dol_print_error($this->db); + } + } + + /** + * Load all objects into $this->lines + * + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int <0 if KO, >0 if OK + */ + function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter=array()) + { + global $conf; + + + $sql="SELECT t.rowid"; + $sql.= ' FROM '.MAIN_DB_PREFIX .$this->table_element.' as t '; + $sql.= " WHERE 1"; + + //Manage filter + if (!empty($filter)){ + foreach($filter as $key => $value) { + if (strpos($key,'date')) { + $sql.= ' AND '.$key.' = \''.$this->db->idate($value).'\''; + } + elseif ($key=='customsql') { + $sql.= ' AND '.$value; + } else { + $sql.= ' AND '.$key.' LIKE \'%'.$value.'%\''; + } + } + } + $sql.= $this->db->order($sortfield,$sortorder); + if ($limit) $sql.= $this->db->plimit($limit+1,$offset); + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + $this->users=array(); + $num = $this->db->num_rows($resql); + if ($num) + { + while ($obj = $this->db->fetch_object($resql)) + { + $line = new self($this->db); + $result = $line->fetch($obj->rowid); + if ($result>0 && !empty($line->id)) { + $this->users[$obj->rowid] = clone $line; + } + } + $this->db->free($resql); + } + return $num; + } + else + { + $this->errors[] = $this->db->lasterror(); + return -1; + } + + } + } From d3ae285c0c3b2a480893dfe46ed44d7cb44a6844 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 22:58:17 +0100 Subject: [PATCH 05/26] finish work --- htdocs/core/actions_sendmails.inc.php | 3 +++ htdocs/core/class/html.formmail.class.php | 2 +- .../triggers/interface_50_modAgenda_ActionsAuto.class.php | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 3498bbc132c..fc21202959c 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -457,6 +457,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (is_array($attachedfiles) && count($attachedfiles)>0) { $object->attachedfiles = $attachedfiles; } + if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $object->sendtouserid = $sendtouserid; + } // Call of triggers if (! empty($trigger_name)) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b2f64f4298d..2b1c94889e3 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -335,7 +335,7 @@ class FormMail extends Form $out.= "\n".'
'."\n"; if ($this->withform == 1) { - $out.= ''."\n"; + $out.= ''."\n"; $out.= ''; $out.= ''; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 78053a0631c..6922189abc4 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -889,6 +889,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->fk_element = $elementid; $actioncomm->elementtype = $elementtype; + if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) { + $actioncomm->userassigned=$object->sendtouserid; + } + $ret=$actioncomm->create($user); // User creating action if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) From c8d309e5998c6dddbb55fd523c6dba9f6125dcf7 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 23:00:33 +0100 Subject: [PATCH 06/26] clean --- htdocs/core/actions_sendmails.inc.php | 3 ++- htdocs/user/class/user.class.php | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index fc21202959c..dd6eeee4361 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -195,7 +195,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($val == 'thirdparty') // Id of third party { $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; - } elseif ($val) // Id du contact + } + elseif ($val) // Id du contact { $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); $sendtoid[] = $val; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 10091853134..6cc7007615a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1,6 +1,4 @@ * Copyright (c) 2002-2003 Jean-Louis Bergamo * Copyright (c) 2004-2012 Laurent Destailleur From 487ef3b7c94786436b257e849b92c17ba0870a58 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 23:01:20 +0100 Subject: [PATCH 07/26] cealn again --- htdocs/user/class/user.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6cc7007615a..75bc87f61a7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -135,7 +135,6 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; - /** * Constructor de la classe * From 4ebb1385334ec103bdb456a7c7567b32077c6016 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 23:03:22 +0100 Subject: [PATCH 08/26] last ones --- htdocs/user/class/user.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 75bc87f61a7..82b10426622 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -115,7 +115,7 @@ class User extends CommonObject public $lastsearch_values_tmp; // To store current search criterias for user public $lastsearch_values; // To store last saved search criterias for user - public $users = array(); // To store all tree of users hierarchy + public $users = array(); // To store all tree of users hierarchy public $parentof; // To store an array of all parents for all ids. private $cache_childids; @@ -3012,11 +3012,11 @@ class User extends CommonObject } /** - * Return property of contact from its id + * Return property of user from its id * * @param int $rowid id of contact * @param string $mode 'email' or 'mobile' - * @return string Email of contact with format: "Full name " + * @return string Email of user with format: "Full name " */ function user_get_property($rowid,$mode) { @@ -3049,7 +3049,7 @@ class User extends CommonObject } /** - * Load all objects into $this->lines + * Load all objects into $this->users * * @param string $sortorder sort order * @param string $sortfield sort field @@ -3062,7 +3062,6 @@ class User extends CommonObject { global $conf; - $sql="SELECT t.rowid"; $sql.= ' FROM '.MAIN_DB_PREFIX .$this->table_element.' as t '; $sql.= " WHERE 1"; From 3de793d88f5a7db9c108348bd6b2f85bebbe559d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 10 Apr 2018 15:28:05 +0200 Subject: [PATCH 09/26] fix #8436 --- htdocs/holiday/list.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index d99afde8c3d..25ff2f42849 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -458,15 +458,19 @@ else // Type print ''; -$typeleaves=$holidaystatic->getTypes(1,-1); -$arraytypeleaves=array(); -foreach($typeleaves as $key => $val) -{ - $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']); - //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); - $arraytypeleaves[$val['rowid']]=$labeltoshow; +if (empty($mysoc->country_id)) { + setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"),$langs->trans("CompanyFoundation")),'errors'); +} else { + $typeleaves=$holidaystatic->getTypes(1,-1); + $arraytypeleaves=array(); + foreach($typeleaves as $key => $val) + { + $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']); + //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); + $arraytypeleaves[$val['rowid']]=$labeltoshow; + } + print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1); } -print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1); print ''; // Duration @@ -521,7 +525,7 @@ if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids) $result = 0; } // Lines -elseif (! empty($holiday->holiday)) +elseif (! empty($holiday->holiday) && !empty($mysoc->country_id)) { $userstatic = new User($db); $approbatorstatic = new User($db); From 8a0baaad170b30573507be6385ece30b7fcacb74 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 10 Apr 2018 16:25:06 +0200 Subject: [PATCH 10/26] fix #8480 --- htdocs/core/lib/functions.lib.php | 21 +++++++++++++++++++ .../tpl/extrafields_list_search_sql.tpl.php | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a75c9176893..a598d6a83d6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6727,6 +6727,27 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) $i2++; // a criteria was added to string } } + else if ($mode == 4) + { + $tmparray=explode(',',trim($crit)); + + if (count($tmparray)) + { + $listofcodes=''; + + foreach($tmparray as $val) + { + if ($val) + { + $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\''; + $newres .= ' OR '. $field . ' = \'' . $db->escape(trim($val)) . '\''; + $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\''; + $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\''; + $i2++; + } + } + } + } else // $mode=0 { $textcrit = ''; diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php index 7006a54351b..e40ac5f2a07 100644 --- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php @@ -15,7 +15,8 @@ foreach ($search_array_options as $key => $val) $typ=$extrafields->attribute_type[$tmpkey]; $mode_search=0; if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric - if (in_array($typ, array('sellist','link','chkbxlst','checkbox')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int + if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int + if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1')) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search); From 80a4428955b3c3fb27352c6a2b435b987aaf51ce Mon Sep 17 00:00:00 2001 From: Gildas Rossignon Date: Tue, 10 Apr 2018 23:11:32 +0200 Subject: [PATCH 11/26] Fix value cond_reglement_id & mode_reglement_id I had a bug when trying to create a supplier proposal by this way : $fournisseur = new Societe($db); $fournisseur->fetch(1); $supplierproposal = new SupplierProposal($db, $fournisseur->id); if ($supplierproposal->create($user) < 1) { echo $supplierproposal->error . '

'; echo $db->lastquery; } This would generate an insert query with an empty value : INSERT INTO llx_supplier_proposal (fk_soc, price, remise, remise_percent, remise_absolue, tva, total, datec, ref, fk_user_author, note_private, note_public, model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, date_livraison, fk_shipping_method, fk_projet, entity, fk_multicurrency, multicurrency_code, multicurrency_tx) VALUES (1, 0, 0, null, null, 0, 0, '2018-04-10 23:01:52', '(PROV)', '1', '', '', '', , , NULL, null, NULL, null, 1, 0, 'EUR', 1) --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 8a6068f7116..4d66bddaf87 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -838,8 +838,8 @@ class SupplierProposal extends CommonObject $sql.= ", '".$this->db->escape($this->note_private)."'"; $sql.= ", '".$this->db->escape($this->note_public)."'"; $sql.= ", '".$this->db->escape($this->modelpdf)."'"; - $sql.= ", ".$this->cond_reglement_id; - $sql.= ", ".$this->mode_reglement_id; + $sql.= ", ".($this->cond_reglement_id?$this->cond_reglement_id:'NULL'); + $sql.= ", ".($this->mode_reglement_id?$this->mode_reglement_id:'NULL'); $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null"); $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); From 185c1aca13574758f7ab89fb332b967fbe153a0a Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Wed, 11 Apr 2018 13:27:25 +1100 Subject: [PATCH 12/26] Passes the list of third parties and the list of objects ref to the complete_substitutions_array function as parameters. --- htdocs/core/actions_massactions.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5a713168c48..db7e2088b9e 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -356,6 +356,14 @@ if (! $error && $massaction == 'confirm_presend') $substitutionarray['__CHECK_READ__'] = ''; $parameters=array('mode'=>'formemail'); + + if ( ! empty( $listofobjectthirdparties ) ) { + $parameters['listofobjectthirdparties'] = $listofobjectthirdparties; + } + if ( ! empty( $listofobjectref ) ) { + $parameters['listofobjectref'] = $listofobjectref; + } + complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); $subject=make_substitutions($subject, $substitutionarray); From 9634f4c82a79f8f21ef90ee18f54aa181be4f163 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Apr 2018 17:29:45 +0200 Subject: [PATCH 13/26] Update supplier_proposal.class.php --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 4d66bddaf87..991e3ad5af8 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -838,8 +838,8 @@ class SupplierProposal extends CommonObject $sql.= ", '".$this->db->escape($this->note_private)."'"; $sql.= ", '".$this->db->escape($this->note_public)."'"; $sql.= ", '".$this->db->escape($this->modelpdf)."'"; - $sql.= ", ".($this->cond_reglement_id?$this->cond_reglement_id:'NULL'); - $sql.= ", ".($this->mode_reglement_id?$this->mode_reglement_id:'NULL'); + $sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL'); + $sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL'); $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null"); $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); From 1aace69b1a6ebbfdb234257cecf48a9b6b38bfe8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Apr 2018 17:37:00 +0200 Subject: [PATCH 14/26] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a598d6a83d6..fd358a04717 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6739,10 +6739,11 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) { if ($val) { - $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\''; + $newres .= ($i2 > 0 ? ' OR (' : '(') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\''; $newres .= ' OR '. $field . ' = \'' . $db->escape(trim($val)) . '\''; $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\''; $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\''; + $newres .= ')'; $i2++; } } From e468584783ab4a90ce442ae28afa4c4d4e8229b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Apr 2018 18:31:46 +0200 Subject: [PATCH 15/26] Update actions_sendmails.inc.php --- htdocs/core/actions_sendmails.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index d478dc6bc06..7df1fe2dba6 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -131,6 +131,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; } else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); + + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + } } else $thirdparty = $mysoc; From 251117fcce649e2c973e05466de270cfeaa5d2f9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 12 Apr 2018 06:07:22 +0200 Subject: [PATCH 16/26] Accountancy - Small fix --- htdocs/accountancy/admin/categories.php | 2 +- htdocs/accountancy/bookkeeping/card.php | 220 ++++++++++++------------ 2 files changed, 110 insertions(+), 112 deletions(-) diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index a91c22ffe4c..69d09ae301b 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -71,7 +71,7 @@ if (! empty($selectcpt)) { if ($return<0) { setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors'); } else { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); } } if ($action == 'delete') { diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f655d245e86..885b090fe0c 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2017 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2017 Laurent Destailleur +/* Copyright (C) 2013-2017 Olivier Geffroy + * Copyright (C) 2013-2017 Florian Henry + * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,9 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -$langs->load("accountancy"); -$langs->load("bills"); -$langs->load("compta"); +$langs->loadLangs(array("accountancy", "bills", "compta")); $action = GETPOST('action','aZ09'); @@ -89,36 +87,36 @@ if ($action == "confirm_update") { if (! $error) { - $book = new BookKeeping($db); + $object = new BookKeeping($db); - $result = $book->fetch($id, null, $mode); + $result = $object->fetch($id, null, $mode); if ($result < 0) { $error++; - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { - $book->numero_compte = $account_number; - $book->subledger_account = $subledger_account; - $book->label_compte = $label_compte; - $book->label_operation= $label_operation; - $book->debit = $debit; - $book->credit = $credit; + $object->numero_compte = $account_number; + $object->subledger_account = $subledger_account; + $object->label_compte = $label_compte; + $object->label_operation= $label_operation; + $object->debit = $debit; + $object->credit = $credit; if (floatval($debit) != 0.0) { - $book->montant = $debit; - $book->sens = 'D'; + $object->montant = $debit; + $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $book->montant = $credit; - $book->sens = 'C'; + $object->montant = $credit; + $object->sens = 'C'; } - $result = $book->update($user, false, $mode); + $result = $object->update($user, false, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $debit = 0; @@ -147,39 +145,39 @@ else if ($action == "add") { } if (! $error) { - $book = new BookKeeping($db); + $object = new BookKeeping($db); - $book->numero_compte = $account_number; - $book->subledger_account = $subledger_account; - $book->label_compte = $label_compte; - $book->label_operation= $label_operation; - $book->debit = $debit; - $book->credit = $credit; - $book->doc_date = GETPOST('doc_date','alpha'); - $book->doc_type = GETPOST('doc_type','alpha'); - $book->piece_num = $piece_num; - $book->doc_ref = GETPOST('doc_ref','alpha'); - $book->code_journal = GETPOST('code_journal','alpha'); - $book->fk_doc = GETPOST('fk_doc','alpha'); - $book->fk_docdet = GETPOST('fk_docdet','alpha'); + $object->numero_compte = $account_number; + $object->subledger_account = $subledger_account; + $object->label_compte = $label_compte; + $object->label_operation= $label_operation; + $object->debit = $debit; + $object->credit = $credit; + $object->doc_date = GETPOST('doc_date','alpha'); + $object->doc_type = GETPOST('doc_type','alpha'); + $object->piece_num = $piece_num; + $object->doc_ref = GETPOST('doc_ref','alpha'); + $object->code_journal = GETPOST('code_journal','alpha'); + $object->fk_doc = GETPOST('fk_doc','alpha'); + $object->fk_docdet = GETPOST('fk_docdet','alpha'); if (floatval($debit) != 0.0) { - $book->montant = $debit; - $book->sens = 'D'; + $object->montant = $debit; + $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $book->montant = $credit; - $book->sens = 'C'; + $object->montant = $credit; + $object->sens = 'C'; } - $result = $book->createStd($user, false, $mode); + $result = $object->createStd($user, false, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $debit = 0; @@ -191,17 +189,17 @@ else if ($action == "add") { } else if ($action == "confirm_delete") { - $book = new BookKeeping($db); + $object = new BookKeeping($db); - $result = $book->fetch($id, null, $mode); - $piece_num = $book->piece_num; + $result = $object->fetch($id, null, $mode); + $piece_num = $object->piece_num; if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { - $result = $book->delete($user, false, $mode); + $result = $object->delete($user, false, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } $action = ''; @@ -210,7 +208,7 @@ else if ($action == "confirm_delete") { else if ($action == "confirm_create") { $error = 0; - $book = new BookKeeping($db); + $object = new BookKeeping($db); if (! GETPOST('code_journal','alpha') || GETPOST('code_journal','alpha') == '-1') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); @@ -225,29 +223,29 @@ else if ($action == "confirm_create") { if (! $error) { - $book->label_compte = ''; - $book->debit = 0; - $book->credit = 0; - $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth','int'), GETPOST('doc_dateday','int'), GETPOST('doc_dateyear','int')); - $book->doc_type = GETPOST('doc_type','alpha'); - $book->piece_num = GETPOST('next_num_mvt','alpha'); - $book->doc_ref = GETPOST('doc_ref','alpha'); - $book->code_journal = GETPOST('code_journal','alpha'); - $book->fk_doc = 0; - $book->fk_docdet = 0; - $book->montant = 0; + $object->label_compte = ''; + $object->debit = 0; + $object->credit = 0; + $object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth','int'), GETPOST('doc_dateday','int'), GETPOST('doc_dateyear','int')); + $object->doc_type = GETPOST('doc_type','alpha'); + $object->piece_num = GETPOST('next_num_mvt','alpha'); + $object->doc_ref = GETPOST('doc_ref','alpha'); + $object->code_journal = GETPOST('code_journal','alpha'); + $object->fk_doc = 0; + $object->fk_docdet = 0; + $object->montant = 0; - $result = $book->createStd($user,0, $mode); + $result = $object->createStd($user,0, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = 'update'; - $id=$book->id; - $piece_num = $book->piece_num; + $id=$object->id; + $piece_num = $object->piece_num; } } } @@ -260,7 +258,7 @@ if ($action == 'setdate') { } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = ''; } @@ -274,7 +272,7 @@ if ($action == 'setjournal') { } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = ''; } @@ -288,7 +286,7 @@ if ($action == 'setdocref') { } else { if ($mode != '_tmp') { - setEventMessages($langs->trans('Saved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = ''; } @@ -326,8 +324,8 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("CreateMvts")); - $book = new BookKeeping($db); - $next_num_mvt = $book->getNextNumMvt('_tmp'); + $object = new BookKeeping($db); + $next_num_mvt = $object->getNextNumMvt('_tmp'); if (empty($next_num_mvt)) { @@ -361,7 +359,7 @@ if ($action == 'create') print ''; print ''; - print '' . $langs->trans("Docref") . ''; + print '' . $langs->trans("Piece") . ''; print ''; print ''; @@ -384,13 +382,13 @@ if ($action == 'create') print ''; } else { - $book = new BookKeeping($db); - $result = $book->fetchPerMvt($piece_num, $mode); + $object = new BookKeeping($db); + $result = $object->fetchPerMvt($piece_num, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } - if (! empty($book->piece_num)) + if (! empty($object->piece_num)) { $backlink = '' . $langs->trans('BackToList') . ''; @@ -398,14 +396,14 @@ if ($action == 'create') $head=array(); $h=0; - $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$book->piece_num.($mode?'&mode='.$mode:''); + $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode?'&mode='.$mode:''); $head[$h][1] = $langs->trans("Transaction"); $head[$h][2] = 'transaction'; $h++; dol_fiche_head($head, 'transaction', '', -1); - //dol_banner_tab($book, '', $backlink); + //dol_banner_tab($object, '', $backlink); print '
'; print '
'; @@ -416,7 +414,7 @@ if ($action == 'create') // Account movement print ''; print '' . $langs->trans("NumMvts") . ''; - print '' . $book->piece_num . ''; + print '' . $object->piece_num . ''; print ''; // Date @@ -425,19 +423,19 @@ if ($action == 'create') print $langs->trans('Docdate'); print ''; if ($action != 'editdate') - print 'piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).''; + print 'piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).''; print ''; print ''; if ($action == 'editdate') { - print '
'; + print ''; print ''; print ''; print ''; - $form->select_date($book->doc_date ? $book->doc_date : - 1, 'doc_date', '', '', '', "setdate"); + $form->select_date($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); print ''; print '
'; } else { - print $book->doc_date ? dol_print_date($book->doc_date, 'day') : ' '; + print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; } print ''; print ''; @@ -448,19 +446,19 @@ if ($action == 'create') print $langs->trans('Codejournal'); print ''; if ($action != 'editjournal') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; + print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; print ''; print ''; if ($action == 'editjournal') { - print '
'; + print ''; print ''; print ''; print ''; - print $formaccounting->select_journal($book->code_journal,'code_journal',0,0,array(),1,1); + print $formaccounting->select_journal($object->code_journal,'code_journal',0,0,array(),1,1); print ''; print '
'; } else { - print $book->code_journal ; + print $object->code_journal ; } print ''; print ''; @@ -468,22 +466,22 @@ if ($action == 'create') // Ref document print ''; print ''; if ($action != 'editdocref') - print ''; + print ''; print '
'; - print $langs->trans('Docref'); + print $langs->trans('Piece'); print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'
'; print ''; if ($action == 'editdocref') { - print '
'; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'; } else { - print $book->doc_ref ; + print $object->doc_ref ; } print ''; print ''; @@ -498,11 +496,11 @@ if ($action == 'create') print ''; // Doc type - if(! empty($book->doc_type)) + if(! empty($object->doc_type)) { print ''; print ''; - print ''; + print ''; print ''; } @@ -510,7 +508,7 @@ if ($action == 'create') print ''; print ''; print ''; print ''; @@ -519,7 +517,7 @@ if ($action == 'create') print ''; print ''; print ''; print ''; - if ($book->doc_type == 'customer_invoice') + if ($object->doc_type == 'customer_invoice') { $sqlmid = 'SELECT rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; - $sqlmid .= " WHERE fac.rowid=" . $book->fk_doc; + $sqlmid .= " WHERE fac.rowid=" . $object->fk_doc; dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); if ($resultmid) { @@ -563,24 +561,24 @@ if ($action == 'create') print '
'; - $result = $book->fetchAllPerMvt($piece_num, $mode); + $result = $object->fetchAllPerMvt($piece_num, $mode); if ($result < 0) { - setEventMessages($book->error, $book->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { print load_fiche_titre($langs->trans("ListeMvts"), '', ''); - print ''; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; + print ''; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; print '' . "\n"; print "
' . $langs->trans("Doctype") . '' . $book->doc_type . '' . $object->doc_type . '
' . $langs->trans("DateCreation") . ''; - print $book->date_creation ? dol_print_date($book->date_creation, 'day') : ' '; + print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; print '
' . $langs->trans("Status") . ''; - if (empty($book->validated)) { + if (empty($object->validated)) { print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; @@ -536,11 +534,11 @@ if ($action == 'create') /* print '
' . $langs->trans("Control") . '
"; - if (count($book->linesmvt) > 0) { + if (count($object->linesmvt) > 0) { $total_debit = 0; $total_credit = 0; @@ -597,7 +595,7 @@ if ($action == 'create') print "\n"; - foreach ($book->linesmvt as $line) { + foreach ($object->linesmvt as $line) { print ''; $total_debit += $line->debit; $total_credit += $line->credit; @@ -692,7 +690,7 @@ if ($action == 'create') print '
'; if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + print ''.$langs->trans("ValidTransaction").''; } else { From c143ac060b84079199f86fd03192762c38a5fd7b Mon Sep 17 00:00:00 2001 From: jess Date: Thu, 12 Apr 2018 14:09:31 +0900 Subject: [PATCH 17/26] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, I'm making updates for Open Collective. Either you or a supporter signed this repo up for Open Collective. This pull request adds backers and sponsors from your Open Collective https://opencollective.com/dolibarr ❤️ It adds two badges at the top to show the latest number of backers and sponsors. It also adds placeholders so that the avatar/logo of new backers/sponsors can automatically be shown without having to update your README.md. [more info](https://github.com/opencollective/opencollective/wiki/Github-banner). See how it looks on [this repo](https://github.com/apex/apex#backers). You can also add a "Donate" button to your website and automatically show your backers and sponsors there with our widgets. Have a look here: https://opencollective.com/widgets P.S: As with any pull request, feel free to comment or suggest changes. The only thing "required" are the placeholders on the README because we believe it's important to acknowledge the people in your community that are contributing (financially or with code!). Thank you for your great contribution to the open source community. You are awesome! 🙌 And welcome to the open collective community! 😊 Come chat with us in the #opensource channel on https://slack.opencollective.com - great place to ask questions and share best practices with other open source sustainers! --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d9ba75f1f5..9aab753dedd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DOLIBARR ERP & CRM -![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) +![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) [![Backers on Open Collective](https://opencollective.com/dolibarr/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/dolibarr/sponsors/badge.svg)](#sponsors) Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…). @@ -199,3 +199,22 @@ Follow Dolibarr project on: - [LinkedIn](https://www.linkedin.com/company/association-dolibarr) - [YouTube](https://www.youtube.com/user/DolibarrERPCRM) - [GitHub](https://github.com/Dolibarr/dolibarr) + +### Contributors + +This project exists thanks to all the people who contribute. [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. + + + +### Backers + +Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/dolibarr#backer)] + + From 34ce9a8aa1db0d14fecab0ec3dc76dc01e046760 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Apr 2018 12:11:05 +0200 Subject: [PATCH 18/26] Update README.md --- README.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9aab753dedd..a7948c642ce 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DOLIBARR ERP & CRM -![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) [![Backers on Open Collective](https://opencollective.com/dolibarr/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/dolibarr/sponsors/badge.svg)](#sponsors) +![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…). @@ -206,15 +206,8 @@ This project exists thanks to all the people who contribute. [[Contribute](https -### Backers - -Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/dolibarr#backer)] - - + + ## CREDITS From baa716dac1230551116f3bea253099db54299136 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Apr 2018 12:23:50 +0200 Subject: [PATCH 22/26] Update README-FR.md --- README-FR.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README-FR.md b/README-FR.md index 19251407ff4..64bd18355cd 100644 --- a/README-FR.md +++ b/README-FR.md @@ -138,11 +138,9 @@ Voici un liste de fonctionnalites pas encore gérées par Dolibarr: Les documentations utilisateur, développeur et traducteur sont disponible sous forme de ressources de la communautés via la site [Wiki](https://wiki.dolibarr.org). -## CONTRIBUTING +## CONTRIBUER -Voir le fichier [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) - -Ce projet existe grâce à ses contributeurs [[Contribuer](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. +Ce projet existe grâce à ses nombreux contributeurs [[Contribuer](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. From 97c30e7693eb2b662b8451098a052313864a6f4a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Apr 2018 12:25:13 +0200 Subject: [PATCH 23/26] Update README.md --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1150c5c8f2a..a01c0679761 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,8 @@ Administrator, user, developer and translator's documentations are available alo ## CONTRIBUTING -See [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) file +This project exists thanks to all the people who contribute. [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. + ## CREDITS @@ -200,11 +201,6 @@ Follow Dolibarr project on: - [YouTube](https://www.youtube.com/user/DolibarrERPCRM) - [GitHub](https://github.com/Dolibarr/dolibarr) -### Contributors - -This project exists thanks to all the people who contribute. [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. - - ### Sponsors From 5f5beb9cfbd63e5742e1802182340ddaede5a9b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Apr 2018 12:30:31 +0200 Subject: [PATCH 24/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a01c0679761..2b76b755f58 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com). -## FUTURE +## WHAT DOLIBARR CAN'T DO YET These are features that Dolibarr does **not** yet fully support: From 413f234fba3e5b45b5584b5d4300ef76f11f216c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Apr 2018 13:07:37 +0200 Subject: [PATCH 25/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b76b755f58..b68e8b65558 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ Administrator, user, developer and translator's documentations are available alo ## CONTRIBUTING This project exists thanks to all the people who contribute. [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. - + ## CREDITS From 72092e7b6bacce520a75a70d83f19132169b2234 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Apr 2018 13:08:09 +0200 Subject: [PATCH 26/26] Update README-FR.md --- README-FR.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-FR.md b/README-FR.md index 64bd18355cd..a9745bb8dbb 100644 --- a/README-FR.md +++ b/README-FR.md @@ -141,7 +141,7 @@ Les documentations utilisateur, développeur et traducteur sont disponible sous ## CONTRIBUER Ce projet existe grâce à ses nombreux contributeurs [[Contribuer](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. - + ## CREDITS