########## accountancy/bookkeeping/list.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/accountancy/bookkeeping/list.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/accountancy/bookkeeping/list.php 2022-12-29 01:48:23.688100467 +0000 @@ -874,7 +874,7 @@ $buttonLabel = $langs->trans("ExportList"); } -$parameters = array(); +$parameters = array('param' => $param); $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); ########## accountancy/bookkeeping/listbyaccount.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/accountancy/bookkeeping/listbyaccount.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/accountancy/bookkeeping/listbyaccount.php 2022-12-29 01:48:23.690662756 +0000 @@ -602,7 +602,7 @@ print ''; print ''; -$parameters = array(); +$parameters = array('param' => $param); $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); ########## accountancy/journal/bankjournal.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/accountancy/journal/bankjournal.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/accountancy/journal/bankjournal.php 2022-12-29 01:48:23.876604621 +0000 @@ -1159,19 +1159,24 @@ //var_dump($tabpay[$key]); print ''; print ''; + + // Date print "".$date.""; - print "".$ref.""; + + // Ref + print "".dol_escape_htmltag($ref).""; + // Ledger account - print ""; $accounttoshow = length_accountg($k); if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { - print ''.$langs->trans("BankAccountNotDefined").''; - } else { - print $accounttoshow; + $accounttoshow = ''.$langs->trans("BankAccountNotDefined").''; } + print ''; + print $accounttoshow; print ""; + // Subledger account - print ""; + print ''; /*$accounttoshow = length_accountg($k); if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { @@ -1179,9 +1184,12 @@ } else print $accounttoshow;*/ print ""; - print ""; - print $reflabel; + + // Label operation + print ''; + print $reflabel; // This is already html escaped content print ""; + print ''.$val["type_payment"].""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; @@ -1205,10 +1213,14 @@ print ''; print ''; + + // Date print "".$date.""; - print "".$ref.""; + + // Ref + print "".dol_escape_htmltag($ref).""; + // Ledger account - print ""; $account_ledger = $k; // Try to force general ledger account depending on type if ($tabtype[$key] == 'payment') { @@ -1237,9 +1249,9 @@ if ($tabtype[$key] == 'unknown') { // We will accept writing, but into a waiting account if (empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) || $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE == '-1') { - print ''.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').''; + $accounttoshow = ''.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').''; } else { - print ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will use a waiting account + $accounttoshow = ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will use a waiting account } } else { // We will refuse writing @@ -1262,15 +1274,15 @@ if ($tabtype[$key] == 'member') { $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; } - print ''.$langs->trans($errorstring).''; + $accounttoshow = ''.$langs->trans($errorstring).''; } - } else { - print $accounttoshow; } + print ''; + print $accounttoshow; print ""; // Subledger account - print ""; + $accounttoshowsubledger = ''; if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger $accounttoshowsubledger = length_accounta($k); if ($accounttoshow != $accounttoshowsubledger) { @@ -1282,18 +1294,20 @@ if (!empty($tabcompany[$key]['code_compta'])) { if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { // For such case, if subledger is not defined, we won't use subledger accounts. - print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").''; + $accounttoshowsubledger = ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").''; } else { - print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).''; + $accounttoshowsubledger = ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).''; } } else { - print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").''; + $accounttoshowsubledger = ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").''; } - } else { - print $accounttoshowsubledger; } + } else { + $accounttoshowsubledger = ''; } } + print ''; + print $accounttoshowsubledger; print ""; print "".$reflabel.""; ########## adherents/class/api_members.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/adherents/class/api_members.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/adherents/class/api_members.class.php 2022-12-29 01:48:24.183346554 +0000 @@ -383,14 +383,18 @@ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$member->delete($member->id, DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when deleting member'); + + $res = $member->delete($member->id, DolibarrApiAccess::$user); + if ($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + } elseif ($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); } return array( 'success' => array( 'code' => 200, - 'message' => 'member deleted' + 'message' => 'Member deleted' ) ); } ########## adherents/class/api_memberstypes.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/adherents/class/api_memberstypes.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/adherents/class/api_memberstypes.class.php 2022-12-29 01:48:24.190767835 +0000 @@ -229,14 +229,17 @@ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$membertype->delete()) { - throw new RestException(401, 'error when deleting member type'); + $res = $membertype->delete(); + if ($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + } elseif ($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); } return array( 'success' => array( 'code' => 200, - 'message' => 'member type deleted' + 'message' => 'Member type deleted' ) ); } ########## adherents/class/api_subscriptions.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/adherents/class/api_subscriptions.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/adherents/class/api_subscriptions.class.php 2022-12-29 01:48:24.222970857 +0000 @@ -215,14 +215,17 @@ throw new RestException(404, 'Subscription not found'); } - if (!$subscription->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when deleting subscription'); + $res = $subscription->delete(DolibarrApiAccess::$user); + if ($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + } elseif ($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); } return array( 'success' => array( 'code' => 200, - 'message' => 'subscription deleted' + 'message' => 'Subscription deleted' ) ); } ########## adherents/subscription/card.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/adherents/subscription/card.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/adherents/subscription/card.php 2022-12-29 01:48:24.329263977 +0000 @@ -108,8 +108,9 @@ $object->dateh = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int')); $object->datef = dol_mktime(GETPOST('datesubendhour', 'int'), GETPOST('datesubendmin', 'int'), 0, GETPOST('datesubendmonth', 'int'), GETPOST('datesubendday', 'int'), GETPOST('datesubendyear', 'int')); $object->fk_type = $typeid; - $object->note = $note; + $object->note_public = $note; $object->note_private = $note; + $object->amount = $amount; $result = $object->update($user); ########## admin/dict.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/admin/dict.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/admin/dict.php 2022-12-29 01:48:24.529882794 +0000 @@ -1965,7 +1965,7 @@ $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); } } elseif ($value == 'recuperableonly' || $value == 'deductible' || $value == 'category_type') { - $valuetoshow = yn($valuetoshow); + $valuetoshow = yn($valuetoshow ? 1 : 0); $class = "center"; } elseif ($value == 'type_cdr') { if (empty($valuetoshow)) { ########## admin/perms.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/admin/perms.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/admin/perms.php 2022-12-29 01:48:24.830810833 +0000 @@ -226,7 +226,7 @@ // Tick if ($obj->bydefault == 1) { print ''; - print ''; + print ''; //print img_edit_remove(); print img_picto('', 'switch_on'); print ''; ########## api/class/api_documents.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/api/class/api_documents.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/api/class/api_documents.class.php 2022-12-29 01:48:25.144136175 +0000 @@ -506,6 +506,11 @@ throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } + $objectType = $modulepart; + if (! empty($object->id) && ! empty($object->table_element)) { + $objectType = $object->table_element; + } + $filearray = dol_dir_list($upload_dir, $type, $recursive, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->ref) ? ' or Ref '.$object->ref : '').' does not return any document.'); @@ -513,11 +518,14 @@ if (($object->id) > 0 && !empty($modulepart)) { require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; $ecmfile = new EcmFiles($this->db); - $result = $ecmfile->fetchAll('', '', 0, 0, array('t.src_object_type' => $modulepart, 't.src_object_id' => $object->id)); + $result = $ecmfile->fetchAll('', '', 0, 0, array('t.src_object_type' => $objectType, 't.src_object_id' => $object->id)); if ($result < 0) { throw new RestException(503, 'Error when retrieve ecm list : '.$this->db->lasterror()); } elseif (is_array($ecmfile->lines) && count($ecmfile->lines) > 0) { - $filearray['ecmfiles_infos'] = $ecmfile->lines; + $count = count($filearray); + for ($i = 0 ; $i < $count ; $i++) { + if ($filearray[$i]['name'] == $ecmfile->lines[$i]->filename) $filearray[$i] = array_merge($filearray[$i], (array) $ecmfile->lines[0]); + } } } } ########## barcode/codeinit.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/barcode/codeinit.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/barcode/codeinit.php 2022-12-29 01:48:25.237382574 +0000 @@ -45,7 +45,7 @@ $modBarCodeProduct = ''; -$maxperinit = 1000; +$maxperinit = empty($conf->global->BARCODE_INIT_MAX) ? 1000 : $conf->global->BARCODE_INIT_MAX; /* @@ -65,14 +65,16 @@ if (preg_match('/^mod_barcode_product_.*php$/', $file)) { $file = substr($file, 0, dol_strlen($file) - 4); - try { - dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) { - dol_syslog($e->getMessage(), LOG_ERR); - } + if ($file == $conf->global->BARCODE_PRODUCT_ADDON_NUM) { + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + } - $modBarCodeProduct = new $file(); - break; + $modBarCodeProduct = new $file(); + break; + } } } closedir($handle); ########## comm/propal/class/propalestats.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/comm/propal/class/propalestats.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/comm/propal/class/propalestats.class.php 2022-12-29 01:48:25.666662580 +0000 @@ -93,9 +93,6 @@ } //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; $this->where .= ($this->where ? ' AND ' : '')."p.entity IN (".getEntity('propal').")"; - if (empty($user->rights->societe->client->voir) && !$this->socid) { - $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } if ($this->socid) { $this->where .= " AND p.fk_soc = ".((int) $this->socid); } @@ -130,7 +127,7 @@ $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -155,7 +152,7 @@ $sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->where; @@ -179,7 +176,7 @@ $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -204,7 +201,7 @@ $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -227,7 +224,7 @@ $sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->where; @@ -253,7 +250,7 @@ $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->where; ########## commande/class/commandestats.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/commande/class/commandestats.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/commande/class/commandestats.class.php 2022-12-29 01:48:25.845817406 +0000 @@ -93,9 +93,6 @@ //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; $this->where .= ($this->where ? ' AND ' : '').'c.entity IN ('.getEntity('commande').')'; - if (empty($user->rights->societe->client->voir) && !$this->socid) { - $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } if ($this->socid) { $this->where .= " AND c.fk_soc = ".((int) $this->socid); } @@ -129,7 +126,7 @@ $sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -154,7 +151,7 @@ $sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->where; @@ -178,7 +175,7 @@ $sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -203,7 +200,7 @@ $sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -226,7 +223,7 @@ $sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; if (empty($user->rights->societe->client->voir) && !$this->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->where; @@ -250,7 +247,7 @@ $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; if (empty($user->rights->societe->client->voir) && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } $sql .= $this->join; $sql .= " WHERE ".$this->where; ########## compta/facture/card.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/compta/facture/card.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/compta/facture/card.php 2022-12-29 01:48:26.210962259 +0000 @@ -2985,6 +2985,11 @@ $remise_percent = (!empty($expesrc->remise_percent) ? $expesrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + if (!empty($conf->multicurrency->enabled)) { + $currency_code = (!empty($expesrc->currency_code) ? $expesrc->currency_code : (!empty($soc->currency_code) ? $soc->currency_code : $objectsrc->multicurrency_code)); + $currency_tx = (!empty($expesrc->currency_tx) ? $expesrc->currency_tx : (!empty($soc->currency_tx) ? $soc->currency_tx : $objectsrc->currency_tx)); + } + //Replicate extrafields $expesrc->fetch_optionals(); $object->array_options = $expesrc->array_options; ########## compta/facture/class/facture.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/compta/facture/class/facture.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/compta/facture/class/facture.class.php 2023-01-19 21:52:35.666739360 +0000 @@ -5680,6 +5680,180 @@ } } + /** MODIF JOSE + * Send emails for invoices that are payed + * CAN BE A CRON TASK + * + * @param int $nbdays Delay after payed date (or before if delay is negative) + * @param string $paymentmode '' or 'all' by default (no filter), or 'LIQ', 'CHQ', CB', ... + * @param int|string $template Name (or id) of email template (Must be a template of type 'facture_send') + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function sendEmailsRemindersOnInvoicePayed($nbdays = 0, $paymentmode = 'all', $template = '') + { + global $conf, $langs, $user; + + $error = 0; + $this->output = ''; + $this->error = ''; + $nbMailSend = 0; + $errorsMsg = array(); + + $langs->load("bills"); + + if (empty($conf->facture->enabled)) { // Should not happen. If module disabled, cron job should not be visible. + $this->output .= $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Facture")); + return 0; + } + /*if (empty($conf->global->FACTURE_REMINDER_EMAIL)) { + $langs->load("bills"); + $this->output .= $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Facture")); + return 0; + } + */ + + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail = new FormMail($this->db); + + $now = dol_now(); + $tmpidate = dol_get_first_hour(dol_time_plus_duree($now, $nbdays, 'd'), 'gmt'); + + $tmpinvoice = new Facture($this->db); + + dol_syslog(__METHOD__, LOG_DEBUG); + + $this->db->begin(); + + //Select all action comm reminder + $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."facture as f"; + if (!empty($paymentmode) && $paymentmode != 'all') { + $sql .= ", ".MAIN_DB_PREFIX."c_paiement as cp"; + } + $sql .= " WHERE f.paye = 1"; //invoice payed + $sql .= " AND f.date_closing = '".$this->db->idate($tmpidate, 'gmt')."'"; + $sql .= " AND f.entity IN (".getEntity('facture').")"; + if (!empty($paymentmode) && $paymentmode != 'all') { + $sql .= " AND f.fk_mode_reglement = cp.id AND cp.code = '".$this->db->escape($paymentmode)."'"; + } + // TODO Add filter to check there is no payment started + // $sql .= $this->db->order("date_lim_reglement", "ASC"); +print_r($sql); + $resql = $this->db->query($sql); + + $stmpidate = dol_print_date($tmpidate, 'day', 'gmt'); + $this->output .= $langs->transnoentitiesnoconv("SearchPaidInvoicesWithDate", $stmpidate); + if (!empty($paymentmode) && $paymentmode != 'all') { + $this->output .= ' ('.$langs->transnoentitiesnoconv("PaymentMode").' '.$paymentmode.')'; + } + $this->output .= '
'; + + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + if (!$error) { + // Load event + $res = $tmpinvoice->fetch($obj->id); + if ($res > 0) { + $tmpinvoice->fetch_thirdparty(); + + $outputlangs = new Translate('', $conf); + if ($tmpinvoice->thirdparty->default_lang) { + $outputlangs->setDefaultLang($tmpinvoice->thirdparty->default_lang); + $outputlangs->loadLangs(array("main", "bills")); + } else { + $outputlangs = $langs; + } + + // Select email template + $arraymessage = $formmail->getEMailTemplate($this->db, 'facture_send', $user, $outputlangs, (is_numeric($template) ? $template : 0), 1, (is_numeric($template) ? '' : $template)); + if (is_numeric($arraymessage) && $arraymessage <= 0) { + $langs->load("errors"); + $this->output .= $langs->trans('ErrorFailedToFindEmailTemplate', $template); + return 0; + } + + // PREPARE EMAIL + $errormesg = ''; + + // Make substitution in email content + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, '', $tmpinvoice); + + complete_substitutions_array($substitutionarray, $outputlangs, $tmpinvoice); + + // Topic + $sendTopic = make_substitutions(empty($arraymessage->topic) ? $outputlangs->transnoentitiesnoconv('InformationMessage') : $arraymessage->topic, $substitutionarray, $outputlangs, 1); + + // Content + $content = $outputlangs->transnoentitiesnoconv($arraymessage->content); + + $sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1); + + // Recipient + $res = $tmpinvoice->fetch_thirdparty(); + $recipient = $tmpinvoice->thirdparty; + if ($res > 0) { + if (!empty($recipient->email)) { + $to = $recipient->email; + } else { + $errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->fk_soc.". No email defined for user."; + $error++; + } + } else { + $errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->fk_soc; + $error++; + } + + // Sender + $from = $conf->global->MAIN_MAIL_EMAIL_FROM; + if (empty($from)) { + $errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM"; + $error++; + } + + if (!$error) { + // Errors Recipient + $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; + + $trackid = 'inv'.$tmpinvoice->id; + // Mail Creation + $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', $trackid, '', '', ''); + + // Sending Mail + if ($cMailFile->sendfile()) { + $nbMailSend++; + } else { + $errormesg = $cMailFile->error.' : '.$to; + $error++; + } + } + + if ($errormesg) { + $errorsMsg[] = $errormesg; + } + } else { + $errorsMsg[] = 'Failed to fetch record invoice with ID = '.$obj->id; + $error++; + } + } + } + } else { + $error++; + } + + if (!$error) { + $this->output .= 'Nb of emails sent : '.$nbMailSend; + $this->db->commit(); + return 0; + } else { + $this->db->commit(); // We commit also on error, to have the error message recorded. + $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; + return $error; + } + } + // END MODIF JOSE + + /** * See if current invoice date is posterior to the last invoice date among validated invoices of same type. * ########## compta/facture/list.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/compta/facture/list.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/compta/facture/list.php 2022-12-29 01:48:26.263517237 +0000 @@ -1789,7 +1789,7 @@ $remaintopay = 0; $multicurrency_remaintopay = 0; } - if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consummed + if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consumed $remaincreditnote = $discount->getAvailableDiscounts($companystatic, '', 'rc.fk_facture_source='.$facturestatic->id); $remaintopay = -$remaincreditnote; $totalpay = price2num($facturestatic->total_ttc - $remaintopay); ########## contrat/card.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/contrat/card.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/contrat/card.php 2022-12-29 01:48:26.926355628 +0000 @@ -496,6 +496,8 @@ $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); + $pu_ht = price2num($price_ht, 'MU'); + // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if ($tmpvat != $tmpprodvat) { @@ -521,7 +523,7 @@ $fk_unit = $prod->fk_unit; } else { - $pu_ht = GETPOST('price_ht'); + $pu_ht = price2num($price_ht, 'MU'); $price_base_type = 'HT'; $tva_tx = GETPOST('tva_tx') ?str_replace('*', '', GETPOST('tva_tx')) : 0; // tva_tx field may be disabled, so we use vat rate 0 $tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0; ########## core/actions_massactions.inc.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/actions_massactions.inc.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/actions_massactions.inc.php 2022-12-29 01:48:26.993534619 +0000 @@ -1040,8 +1040,9 @@ } if ($objectclass == 'Holiday' && ! in_array($objecttmp->statut, array(Holiday::STATUS_DRAFT, Holiday::STATUS_CANCELED, Holiday::STATUS_REFUSED))) { + $langs->load("errors"); $nbignored++; - $resaction .= '
'.$langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).'

