diff --git a/.gitignore b/.gitignore index 1ece034ae94..aa332681474 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ dolibarr_install.log upgrade.log doxygen_warnings.log /.project +/.vscode .DS_Store .idea *.iml diff --git a/COPYRIGHT b/COPYRIGHT index bd3565c3bd1..83f72bb558b 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -53,6 +53,10 @@ JsTimezoneDetect 1.0.6 MIT License Yes SwaggerUI 2.0.24 GPL-2+ Yes JS library to offer the REST API explorer Ace 1.2.8 BSD Yes JS library to get code syntaxique coloration in a textarea. +Image libraries +Octicons 8.1 MIT Yes + + For licenses compatibility informations: http://www.gnu.org/licenses/licenses.en.html diff --git a/ChangeLog b/ChangeLog index 891b27ba78f..e516382f62f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,8 +8,12 @@ For Users: NEW: Stable module: Website NEW: Stable module: WebDAV NEW: Stable module: Module Builder +NEW: Stable module "Skype" has been replaced with module "Social Networks" to support more tools. +NEW: Experimental module "TakePos" NEW: Dolibarr can provide information in page title when multicompany is enabled of not, making Android application like DoliDroid able to provide native features for multicompany module. +NEW: Compatibility with PHP 7.3 + For developers: * Code changes to be more compatible with PSR2 @@ -24,6 +28,40 @@ Following changes may create regressions for some external modules, but were nec +***** ChangeLog for 8.0.2 compared to 8.0.1 ***** +FIX: #8452 +FIX: #9043 +FIX: #9316 Error when listing invoices +FIX: #9317 +FIX: #9353 Bug: html error - div inside span on graphs +FIX: #9355 +FIX: #9393 inconsistency behaviour. option FACTURE_ENABLE_NEGATIVE_LINES +FIX: #9394 +FIX: #9396 +FIX: #9403 +FIX: #9412 +FIX: #9497 +FIX: Add paypal error message in alert email when online payment fails. +FIX: better compatibility with multicompany +FIX: capital must be empty and not 0 if undefined +FIX: character making error on bill list +FIX: Entering negative price on order. +FIX: Expedition not showing extrafields on creation. +FIX: Homepage links were using wrong topmenus +FIX: inconsistency behaviour on option FACTURE_ENABLE_NEGATIVE_LINES +FIX: invert mime type and name. +FIX: invoice popup hide localtax2 and 3 if not defined. +FIX: Lose filter on payment type or category after a sort on invoice list. +FIX: Maxi debug to allow to load chart of account with multicompany. +FIX: Missing translation in predefined email to membership renewal. +FIX: Mixing tickets of different thirdparties. +FIX: "Other ..." link so the "Back to" link works. +FIX: PDF address: handle when contact thirdparty is different from thirdparty of document +FIX: Problems with permissions of module to record payment of salaries +FIX: remove debug +FIX: Several fixes on the management of minimal amount for orders +FIX: wrong var name + ***** ChangeLog for 8.0.1 compared to 8.0.0 ***** FIX: #9258 FIX: #9328 diff --git a/build/exe/doliwamp/Languages/MyEnglish.isl b/build/exe/doliwamp/Languages/MyEnglish.isl index 11d2e4456bd..b7c5ecb6230 100644 --- a/build/exe/doliwamp/Languages/MyEnglish.isl +++ b/build/exe/doliwamp/Languages/MyEnglish.isl @@ -13,8 +13,8 @@ AssocingFileExtension=Associating %1 with the %2 file extension... YouWillInstallDoliWamp=You will install or upgrade DoliWamp (Apache+Mysql+PHP+Dolibarr) on your computer. ThisAssistantInstallOrUpgrade=This assistant installs or upgrades Dolibarr ERP-CRM and all required third party softwares (Apache, Mysql and PHP) optimized for a Dolibarr usage. -IfYouHaveTechnicalKnowledge=If you have technical knowledge and plan to share your Apache, Mysql and PHP with other projects than Dolibarr, you should not use this assistant and make a manual installation of Dolibarr on your existing Apache, Mysql and PHP installation. -ButIfYouLook=But if you look for an automatic setup, you''re on the good way... +IfYouHaveTechnicalKnowledge=If you are looking for a hosted version in the Cloud, you should look at https://saas.dolibarr.org. If you have technical knowledge and want to manage your Apache, Mysql and PHP yourself, you should not use this assistant and make a manual installation of Dolibarr on your existing Apache, Mysql and PHP installation. +ButIfYouLook=But if you look for an automatic setup on your local computer, you''re on the good way... DoYouWantToStart=Do you want to start installation/upgrade process ? TechnicalParameters=Technical parameters diff --git a/build/exe/doliwamp/Languages/MyFrench.isl b/build/exe/doliwamp/Languages/MyFrench.isl index 1daf4425e68..8c7cff0bb42 100644 --- a/build/exe/doliwamp/Languages/MyFrench.isl +++ b/build/exe/doliwamp/Languages/MyFrench.isl @@ -13,8 +13,8 @@ AssocingFileExtension=Associe %1 avec l'extension de fichier %2... YouWillInstallDoliWamp=Vous allez installer ou mettre à jour DoliWamp (Apache+Mysql+PHP+Dolibarr) sur votre ordinateur. ThisAssistantInstallOrUpgrade=Cet assistant installe ou met à jour Dolibarr ERP-CRM et tous ses composants prérequis (Apache, Mysql et PHP) optimisés pour une utilisation de Dolibarr. -IfYouHaveTechnicalKnowledge=Si vous avez des compétences techniques et envisagez de partager votre Apache, Mysql et PHP avec d'autres applications que Dolibarr, vous ne devriez pas utiliser cet assistant mais faire plutôt une installation manuelle de Dolibarr sur un socle Apache, Mysql et PHP existant. -ButIfYouLook=Mais si vous recherchez une installation clé en main automatisée, vous êtes sur la bonne voie... +IfYouHaveTechnicalKnowledge=Si vous cherchez un hébergement dans le Cloud, aller voir sur https://saas.dolibarr.org. Si vous avez des compétences techniques et voulez gérer vous même Apache, Mysql et PHP, vous ne devriez pas utiliser cet assistant mais faire plutôt une installation manuelle de Dolibarr sur votre socle Apache, Mysql et PHP existant. +ButIfYouLook=Mais si vous recherchez une installation automatisée locale sur votre ordinateur, clé en main, vous êtes sur la bonne voie... DoYouWantToStart=Voulez-vous démarrer le processus d'installation/mise à jour ? TechnicalParameters=Paramètres techniques diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 2d4668b447c..cc6a39a62a4 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -32,7 +32,7 @@ AppPublisherURL=https://www.nltechno.com AppSupportURL=https://www.dolibarr.org AppUpdatesURL=https://www.dolibarr.org AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql softwares. -AppCopyright=Copyright (C) 2008-2017 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) +AppCopyright=Copyright (C) 2008-2018 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) DefaultDirName=c:\dolibarr DefaultGroupName=Dolibarr ;LicenseFile=COPYING diff --git a/dev/initdata/purge-data.php b/dev/initdata/purge-data.php index 5a1e7b3afc3..2bdf200225b 100755 --- a/dev/initdata/purge-data.php +++ b/dev/initdata/purge-data.php @@ -44,8 +44,7 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -$langs->load("main"); -$langs->load("errors"); +$langs->loadLangs(array("main", "errors")); // Global variables $version=DOL_VERSION; diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 2eedcda8760..0e3b2c7513f 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -295,6 +295,7 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0; if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0; if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0; + if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean=0; // admin.lang if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0; if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0; diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index ca47dbc7b96..087f9957f16 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -63,9 +63,9 @@ if (! $sortorder) $sortorder = "ASC"; $arrayfields=array( 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>0), + 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), - 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'), 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) ); @@ -122,16 +122,34 @@ if (empty($reshook)) { $sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql'; - // FIXME Get the ADD rowid and pass it + num of comapny * 100 000 000 to run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value. + $offsetforchartofaccount = 0; + // Get the comment line '-- ADD CCCNNNNN to rowid...' to find CCCNNNNN (CCC is country num, NNNNN is id of accounting account) + // and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value. + // This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used. + $tmp = file_get_contents($sqlfile); + if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) + { + $offsetforchartofaccount += $reg[1]; + } + $offsetforchartofaccount+=($conf->entity * 100000000); - $result = run_sql($sqlfile, 1, 0, 1); + $result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount); + + if ($result > 0) + { + setEventMessages($langs->trans("ChartLoaded"), null); + } + else + { + setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings'); + } } if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error++; } } else { - $error ++; + $error++; } } diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 2c7d92f3735..e3ed164d60b 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -524,62 +524,18 @@ if ($id) $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=$langs->trans($valuetoshow); // try to translate $align="left"; - if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } - if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { - if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); - else $valuetoshow=$langs->trans("Amount"); - $align='right'; - } - if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2";} - if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3";} - if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } - if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } - if ($fieldlist[$field]=='type') { - if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") $valuetoshow=$form->textwithtooltip($langs->trans("Type"),$langs->trans("TypePaymentDesc"),2,1,img_help(1,'')); - else $valuetoshow=$langs->trans("Type"); - } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); if ($id != 25) $valuetoshow.="*"; } - if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; } if ($fieldlist[$field]=='country') { if (in_array('region_id',$fieldlist)) { print '
';
print '';
print '';
- print ''.print_r($printer, true).''; - if (count($printer->getlist_available_printers())) { + if (count($printer->getlistAvailablePrinters())) { if ($printer->listAvailablePrinters()==0) { print $printer->resprint; } else { diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 76b3cf76b57..0dba6ea6700 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -67,6 +67,8 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'', $conf->entity); + + dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", $_POST["MAIN_INVERT_SENDER_RECIPIENT"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'', $conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'', $conf->entity); @@ -572,31 +574,36 @@ else // Show print ""; print ''; - //Desc + // Hide Desc print '
';
@@ -170,6 +173,8 @@ foreach($fulltree as $key => $val)
}
+//print_barre_liste('', 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, 0, '', 0, $newcardbutton, '', 0, 1, 1);
+
print '
';
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
- $morehtmlref.=$langs->trans('Project') . ' ';
- if ($user->rights->tax->charges->creer)
+ $morehtmlref.=$langs->trans('Project') . ' : ';
+ if ($user->rights->banque->modifier && 0)
{
if ($action != 'classify')
$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
@@ -108,16 +109,14 @@ if ($object->id)
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
- $morehtmlref.='';
- $morehtmlref.=$proj->ref;
- $morehtmlref.='';
+ $morehtmlref.=$proj->getNomUrl(1);
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.=' ';
- $linkback = ''.$langs->trans("BackToList").'';
+ $linkback = ''.$langs->trans("BackToList").'';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php
index c39a6379000..d9f8709b155 100644
--- a/htdocs/compta/bank/various_payment/info.php
+++ b/htdocs/compta/bank/various_payment/info.php
@@ -25,6 +25,7 @@ require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
@@ -49,9 +50,50 @@ $object->info($id);
$head = various_payment_prepare_head($object);
-dol_fiche_head($head, 'info', $langs->trans("VariousPayment"), 0, 'payment');
+dol_fiche_head($head, 'info', $langs->trans("VariousPayment"), -1, 'payment');
+$morehtmlref='';
+// Project
+if (! empty($conf->projet->enabled))
+{
+ $langs->load("projects");
+ $morehtmlref.=$langs->trans('Project') . ' : ';
+ if ($user->rights->banque->modifier && 0)
+ {
+ if ($action != 'classify')
+ $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref.=$proj->getNomUrl(1);
+ } else {
+ $morehtmlref.='';
+ }
+ }
+}
+$morehtmlref.=' ';
+$linkback = ''.$langs->trans("BackToList").'';
+
+dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
+
+print '';
+print '';
+
+print ' '; + print '
'.$file['name'].''; + $filesarray[]=$file; + } + if(count($files)<1){ + $nofile['date']=$db->idate($objd->date); + $nofile['paid']=$objd->paid; + $nofile['amount']=$objd->total_ttc; + $nofile['ref']=$objd->ref; + $nofile['fk']=$objd->fk_soc; + $nofile['item']=$objd->item; + $filesarray[]=$nofile; + } + } + $i++; + } + } + $db->free($resd); + +} +/* + * cleanup of old ZIP + */ +//FIXME +/* +*ZIP creation +*/ +if($result & $action=="dl"){ + unset($zip); + $log='date,type,ref,total,paid,filename,item_id'."\n"; + $zipname = ($date_start)."-".($date_stop).'_export.zip'; + $zip = new ZipArchive; + $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); + if ($res){ + foreach ($filesarray as $key=> $file) { + if(file_exists($file["fullname"])) $zip->addFile($file["fullname"],$file["name"]);// + $log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; + } + $zip->addFromString('log.csv', $log); + $zip->close(); + ///Then download the zipped file. + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename='.$zipname); + header('Content-Length: ' . filesize($zipname)); + readfile($zipname); + unlink($zipname); + exit(); + } +} +// None +/* + * View + */ +$form = new Form($db); +$userstatic=new User($db); +$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List"); +//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Symmary"); +$help_url='EN:Module_Accounting|FR:Module_Compatibilite'; //FIXME +llxHeader('',$title,$help_url); +print ''."\n\t\t"; +if (!empty($date_start) && !empty($date_stop))echo dol_print_date($date_start)." - ".dol_print_date($date_stop); +print '
\n\t\t\t";
+
+
+
+llxFooter();
+$db->close();
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index a40ad636976..4d538bfc68b 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -954,6 +954,8 @@ if (empty($reshook))
if($facture_source->type == Facture::TYPE_SITUATION)
{
+ $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
+ $line->fk_prev_id = $line->id; // Credit note line need to be linked to the situation invoice it is create from
if(!empty($facture_source->tab_previous_situation_invoice))
{
@@ -977,7 +979,7 @@ if (empty($reshook))
$maxPrevSituationPercent = 0;
foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
{
- if($prevLine->id == $line->fk_prev_id)
+ if($prevLine->id == $source_fk_prev_id)
{
$maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent);
@@ -1535,6 +1537,7 @@ if (empty($reshook))
$line->origin = $object->origin;
$line->origin_id = $line->id;
$line->fetch_optionals($line->id);
+ $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note
// Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée
if ($line->fk_remise_except)
@@ -1960,7 +1963,7 @@ if (empty($reshook))
if ($tva_npr)
$info_bits |= 0x01;
- if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) {
+ if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
setEventMessages($mesg, null, 'errors');
} else {
@@ -2032,7 +2035,7 @@ if (empty($reshook))
}
}
- elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel','alpha'))
+ elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha'))
{
if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty();
@@ -2123,7 +2126,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
- if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
+ if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) {
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error++;
}
@@ -2255,7 +2258,7 @@ if (empty($reshook))
}
}
- else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) {
+ else if ($action == 'updateline' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) {
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition
exit();
}
@@ -3644,7 +3647,7 @@ else if ($id > 0 || ! empty($ref))
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.=' | '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherBills").')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherBills").')'; // Project if (! empty($conf->projet->enabled)) { @@ -4463,6 +4466,7 @@ else if ($id > 0 || ! empty($ref)) print ' | ';
}
@@ -4486,6 +4490,7 @@ else if ($id > 0 || ! empty($ref))
print ' | ';
print " | ';
}
@@ -4509,7 +4514,7 @@ else if ($id > 0 || ! empty($ref))
print ' | |||||||||||||||||||||||||||||||||||||||||||||
| '; + print ' | '; print $facturestatic->getNomUrl(1,'',200,0,'',0,1); print empty($obj->increment)?'':' ('.$obj->increment.')'; - print ' | '; - print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->id; diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index c9794d9662e..1f0175bd370 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -135,15 +135,15 @@ class Cpaiement if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action to call a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + //if (!$notrigger) { - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) $error++; - //// End call triggers - } + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_CREATE',$user); + // if ($result < 0) $error++; + // // End call triggers + //} } // Commit or rollback @@ -278,15 +278,15 @@ class Cpaiement dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - if (!$error && !$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + //if (!$error && !$notrigger) { - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_MODIFY',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + //} // Commit or rollback if ($error) { @@ -316,17 +316,15 @@ class Cpaiement $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + //if (!$error && !$notrigger) { - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_DELETE',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } - } + // // Call triggers + // $result=$this->call_trigger('MYOBJECT_DELETE',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + //} if (!$error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index b22d4d21e43..b4a21e198de 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -74,7 +74,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char } } -// Create payment +// Validate social contribution +/* if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer) { $db->begin(); @@ -111,6 +112,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->char $db->rollback(); } } +*/ /* @@ -150,12 +152,14 @@ if ($action == 'delete') /* * Validation confirmation of payment */ +/* if ($action == 'valide') { $facid = $_GET['facid']; print $form->formconfirm('card.php?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); } +*/ $linkback = '' . $langs->trans("BackToList") . ''; diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index dc45c9a4fb0..ea67873c2ee 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -82,7 +82,6 @@ class PaymentSalary extends CommonObject $this->db = $db; $this->element = 'payment_salary'; $this->table_element = 'payment_salary'; - return 1; } /** diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 409ee99aaae..9013edee195 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -25,7 +25,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -77,31 +77,18 @@ class Cchargesociales $error = 0; - // Clean parameters - - if (isset($this->libelle)) { - $this->libelle = trim($this->libelle); - } - if (isset($this->deductible)) { - $this->deductible = trim($this->deductible); - } - if (isset($this->active)) { - $this->active = trim($this->active); - } - if (isset($this->code)) { - $this->code = trim($this->code); - } - if (isset($this->fk_pays)) { - $this->fk_pays = trim($this->fk_pays); - } - if (isset($this->module)) { - $this->module = trim($this->module); - } - if (isset($this->accountancy_code)) { - $this->accountancy_code = trim($this->accountancy_code); - } - - + // Clean parameters + $this->trimParameters( + array( + 'libelle', + 'deductible', + 'active', + 'code', + 'fk_pays', + 'module', + 'accountancy_code', + ) + ); // Check parameters // Put here code to add control on parameters values @@ -143,7 +130,7 @@ class Cchargesociales if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - if (!$notrigger) { + //if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. @@ -151,7 +138,7 @@ class Cchargesociales //$result=$this->call_trigger('MYOBJECT_CREATE',$user); //if ($result < 0) $error++; //// End call triggers - } + //} } // Commit or rollback @@ -243,28 +230,17 @@ class Cchargesociales // Clean parameters - if (isset($this->libelle)) { - $this->libelle = trim($this->libelle); - } - if (isset($this->deductible)) { - $this->deductible = trim($this->deductible); - } - if (isset($this->active)) { - $this->active = trim($this->active); - } - if (isset($this->code)) { - $this->code = trim($this->code); - } - if (isset($this->fk_pays)) { - $this->fk_pays = trim($this->fk_pays); - } - if (isset($this->module)) { - $this->module = trim($this->module); - } - if (isset($this->accountancy_code)) { - $this->accountancy_code = trim($this->accountancy_code); - } - + $this->trimParameters( + array( + 'libelle', + 'deductible', + 'active', + 'code', + 'fk_pays', + 'module', + 'accountancy_code', + ) + ); // Check parameters @@ -290,7 +266,7 @@ class Cchargesociales dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - if (!$error && !$notrigger) { + //if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -298,7 +274,7 @@ class Cchargesociales //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} //// End call triggers - } + //} // Commit or rollback if ($error) { @@ -328,8 +304,8 @@ class Cchargesociales $this->db->begin(); - if (!$error) { - if (!$notrigger) { + //if (!$error) { + //if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -337,8 +313,8 @@ class Cchargesociales //$result=$this->call_trigger('MYOBJECT_DELETE',$user); //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} //// End call triggers - } - } + //} + //} if (!$error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; @@ -476,34 +452,33 @@ class Cchargesociales if ($mode == 0) { - $prefix=''; if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 1) + elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } - if ($mode == 2) + elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } - if ($mode == 3) + elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); } - if ($mode == 4) + elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); } - if ($mode == 5) + elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } } @@ -526,4 +501,20 @@ class Cchargesociales $this->module = ''; $this->accountancy_code = ''; } + + /** + * Trim object parameters + * @param string[] $parameters array of parameters to trim + * + * @return void + */ + private function trimParameters($parameters) + { + if (!is_array($parameters)) return; + foreach ($parameters as $parameter) { + if (isset($this->$parameter)) { + $this->$parameter = trim($this->$parameter); + } + } + } } diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 2ea82fb32c4..aa5786d0eb5 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -76,7 +76,6 @@ class ChargeSociales extends CommonObject function __construct($db) { $this->db = $db; - return 1; } /** @@ -431,8 +430,9 @@ class ChargeSociales extends CommonObject { // phpcs:enable global $langs; - $langs->load('customers'); - $langs->load('bills'); + + // Load translation files required by the page + $langs->loadLangs(array("customers","bills")); if ($mode == 0 || $mode == 1) { diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 9e1757fdc5a..babc7e1453a 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -186,6 +186,8 @@ if (empty($reshook)) $object->country_id = GETPOST("country_id",'int'); $object->state_id = GETPOST("state_id",'int'); $object->skype = GETPOST("skype",'alpha'); + $object->twitter = GETPOST("twitter",'alpha'); + $object->facebook = GETPOST("facebook",'alpha'); $object->email = GETPOST("email",'alpha'); $object->phone_pro = GETPOST("phone_pro",'alpha'); $object->phone_perso = GETPOST("phone_perso",'alpha'); @@ -358,6 +360,8 @@ if (empty($reshook)) $object->email = GETPOST("email",'alpha'); $object->skype = GETPOST("skype",'alpha'); + $object->twitter = GETPOST("twitter",'alpha'); + $object->facebook = GETPOST("facebook",'alpha'); $object->phone_pro = GETPOST("phone_pro",'alpha'); $object->phone_perso = GETPOST("phone_perso",'alpha'); $object->phone_mobile = GETPOST("phone_mobile",'alpha'); @@ -658,13 +662,28 @@ else // Instant message and no email print ' | |
| '; - print ' | jabberid).'"> | jabberid).'"> | '; - // Skype - if (! empty($conf->skype->enabled)) + if (! empty($conf->socialnetworks->enabled)) { - print '|
| '; - print ' | skype).'"> | ||
| '; + print ' | skype).'"> | ||
| '; + print ' | twitter).'"> | ||
| '; + print ' | facebook).'"> | ||
| '; - print ' | skype).'"> | ||
| '; + print ' | skype).'"> | ||
| '; + print ' | twitter).'"> | ||
| '; + print ' | facebook).'"> | '.dol_trunc($obj->poste,20).' | '; + print ''.$obj->poste.' | '; if (! $i) $totalarray['nbfield']++; } // Zip diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0e0b0ee44f1..0c0247dc7fa 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -566,7 +566,7 @@ if (empty($reshook)) $info_bits=0; if ($tva_npr) $info_bits |= 0x01; - if($price_min && (price2num($pu_ht)*(1-price2num($remise_percent)/100) < price2num($price_min))) + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& ($price_min && (price2num($pu_ht)*(1-price2num($remise_percent)/100) < price2num($price_min)))) { $object->error = $langs->trans("CantBeLessThanMinPrice",price(price2num($price_min,'MU'),0,$langs,0,0,-1,$conf->currency)); $result = -1 ; @@ -1318,8 +1318,10 @@ else { $object->fetch_thirdparty(); - $result=$object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed - if ($result < 0) dol_print_error($db,$object->error); + $result=$object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed + if ($result < 0) { + dol_print_error($db,$object->error); + } $nbofservices=count($object->lines); @@ -1334,56 +1336,54 @@ else $head = contract_prepare_head($object); - $hselected = 0; + $hselected = 0; + $formconfirm = ''; - dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); + dol_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); - /* - * Confirmation de la suppression du contrat - */ - if ($action == 'delete') - { - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete",'',0,1); + if ($action == 'delete') { + //Confirmation de la suppression du contrat + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete",'',0,1); + } elseif ($action == 'valid') { + //Confirmation de la validation + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { + $numref = $object->getNextNumRef($object->thirdparty); + } else { + $numref = $object->ref; + } + $text = $langs->trans('ConfirmValidateContract',$numref); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$text,"confirm_valid",'',0,1); + } elseif ($action == 'close') { + // Confirmation de la fermeture + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1); + } elseif ($action == 'activate') { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ActivateAllOnContract"),$langs->trans("ConfirmActivateAllOnContract"),"confirm_activate",'',0,1); + } elseif ($action == 'clone') { + // Clone confirmation + $formquestion = array(array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - } - /* - * Confirmation de la validation - */ - if ($action == 'valid') - { - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) - { - $numref = $object->getNextNumRef($object->thirdparty); - } - else - { - $numref = $object->ref; - } + // Call Hook formConfirm + $parameters = array( + 'id' => $id, + //'lineid' => $lineid, + ); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - $text=$langs->trans('ConfirmValidateContract',$numref); + // Print form confirm + print $formconfirm; - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$text,"confirm_valid",'',0,1); - - } - - /* - * Confirmation de la fermeture - */ - if ($action == 'close') - { - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1); - - } - if ($action == 'activate') - { - print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ActivateAllOnContract"),$langs->trans("ConfirmActivateAllOnContract"),"confirm_activate",'',0,1); - - } - - /* + /* * Contrat */ if (! empty($object->brouillon) && $user->rights->contrat->creer) @@ -1393,12 +1393,6 @@ else print ''; } - // Clone confirmation - if ($action == 'clone') { - $formquestion = array(array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); - print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } - // Contract card $linkback = ''.$langs->trans("BackToList").''; @@ -1422,6 +1416,7 @@ else $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
| '.$langs->trans('Discount').' | ';
- if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
- else print $langs->trans("CompanyHasNoRelativeDiscount");
- $absolute_discount=$object->thirdparty->getAvailableDiscounts();
+ if ($object->thirdparty->remise_percent) {
+ print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
+ } else {
+ print $langs->trans("CompanyHasNoRelativeDiscount");
+ }
+ $absolute_discount = $object->thirdparty->getAvailableDiscounts();
print '. ';
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
@@ -239,9 +241,7 @@ if ($id > 0 || ! empty($ref))
// Contacts lines
include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php';
- }
- else
- {
+ } else {
print "ErrorRecordNotFound";
}
}
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index e616afefd99..96f20fdaf67 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -107,7 +107,6 @@ $fieldstosearchall = array(
'c.ref_customer'=>'RefCustomer',
'c.ref_supplier'=>'RefSupplier',
's.nom'=>"ThirdParty",
- 'cd.description'=>'Description',
'c.note_public'=>'NotePublic',
);
if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate";
@@ -252,7 +251,7 @@ else if ($year > 0)
$sql.= " AND c.date_contrat BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($search_name) $sql .= natural_search('s.nom', $search_name);
-if ($search_email) $sql .= natural_search('s.email', $search_name);
+if ($search_email) $sql .= natural_search('s.email', $search_email);
if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract);
if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer'), $search_ref_customer);
if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier);
@@ -622,7 +621,7 @@ while ($i < min($num,$limit))
if (!empty($obj->note_private) || !empty($obj->note_public))
{
print ' ';
- print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'';
+ print ''.img_picto($langs->trans("ViewPrivateNote"),'note').'';
print '';
}
diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php
index 302ad161241..d2d34cd523a 100644
--- a/htdocs/core/actions_printing.inc.php
+++ b/htdocs/core/actions_printing.inc.php
@@ -28,8 +28,7 @@
// Filename to print must be provided into 'file' parameter
// Print file
-if ($action == 'print_file' && $user->rights->printing->read)
-{
+if ($action == 'print_file' && $user->rights->printing->read) {
$langs->load("printing");
require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php';
$objectprint = new PrintingDriver($db);
@@ -55,7 +54,7 @@ if ($action == 'print_file' && $user->rights->printing->read)
$subdir = 'commande';
}
try {
- $ret = $printer->print_file(GETPOST('file', 'alpha'), $module, $subdir);
+ $ret = $printer->printFile(GETPOST('file', 'alpha'), $module, $subdir);
if ($ret > 0) {
//print ''.print_r($printer->errors, true).''; setEventMessages($printer->error, $printer->errors, 'errors'); diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 57483848c4e..364903c9cd7 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -53,6 +53,12 @@ $search_boxvalue=GETPOST('q', 'none'); $arrayresult=array(); // Define $searchform + +if (! empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) +{ + $arrayresult['searchintomember']=array('position'=>8, 'shortcut'=>'M', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); +} + if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) { $arrayresult['searchintothirdparty']=array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); @@ -63,11 +69,6 @@ if (! empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CON $arrayresult['searchintocontact']=array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); } -if (! empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) -{ - $arrayresult['searchintomember']=array('position'=>20, 'shortcut'=>'M', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); -} - if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) { diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 54d265bf6af..dd64a07b8d9 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -86,7 +86,7 @@ class box_factures_imp extends ModeleBoxes if ($user->rights->facture->lire) { - $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; $sql.= " s.code_client,"; $sql.= " s.logo,"; $sql.= " f.facnumber, f.date_lim_reglement as datelimite,"; @@ -134,9 +134,11 @@ class box_factures_imp extends ModeleBoxes $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite); + $societestatic->id = $objp->socid; $societestatic->name = $objp->name; $societestatic->client = 1; + $societestatic->email = $objp->email; $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 45998a78869..7562cd609c2 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -59,7 +59,11 @@ class CMailFile var $eol; var $eol2; - var $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; var $smtps; // Contains SMTPs object (if this method is used) var $phpmailer; // Contains PHPMailer object (if this method is used) @@ -385,13 +389,17 @@ class CMailFile // TODO if (! empty($moreinheader)) ... // Give the message a subject - $this->message->setSubject($this->encodetorfc2822($subject)); + try { + $result = $this->message->setSubject($subject); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } // Set the From address with an associative array //$this->message->setFrom(array('john@doe.com' => 'John Doe')); if (! empty($from)) { try { - $this->message->setFrom($this->getArrayAddress($from)); + $result = $this->message->setFrom($this->getArrayAddress($from)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } @@ -400,7 +408,7 @@ class CMailFile // Set the To addresses with an associative array if (! empty($to)) { try { - $this->message->setTo($this->getArrayAddress($to)); + $result = $this->message->setTo($this->getArrayAddress($to)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } @@ -408,13 +416,17 @@ class CMailFile if (! empty($replyto)) { try { - $this->message->SetReplyTo($this->getArrayAddress($replyto)); + $result = $this->message->SetReplyTo($this->getArrayAddress($replyto)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } } - $this->message->setCharSet($conf->file->character_set_client); + try { + $result = $this->message->setCharSet($conf->file->character_set_client); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } if (! empty($this->html)) { @@ -1027,7 +1039,7 @@ class CMailFile $mimedone=0; $out = ""; - if ($filename_list) + if (is_array($filename_list)) { $filename_list_size=count($filename_list); for($i=0;$i < $filename_list_size;$i++) @@ -1199,7 +1211,7 @@ class CMailFile /** * Attach an image to email (mode = 'mail') * - * @param array $images_list Tableau + * @param array $images_list Array of array image * @return string Chaine images encodees */ function write_images($images_list) @@ -1207,7 +1219,7 @@ class CMailFile // phpcs:enable $out = ''; - if ($images_list) + if (is_array($images_list)) { foreach ($images_list as $img) { diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index c2512af70ef..b6c334f7e1c 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -34,15 +34,18 @@ */ class CSMSFile { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - var $addr_from; - var $addr_to; - var $deferred; - var $priority; - var $class; - var $message; - var $nostop; + public $addr_from; + public $addr_to; + public $deferred; + public $priority; + public $class; + public $message; + public $nostop; /** diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index d18501d54d9..c67e3f5f59d 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -40,7 +40,10 @@ class AntiVir */ public $errors = array(); - var $output; + /** + * @var string Used to return message + */ + public $output; /** * @var DoliDB Database handler. diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index a4665701661..cf830048cc0 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -43,15 +43,15 @@ class Canvas */ public $errors = array(); - var $actiontype; + public $actiontype; - var $dirmodule; // Module directory - var $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - var $canvas; // Name of canvas (ex: company, individual, product, service, ...) - var $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - var $template_dir; // Initialized by getCanvas with templates directory - var $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance /** diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 2f9a8636c8b..f07916a7511 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -76,7 +76,6 @@ class Ccountry // extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a818bfe7a2f..3792aaf9327 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -33,7 +33,11 @@ */ abstract class CommonDocGenerator { - var $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; + protected $db; @@ -491,11 +495,11 @@ abstract class CommonDocGenerator /** * Define array with couple substitution key => substitution value * - * @param array $line Array of lines + * @param Object $line Object line * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_lines($line,$outputlangs) + function get_substitutionarray_lines($line, $outputlangs) { // phpcs:enable global $conf; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index e9be4b1f9da..b5b363db923 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -62,7 +62,7 @@ abstract class CommonInvoice extends CommonObject const TYPE_SITUATION = 5; /** - * Draft + * Draft status */ const STATUS_DRAFT = 0; @@ -431,11 +431,11 @@ abstract class CommonInvoice extends CommonObject { global $langs; if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); - if ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); - if ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); - if ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); - if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. - if ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); + elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); + elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); + elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. + elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } @@ -475,10 +475,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); - return $langs->trans('Bill'.$prefix.'StatusStarted'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); + else return $langs->trans('Bill'.$prefix.'StatusStarted'); } else { @@ -493,10 +493,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); - return $langs->trans('Bill'.$prefix.'StatusStarted'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); + else return $langs->trans('Bill'.$prefix.'StatusStarted'); } else { @@ -511,10 +511,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); - return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); + else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); } else { @@ -529,10 +529,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); - if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); - return img_picto($langs->trans('BillStatusStarted'),'statut3'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); + else return img_picto($langs->trans('BillStatusStarted'),'statut3'); } else { @@ -547,10 +547,10 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); - return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); + else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); } else { @@ -566,14 +566,14 @@ abstract class CommonInvoice extends CommonObject if (! $paye) { if ($status == 0) return ''.$langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0'); - if (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); - if ($alreadypaid <= 0) + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); + elseif ($alreadypaid <= 0) { if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' '.img_picto($langs->trans('StatusNotRefunded'),'statut1'); return ''.$langs->trans('Bill'.$prefix.'StatusNotPaid').' '.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); } - return ''.$langs->trans('Bill'.$prefix.'StatusStarted').' '.img_picto($langs->trans('BillStatusStarted'),'statut3'); + else return ''.$langs->trans('Bill'.$prefix.'StatusStarted').' '.img_picto($langs->trans('BillStatusStarted'),'statut3'); } else { @@ -587,7 +587,7 @@ abstract class CommonInvoice extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Renvoi une date limite de reglement de facture en fonction des - * conditions de reglements de la facture et date de facturation + * conditions de reglements de la facture et date de facturation. * * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. * @return date Date limite de reglement si ok, <0 si ko @@ -598,9 +598,11 @@ abstract class CommonInvoice extends CommonObject if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; - $cdr_nbjour=0; $cdr_type=0; $cdr_decalage=0; + $cdr_nbjour=0; + $cdr_type=0; + $cdr_decalage=0; - $sqltemp = 'SELECT c.type_cdr,c.nbjour,c.decalage'; + $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; else { @@ -629,12 +631,18 @@ abstract class CommonInvoice extends CommonObject /* Definition de la date limite */ - // 1 : ajout du nombre de jours - $datelim = $this->date + ($cdr_nbjour * 3600 * 24); - - // 2 : application de la regle "fin de mois" - if ($cdr_type == 1) + // 0 : ajout du nombre de jours + if ($cdr_type == 0) { + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); + + $datelim += ($cdr_decalage * 3600 * 24); + } + // 1 : application de la regle "fin de mois" + elseif ($cdr_type == 1) + { + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); + $mois=date('m', $datelim); $annee=date('Y', $datelim); if ($mois == 12) @@ -649,23 +657,24 @@ abstract class CommonInvoice extends CommonObject // On se deplace au debut du mois suivant, et on retire un jour $datelim=dol_mktime(12,0,0,$mois,1,$annee); $datelim -= (3600 * 24); - } - elseif($cdr_type == 2 && !empty($cdr_nbjour)) // Application de la règle, le N du mois courant ou suivant - { - $date_piece = dol_mktime(0,0,0,date('m', $this->date),date('d', $this->date),date('Y', $this->date)); // Sans les heures minutes et secondes - $date_lim_current = dol_mktime(0,0,0,date('m', $this->date),$cdr_nbjour,date('Y', $this->date)); // Sans les heures minutes et secondes - $date_lim_next = strtotime(date('Y-m-d', $date_lim_current).' +1month'); + $datelim += ($cdr_decalage * 3600 * 24); + } + // 2 : application de la règle, le N du mois courant ou suivant + elseif ($cdr_type == 2 && !empty($cdr_decalage)) + { + $datelim = $this->date + ($cdr_nbjour * 3600 * 24); + + $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes + $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes + $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month $diff = $date_piece - $date_lim_current; - if($diff < 0) $datelim = $date_lim_current; + if ($diff < 0) $datelim = $date_lim_current; else $datelim = $date_lim_next; - } - - // 3 : application du decalage - $datelim += ($cdr_decalage * 3600 * 24); + else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement; return $datelim; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7991bbb9ae9..a11cd3dd49e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -976,7 +976,7 @@ abstract class CommonObject * @param string $source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) * @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) - * @return array Array of contacts + * @return array|int Array of contacts, -1 if error */ function liste_contact($statut=-1,$source='external',$list=0,$code='') { @@ -1164,8 +1164,8 @@ abstract class CommonObject $sql.= " ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE ec.element_id = ".$id; $sql.= " AND ec.fk_socpeople = c.rowid"; - if ($source == 'internal') $sql.= " AND c.entity IN (0,".$conf->entity.")"; - if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('socpeople').")"; + if ($source == 'internal') $sql.= " AND c.entity IN (".getEntity('user').")"; + if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")"; $sql.= " AND ec.fk_c_type_contact = tc.rowid"; $sql.= " AND tc.element = '".$element."'"; $sql.= " AND tc.source = '".$source."'"; @@ -2899,6 +2899,7 @@ abstract class CommonObject // Special case if ($origin == 'order') $origin='commande'; if ($origin == 'invoice') $origin='facture'; + if ($origin == 'invoice_template') $origin='facturerec'; $this->db->begin(); @@ -2929,7 +2930,9 @@ abstract class CommonObject } /** - * Fetch array of objects linked to current object. Links are loaded into this->linkedObjects array and this->linkedObjectsIds + * Fetch array of objects linked to current object (object of enabled modules only). Links are loaded into + * this->linkedObjectsIds array and + * this->linkedObjects array if $loadalsoobjects = 1 * Possible usage for parameters: * - all parameters empty -> we look all link to current object (current object can be source or target) * - source id+type -> will get target list linked to source @@ -2937,17 +2940,18 @@ abstract class CommonObject * - source id+type + target type -> will get target list of the type * - target id+type + target source -> will get source list of the type * - * @param int $sourceid Object source id (if not defined, id of object) - * @param string $sourcetype Object source type (if not defined, element name of object) - * @param int $targetid Object target id (if not defined, id of object) - * @param string $targettype Object target type (if not defined, elemennt name of object) - * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided - * @param int $alsosametype 0=Return only links to object that differs from source. 1=Include also link to objects of same type. - * @param string $orderby SQL 'ORDER BY' clause - * @return int <0 if KO, >0 if OK + * @param int $sourceid Object source id (if not defined, id of object) + * @param string $sourcetype Object source type (if not defined, element name of object) + * @param int $targetid Object target id (if not defined, id of object) + * @param string $targettype Object target type (if not defined, elemennt name of object) + * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided + * @param int $alsosametype 0=Return only links to object that differs from source type. 1=Include also link to objects of same type. + * @param string $orderby SQL 'ORDER BY' clause + * @param int $loadalsoobjects Load also array this->linkedObjects (Use 0 to increase performances) + * @return int <0 if KO, >0 if OK * @see add_object_linked, updateObjectLinked, deleteObjectLinked */ - function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1,$orderby='sourcetype') + function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1,$orderby='sourcetype',$loadalsoobjects=1) { global $conf; @@ -2976,10 +2980,10 @@ abstract class CommonObject $targettype = (! empty($targettype) ? $targettype : $this->element); /*if (empty($sourceid) && empty($targetid)) - { - dol_syslog('Bad usage of function. No source nor target id defined (nor as parameter nor as object id)', LOG_ERR); - return -1; - }*/ + { + dol_syslog('Bad usage of function. No source nor target id defined (nor as parameter nor as object id)', LOG_ERR); + return -1; + }*/ // Links between objects are stored in table element_element $sql = 'SELECT rowid, fk_source, sourcetype, fk_target, targettype'; @@ -3041,7 +3045,8 @@ abstract class CommonObject if (! empty($this->linkedObjectsIds)) { - foreach($this->linkedObjectsIds as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) + $tmparray = $this->linkedObjectsIds; + foreach($tmparray as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...) { // Parse element/subelement (ex: project_task, cabinetmed_consultation, ...) $module = $element = $subelement = $objecttype; @@ -3107,21 +3112,28 @@ abstract class CommonObject // Here $module, $classfile and $classname are set if ($conf->$module->enabled && (($element != $this->element) || $alsosametype)) { - dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); - //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); - if (class_exists($classname)) + if ($loadalsoobjects) { - foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element + dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); + //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); + if (class_exists($classname)) { - $object = new $classname($this->db); - $ret = $object->fetch($objectid); - if ($ret >= 0) + foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element { - $this->linkedObjects[$objecttype][$i] = $object; + $object = new $classname($this->db); + $ret = $object->fetch($objectid); + if ($ret >= 0) + { + $this->linkedObjects[$objecttype][$i] = $object; + } } } } } + else + { + unset($this->linkedObjectsIds[$objecttype]); + } } } return 1; @@ -3824,6 +3836,7 @@ abstract class CommonObject print ' | ||
| '; // Description @@ -4911,6 +4924,9 @@ abstract class CommonObject } } + //dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG); + //dol_syslog("attributeType=".$attributeType, LOG_DEBUG); + switch ($attributeType) { case 'int': @@ -4924,6 +4940,21 @@ abstract class CommonObject $new_array_options[$key] = null; } break; + case 'double': + $value = price2num($value); + if (!is_numeric($value) && $value!='') + { + dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); + $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); + return -1; + } + elseif ($value=='') + { + $new_array_options[$key] = null; + } + //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); + $new_array_options[$key] = $value; + break; /*case 'select': // Not required, we chosed value='0' for undefined values if ($value=='-1') { @@ -5118,6 +5149,9 @@ abstract class CommonObject $attributeParam = $extrafields->attributes[$this->table_element]['param'][$key]; $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key]; + //dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG); + //dol_syslog("attributeType=".$attributeType, LOG_DEBUG); + switch ($attributeType) { case 'int': @@ -5131,6 +5165,21 @@ abstract class CommonObject $this->array_options["options_".$key] = null; } break; + case 'double': + $value = price2num($value); + if (!is_numeric($value) && $value!='') + { + dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG); + $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel); + return -1; + } + elseif ($value=='') + { + $this->array_options["options_".$key] = null; + } + //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); + $this->array_options["options_".$key] = $value; + break; /*case 'select': // Not required, we chosed value='0' for undefined values if ($value=='-1') { @@ -5222,37 +5271,34 @@ abstract class CommonObject $val=$this->fields[$key]; $out=''; - $type=''; - $param['options']=array(); - $size =$this->fields[$key]['size']; - // Because we work on extrafields - if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ - $param['options']=array($reg[1].':'.$reg[2]=>'N'); - $type ='link'; - }else if(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)){ - $param['options']=array($reg[1].':'.$reg[2]=>'N'); - $type ='link'; - }else if(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){ - - $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); - $type ='sellist'; - }else if(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)){ - - $param['options']=array(); - $type ='varchar'; - $size=$reg[1]; - }else if(preg_match('/varchar/', $val['type'])){ - - $param['options']=array(); - $type ='varchar'; - }else if(is_array($this->fields[$key]['arrayofkeyval'])){ - - $param['options']=$this->fields[$key]['arrayofkeyval']; - $type ='select'; - }else { - $param['options']=array(); - $type =$this->fields[$key]['type']; - } + $type=''; + $param = array(); + $param['options']=array(); + $size =$this->fields[$key]['size']; + // Because we work on extrafields + if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[1].':'.$reg[2]=>'N'); + $type ='link'; + } elseif(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)) { + $param['options']=array($reg[1].':'.$reg[2]=>'N'); + $type ='link'; + } elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); + $type ='sellist'; + } elseif(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)) { + $param['options']=array(); + $type ='varchar'; + $size=$reg[1]; + } elseif(preg_match('/varchar/', $val['type'])) { + $param['options']=array(); + $type ='varchar'; + } elseif(is_array($this->fields[$key]['arrayofkeyval'])) { + $param['options']=$this->fields[$key]['arrayofkeyval']; + $type ='select'; + } else { + $param['options']=array(); + $type =$this->fields[$key]['type']; + } $label=$this->fields[$key]['label']; //$elementtype=$this->fields[$key]['elementtype']; // Seems not used @@ -5329,7 +5375,7 @@ abstract class CommonObject if (!$required && $value == '') $value = '-1'; // TODO Must also support $moreparam - $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0); + $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } elseif (in_array($type,array('int','integer'))) { @@ -7288,7 +7334,7 @@ abstract class CommonObject $comment = new Comment($this->db); $result=$comment->fetchAllFor($this->element, $this->id); if ($result<0) { - $this->errors=array_merge($this->errors,$comment->errors); + $this->errors=array_merge($this->errors, $comment->errors); return -1; } else { $this->comments = $comment->comments; @@ -7305,4 +7351,20 @@ abstract class CommonObject { return count($this->comments); } + + /** + * Trim object parameters + * @param string[] $parameters array of parameters to trim + * + * @return void + */ + public function trimParameters($parameters) + { + if (!is_array($parameters)) return; + foreach ($parameters as $parameter) { + if (isset($this->$parameter)) { + $this->$parameter = trim($this->$parameter); + } + } + } } diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 6d4c32d82bb..d5bf6f3317e 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -1,10 +1,10 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo | |||
| '; print ''; print ' | '; @@ -6483,7 +6512,7 @@ class Form * @param int $useempty 1=Add empty line * @return string See option */ - function selectyesno($htmlname, $value='', $option=0, $disabled=false, $useempty='') + function selectyesno($htmlname, $value='', $option=0, $disabled=false, $useempty=0) { global $langs; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index e01e1f2ad65..25a3973cbd8 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -48,7 +48,6 @@ class FormActions function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 22fa73741ce..510b34c8f47 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -41,7 +41,6 @@ class FormAdmin function __construct($db) { $this->db = $db; - return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps @@ -56,7 +55,7 @@ class FormAdmin * @param int $showwarning Show a warning if language is not complete * @param int $disabled Disable edit of select * @param string $morecss Add more css styles - * @param int $showcode Add language code into label + * @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end * @param int $forcecombo Force to use combo box (so no ajax beautify effect) * @return string Return HTML select string with list of languages */ @@ -90,8 +89,9 @@ class FormAdmin foreach ($langs_available as $key => $value) { - $valuetoshow=$value; - if ($showcode) $valuetoshow=$key.' - '.$value; + $valuetoshow=$value; + if ($showcode == 1) $valuetoshow=$key.' - '.$value; + if ($showcode == 2) $valuetoshow=$value.' ('.$key.')'; if ($filter && is_array($filter)) { diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index c2c408801c4..eb08aab6de7 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -48,7 +48,6 @@ class FormBarCode function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 5c39bc0cef4..273a84cbc94 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -49,8 +49,6 @@ class FormCompany function __construct($db) { $this->db = $db; - - return 1; } diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 496d77f1f68..94747481cb0 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -46,7 +46,6 @@ class FormCron extends Form function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index c1bc479fc73..4a59e28f044 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -54,7 +54,6 @@ class FormFile { $this->db = $db; $this->numoffiles=0; - return 1; } @@ -128,11 +127,12 @@ class FormFile if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024; if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024; // Now $max and $maxphp are in Kb - if ($maxphp > 0) $max=min($max,$maxphp); + $maxmin = $max; + if ($maxphp > 0) $maxmin=min($max,$maxphp); - if ($max > 0) + if ($maxmin > 0) { - $out .= ''; + $out .= ''; } $out .= 'load('link'); $title = $langs->trans("LinkANewFile"); $out .= load_fiche_titre($title, null, null); @@ -213,19 +213,18 @@ class FormFile $out .= ''; $out .= ''; $out .= '|||