From 01e9d1bf4b3c29fb68a22de9f54d8434cdf34022 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 20 Dec 2022 18:38:01 +0100 Subject: [PATCH 001/203] NEW : Uniformize stat adh in boxes and index --- htdocs/adherents/class/adherent.class.php | 4 +- .../adherents/class/adherentstats.class.php | 53 +++++++ htdocs/adherents/index.php | 50 ++---- htdocs/core/boxes/box_members_by_type.php | 147 ++++++------------ 4 files changed, 119 insertions(+), 135 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4c68b3e91ec..215e7de4bc2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2381,8 +2381,8 @@ class Adherent extends CommonObject $labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort"); } elseif (!$date_end_subscription) { $statusType = 'status1'; - $labelStatus = $langs->trans("MemberStatusActive"); - $labelStatusShort = $langs->trans("MemberStatusActiveShort"); + $labelStatus = $langs->trans("WaitingSubscription"); + $labelStatusShort = $langs->trans("WaitingSubscription"); } elseif ($date_end_subscription < dol_now()) { // expired $statusType = 'status8'; $labelStatus = $langs->trans("MemberStatusActiveLate"); diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 9aa2fe2e8ad..b2d856904fe 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -181,4 +181,57 @@ class AdherentStats extends Stats return $this->_getAllByYear($sql); } + + + /** + * Return count of member by status group by adh type, total and average + * + * @return array Array with + */ + public function countMembersByTypeAndStatus() + { + global $user; + + $now = dol_now(); + + $sql = "SELECT COALESCE(d.fk_adherent_type, 'total') as fk_adherent_type, t.libelle as label"; + $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_DRAFT." THEN 'members_draft' ELSE NULL END) as members_draft"; + $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1') THEN 'members_pending' ELSE NULL END) as members_pending"; + $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0) THEN 'members_uptodate' ELSE NULL END) as members_uptodate"; + $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1) THEN 'members_expired' ELSE NULL END) as members_expired"; + $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_EXCLUDED." THEN 'members_excluded' ELSE NULL END) as members_excluded"; + $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_RESILIATED." THEN 'members_resiliated' ELSE NULL END) as members_resiliated"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d , ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " WHERE t.rowid = d.fk_adherent_type"; + $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND t.entity IN (".getEntity('member_type').")"; + $sql .= " AND t.statut = 1"; + $sql .= " GROUP BY d.fk_adherent_type"; + $sql .= " WITH ROLLUP;"; + + dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + $MembersCountArray = []; + while ($i < $num) { + $objp = $this->db->fetch_object($result); + $MembersCountArray[$objp->fk_adherent_type] = array( + "label" => $objp->label, + "members_draft" => (int) $objp->members_draft, + "members_pending" => (int) $objp->members_pending, + "members_uptodate" => (int) $objp->members_uptodate, + "members_expired" => (int) $objp->members_expired, + "members_excluded" => (int) $objp->members_excluded, + "members_resiliated" => (int) $objp->members_resiliated + ); + $i++; + } + $this->db->free($result); + } + return $MembersCountArray; + } + } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index a5f9c26f192..e6d069bc3e2 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -85,6 +85,7 @@ $subscriptionstatic = new Subscription($db); print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members'); +/* $MembersValidated = array(); $MembersToValidate = array(); $MembersWaitingSubscription = array(); @@ -217,43 +218,24 @@ if ($conf->use_javascript_ajax) { $boxgraph .=''; $boxgraph .=''; $boxgraph .=''; $boxgraph .= ''; $boxgraph .= '
'.$langs->trans("Statistics").'
'; + + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; + $stats = new AdherentStats($db, 0, $userid); - $SumToValidate = 0; - $SumWaitingSubscription = 0; - $SumUpToDate = 0; - $SumExpired = 0; - $SumResiliated = 0; - $SumExcluded = 0; - - $total = 0; - $dataval = array(); - $i = 0; - foreach ($AdherentType as $key => $adhtype) { - $dataval['draft'][] = array($i, isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0); - $dataval['waitingsubscription'][] = array($i, isset($MembersWaitingSubscription[$key]) ? $MembersWaitingSubscription[$key] : 0); - $dataval['uptodate'][] = array($i, isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0); - $dataval['expired'][] = array($i, isset($MembersExpired[$key]) ? $MembersExpired[$key] : 0); - $dataval['excluded'][] = array($i, isset($MembersExcluded[$key]) ? $MembersExcluded[$key] : 0); - $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); - - $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; - $SumWaitingSubscription += isset($MembersWaitingSubscription[$key]) ? $MembersWaitingSubscription[$key] : 0; - $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0; - $SumExpired += isset($MembersExpired[$key]) ? $MembersExpired[$key] : 0; - $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0; - $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; - $i++; - } - $total = $SumToValidate + $SumWaitingSubscription + $SumUpToDate + $SumExpired + $SumExcluded + $SumResiliated; + // Show array + $sumMembers = $stats->countMembersByTypeAndStatus(); + $total = $sumMembers['total']['members_draft'] + $sumMembers['total']['members_pending'] + $sumMembers['total']['members_uptodate'] + $sumMembers['total']['members_expired'] + $sumMembers['total']['members_excluded'] + $sumMembers['total']['members_resiliated']; + $dataseries = array(); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SumToValidate)); // Draft, not yet validated - $dataseries[] = array($langs->transnoentitiesnoconv("WaitingSubscription"), round($SumWaitingSubscription)); - $dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), round($SumUpToDate)); - $dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), round($SumExpired)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), round($SumExcluded)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SumResiliated)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), $sumMembers['total']['members_draft']); // Draft, not yet validated + $dataseries[] = array($langs->transnoentitiesnoconv("WaitingSubscription"), $sumMembers['total']['members_pending']); + $dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), $sumMembers['total']['members_uptodate']); + $dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), $sumMembers['total']['members_expired']); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), $sumMembers['total']['members_excluded']); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), $sumMembers['total']['members_resiliated']); include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + echo "
";var_dump($total); echo "
"; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); @@ -268,7 +250,7 @@ if ($conf->use_javascript_ajax) { $boxgraph .= '
'.$langs->trans("Total").''; - $boxgraph .= $SumToValidate + $SumWaitingSubscription + $SumUpToDate + $SumExpired + $SumExcluded + $SumResiliated; + $boxgraph .= $total; $boxgraph .= '
'; $boxgraph .= ''; diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 2e25da59564..ef64053b9be 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -91,124 +91,64 @@ class box_members_by_type extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType", $max)); if ($user->rights->adherent->lire) { - $MembersToValidate = array(); - $MembersValidated = array(); - $MembersUpToDate = array(); - $MembersExcluded = array(); - $MembersResiliated = array(); - - $SumToValidate = 0; - $SumValidated = 0; - $SumUpToDate = 0; - $SumResiliated = 0; - $SumExcluded = 0; - - $AdherentType = array(); - - // Type of membership - $sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; - $sql .= " d.statut, count(d.rowid) as somme"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "adherent as d"; - $sql .= " ON t.rowid = d.fk_adherent_type"; - $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; - $sql .= " WHERE t.entity IN (" . getEntity('member_type') . ")"; - $sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; - - dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $this->db->fetch_object($result); - - $adhtype = new AdherentType($this->db); - $adhtype->id = $objp->rowid; - $adhtype->subscription = $objp->subscription; - $adhtype->label = $objp->label; - $AdherentType[$objp->rowid] = $adhtype; - - if ($objp->statut == Adherent::STATUS_DRAFT) { - $MembersToValidate[$objp->rowid] = $objp->somme; - } - if ($objp->statut == Adherent::STATUS_VALIDATED) { - $MembersValidated[$objp->rowid] = $objp->somme; - } - if ($objp->statut == Adherent::STATUS_EXCLUDED) { - $MembersExcluded[$objp->rowid] = $objp->somme; - } - if ($objp->statut == Adherent::STATUS_RESILIATED) { - $MembersResiliated[$objp->rowid] = $objp->somme; - } - - $i++; - } - $this->db->free($result); - $now = dol_now(); - - // Members up to date list - // current rule: uptodate = the end date is in future whatever is type - // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) - $sql = "SELECT count(*) as somme , d.fk_adherent_type"; - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t"; - $sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")"; - $sql .= " AND d.statut = 1 AND (d.datefin >= '" . $this->db->idate($now) . "' OR t.subscription = 0)"; - $sql .= " AND t.rowid = d.fk_adherent_type"; - $sql .= " GROUP BY d.fk_adherent_type"; - - dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num2 = $this->db->num_rows($result); - $i = 0; - while ($i < $num2) { - $objp = $this->db->fetch_object($result); - $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $this->db->free($result); - } + + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; + $stats = new AdherentStats($this->db, $user->socid, $user->id); + // Show array + $sumMembers = $stats->countMembersByTypeAndStatus(); + if ($sumMembers) { $line = 0; $this->info_box_contents[$line][] = array( 'td' => 'class=""', 'text' => '', ); + // Members Status To Valid $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); - $labelstatus = $langs->trans("UpToDate"); + // Waiting for subscription + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus, + ); + // Up to date $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus, ); - $labelstatus = $langs->trans("OutOfDate"); + // Out of date $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); + // Excluded $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); + // Resiliated $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); $line++; - foreach ($AdherentType as $key => $adhtype) { - $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; - $SumValidated += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0; - $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0; - $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0; - $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + foreach ($sumMembers as $key => $data) { + $adhtype = new AdherentType($this->db); + $adhtype->id = $key; + + if($key=='total'){ + break; + } + $adhtype->label = $data['label']; + $AdherentType[$key] = $adhtype; $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', @@ -217,36 +157,40 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersToValidate[$key]) && $MembersToValidate[$key] > 0 ? $MembersToValidate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), + 'text' => (isset($data['members_draft']) && $data['members_draft'] > 0 ? $data['members_draft'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'text' => (isset($data['members_pending']) && $data['members_pending'] > 0 ? $data['members_pending'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'text' => (isset($data['members_uptodate']) && $data['members_uptodate'] > 0 ? $data['members_uptodate'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersExcluded[$key]) && $MembersExcluded[$key] > 0 ? $MembersExcluded[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, $now, 3), + 'text' => (isset($data['members_expired']) && $data['members_expired'] > 0 ? $data['members_expired'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), 'asis' => 1, ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => (isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'text' => (isset($data['members_excluded']) && $data['members_excluded'] > 0 ? $data['members_excluded'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, $now, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_resiliated']) && $data['members_resiliated'] > 0 ? $data['members_resiliated'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), 'asis' => 1, ); - $line++; } - if ($num == 0) { + if (count($sumMembers) == 0) { $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', + 'td' => 'class="center" colspan="6"', 'text' => $langs->trans("NoRecordedMembersByType") ); } else { @@ -257,27 +201,32 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumToValidate.' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), + 'text' => $sumMembers['total']['members_draft'].' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumUpToDate.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'text' => $sumMembers['total']['members_pending'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumValidated.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'text' => $sumMembers['total']['members_uptodate'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumExcluded.' '.$staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, 0, 3), + 'text' => $sumMembers['total']['members_expired'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumResiliated.' '.$staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'text' => $sumMembers['total']['members_excluded'].' '.$staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_resiliated'].' '.$staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), 'asis' => 1 ); } From 300c58dd3835790e1ad5d93807e733b51512db37 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 20 Dec 2022 18:45:21 +0100 Subject: [PATCH 002/203] Clean code --- htdocs/adherents/index.php | 124 ------------------------------------- 1 file changed, 124 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index e6d069bc3e2..29a21f03fc7 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -85,129 +85,6 @@ $subscriptionstatic = new Subscription($db); print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members'); -/* -$MembersValidated = array(); -$MembersToValidate = array(); -$MembersWaitingSubscription = array(); -$MembersUpToDate = array(); -$MembersExpired = array(); -$MembersExcluded = array(); -$MembersResiliated = array(); - -$AdherentType = array(); - -// Type of membership -$sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; -$sql .= " d.statut, count(d.rowid) as somme"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; -$sql .= " ON t.rowid = d.fk_adherent_type"; -$sql .= " AND d.entity IN (".getEntity('adherent').")"; -$sql .= " WHERE t.entity IN (".getEntity('member_type').")"; -$sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; - -dol_syslog("index.php::select nb of members per type", LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - - $adhtype = new AdherentType($db); - $adhtype->id = $objp->rowid; - $adhtype->subscription = $objp->subscription; - $adhtype->label = $objp->label; - $AdherentType[$objp->rowid] = $adhtype; - - if ($objp->statut == -1) { - $MembersToValidate[$objp->rowid] = $objp->somme; - } - if ($objp->statut == 1) { - $MembersValidated[$objp->rowid] = $objp->somme; - } - if ($objp->statut == -2) { - $MembersExcluded[$objp->rowid] = $objp->somme; - } - if ($objp->statut == 0) { - $MembersResiliated[$objp->rowid] = $objp->somme; - } - - $i++; - } - $db->free($resql); -} - -$now = dol_now(); - -// Members waiting subscription -$sql = "SELECT count(*) as somme , d.fk_adherent_type"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut = 1"; // validated -$sql .= " AND (d.datefin IS NULL AND t.subscription = '1')"; -$sql .= " AND t.rowid = d.fk_adherent_type"; -$sql .= " GROUP BY d.fk_adherent_type"; - -dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - $MembersWaitingSubscription[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $db->free($resql); -} - -// Members up to date list -// current rule: uptodate = the end date is in future or no subcription required -// old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) -$sql = "SELECT count(*) as somme , d.fk_adherent_type"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut = 1"; // validated -$sql .= " AND (d.datefin >= '".$db->idate($now)."' OR t.subscription = '0')"; // end date in future -$sql .= " AND t.rowid = d.fk_adherent_type"; -$sql .= " GROUP BY d.fk_adherent_type"; - -dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $db->free($resql); -} - -// Members expired list -$sql = "SELECT count(*) as somme , d.fk_adherent_type"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut = 1"; // validated -$sql .= " AND (d.datefin < '".$db->idate($now)."' AND t.subscription = '1')"; -$sql .= " AND t.rowid = d.fk_adherent_type"; -$sql .= " GROUP BY d.fk_adherent_type"; - -dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - $MembersExpired[$objp->fk_adherent_type] = $objp->somme; - $i++; - } - $db->free($resql); -} - /* * Statistics */ @@ -235,7 +112,6 @@ if ($conf->use_javascript_ajax) { $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), $sumMembers['total']['members_resiliated']); include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - echo "
";var_dump($total); echo "
"; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); From 21e22ee990876d46275a2a54893d24f2d97fffab Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 20 Dec 2022 18:06:23 +0000 Subject: [PATCH 003/203] Fixing style errors. --- htdocs/adherents/class/adherentstats.class.php | 7 +++---- htdocs/adherents/index.php | 4 ++-- htdocs/core/boxes/box_members_by_type.php | 4 +--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index b2d856904fe..6e29f988ada 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -186,7 +186,7 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @return array Array with + * @return array Array with */ public function countMembersByTypeAndStatus() { @@ -208,10 +208,10 @@ class AdherentStats extends Stats $sql .= " AND t.statut = 1"; $sql .= " GROUP BY d.fk_adherent_type"; $sql .= " WITH ROLLUP;"; - + dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); $result = $this->db->query($sql); - + if ($result) { $num = $this->db->num_rows($result); $i = 0; @@ -233,5 +233,4 @@ class AdherentStats extends Stats } return $MembersCountArray; } - } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 29a21f03fc7..823ea6edfce 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -95,14 +95,14 @@ if ($conf->use_javascript_ajax) { $boxgraph .=''; $boxgraph .=''; $boxgraph .=''; + print ''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } // Accountancy code buy if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } From 25eb177bea63333a9a52e53d3b55e8b6dfa736f9 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 8 May 2023 22:39:52 +0200 Subject: [PATCH 039/203] Fix search in hidden ecotaxe dictionary by code. --- htdocs/admin/dict.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 774ade233bd..8c3317a46c9 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1250,6 +1250,8 @@ if ($id > 0) { $sql .= natural_search("f.code", $search_code); } elseif ($search_code != '' && $id == 2) { $sql .= natural_search("d.code_departement", $search_code); + } elseif ($search_code != '' && $id == 14) { + $sql .= natural_search("e.code", $search_code); } elseif ($search_code != '' && $id != 9) { $sql .= natural_search("code", $search_code); } From 1b75dc54b45d029fd60be33799374254e72797f6 Mon Sep 17 00:00:00 2001 From: hystepik Date: Tue, 9 May 2023 11:04:53 +0200 Subject: [PATCH 040/203] can update and create --- htdocs/core/lib/sendings.lib.php | 7 + htdocs/expedition/dispatch.php | 1086 ++++++++++++++++++++++ htdocs/expedition/js/lib_dispatch.js.php | 222 +++++ htdocs/langs/en_US/sendings.lang | 3 + 4 files changed, 1318 insertions(+) create mode 100644 htdocs/expedition/dispatch.php create mode 100644 htdocs/expedition/js/lib_dispatch.js.php diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index cfbed82f9d3..60566dae909 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -47,6 +47,13 @@ function shipping_prepare_head($object) $head[$h][2] = 'shipping'; $h++; + if ($object->statut == Expedition::STATUS_DRAFT) { + $head[$h][0] = DOL_URL_ROOT."/expedition/dispatch.php?id=".$object->id; + $head[$h][1] = $langs->trans("DispatchCard"); + $head[$h][2] = 'dispatch'; + $h++; + } + if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY') && $user->rights->expedition->delivery->lire) { // delivery link $object->fetchObjectLinked($object->id, $object->element); diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php new file mode 100644 index 00000000000..be586906c3f --- /dev/null +++ b/htdocs/expedition/dispatch.php @@ -0,0 +1,1086 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2010-2021 Juanjo Menent + * Copyright (C) 2014 Cedric Gross + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2017-2022 Ferran Marcet + * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2019-2020 Christophe Battarel + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/fourn/expedition/dispatch.php + * \ingroup expedition + * \brief Page to dispatch expediting + */ + +// Load Dolibarr environment +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; + + + +if (isModEnabled('project')) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +} + +// Load translation files required by the page +$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal')); + +if (isModEnabled('productbatch')) { + $langs->load('productbatch'); +} + + // Security check +$id = GETPOST("id", 'int'); +$ref = GETPOST('ref'); +$lineid = GETPOST('lineid', 'int'); +$action = GETPOST('action', 'aZ09'); +$fk_default_warehouse = GETPOST('fk_default_warehouse', 'int'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); + +if ($user->socid) { + $socid = $user->socid; +} + +$hookmanager->initHooks(array('expeditiondispatch')); + +// Recuperation de l'id de projet +$projectid = 0; +if (GETPOSTISSET("projectid")) { + $projectid = GETPOST("projectid", 'int'); +} + +$object = new Expedition($db); +$objectorder = new Commande($db); + +if ($id > 0 || !empty($ref)) { + $result = $object->fetch($id, $ref); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + $result = $object->fetch_thirdparty(); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + if (!empty($object->origin)) { + $origin = $object->origin; + + $object->fetch_origin(); + $typeobject = $object->origin; + } +} + +// $id is id of a purchase order. +$result = restrictedArea($user, 'expedition', $object->id, ''); + +if (!isModEnabled('stock')) { + accessforbidden(); +} + +$usercancreate = $user->hasRight('expedition', 'creer'); +$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php + +/* + * Actions + */ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +// Update a dispatched line +if ($action == 'updatelines' && $usercancreate) { + $db->begin(); + $error = 0; + + $expeditiondispatch = new ExpeditionLigne($db); + $expeditionlinebatch = new ExpeditionLineBatch($db); + + $pos = 0; + + foreach ($_POST as $key => $value) { + // without batch module enabled + $reg = array(); + if (preg_match('/^product_.*([0-9]+)_([0-9]+)$/i', $key, $reg)) { + $pos++; + if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { + $modebatch = "barcode"; + } elseif (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) { // With batchmode enabled + $modebatch = "batch"; + } + + $numline = $pos; + if ($modebatch == "barcode") { + $prod = "product_".$reg[1].'_'.$reg[2]; + } else { + $prod = 'product_batch_'.$reg[1].'_'.$reg[2]; + } + $qty = "qty_".$reg[1].'_'.$reg[2]; + $ent = "entrepot_".$reg[1].'_'.$reg[2]; + $fk_commandedet = "fk_commandedet_".$reg[1].'_'.$reg[2]; + $idline = GETPOST("idline_".$reg[1].'_'.$reg[2]); + $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount + $lot = ''; + $dDLUO = ''; + $dDLC = ''; + if ($modebatch == "batch") { //TODO: Make imposible to input non existing batchcode + $lot = GETPOST('lot_number_'.$reg[1].'_'.$reg[2]); + $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'year', 'int')); + $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'year', 'int')); + } + + // We ask to move a qty + if (($modebatch == "batch" && GETPOST($qty) > 0) || ($modebatch == "barcode" && GETPOST($qty) != 0)) { + if (!(GETPOST($ent, 'int') > 0)) { + dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.'); + $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline); + setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); + $error++; + } + + if (!$error) { + $qtystart = 0; + if ($idline > 0) { + $result = $expeditiondispatch->fetch($idline); + if ($result < 0) { + setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); + $error++; + } else { + $qtystart = $expeditiondispatch->qty; + $expeditiondispatch->qty = GETPOST($qty); + $expeditiondispatch->entrepot_id = GETPOST($ent, 'int'); + + $result = $expeditiondispatch->update($user); + if ($result < 0) { + setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); + $error++; + } + + if (!$error && $modebatch == "batch") { + $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET"; + $sql .= " eatby = ".($eatby ? "'".$this->db->idate($eatby)."'" : "null"); + $sql .= " , sellby = ".($sellby ? "'".$this->db->idate($sellby)."'" : "null"); + $sql .= " , qty = ".((float) price2num(GETPOST($qty, 'int'), 'MS')); + $sql .= " WHERE fk_expeditiondet = ".((int) $idline); + $sql .= " AND batch = ".((int) $idline); + $resql = $db->query($sql); + if (!$db->query($sql)) { + dol_print_error($db); + $error++; + } + } + } + } else { + $expeditiondispatch->fk_expedition = $object->id; + $expeditiondispatch->entrepot_id = GETPOST($ent, 'int'); + $expeditiondispatch->fk_origin_line = GETPOST($fk_commandedet, 'int'); + $expeditiondispatch->qty = GETPOST($qty, 'int'); + $idline = $expeditiondispatch->insert($user); + if ($idline < 0) { + setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors'); + $error++; + } + + if ($modebatch == "batch" && !$error) { + $expeditionlinebatch->sellby = $dDLUO; + $expeditionlinebatch->eatby = $dDLC; + $expeditionlinebatch->batch = $lot; + $expeditionlinebatch->qty = GETPOST($qty, 'int'); + $expeditionlinebatch->fk_origin_stock = 0; + $result = $expeditionlinebatch->create($idline); + if ($result < 0) { + setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors'); + $error++; + } + } + } + + // If module stock is enabled and the stock increase is done on purchase order dispatching + if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + $mouv = new MouvementStock($db); + $product = GETPOST($prod, 'int'); + $entrepot = GETPOST($ent, 'int'); + $qtymouv = GETPOST($qty) - $qtystart; + $price = GETPOST($pu); + $comment = GETPOST('comment'); + $inventorycode = dol_print_date(dol_now(), 'dayhourlog'); + $now = dol_now(); + $eatby = ''; + $sellby = ''; + $batch = ''; + if ($modebatch == "batch") { + $eatby = $dDLUO; + $sellby = $dDLC; + $batch = $lot ; + } + if ($product > 0 && $qtymouv != 0) { + // $price should take into account discount (except if option STOCK_EXCLUDE_DISCOUNT_FOR_PMP is on) + $mouv->origin = $objectorder; + $mouv->setOrigin($objectorder->element, $objectorder->id); + + // Method change if qty < 0 + if (!empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN) && $qtymouv < 0) { + $result = $mouv->reception($user, $product, $entrepot, $qtymouv*(-1), $price, $comment, $eatby, $sellby, $batch, '', 0, $inventorycode); + } else { + $result = $mouv->livraison($user, $product, $entrepot, $qtymouv, $price, $comment, $now, $eatby, $sellby, $batch, 0, $inventorycode); + } + + if ($result < 0) { + setEventMessages($mouv->error, $mouv->errors, 'errors'); + $error++; + } + } + } + } + } + } + } + if ($error > 0) { + $db->rollback(); + setEventMessages($error, $errors, 'errors'); + } else { + $db->commit(); + setEventMessages($langs->trans("ReceptionUpdated"), null); + } +} elseif ($action == 'setdate_livraison' && $usercancreate) { + $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); + + $object->fetch($id); + $result = $object->setDeliveryDate($user, $datedelivery); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + + +/* + * View + */ + +$now = dol_now(); + +$form = new Form($db); +$formproduct = new FormProduct($db); +$warehouse_static = new Entrepot($db); + +$title = $langs->trans('Shipment'); +$help_url = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen'; +$morejs = array('/expedition/js/lib_dispatch.js.php'); + +llxHeader('', $title, $help_url, '', 0, 0, $morejs); + +if ($id > 0 || !empty($ref)) { + $lines = $object->lines; + + $num_prod = count($lines); + + if (!empty($object->origin) && $object->origin_id > 0) { + $object->origin = 'commande'; + $typeobject = $object->origin; + $origin = $object->origin; + $origin_id = $object->origin_id; + $object->fetch_origin(); // Load property $object->commande, $object->propal, ... + } + $soc = new Societe($db); + $soc->fetch($object->socid); + + $author = new User($db); + $author->fetch($object->user_author_id); + + $head = shipping_prepare_head($object); + + print dol_get_fiche_head($head, 'dispatch', $langs->trans("Shipment"), -1, $object->picto); + + + $formconfirm = ''; + + // Confirmation to delete line + if ($action == 'ask_deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + // Note that $action and $object may be modified by hook + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { + $objectsrc = new Commande($db); + $objectsrc->fetch($object->$typeobject->id); + } + if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { + $objectsrc = new Propal($db); + $objectsrc->fetch($object->$typeobject->id); + } + + // Shipment card + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref = '
'; + + // Ref customer shipment + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); + + // Thirdparty + $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->project->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
'; + if (0) { // Do not change on reception + $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + if ($action != 'classify' && $permissiontoadd) { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + } else { + if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { + $proj = new Project($db); + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; + } + } + } + } + $morehtmlref .= '
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + + print '
'.$langs->trans("Statistics").'
'; - + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; $stats = new AdherentStats($db, 0, $userid); // Show array $sumMembers = $stats->countMembersByTypeAndStatus(); $total = $sumMembers['total']['members_draft'] + $sumMembers['total']['members_pending'] + $sumMembers['total']['members_uptodate'] + $sumMembers['total']['members_expired'] + $sumMembers['total']['members_excluded'] + $sumMembers['total']['members_resiliated']; - + $dataseries = array(); $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), $sumMembers['total']['members_draft']); // Draft, not yet validated $dataseries[] = array($langs->transnoentitiesnoconv("WaitingSubscription"), $sumMembers['total']['members_pending']); diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index ef64053b9be..70be7f7a61e 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -91,13 +91,11 @@ class box_members_by_type extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType", $max)); if ($user->rights->adherent->lire) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; $stats = new AdherentStats($this->db, $user->socid, $user->id); // Show array $sumMembers = $stats->countMembersByTypeAndStatus(); if ($sumMembers) { - $line = 0; $this->info_box_contents[$line][] = array( 'td' => 'class=""', @@ -144,7 +142,7 @@ class box_members_by_type extends ModeleBoxes $adhtype = new AdherentType($this->db); $adhtype->id = $key; - if($key=='total'){ + if ($key=='total') { break; } $adhtype->label = $data['label']; From f1f510cf60353a86b783eda38437ca1a62481906 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 20 Dec 2022 19:40:58 +0100 Subject: [PATCH 004/203] Copyright --- htdocs/adherents/class/adherentstats.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 6e29f988ada..3abc4fdcf49 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (c) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2022 Waël Almoman * * 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 From af95484b91ee1769450bb1a2d6cf7e5a1ccbe31b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 20 Dec 2022 19:42:05 +0100 Subject: [PATCH 005/203] Copyright --- htdocs/adherents/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 823ea6edfce..8f67adb61d1 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021 Frédéric France - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021-2022 Waël Almoman * * 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 From 7c6543b52902d4f16f1a2b1c9f703dc7d12fbe4e Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 20 Dec 2022 19:43:22 +0100 Subject: [PATCH 006/203] Copyright --- htdocs/core/boxes/box_members_by_type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 70be7f7a61e..9c0acd521ae 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015-2020 Frederic France - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021-2022 Waël Almoman * * 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 From 4c47e29a2de2fd58e23f1fc398f75042a94731d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Dec 2022 19:38:49 +0100 Subject: [PATCH 007/203] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 215e7de4bc2..4c68b3e91ec 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2381,8 +2381,8 @@ class Adherent extends CommonObject $labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort"); } elseif (!$date_end_subscription) { $statusType = 'status1'; - $labelStatus = $langs->trans("WaitingSubscription"); - $labelStatusShort = $langs->trans("WaitingSubscription"); + $labelStatus = $langs->trans("MemberStatusActive"); + $labelStatusShort = $langs->trans("MemberStatusActiveShort"); } elseif ($date_end_subscription < dol_now()) { // expired $statusType = 'status8'; $labelStatus = $langs->trans("MemberStatusActiveLate"); From 0ae8809ae24496b32b479ca92a863b8ea9ea312b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 22 Dec 2022 12:40:12 +0100 Subject: [PATCH 008/203] Use db->ifsql instead of case when --- htdocs/adherents/class/adherentstats.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 3abc4fdcf49..9aeb6a3ea46 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -196,12 +196,12 @@ class AdherentStats extends Stats $now = dol_now(); $sql = "SELECT COALESCE(d.fk_adherent_type, 'total') as fk_adherent_type, t.libelle as label"; - $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_DRAFT." THEN 'members_draft' ELSE NULL END) as members_draft"; - $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1') THEN 'members_pending' ELSE NULL END) as members_pending"; - $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0) THEN 'members_uptodate' ELSE NULL END) as members_uptodate"; - $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1) THEN 'members_expired' ELSE NULL END) as members_expired"; - $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_EXCLUDED." THEN 'members_excluded' ELSE NULL END) as members_excluded"; - $sql .= ", COUNT(CASE WHEN d.statut = ".Adherent::STATUS_RESILIATED." THEN 'members_resiliated' ELSE NULL END) as members_resiliated"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT,"'members_draft'", 'NULL').") as members_draft"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')","'members_pending'", 'NULL').") as members_pending"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)","'members_uptodate'", 'NULL').") as members_uptodate"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)","'members_expired'", 'NULL').") as members_expired"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED,"'members_excluded'", 'NULL').") as members_excluded"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED,"'members_resiliated'", 'NULL').") as members_resiliated"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d , ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE t.rowid = d.fk_adherent_type"; $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; From 0109a4e1728700c8da8763375c9dca3c5e0a2171 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Dec 2022 11:40:52 +0000 Subject: [PATCH 009/203] Fixing style errors. --- htdocs/adherents/class/adherentstats.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 9aeb6a3ea46..0ca91273512 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -196,12 +196,12 @@ class AdherentStats extends Stats $now = dol_now(); $sql = "SELECT COALESCE(d.fk_adherent_type, 'total') as fk_adherent_type, t.libelle as label"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT,"'members_draft'", 'NULL').") as members_draft"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')","'members_pending'", 'NULL').") as members_pending"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)","'members_uptodate'", 'NULL').") as members_uptodate"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)","'members_expired'", 'NULL').") as members_expired"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED,"'members_excluded'", 'NULL').") as members_excluded"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED,"'members_resiliated'", 'NULL').") as members_resiliated"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')", "'members_pending'", 'NULL').") as members_pending"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)", "'members_uptodate'", 'NULL').") as members_uptodate"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)", "'members_expired'", 'NULL').") as members_expired"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED, "'members_excluded'", 'NULL').") as members_excluded"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED, "'members_resiliated'", 'NULL').") as members_resiliated"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d , ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE t.rowid = d.fk_adherent_type"; $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; From e16994bcff4a581a08c575f20fd26d64c85ffe54 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 22 Dec 2022 16:23:18 +0100 Subject: [PATCH 010/203] Fix add not used active member type --- htdocs/adherents/class/adherentstats.class.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 9aeb6a3ea46..c31cdd2284d 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -187,7 +187,7 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @return array Array with + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type */ public function countMembersByTypeAndStatus() { @@ -195,19 +195,18 @@ class AdherentStats extends Stats $now = dol_now(); - $sql = "SELECT COALESCE(d.fk_adherent_type, 'total') as fk_adherent_type, t.libelle as label"; + $sql = "SELECT COALESCE(t.rowid, 'total') as fk_adherent_type, t.libelle as label"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT,"'members_draft'", 'NULL').") as members_draft"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')","'members_pending'", 'NULL').") as members_pending"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)","'members_uptodate'", 'NULL').") as members_uptodate"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)","'members_expired'", 'NULL').") as members_expired"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED,"'members_excluded'", 'NULL').") as members_excluded"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED,"'members_resiliated'", 'NULL').") as members_resiliated"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d , ".MAIN_DB_PREFIX."adherent_type as t"; - $sql .= " WHERE t.rowid = d.fk_adherent_type"; - $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; - $sql .= " AND t.entity IN (".getEntity('member_type').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON t.rowid = d.fk_adherent_type AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; $sql .= " AND t.statut = 1"; - $sql .= " GROUP BY d.fk_adherent_type"; + $sql .= " GROUP BY t.rowid"; $sql .= " WITH ROLLUP;"; dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); From 64363066340123d3ce6748b6b020a0d8cf280b27 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Dec 2022 15:25:09 +0000 Subject: [PATCH 011/203] Fixing style errors. --- htdocs/adherents/class/adherentstats.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index c31cdd2284d..53ad30bcd26 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -187,7 +187,7 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type */ public function countMembersByTypeAndStatus() { @@ -196,12 +196,12 @@ class AdherentStats extends Stats $now = dol_now(); $sql = "SELECT COALESCE(t.rowid, 'total') as fk_adherent_type, t.libelle as label"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT,"'members_draft'", 'NULL').") as members_draft"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')","'members_pending'", 'NULL').") as members_pending"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)","'members_uptodate'", 'NULL').") as members_uptodate"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)","'members_expired'", 'NULL').") as members_expired"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED,"'members_excluded'", 'NULL').") as members_excluded"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED,"'members_resiliated'", 'NULL').") as members_resiliated"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')", "'members_pending'", 'NULL').") as members_pending"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)", "'members_uptodate'", 'NULL').") as members_uptodate"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)", "'members_expired'", 'NULL').") as members_expired"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED, "'members_excluded'", 'NULL').") as members_excluded"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED, "'members_resiliated'", 'NULL').") as members_resiliated"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON t.rowid = d.fk_adherent_type AND d.entity IN (" . getEntity('adherent') . ")"; $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; From 26370ff1c81dafc6b29b5858d92cef3e3325e15f Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 22 Dec 2022 22:35:35 +0100 Subject: [PATCH 012/203] Remove With rollup --- .../adherents/class/adherentstats.class.php | 36 ++++++++++++++----- htdocs/core/boxes/box_members_by_type.php | 16 +++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index c31cdd2284d..f7381b17fba 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -195,7 +195,7 @@ class AdherentStats extends Stats $now = dol_now(); - $sql = "SELECT COALESCE(t.rowid, 'total') as fk_adherent_type, t.libelle as label"; + $sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT,"'members_draft'", 'NULL').") as members_draft"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')","'members_pending'", 'NULL').") as members_pending"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)","'members_uptodate'", 'NULL').") as members_uptodate"; @@ -207,7 +207,6 @@ class AdherentStats extends Stats $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; $sql .= " AND t.statut = 1"; $sql .= " GROUP BY t.rowid"; - $sql .= " WITH ROLLUP;"; dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); $result = $this->db->query($sql); @@ -216,20 +215,39 @@ class AdherentStats extends Stats $num = $this->db->num_rows($result); $i = 0; $MembersCountArray = []; + $totalstatus = array( + 'label' => 'Total', + 'members_draft' => 0, + 'members_pending' => 0, + 'members_uptodate' => 0, + 'members_expired' => 0, + 'members_excluded' => 0, + 'members_resiliated' => 0 + ); while ($i < $num) { $objp = $this->db->fetch_object($result); $MembersCountArray[$objp->fk_adherent_type] = array( - "label" => $objp->label, - "members_draft" => (int) $objp->members_draft, - "members_pending" => (int) $objp->members_pending, - "members_uptodate" => (int) $objp->members_uptodate, - "members_expired" => (int) $objp->members_expired, - "members_excluded" => (int) $objp->members_excluded, - "members_resiliated" => (int) $objp->members_resiliated + 'label' => $objp->label, + 'members_draft' => (int) $objp->members_draft, + 'members_pending' => (int) $objp->members_pending, + 'members_uptodate' => (int) $objp->members_uptodate, + 'members_expired' => (int) $objp->members_expired, + 'members_excluded' => (int) $objp->members_excluded, + 'members_resiliated' => (int) $objp->members_resiliated ); + $totalrow = 0; + foreach ($MembersCountArray[$objp->fk_adherent_type] as $key=>$nb) { + if ($key!='label'){ + $totalrow += $nb; + $totalstatus[$key] += $nb; + } + } + $MembersCountArray[$objp->fk_adherent_type]['total_adhtype'] = $totalrow; $i++; } $this->db->free($result); + $MembersCountArray['total'] = $totalstatus; + $MembersCountArray['total']['all'] = array_sum($totalstatus); } return $MembersCountArray; } diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 9c0acd521ae..2109e650a07 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -137,6 +137,12 @@ class box_members_by_type extends ModeleBoxes 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); + // Total row + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($langs->trans("Total")).'"', + 'text' => $langs->trans("Total") + ); $line++; foreach ($sumMembers as $key => $data) { $adhtype = new AdherentType($this->db); @@ -183,6 +189,11 @@ class box_members_by_type extends ModeleBoxes 'text' => (isset($data['members_resiliated']) && $data['members_resiliated'] > 0 ? $data['members_resiliated'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), 'asis' => 1, ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['total_adhtype']) && $data['total_adhtype'] > 0 ? $data['total_adhtype'] : ''), + 'asis' => 1, + ); $line++; } @@ -227,6 +238,11 @@ class box_members_by_type extends ModeleBoxes 'text' => $sumMembers['total']['members_resiliated'].' '.$staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), 'asis' => 1 ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['all'], + 'asis' => 1 + ); } } else { $this->info_box_contents[0][0] = array( From be34e7d53a5f466515c4a4ed86d70b0e85ca4799 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Dec 2022 21:53:30 +0000 Subject: [PATCH 013/203] Fixing style errors. --- htdocs/adherents/class/adherentstats.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 2095af178e6..1809ecdf982 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -196,12 +196,12 @@ class AdherentStats extends Stats $now = dol_now(); $sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT,"'members_draft'", 'NULL').") as members_draft"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')","'members_pending'", 'NULL').") as members_pending"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)","'members_uptodate'", 'NULL').") as members_uptodate"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)","'members_expired'", 'NULL').") as members_expired"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED,"'members_excluded'", 'NULL').") as members_excluded"; - $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED,"'members_resiliated'", 'NULL').") as members_resiliated"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')", "'members_pending'", 'NULL').") as members_pending"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)", "'members_uptodate'", 'NULL').") as members_uptodate"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)", "'members_expired'", 'NULL').") as members_expired"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED, "'members_excluded'", 'NULL').") as members_excluded"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED, "'members_resiliated'", 'NULL').") as members_resiliated"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON t.rowid = d.fk_adherent_type AND d.entity IN (" . getEntity('adherent') . ")"; $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; @@ -237,12 +237,12 @@ class AdherentStats extends Stats ); $totalrow = 0; foreach ($MembersCountArray[$objp->fk_adherent_type] as $key=>$nb) { - if ($key!='label'){ + if ($key!='label') { $totalrow += $nb; $totalstatus[$key] += $nb; } } - $MembersCountArray[$objp->fk_adherent_type]['total_adhtype'] = $totalrow; + $MembersCountArray[$objp->fk_adherent_type]['total_adhtype'] = $totalrow; $i++; } $this->db->free($result); From d107cc4c0cd7f2439d67e89b62ec83c359a34e59 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 22 Dec 2022 22:53:57 +0100 Subject: [PATCH 014/203] Fix label status --- htdocs/adherents/class/adherent.class.php | 4 ++-- htdocs/langs/en_US/members.lang | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6aaac503060..20e3871b01d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2417,8 +2417,8 @@ class Adherent extends CommonObject $labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort"); } elseif (!$date_end_subscription) { $statusType = 'status1'; - $labelStatus = $langs->trans("MemberStatusActive"); - $labelStatusShort = $langs->trans("MemberStatusActiveShort"); + $labelStatus = $langs->trans("WaitingSubscription"); + $labelStatusShort = $langs->trans("WaitingSubscriptionShort"); } elseif ($date_end_subscription < dol_now()) { // expired $statusType = 'status8'; $labelStatus = $langs->trans("MemberStatusActiveLate"); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index eb911c1cdbf..4d91099a81a 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -37,6 +37,7 @@ EndSubscription=End of membership SubscriptionId=Contribution ID WithoutSubscription=Without membership WaitingSubscription=Membership pending +WaitingSubscriptionShort=Pending MemberId=Member Id MemberRef=Member Ref NewMember=New member From 0506f028c9b1417af9ec1f0ab1c4ff78b0be3992 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 23 Dec 2022 14:21:23 +0100 Subject: [PATCH 015/203] Add MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH in widget and graphh --- htdocs/adherents/class/adherentstats.class.php | 6 +++++- htdocs/adherents/index.php | 3 ++- htdocs/core/boxes/box_members_by_type.php | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 1809ecdf982..2af18e3e139 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -189,11 +189,14 @@ class AdherentStats extends Stats * * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type */ - public function countMembersByTypeAndStatus() + public function countMembersByTypeAndStatus($numberYears) { global $user; $now = dol_now(); + $endYear = date('Y'); + $startYear = $endYear - $numberYears; + echo "startYear = endYear - numberYears => $startYear = $endYear - $numberYears"; $sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; @@ -204,6 +207,7 @@ class AdherentStats extends Stats $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED, "'members_resiliated'", 'NULL').") as members_resiliated"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON t.rowid = d.fk_adherent_type AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.datefin BETWEEN '".$this->db->idate(dol_get_first_day($startYear))."' AND '".$this->db->idate(dol_get_last_day($endYear))."'"; $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; $sql .= " AND t.statut = 1"; $sql .= " GROUP BY t.rowid"; diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 8f67adb61d1..d3178ee3df3 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -100,7 +100,8 @@ if ($conf->use_javascript_ajax) { $stats = new AdherentStats($db, 0, $userid); // Show array - $sumMembers = $stats->countMembersByTypeAndStatus(); + $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); + $sumMembers = $stats->countMembersByTypeAndStatus($numberyears); $total = $sumMembers['total']['members_draft'] + $sumMembers['total']['members_pending'] + $sumMembers['total']['members_uptodate'] + $sumMembers['total']['members_expired'] + $sumMembers['total']['members_excluded'] + $sumMembers['total']['members_resiliated']; $dataseries = array(); diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 903e5f6e686..17984f6d4e6 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -94,7 +94,8 @@ class box_members_by_type extends ModeleBoxes require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; $stats = new AdherentStats($this->db, $user->socid, $user->id); // Show array - $sumMembers = $stats->countMembersByTypeAndStatus(); + $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); + $sumMembers = $stats->countMembersByTypeAndStatus($numberyears); if ($sumMembers) { $line = 0; $this->info_box_contents[$line][] = array( From b1e5c92455efba490bdf60557feb2ae3d51fbbcc Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 23 Dec 2022 14:22:07 +0100 Subject: [PATCH 016/203] Clean code --- htdocs/adherents/class/adherentstats.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 2af18e3e139..4d03194766d 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -196,7 +196,6 @@ class AdherentStats extends Stats $now = dol_now(); $endYear = date('Y'); $startYear = $endYear - $numberYears; - echo "startYear = endYear - numberYears => $startYear = $endYear - $numberYears"; $sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; From 61536455c2754d3e473dc408d71c3249ca5b95b6 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 23 Dec 2022 14:25:52 +0100 Subject: [PATCH 017/203] Comment --- htdocs/adherents/class/adherentstats.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 4d03194766d..be48b5c0b25 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -187,7 +187,8 @@ class AdherentStats extends Stats /** * Return count of member by status group by adh type, total and average * - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + * @param int $numberYears Years to scan + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type */ public function countMembersByTypeAndStatus($numberYears) { From 9039bdb827164468eecc3dc6eacaf0ef2b73c818 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 23 Dec 2022 14:48:00 +0100 Subject: [PATCH 018/203] Add period in title --- htdocs/adherents/index.php | 6 ++++-- htdocs/core/boxes/box_members_by_type.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index d3178ee3df3..cb61d66b90d 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -91,16 +91,18 @@ print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist $boxgraph = ''; if ($conf->use_javascript_ajax) { + $year = date('Y'); + $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); + $boxgraph .='
'; $boxgraph .=''; - $boxgraph .=''; + $boxgraph .=''; $boxgraph .=''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -1917,6 +1911,9 @@ while ($i < $imaxinloop) { $i++; } +// Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script +$formcompany->select_status('status_prospect', null, null, null, "js"); + // If no record found if ($num == 0) { $colspan = 1; From e9e2a8850f8f8a28b9f8bf592ce80efbb00a07d4 Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 28 Mar 2023 16:50:44 +0200 Subject: [PATCH 023/203] fix the sql request, add (int) --- htdocs/core/ajax/ajaxstatusprospect.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/ajaxstatusprospect.php b/htdocs/core/ajax/ajaxstatusprospect.php index 4cf540db1f6..481d8a9a1d9 100644 --- a/htdocs/core/ajax/ajaxstatusprospect.php +++ b/htdocs/core/ajax/ajaxstatusprospect.php @@ -53,8 +53,8 @@ if ($action === "updatestatusprospect") { $response = ''; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql .= "fk_stcomm=".$db->escape($idstatus); - $sql .= " WHERE rowid = ".$db->escape($idprospect); + $sql .= "fk_stcomm=".(int) $db->escape($idstatus); + $sql .= " WHERE rowid = ".(int) $db->escape($idprospect); $resql = $db->query($sql); From a0d9419be5cb766db6b8d3f9f47ba1322d1196e1 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Thu, 30 Mar 2023 19:06:47 +0200 Subject: [PATCH 024/203] Improve multicurrency payments --- htdocs/compta/paiement.php | 5 +++++ htdocs/compta/paiement/class/paiement.class.php | 11 ++++++++--- htdocs/fourn/class/paiementfourn.class.php | 9 +++++++-- htdocs/fourn/facture/paiement.php | 5 +++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index f2cd1fe18f9..0efb7bf4d61 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -9,6 +9,7 @@ * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -223,6 +224,7 @@ if (empty($reshook)) { } $multicurrency_code = array(); + $multicurrency_tx = array(); // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched @@ -233,6 +235,7 @@ if (empty($reshook)) { $amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -243,6 +246,7 @@ if (empty($reshook)) { $multicurrency_amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } if (isModEnabled("banque")) { @@ -259,6 +263,7 @@ if (empty($reshook)) { $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching + $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha'); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index f573ec5be56..78909e95d9d 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2020 Andreu Bisquerra Gaya * Copyright (C) 2021 OpenDsi * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -76,6 +77,7 @@ class Paiement extends CommonObject public $multicurrency_amount; // Total amount of payment (in the currency of the bank account) public $amounts = array(); // array: invoice ID => amount for that invoice (in the main currency) public $multicurrency_amounts = array(); // array: invoice ID => amount for that invoice (in the invoice's currency) + public $multicurrency_tx = array(); // array: invoice ID => currency tx for that invoice public $multicurrency_code = array(); // array: invoice ID => currency code for that invoice public $pos_change = 0; // Excess received in TakePOS cash payment @@ -262,6 +264,7 @@ class Paiement extends CommonObject } $currencyofpayment = ''; + $currencytxofpayment = ''; foreach ($amounts as $key => $value) { // How payment is dispatch if (empty($value)) { @@ -282,6 +285,9 @@ class Paiement extends CommonObject $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; return -1; } + if (empty($currencytxofpayment)) { + $currencytxofpayment = isset($this->multicurrency_tx[$key]) ? $this->multicurrency_tx[$key] : ""; + } $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -351,9 +357,8 @@ class Paiement extends CommonObject $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)"; - // TODO Add multicurrency_code and multicurrency_tx - $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).")"; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)'; + $sql .= ' VALUES ('.((int) $facid).', '.((int) $this->id).', "'.((float) $amount).'", "'.((float) $this->multicurrency_amounts[$key]).'", '.($this->multicurrency_code ? '"'.$this->db->escape($currencyofpayment).'"' : 'NULL').', '.(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).')'; dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index e3b7be2c42a..168a9c98821 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Frédéric France * Copyright (C) 2023 Joachim Kueter + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -186,6 +187,7 @@ class PaiementFourn extends Paiement } $currencyofpayment = ''; + $currencytxofpayment = ''; foreach ($amounts as $key => $value) { if (empty($value)) { @@ -207,6 +209,9 @@ class PaiementFourn extends Paiement $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; return -1; } + if (empty($currencytxofpayment)) { + $currencytxofpayment = $this->multicurrency_tx[$key]; + } $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); @@ -264,8 +269,8 @@ class PaiementFourn extends Paiement $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount)'; - $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).', '.((float) $this->multicurrency_amounts[$key]).')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)'; + $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).', '.((float) $this->multicurrency_amounts[$key]).', '.($currencyofpayment ? '"'.$this->db->escape($currencyofpayment).'"' : 'NULL').', '.(!empty($currencytxofpayment) ? (double) $currencytxofpayment : 1).')'; $resql = $this->db->query($sql); if ($resql) { $invoice = new FactureFournisseur($this->db); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index bad8d19bd28..5e1665d6c2b 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -12,6 +12,7 @@ * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2021 Charlene Benke * Copyright (C) 2022 Udo Tamm + * Copyright (C) 2023 Sylvain Legrand * * 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 @@ -270,6 +271,7 @@ if (empty($reshook)) { $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $multicurrency_code = array(); + $multicurrency_tx = array(); // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched @@ -280,6 +282,7 @@ if (empty($reshook)) { $amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -290,6 +293,7 @@ if (empty($reshook)) { $multicurrency_amounts[$key] = - abs($newvalue); } $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; + $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx; } //var_dump($amounts); @@ -310,6 +314,7 @@ if (empty($reshook)) { $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching + $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching $paiement->paiementid = GETPOST('paiementid', 'int'); $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml'); $paiement->note_private = GETPOST('comment', 'alpha'); From 3c57992074460bcc7776f7cc2a185323a1eda32f Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Thu, 30 Mar 2023 20:59:27 +0200 Subject: [PATCH 025/203] Update paiement.class.php --- htdocs/compta/paiement/class/paiement.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 78909e95d9d..ec33f6368d4 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -357,8 +357,8 @@ class Paiement extends CommonObject $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)'; - $sql .= ' VALUES ('.((int) $facid).', '.((int) $this->id).', "'.((float) $amount).'", "'.((float) $this->multicurrency_amounts[$key]).'", '.($this->multicurrency_code ? '"'.$this->db->escape($currencyofpayment).'"' : 'NULL').', '.(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).')'; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)"; + $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).", ".($this->multicurrency_code ? $this->db->escape($currencyofpayment) : 'NULL').", ".(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).")"; dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql = $this->db->query($sql); From d8c51e712dc1783432ec3b2bb80adb4783385214 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 12 Apr 2023 10:17:13 +0200 Subject: [PATCH 026/203] FIX reassortlot search categorie + add inihook --- htdocs/product/reassortlot.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 65e69b91384..437b698435e 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -88,6 +88,8 @@ if ($user->socid) { } $result = restrictedArea($user, 'produit|service', 0, 'product&product'); +$hookmanager->initHooks(array('reassortlotlist')); + /* * Actions @@ -135,11 +137,11 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid' $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key // We'll need this table joined to the select in order to filter by categ -if ($search_categ) { +if ($search_categ > 0) { $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; } $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) { +if ($search_categ > 0) { $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ } if ($sall) { @@ -178,7 +180,7 @@ if ($fourn_id > 0) { $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id); } // Insert categ filter -if ($search_categ) { +if ($search_categ > 0) { $sql .= " AND cp.fk_categorie = ".((int) $search_categ); } if ($search_warehouse) { @@ -277,7 +279,7 @@ if ($resql) { if ($search_sale) { $param .= "&search_sale=".urlencode($search_sale); } - if ($search_categ) { + if ($search_categ > 0) { $param .= "&search_categ=".urlencode($search_categ); } /*if ($eatby) $param.="&eatby=".$eatby; From 40d476d2c9d2c174a8646cee12d58ac918d12ca8 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Thu, 27 Apr 2023 11:02:22 +0200 Subject: [PATCH 027/203] first commit --- htdocs/contact/class/contact.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 14 ++++++++++++++ htdocs/ticket/class/actions_ticket.class.php | 8 ++++++++ htdocs/ticket/class/ticket.class.php | 8 +++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 23fcf2d8c0a..5b76d43ab1d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1535,7 +1535,7 @@ class Contact extends CommonObject $linkend = ''; } - $result .= $linkstart; + $result .= (($option == 'nolink') ? '' : $linkstart); if ($withpicto) { if ($withpicto < 0) { $result .= ''.Form::showphoto('contact', $this, 0, 0, 0, 'userphoto'.($withpicto == -3 ? 'small' : ''), 'mini', 0, 1).''; @@ -1546,7 +1546,7 @@ class Contact extends CommonObject if ($withpicto != 2 && $withpicto != -2) { $result .= ''.($maxlen ? dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)).''; } - $result .= $linkend; + $result .= (($option == 'nolink') ? '' : $linkend); global $action; $hookmanager->initHooks(array('contactdao')); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bedb62c1162..62f552b7b80 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12077,6 +12077,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $sql .= " a.percent as percent, 'action' as type,"; $sql .= " a.fk_element, a.elementtype,"; $sql .= " a.fk_contact,"; + $sql .= " a.email_from as msg_from,"; $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; if (is_object($filterobj) && get_class($filterobj) == 'Societe') { @@ -12276,6 +12277,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n 'userfirstname'=>$obj->user_firstname, 'userlastname'=>$obj->user_lastname, 'userphoto'=>$obj->user_photo, + 'msg_from'=>$obj->msg_from, 'contact_id'=>$obj->fk_contact, 'socpeopleassigned' => $contactaction->socpeopleassigned, @@ -12339,6 +12341,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $userstatic = new User($db); $contactstatic = new Contact($db); $userGetNomUrlCache = array(); + $contactGetNomUrlCache = array(); $out .= '
'; $out .= '
'; @@ -12501,6 +12504,17 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n } $out .= $userGetNomUrlCache[$histo[$key]['userid']]; } + else if (!empty($histo[$key]['msg_from']) && $actionstatic->code == 'TICKET_MSG') { + if (!isset($contactGetNomUrlCache[$histo[$key]['msg_from']])) { + if ($contactstatic->fetch(0,null,'',$histo[$key]['msg_from']) > 0) { + $contactGetNomUrlCache[$histo[$key]['msg_from']] = $contactstatic->getNomUrl(-1, '', 16); + } + else { + $contactGetNomUrlCache[$histo[$key]['msg_from']] = $histo[$key]['msg_from']; + } + } + $out .= $contactGetNomUrlCache[$histo[$key]['msg_from']]; + } $out .= '
'; // Title diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 29a013f1eb9..fb426d74e09 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -306,6 +306,14 @@ class ActionsTicket if ($res) { print $userstat->getNomUrl(0); } + } else if (isset($arraymsgs['fk_contact_author'])) { + $contactstat = new Contact($this->db); + $res = $contactstat->fetch(0, null, '', $arraymsgs['fk_contact_author']); + if ($res) { + print $contactstat->getNomUrl(0, 'nolink'); + } else { + print $arraymsgs['fk_contact_author']; + } } else { print $langs->trans('Customer'); } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 92baa55ea89..9ca4e3a3309 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1700,6 +1700,9 @@ class Ticket extends CommonObject if ($send_email) { $actioncomm->code .= '_SENTBYMAIL'; } + if ((empty($user->id) || $user->id == 0) && isset($_SESSION['email_customer'])) { + $actioncomm->email_from = $_SESSION['email_customer']; + } $actioncomm->socid = $this->socid; $actioncomm->label = $this->subject; $actioncomm->note_private = $this->message; @@ -1753,7 +1756,7 @@ class Ticket extends CommonObject // Cache already loaded - $sql = "SELECT id as rowid, fk_user_author, datec, label, note as message, code"; + $sql = "SELECT id as rowid, fk_user_author, email_from, datec, label, note as message, code"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; $sql .= " WHERE fk_element = ".(int) $this->id; $sql .= " AND elementtype = 'ticket'"; @@ -1768,6 +1771,9 @@ class Ticket extends CommonObject $obj = $this->db->fetch_object($resql); $this->cache_msgs_ticket[$i]['id'] = $obj->rowid; $this->cache_msgs_ticket[$i]['fk_user_author'] = $obj->fk_user_author; + if ($obj->code == 'TICKET_MSG' && empty($obj->fk_user_author)) { + $this->cache_msgs_ticket[$i]['fk_contact_author'] = $obj->email_from; + } $this->cache_msgs_ticket[$i]['datec'] = $this->db->jdate($obj->datec); $this->cache_msgs_ticket[$i]['subject'] = $obj->label; $this->cache_msgs_ticket[$i]['message'] = $obj->message; From df817dba7de74d562c7096781242343aced3b564 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sat, 15 Apr 2023 18:01:42 +0200 Subject: [PATCH 028/203] ContactTest: assertStringContainsString instead of assertContains PHPUnit >= 9 adds assertStringContainsString, which ought to replace assertContains, and PHPUnit >= 9 removed[^1] support for calling assertContains on strings. [^1]: https://github.com/sebastianbergmann/phpunit/issues/3426 --- test/phpunit/ContactTest.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index c28db01d579..7701f67bd08 100644 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -296,7 +297,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $result=$localobject->getFullAddress(1); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result); $localobject->info($localobject->id); print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; @@ -357,7 +358,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nFrance", $result); + $this->assertStringContainsString("New address\nNew zip New town\nFrance", $result); // Belgium unset($localobjectadd->country_code); @@ -368,7 +369,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result); // Switzerland unset($localobjectadd->country_code); @@ -379,7 +380,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nSwitzerland", $result); + $this->assertStringContainsString("New address\nNew zip New town\nSwitzerland", $result); // USA unset($localobjectadd->country_code); @@ -390,7 +391,7 @@ class ContactTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew town, New zip\nUnited States", $result); + $this->assertStringContainsString("New address\nNew town, New zip\nUnited States", $result); return $localobjectadd->id; } From e9dcac67f02cf28a8ac4769e07bcd19c434a8db9 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Fri, 28 Apr 2023 17:35:06 +0200 Subject: [PATCH 029/203] Stickler --- htdocs/core/lib/functions.lib.php | 7 +++---- htdocs/ticket/class/actions_ticket.class.php | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 62f552b7b80..1663b80ae70 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12504,12 +12504,11 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n } $out .= $userGetNomUrlCache[$histo[$key]['userid']]; } - else if (!empty($histo[$key]['msg_from']) && $actionstatic->code == 'TICKET_MSG') { + elseif (!empty($histo[$key]['msg_from']) && $actionstatic->code == 'TICKET_MSG') { if (!isset($contactGetNomUrlCache[$histo[$key]['msg_from']])) { - if ($contactstatic->fetch(0,null,'',$histo[$key]['msg_from']) > 0) { + if ($contactstatic->fetch(0, null, '', $histo[$key]['msg_from']) > 0) { $contactGetNomUrlCache[$histo[$key]['msg_from']] = $contactstatic->getNomUrl(-1, '', 16); - } - else { + } else { $contactGetNomUrlCache[$histo[$key]['msg_from']] = $histo[$key]['msg_from']; } } diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index fb426d74e09..c566bf54329 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -306,7 +306,7 @@ class ActionsTicket if ($res) { print $userstat->getNomUrl(0); } - } else if (isset($arraymsgs['fk_contact_author'])) { + } elseif (isset($arraymsgs['fk_contact_author'])) { $contactstat = new Contact($this->db); $res = $contactstat->fetch(0, null, '', $arraymsgs['fk_contact_author']); if ($res) { From 8245fa44e14a88299aa270257932a20ee792b97a Mon Sep 17 00:00:00 2001 From: hystepik Date: Tue, 2 May 2023 14:32:18 +0200 Subject: [PATCH 030/203] fix php 8.1 warnings --- htdocs/expedition/card.php | 6 ++++++ htdocs/expedition/class/expedition.class.php | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 6ad121a2042..e6479ccbdd3 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1430,6 +1430,7 @@ if ($action == 'create') { } $tmpwarehouseObject = new Entrepot($db); foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) { // $stock_warehouse is product_stock + $var = $subj % 2; if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) { // if a warehouse was selected by user, picking is limited to this warehouse and his children continue; @@ -1459,6 +1460,8 @@ if ($action == 'create') { $tooltip = ''; if (!empty($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) { $tooltip = ' class="classfortooltip" title="'.$langs->trans('StockQuantitiesAlreadyAllocatedOnPreviousLines').' : '.$alreadyQtySetted[$line->fk_product][intval($warehouse_id)].'" '; + } else { + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = 0; } $alreadyQtySetted[$line->fk_product][intval($warehouse_id)] = $deliverableQty + $alreadyQtySetted[$line->fk_product][intval($warehouse_id)]; @@ -1539,6 +1542,7 @@ if ($action == 'create') { } foreach ($product->stock_warehouse as $warehouse_id => $stock_warehouse) { + $var = $subj % 2; if (!empty($warehousePicking) && !in_array($warehouse_id, $warehousePicking)) { // if a warehouse was selected by user, picking is limited to this warehouse and his children continue; @@ -1573,6 +1577,8 @@ if ($action == 'create') { if (!empty($alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)])) { $tooltipClass = ' classfortooltip'; $tooltipTitle = $langs->trans('StockQuantitiesAlreadyAllocatedOnPreviousLines').' : '.$alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]; + } else { + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = 0 ; } $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index f145c82c9ea..0fa27706993 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -516,7 +516,10 @@ class Expedition extends CommonObject $tab = $line_ext->detail_batch; // create stockLocation Qty array foreach ($tab as $detbatch) { - if ($detbatch->entrepot_id) { + if (!empty($detbatch->entrepot_id)) { + if (empty($stockLocationQty[$detbatch->entrepot_id])) { + $stockLocationQty[$detbatch->entrepot_id] = 0; + } $stockLocationQty[$detbatch->entrepot_id] += $detbatch->qty; } } @@ -979,7 +982,7 @@ class Expedition extends CommonObject $linebatch->qty = $value['q']; $tab[] = $linebatch; - if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { + if (!empty(getDolUserString("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", '0'))) { require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; $prod_batch = new Productbatch($this->db); $prod_batch->fetch($value['id_batch']); From 2967d653c6da61c78c98065be9f9c810ef8a6207 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut Date: Fri, 5 May 2023 09:53:35 +0200 Subject: [PATCH 031/203] Fix date form for order --- htdocs/fourn/commande/card.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 3b0f4fdb6e5..71732626819 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2642,10 +2642,7 @@ if ($action == 'create') { //print '
'; print ''; // Force mandatory order method From 93551c8e64d3f4c713c0525bc99f28378fe621cb Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 5 May 2023 12:43:09 +0200 Subject: [PATCH 032/203] feat: Upgrade default PDF models to the 'new' ones (eproved since 4 dolibarr versions from now) --- htdocs/admin/delivery.php | 4 ++-- .../core/modules/delivery/mod_delivery_saphir.php | 4 ++-- .../core/modules/project/mod_project_universal.php | 4 ++-- .../modules/project/task/mod_task_universal.php | 4 ++-- htdocs/delivery/class/delivery.class.php | 2 +- htdocs/install/mysql/migration/17.0.0-18.0.0.sql | 13 +++++++++++++ 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index 9094762f68d..a901b0790b5 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -165,7 +165,7 @@ if ($action == 'set') { if ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->DELIVERY_ADDON_PDF == "$value") { + if (getDolGlobalString('DELIVERY_ADDON_PDF') == $value) { dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity); } } @@ -420,7 +420,7 @@ if (!empty($conf->global->MAIN_SUBMODULE_DELIVERY)) { // Default print "'; - $texte .= ''; + $texte .= ''; $texte .= ''; @@ -130,7 +130,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask = $conf->global->DELIVERY_SAPHIR_MASK; + $mask = getDolGlobalString('DELIVERY_SAPHIR_MASK'); if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 889164fbfe5..93530cc793c 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -88,7 +88,7 @@ class mod_project_universal extends ModeleNumRefProjects // Parametrage du prefix $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; @@ -134,7 +134,7 @@ class mod_project_universal extends ModeleNumRefProjects require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask = $conf->global->PROJECT_UNIVERSAL_MASK; + $mask = getDolGlobalString('PROJECT_UNIVERSAL_MASK'); if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 22ac9e3d681..4084f3d9298 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -83,7 +83,7 @@ class mod_task_universal extends ModeleNumRefTask // Parametrage du prefix $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; @@ -128,7 +128,7 @@ class mod_task_universal extends ModeleNumRefTask require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $mask = !empty($conf->global->PROJECT_TASK_UNIVERSAL_MASK) ? $conf->global->PROJECT_TASK_UNIVERSAL_MASK : ''; + $mask = getDolGlobalString('PROJECT_TASK_UNIVERSAL_MASK'); if (!$mask) { $this->error = 'NotConfigured'; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 5adb955e0d3..7d528f0d051 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -986,7 +986,7 @@ class Delivery extends CommonObject $i = 0; $line = new DeliveryLine($this->db); - $line->fk_product = $prodids[0]; + $line->fk_product = reset($prodids); $line->qty_asked = 10; $line->qty_shipped = 9; $line->ref = 'REFPROD'; diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index 64ede43cf9f..568e2838f5e 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -411,3 +411,16 @@ CREATE TABLE llx_c_invoice_subtype ( ALTER TABLE llx_c_invoice_subtype ADD UNIQUE INDEX uk_c_invoice_subtype (entity, code); +-- Upgrade default PDF models to the 'new' ones (eproved since 4 dolibarr versions from now) +UPDATE llx_const SET value="eratosthene" WHERE name="COMMANDE_ADDON_PDF" and value="einstein"; +DELETE FROM llx_document_model WHERE name="einstein" AND type="order"; +UPDATE llx_const SET value="sponge" WHERE name="FACTURE_ADDON_PDF" and value="crabe"; +DELETE FROM llx_document_model WHERE name="crabe" AND type="invoice"; +UPDATE llx_const SET value="espadon" WHERE name="EXPEDITION_ADDON_PDF" and value="merou"; +DELETE FROM llx_document_model WHERE name="merou" AND type="shipping"; +UPDATE llx_const SET value="cyan" WHERE name="PROPALE_ADDON_PDF" and value="azur"; +DELETE FROM llx_document_model WHERE name="azur" AND type="propal"; +UPDATE llx_const SET value="storm" WHERE name IN ("DELIVERY_ADDON_PDF","LIVRAISON_ADDON_PDF") and value="typhon"; +DELETE FROM llx_document_model WHERE name="typhon" AND type="delivery"; +UPDATE llx_const SET value="cornas" WHERE name="COMMANDE_SUPPLIER_ADDON_PDF" and value="muscadet"; +DELETE FROM llx_document_model WHERE name="muscadet" AND type="order_supplier"; From 631f2bce1db171c83a3de872e6b62387334f4058 Mon Sep 17 00:00:00 2001 From: Joe Bidon Date: Thu, 27 Apr 2023 08:22:19 +0200 Subject: [PATCH 033/203] Add hidden option COMPANY_AQUARIUM_NO_PREFIX to ignore PREFIX --- .../modules/societe/mod_codecompta_aquarium.php | 14 ++++++++++++-- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 257bdf55e52..e3c6ad1600c 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -61,8 +61,14 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') { $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401'; } - $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; - $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; + + if (!empty($conf->global->COMPANY_AQUARIUM_NO_PREFIX)) { + $this->prefixcustomeraccountancycode = ''; + $this->prefixsupplieraccountancycode = ''; + }else{ + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; + } } @@ -102,6 +108,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) { $texte .= $langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."
\n"; } + + if (!empty($conf->global->COMPANY_AQUARIUM_NO_PREFIX)) { + $texte .= $langs->trans('COMPANY_AQUARIUM_NO_PREFIX').' = '.$conf->global->COMPANY_AQUARIUM_NO_PREFIX."
\n"; + } $texte .= ''; $texte .= '
'; $texte .= '
'.$langs->trans("Statistics").'
'.$langs->trans("Statistics").' ('.$year-$numberyears.' - '.$year.')
'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; $stats = new AdherentStats($db, 0, $userid); // Show array - $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); $sumMembers = $stats->countMembersByTypeAndStatus($numberyears); $total = $sumMembers['total']['members_draft'] + $sumMembers['total']['members_pending'] + $sumMembers['total']['members_uptodate'] + $sumMembers['total']['members_expired'] + $sumMembers['total']['members_excluded'] + $sumMembers['total']['members_resiliated']; diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 17984f6d4e6..1fc6590fd99 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -88,13 +88,15 @@ class box_members_by_type extends ModeleBoxes require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php'; $staticmember = new Adherent($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType", $max)); + $year = date('Y'); + $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType").' ('.$year-$numberyears.' - '.$year.')'); if ($user->rights->adherent->lire) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; $stats = new AdherentStats($this->db, $user->socid, $user->id); // Show array - $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); $sumMembers = $stats->countMembersByTypeAndStatus($numberyears); if ($sumMembers) { $line = 0; From 1a2cf76e1c86e3013f9302bee9f378295ade2277 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 23 Dec 2022 13:48:33 +0000 Subject: [PATCH 019/203] Fixing style errors. --- htdocs/core/boxes/box_members_by_type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 1fc6590fd99..bed04be18b7 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -90,7 +90,7 @@ class box_members_by_type extends ModeleBoxes $year = date('Y'); $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); - + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType").' ('.$year-$numberyears.' - '.$year.')'); if ($user->rights->adherent->lire) { From 4a49bc29060072d17e9206021f8507f0c9c3e955 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 23 Dec 2022 14:55:09 +0100 Subject: [PATCH 020/203] look and feel --- htdocs/core/boxes/box_members_by_type.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 1fc6590fd99..ea475fbd15b 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -107,37 +107,37 @@ class box_members_by_type extends ModeleBoxes // Members Status To Valid $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); // Waiting for subscription $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus, ); // Up to date $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus, ); // Expired $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); // Excluded $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); // Resiliated $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); $this->info_box_contents[$line][] = array( - 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); // Total row From 95cea254e5777190e3ba489753eb06547a867f98 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Mon, 26 Dec 2022 22:39:17 +0100 Subject: [PATCH 021/203] Fix missing few up to date members --- htdocs/adherents/class/adherentstats.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index be48b5c0b25..683a18c7d62 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -207,7 +207,7 @@ class AdherentStats extends Stats $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED, "'members_resiliated'", 'NULL').") as members_resiliated"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON t.rowid = d.fk_adherent_type AND d.entity IN (" . getEntity('adherent') . ")"; - $sql .= " AND d.datefin BETWEEN '".$this->db->idate(dol_get_first_day($startYear))."' AND '".$this->db->idate(dol_get_last_day($endYear))."'"; + $sql .= " AND d.datefin > '".$this->db->idate(dol_get_first_day($startYear))."'"; $sql .= " WHERE t.entity IN (".getEntity('member_type').")"; $sql .= " AND t.statut = 1"; $sql .= " GROUP BY t.rowid"; From 1411acca52ae5e3c8d55fcb33aa8791f0892b03d Mon Sep 17 00:00:00 2001 From: FLIO Date: Mon, 27 Mar 2023 12:20:02 +0200 Subject: [PATCH 022/203] feature (select prospect status) change of the way to modify the status of the prospect by replacing it with a combobox --- htdocs/core/ajax/ajaxstatusprospect.php | 70 +++++ htdocs/core/class/html.formcompany.class.php | 280 +++++++++++-------- htdocs/societe/list.php | 25 +- 3 files changed, 246 insertions(+), 129 deletions(-) create mode 100644 htdocs/core/ajax/ajaxstatusprospect.php diff --git a/htdocs/core/ajax/ajaxstatusprospect.php b/htdocs/core/ajax/ajaxstatusprospect.php new file mode 100644 index 00000000000..4cf540db1f6 --- /dev/null +++ b/htdocs/core/ajax/ajaxstatusprospect.php @@ -0,0 +1,70 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2010 Cyrille de Lambert + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/ajaxstatusprospect.php + * \brief File to return Ajax response on third parties request + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +// If there is no need to load and show top and left menu +if (!defined("NOLOGIN")) { + define("NOLOGIN", '1'); +} + +// Load Dolibarr environment +require '../../main.inc.php'; + + +/* + * View + */ + +top_httphead(); + +$idstatus = GETPOST('id', 'int'); +$idprospect = GETPOST('prospectid', 'int'); +$action = GETPOST('action', 'aZ09'); + +if ($action === "updatestatusprospect") { + $response = ''; + + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; + $sql .= "fk_stcomm=".$db->escape($idstatus); + $sql .= " WHERE rowid = ".$db->escape($idprospect); + + $resql = $db->query($sql); + + if (!$resql) { + dol_print_error($db); + } else { + $num = $db->affected_rows($resql); + $response = http_response_code(200); + } + + $response =json_encode($response); + echo $response; +} diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 91d18049070..b188ea560b7 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -31,7 +31,7 @@ * Only common components are here. */ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; /** @@ -56,13 +56,13 @@ class FormCompany extends Form $effs = array(); $sql = "SELECT id, code, libelle"; - $sql .= " FROM ".$this->db->prefix()."c_typent"; - $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id) ? '0' : $mysoc->country_id).")"; + $sql .= " FROM " . $this->db->prefix() . "c_typent"; + $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = " . (empty($mysoc->country_id) ? '0' : $mysoc->country_id) . ")"; if ($filter) { - $sql .= " ".$filter; + $sql .= " " . $filter; } $sql .= " ORDER by position, id"; - dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); + dol_syslog(get_class($this) . '::typent_array', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -105,13 +105,13 @@ class FormCompany extends Form $effs = array(); $sql = "SELECT id, code, libelle"; - $sql .= " FROM ".$this->db->prefix()."c_effectif"; + $sql .= " FROM " . $this->db->prefix() . "c_effectif"; $sql .= " WHERE active = 1"; if ($filter) { - $sql .= " ".$filter; + $sql .= " " . $filter; } $sql .= " ORDER BY id ASC"; - dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); + dol_syslog(get_class($this) . '::effectif_array', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -149,13 +149,13 @@ class FormCompany extends Form // phpcs:enable global $user, $langs; - print '
'; + print ''; print ''; - print ''; + print ''; - dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); + dol_syslog(get_class($this) . '::form_prospect_level', LOG_DEBUG); $sql = "SELECT code, label"; - $sql .= " FROM ".$this->db->prefix()."c_prospectlevel"; + $sql .= " FROM " . $this->db->prefix() . "c_prospectlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); @@ -181,9 +181,9 @@ class FormCompany extends Form dol_print_error($this->db); } if (!empty($htmlname) && $user->admin) { - print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - print ''; + print ''; print '
'; } @@ -200,13 +200,13 @@ class FormCompany extends Form { global $user, $langs; - print '
'; + print ''; print ''; - print ''; + print ''; dol_syslog(__METHOD__, LOG_DEBUG); $sql = "SELECT code, label"; - $sql .= " FROM ".$this->db->prefix()."c_prospectcontactlevel"; + $sql .= " FROM " . $this->db->prefix() . "c_prospectcontactlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); @@ -232,9 +232,9 @@ class FormCompany extends Form dol_print_error($this->db); } if (!empty($htmlname) && $user->admin) { - print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - print ''; + print ''; print '
'; } @@ -275,7 +275,7 @@ class FormCompany extends Form // phpcs:enable global $conf, $langs, $user; - dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_departement selected=" . $selected . ", country_codeid=" . $country_codeid, LOG_DEBUG); $langs->load("dict"); @@ -283,28 +283,28 @@ class FormCompany extends Form // Serch departements/cantons/province active d'une region et pays actif $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; - $sql .= " ".$this->db->prefix()."c_departements as d, ".$this->db->prefix()."c_regions as r,".$this->db->prefix()."c_country as c"; + $sql .= " " . $this->db->prefix() . "c_departements as d, " . $this->db->prefix() . "c_regions as r," . $this->db->prefix() . "c_country as c"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; if ($country_codeid && is_numeric($country_codeid)) { - $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; + $sql .= " AND c.rowid = '" . $this->db->escape($country_codeid) . "'"; } if ($country_codeid && !is_numeric($country_codeid)) { - $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; + $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'"; } $sql .= " ORDER BY c.code, d.code_departement"; $result = $this->db->query($sql); if ($result) { if (!empty($htmlname)) { - $out .= ''; } if ($country_codeid) { $out .= ''; } $num = $this->db->num_rows($result); $i = 0; - dol_syslog(get_class($this)."::select_departement num=".$num, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_departement num=" . $num, LOG_DEBUG); if ($num) { $country = ''; while ($i < $num) { @@ -315,28 +315,30 @@ class FormCompany extends Form if (!$country || $country != $obj->country) { // Show break if we are in list with multiple countries if (!$country_codeid && $obj->country_code) { - $out .= '\n"; + $out .= '\n"; $country = $obj->country; } } if (!empty($selected) && $selected == $obj->rowid) { - $out .= '\n"; + $key = $langs->trans("Country" . strtoupper($obj->country_code)); + $valuetoshow = ($key != "Country" . strtoupper($obj->country_code)) ? $obj->country_code . " - " . $key : $obj->country; + print '\n"; $country = $obj->country; } if ($selected > 0 && $selected == $obj->code) { - print ''; + print ''; } else { - print ''; + print ''; } } $i++; @@ -444,13 +446,13 @@ class FormCompany extends Form $out = ''; - $sql = "SELECT rowid, code, label, active FROM ".$this->db->prefix()."c_civility"; + $sql = "SELECT rowid, code, label, active FROM " . $this->db->prefix() . "c_civility"; $sql .= " WHERE active = 1"; dol_syslog("Form::select_civility", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $out .= ''; $out .= ''; $num = $this->db->num_rows($resql); $i = 0; @@ -458,12 +460,12 @@ class FormCompany extends Form while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($selected == $obj->code) { - $out .= ''; $i++; } @@ -475,7 +477,7 @@ class FormCompany extends Form if ($addjscombo) { // Enhance with select2 - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname); } } else { @@ -525,22 +527,22 @@ class FormCompany extends Form // On recherche les formes juridiques actives des pays actifs $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; - $sql .= " FROM ".$this->db->prefix()."c_forme_juridique as f, ".$this->db->prefix()."c_country as c"; + $sql .= " FROM " . $this->db->prefix() . "c_forme_juridique as f, " . $this->db->prefix() . "c_country as c"; $sql .= " WHERE f.fk_pays=c.rowid"; $sql .= " AND f.active = 1 AND c.active = 1"; if ($country_codeid) { - $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; + $sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'"; } if ($filter) { - $sql .= " ".$filter; + $sql .= " " . $filter; } $sql .= " ORDER BY c.code"; - dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); + dol_syslog(get_class($this) . "::select_juridicalstatus", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $out .= '
'; - $out .= ''; if ($country_codeid) { $out .= ''; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. } @@ -554,31 +556,31 @@ class FormCompany extends Form $obj = $this->db->fetch_object($resql); if ($obj->code) { // We exclude empty line, we will add it later - $labelcountry = (($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); - $labeljs = (($langs->trans("JuridicalStatus".$obj->code) != "JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver) - $arraydata[$obj->code] = array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); + $labelcountry = (($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code) ? $langs->trans("Country" . $obj->country_code) : $obj->country); + $labeljs = (($langs->trans("JuridicalStatus" . $obj->code) != "JuridicalStatus" . $obj->code) ? $langs->trans("JuridicalStatus" . $obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver) + $arraydata[$obj->code] = array('code' => $obj->code, 'label' => $labeljs, 'label_sort' => $labelcountry . '_' . $labeljs, 'country_code' => $obj->country_code, 'country' => $labelcountry); } $i++; } $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC'); if (empty($country_codeid)) { // Introduce empty value (if $country_codeid not empty, empty value was already added) - $arraydata[0] = array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); + $arraydata[0] = array('code' => 0, 'label' => '', 'label_sort' => '_', 'country_code' => '', 'country' => ''); } foreach ($arraydata as $key => $val) { if (!$country || $country != $val['country']) { // Show break when we are in multi country mode if (empty($country_codeid) && $val['country_code']) { - $out .= '\n"; + $out .= '\n"; $country = $val['country']; } } if ($selected > 0 && $selected == $val['code']) { - $out .= '
'; @@ -645,13 +647,13 @@ class FormCompany extends Form $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); if (count($events)) { // If there is some ajax events to run once selection is done, we add code here to run events - print ''; } - print "\n".''."\n"; - print ''; - print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajax/ajaxcompanies.php', '', $minLength, 0); + print "\n" . '' . "\n"; + print ''; + print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT . '/societe/ajax/ajaxcompanies.php', '', $minLength, 0); return $socid; } else { // Search to list thirdparties @@ -709,14 +711,14 @@ class FormCompany extends Form $sql .= ", s.address, s.zip, s.town"; $sql .= ", dictp.code as country_code"; } - $sql .= " FROM ".$this->db->prefix()."societe as s"; + $sql .= " FROM " . $this->db->prefix() . "societe as s"; if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."c_country as dictp ON dictp.rowid = s.fk_pays"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays"; } - $sql .= " WHERE s.entity IN (".getEntity('societe').")"; + $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")"; // For ajax search we limit here. For combo list, we limit later if (is_array($limitto) && count($limitto)) { - $sql .= " AND s.rowid IN (".$this->db->sanitize(join(',', $limitto)).")"; + $sql .= " AND s.rowid IN (" . $this->db->sanitize(join(',', $limitto)) . ")"; } // Add where from hooks $parameters = array(); @@ -726,10 +728,10 @@ class FormCompany extends Form $resql = $this->db->query($sql); if ($resql) { - print ''; + $out .= '"; if ($user->admin && empty($forcehidetooltip)) { - $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } $out .= ajax_combobox($htmlname); @@ -837,9 +839,9 @@ class FormCompany extends Form if ($rendermode === 'view') { $toprint = array(); foreach ($contact->roles as $key => $val) { - $toprint[] = '
  • '.$val['label'].'
  • '; + $toprint[] = '
  • ' . $val['label'] . '
  • '; } - return '
      '.implode(' ', $toprint).'
    '; + return '
      ' . implode(' ', $toprint) . '
    '; } if ($rendermode === 'edit') { @@ -885,14 +887,14 @@ class FormCompany extends Form $size = ''; if (!empty($fieldsize)) { - $size = 'size="'.$fieldsize.'"'; + $size = 'size="' . $fieldsize . '"'; } if ($conf->use_javascript_ajax && empty($disableautocomplete)) { - $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; + $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT . '/core/ajax/ziptown.php') . "\n"; $moreattrib .= ' autocomplete="off"'; } - $out .= ''."\n"; + $out .= '' . "\n"; return $out; } @@ -965,10 +967,10 @@ class FormCompany extends Form $out = ''; // Execute hook getInputIdProf to complete or replace $out - $parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code); + $parameters = array('formlength' => $formlength, 'selected' => $preselected, 'idprof' => $idprof, 'htmlname' => $htmlname, 'country_code' => $country_code); $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters); if (empty($reshook)) { - $out .= ''; + $out .= ''; } $out .= $hookmanager->resPrint; @@ -996,18 +998,18 @@ class FormCompany extends Form if (count($valors) > 1) { //montar select - print ''; while ($i <= (count($valors)) - 1) { if ($selected == $valors[$i]) { - print ''; $i++; } - print''; + print ''; } } } @@ -1027,10 +1029,10 @@ class FormCompany extends Form { global $conf, $langs; if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && !isModEnabled('fournisseur')) { - return '' ; + return ''; } - $out = ''; if ($typeinput == 'form') { if ($allowempty || ($selected == '' || $selected == '-1')) { $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } - $out .= ''; + $out .= ''; } elseif ($typeinput == 'list') { - $out .= ''; + $out .= ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } if (isModEnabled("fournisseur")) { - $out .= ''; + $out .= ''; } - $out .= ''; + $out .= ''; } elseif ($typeinput == 'admin') { if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { - $out .= ''; + $out .= ''; } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $out .= ''; + $out .= ''; } } $out .= ''; @@ -1094,12 +1096,12 @@ class FormCompany extends Form $out = ''; if ($htmlname != "none") { - $out .= '
    '; + $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. $out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1); - $out .= ''; + $out .= ''; $out .= '
    '; } else { if ($selected > 0) { @@ -1117,4 +1119,52 @@ class FormCompany extends Form print $out; } } + + /** + * Output html select to select prospect status + * + * @param string $htmlname Name of HTML select + * @param object $prospectstatic list of status prospect + * @param int $statusprospect status of prospect + * @param int $idprospect id of prospect + * @param string $mode select if we want activate de html part or js + * @return void + */ + public function selectStatus($htmlname, $prospectstatic, $statusprospect, $idprospect, $mode = "html") + { + + if ($mode === "html") { + print ''; + print ajax_combobox($htmlname); + } elseif ($mode === "js") { + print ''; + } + } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 085bc0d2532..3b9493ae2e4 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1826,20 +1826,14 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['s.fk_stcomm']['checked'])) { // Prospect status - print '
    '; - print '
    '; - print $companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); - print '
    -
    '; - foreach ($prospectstatic->cacheprospectstatus as $key => $val) { - $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { - $titlealt = $val['label']; - } - if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; - } - } - print '
    '; + + $prospectid = $obj->rowid; + $statusprospect = $obj->stcomm_id; + + $formcompany->selectStatus('status_prospect', $prospectstatic, $statusprospect, $prospectid); + + print '
    '.$langs->trans("ToOrder").'
    '.$langs->trans("OrderDate").''; $date_com = dol_mktime(GETPOST('rehour', 'int'), GETPOST('remin', 'int'), GETPOST('resec', 'int'), GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($date_com)) { - $date_com = dol_now(); - } - print $form->selectDate($date_com, '', 1, 1, '', "commande", 1, 1); + print $form->selectDate($date_com ?: '', '', 0, 0, '', "commande", 1, 1); print '
    "; - if ($conf->global->DELIVERY_ADDON_PDF == "$name") { + if (getDolGlobalString('DELIVERY_ADDON_PDF') == "$name") { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php index 68da925e62b..89cdafa9fe7 100644 --- a/htdocs/core/modules/delivery/mod_delivery_saphir.php +++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php @@ -83,7 +83,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder // Parametrage du prefix $texte .= '
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).' 
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).' 
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).''.$form->textwithpicto('', $tooltip, 1, 1).' 
    '; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9c5d62fc38b..ed2551386b6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2085,6 +2085,7 @@ EnterCalculationRuleIfPreviousFieldIsYes=Enter calculation rule if previous fiel SeveralLangugeVariatFound=Several language variants found RemoveSpecialChars=Remove special characters COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) +COMPANY_AQUARIUM_NO_PREFIX=Do not use prefix, only copy customer or supplier code COMPANY_DIGITARIA_CLEAN_REGEX=Regex filter to clean value (COMPANY_DIGITARIA_CLEAN_REGEX) COMPANY_DIGITARIA_UNIQUE_CODE=Duplicate not allowed RemoveSpecialWords=Clean certain words when generating sub-accounts for customers or suppliers From 9179d51c0ee38ffcc76aad04cc2488026cabcadb Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 7 May 2023 14:00:18 +0000 Subject: [PATCH 034/203] Fixing style errors. --- htdocs/core/modules/societe/mod_codecompta_aquarium.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index e3c6ad1600c..3805feee4ce 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -65,7 +65,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode if (!empty($conf->global->COMPANY_AQUARIUM_NO_PREFIX)) { $this->prefixcustomeraccountancycode = ''; $this->prefixsupplieraccountancycode = ''; - }else{ + } else { $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; } From 5a58166614930caf86c47f185bacccb15ca66d61 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 8 May 2023 13:18:42 +0200 Subject: [PATCH 035/203] FIX list orders API --- htdocs/commande/class/api_orders.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index bb51b8c2111..ae9625fbcb5 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -184,7 +184,7 @@ class Orders extends DolibarrApi if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) } - $sql .= " FROM ".MAIN_DB_PREFIX."facture AS t LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields + $sql .= " FROM ".MAIN_DB_PREFIX."commande AS t LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale From df0adc391d22401c3ffa542d0af88eb2d7a30e83 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 7 May 2023 14:31:35 +0200 Subject: [PATCH 036/203] FIX test/phpunit: add $name to __construct() Fix the following errors when running recent phpunit: Message: Too few arguments to function PHPUnit\Framework\TestCase::__construct(), 0 passed in dolibarr/test/phpunit/DateLibTzFranceTest.php on line 63 and exactly 1 expected Location: phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestCase.php:265 Indeed, the old constructor had an optional $name='' parameter but the new constructor reads like this: public function __construct(string $name) and the parameter is now mandatory. --- htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php | 5 +++-- test/phpunit/AccountingAccountTest.php | 5 +++-- test/phpunit/ActionCommTest.php | 5 +++-- test/phpunit/AdherentTest.php | 5 +++-- test/phpunit/AdminLibTest.php | 5 +++-- test/phpunit/BOMTest.php | 5 +++-- test/phpunit/BankAccountTest.php | 5 +++-- test/phpunit/BarcodeTest.php | 5 +++-- test/phpunit/BonPrelevementTest.php | 5 +++-- test/phpunit/BuildDocTest.php | 5 +++-- test/phpunit/CMailFileTest.php | 5 +++-- test/phpunit/CategorieTest.php | 5 +++-- test/phpunit/ChargeSocialesTest.php | 5 +++-- test/phpunit/CodingPhpTest.php | 5 +++-- test/phpunit/CodingSqlTest.php | 5 +++-- test/phpunit/CommandeFournisseurTest.php | 5 +++-- test/phpunit/CommandeTest.php | 5 +++-- test/phpunit/CommonInvoiceTest.php | 5 +++-- test/phpunit/CommonObjectTest.php | 5 +++-- test/phpunit/CompanyBankAccountTest.php | 5 +++-- test/phpunit/CompanyLibTest.php | 5 +++-- test/phpunit/ContactTest.php | 5 +++-- test/phpunit/ContratTest.php | 5 +++-- test/phpunit/CoreTest.php | 5 +++-- test/phpunit/DateLibTest.php | 5 +++-- test/phpunit/DateLibTzFranceTest.php | 5 +++-- test/phpunit/DiscountTest.php | 5 +++-- test/phpunit/DoliDBTest.php | 5 +++-- test/phpunit/EmailCollectorTest.php | 5 +++-- test/phpunit/EntrepotTest.php | 5 +++-- test/phpunit/EvalMathTest.php | 4 ++-- test/phpunit/ExpenseReportTest.php | 5 +++-- test/phpunit/ExportTest.php | 5 +++-- test/phpunit/FactureFournisseurTest.php | 5 +++-- test/phpunit/FactureRecTest.php | 5 +++-- test/phpunit/FactureTest.php | 5 +++-- test/phpunit/FichinterTest.php | 5 +++-- test/phpunit/FilesLibTest.php | 5 +++-- test/phpunit/FormAdminTest.php | 5 +++-- test/phpunit/FormTest.php | 5 +++-- test/phpunit/Functions2LibTest.php | 5 +++-- test/phpunit/FunctionsLibTest.php | 5 +++-- test/phpunit/GetUrlLibTest.php | 5 +++-- test/phpunit/HolidayTest.php | 5 +++-- test/phpunit/ImagesLibTest.php | 5 +++-- test/phpunit/ImportTest.php | 5 +++-- test/phpunit/InventoryTest.php | 5 +++-- test/phpunit/JsonLibTest.php | 5 +++-- test/phpunit/KnowledgeRecordTest.php | 5 +++-- test/phpunit/LangTest.php | 5 +++-- test/phpunit/LesscTest.php | 5 +++-- test/phpunit/LoanTest.php | 5 +++-- test/phpunit/MarginsLibTest.php | 5 +++-- test/phpunit/ModulesTest.php | 5 +++-- test/phpunit/MouvementStockTest.php | 5 +++-- test/phpunit/NumberingModulesTest.php | 5 +++-- test/phpunit/ODFTest.php | 4 ++-- test/phpunit/PaypalTest.php | 5 +++-- test/phpunit/PdfDocTest.php | 5 +++-- test/phpunit/PgsqlTest.php | 5 +++-- test/phpunit/PricesTest.php | 5 +++-- test/phpunit/ProductTest.php | 5 +++-- test/phpunit/ProjectTest.php | 5 +++-- test/phpunit/PropalTest.php | 5 +++-- test/phpunit/RepositoryTest.php | 5 +++-- test/phpunit/RestAPIDocumentTest.php | 5 +++-- test/phpunit/RestAPIUserTest.php | 5 +++-- test/phpunit/ScriptsTest.php | 5 +++-- test/phpunit/SecurityTest.php | 5 +++-- test/phpunit/SocieteTest.php | 5 +++-- test/phpunit/StripeTest.php | 5 +++-- test/phpunit/SupplierProposalTest.php | 5 +++-- test/phpunit/TargetTest.php | 5 +++-- test/phpunit/TicketTest.php | 5 +++-- test/phpunit/UserGroupTest.php | 5 +++-- test/phpunit/UserTest.php | 5 +++-- test/phpunit/UtilsTest.php | 5 +++-- test/phpunit/WebservicesInvoicesTest.php | 5 +++-- test/phpunit/WebservicesOrdersTest.php | 5 +++-- test/phpunit/WebservicesOtherTest.php | 5 +++-- test/phpunit/WebservicesProductsTest.php | 5 +++-- test/phpunit/WebservicesThirdpartyTest.php | 5 +++-- test/phpunit/WebservicesUserTest.php | 5 +++-- test/phpunit/WebsiteTest.php | 5 +++-- test/phpunit/XCalLibTest.php | 5 +++-- 85 files changed, 253 insertions(+), 170 deletions(-) diff --git a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php index b31a3ca08d5..d4c811f1666 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2023 Alexandre Janniaux * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify @@ -57,9 +58,9 @@ class MyObjectTest extends PHPUnit\Framework\TestCase * Constructor * We save global variables into local variables */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf, $user, $langs, $db; diff --git a/test/phpunit/AccountingAccountTest.php b/test/phpunit/AccountingAccountTest.php index bf34616563a..938302d7445 100644 --- a/test/phpunit/AccountingAccountTest.php +++ b/test/phpunit/AccountingAccountTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class AccountingAccountTest extends PHPUnit\Framework\TestCase * * @return AccountingAccountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ActionCommTest.php b/test/phpunit/ActionCommTest.php index d3c0a02a656..be8d16758ca 100644 --- a/test/phpunit/ActionCommTest.php +++ b/test/phpunit/ActionCommTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class ActionCommTest extends PHPUnit\Framework\TestCase * * @return ActionCommTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index ce7c44e01c6..a1e297a1a40 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2013 Marcos García + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class AdherentTest extends PHPUnit\Framework\TestCase * * @return AdherentTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/AdminLibTest.php b/test/phpunit/AdminLibTest.php index 4df1a6933e1..32e3564a656 100644 --- a/test/phpunit/AdminLibTest.php +++ b/test/phpunit/AdminLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class AdminLibTest extends PHPUnit\Framework\TestCase * * @return AdminLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BOMTest.php b/test/phpunit/BOMTest.php index c331c3cd4e2..66e84e17d50 100644 --- a/test/phpunit/BOMTest.php +++ b/test/phpunit/BOMTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software: you can redistribute it and/or modify @@ -58,9 +59,9 @@ class BOMTest extends PHPUnit\Framework\TestCase * * @return BOMTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BankAccountTest.php b/test/phpunit/BankAccountTest.php index 4e879be7c0a..538c417a188 100644 --- a/test/phpunit/BankAccountTest.php +++ b/test/phpunit/BankAccountTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -60,9 +61,9 @@ class BankAccountTest extends PHPUnit\Framework\TestCase * * @return BankAccountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BarcodeTest.php b/test/phpunit/BarcodeTest.php index 67cc013c50b..c2c22b6707f 100644 --- a/test/phpunit/BarcodeTest.php +++ b/test/phpunit/BarcodeTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -60,9 +61,9 @@ class BarcodeTest extends PHPUnit\Framework\TestCase * * @return BarcodeTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BonPrelevementTest.php b/test/phpunit/BonPrelevementTest.php index 1adf938a906..039cc928b28 100644 --- a/test/phpunit/BonPrelevementTest.php +++ b/test/phpunit/BonPrelevementTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class BonPrelevementTest extends PHPUnit\Framework\TestCase * * @return BankAccountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index 82fe9c43ee6..604430e032f 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -87,9 +88,9 @@ class BuildDocTest extends PHPUnit\Framework\TestCase * * @return BuildDocTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index 729aa4b4c7f..5ad9ca3268d 100644 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class CMailFileTest extends PHPUnit\Framework\TestCase * * @return CMailFile */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 763be9cca65..5f90628cbd9 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class CategorieTest extends PHPUnit\Framework\TestCase * * @return CategorieTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index 2feaccd497b..0a33086432a 100644 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class ChargeSocialesTest extends PHPUnit\Framework\TestCase * * @return ChargeSocialesTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index f33aa1c1588..04cd05698cf 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -89,9 +90,9 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase * * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 94b6d57b558..31e422b63cb 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -89,9 +90,9 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase * * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 7282fb1a88e..cc9a4018e11 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class CommandeFournisseurTest extends PHPUnit\Framework\TestCase * * @return CommandeFournisseurTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index fa3fe3ac843..5849132cd69 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class CommandeTest extends PHPUnit\Framework\TestCase * * @return CommandeTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CommonInvoiceTest.php b/test/phpunit/CommonInvoiceTest.php index a5b93720ede..ede02bc6a53 100644 --- a/test/phpunit/CommonInvoiceTest.php +++ b/test/phpunit/CommonInvoiceTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class CommonInvoiceTest extends PHPUnit\Framework\TestCase * * @return CommonObjectTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index bf68954227c..1533f0fe879 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class CommonObjectTest extends PHPUnit\Framework\TestCase * * @return CommonObjectTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index 05f0abd136d..3a815dc572e 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class CompanyBankAccountTest extends PHPUnit\Framework\TestCase * * @return CompanyBankAccountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CompanyLibTest.php b/test/phpunit/CompanyLibTest.php index 39b8109b3a3..047a27d734c 100644 --- a/test/phpunit/CompanyLibTest.php +++ b/test/phpunit/CompanyLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class CompanyLibTest extends PHPUnit\Framework\TestCase * * @return AdminLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index c28db01d579..80916d02f44 100644 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -64,9 +65,9 @@ class ContactTest extends PHPUnit\Framework\TestCase * * @return ContactTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php index 17d302fcf82..706e058899c 100644 --- a/test/phpunit/ContratTest.php +++ b/test/phpunit/ContratTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class ContratTest extends PHPUnit\Framework\TestCase * * @return ContratTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 8ac448fa15e..82d4d3d50c2 100644 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -80,9 +81,9 @@ class CoreTest extends PHPUnit\Framework\TestCase * * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index eef029d26d1..f4287c2493f 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -61,9 +62,9 @@ class DateLibTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/DateLibTzFranceTest.php b/test/phpunit/DateLibTzFranceTest.php index b855b240648..ecb434751ff 100644 --- a/test/phpunit/DateLibTzFranceTest.php +++ b/test/phpunit/DateLibTzFranceTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class DateLibTzFranceTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/DiscountTest.php b/test/phpunit/DiscountTest.php index b7e4297f490..279cfd3ae29 100644 --- a/test/phpunit/DiscountTest.php +++ b/test/phpunit/DiscountTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class DiscountTest extends PHPUnit\Framework\TestCase * * @return DiscountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/DoliDBTest.php b/test/phpunit/DoliDBTest.php index f810deee98e..e090bea30e1 100644 --- a/test/phpunit/DoliDBTest.php +++ b/test/phpunit/DoliDBTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class DoliDBTest extends PHPUnit\Framework\TestCase * * @return DiscountTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/EmailCollectorTest.php b/test/phpunit/EmailCollectorTest.php index 8ad06dc1f23..eaeac54d5e0 100644 --- a/test/phpunit/EmailCollectorTest.php +++ b/test/phpunit/EmailCollectorTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class EmailCollectorTest extends PHPUnit\Framework\TestCase * * @return ExpenseReportTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index 9bf237374ef..d61d5373694 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class EntrepotTest extends PHPUnit\Framework\TestCase * * @return EntrepotTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/EvalMathTest.php b/test/phpunit/EvalMathTest.php index bc50c65f6b8..36ff52a8cea 100644 --- a/test/phpunit/EvalMathTest.php +++ b/test/phpunit/EvalMathTest.php @@ -57,9 +57,9 @@ class EvalMathTest extends PHPUnit\Framework\TestCase * * @return InventoryTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ExpenseReportTest.php b/test/phpunit/ExpenseReportTest.php index 689c88d1313..226e3879fa0 100644 --- a/test/phpunit/ExpenseReportTest.php +++ b/test/phpunit/ExpenseReportTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class ExpenseReportTest extends PHPUnit\Framework\TestCase * * @return ExpenseReportTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 0a0a1c867ba..c8c7910be28 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -82,9 +83,9 @@ class ExportTest extends PHPUnit\Framework\TestCase * * @return ExportTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index 4b0c41d5f82..8979008daf4 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 Juanjo Menent + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class FactureFournisseurTest extends PHPUnit\Framework\TestCase * * @return FactureFournisseurTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index d5d9a164daa..7ed8addde38 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class FactureRecTest extends PHPUnit\Framework\TestCase * * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 004fc18725e..df4ad4077dc 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Frédéric France + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class FactureTest extends PHPUnit\Framework\TestCase * * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FichinterTest.php b/test/phpunit/FichinterTest.php index 8fb2ee736cc..7211a80f056 100644 --- a/test/phpunit/FichinterTest.php +++ b/test/phpunit/FichinterTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class FichinterTest extends PHPUnit\Framework\TestCase * * @return ContratTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 520e1888899..848f55a9d3a 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class FilesLibTest extends PHPUnit\Framework\TestCase * * @return FilesLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FormAdminTest.php b/test/phpunit/FormAdminTest.php index e9beea8a5c6..d2517f41b36 100644 --- a/test/phpunit/FormAdminTest.php +++ b/test/phpunit/FormAdminTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class FormAdminTest extends PHPUnit\Framework\TestCase * * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FormTest.php b/test/phpunit/FormTest.php index 429ae296152..9ea3091e0c4 100644 --- a/test/phpunit/FormTest.php +++ b/test/phpunit/FormTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class FormTest extends PHPUnit\Framework\TestCase * * @return FactureTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 69ccdc45866..fe90ded3947 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -81,9 +82,9 @@ class Functions2LibTest extends PHPUnit\Framework\TestCase * * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 90a92c450cb..2717e5752d6 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -88,9 +89,9 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase * * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db,$mysoc; diff --git a/test/phpunit/GetUrlLibTest.php b/test/phpunit/GetUrlLibTest.php index b8e3c50363f..e408a9637b3 100644 --- a/test/phpunit/GetUrlLibTest.php +++ b/test/phpunit/GetUrlLibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class GetUrlLibTest extends PHPUnit\Framework\TestCase * * @return FilesLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index d6ebd6425e4..5c63cfa3a4a 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class HolidayTest extends PHPUnit\Framework\TestCase * * @return HolidayTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index b8288aa25e6..85515e41410 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class ImagesLibTest extends PHPUnit\Framework\TestCase * * @return ImagesLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php index d64c82cc4e8..86491f51d44 100644 --- a/test/phpunit/ImportTest.php +++ b/test/phpunit/ImportTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -80,9 +81,9 @@ class ImportTest extends PHPUnit\Framework\TestCase * * @return ImportTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/InventoryTest.php b/test/phpunit/InventoryTest.php index c4b415885d3..37ecd42b3bf 100644 --- a/test/phpunit/InventoryTest.php +++ b/test/phpunit/InventoryTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Frédéric France + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class InventoryTest extends PHPUnit\Framework\TestCase * * @return InventoryTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php index 341cf51583f..c5f11995a62 100644 --- a/test/phpunit/JsonLibTest.php +++ b/test/phpunit/JsonLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -80,9 +81,9 @@ class JsonLibTest extends PHPUnit\Framework\TestCase * * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/KnowledgeRecordTest.php b/test/phpunit/KnowledgeRecordTest.php index 8dab9846435..df45e08f9ad 100644 --- a/test/phpunit/KnowledgeRecordTest.php +++ b/test/phpunit/KnowledgeRecordTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2021 SuperAdmin + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -60,9 +61,9 @@ class KnowledgeRecordTest extends PHPUnit\Framework\TestCase * * @return KnowledgeRecordTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf, $user, $langs, $db; diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index 18fa1c2d4db..f4a69984826 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -89,9 +90,9 @@ class LangTest extends PHPUnit\Framework\TestCase * * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/LesscTest.php b/test/phpunit/LesscTest.php index e9a72d0ef4f..410dd9962ae 100644 --- a/test/phpunit/LesscTest.php +++ b/test/phpunit/LesscTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -89,9 +90,9 @@ class LesscTest extends PHPUnit\Framework\TestCase * * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/LoanTest.php b/test/phpunit/LoanTest.php index 2eaaa221183..dee18969671 100644 --- a/test/phpunit/LoanTest.php +++ b/test/phpunit/LoanTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class LoanTest extends PHPUnit\Framework\TestCase * * @return LoanTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/MarginsLibTest.php b/test/phpunit/MarginsLibTest.php index 0b5aa0cfb5e..6ed510a0e84 100644 --- a/test/phpunit/MarginsLibTest.php +++ b/test/phpunit/MarginsLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class MarginsLibTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php index 5ef22cddd88..85612835a88 100644 --- a/test/phpunit/ModulesTest.php +++ b/test/phpunit/ModulesTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,9 +57,9 @@ class ModulesTest extends PHPUnit\Framework\TestCase * * @return BuildDocTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index 68eacd466bf..c2aa8d974cb 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase * * @return ContratTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 9134ad3e0d5..ccdb9605b47 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -56,9 +57,9 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase * * @return NumberingModulesTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ODFTest.php b/test/phpunit/ODFTest.php index 4211a637303..744ca217f56 100644 --- a/test/phpunit/ODFTest.php +++ b/test/phpunit/ODFTest.php @@ -59,9 +59,9 @@ class ODFTest extends PHPUnit\Framework\TestCase * * @return BOMTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index fdcc17fd48d..70843685d53 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class PaypalTest extends PHPUnit\Framework\TestCase * * @return ProductTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index 238830ac1a0..ef7fbe384b5 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -60,9 +61,9 @@ class PdfDocTest extends PHPUnit\Framework\TestCase * * @return PdfDocTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PgsqlTest.php b/test/phpunit/PgsqlTest.php index 17c4c82714e..75f34a6a339 100644 --- a/test/phpunit/PgsqlTest.php +++ b/test/phpunit/PgsqlTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class PgsqlTest extends PHPUnit\Framework\TestCase * * @return ContactTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index cab19d715f5..0238ad436bf 100644 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -63,9 +64,9 @@ class PricesTest extends PHPUnit\Framework\TestCase * * @return CoreTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 4f237a90314..f40b3877b43 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class ProductTest extends PHPUnit\Framework\TestCase * * @return ProductTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ProjectTest.php b/test/phpunit/ProjectTest.php index ee2f4ed92c2..0e4515d6ae3 100644 --- a/test/phpunit/ProjectTest.php +++ b/test/phpunit/ProjectTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class ProjectTest extends PHPUnit\Framework\TestCase * * @return ProjectTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php index 833812bfb4b..4774896b610 100644 --- a/test/phpunit/PropalTest.php +++ b/test/phpunit/PropalTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class PropalTest extends PHPUnit\Framework\TestCase * * @return PropalTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/RepositoryTest.php b/test/phpunit/RepositoryTest.php index 1df9cbe7aa8..fbfd46c0273 100644 --- a/test/phpunit/RepositoryTest.php +++ b/test/phpunit/RepositoryTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -88,9 +89,9 @@ class RepositoryTest extends PHPUnit\Framework\TestCase * * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index 1992e56d815..e10b9475938 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -60,9 +61,9 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 4de0557c561..aa7b46acd31 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -62,9 +63,9 @@ class RestAPIUserTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/ScriptsTest.php b/test/phpunit/ScriptsTest.php index 6132cd7837a..9318f06768f 100644 --- a/test/phpunit/ScriptsTest.php +++ b/test/phpunit/ScriptsTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -89,9 +90,9 @@ class ScriptsTest extends PHPUnit\Framework\TestCase * * @return ScriptsTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 1138e06d3b2..faaed70f55c 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -85,9 +86,9 @@ class SecurityTest extends PHPUnit\Framework\TestCase * * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index 415212c64cb..08fe801ad07 100644 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class SocieteTest extends PHPUnit\Framework\TestCase * * @return SocieteTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/StripeTest.php b/test/phpunit/StripeTest.php index e26b023a38e..1ffc13111d5 100644 --- a/test/phpunit/StripeTest.php +++ b/test/phpunit/StripeTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class StripeTest extends PHPUnit\Framework\TestCase * * @return ProductTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index 81917e34d9e..00945a3f21b 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -60,9 +61,9 @@ class SupplierProposalTest extends PHPUnit\Framework\TestCase * * @return PropalTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/TargetTest.php b/test/phpunit/TargetTest.php index 3a96ceba3b2..0f8b131cf0f 100644 --- a/test/phpunit/TargetTest.php +++ b/test/phpunit/TargetTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -59,9 +60,9 @@ class TargetTest extends PHPUnit\Framework\TestCase * * @return TargetTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf, $user, $langs, $db; diff --git a/test/phpunit/TicketTest.php b/test/phpunit/TicketTest.php index 5d05f7839f4..9e4ad378d78 100644 --- a/test/phpunit/TicketTest.php +++ b/test/phpunit/TicketTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -58,9 +59,9 @@ class TicketTest extends PHPUnit\Framework\TestCase * * @return ContratTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/UserGroupTest.php b/test/phpunit/UserGroupTest.php index 8ca21384002..e3ca255d737 100644 --- a/test/phpunit/UserGroupTest.php +++ b/test/phpunit/UserGroupTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class UserGroupTest extends PHPUnit\Framework\TestCase * * @return UserGroupTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index 625c4df7ef7..8ddc77c2af8 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class UserTest extends PHPUnit\Framework\TestCase * * @return UserTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/UtilsTest.php b/test/phpunit/UtilsTest.php index 5c34df81ea4..d4aacaddf4e 100644 --- a/test/phpunit/UtilsTest.php +++ b/test/phpunit/UtilsTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class UtilsTest extends PHPUnit\Framework\TestCase * * @return UserTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index dccf1516993..3db4faf838c 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -69,9 +70,9 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index f790ac15902..17ad8a72e9f 100644 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -61,9 +62,9 @@ class WebservicesOrdersTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index 5f5a6e833b1..d8a2fa09632 100644 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -61,9 +62,9 @@ class WebservicesOtherTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index 021c305f7e2..81c05899929 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -67,9 +68,9 @@ class WebservicesProductsTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 7d8fb7aab8e..a4b442dc7bd 100644 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -67,9 +68,9 @@ class WebservicesThirdpartyTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php index 6eba28dfde8..03b0c56e660 100644 --- a/test/phpunit/WebservicesUserTest.php +++ b/test/phpunit/WebservicesUserTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -61,9 +62,9 @@ class WebservicesUserTest extends PHPUnit\Framework\TestCase * * @return DateLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebsiteTest.php b/test/phpunit/WebsiteTest.php index 4383d844ed8..1b23a3d92f9 100644 --- a/test/phpunit/WebsiteTest.php +++ b/test/phpunit/WebsiteTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -90,9 +91,9 @@ class WebsiteTest extends PHPUnit\Framework\TestCase * * @return SecurityTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/XCalLibTest.php b/test/phpunit/XCalLibTest.php index dc4550fc84f..cc69bd85b60 100644 --- a/test/phpunit/XCalLibTest.php +++ b/test/phpunit/XCalLibTest.php @@ -1,5 +1,6 @@ + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -57,9 +58,9 @@ class XCalLibTest extends PHPUnit\Framework\TestCase * * @return FilesLibTest */ - public function __construct() + public function __construct($name = '') { - parent::__construct(); + parent::__construct($name); //$this->sharedFixture global $conf,$user,$langs,$db; From d21daa267c707878682b4f2ae2cc10f52b661b04 Mon Sep 17 00:00:00 2001 From: bomuux Date: Mon, 8 May 2023 17:54:42 +0200 Subject: [PATCH 037/203] FIX: Inventory lines values deleted when changing page length On page /product/inventory/inventory.php 1. With the default page limit of 20, 2. With an inventory containing more than 20 lines, let's say 30, thus displayed on 2 pages: -> updating when changing page WITH ARROWS works well. -> switching page length (limit) from 20 to more (say 30) WILL ERASE VALUES from line 21 to 30. the reason is that javascript posts the form with a limit value of 30 and values of line fields from 1 to 20 (values for lines 21 to 30 are not posted, they're not on the page!): the code evaluates values for line 21 to 30 to empty and wrongly deletes them. The correction checks that values are really posted. I guess that updating (deleting) not posted values is not desired here. --- htdocs/product/inventory/inventory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 00b2a544d6e..f6a852b0c63 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -297,7 +297,7 @@ if (empty($reshook)) { $inventoryline->pmp_expected = price2num(GETPOST('expectedpmp_'.$lineid, 'alpha'), 'MS'); $resultupdate = $inventoryline->update($user); } - } else { + } elseif (GETPOSTISSET('id_' . $lineid)) { // Delete record $result = $inventoryline->fetch($lineid); if ($result > 0) { From dc7dd85fadbdfac5e87dfac7d435f93573cc9895 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 8 May 2023 21:50:44 +0200 Subject: [PATCH 038/203] #24690 Product list - Search on accountancy account product --- htdocs/product/list.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 1cb3385b2ed..5e2c76987b3 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -11,7 +11,7 @@ * Copyright (C) 2013 Adolfo segura * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2020-2021 Open-DSI + * Copyright (C) 2020-2023 Alexandre Spangaro * * 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 @@ -44,6 +44,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; +if (isModEnabled('accounting')) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +} if (isModEnabled('categorie')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; @@ -569,22 +572,22 @@ if ($search_finished >= 0 && $search_finished !== '') { $sql .= " AND p.finished = ".((int) $search_finished); } if ($search_accountancy_code_sell) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell', $search_accountancy_code_sell); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell', clean_account($search_accountancy_code_sell)); } if ($search_accountancy_code_sell_intra) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_intra', clean_account($search_accountancy_code_sell_intra)); } if ($search_accountancy_code_sell_export) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_export', $search_accountancy_code_sell_export); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_sell_export', clean_account($search_accountancy_code_sell_export)); } if ($search_accountancy_code_buy) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy', $search_accountancy_code_buy); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy', clean_account($search_accountancy_code_buy)); } if ($search_accountancy_code_buy_intra) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_intra', clean_account($search_accountancy_code_buy_intra)); } if ($search_accountancy_code_buy_export) { - $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', $search_accountancy_code_buy_export); + $sql .= natural_search($alias_product_perentity . '.accountancy_code_buy_export', clean_account($search_accountancy_code_buy_export)); } if (!empty($conf->global->PRODUCT_USE_UNITS) && $search_units) { $sql .= natural_search('cu.rowid', $search_units); @@ -1964,38 +1967,38 @@ while ($i < $imaxinloop) { } // Accountancy code sell if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { - print '
    '.$product_static->accountancy_code_sell.''.length_accountg($product_static->accountancy_code_sell).''.$product_static->accountancy_code_sell_intra.''.length_accountg($product_static->accountancy_code_sell_intra).''.$product_static->accountancy_code_sell_export.''.length_accountg($product_static->accountancy_code_sell_export).''.$product_static->accountancy_code_buy.''.length_accountg($product_static->accountancy_code_buy).''.$product_static->accountancy_code_buy_intra.''.length_accountg($product_static->accountancy_code_buy_intra).''.$product_static->accountancy_code_buy_export.''.length_accountg($product_static->accountancy_code_buy_export).'
    '; + + // Linked documents + if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { + print ''; + print '\n"; + print ''; + } + if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { + print ''; + print '\n"; + print ''; + } + + // Date creation + print ''; + print '\n"; + print ''; + + // Delivery date planned + print ''; + print '
    '; + print $langs->trans("RefOrder").''; + print $objectsrc->getNomUrl(1, 'commande'); + print "
    '; + print $langs->trans("RefProposal").''; + print $objectsrc->getNomUrl(1, 'expedition'); + print "
    '.$langs->trans("DateCreation").''.dol_print_date($object->date_creation, "dayhour", "tzuserrel")."
    '; + print ''; + + if ($action != 'editdate_livraison') { + print ''; + } + print '
    '; + print $langs->trans('DateDeliveryPlanned'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
    '; + print '
    '; + if ($action == 'editdate_livraison') { + print ''; + print ''; + print ''; + print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); + print ''; + print ''; + } else { + print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; + } + print '
    '; + + print '
    '; + print ''.img_picto("", 'eraser', 'class="pictofixedwidth"').$langs->trans("ResetQtyToDispatch").''; + print ''.img_picto("", 'eraser', 'class="pictofixedwidth"').$langs->trans("Reset").''; + print '
    '; + + print '
    '; + $disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0. + + if ($object->statut == Reception::STATUS_DRAFT) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $formproduct->loadWarehouses(); + $entrepot = new Entrepot($db); + $listwarehouses = $entrepot->list_array(1); + + + print '
    '; + + + print ''; + print ''; + print ''; + + + print '
    '; + print ''; + + // Set $products_dispatched with qty dispatched for each product id + $products_dispatched = array(); + $sql = "SELECT ed.fk_origin_line as rowid, sum(ed.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= " WHERE ed.fk_expedition = ".((int) $object->id); + $sql .= " GROUP BY ed.fk_origin_line"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + if ($num) { + while ($i < $num) { + $objd = $db->fetch_object($resql); + $products_dispatched[$objd->rowid] = price2num($objd->qty, 5); + $i++; + } + } + $db->free($resql); + } + //$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,"; + $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref_ext AS sref, l.qty as qty,"; + $sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse"; + // Enable hooks to alter the SQL query (SELECT) + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListSelect', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + $sql .= $hookmanager->resPrint; + + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as l"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid"; + $sql .= " WHERE l.fk_commande = ".((int) $objectsrc->id); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $sql .= " AND l.product_type = 0"; + } + + // Enable hooks to alter the SQL query (WHERE) + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListWhere', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + $sql .= $hookmanager->resPrint; + + //$sql .= " GROUP BY p.ref, p.label, p.tobatch, p.fk_default_warehouse, l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product + $sql .= " ORDER BY l.rang, p.ref, p.label"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $numline = 1; + + if ($num) { + print ''; + + print ''; + if (isModEnabled('productbatch')) { + print ''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + } else { + print ''; + print ''; + print ''; + } + print ''; + print ''; + print ' '; + + if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) { + print ''; + print ''; + print ''; + } + } + + print ''; + + // Enable hooks to append additional columns + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListTitle', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; + + print "\n"; + } + + $nbfreeproduct = 0; // Nb of lins of free products/services + $nbproduct = 0; // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default) + // or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on. + + $conf->cache['product'] = array(); + + while ($i < $num) { + $objp = $db->fetch_object($resql); + + // On n'affiche pas les produits libres + if (!$objp->fk_product > 0) { + $nbfreeproduct++; + } else { + $alreadydispatched = isset($products_dispatched[$objp->rowid])?$products_dispatched[$objp->rowid]:0; + $remaintodispatch = price2num($objp->qty, 5); // Calculation of dispatched + if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) { + $remaintodispatch = 0; + } + + if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) { + $nbproduct++; + + // To show detail cref and description value, we must make calculation by cref + // print ($objp->cref?' ('.$objp->cref.')':''); + // if ($objp->description) print '
    '.nl2br($objp->description); + $suffix = '_0_'.$i; + + print "\n"; + print ''."\n"; + // hidden fields for js function + print ''; + print ''; + print ''; + + if (empty($conf->cache['product'][$objp->fk_product])) { + $tmpproduct = new Product($db); + $tmpproduct->fetch($objp->fk_product); + $conf->cache['product'][$objp->fk_product] = $tmpproduct; + } else { + $tmpproduct = $conf->cache['product'][$objp->fk_product]; + } + + $linktoprod = $tmpproduct->getNomUrl(1); + $linktoprod .= ' - '.$objp->label."\n"; + + if (isModEnabled('productbatch')) { + if ($objp->tobatch) { + // Product + print '"; + print ''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + } else { + // Product + print '"; + print ''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + } + } else { + print '"; + } + // Define unit price for PMP calculation + $up_ht_disc = $objp->subprice; + if (!empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { + $up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU'); + } + + // Qty ordered + print ''; + + // Already dispatched + print ''; + + print ''; // Qty to dispatch + print ''; // Dispatch column + print ''; // Warehouse column + + /*$sql = "SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; + $sql .= " WHERE cfd.fk_commandefourndet = ".(int) $objp->rowid;*/ + + $sql = "SELECT ed.rowid, ed.qty, ed.fk_entrepot, eb.batch, eb.eatby, eb.sellby, cd.fk_product FROM llx_expeditiondet as ed"; + $sql .= " LEFT JOIN llx_expeditiondet_batch as eb on ed.rowid = eb.fk_expeditiondet"; + $sql .= " JOIN llx_commandedet as cd on ed.fk_origin_line = cd.rowid"; + $sql .= " WHERE ed.fk_origin_line =".(int) $objp->rowid; + $sql .= " AND ed.fk_expedition =".(int) $object->id; + $sql .= " ORDER BY ed.rowid, ed.fk_origin_line"; + + $resultsql = $db->query($sql); + $j = 0; + if ($resultsql) { + $numd = $db->num_rows($resultsql); + + while ($j < $numd) { + $suffix = "_".$j."_".$i; + $objd = $db->fetch_object($resultsql); + if (isModEnabled('productbatch') && !empty($objd->batch)) { + $type = 'batch'; + + // Enable hooks to append additional columns + $parameters = array( + // allows hook to distinguish between the rows with information and the rows with dispatch form input + 'is_information_row' => true, + 'j' => $j, + 'suffix' => $suffix, + 'objd' => $objd, + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; + + print ''; + + print ''; + print ''; + print ''; + + print ''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + print ''; // Supplier ref + Qty ordered + qty already dispatched + } else { + $type = 'dispatch'; + $colspan = 6; + $colspan = (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) ? --$colspan : $colspan; + $colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan; + + // Enable hooks to append additional columns + $parameters = array( + // allows hook to distinguish between the rows with information and the rows with dispatch form input + 'is_information_row' => true, + 'j' => $j, + 'suffix' => $suffix, + 'objd' => $objd, + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; + + print ''; + + print ''; + print ''; + print ''; + } + // Qty to dispatch + print ''; + print ''; + + // Warehouse + print '\n"; + + // Enable hooks to append additional columns + $parameters = array( + 'is_information_row' => false, // this is a dispatch form row + 'i' => $i, + 'suffix' => $suffix, + 'objp' => $objp, + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; + + print "\n"; + $j++; + + $numline++; + } + $suffix = "_".$j."_".$i; + } + if ($j == 0) { + if (isModEnabled('productbatch') && !empty($objp->tobatch)) { + $type = 'batch'; + + // Enable hooks to append additional columns + $parameters = array( + // allows hook to distinguish between the rows with information and the rows with dispatch form input + 'is_information_row' => true, + 'j' => $j, + 'suffix' => $suffix, + 'objp' => $objp, + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; + + print ''; + + print ''; + print ''; + print ''; + + print ''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + print ''; // Supplier ref + Qty ordered + qty already dispatched + } else { + $type = 'dispatch'; + $colspan = 6; + $colspan = (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) ? --$colspan : $colspan; + $colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan; + + // Enable hooks to append additional columns + $parameters = array( + // allows hook to distinguish between the rows with information and the rows with dispatch form input + 'is_information_row' => true, + 'j' => $j, + 'suffix' => $suffix, + 'objp' => $objp, + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; + + print ''; + + print ''; + print ''; + print ''; + } + // Qty to dispatch + print ''; + print ''; + // Warehouse + print '\n"; + + // Enable hooks to append additional columns + $parameters = array( + 'is_information_row' => false, // this is a dispatch form row + 'i' => $i, + 'suffix' => $suffix, + 'objp' => $objp, + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + print $hookmanager->resPrint; + print "\n"; + } + } + } + $i++; + } + $db->free($resql); + } else { + dol_print_error($db); + } + + print "
    '.$langs->trans("Description").''.$langs->trans("batch_number").''.$langs->trans("SellByDate").''.$langs->trans("EatByDate").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyDispatchedShort").''.$langs->trans("QtyToDispatchShort"); + print ''.$langs->trans("Price").''.$langs->trans("ReductionShort").' (%)'.$langs->trans("UpdatePrice").''.$langs->trans("Warehouse"); + + // Select warehouse to force it everywhere + if (count($listwarehouses) > 1) { + print '
    '.$langs->trans("ForceTo").' '.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, $disabled, '', 'minwidth100 maxwidth300', 1); + } elseif (count($listwarehouses) == 1) { + print '
    '.$langs->trans("ForceTo").' '.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled, '', 'minwidth100 maxwidth300', 1); + } + + print '
    '; + print $linktoprod; + print "'; + print $linktoprod; + print "'; + print $langs->trans("ProductDoesNotUseBatchSerial"); + print ''; + print $linktoprod; + print "'.$objp->qty.''.$alreadydispatched.''; + print ''; + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $dlcdatesuffix = !empty($objd->sellby) ? dol_stringtotime($objd->sellby) : dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year')); + print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, ''); + print ''; + $dluodatesuffix = !empty($objd->eatby) ? dol_stringtotime($objd->eatby) : dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year')); + print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, ''); + print ' 
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; + print ''; + print ''; + if (isModEnabled('productbatch') && $objp->tobatch > 0) { + $type = 'batch'; + print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" '.($numd != $j+1 ? 'style="display:none"' : '').' onClick="addDispatchLine('.$i.', \''.$type.'\')"'); + } else { + $type = 'dispatch'; + print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" '.($numd != $j+1 ? 'style="display:none"' : '').' onClick="addDispatchLine('.$i.', \''.$type.'\')"'); + } + + print ''; + if (count($listwarehouses) > 1) { + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ?GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + } elseif (count($listwarehouses) == 1) { + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ?GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + } else { + $langs->load("errors"); + print $langs->trans("ErrorNoWarehouseDefined"); + } + print "
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year')); + print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, ''); + print ''; + $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year')); + print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, ''); + print ' 
    '; + print ''; + print ''; + print ''; + print ''; + print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; + print ''; + print ''; + if (isModEnabled('productbatch') && $objp->tobatch > 0) { + $type = 'batch'; + print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"'); + } else { + $type = 'dispatch'; + print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"'); + } + + print ''; + if (count($listwarehouses) > 1) { + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ?GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + } elseif (count($listwarehouses) == 1) { + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ?GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + } else { + $langs->load("errors"); + print $langs->trans("ErrorNoWarehouseDefined"); + } + print "
    \n"; + print '
    '; + + if ($nbproduct) { + $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); + + print '
    '; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { + if (empty($conf->reception->enabled)) { + print $langs->trans("Comment").' : '; + print 'trans("DispatchSupplierOrder", $object->ref); + // print ' / '.$object->ref_supplier; // Not yet available + print '" class="flat">
    '; + + print ' '.$checkboxlabel; + } + + $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception"); + + print '
    '; + print ''; + } + print '
    '; + } + + // Message if nothing to dispatch + if (!$nbproduct) { + print "
    \n"; + if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) { + print '
    '.$langs->trans("NoPredefinedProductToDispatch").'
    '; // No predefined line at all + } else { + print '
    '.$langs->trans("NoMorePredefinedProductToDispatch").'
    '; // No predefined line that remain to be dispatched. + } + } + + print '
    '; + } + + print dol_get_fiche_end(); + + // traitement entrepot par défaut + print ''; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/expedition/js/lib_dispatch.js.php b/htdocs/expedition/js/lib_dispatch.js.php new file mode 100644 index 00000000000..d7c8bf2d74b --- /dev/null +++ b/htdocs/expedition/js/lib_dispatch.js.php @@ -0,0 +1,222 @@ + +// Copyright (C) 2017 Francis Appels +// +// 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 +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// or see https://www.gnu.org/ + +/** + * \file htdocs/fourn/js/lib_dispatch.js.php + * \brief File that include javascript functions used for dispatching qty/stock/lot + */ + +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', 1); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} + +session_cache_limiter('public'); + +require_once '../../main.inc.php'; + +// Define javascript type +top_httphead('text/javascript; charset=UTF-8'); +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} + +?> +/** + * addDispatchLine + * Adds new table row for dispatching to multiple stock locations or multiple lot/serial + * + * @param index int index of product line. 0 = first product line + * @param type string type of dispatch ('batch' = batch dispatch, 'dispatch' = non batch dispatch) + * @param mode string 'qtymissing' will create new line with qty missing, 'lessone' will keep 1 in old line and the rest in new one + */ +function addDispatchLine(index, type, mode) { + mode = mode || 'qtymissing' + + console.log("fourn/js/lib_dispatch.js.php addDispatchLine Split line type="+type+" index="+index+" mode="+mode); + + var $row0 = $("tr[name='"+type+'_0_'+index+"']"); + var $dpopt = $row0.find('.hasDatepicker').first().datepicker('option', 'all'); // get current datepicker options to apply the same to the cloned datepickers + var $row = $row0.clone(true); // clone first batch line to jQuery object + var nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length; // count nb of tr line with attribute name that starts with 'batch_' or 'dispatch_', and end with _index + var qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // Qty ordered is same for all rows + + var qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()); + if (isNaN(qty)) { + qty = ''; + } + + console.log("fourn/js/lib_dispatch.js.php addDispatchLine Split line nbrTrs="+nbrTrs+" qtyOrdered="+qtyOrdered+" qty="+qty); + + var qtyDispatched; + + if (mode === 'lessone') { + qtyDispatched = parseFloat($("#qty_dispatched_0_" + index).val()) + 1; + } + else { + qtyDispatched = parseFloat($("#qty_dispatched_0_" + index).val()) + qty; + // If user did not reduced the qty to dispatch on old line, we keep only 1 on old line and the rest on new line + if (qtyDispatched == qtyOrdered && qtyDispatched > 1) { + qtyDispatched = parseFloat($("#qty_dispatched_0_" + index).val()) + 1; + mode = 'lessone'; + } + } + console.log("qtyDispatched=" + qtyDispatched + " qtyOrdered=" + qtyOrdered+ " qty=" + qty); + + if (qtyOrdered - qtyDispatched < 1) { + window.alert("Remain quantity to dispatch is too low to be split"); + } else { + oldlineqty = qtyDispatched; + newlineqty = qtyOrdered - qtyDispatched; + if (newlineqty <= 0) { + newlineqty = qty - 1; + oldlineqty = 1; + $("#qty_"+(nbrTrs - 1)+"_"+index).val(oldlineqty); + } + + //replace tr suffix nbr + $row.html($row.html().replace(/_0_/g, "_" + nbrTrs + "_")); + + // jquery's deep clone is incompatible with date pickers (the clone shares data with the original) + // so we destroy and rebuild the new date pickers + setTimeout(() => { + $row.find('.hasDatepicker').each((i, dp) => { + $(dp).removeData() + .removeClass('hasDatepicker'); + $(dp).next('img.ui-datepicker-trigger').remove(); + $(dp).datepicker($dpopt); + }); + }, 0); + + //create new select2 to avoid duplicate id of cloned one + $row.find("select[name='" + 'entrepot_' + nbrTrs + '_' + index + "']").select2(); + // TODO find solution to copy selected option to new select + // TODO find solution to keep new tr's after page refresh + //clear value + $row.find("input[name^='qty']").val(''); + //change name of new row + $row.attr('name', type + '_' + nbrTrs + '_' + index); + //insert new row before last row + $("tr[name^='" + type + "_'][name$='_" + index + "']:last").after($row); + + //remove cloned select2 with duplicate id. + $("#s2id_entrepot_" + nbrTrs + '_' + index).detach(); // old way to find duplicated select2 component + $(".csswarehouse_" + nbrTrs + "_" + index + ":first-child").parent("span.selection").parent(".select2").detach(); + + /* Suffix of lines are: _ trs.length _ index */ + $("#qty_"+nbrTrs+"_"+index).focus(); + $("#qty_dispatched_0_"+index).val(oldlineqty); + + //hide all buttons then show only the last one + $("tr[name^='" + type + "_'][name$='_" + index + "'] .splitbutton").hide(); + $("tr[name^='" + type + "_'][name$='_" + index + "']:last .splitbutton").show(); + + $("#reset_" + (nbrTrs) + "_" + index).click(function () { + id = $(this).attr("id"); + id = id.split("reset_"); + idrow = id[1]; + idlast = $("tr[name^='" + type + "_'][name$='_" + index + "']:last .qtydispatchinput").attr("id"); + if (idlast == $("#qty_" + idrow).attr("id")) { + console.log("Remove trigger for tr name = " + type + "_" + idrow); + $('tr[name="' + type + '_' + idrow + '"').remove(); + $("tr[name^='" + type + "_'][name$='_" + index + "']:last .splitbutton").show(); + } else { + console.log("Reset trigger for id = #qty_" + idrow); + $("#qty_" + idrow).val(""); + } + }); + + if (mode === 'lessone') + { + qty = 1; // keep 1 in old line + $("#qty_"+(nbrTrs-1)+"_"+index).val(qty); + } + $("#qty_"+nbrTrs+"_"+index).val(newlineqty); + // Store arbitrary data for dispatch qty input field change event + $("#qty_" + (nbrTrs - 1) + "_" + index).data('qty', qty); + $("#qty_" + (nbrTrs - 1) + "_" + index).data('type', type); + $("#qty_" + (nbrTrs - 1) + "_" + index).data('index', index); + // Update dispatched qty when value dispatch qty input field changed + //$("#qty_" + (nbrTrs - 1) + "_" + index).change(this.onChangeDispatchLineQty); + //set focus on lot of new line (if it exists) + $("#lot_number_" + (nbrTrs) + "_" + index).focus(); + //Clean bad values + $("tr[name^='" + type + "_'][name$='_" + index + "']:last").data("remove", "remove"); + $("#lot_number_" + (nbrTrs) + "_" + index).val("") + $("#idline_" + (nbrTrs) + "_" + index).val("-1") + $("#qty_" + (nbrTrs) + "_" + index).data('expected', "0"); + $("input[type='hidden']#lot_number_" + (nbrTrs) + "_" + index).remove(); + $("#lot_number_" + (nbrTrs) + "_" + index).removeAttr("disabled"); + } +} + +/** + * onChangeDispatchLineQty + * + * Change event handler for dispatch qty input field, + * recalculate qty dispatched when qty input has changed. + * If qty is more than qty ordered reset input qty to max qty to dispatch. + * + * element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line) + */ +function onChangeDispatchLineQty(element) { + var type = $(element).data('type'), + qty = parseFloat($(element).data('expected')), + changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched; + id = $(element).attr("id"); + id = id.split("_"); + index = id[2]; + + if (index >= 0 && type && qty >= 0) { + nbrTrs = $("tr[name^='" + type + "_'][name$='_" + index + "']").length; + qtyChanged = parseFloat($(element).val()) - qty; // qty changed + qtyDispatching = parseFloat($(element).val()); // qty currently being dispatched + qtyOrdered = parseFloat($("#qty_ordered_0_" + index).val()); // qty ordered + qtyDispatched = parseFloat($("#qty_dispatched_0_" + index).val()); // qty already dispatched + + console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: " + qtyDispatched); + + if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) { + $("#qty_dispatched_0_" + index).val(qtyDispatched + qtyChanged); + } else { + /*console.log("eee"); + $(element).val($(element).data('expected'));*/ + } + $(element).data('expected', $(element).val()); + } +} diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 7850d7a3fd6..3ab1d897580 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -74,3 +74,6 @@ SumOfProductWeights=Sum of product weights # warehouse details DetailWarehouseNumber= Warehouse details DetailWarehouseFormat= W:%s (Qty: %d) + +# Other +DispatchCard = Dispatch card \ No newline at end of file From fbda1c87cde2be15cf279c3b4aa243d070007e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Fali=C3=A8re?= Date: Tue, 9 May 2023 14:38:20 +0200 Subject: [PATCH 041/203] FIX token errors on public interface --- htdocs/public/ticket/index.php | 2 +- htdocs/public/ticket/list.php | 5 +++-- htdocs/public/ticket/view.php | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index e4e46938122..692656f8ad1 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -86,7 +86,7 @@ print '

    '.(getDolGlobalString("TICKET_PUBLIC_TEXT_H print '
    '; print '

    '; -print '

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

    '.dol_escape_htmltag($langs->trans("CreateTicket")).'
    '; print '

    '.dol_escape_htmltag($langs->trans("ViewMyTicketList")).'
    '; print '
    '.img_picto('', 'ticket', 'class="fa-15"').'
    '.dol_escape_htmltag($langs->trans("ShowTicketWithTrackId")).'
    '; print '
    '; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 9ac4b25cb04..f03d9aaea76 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -195,7 +195,6 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); if ($action == "view_ticketlist") { - print '
    '; print '
    '; print '
    '; @@ -236,6 +235,8 @@ if ($action == "view_ticketlist") { $param .= '&entity='.((int) $entity); } + $param .= '&token='.newToken(); + // Definition of fields for list $arrayfields = array( 't.datec' => array('label' => $langs->trans("Date"), 'checked' => 1), @@ -415,6 +416,7 @@ if ($action == "view_ticketlist") { // Search bar print '
    '."\n"; print ''; + print ''; print ''; print ''; print ''; @@ -724,7 +726,6 @@ if ($action == "view_ticketlist") { } print '
    '; - print '
    '; } else { print '
    '; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 9f2eee2a6ea..04ffd53f2f3 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -171,7 +171,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a if ($object->dao->close($user)) { setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); - $url = 'view.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha').(!empty($entity) && isModEnabled('multicompany')?'&entity='.$entity:''); + $url = 'view.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha').(!empty($entity) && isModEnabled('multicompany')?'&entity='.$entity:'').'&token='.newToken(); header("Location: ".$url); exit; } else { @@ -372,11 +372,11 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a if ($object->dao->fk_statut < Ticket::STATUS_CLOSED) { // New message - print ''; + print ''; // Close ticket if ($object->dao->fk_statut >= Ticket::STATUS_NOT_READ && $object->dao->fk_statut < Ticket::STATUS_CLOSED) { - print ''; + print ''; } } From 2b2b722eada028747f4f405a7599a14c4bb10b5b Mon Sep 17 00:00:00 2001 From: hystepik Date: Tue, 9 May 2023 15:37:49 +0200 Subject: [PATCH 042/203] add verification on batchcode --- htdocs/expedition/dispatch.php | 29 ++++++++++++++++++++++++++--- htdocs/langs/en_US/sendings.lang | 5 ++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index be586906c3f..374980377ae 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -164,6 +164,29 @@ if ($action == 'updatelines' && $usercancreate) { setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors'); $error++; } + if ($modebatch == "batch") { + $sql = "SELECT pb.rowid "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; + $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " ON ps.rowid = pb.fk_product_stock"; + $sql .= " WHERE pb.batch ='".$db->escape($lot)."'"; + $sql .= " AND ps.fk_product =".((int) GETPOST($prod, 'int')) ; + $sql .= " AND ps.fk_entrepot =".((int) GETPOST($ent, 'int')) ; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + if ($num > 1) { + dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').'); + setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors'); + $error++; + } elseif ($num < 1) { + dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.'); + setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors'); + $error++; + } + $db->free($resql); + } + } if (!$error) { $qtystart = 0; @@ -686,9 +709,9 @@ if ($id > 0 || !empty($ref)) { $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; $sql .= " WHERE cfd.fk_commandefourndet = ".(int) $objp->rowid;*/ - $sql = "SELECT ed.rowid, ed.qty, ed.fk_entrepot, eb.batch, eb.eatby, eb.sellby, cd.fk_product FROM llx_expeditiondet as ed"; - $sql .= " LEFT JOIN llx_expeditiondet_batch as eb on ed.rowid = eb.fk_expeditiondet"; - $sql .= " JOIN llx_commandedet as cd on ed.fk_origin_line = cd.rowid"; + $sql = "SELECT ed.rowid, ed.qty, ed.fk_entrepot, eb.batch, eb.eatby, eb.sellby, cd.fk_product FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as eb on ed.rowid = eb.fk_expeditiondet"; + $sql .= " JOIN ".MAIN_DB_PREFIX."commandedet as cd on ed.fk_origin_line = cd.rowid"; $sql .= " WHERE ed.fk_origin_line =".(int) $objp->rowid; $sql .= " AND ed.fk_expedition =".(int) $object->id; $sql .= " ORDER BY ed.rowid, ed.fk_origin_line"; diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 3ab1d897580..dbbb4926ec0 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -76,4 +76,7 @@ DetailWarehouseNumber= Warehouse details DetailWarehouseFormat= W:%s (Qty: %d) # Other -DispatchCard = Dispatch card \ No newline at end of file +DispatchCard = Dispatch card + +ErrorTooManyCombinationBatchcode=No dispatch for line %s as too many combination warehouse, product, batch code was found (%s). +ErrorNoCombinationBatchcode=No dispatch for line %s as no combination warehouse, product, batch code was found. \ No newline at end of file From 7c996e97fdb20194c41c0e78d8449510f9a698c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Fali=C3=A8re?= Date: Tue, 9 May 2023 15:45:52 +0200 Subject: [PATCH 043/203] FIX broken feature : send private message by email --- htdocs/core/class/html.formticket.class.php | 73 +++++++++++---------- htdocs/theme/eldy/timeline.inc.php | 3 +- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 08ccfc10190..cb5a1aacc0f 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1345,44 +1345,51 @@ class FormTicket $send_email = GETPOST('send_email', 'int') ? GETPOST('send_email', 'int') : 0; - // Example 1 : Adding jquery code - print ''; + }'; + + // If constant set, allow to send private messages as email + if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) { + print 'jQuery("#send_msg_email").click(function() { + if(jQuery(this).is(":checked")) { + if (jQuery("#private_message").is(":checked")) { + jQuery("#private_message").prop("checked", false).trigger("change"); + } + jQuery(".email_line").show(); + } + else { + jQuery(".email_line").hide(); + } + }); + + jQuery("#private_message").click(function() { + if (jQuery(this).is(":checked")) { + if (jQuery("#send_msg_email").is(":checked")) { + jQuery("#send_msg_email").prop("checked", false).trigger("change"); + } + jQuery(".email_line").hide(); + } + });'; + } + + print '}); + '; + + print ''; print ''; diff --git a/htdocs/theme/eldy/timeline.inc.php b/htdocs/theme/eldy/timeline.inc.php index 84d486817b1..a4fa4ee29b3 100644 --- a/htdocs/theme/eldy/timeline.inc.php +++ b/htdocs/theme/eldy/timeline.inc.php @@ -62,7 +62,8 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { position: relative; } -.timeline > li.timeline-code-ticket_msg_private > .timeline-item { +.timeline > li.timeline-code-ticket_msg_private > .timeline-item, +.timeline > li.timeline-code-ticket_msg_private_sentbymail > .timeline-item { background: #fffbe5; border-color: #d0cfc0; } From 44856cc6ea6f43aa3ef03b0cbd4d63f512753dd7 Mon Sep 17 00:00:00 2001 From: hystepik Date: Tue, 9 May 2023 16:05:15 +0200 Subject: [PATCH 044/203] Fix Ci --- htdocs/expedition/dispatch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 374980377ae..9b08075da17 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -208,8 +208,8 @@ if ($action == 'updatelines' && $usercancreate) { if (!$error && $modebatch == "batch") { $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET"; - $sql .= " eatby = ".($eatby ? "'".$this->db->idate($eatby)."'" : "null"); - $sql .= " , sellby = ".($sellby ? "'".$this->db->idate($sellby)."'" : "null"); + $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null"); + $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null"); $sql .= " , qty = ".((float) price2num(GETPOST($qty, 'int'), 'MS')); $sql .= " WHERE fk_expeditiondet = ".((int) $idline); $sql .= " AND batch = ".((int) $idline); From 7ae43d7872ce7143e2c51b235fcccfc7ffd1900d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 9 May 2023 14:18:54 +0000 Subject: [PATCH 045/203] Fixing style errors. --- htdocs/core/class/html.formticket.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index cb5a1aacc0f..c83becab676 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1363,8 +1363,8 @@ class FormTicket }'; // If constant set, allow to send private messages as email - if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) { - print 'jQuery("#send_msg_email").click(function() { + if (empty($conf->global->TICKET_SEND_PRIVATE_EMAIL)) { + print 'jQuery("#send_msg_email").click(function() { if(jQuery(this).is(":checked")) { if (jQuery("#private_message").is(":checked")) { jQuery("#private_message").prop("checked", false).trigger("change"); @@ -1384,12 +1384,12 @@ class FormTicket jQuery(".email_line").hide(); } });'; - } + } print '}); '; - - + + print ''; print ''; From 120d750f432eb5afd190d5a5e8428204f66e64ef Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 9 May 2023 16:44:26 +0200 Subject: [PATCH 046/203] FIX missing constant and avoid submit button conflict --- htdocs/core/class/html.formticket.class.php | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 08ccfc10190..976177aba5b 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1384,7 +1384,7 @@ class FormTicket print '}); '; - print ''; + print ''; print ''; print ''; print ''; @@ -1534,6 +1534,14 @@ class FormTicket $out .= ''."\n"; $out .= ''; + } + print "\n"; } } From e74945e9cf62d231d7c939e74a76e721a8982cb9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 9 May 2023 16:54:39 +0200 Subject: [PATCH 047/203] FIX missing checking if file is uploaded --- htdocs/core/class/html.formticket.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 976177aba5b..fe4a04c517b 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1635,8 +1635,13 @@ class FormTicket print ''; print '

    '; - print ''; - if ($this->withcancel) { + print 'withfile == 2 && !empty($conf->use_javascript_ajax)) { + print ' onClick="if (document.ticket.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + } + print ' />'; + if (!empty($this->withcancel)) { print "     "; print ''; } From bfe7cd76c273efaa5d3320fa306ae72b0c4b1784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Tue, 9 May 2023 17:12:09 +0200 Subject: [PATCH 048/203] FIX: No error message because $price_ht_devise is equal to 0 if not fill because of price2num --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 8d100370a00..072e1bfdf5b 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -586,7 +586,7 @@ if (empty($reshook)) { $error++; } - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && GETPOST('multicurrency_price_ht') === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPrice")), null, 'errors'); $error++; } From d8dd1ebd19721f38e9d129cfdb14d3685e511542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Tue, 9 May 2023 17:43:31 +0200 Subject: [PATCH 049/203] FIX: Authorize '0' subprice --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 3155ab3ae0a..88ba4a07022 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -3048,7 +3048,7 @@ class SupplierProposalLine extends CommonObjectLine $sql .= " ".price2num($this->localtax2_tx).","; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= " ".(!empty($this->subprice) ? price2num($this->subprice, 'MU') : "null").","; + $sql .= " ".price2num($this->subprice, 'MU') .","; $sql .= " ".((float) $this->remise_percent).","; $sql .= " ".(isset($this->info_bits) ? ((int) $this->info_bits) : "null").","; $sql .= " ".price2num($this->total_ht, 'MT').","; From 05bbdc435bbefacfed9c3f075ccb6ca69e38b7e4 Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 9 May 2023 18:37:37 +0200 Subject: [PATCH 050/203] fix add security check and fix the function call in societe/list --- htdocs/core/ajax/ajaxstatusprospect.php | 28 +++++++++++++++---------- htdocs/societe/list.php | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/htdocs/core/ajax/ajaxstatusprospect.php b/htdocs/core/ajax/ajaxstatusprospect.php index 481d8a9a1d9..e5719b98d8b 100644 --- a/htdocs/core/ajax/ajaxstatusprospect.php +++ b/htdocs/core/ajax/ajaxstatusprospect.php @@ -23,21 +23,30 @@ * \brief File to return Ajax response on third parties request */ -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); // Disables token renewal -} +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -// If there is no need to load and show top and left menu -if (!defined("NOLOGIN")) { - define("NOLOGIN", '1'); -} // Load Dolibarr environment require '../../main.inc.php'; +$idstatus = GETPOST('id', 'int'); +$idprospect = GETPOST('prospectid', 'int'); +$action = GETPOST('action', 'aZ09'); + +// Security check +if ($user->socid > 0) { + if ($idprospect != $user->socid) { + accessforbidden('Not allowed on this thirdparty'); + } +} + +// var_dump( $user, 'societe', $idprospect, '&societe'); +$result = restrictedArea($user, 'societe', $idprospect, '&societe'); + +$permisstiontoupdate = $user->hasRight('societe', 'creer'); /* * View @@ -45,11 +54,8 @@ require '../../main.inc.php'; top_httphead(); -$idstatus = GETPOST('id', 'int'); -$idprospect = GETPOST('prospectid', 'int'); -$action = GETPOST('action', 'aZ09'); -if ($action === "updatestatusprospect") { +if ($action === "updatestatusprospect" && $permisstiontoupdate) { $response = ''; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 86c4e5cc508..595e1b67f7b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1912,7 +1912,7 @@ while ($i < $imaxinloop) { } // Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script -$formcompany->select_status('status_prospect', null, null, null, "js"); +$formcompany->selectStatus('status_prospect', null, null, null, "js"); // If no record found if ($num == 0) { From 396abfe8820f8a024c3f605664720c74c84727cf Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 10 May 2023 09:27:49 +0200 Subject: [PATCH 051/203] update ticket ref when the ref is already used at the creation --- htdocs/langs/en_US/ticket.lang | 1 + htdocs/ticket/card.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index b75da799cb2..4ce8d347730 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -274,6 +274,7 @@ TicketsDelayForFirstResponseTooLong=Too much time elapsed since ticket opening w TicketsDelayFromLastResponseTooLong=Too much time elapsed since last answer on this ticket. TicketNoContractFoundToLink=No contract was found to be automatically linked to this ticket. Please link a contract manually. TicketManyContractsLinked=Many contracts have been automatically linked to this ticket. Make sure to verify which should be chosen. +TicketRefAlreadyUsed=The reference [%s] is already used, your new reference is [%s] # # Logs diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 76d266eb760..1b8e15adc98 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -207,7 +207,16 @@ if (empty($reshook)) { if (!$error) { $db->begin(); - $object->ref = GETPOST("ref", 'alphanohtml'); + $getRef = GETPOST("ref", 'alphanohtml'); + if ($object->fetch('', $getRef) > 0) { + $object->ref = $object->getDefaultRef(); + $object->track_id = null; + setEventMessage($langs->trans('TicketRefAlreadyUsed', $getRef, $object->ref)); + } + else { + $object->ref = $getRef; + } + $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0; $object->subject = GETPOST("subject", 'alphanohtml'); $object->message = GETPOST("message", 'restricthtml'); From 7f71fb003833a5d820a91b8e39fa971fb2f5a92e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 10 May 2023 07:36:39 +0000 Subject: [PATCH 052/203] Fixing style errors. --- htdocs/ticket/card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 1b8e15adc98..f1f35f2c73f 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -212,11 +212,10 @@ if (empty($reshook)) { $object->ref = $object->getDefaultRef(); $object->track_id = null; setEventMessage($langs->trans('TicketRefAlreadyUsed', $getRef, $object->ref)); - } - else { + } else { $object->ref = $getRef; } - + $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0; $object->subject = GETPOST("subject", 'alphanohtml'); $object->message = GETPOST("message", 'restricthtml'); From 9a19bd000a5f8cab9289b1a301a2de41330e60f8 Mon Sep 17 00:00:00 2001 From: Romain Neil Date: Wed, 10 May 2023 12:23:32 +0200 Subject: [PATCH 053/203] doc(api/documents): add list of supported modules --- htdocs/api/class/api_documents.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 63481f777b1..1d19f68132e 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -121,6 +121,8 @@ class Documents extends DolibarrApi * * Test sample 1: { "modulepart": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }. * + * Supported modules: invoice, order, proposal, contract + * * @param string $modulepart Name of module or area concerned by file download ('thirdparty', 'member', 'proposal', 'supplier_proposal', 'order', 'supplier_order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...) * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf). * @param string $doctemplate Set here the doc template to use for document generation (If not set, use the default template). @@ -256,6 +258,8 @@ class Documents extends DolibarrApi /** * Return the list of documents of a dedicated element (from its ID or Ref) * + * Supported modules: thirdparty, user, member, proposal, order, supplier_order, shipment, invoice, supplier_invoice, product, event, expensereport, knowledgemanagement, category, contract + * * @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...) * @param int $id ID of element * @param string $ref Ref of element @@ -583,6 +587,8 @@ class Documents extends DolibarrApi * Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. * Test sample for medias file: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }. * + * Supported modules: invoice, order, supplier_order, task/project_task, product/service, expensereport, fichinter, member, propale, agenda, contact + * * @param string $filename Name of file to create ('FA1705-0123.txt') * @param string $modulepart Name of module or area concerned by file upload ('product', 'service', 'invoice', 'proposal', 'project', 'project_task', 'supplier_invoice', 'expensereport', 'member', ...) * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) From 0ca6ab84a35e30079a71c1a75c96c2cc50c239ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 May 2023 13:55:41 +0200 Subject: [PATCH 054/203] fix hidden condition --- htdocs/core/boxes/box_scheduled_jobs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 915884d6f43..f0868036e9d 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -63,7 +63,7 @@ class box_scheduled_jobs extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->hasRight('service', 'lire') && $user->hasRight('contrat', 'lire')); + $this->hidden = !($user->hasRight('cron', 'read')); } /** @@ -79,7 +79,7 @@ class box_scheduled_jobs extends ModeleBoxes $langs->load("cron"); $this->info_box_head = array('text' => $langs->trans("BoxScheduledJobs", $max)); - if ($user->rights->cron->read) { + if ($user->hasRight('cron', 'read')) { include_once DOL_DOCUMENT_ROOT . '/cron/class/cronjob.class.php'; $cronstatic = new Cronjob($this->db); $resultarray = array(); From e7e40b4c9eb4623693aa64fdca5613707b2ff4e9 Mon Sep 17 00:00:00 2001 From: Romain Neil Date: Wed, 10 May 2023 14:27:51 +0200 Subject: [PATCH 055/203] wip: api/documents: generate supplier invoices --- htdocs/api/class/api_documents.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 63481f777b1..96d66448428 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -198,6 +198,19 @@ class Documents extends DolibarrApi if ($result <= 0) { throw new RestException(500, 'Error generating document'); } + } elseif($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') { + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; + $this->supplier_invoice = new FactureFournisseur($this->db); + $result = $this->supplier_invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); + if (!$result) { + throw new RestException(404, 'Supplier invoice not found'); + } + + $templateused = $doctemplate ? $doctemplate : $this->supplier_invoice->model_pdf; + $result = $this->supplier_invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) { + throw new RestException(500, 'Error generating document'); + } } elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $this->order = new Commande($this->db); From d816ef290bc6903a0e1adbdd8dee65bbb271425b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 10 May 2023 12:30:51 +0000 Subject: [PATCH 056/203] Fixing style errors. --- htdocs/api/class/api_documents.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 96d66448428..04ad7f19760 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -198,7 +198,7 @@ class Documents extends DolibarrApi if ($result <= 0) { throw new RestException(500, 'Error generating document'); } - } elseif($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') { + } elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') { require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; $this->supplier_invoice = new FactureFournisseur($this->db); $result = $this->supplier_invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); From bc42bdef49b688d954b776cf4f4d7b1d74da53d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Thu, 11 May 2023 09:25:07 +0200 Subject: [PATCH 057/203] FIX: wrong colspan for tasks list --- htdocs/projet/tasks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 64d134a7254..53ad98eb194 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -773,7 +773,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; // Other options - $parameters = array(); + $parameters = array('arrayfields' => &$arrayfields); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -1046,7 +1046,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $j = 0; $level = 0; $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields); } else { - $colspan = 10; + $colspan = count($arrayfields); if ($object->usage_bill_time) { $colspan += 2; } From 07bec30c32b9a758ed01fd7d55ff47e4961ed504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Thu, 11 May 2023 11:10:33 +0200 Subject: [PATCH 058/203] FIX: Task events not displayed --- htdocs/projet/tasks/task.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index f163af75cae..6fb8f07d0a6 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -644,8 +644,7 @@ if ($id > 0 || !empty($ref)) { // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $defaultthirdpartyid = $socid > 0 ? $socid : $object->project->socid; - $formactions->showactions($object, 'task', $defaultthirdpartyid, 1, '', 10, 'withproject='.$withproject); + $formactions->showactions($object, 'project_task', 0, 1, '', 10, 'withproject='.$withproject); print '
    '; } From fc78b2e882a48099174ee84ef8b3e218db517de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 11 May 2023 11:22:02 +0200 Subject: [PATCH 059/203] can use isModEnabled("module") in extrafield enabled --- htdocs/core/actions_extrafields.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 83fd8d47c4f..e8c4154c85b 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -367,7 +367,7 @@ if ($action == 'update') { $computedvalue, (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), - GETPOST('enabled', 'alpha'), + GETPOST('enabled', 'restricthtml'), (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha'), array('css' => $css, 'cssview' => $cssview, 'csslist' => $csslist) From 69dcd9dfd098110414ea40dfe7b111e5705e10b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 11 May 2023 11:23:30 +0200 Subject: [PATCH 060/203] Update admin_extrafields_edit.tpl.php --- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 2e8511acf8e..e12c6c17ce6 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2023 Frédéric France * * 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 @@ -143,7 +143,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
    Contact:con - + From 4ad585facc76bc62ff2f3c841bb4bd3b914275e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Thu, 11 May 2023 11:41:58 +0200 Subject: [PATCH 061/203] FIX: Add Missing rights check on holiday calendar --- htdocs/comm/action/index.php | 132 +++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 9b451a47659..4878ecaa13c 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -582,10 +582,18 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on // Local calendar $s .= '
    '.$langs->trans("LocalAgenda").'  
    '; - // Holiday calendar - $s .= '
     
    '; + if ($user->rights->holiday->read) { + // Holiday calendar + $s .= ' +
    +   +
    '; + } - // External calendars + // External calendars if (is_array($showextcals) && count($showextcals) > 0) { $s .= '"; + } + $('#revenuestamp_val').val(revenue); + $('#revenuestamp_span').html(revenue); + } + "; } else { - print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); + print price($object->revenuestamp, 1, '', 1, -1, -1, $conf->currency); } print ''; } - // Total with tax - print ''.$langs->trans('AmountTTC').''.price($sign * $object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; - - print ''; - - $nbrows = 8; $nbcols = 3; if (isModEnabled('project')) { From 3f32f9ae558b5c60ff8b293c039061b102f55bb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 17 May 2023 20:02:12 +0200 Subject: [PATCH 170/203] Fix transfer --- htdocs/compta/bank/transfer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index ff0666e0d81..fb45c3fb449 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -228,10 +228,10 @@ print ' + '; // End of page From 5bc87a590cf318424801ba37d28f2ab2db31b39c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 May 2023 22:29:46 +0200 Subject: [PATCH 202/203] NEW Add partial payment reason "withholding tax" --- ChangeLog | 1 + htdocs/compta/facture/card.php | 8 +++++++- htdocs/compta/paiement.php | 3 ++- htdocs/compta/paiement/class/paiement.class.php | 8 ++++++-- htdocs/langs/en_US/bills.lang | 4 +++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 045ff0b61fa..6cd8025ebe9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -179,6 +179,7 @@ NEW: Widgets: Add widget "The next upcoming events" NEW: Widgets: Add widget of open opportunities NEW: Use an ajax component to swith prospection status on thidparty list NEW: Comment on survey is possible only after vote. +NEW: Add partial payment reason "withholding tax" For developers or integrators: ------------------------------ diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 77ecc4e4a05..aa0c99ec4ff 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4248,6 +4248,8 @@ if ($action == 'create') { $i++; $close[$i]['code'] = 'bankcharge'; $i++; + $close[$i]['code'] = 'withholdingtax'; + $i++; $close[$i]['code'] = 'other'; $i++; // Help @@ -4258,6 +4260,8 @@ if ($action == 'create') { $i++; $close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBankChargeDesc"); $i++; + $close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonWithholdingTaxDesc"); + $i++; $close[$i]['label'] = $langs->trans("Other"); $i++; // Texte @@ -4268,6 +4272,8 @@ if ($action == 'create') { $i++; $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBankCharge", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1); $i++; + $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonWithholdingTax"), $close[$i]['label'], 1); + $i++; $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("Other"), $close[$i]['label'], 1); $i++; // arrayreasons[code]=reason @@ -4278,7 +4284,7 @@ if ($action == 'create') { // Cree un tableau formulaire $formquestion = array('text' => $langs->trans("ConfirmClassifyPaidPartiallyQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300')); // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 1, 340, 600); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidPartially', $object->ref), 'confirm_paid_partially', $formquestion, "yes", 1, 380, 600); } // Confirmation du classement abandonne diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index bcc420ddfbc..9d1e3b39a03 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -475,6 +475,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; + print ''; print dol_get_fiche_head(); @@ -868,7 +869,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $langs->load("withdrawals"); if (!empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '
    '.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed"); }*/ - print '


    '; + print '


    '; print ''; } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index dd1c121094a..7df61ebefcb 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -266,7 +266,7 @@ class Paiement extends CommonObject $currencyofpayment = ''; $currencytxofpayment = ''; - foreach ($amounts as $key => $value) { // How payment is dispatch + foreach ($amounts as $key => $value) { // How payment is dispatched if (empty($value)) { continue; } @@ -300,6 +300,10 @@ class Paiement extends CommonObject } } + if (empty($currencyofpayment)) { // Should not happen. For the case the multicurrency_code was not saved into invoices + $currencyofpayment = $conf->currency; + } + if (!empty($currencyofpayment)) { // We must check that the currency of invoices is the same than the currency of the bank $bankaccount = new Account($this->db); @@ -358,7 +362,7 @@ class Paiement extends CommonObject if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount, multicurrency_code, multicurrency_tx)"; - $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).", ".($this->multicurrency_code ? $this->db->escape($currencyofpayment) : 'NULL').", ".(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).")"; + $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).", ".($currencyofpayment ? "'".$this->db->escape($currencyofpayment)."'" : 'NULL').", ".(!empty($this->multicurrency_tx) ? (double) $currencytxofpayment : 1).")"; dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 95877a47d4d..9c1bc1791ca 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -196,7 +196,8 @@ ConfirmClassifyPaidPartiallyReasonDiscount=Remaining unpaid (%s %s) is a ConfirmClassifyPaidPartiallyReasonDiscountNoVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I accept to lose the VAT on this discount. ConfirmClassifyPaidPartiallyReasonDiscountVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I recover the VAT on this discount without a credit note. ConfirmClassifyPaidPartiallyReasonBadCustomer=Bad customer -ConfirmClassifyPaidPartiallyReasonBankCharge=Deduction by bank (intermediary bank fees) +ConfirmClassifyPaidPartiallyReasonBankCharge=Deduction by bank (intermediary bank fee) +ConfirmClassifyPaidPartiallyReasonWithholdingTax=Withholding tax ConfirmClassifyPaidPartiallyReasonProductReturned=Products partially returned ConfirmClassifyPaidPartiallyReasonOther=Amount abandoned for other reason ConfirmClassifyPaidPartiallyReasonDiscountNoVatDesc=This choice is possible if your invoice has been provided with suitable comments. (Example «Only the tax corresponding to the price that has been actually paid gives rights to deduction») @@ -205,6 +206,7 @@ ConfirmClassifyPaidPartiallyReasonAvoirDesc=Use this choice if all other does no ConfirmClassifyPaidPartiallyReasonBadCustomerDesc=A bad customer is a customer that refuses to pay his debt. ConfirmClassifyPaidPartiallyReasonProductReturnedDesc=This choice is used when payment is not complete because some of products were returned ConfirmClassifyPaidPartiallyReasonBankChargeDesc=The unpaid amount is intermediary bank fees, deducted directly from the correct amount paid by the Customer. +ConfirmClassifyPaidPartiallyReasonWithholdingTaxDesc=The unpaid amount will never be paid as it is a withholding tax ConfirmClassifyPaidPartiallyReasonOtherDesc=Use this choice if all others are not suitable, for example in following situation:
    - payment not complete because some products were shipped back
    - amount claimed too important because a discount was forgotten
    In all cases, amount over-claimed must be corrected in accountancy system by creating a credit note. ConfirmClassifyAbandonReasonOther=Other ConfirmClassifyAbandonReasonOtherDesc=This choice will be used in all other cases. For example because you plan to create a replacing invoice. From 45cc41005e183f8c418ea5389afff81287bb266b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 May 2023 13:26:12 +0200 Subject: [PATCH 203/203] Keep existing setup safe --- htdocs/install/mysql/migration/17.0.0-18.0.0.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index b68cf008f2f..6de234d2af8 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -412,12 +412,12 @@ CREATE TABLE llx_c_invoice_subtype ( ALTER TABLE llx_c_invoice_subtype ADD UNIQUE INDEX uk_c_invoice_subtype (entity, code); -- Upgrade default PDF models to the 'new' ones (eproved since 4 dolibarr versions from now) -UPDATE llx_const SET value="eratosthene" WHERE name="COMMANDE_ADDON_PDF" and value="einstein"; -UPDATE llx_const SET value="sponge" WHERE name="FACTURE_ADDON_PDF" and value="crabe"; -UPDATE llx_const SET value="espadon" WHERE name="EXPEDITION_ADDON_PDF" and value="merou"; -UPDATE llx_const SET value="cyan" WHERE name="PROPALE_ADDON_PDF" and value="azur"; -UPDATE llx_const SET value="storm" WHERE name IN ("DELIVERY_ADDON_PDF","LIVRAISON_ADDON_PDF") and value="typhon"; -UPDATE llx_const SET value="cornas" WHERE name="COMMANDE_SUPPLIER_ADDON_PDF" and value="muscadet"; +--UPDATE llx_const SET value="eratosthene" WHERE name="COMMANDE_ADDON_PDF" and value="einstein"; +--UPDATE llx_const SET value="sponge" WHERE name="FACTURE_ADDON_PDF" and value="crabe"; +--UPDATE llx_const SET value="espadon" WHERE name="EXPEDITION_ADDON_PDF" and value="merou"; +--UPDATE llx_const SET value="cyan" WHERE name="PROPALE_ADDON_PDF" and value="azur"; +--UPDATE llx_const SET value="storm" WHERE name IN ("DELIVERY_ADDON_PDF","LIVRAISON_ADDON_PDF") and value="typhon"; +--UPDATE llx_const SET value="cornas" WHERE name="COMMANDE_SUPPLIER_ADDON_PDF" and value="muscadet"; ALTER TABLE llx_c_propalst ADD COLUMN sortorder smallint DEFAULT 0;