'; + $TMsg[] = '
'.$langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).'

'; continue; } @@ -1418,7 +1419,7 @@ // If no SQL error, we redirect to the request form if (!$error) { - // Calculcate number of days consummed + // Calculcate number of days consumed $nbopenedday = num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday); $soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type); $newSolde = ($soldeActuel - $nbopenedday); ########## core/class/commonobject.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/class/commonobject.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/class/commonobject.class.php 2022-12-29 01:48:27.349021301 +0000 @@ -8113,7 +8113,7 @@ if ($display_type == 'card') { $out .= ''; - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && ($action == 'view' || $action == 'valid' || $action == 'editline')) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && ($action == 'view' || $action == 'valid' || $action == 'editline' || $action == 'confirm_valid' || $action == 'confirm_cancel')) { $out .= ''; } $out .= 'table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,"; + $sql = "SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,"; $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -1225,6 +1225,7 @@ $contactstatic->email = $obj->email; $contactstatic->socialnetworks = $obj->socialnetworks; $contactstatic->photo = $obj->photo; + $contactstatic->entity = $obj->entity; $country_code = getCountry($obj->country_id, 2); $contactstatic->country_code = $country_code; ########## core/lib/files.lib.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/lib/files.lib.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/lib/files.lib.php 2022-12-29 01:48:29.075786505 +0000 @@ -2435,7 +2435,7 @@ if (empty($refname)) { $refname = basename(dirname($original_file)."/"); if ($refname == 'thumbs') { - // If we get the thumbns directory, we must go one step higher. For example original_file='10/thumbs/myfile_small.jpg' -> refname='10' + // If we get the thumbs directory, we must go one step higher. For example original_file='10/thumbs/myfile_small.jpg' -> refname='10' $refname = basename(dirname(dirname($original_file))."/"); } } ########## core/lib/functions.lib.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/lib/functions.lib.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/lib/functions.lib.php 2022-12-29 01:48:29.112334336 +0000 @@ -3959,7 +3959,8 @@ 'shapes', 'square', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'uncheck', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private', - 'conferenceorbooth', 'eventorganization' + 'conferenceorbooth', 'eventorganization', + 'stamp', 'signature' ))) { $fakey = $pictowithouttext; $facolor = ''; @@ -4063,7 +4064,7 @@ // Add CSS $arrayconvpictotomorcess = array( 'action'=>'infobox-action', 'account'=>'infobox-bank_account', 'accounting_account'=>'infobox-bank_account', 'accountline'=>'infobox-bank_account', 'accountancy'=>'infobox-bank_account', 'asset'=>'infobox-bank_account', - 'bank_account'=>'bg-infobox-bank_account', + 'bank_account'=>'infobox-bank_account', 'bill'=>'infobox-commande', 'billa'=>'infobox-commande', 'billr'=>'infobox-commande', 'billd'=>'infobox-commande', 'margin'=>'infobox-bank_account', 'conferenceorbooth'=>'infobox-project', 'cash-register'=>'infobox-bank_account', 'contract'=>'infobox-contrat', 'check'=>'font-status4', 'collab'=>'infobox-action', 'conversation'=>'infobox-contrat', ########## core/lib/project.lib.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/lib/project.lib.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/lib/project.lib.php 2022-12-29 01:48:29.191542844 +0000 @@ -1529,7 +1529,7 @@ if (!empty($arrayfields['timeconsumed']['checked'])) { // Time spent by everybody print ''; - // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user if ($lines[$i]->duration) { print ''; print convertSecondToTime($lines[$i]->duration, 'allhourmin'); @@ -1934,7 +1934,7 @@ if (!empty($arrayfields['timeconsumed']['checked'])) { // Time spent by everybody print ''; - // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user if ($lines[$i]->duration) { print ''; print convertSecondToTime($lines[$i]->duration, 'allhourmin'); @@ -2228,7 +2228,7 @@ // Time spent by everybody print ''; - // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user + // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consumed by user if ($lines[$i]->duration) { print ''; print convertSecondToTime($lines[$i]->duration, 'allhourmin'); ########## core/modules/mailings/contacts1.modules.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/modules/mailings/contacts1.modules.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/modules/mailings/contacts1.modules.php 2022-12-29 01:48:30.010635239 +0000 @@ -408,7 +408,7 @@ } // Filter on language - if ($filter_lang != '') { + if (!empty($filter_lang)) { $sql .= " AND sp.default_lang = '".$this->db->escape($filter_lang)."'"; } @@ -439,7 +439,6 @@ $sql .= " ORDER BY sp.email"; // print "wwwwwwx".$sql; - // Stocke destinataires dans cibles $result = $this->db->query($sql); if ($result) { ########## core/tpl/card_presend.tpl.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/tpl/card_presend.tpl.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/tpl/card_presend.tpl.php 2022-12-29 01:48:30.787255943 +0000 @@ -70,7 +70,7 @@ $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($newlang); // Load traductions files required by page - $outputlangs->loadLangs(array('commercial', 'bills', 'orders', 'contracts', 'members', 'propal', 'products', 'supplier_proposal', 'interventions', 'receptions')); + $outputlangs->loadLangs(array('commercial', 'bills', 'orders', 'contracts', 'members', 'propal', 'products', 'supplier_proposal', 'interventions', 'receptions', 'sendings')); } $topicmail = ''; ########## core/tpl/list_print_total.tpl.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/tpl/list_print_total.tpl.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/tpl/list_print_total.tpl.php 2023-11-04 07:51:16.403928000 +0000 @@ -6,6 +6,7 @@ $totalarray['val'][$keytotalizable] = $valtotalizable['total']; } } +print_r($totalarray); // Show total line if (isset($totalarray['pos'])) { print ''; ########## core/tpl/notes.tpl.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/tpl/notes.tpl.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/tpl/notes.tpl.php 2022-12-29 01:48:30.858872455 +0000 @@ -91,7 +91,7 @@ } elseif ($module == 'shipping') { $permission = $user->hasRight("expedition", "creer"); } elseif ($module == 'product') { - $permission = $user->hasRight("produit", "creer"); + $permission = $user->hasRight("product", "creer"); } elseif ($module == 'service') { $permission = $user->hasRight("service", "creer"); } elseif ($module == 'ecmfiles') { ########## fichinter/list.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/fichinter/list.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/fichinter/list.php 2022-12-29 01:48:31.670720096 +0000 @@ -496,7 +496,7 @@ $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; -print ''."\n"; +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -844,6 +844,9 @@ if (!$i) { $totalarray['type'][$totalarray['nbfield']] = 'duration'; } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + } $totalarray['val']['fd.duree'] += $obj->duree; } // Action column ########## holiday/card.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/holiday/card.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/holiday/card.php 2022-12-29 01:48:31.923171492 +0000 @@ -578,7 +578,7 @@ // If no SQL error, we redirect to the request form if (!$error) { - // Calculcate number of days consummed + // Calculcate number of days consumed $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); $newSolde = ($soldeActuel - $nbopenedday); @@ -799,7 +799,7 @@ $error++; } - // Calculcate number of days consummed + // Calculcate number of days consumed $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); ########## modulebuilder/template/admin/setup.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/modulebuilder/template/admin/setup.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/modulebuilder/template/admin/setup.php 2022-12-29 01:49:14.155774499 +0000 @@ -55,6 +55,9 @@ // Libraries require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/mymodule.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + //require_once "../class/myclass.class.php"; // Translations ########## product/card.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/product/card.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/product/card.php 2022-12-29 01:49:14.755754750 +0000 @@ -568,7 +568,7 @@ $object->volume = GETPOST('volume'); $object->volume_units = GETPOST('volume_units'); // This is not the fk_unit but the power of unit $finished = GETPOST('finished', 'int'); - if ($finished > 0) { + if ($finished >= 0) { $object->finished = $finished; } else { $object->finished = null; ########## product/class/api_products.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/product/class/api_products.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/product/class/api_products.class.php 2022-12-29 01:49:14.765933737 +0000 @@ -454,7 +454,19 @@ global $user; $user = DolibarrApiAccess::$user; - return $this->product->delete(DolibarrApiAccess::$user); + $res = $this->product->delete(DolibarrApiAccess::$user); + if ($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + } elseif ($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Object deleted' + ) + ); } /** ########## product/class/product.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/product/class/product.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/product/class/product.class.php 2023-01-03 18:25:16.202374829 +0000 @@ -5501,8 +5501,60 @@ $stock_inproduction = $this->stats_mrptoproduce['qty'] - $this->stats_mrptoconsume['qty']; } + // MODIF JOSE $this->stock_theorique = $this->stock_reel + $stock_inproduction; + + /*MODIF JOSE LINE 5334 $this->stock_theorique = $this->stock_reel + $stock_inproduction; + + $stockRealSave = $this->stock_reel; + $this->load_stock('warehouseforwoo,novirtual'); + $this->stock_theorique = $this->stock_reel + $stock_inproduction; + $this->stock_reel = $stockRealSave;*/ + + if (!empty($conf->global->ENTREPOT_FOR_WOO)) { + + $sql = "SELECT sum(ps.reel) as stockvente"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= ", ".MAIN_DB_PREFIX."entrepot as w"; + $sql .= " WHERE w.entity IN (".getEntity('stock').")"; + $sql .= " AND w.rowid = ps.fk_entrepot"; + $sql .= " AND ps.fk_product = ".((int) $this->id); + $sql .= " AND ps.fk_entrepot IN (".$conf->global->ENTREPOT_FOR_WOO.")"; + +// error_log("Requete SQL Produit Liste Load".print_r($sql,1),1,"jose.martinez@ridin-family.com"); + + dol_syslog(get_class($this)."::stock_virtuel_woo", LOG_DEBUG); + $result = $this->db->query($sql); +// error_log("Result SQL ".print_r($result,1),1,"jose.martinez@ridin-family.com"); + if ($result) { + $num = $this->db->num_rows($result); + if ($num > 0) { + $row = $this->db->fetch_object($result); +// error_log("Resultat ROW ".print_r($row,1),1,"jose.martinez@ridin-family.com"); + } +// error_log("Resultat ROW Stockvente ".print_r($row->stockvente,1),1,"jose.martinez@ridin-family.com"); + $stock_reel_vente = $row->stockvente; + + $this->db->free($result); + + //return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + $this->stock_theorique = $stock_reel_vente + $stock_inproduction; +// error_log("Resultat Stock Theorique ".print_r($this->stock_theorique,1),1,"jose.martinez@ridin-family.com"); + } else { + $this->stock_theorique = $this->stock_reel + $stock_inproduction; + } + if ($this->id == 265) { + // print 'Stock Virtuel avant :'.$this->stock_theorique; + // error_log('Stock Virtuel avant :'.$this->stock_theorique,1,"jose.martinez@ridin-family.com"); + } + + // FIN MODIF JOSE + // Stock decrease mode if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { $this->stock_theorique -= ($stock_commande_client - $stock_sending_client); ########## product/fournisseurs.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/product/fournisseurs.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/product/fournisseurs.php 2022-12-29 01:49:14.875121342 +0000 @@ -753,16 +753,11 @@ // Barcode type print ''; - print ''; + print ''; print ''; - print ''; - - // Barcode value - print ''; - print ''; - print ''; + print img_picto('', 'barcode', 'class="pictofixedwidth"'); + print $formbarcode->selectBarcodeType((GETPOSTISSET('fk_barcode_type') ? GETPOST('fk_barcode_type', 'int') : ($rowid ? $object->supplier_fk_barcode_type : getDolGlobalint("PRODUIT_DEFAULT_BARCODE_TYPE"))), 'fk_barcode_type', 1); + print ' '; print ''; } ########## product/inventory/inventory.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/product/inventory/inventory.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/product/inventory/inventory.php 2022-12-29 01:49:14.921600655 +0000 @@ -979,6 +979,7 @@ $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement, id.pmp_real, id.pmp_expected'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); + $sql .= ' ORDER BY id.rowid'; $cacheOfProducts = array(); $cacheOfWarehouses = array(); ########## product/stock/list.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/product/stock/list.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/product/stock/list.php 2023-11-04 08:42:50.106541000 +0000 @@ -687,7 +687,7 @@ $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell'; } } - +print_r($totalarray); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook ########## product/stock/replenish.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/product/stock/replenish.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/product/stock/replenish.php 2022-12-29 01:49:15.072825440 +0000 @@ -464,7 +464,7 @@ $sqlProductionToConsume .= " ".MAIN_DB_PREFIX."mrp_production as mp5"; $sqlProductionToConsume .= " WHERE mm5.rowid = mp5.fk_mo AND mm5.entity IN (".getEntity(!empty($conf->global->STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE) ? 'stock' : 'mo').")"; $sqlProductionToConsume .= " AND mp5.fk_product = p.rowid"; - $sqlProductionToConsume .= " AND mp5.role IN ('toconsume', 'consummed')"; + $sqlProductionToConsume .= " AND mp5.role IN ('toconsume', 'consumed')"; $sqlProductionToConsume .= " AND mm5.status IN (1,2))"; $sqlProductionToProduce = "(SELECT GREATEST(0, ".$db->ifsql("SUM(".$db->ifsql("mp5.role = 'toproduce'", 'mp5.qty', '- mp5.qty').") IS NULL", "0", "SUM(".$db->ifsql("mp5.role = 'toconsume'", 'mp5.qty', '- mp5.qty').")").") as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL ########## projet/card.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/projet/card.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/projet/card.php 2022-12-29 01:49:15.184056244 +0000 @@ -489,11 +489,11 @@ $titleboth = $langs->trans("LeadsOrProjects"); $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default -if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { +if (!getDolGlobalInt('PROJECT_USE_OPPORTUNITIES')) { $titleboth = $langs->trans("Projects"); $titlenew = $langs->trans("NewProject"); } -if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only +if (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only $titleboth = $langs->trans("Leads"); $titlenew = $langs->trans("NewLead"); } ########## projet/class/api_tasks.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/projet/class/api_tasks.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/projet/class/api_tasks.class.php 2022-12-29 01:49:15.187753903 +0000 @@ -544,7 +544,7 @@ $this->task->timespent_datehour = $newdate; $this->task->timespent_withhour = 1; $this->task->timespent_duration = $duration; - $this->task->timespent_fk_user = $user_id; + $this->task->timespent_fk_user = $uid; $this->task->timespent_note = $note; $result = $this->task->addTimeSpent(DolibarrApiAccess::$user, 0); ########## projet/class/taskstats.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/projet/class/taskstats.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/projet/class/taskstats.class.php 2022-12-29 01:49:15.194050254 +0000 @@ -193,4 +193,34 @@ // var_dump($res);print '
'; return $res; } + + /** + * Return the Task amount by month for a year + * + * @param int $year Year to scan + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array with amount by month + */ + public function getAmountByMonth($year, $format = 0) + { + // Return an empty array at the moment because task has no amount + return array(); + } + + /** + * Return average of entity by month + * @param int $year year number + * @return int value + */ + protected function getAverageByMonth($year) + { + $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; + $sql .= " FROM ".$this->from; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAverageByMonth($year, $sql); + } } ########## projet/tasks/time.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/projet/tasks/time.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/projet/tasks/time.php 2022-12-29 01:49:15.257124788 +0000 @@ -164,7 +164,7 @@ $search_date_update = ''; $search_task_ref = ''; $search_task_label = ''; - $search_user = 0; + $search_user = -1; $search_valuebilled = ''; $toselect = array(); $search_array_options = array(); @@ -462,17 +462,22 @@ foreach ($arrayoftasks as $userid => $value) { $fuser->fetch($userid); - //$pu_ht = $value['timespent'] * $fuser->thm; + $pu_ht = $fuser->thm; $username = $fuser->getFullName($langs); // Define qty per hour $qtyhour = $value['timespent'] / 3600; $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + /* // If no unit price known if (empty($pu_ht)) { $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); } + */ + + //Unit price + $pu_ht = price2num(($value['totalvaluetodivideby3600'] / $value['timespent']), 'MU'); // Add lines $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); @@ -1235,7 +1240,7 @@ print $langs->trans('InvoiceToUse'); print ''; print ''; print ''; /*print ''; @@ -1341,7 +1346,7 @@ if (empty($search_user)) { $search_user = $user->id; } - $sql .= " AND t.fk_user = ".((int) $search_user); + if ($search_user > 0) $sql .= " AND t.fk_user = ".((int) $search_user); } if ($search_note) { ########## reception/class/reception.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/reception/class/reception.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/reception/class/reception.class.php 2022-12-29 01:49:15.625402913 +0000 @@ -1781,7 +1781,7 @@ // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', $obj->fk_origin_stock, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1913,7 +1913,7 @@ // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; ########## societe/class/api_thirdparties.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/societe/class/api_thirdparties.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/societe/class/api_thirdparties.class.php 2022-12-29 01:48:12.914066384 +0000 @@ -528,7 +528,20 @@ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->company->oldcopy = clone $this->company; - return $this->company->delete($id); + + $res = $this->company->delete($id); + if ($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + } elseif ($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Object deleted' + ) + ); } /** ########## ticket/card.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/ticket/card.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/ticket/card.php 2022-12-29 01:49:15.817228099 +0000 @@ -726,7 +726,7 @@ $formticket->withcancel = 1; - $formticket->showForm(1, 'create', 0); + $formticket->showForm(1, 'create', 0, null, $action); /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) { $formticket = new FormTicket($db); ########## user/class/api_users.class.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/user/class/api_users.class.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/user/class/api_users.class.php 2022-12-29 01:49:16.035242078 +0000 @@ -640,7 +640,17 @@ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->useraccount->oldcopy = clone $this->useraccount; - return $this->useraccount->delete(DolibarrApiAccess::$user); + + if (!$this->useraccount->delete(DolibarrApiAccess::$user)) { + throw new RestException(500); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Ticket deleted' + ) + ); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore ########## user/perms.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/user/perms.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/user/perms.php 2022-12-29 01:49:16.095127545 +0000 @@ -309,16 +309,14 @@ print ''; print ''; -if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) { - if ($caneditperms) { - print ''; - } - print ''; +if ($caneditperms) { + print ''; } +print ''; print ''; if ($user->admin) { print ''; ########## viewimage.php --- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/viewimage.php 2022-11-29 17:31:43.000000000 +0000 +++ /homez.786/ridinteadu/serious/dolibarr/htdocs/viewimage.php 2022-12-29 01:49:16.187515301 +0000 @@ -228,6 +228,10 @@ // Find the subdirectory name as the reference $refname = basename(dirname($original_file)."/"); +if ($refname == 'thumbs') { + // If we get the thumbs directory, we must go one step higher. For example original_file='10/thumbs/myfile_small.jpg' -> refname='10' + $refname = basename(dirname(dirname($original_file))."/"); +} // Check that file is allowed for view with viewimage.php if (!empty($original_file) && !dolIsAllowedForPreview($original_file)) {
'.$langs->trans('BarcodeType').''.$langs->trans('GencodBuyPrice').''; - print $formbarcode->selectBarcodeType(($rowid ? $object->supplier_fk_barcode_type : getDolGlobalint("PRODUIT_DEFAULT_BARCODE_TYPE")), 'fk_barcode_type', 1); - print '
'.$langs->trans('BarcodeValue').''.img_picto('', 'barcode', 'class="pictofixedwidth"').'
'; - $form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); + $form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); print '
'.$langs->trans("Module").''; - print ''.$langs->trans("All").""; - print ' / '; - print ''.$langs->trans("None").""; - print ' '; + print ''.$langs->trans("All").""; + print ' / '; + print ''.$langs->trans("None").""; + print ' '.$langs->trans("Permissions").'