Merge branch '8.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/adherents/class/adherent.class.php
This commit is contained in:
Laurent Destailleur 2018-10-10 01:51:54 +02:00
commit 8f4b74733c
8 changed files with 145 additions and 107 deletions

View File

@ -100,8 +100,8 @@ class Adherent extends CommonObject
public $datec; public $datec;
public $datem; public $datem;
public $datefin;
public $datevalid; public $datevalid;
public $birth; public $birth;
public $note_public; public $note_public;
@ -119,6 +119,8 @@ class Adherent extends CommonObject
*/ */
public $fk_soc; public $fk_soc;
public $datefin; // From member table
// Fields loaded by fetch_subscriptions() // Fields loaded by fetch_subscriptions()
public $first_subscription_date; public $first_subscription_date;
public $first_subscription_amount; public $first_subscription_amount;
@ -1223,11 +1225,9 @@ class Adherent extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Fonction qui recupere pour un adherent les parametres * Function to get member subscriptions data
* first_subscription_date * first_subscription_date, first_subscription_date_start, first_subscription_date_end, first_subscription_amount
* first_subscription_amount * last_subscription_date, last_subscription_date_start, last_subscription_date_end, last_subscription_amount
* last_subscription_date
* last_subscription_amount
* *
* @return int <0 si KO, >0 si OK * @return int <0 si KO, >0 si OK
*/ */
@ -1258,10 +1258,14 @@ class Adherent extends CommonObject
{ {
if ($i==0) 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->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; $this->last_subscription_amount=$obj->subscription;
$subscription=new Subscription($this->db); $subscription=new Subscription($this->db);
@ -1346,9 +1350,9 @@ class Adherent extends CommonObject
{ {
// Change properties of object (used by triggers) // Change properties of object (used by triggers)
$this->last_subscription_date=dol_now(); $this->last_subscription_date=dol_now();
$this->last_subscription_amount=$amount;
$this->last_subscription_date_start=$date; $this->last_subscription_date_start=$date;
$this->last_subscription_date_end=$datefin; $this->last_subscription_date_end=$datefin;
$this->last_subscription_amount=$amount;
} }
if (! $error) if (! $error)
@ -2279,8 +2283,13 @@ class Adherent extends CommonObject
$this->need_subscription=0; $this->need_subscription=0;
$this->first_subscription_date=time(); $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->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; $this->last_subscription_amount=10;
} }
@ -2585,10 +2594,10 @@ class Adherent extends CommonObject
* Send reminders by emails before subscription end * Send reminders by emails before subscription end
* CAN BE A CRON TASK * CAN BE A CRON TASK
* *
* @param int $daysbeforeend Nb of days before end of subscription (negative number = after subscription) * @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) * @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; global $conf, $langs, $mysoc, $user;
@ -2606,11 +2615,23 @@ class Adherent extends CommonObject
}*/ }*/
$now = dol_now(); $now = dol_now();
$nbok = 0;
$nbko = 0;
dol_syslog(__METHOD__, LOG_DEBUG); $arraydaysbeforeend=explode(';',$daysbeforeendlist);
foreach($arraydaysbeforeend as $daysbeforeend) // Loop on each delay
{
dol_syslog(__METHOD__.' - Process delta = '.$daysbeforeend, LOG_DEBUG);
if (! is_numeric($daysbeforeend))
{
$blockingerrormsg="Value for delta is not a positive or negative numeric";
$nbko++;
break;
}
$tmp=dol_getdate($now); $tmp=dol_getdate($now);
$datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), -1 * $daysbeforeend, 'd'); $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd');
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent';
$sql.= " WHERE datefin = '".$this->db->idate($datetosearchfor)."'"; $sql.= " WHERE datefin = '".$this->db->idate($datetosearchfor)."'";
@ -2625,13 +2646,11 @@ class Adherent extends CommonObject
$formmail = new FormMail($this->db); $formmail = new FormMail($this->db);
$i=0; $i=0;
$nbok = 0;
$nbko = 0;
while ($i < $num_rows) while ($i < $num_rows)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$adherent->fetch($obj->rowid); $adherent->fetch($obj->rowid, '', '', '', true, true);
if (empty($adherent->email)) if (empty($adherent->email))
{ {
@ -2644,7 +2663,6 @@ class Adherent extends CommonObject
// Send reminder email // Send reminder email
$outputlangs = new Translate('', $conf); $outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); $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")); $outputlangs->loadLangs(array("main", "members"));
dol_syslog("sendReminderForExpiredSubscription Language set to ".$outputlangs->defaultlang); dol_syslog("sendReminderForExpiredSubscription Language set to ".$outputlangs->defaultlang);
@ -2680,6 +2698,9 @@ class Adherent extends CommonObject
else else
{ {
$nbok++; $nbok++;
// TODO Add event email sent for member
} }
} }
else else
@ -2698,6 +2719,7 @@ class Adherent extends CommonObject
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
return 1; return 1;
} }
}
if ($blockingerrormsg) if ($blockingerrormsg)
{ {

View File

@ -1229,6 +1229,10 @@ class Facture extends CommonInvoice
if ($user->rights->facture->lire) { if ($user->rights->facture->lire) {
$label = '<u>' . $langs->trans("ShowInvoice") . '</u>'; $label = '<u>' . $langs->trans("ShowInvoice") . '</u>';
if ($this->type == self::TYPE_REPLACEMENT) $label='<u>' . $langs->transnoentitiesnoconv("ShowInvoiceReplace") . '</u>';
if ($this->type == self::TYPE_CREDIT_NOTE) $label='<u>' . $langs->transnoentitiesnoconv("ShowInvoiceAvoir") . '</u>';
if ($this->type == self::TYPE_DEPOSIT) $label='<u>' . $langs->transnoentitiesnoconv("ShowInvoiceDeposit") . '</u>';
if ($this->type == self::TYPE_SITUATION) $label='<u>' . $langs->transnoentitiesnoconv("ShowInvoiceSituation") . '</u>';
if (! empty($this->ref)) if (! empty($this->ref))
$label .= '<br><b>'.$langs->trans('Ref') . ':</b> ' . $this->ref; $label .= '<br><b>'.$langs->trans('Ref') . ':</b> ' . $this->ref;
if (! empty($this->ref_client)) if (! empty($this->ref_client))
@ -1243,10 +1247,6 @@ class Facture extends CommonInvoice
$label.= '<br><b>' . $langs->trans('LT2') . ':</b> ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency); $label.= '<br><b>' . $langs->trans('LT2') . ':</b> ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency);
if (! empty($this->total_ttc)) if (! empty($this->total_ttc))
$label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); $label.= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . 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; if ($moretitle) $label.=' - '.$moretitle;
} }

