diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index dd2dd835a58..21f6c3407d9 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -100,8 +100,8 @@ class Adherent extends CommonObject public $datec; public $datem; - public $datefin; public $datevalid; + public $birth; public $note_public; @@ -119,6 +119,8 @@ class Adherent extends CommonObject */ public $fk_soc; + public $datefin; // From member table + // Fields loaded by fetch_subscriptions() public $first_subscription_date; public $first_subscription_amount; @@ -1223,11 +1225,9 @@ class Adherent extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Fonction qui recupere pour un adherent les parametres - * first_subscription_date - * first_subscription_amount - * last_subscription_date - * last_subscription_amount + * Function to get member subscriptions data + * first_subscription_date, first_subscription_date_start, first_subscription_date_end, first_subscription_amount + * last_subscription_date, last_subscription_date_start, last_subscription_date_end, last_subscription_amount * * @return int <0 si KO, >0 si OK */ @@ -1258,10 +1258,14 @@ class Adherent extends CommonObject { if ($i==0) { - $this->first_subscription_date=$obj->dateh; + $this->first_subscription_date=$this->db->jdate($obj->datec); + $this->first_subscription_date_start=$this->db->jdate($obj->dateh); + $this->first_subscription_date_end=$this->db->jdate($obj->datef); $this->first_subscription_amount=$obj->subscription; } - $this->last_subscription_date=$obj->dateh; + $this->last_subscription_date=$this->db->jdate($obj->datec); + $this->last_subscription_date_start=$this->db->jdate($obj->datef); + $this->last_subscription_date_end=$this->db->jdate($obj->datef); $this->last_subscription_amount=$obj->subscription; $subscription=new Subscription($this->db); @@ -1346,9 +1350,9 @@ class Adherent extends CommonObject { // Change properties of object (used by triggers) $this->last_subscription_date=dol_now(); - $this->last_subscription_amount=$amount; $this->last_subscription_date_start=$date; $this->last_subscription_date_end=$datefin; + $this->last_subscription_amount=$amount; } if (! $error) @@ -2279,8 +2283,13 @@ class Adherent extends CommonObject $this->need_subscription=0; $this->first_subscription_date=time(); + $this->first_subscription_date_start=$this->first_subscription_date; + $this->first_subscription_date_end=dol_time_plus_duree($this->first_subscription_date_start, 1, 'y'); $this->first_subscription_amount=10; - $this->last_subscription_date=time(); + + $this->last_subscription_date=$this->first_subscription_date; + $this->last_subscription_date_start=$this->first_subscription_date; + $this->last_subscription_date_end=dol_time_plus_duree($this->last_subscription_date_start, 1, 'y'); $this->last_subscription_amount=10; } @@ -2585,10 +2594,10 @@ class Adherent extends CommonObject * Send reminders by emails before subscription end * CAN BE A CRON TASK * - * @param int $daysbeforeend Nb of days before end of subscription (negative number = after subscription) - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + * @param string $daysbeforeendlist Nb of days before end of subscription (negative number = after subscription). Can be a list of delay, separated by a semicolon, for example '10;5;0;-5' + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function sendReminderForExpiredSubscription($daysbeforeend=10) + public function sendReminderForExpiredSubscription($daysbeforeendlist='10') { global $conf, $langs, $mysoc, $user; @@ -2606,97 +2615,110 @@ class Adherent extends CommonObject }*/ $now = dol_now(); + $nbok = 0; + $nbko = 0; - dol_syslog(__METHOD__, LOG_DEBUG); - - $tmp=dol_getdate($now); - $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), -1 * $daysbeforeend, 'd'); - - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; - $sql.= " WHERE datefin = '".$this->db->idate($datetosearchfor)."'"; - - $resql = $this->db->query($sql); - if ($resql) + $arraydaysbeforeend=explode(';',$daysbeforeendlist); + foreach($arraydaysbeforeend as $daysbeforeend) // Loop on each delay { - $num_rows = $this->db->num_rows($resql); + dol_syslog(__METHOD__.' - Process delta = '.$daysbeforeend, LOG_DEBUG); - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $adherent = new Adherent($this->db); - $formmail = new FormMail($this->db); - - $i=0; - $nbok = 0; - $nbko = 0; - while ($i < $num_rows) + if (! is_numeric($daysbeforeend)) { - $obj = $this->db->fetch_object($resql); + $blockingerrormsg="Value for delta is not a positive or negative numeric"; + $nbko++; + break; + } - $adherent->fetch($obj->rowid); + $tmp=dol_getdate($now); + $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd'); - if (empty($adherent->email)) + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; + $sql.= " WHERE datefin = '".$this->db->idate($datetosearchfor)."'"; + + $resql = $this->db->query($sql); + if ($resql) + { + $num_rows = $this->db->num_rows($resql); + + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $adherent = new Adherent($this->db); + $formmail = new FormMail($this->db); + + $i=0; + while ($i < $num_rows) { - $nbko++; - } - else - { - $adherent->fetch_thirdparty(); + $obj = $this->db->fetch_object($resql); - // Send reminder email - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); - // Load traductions files requiredby by page - $outputlangs->loadLangs(array("main", "members")); - dol_syslog("sendReminderForExpiredSubscription Language set to ".$outputlangs->defaultlang); + $adherent->fetch($obj->rowid, '', '', '', true, true); - $arraydefaultmessage=null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION; - - if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - - if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + if (empty($adherent->email)) { - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $adherent); - //if (is_array($adherent->thirdparty)) $substitutionarraycomp = ... - complete_substitutions_array($substitutionarray, $outputlangs, $adherent); - - $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); - $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = $conf->global->ADHERENT_MAIL_FROM; - $to = $adherent->email; - - $trackid = 'mem'.$adherent->id; - $moreinheader='X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n"; - - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, $moreinheader); - $result = $cmail->sendfile(); - if (! $result) - { - $error++; - $this->error = $cmail->error; - $this->errors += $cmail->errors; - $nbko++; - } - else - { - $nbok++; - } + $nbko++; } else { - $blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding"; - $nbko++; - break; - } - } + $adherent->fetch_thirdparty(); - $i++; + // Send reminder email + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); + $outputlangs->loadLangs(array("main", "members")); + dol_syslog("sendReminderForExpiredSubscription Language set to ".$outputlangs->defaultlang); + + $arraydefaultmessage=null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION; + + if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + + if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + { + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $adherent); + //if (is_array($adherent->thirdparty)) $substitutionarraycomp = ... + complete_substitutions_array($substitutionarray, $outputlangs, $adherent); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = $conf->global->ADHERENT_MAIL_FROM; + $to = $adherent->email; + + $trackid = 'mem'.$adherent->id; + $moreinheader='X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n"; + + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, $moreinheader); + $result = $cmail->sendfile(); + if (! $result) + { + $error++; + $this->error = $cmail->error; + $this->errors += $cmail->errors; + $nbko++; + } + else + { + $nbok++; + + // TODO Add event email sent for member + + } + } + else + { + $blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding"; + $nbko++; + break; + } + } + + $i++; + } + } + else + { + $this->error = $this->db->lasterror(); + return 1; } - } - else - { - $this->error = $this->db->lasterror(); - return 1; } if ($blockingerrormsg) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5912e8b6489..36863547eb0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1229,6 +1229,10 @@ class Facture extends CommonInvoice if ($user->rights->facture->lire) { $label = '' . $langs->trans("ShowInvoice") . ''; + if ($this->type == self::TYPE_REPLACEMENT) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceReplace") . ''; + if ($this->type == self::TYPE_CREDIT_NOTE) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceAvoir") . ''; + if ($this->type == self::TYPE_DEPOSIT) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceDeposit") . ''; + if ($this->type == self::TYPE_SITUATION) $label='' . $langs->transnoentitiesnoconv("ShowInvoiceSituation") . ''; if (! empty($this->ref)) $label .= '
'.$langs->trans('Ref') . ': ' . $this->ref; if (! empty($this->ref_client)) @@ -1243,10 +1247,6 @@ class Facture extends CommonInvoice $label.= '
' . $langs->trans('LT2') . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_ttc)) $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; - if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; - if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; - if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; if ($moretitle) $label.=' - '.$moretitle; } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 348bd7b9fe5..e281fbe5c60 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -76,9 +76,11 @@ class box_factures extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic=new Facture($db); + $facturestatic = new Facture($db); $societestatic = new Societe($db); + $langs->load("bills"); + $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max); $this->info_box_head = array( 'text' => $text, @@ -92,9 +94,7 @@ class box_factures extends ModeleBoxes $sql.= ", f.total_ttc"; $sql.= ", f.datef as df"; $sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; - $sql.= ", s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; + $sql.= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql.= ", f.date_lim_reglement as datelimite"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -121,6 +121,7 @@ class box_factures extends ModeleBoxes $datelimite = $db->jdate($objp->datelimite); $date = $db->jdate($objp->df); $datem = $db->jdate($objp->tms); + $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->facnumber; $facturestatic->type = $objp->type; @@ -133,7 +134,14 @@ class box_factures extends ModeleBoxes $societestatic->id = $objp->socid; $societestatic->name = $objp->name; $societestatic->code_client = $objp->code_client; - + $societestatic->tva_intra = $objp->tva_intra; + $societestatic->email = $objp->email; + $societestatic->idprof1 = $objp->idprof1; + $societestatic->idprof2 = $objp->idprof2; + $societestatic->idprof3 = $objp->idprof3; + $societestatic->idprof4 = $objp->idprof4; + $societestatic->idprof5 = $objp->idprof5; + $societestatic->idprof6 = $objp->idprof6; $late = ''; if ($facturestatic->hasDelay()) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d53e20fdc7d..4424d3fa904 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5982,6 +5982,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__'; $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; if (is_object($object) && $object->element == 'member') @@ -6044,6 +6045,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone; $substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso; $substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile; + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE__'] = dol_print_date($object->last_subscription_date, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->last_subscription_date_start, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->last_subscription_date_end, 'dayrfc'); if (is_object($object) && $object->element == 'societe') { @@ -6212,7 +6219,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob * @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...) * @param Translate $outputlangs Output language * @return string Output string after substitutions - * @see complete_substitutions_array + * @see complete_substitutions_array, getCommonSubstitutionArray */ function make_substitutions($text, $substitutionarray, $outputlangs=null) { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index cbe6b36ef73..cd58eae7a8c 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1504,11 +1504,11 @@ if ($action == 'create') print ''; print ''; - //print $line->fk_product.' - '.$dbatch->batch; + //print '|'.$line->fk_product.'|'.$dbatch->batch.'|
'; print $langs->trans("Batch").': '; $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch); if ($result > 0) print $productlotObject->getNomUrl(1); - else print 'TableLotIncompleteRunRepair'; + else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed'; print ' ('.$dbatch->qty.')'; $quantityToBeDelivered -= $deliverableQty; if ($quantityToBeDelivered < 0) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index c51f8c8d1b1..8fa24a97a69 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -810,7 +810,7 @@ if ($ok && GETPOST('clean_product_stock_batch','alpha')) } -// clean_linked_elements: Check and clean linked elements +// clean_product_stock_negative_if_batch if ($ok && GETPOST('clean_product_stock_negative_if_batch','alpha')) { print '
Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)'; @@ -834,12 +834,13 @@ if ($ok && GETPOST('clean_product_stock_negative_if_batch','alpha')) $obj=$db->fetch_object($resql); print ''.$obj->rowid.'-'.$obj->ref.'-'.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' != '.$obj->reelbatch; + // TODO } } } } -// clean_linked_elements: Check and clean linked elements +// set_empty_time_spent_amount if ($ok && GETPOST('set_empty_time_spent_amount','alpha')) { print '
*** Set value of time spent without amount'; @@ -900,7 +901,7 @@ if ($ok && GETPOST('set_empty_time_spent_amount','alpha')) } -// clean_old_module_entries: Clean data into const when files of module were removed without being +// force_disable_of_modules_not_found if ($ok && GETPOST('force_disable_of_modules_not_found','alpha')) { print '
*** Force modules not found to be disabled (only modules adding js, css or hooks can be detected as removed)'; @@ -1071,7 +1072,7 @@ if ($ok && GETPOST('clean_perm_table','alpha')) -// clean_linked_elements: Check and clean linked elements +// force utf8 on tables if ($ok && GETPOST('force_utf8_on_tables','alpha')) { print '
*** Force page code and collation of tables into utf8/utf8_unicode_ci (for mysql/mariadb only)'; diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 7b475b25ce6..e5975516e4f 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -194,4 +194,4 @@ SubscriptionRecorded=Subscription recorded NoEmailSentToMember=No email sent to member EmailSentToMember=Email sent to member at %s SendReminderForExpiredSubscriptionTitle=Send reminder by email for expired subscription -SendReminderForExpiredSubscription=Send reminder by email to members when subscription is about to expire (parameter is number of days before end of subscription to send the remind) +SendReminderForExpiredSubscription=Send reminder by email to members when subscription is about to expire (parameter is number of days before end of subscription to send the remind. It can be a list of days separated by a semicolon, for example '10;5;0;-5') diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 0eff61cd9fa..f4163d61d3c 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1429,7 +1429,7 @@ if ($action != 'dopayment') { if ($source == 'invoice' && $object->paye) { - print '

'.$langs->trans("InvoicePaid"); + print '

'.$langs->trans("InvoicePaid").''; } else {