View File

@ -79,6 +79,8 @@ class box_factures extends ModeleBoxes
$facturestatic = new Facture($db); $facturestatic = new Facture($db);
$societestatic = new Societe($db); $societestatic = new Societe($db);
$langs->load("bills");
$text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max); $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max);
$this->info_box_head = array( $this->info_box_head = array(
'text' => $text, 'text' => $text,
@ -92,9 +94,7 @@ class box_factures extends ModeleBoxes
$sql.= ", f.total_ttc"; $sql.= ", f.total_ttc";
$sql.= ", f.datef as df"; $sql.= ", f.datef as df";
$sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; $sql.= ", f.paye, f.fk_statut, f.datec, f.tms";
$sql.= ", s.nom as name"; $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.= ", s.rowid as socid";
$sql.= ", s.code_client";
$sql.= ", f.date_lim_reglement as datelimite"; $sql.= ", f.date_lim_reglement as datelimite";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $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"; 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); $datelimite = $db->jdate($objp->datelimite);
$date = $db->jdate($objp->df); $date = $db->jdate($objp->df);
$datem = $db->jdate($objp->tms); $datem = $db->jdate($objp->tms);
$facturestatic->id = $objp->facid; $facturestatic->id = $objp->facid;
$facturestatic->ref = $objp->facnumber; $facturestatic->ref = $objp->facnumber;
$facturestatic->type = $objp->type; $facturestatic->type = $objp->type;
@ -133,7 +134,14 @@ class box_factures extends ModeleBoxes
$societestatic->id = $objp->socid; $societestatic->id = $objp->socid;
$societestatic->name = $objp->name; $societestatic->name = $objp->name;
$societestatic->code_client = $objp->code_client; $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 = ''; $late = '';
if ($facturestatic->hasDelay()) { if ($facturestatic->hasDelay()) {

View File

@ -5982,6 +5982,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
$substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__';
$substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__';
$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__';
$substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__';
if (is_object($object) && $object->element == 'member') 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_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone;
$substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso; $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_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') 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 array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...)
* @param Translate $outputlangs Output language * @param Translate $outputlangs Output language
* @return string Output string after substitutions * @return string Output string after substitutions
* @see complete_substitutions_array * @see complete_substitutions_array, getCommonSubstitutionArray
*/ */
function make_substitutions($text, $substitutionarray, $outputlangs=null) function make_substitutions($text, $substitutionarray, $outputlangs=null)
{ {

View File

@ -1504,11 +1504,11 @@ if ($action == 'create')
print '<!-- Show details of lot -->'; print '<!-- Show details of lot -->';
print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">'; print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">';
//print $line->fk_product.' - '.$dbatch->batch; //print '|'.$line->fk_product.'|'.$dbatch->batch.'|<br>';
print $langs->trans("Batch").': '; print $langs->trans("Batch").': ';
$result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch); $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
if ($result > 0) print $productlotObject->getNomUrl(1); if ($result > 0) print $productlotObject->getNomUrl(1);
else print 'TableLotIncompleteRunRepair'; else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed';
print ' ('.$dbatch->qty.')'; print ' ('.$dbatch->qty.')';
$quantityToBeDelivered -= $deliverableQty; $quantityToBeDelivered -= $deliverableQty;
if ($quantityToBeDelivered < 0) if ($quantityToBeDelivered < 0)

View File

@ -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')) if ($ok && GETPOST('clean_product_stock_negative_if_batch','alpha'))
{ {
print '<tr><td colspan="2"><br>Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)</td></tr>'; print '<tr><td colspan="2"><br>Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)</td></tr>';
@ -834,12 +834,13 @@ if ($ok && GETPOST('clean_product_stock_negative_if_batch','alpha'))
$obj=$db->fetch_object($resql); $obj=$db->fetch_object($resql);
print '<tr><td>'.$obj->rowid.'-'.$obj->ref.'-'.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' != '.$obj->reelbatch; print '<tr><td>'.$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')) if ($ok && GETPOST('set_empty_time_spent_amount','alpha'))
{ {
print '<tr><td colspan="2"><br>*** Set value of time spent without amount</td></tr>'; print '<tr><td colspan="2"><br>*** Set value of time spent without amount</td></tr>';
@ -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')) if ($ok && GETPOST('force_disable_of_modules_not_found','alpha'))
{ {
print '<tr><td colspan="2"><br>*** Force modules not found to be disabled (only modules adding js, css or hooks can be detected as removed)</td></tr>'; print '<tr><td colspan="2"><br>*** Force modules not found to be disabled (only modules adding js, css or hooks can be detected as removed)</td></tr>';
@ -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')) if ($ok && GETPOST('force_utf8_on_tables','alpha'))
{ {
print '<tr><td colspan="2"><br>*** Force page code and collation of tables into utf8/utf8_unicode_ci (for mysql/mariadb only)</td></tr>'; print '<tr><td colspan="2"><br>*** Force page code and collation of tables into utf8/utf8_unicode_ci (for mysql/mariadb only)</td></tr>';

View File

@ -194,4 +194,4 @@ SubscriptionRecorded=Subscription recorded
NoEmailSentToMember=No email sent to member NoEmailSentToMember=No email sent to member
EmailSentToMember=Email sent to member at %s EmailSentToMember=Email sent to member at %s
SendReminderForExpiredSubscriptionTitle=Send reminder by email for expired subscription 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')

View File

@ -1429,7 +1429,7 @@ if ($action != 'dopayment')
{ {
if ($source == 'invoice' && $object->paye) if ($source == 'invoice' && $object->paye)
{ {
print '<br><br>'.$langs->trans("InvoicePaid"); print '<br><br><span class="amountpaymentcomplete">'.$langs->trans("InvoicePaid").'</span>';
} }
else else
{ {