diff --git a/ChangeLog b/ChangeLog index a0470fee04a..06650828623 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,26 @@ Following changes may create regression for some external modules, but were nece exists, but if an external module need action on it, it must provides itself its trigger file. * Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', false) instead getEntity('xxx') or getEntity('xxx', 0) +***** ChangeLog for 5.0.3 compared to 5.0.2 ***** +FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty +FIX: #6813 +FIX: 6863 +FIX: #6877 +FIX: #6881 +FIX: Better sanitizing of search all parameter. +FIX: Correction with author and validator user on orders +FIX: dialog window with md theme must not be hidden by left menu part. +FIX: doactions hook missing in invoice model page +FIX: Fullname when member is a moral entity with no name. +FIX: Link to files on bank account tab broken with multicompany FIX: Link to preview on thirdparty broken with multicompany +FIX: New vat code not correctly implemented if "1 price per customer". +FIX: Pagination of invoices +FIX: pagination on resources +FIX: REST API not possible to add agendaevents +FIX: situation invoice broken due to the all percent application form inside addline form +FIX: SQL injection on user/index.php parameter search_statut. +FIX: XSS + ***** ChangeLog for 5.0.2 compared to 5.0.1 ***** FIX: #6468 + Fix missing translation FIX: #6517 #6525 Autocompletion of thirdparty after n chars not implemented @@ -236,7 +256,29 @@ Dolibarr better: - Method commande->set_availability(user, availability_id) removed from commande class, use method commande->availability(availability_id, notrigger). Dolibarr 5.0 was frozen before PHP 7.1 was released. Unit tests are successful on PHP 7.1 but we don't have enough -feedback to confirm all application is compatible. Current officiel supported PHP versions are PHP 5.3 to 7.0. +feedback to confirm whole application is compatible. Current officiel supported PHP versions are PHP 5.3 to 7.0. + + +***** ChangeLog for 4.0.6 to 4.0.5 ***** +FIX: #6613 Default subject for Supplier proposal emails is filled with a non-existing key +FIX: #6623 User card shows "Return to list" link even if the user has no rights to list users +FIX: #6636 Complete fix +FIX: #6669 User with no permission to edit customer invoices can see a edit button in project entry +FIX: #6671 Cannot remove thirdparty type with "#" in its name +FIX: #6673 Missing "nature" table header in thirdparty list +FIX: #6675 Restricted user with no agenda permissions can see a button to create appointment in thirdparty contact list +FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty +FIX: #6679 User with restricted supplier invoice permissions can edit project, payment conditions, payment mode +FIX: #6680 User with restricted supplier invoice permissions sees "reopen" button even if he has no permission to do it +FIX: #6813 +FIX: Correction with author and validator user on orders +FIX: doactions hook missing in invoice model page +FIX: dont get empty "Incoterms : - " string if no incoterm +FIX: dont lose supplier ref if no supplier price in database +FIX: forgotten parameter for right multicompany use +FIX: global $dateSelector isn't the good one, then date selector on objectline_create tpl was hidden +FIX: limit+1 dosn't show Total line +FIX: supplier order line were always created with rang = 0 ***** ChangeLog for 4.0.5 to 4.0.4 ***** diff --git a/build/debian/README.howto b/build/debian/README.howto index c94309ec2ef..1632e954237 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -444,3 +444,4 @@ Note that package 3.5.7 contains not only fixed for bugs reported to debian. It so it is a better solution to validate this maintenance release than applying a patch of the only CVE-2015-3935. After discussion with ..., it appears that security holes are enough to request this unblock request." +Note: If there is a response to ask more information, don't forget to remove the tag during answer. diff --git a/build/debian/source/lintian-overrides b/build/debian/source/lintian-overrides index b4c0956e90f..c878035b482 100644 --- a/build/debian/source/lintian-overrides +++ b/build/debian/source/lintian-overrides @@ -4,7 +4,12 @@ dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jsgantt/* dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jstz/* # Those are false positives, the files are their own sources since # they are not minified -source-is-missing htdocs/includes/jsgantt/jsgantt.js * -source-is-missing htdocs/includes/jquery/plugins/colorpicker/jquery.colorpicker.js * -source-is-missing htdocs/includes/jquery/plugins/select2/select2.js * -source-is-missing htdocs/includes/jquery/plugins/select2/select2_locale_ar.js * +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/a11yhelp/dialogs/lang/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/specialchar/dialogs/lang/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/lang/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/dialogs/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/*/filter/*.js +source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/templates/templates/default.js +source-is-missing htdocs/includes/mobiledetect/mobiledetectlib/Mobile_Detect.json +source-is-missing htdocs/includes/restler/framework/Luracast/Restler/explorer/lib/*.js + diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index ff9e0878750..b47ae023129 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -14,7 +14,7 @@ #---------------------------------------------------------------------------- use Cwd; - +use Term::ANSIColor; # Change this to defined target for option 98 and 99 $PROJECT="dolibarr"; @@ -313,20 +313,6 @@ foreach my $target (sort keys %CHOOSEDTARGET) { print "\n"; -# Build xml check file -#----------------------- -if ($CHOOSEDTARGET{'-CHKSUM'}) -{ - print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filecheck_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n"; - $ret=`php $SOURCE/build/generate_filelist_xml.php release=$MAJOR.$MINOR.$BUILD`; - print $ret."\n"; - # Copy to final dir - $NEWDESTI=$DESTI; - print "Copy \"$SOURCE/htdocs/install/filelist-$MAJOR.$MINOR.$BUILD.xml\" to $NEWDESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml\n"; - use File::Copy qw(copy); - copy "$SOURCE/htdocs/install/filelist-$MAJOR.$MINOR.$BUILD.xml", "$NEWDESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"; -} - #print join(',',sort keys %CHOOSEDTARGET)."\n"; @@ -335,7 +321,10 @@ if ($CHOOSEDTARGET{'-CHKSUM'}) $nboftargetok=0; $nboftargetneedbuildroot=0; $nbofpublishneedtag=0; +$nbofpublishneedchangelog=0; + foreach my $target (sort keys %CHOOSEDTARGET) { + if ($target eq '-CHKSUM') { $nbofpublishneedchangelog++; } if ($CHOOSEDTARGET{$target} < 0) { next; } if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP' && $target ne '-CHKSUM') { @@ -345,34 +334,31 @@ foreach my $target (sort keys %CHOOSEDTARGET) { } foreach my $target (sort keys %CHOOSEDPUBLISH) { if ($CHOOSEDPUBLISH{$target} < 0) { next; } - if ($target eq 'ASSO') { $nbofpublishneedtag++; } - if ($target eq 'SF') { $nbofpublishneedtag++; } + if ($target eq 'ASSO') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; } + if ($target eq 'SF') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; } $nboftargetok++; } + if ($nboftargetok) { - # Update GIT tag if required - #--------------------------- - if ($nbofpublishneedtag) + # Check Changelog + #---------------- + if ($nbofpublishneedchangelog) { - print "Go to directory $SOURCE\n"; - $olddir=getcwd(); - chdir("$SOURCE"); - # Test that the ChangeLog is ok $TMPBUILDTOCHECKCHANGELOG=$BUILD; $TMPBUILDTOCHECKCHANGELOG =~ s/\-rc\d*//; $TMPBUILDTOCHECKCHANGELOG =~ s/\-beta\d*//; - print "Check if ChangeLog is ok for version $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG\n"; + print "\nCheck if ChangeLog is ok for version $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG\n"; $ret=`grep "ChangeLog for $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG" "$SOURCE/ChangeLog" 2>&1`; if (! $ret) { - print "Error: The ChangeLogFile was not updated. Run the following command before building package for $MAJOR.$MINOR.$BUILD:\n"; + print color("yellow"), "Error: The ChangeLogFile was not updated. Run the following command before building package for $MAJOR.$MINOR.$BUILD:\n", color('reset'); } else { - print "ChangeLog for $MAJOR.$MINOR\.$BUILD was found into '$SOURCE/ChangeLog. But you can regenerate it with commande:'\n"; + print "ChangeLog for $MAJOR.$MINOR\.$BUILD was found into '$SOURCE/ChangeLog. But you can regenerate it with command:'\n"; } if (! $BUILD || $BUILD eq '0-rc') # For a major version { @@ -385,9 +371,39 @@ if ($nboftargetok) { print "\n"; if (! $ret) { - exit; + print "\nPress F to force and continue anyway (or other key to stop)... "; + my $WAITKEY=; + chomp($WAITKEY); + if ($WAITKEY ne 'F') + { + print "Canceled.\n"; + exit; + } } - + } + + # Build xml check file + #----------------------- + if ($CHOOSEDTARGET{'-CHKSUM'}) + { + print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filecheck_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n"; + $ret=`php $SOURCE/build/generate_filelist_xml.php release=$MAJOR.$MINOR.$BUILD`; + print $ret."\n"; + # Copy to final dir + $NEWDESTI=$DESTI; + print "Copy \"$SOURCE/htdocs/install/filelist-$MAJOR.$MINOR.$BUILD.xml\" to $NEWDESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml\n"; + use File::Copy qw(copy); + copy "$SOURCE/htdocs/install/filelist-$MAJOR.$MINOR.$BUILD.xml", "$NEWDESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"; + } + + # Update GIT tag if required + #--------------------------- + if ($nbofpublishneedtag) + { + print "Go to directory $SOURCE\n"; + $olddir=getcwd(); + chdir("$SOURCE"); + print 'Run git tag -a -m "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'" "'.$MAJOR.'.'.$MINOR.'.'.$BUILD.'"'."\n"; $ret=`git tag -a -m "$MAJOR.$MINOR.$BUILD" "$MAJOR.$MINOR.$BUILD" 2>&1`; if ($ret =~ /(already exists|existe déjà)/) @@ -517,6 +533,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimed*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimod*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/factory*`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/forceproject*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/lead*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/management*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/multicompany*`; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index ea98d678671..b42ef34d663 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT . '/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php'; @@ -222,7 +223,7 @@ if ($result) { // Now loop on each link of record in bank. foreach ( $links as $key => $val ) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert'))) // So we excluded 'company' here + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation'))) // So we excluded 'company' here { // We save tabtype for a future use, to remember what kind of payment it is $tabtype[$obj->rowid] = $links[$key]['type']; @@ -278,13 +279,15 @@ if ($result) { } else if ($links[$key]['type'] == 'payment_donation') { $paymentdonstatic->id = $links[$key]['url_id']; $paymentdonstatic->fk_donation = $links[$key]['url_id']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentDonation"); + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2); + $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; } else if ($links[$key]['type'] == 'payment_vat') { $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->label = $links[$key]['label']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentVat"); + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; } else if ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; @@ -415,6 +418,12 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->code_tiers = ''; + $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment + } else if ($tabtype[$key] == 'payment_donation') { + $bookkeeping->code_tiers = ''; + $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } $result = $bookkeeping->create($user); @@ -435,7 +444,7 @@ if (! $error && $action == 'writebookkeeping') { } } } - + // Third party if (! $errorforline) { @@ -475,7 +484,6 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice - $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -487,10 +495,18 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; - } else if ($tabtype[$key] == 'banktransfert') { - $bookkeeping->code_tiers = ''; + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat + } else if ($tabtype[$key] == 'payment_donation') { + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation + } else if ($tabtype[$key] == 'banktransfert') { + $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; } else { // FIXME Should be a temporary account ??? @@ -724,6 +740,8 @@ if (empty($action) || $action == 'view') { $invoicestatic = new Facture($db); $invoicesupplierstatic = new FactureFournisseur($db); $expensereportstatic = new ExpenseReport($db); + $vatstatic = new Tva($db); + $donationstatic = new Don($db); llxHeader('', $langs->trans("FinanceJournal")); @@ -793,7 +811,7 @@ if (empty($action) || $action == 'view') { } if ($reflabel == '(CustomerInvoicePayment)') { $reflabel = $langs->trans('Customer'); - } + } if ($reflabel == '(SocialContributionPayment)') { $reflabel = $langs->trans('SocialContribution'); } @@ -806,7 +824,7 @@ if (empty($action) || $action == 'view') { if ($reflabel == '(ExpenseReportPayment)') { $reflabel = $langs->trans('Employee'); } - + $ref=$reflabel; if ($tabtype[$key] == 'payment') { @@ -850,6 +868,34 @@ if (empty($action) || $action == 'view') { } else dol_print_error($db); } + elseif ($tabtype[$key] == 'payment_vat') + { + $sqlmid = 'SELECT v.rowid as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; + $sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $vatstatic->fetch($objmid->id); + $ref=$langs->trans("PaymentVat").' '.$vatstatic->getNomUrl(1); + } + else dol_print_error($db); + } + elseif ($tabtype[$key] == 'payment_donation') + { + $sqlmid = 'SELECT payd.fk_donation as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; + $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $donationstatic->fetch($objmid->id); + $ref=$langs->trans("Donation").' '.$donationstatic->getNomUrl(1); + } + else dol_print_error($db); + } /*$invoicestatic->id = $key; @@ -871,7 +917,7 @@ if (empty($action) || $action == 'view') { else print $accountoshow; print ""; if ($val['soclib'] == '') { - print "" . $bankstatic->label . " - " . $val["ref"] . ""; + print "" . $bankstatic->label . " - " . $reflabel . ""; } else { print "" . $bankstatic->label . " - " . $val['soclib'] . ""; } diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index bd9587a4440..44ec3ade889 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -49,6 +49,8 @@ $type = 'action'; * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -77,21 +79,6 @@ if (preg_match('/del_(.*)/',$action,$reg)) dol_print_error($db); } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - if (! $error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} if ($action == 'set') { dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); @@ -233,7 +220,7 @@ else if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print load_fiche_titre($langs->trans("AgendaModelModule"),'',''); - + print ''."\n"; print ''."\n"; print ''."\n"; @@ -243,13 +230,13 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print ''; print ''."\n"; - + clearstatcache(); - + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/action/doc/"); - + if (is_dir($dir)) { $handle=opendir($dir); @@ -261,10 +248,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); - + require_once $dir.'/'.$file; - $module = new $classname($db, new ActionComm($db)); - + $module = new $classname($db, new ActionComm($db)); + print ''."\n"; print "\n"; - + // Active if (in_array($name, $def)) { - + print '"; } - + // Default print ''; - + // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); @@ -326,7 +313,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; - + print "\n"; } } @@ -366,7 +353,7 @@ print ''."\n"; if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - + print ''; print ''."\n"; print ''."\n"; @@ -404,30 +391,30 @@ print ''."\n"; // AGENDA NOTIFICATION if ($conf->global->MAIN_FEATURES_LEVEL > 0) { - + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; } else { print ''.img_picto($langs->trans('Enabled'),'switch_on').''; print ''."\n"; - + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; } } diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index db81c9a325f..ba649fe9223 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -39,6 +39,8 @@ $action = GETPOST('action','alpha'); * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'setbarcodeproducton') { $res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", GETPOST('value'), 'chaine', 0, '', $conf->entity); @@ -72,33 +74,7 @@ else if ($action == 'update') else if ($action == 'updateengine') { // TODO Update engines. - -} -// define constants for models generator that need parameters -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - } - } - if (! $res > 0) $error++; - - if (! $error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } } if ($action && $action != 'setcoder' && $action != 'setModuleOptions') @@ -276,7 +252,7 @@ if ($resql) print '\n"; - + $i++; } } @@ -312,7 +288,7 @@ print ''; // Chemin du binaire genbarcode sous linux if (! isset($_SERVER['WINDIR'])) { - + print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -609,7 +582,7 @@ print "\n"; print ''; // Shippable Icon in List -/* Kept as hidden feature for the moment, result seems bugged. +/* Kept as hidden feature for the moment, result seems bugged. Whet is definition of "shippable" according to all different STOCK_CALCULATE_... options ? print ''; @@ -631,7 +604,7 @@ print ''; // Ask for payment bank during order if ($conf->banque->enabled) { - + print ''; } @@ -661,7 +634,7 @@ else // Ask for warehouse during order if ($conf->stock->enabled) { - + print ''; } diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 4c0a9572761..e2f865f61f6 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -50,6 +50,8 @@ if (empty($conf->global->CONTRACT_ADDON)) * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconst = GETPOST('maskconstcontract','alpha'); @@ -113,35 +115,6 @@ else if ($action == 'specimen') // For contract } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model else if ($action == 'set') { @@ -185,7 +158,7 @@ else if ($action == 'setmod') else if ($action == 'set_other') { - $freetext= GETPOST('CONTRACT_FREE_TEXT'); // No alpha here, we want exact string + $freetext= GETPOST('CONTRACT_FREE_TEXT','none'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); $draft= GETPOST('CONTRACT_DRAFT_WATERMARK','alpha'); @@ -265,7 +238,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - + print ''; @@ -501,7 +474,7 @@ print ''; print "\n"; $var=true; -$substitutionarray=pdf_getSubstitutionArray($langs); +$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount')); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 40e63de8aea..10d9ec5c282 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -120,11 +120,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac $error++; } } - + if (! $error) { $db->begin(); - + if ($action == 'add' || (GETPOST('add') && $action != 'update')) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; @@ -134,7 +134,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; $sql.= " WHERE rowid = ".$id; } - + $result = $db->query($sql); if ($result > 0) { @@ -223,7 +223,7 @@ print ''; print ''; $head=defaultvalues_prepare_head(); - + dol_fiche_head($head, $mode, '', -1, ''); if ($mode == 'sortorder') @@ -249,11 +249,11 @@ $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); // Field $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); -if ($mode != 'sortorder') +if ($mode != 'sortorder') { $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); } -else +else { $texthelp='field or alias.field'; $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); @@ -264,22 +264,14 @@ if ($mode != 'focus') { if ($mode != 'sortorder') { + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST + $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; - // See list into GETPOST - $texthelp.='__USERID__
'; - $texthelp.='__SUPERVISORID__
'; - $texthelp.='__MYCOUNTRYID__
'; - $texthelp.='__DAY__
'; - $texthelp.='__MONTH__
'; - $texthelp.='__YEAR__
'; - $texthelp.='__PREVIOUS_DAY__
'; - $texthelp.='__PREVIOUS_MONTH__
'; - $texthelp.='__PREVIOUS_YEAR__
'; - $texthelp.='__NEXT_DAY__
'; - $texthelp.='__NEXT_MONTH__
'; - $texthelp.='__NEXT_YEAR__
'; - if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__
'; - $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); + foreach($substitutionarray as $key => $val) + { + $texthelp.=$key.'
'; + } + $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click } else { @@ -351,18 +343,18 @@ if ($result) while ($i < $num) { $obj = $db->fetch_object($result); - + print "\n"; print '
'; - + // Page print ''."\n"; - + // Field print ''; } - + // Actions print ''; - + print "\n"; print "\n"; $i++; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 3c89960ede6..12d0b7951d5 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -57,6 +57,9 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) /* * Actions */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconst=GETPOST('maskconstexpedition','alpha'); @@ -75,14 +78,14 @@ if ($action == 'updateMask') else if ($action == 'set_param') { - $freetext=GETPOST('SHIPPING_FREE_TEXT'); // No alpha here, we want exact string + $freetext=GETPOST('SHIPPING_FREE_TEXT','none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); if ($res <= 0) { $error++; setEventMessages($langs->trans("Error"), null, 'errors'); } - + $draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha'); $res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); if ($res <= 0) @@ -142,35 +145,6 @@ else if ($action == 'specimen') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -else if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model else if ($action == 'set') { diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index eefe5747abd..24aaeede5b4 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -51,6 +51,9 @@ $type='expensereport'; /* * Actions */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconst=GETPOST('maskconst','alpha'); @@ -77,7 +80,7 @@ else if ($action == 'specimen') // For fiche inter $inter->initAsSpecimen(); $inter->status = 0; // Force statut draft to show watermark $inter->fk_statut = 0; // Force statut draft to show watermark - + // Search template files $file=''; $classname=''; $filefound=0; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); @@ -116,35 +119,6 @@ else if ($action == 'specimen') // For fiche inter } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model else if ($action == 'set') { @@ -193,13 +167,13 @@ else if ($action == 'setmod') else if ($action == 'setoptions') { $db->begin(); - - $freetext= GETPOST('EXPENSEREPORT_FREE_TEXT'); // No alpha here, we want exact string + + $freetext= GETPOST('EXPENSEREPORT_FREE_TEXT','none'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "EXPENSEREPORT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); - + $draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK','alpha'); $res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); - + if (! $res1 > 0 || ! $res2 > 0) $error++; if (! $error) @@ -276,7 +250,7 @@ foreach ($dirmodels as $reldir) if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - + print ''; @@ -399,7 +373,7 @@ foreach ($dirmodels as $reldir) if (file_exists($dir.'/'.$file)) { - + $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 8a57a62b144..57ff2321a12 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -51,6 +51,8 @@ $type='invoice'; * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconstinvoice=GETPOST('maskconstinvoice','alpha'); @@ -123,31 +125,6 @@ if ($action == 'specimen') } } -// define constants for models generator that need parameters -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - } - } - if (! $res > 0) $error++; - - if (! $error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model else if ($action == 'set') { @@ -229,7 +206,7 @@ if ($action == 'set_FACTURE_DRAFT_WATERMARK') if ($action == 'set_INVOICE_FREE_TEXT') { - $freetext = GETPOST('INVOICE_FREE_TEXT'); // No alpha here, we want exact string + $freetext = GETPOST('INVOICE_FREE_TEXT','none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); @@ -693,7 +670,7 @@ if ($resql) $i = 0; while ($i < $num) { - + $row = $db->fetch_row($resql); print ''; @@ -432,7 +406,7 @@ foreach ($dirmodels as $reldir) { if (file_exists($dir.'/'.$file)) { - + $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 7c23b62f230..f764f40c054 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -90,11 +90,11 @@ if ($action == 'update') $val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE'); if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity); else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'),'chaine',0,'',$conf->entity); - + $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val,'chaine',0,'',$conf->entity); - + $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val,'chaine',0,'',$conf->entity); @@ -109,25 +109,25 @@ if ($action == 'update') $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val,'chaine',0,'',$conf->entity); - + $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val,'chaine',0,'',$conf->entity); $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val,'chaine',0,'',$conf->entity); - + $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity); - + if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black) else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity); $val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'),array())))); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val,'chaine',0,'',$conf->entity); - + dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity); @@ -137,7 +137,7 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity); - + dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity); @@ -150,7 +150,7 @@ if ($action == 'update') if (preg_match('/([^\\/:]+)$/i',$_FILES[$varforimage]["name"],$reg)) { $original_file=$reg[1]; - + $isimage=image_format_supported($original_file); if ($isimage >= 0) { @@ -185,9 +185,9 @@ if ($action == 'update') } } } - - - + + + $_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); @@ -222,7 +222,7 @@ if ($action == 'edit') // Edit print ''; clearstatcache(); - + print '
'; print '
'.$langs->trans("Name").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
"; print (empty($module->name)?$name:$module->name); @@ -272,16 +259,16 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print "\n"; require_once $dir.$file; $module = new $classname($db,$specimenthirdparty); - if (method_exists($module,'info')) + if (method_exists($module,'info')) print $module->info($langs); - else + else print $module->description; print "'."\n"; if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") { @@ -301,7 +288,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"),'switch_off').''; print "'; if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") @@ -313,7 +300,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; } print ''; print ''.img_object($langs->trans("Preview"),'order').''; print '
'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'
'.$langs->trans('AGENDA_NOTIFICATION').' '."\n"; - + if (empty($conf->global->AGENDA_NOTIFICATION)) { print ''.img_picto($langs->trans('Disabled'),'switch_off').''; print '
'.$langs->trans('AGENDA_NOTIFICATION_SOUND').' '."\n"; - + if (empty($conf->global->AGENDA_NOTIFICATION_SOUND)) { print ''.img_picto($langs->trans('Disabled'),'switch_off').''; } else { print ''.img_picto($langs->trans('Enabled'),'switch_on').''; } - + print '
'; print $formbarcode->setBarcodeEncoder($obj->coder,$barcodelist,$obj->rowid,'form'.$i); print "
'.$langs->trans("GenbarcodeLocation").''; @@ -328,7 +304,7 @@ if (! isset($_SERVER['WINDIR'])) // Module products if (! empty($conf->product->enabled)) { - + print '
'.$langs->trans("SetDefaultBarcodeTypeProducts").''; @@ -339,7 +315,7 @@ if (! empty($conf->product->enabled)) // Module thirdparty if (! empty($conf->societe->enabled)) { - + print '
'.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index bc55eb4b9f6..f88dfc6f5a6 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -77,7 +77,7 @@ if ($action == 'setmod') if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') { - $freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT'); // No alpha here, we want exact string + $freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT','none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index d60144a3492..f4104e2007f 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -54,6 +54,8 @@ $type = 'order'; * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconstorder=GETPOST('maskconstorder','alpha'); @@ -118,35 +120,6 @@ else if ($action == 'specimen') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model else if ($action == 'set') { @@ -182,7 +155,7 @@ else if ($action == 'setdoc') else if ($action == 'setmod') { - // TODO Check if numbering module chosen can be activated + // TODO Check if numbering module chosen can be activated // by calling method canBeActivated dolibarr_set_const($db, "COMMANDE_ADDON",$value,'chaine',0,'',$conf->entity); @@ -207,7 +180,7 @@ else if ($action == 'set_COMMANDE_DRAFT_WATERMARK') else if ($action == 'set_ORDER_FREE_TEXT') { - $freetext = GETPOST("ORDER_FREE_TEXT"); // No alpha here, we want exact string + $freetext = GETPOST("ORDER_FREE_TEXT",'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); @@ -331,7 +304,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - + print '
'.$module->nom."\n"; print $module->info(); print '
'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").' '; if (! empty($conf->use_javascript_ajax)) @@ -653,7 +626,7 @@ if ($conf->banque->enabled) } else { - + print '
'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").' '.$langs->trans('NotAvailable').'
'; print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '; if (! empty($conf->use_javascript_ajax)) @@ -683,7 +656,7 @@ if ($conf->stock->enabled) } else { - + print '
'; print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '.$langs->trans('NotAvailable').'
'.$module->nom."\n"; print $module->info(); print ''.$langs->trans("Value").'
'; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page; else print ''; print ''; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; @@ -382,7 +374,7 @@ if ($result) else print ''; print ''; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) @@ -400,7 +392,7 @@ if ($result) print ''; } print '
'.$module->nom."\n"; print $module->info(); print '
'.$module->nom."\n"; print $module->info(); print '
'; print ''; @@ -264,7 +264,7 @@ if ($action == 'edit') // Edit print ''; print ''; print ''; - + // show input border /* print ''; print ''; */ - + // Disable javascript and ajax print ''; print ''; print ''; - + // Hide version link /* - + print ''; print ''; print ''; */ - + // Show bugtrack link print ''; // Message of the day on home page - print '
'.$langs->trans("Language").'
'.$langs->trans("DefaultMaxSizeShortList").' 
'.$langs->trans("showInputBorder").''; @@ -273,7 +273,7 @@ if ($action == 'edit') // Edit print ' 
'.$langs->trans("DisableJavascript").''; print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1); @@ -323,17 +323,17 @@ if ($action == 'edit') // Edit print ' 
'.$langs->trans("HideVersionLink").''; print $form->selectyesno('MAIN_HIDE_VERSION',$conf->global->MAIN_HIDE_VERSION,1); print ' 
'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).''; print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK',$conf->global->MAIN_BUGTRACK_ENABLELINK,1); @@ -349,7 +349,19 @@ if ($action == 'edit') // Edit print '
'.$langs->trans("MessageOfDay").''; + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); + complete_substitutions_array($substitutionarray, $langs); + $substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey'); + + print '
'; + $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; + foreach($substitutionarray as $key => $val) + { + $texthelp.=$key.'
'; + } + print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, ''); + + print '
'; $doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor->Create(); @@ -359,26 +371,36 @@ if ($action == 'edit') // Edit print '
'."\n"; print '
'; - + // Other print ''; print ''; print ''; print ''; - + // Message on login page - print ''."\n"; - + // Hide helpcenter link on login page print ''; print ''; print ''; - + // Background print ''; - + print '
'.$langs->trans("LoginPage").' 
'.$langs->trans("MessageLogin").''; + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','user')); + complete_substitutions_array($substitutionarray, $langs); + $substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey'); + print '
'; + $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; + foreach($substitutionarray as $key => $val) + { + $texthelp.=$key.'
'; + } + print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, ''); + print '
'; $doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%'); $doleditor->Create(); print '
'.$langs->trans("DisableLinkToHelpCenter").''; print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK',isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0,1); print ' 
'; print '
'; @@ -394,9 +416,9 @@ if ($action == 'edit') // Edit } print '
'; print '
'."\n"; - + print '
'; print ''; @@ -421,7 +443,7 @@ else // Show if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1); print ''; print ""; - + print ''.$langs->trans("EnableMultilangInterface").'' . yn($conf->global->MAIN_MULTILANGS) . ''; print ' '; print ""; @@ -441,7 +463,7 @@ else // Show print ''.$langs->trans("DefaultMaxSizeList").'' . $conf->global->MAIN_SIZE_LISTE_LIMIT . ''; print ' '; print ""; - + print ''.$langs->trans("DefaultMaxSizeShortList").'' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . ''; print ' '; print ""; @@ -452,7 +474,7 @@ else // Show print ' '; print ""; */ - + // Disable javascript/ajax print ''.$langs->trans("DisableJavascript").''; print yn($conf->global->MAIN_DISABLE_JAVASCRIPT).""; @@ -506,7 +528,7 @@ else // Show print ' '; print ''; */ - + // Show bugtrack link print ''.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).''; print yn($conf->global->MAIN_BUGTRACK_ENABLELINK).""; @@ -527,7 +549,7 @@ else // Show print ''."\n"; print '
'; - + // Login page print ''; print ''; @@ -537,7 +559,7 @@ else // Show if (isset($conf->global->MAIN_HOME)) print dol_htmlcleanlastbr($conf->global->MAIN_HOME); else print ' '; print ''."\n"; - + // Link to help center print ''; - + print '
'.$langs->trans("LoginPage").' 
'.$langs->trans("DisableLinkToHelpCenter").''; print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1); @@ -557,9 +579,9 @@ else // Show } print ''; print '
'."\n"; - + print '
'; print ''.$langs->trans("Modify").''; print '
'; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 74081266f43..0136f6cc9d9 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -47,10 +47,13 @@ $label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $type='delivery'; + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconstdelivery=GETPOST('maskconstdelivery','alpha'); @@ -71,7 +74,7 @@ if ($action == 'updateMask') if ($action == 'set_DELIVERY_FREE_TEXT') { - $free=GETPOST('DELIVERY_FREE_TEXT'); // No alpha here, we want exact string + $free=GETPOST('DELIVERY_FREE_TEXT','none'); // No alpha here, we want exact string $res=dolibarr_set_const($db, "DELIVERY_FREE_TEXT",$free,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; @@ -131,35 +134,6 @@ if ($action == 'specimen') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - if ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); @@ -259,7 +233,7 @@ foreach ($dirmodels as $reldir) if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - + print ''.$module->nom."\n"; print $module->info(); print ''; @@ -386,7 +360,7 @@ foreach ($dirmodels as $reldir) { if (file_exists($dir.'/'.$file)) { - + $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6f060ca136f..9ff909862a3 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -59,8 +59,8 @@ $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"),'switch_off'); $actl[1] = img_picto($langs->trans("Activated"),'switch_on'); -$listoffset=GETPOST('listoffset'); -$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; +$listoffset=GETPOST('listoffset','alpha'); +$listlimit=GETPOST('listlimit','alpha')>0?GETPOST('listlimit','alpha'):1000; $active = 1; $sortfield = GETPOST("sortfield",'alpha'); @@ -119,14 +119,14 @@ $formmail=new FormMail($db); if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tmp=FormMail::getAvailableSubstitKey('formemail'); - $tmp['__(AnyTransKey)__']='__(AnyTransKey)__'; + $tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__'; $helpsubstit = $langs->trans("AvailableVariables").':
'.implode('
', $tmp); $helpsubstitforlines = $langs->trans("AvailableVariables").':
'.implode('
', $tmp); } else { $tmp=FormMail::getAvailableSubstitKey('formemailwithlines'); - $tmp['__(AnyTransKey)__']='__(AnyTransKey)__'; + $tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__'; $helpsubstit = $langs->trans("AvailableVariables").':
'.implode('
', $tmp); $tmp=FormMail::getAvailableSubstitKey('formemailforlines'); $helpsubstitforlines = $langs->trans("AvailableVariables").':
'.implode('
', $tmp); @@ -175,7 +175,7 @@ $id = 25; if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) { - //$search_country_id = ''; + //$search_country_id = ''; } // Actions add or modify an entry into a dictionary @@ -479,12 +479,12 @@ if ($action != 'edit') if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } if ($fieldlist[$field]=='content') { $valuetoshow=''; } if ($fieldlist[$field]=='content_lines') { $valuetoshow=''; } - + if ($valuetoshow != '') { print ''; if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1,$valuetoshow).''; - else if (! empty($tabhelp[$id][$value])) + else if (! empty($tabhelp[$id][$value])) { if (in_array($value, array('topic'))) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover @@ -494,15 +494,15 @@ if ($action != 'edit') } if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } - + print ''; print ''; print ''; print ''; - + // Line to enter new values print ""; - + $obj = new stdClass(); // If data was already input, we define them in obj to populate input fields. if (GETPOST('actionadd')) @@ -513,12 +513,12 @@ if ($action != 'edit') $obj->$val=GETPOST($val); } } - + $tmpaction = 'create'; $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - + if (empty($reshook)) { if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') @@ -530,11 +530,11 @@ if ($action != 'edit') fieldList($fieldlist,$obj,$tabname[$id],'add'); } } - + print ''; print ''; print ""; - + $fieldsforcontent = array('content'); if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { @@ -545,7 +545,7 @@ if ($action != 'edit') print ''; if ($tmpfieldlist == 'content') print ''.$form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; if ($tmpfieldlist == 'content_lines') print ''.$form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'
'; - + if ($context != 'hide') { //print ''; @@ -556,7 +556,7 @@ if ($action != 'edit') } else print ' '; print ''; - if ($tmpfieldlist == 'content') + if ($tmpfieldlist == 'content') { print ''; if ($action != 'edit') @@ -568,12 +568,12 @@ if ($action != 'edit') //else print ''; print ''; } - - - + + + $colspan=count($fieldlist)+1; print ' '; // Keep   to have a line with enough height -} +} // List of available record in database @@ -590,7 +590,7 @@ if ($resql) if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); - + // There is several pages if ($num > $listlimit) { @@ -628,7 +628,7 @@ if ($resql) // Affiche nom du champ if ($showfield) { - if (! empty($tabhelp[$id][$value])) + if (! empty($tabhelp[$id][$value])) { if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover @@ -653,7 +653,7 @@ if ($resql) print ''; print ''; print ''; - + if ($num) { // Lines with values @@ -680,7 +680,7 @@ if ($resql) print '
'; print ''; print ''; - + $fieldsforcontent = array('content'); if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { @@ -691,11 +691,11 @@ if ($resql) $showfield = 1; $align = "left"; $valuetoshow = $obj->{$tmpfieldlist}; - + $class = 'tddict'; // Show value for field if ($showfield) { - + print ''; // To create an artificial CR for the current tr we are on $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) @@ -704,9 +704,9 @@ if ($resql) print $doleditor->Create(1); print ''; print ''; - + } - } + } } else { @@ -778,16 +778,16 @@ if ($resql) { $fieldsforcontent = array('content', 'content_lines'); } - foreach ($fieldsforcontent as $tmpfieldlist) + foreach ($fieldsforcontent as $tmpfieldlist) { $showfield = 1; $align = "left"; $valuetoshow = $obj->{$tmpfieldlist}; - + $class = 'tddict'; // Show value for field if ($showfield) { - + print ''; // To create an artificial CR for the current tr we are on $okforextended = true; if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) @@ -796,13 +796,13 @@ if ($resql) print $doleditor->Create(1); print ''; print ''; - + } }*/ } print "\n"; - - + + $i++; } } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5c4291ff3f3..fe735cb2499 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -430,7 +430,6 @@ print "
\n"; if ($mode == 'common') { - print '
'; if ($optioncss != '') print ''; print ''; @@ -763,13 +762,20 @@ if ($mode == 'common') } print "\n"; - } - print "\n"; - print '
'; + if ($oldfamily) + { + print "\n"; + print ''; + } dol_fiche_end(); + + // Show warning about external users + print info_admin(showModulesExludedForExternal($modules))."\n"; + + print ''; } if ($mode == 'marketplace') @@ -909,9 +915,6 @@ if ($mode == 'deploy') } -// Show warning about external users -if ($mode == 'common') print info_admin(showModulesExludedForExternal($modules))."\n"; - llxFooter(); diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 88f2d8cd1c1..061b9d50f6a 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -71,7 +71,7 @@ if ($action == 'setmod') if ($action == 'setparams') { - $freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS'); // No alpha here, we want exact string + $freetext = GETPOST('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS','none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS",$freetext,'chaine',0,'',$conf->entity); @@ -81,24 +81,11 @@ if ($action == 'setparams') { setEventMessages($langs->trans("Error"), null, 'errors'); } - - /* - $freetext = GETPOST('INVOICE_AUTO_FILLJS'); // No alpha here, we want exact string - - $res = dolibarr_set_const($db, "INVOICE_AUTO_FILLJS",$freetext,'chaine',0,'',$conf->entity); - - if (! $res > 0) $error++; - - if ($error) - { - setEventMessages($langs->trans("Error"), null, 'errors'); - }*/ - if (! $error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } - + } diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 7c8413a28a6..8acbf19f939 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -49,6 +49,9 @@ $type='propal'; /* * Actions */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + $error=0; if ($action == 'updateMask') { @@ -132,7 +135,7 @@ if ($action == 'set_PROPALE_DRAFT_WATERMARK') if ($action == 'set_PROPOSAL_FREE_TEXT') { - $freetext = GETPOST('PROPOSAL_FREE_TEXT'); // No alpha here, we want exact string + $freetext = GETPOST('PROPOSAL_FREE_TEXT','none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "PROPOSAL_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); @@ -180,35 +183,6 @@ if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model if ($action == 'set') { @@ -310,7 +284,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - + print ''.$module->nom."\n"; print $module->info(); print ''; @@ -614,7 +588,7 @@ print ''; /* Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation. if ($conf->banque->enabled) { - + print ''; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").' '; if (! empty($conf->use_javascript_ajax)) @@ -636,7 +610,7 @@ if ($conf->banque->enabled) } else { - + print ''; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").' '.$langs->trans('NotAvailable').''; } diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index d408657ac8c..17501cdb4f9 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -172,7 +172,7 @@ if ($action == 'addcat') if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') { - $freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT','none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); @@ -251,7 +251,7 @@ foreach ($dirmodels as $reldir) if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - + print ''.$module->nom."\n"; print $module->info(); print ''; @@ -370,7 +370,7 @@ foreach ($dirmodels as $reldir) { while (($file = readdir($handle))!==false) { - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) { $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); @@ -378,7 +378,7 @@ foreach ($dirmodels as $reldir) require_once $dir.'/'.$file; $module = new $classname($db, new FactureFournisseur($db)); - + print "\n"; print ""; print (empty($module->name)?$name:$module->name); diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index acce3a38c7c..13499af551a 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -169,7 +169,7 @@ else if ($action == 'addcat') else if ($action == 'set_SUPPLIER_ORDER_OTHER') { - $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT','none'); // No alpha here, we want exact string $doubleapproval = GETPOST('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED','alpha'); $doubleapproval = price2num($doubleapproval ); @@ -280,7 +280,7 @@ foreach ($dirmodels as $reldir) if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - + print ''.$module->nom."\n"; print $module->info(); print ''; @@ -402,7 +402,7 @@ foreach ($dirmodels as $reldir) require_once $dir.'/'.$file; $module = new $classname($db, new CommandeFournisseur($db)); - + print "\n"; print ""; print (empty($module->name)?$name:$module->name); @@ -502,14 +502,14 @@ $var=false; print ''; print ''; print "\n"; - + //} // Ask for payment bank during supplier order /* Kept as hidden for the moment if ($conf->banque->enabled) { - + print ''; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").' '; if (! empty($conf->use_javascript_ajax)) @@ -531,7 +531,7 @@ if ($conf->banque->enabled) } else { - + print ''; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER").' '.$langs->trans('NotAvailable').''; } diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index adaa114b1ca..4227f4d4221 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -47,6 +47,8 @@ $type='supplier_payment'; * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconstsupplierpayment=GETPOST('maskconstsupplierpayment','alpha'); @@ -68,31 +70,6 @@ if ($action == 'updateMask') dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); } -// define constants for models generator that need parameters -else if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - } - } - if (! $res > 0) $error++; - - if (! $error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model else if ($action == 'set') { @@ -195,7 +172,7 @@ dol_fiche_head($head, 'supplierpayment', $langs->trans("Suppliers"), -1, 'compan */ if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMENT_ADDON = 'mod_supplier_payment_bronan'; - + print load_fiche_titre($langs->trans("PaymentsNumberingModule"), '', ''); // Load array def with activated templates @@ -265,7 +242,7 @@ foreach ($dirmodels as $reldir) require_once $dir.$filebis; $module = new $classname($db); - + // Show modules according to features level if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; @@ -375,7 +352,7 @@ foreach ($dirmodels as $reldir) { while (($file = readdir($handle))!==false) { - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) { $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); @@ -383,7 +360,7 @@ foreach ($dirmodels as $reldir) require_once $dir.'/'.$file; $module = new $classname($db, new PaiementFourn($db)); - + print "\n"; print ""; print (empty($module->name)?$name:$module->name); diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 8a8d2a181a4..8c52ee83dda 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -41,10 +41,15 @@ $label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $type='supplier_proposal'; +$error=0; + + /* * Actions */ -$error=0; + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconstsupplier_proposal=GETPOST('maskconstsupplier_proposal','alpha'); @@ -127,7 +132,7 @@ if ($action == 'set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK') if ($action == 'set_SUPPLIER_PROPOSAL_FREE_TEXT') { - $freetext = GETPOST('SUPPLIER_PROPOSAL_FREE_TEXT'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_PROPOSAL_FREE_TEXT','none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "SUPPLIER_PROPOSAL_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); @@ -159,35 +164,6 @@ if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model if ($action == 'set') { @@ -289,7 +265,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - + print ''.$module->nom."\n"; print $module->info(); print ''; @@ -567,7 +543,7 @@ print ''; if ($conf->banque->enabled) { - + print ''; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; if (! empty($conf->use_javascript_ajax)) @@ -589,7 +565,7 @@ if ($conf->banque->enabled) } else { - + print ''; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').''; } diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 0c7574b7ec4..31efcb22474 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -47,37 +47,9 @@ $type='user'; * Action */ -// Activate a model +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} -elseif ($action == 'set_default') +if ($action == 'set_default') { $ret = addDocumentModel($value, $type, $label, $scandir); $res = true; diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 4642e6d3183..8d098ee6923 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -47,37 +47,9 @@ $type='group'; * Action */ -// Activate a model +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} -elseif ($action == 'set_default') +if ($action == 'set_default') { $ret = addDocumentModel($value, $type, $label, $scandir); $res = true; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 02ee84dc2de..eb2eddb3197 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1208,7 +1208,7 @@ if ($id > 0) $out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewCal").''; $out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); - $out.=''.$langs->trans("ViewWeek").''; + $out.=''.$langs->trans("ViewWeek").''; $out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewDay").''; $linkback.=$out; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 50ccf788bf5..86e8dd893f5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -54,7 +54,7 @@ class Facture extends CommonInvoice public $fk_element = 'fk_facture'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='bill'; - + /** * {@inheritdoc} */ @@ -243,7 +243,7 @@ class Facture extends CommonInvoice if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; if (empty($this->entity)) $this->entity = $conf->entity; - + // Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate) if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); @@ -280,7 +280,7 @@ class Facture extends CommonInvoice if ($this->fac_rec > 0) { $this->fk_fac_rec_source = $this->fac_rec; - + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; $_facrec = new FactureRec($this->db); $result=$_facrec->fetch($this->fac_rec); @@ -288,7 +288,7 @@ class Facture extends CommonInvoice $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template $this->entity = $_facrec->entity; // Invoice created in same entity than template - + // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; $this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public; @@ -301,7 +301,7 @@ class Facture extends CommonInvoice // Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result $this->total_ht = $_facrec->total_ht; $this->total_ttc = $_facrec->total_ttc; - + // Fields always coming from template $this->remise_absolue = $_facrec->remise_absolue; $this->remise_percent = $_facrec->remise_percent; @@ -360,9 +360,10 @@ class Facture extends CommonInvoice '__INVOICE_YEAR__' => dol_print_date($this->date, '%Y'), '__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'), ); - + + $substitutionisok=true; complete_substitutions_array($substitutionarray, $outputlangs); - + $this->note_public=make_substitutions($this->note_public,$substitutionarray); $this->note_private=make_substitutions($this->note_private,$substitutionarray); } @@ -472,7 +473,7 @@ class Facture extends CommonInvoice } } } - + if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object { $originforcontact = $this->origin; @@ -483,7 +484,7 @@ class Facture extends CommonInvoice $exp = new Expedition($this->db); $exp->fetch($this->origin_id); $exp->fetchObjectLinked(); - if (count($exp->linkedObjectsIds['commande']) > 0) + if (count($exp->linkedObjectsIds['commande']) > 0) { foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { @@ -493,10 +494,10 @@ class Facture extends CommonInvoice } } } - + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; - + $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { @@ -555,11 +556,11 @@ class Facture extends CommonInvoice foreach ($this->lines as $i => $val) { $line = $this->lines[$i]; - + // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object. if (! is_object($line)) $line = (object) $line; - + if (($line->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 { // Reset fk_parent_line for no child products and special product @@ -1060,7 +1061,7 @@ class Facture extends CommonInvoice if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice $label=''; - + if ($user->rights->facture->lire) { $label = '' . $langs->trans("ShowInvoice") . ''; if (! empty($this->ref)) @@ -1079,7 +1080,7 @@ class Facture extends CommonInvoice if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref; if ($moretitle) $label.=' - '.$moretitle; } - + $linkclose=''; if (empty($notooltip) && $user->rights->facture->lire) { @@ -1113,7 +1114,7 @@ class Facture extends CommonInvoice $result.=''; } } - + return $result; } @@ -1321,7 +1322,7 @@ class Facture extends CommonInvoice $line->qty = $objp->qty; $line->subprice = $objp->subprice; - $line->vat_src_code = $objp->vat_src_code; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -1574,7 +1575,7 @@ class Facture extends CommonInvoice $arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false); $facligne->pa_ht = $arraytmp['pa_total']; } - + $facligne->total_ht = -$remise->amount_ht; $facligne->total_tva = -$remise->amount_tva; $facligne->total_ttc = -$remise->amount_ttc; @@ -1628,7 +1629,7 @@ class Facture extends CommonInvoice function set_ref_client($ref_client, $notrigger=0) { global $user; - + $error=0; $this->db->begin(); @@ -2457,7 +2458,7 @@ class Facture extends CommonInvoice if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); - + // Clean vat code $vat_src_code=''; if (preg_match('/\((.*)\)/', $txtva, $reg)) @@ -2465,7 +2466,7 @@ class Facture extends CommonInvoice $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - + $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu_ht=price2num($pu_ht); @@ -2650,7 +2651,7 @@ class Facture extends CommonInvoice * @param double $pu_ht_devise Unit price in currency * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $pu_ht_devise = 0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0) { global $conf,$user; // Deprecation warning @@ -2770,14 +2771,14 @@ class Facture extends CommonInvoice $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative - + $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; - + $this->line->remise_percent = $remise_percent; $this->line->subprice = ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->date_start = $date_start; @@ -2896,7 +2897,7 @@ class Facture extends CommonInvoice function deleteline($rowid) { global $user; - + dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); if (! $this->brouillon) @@ -2922,13 +2923,13 @@ class Facture extends CommonInvoice } $line=new FactureLigne($this->db); - + $line->context = $this->context; // For triggers $result = $line->fetch($rowid); if (! ($result > 0)) dol_print_error($db, $line->error, $line->errors); - + if ($line->delete($user) > 0) { $result=$this->update_price(1); @@ -4292,7 +4293,7 @@ class FactureLigne extends CommonInvoiceLine $this->fk_unit = $objp->fk_unit; $this->fk_user_modif = $objp->fk_user_modif; $this->fk_user_author = $objp->fk_user_author; - + $this->situation_percent = $objp->situation_percent; $this->fk_prev_id = $objp->fk_prev_id; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 90ba6a22431..ab04278ea84 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -252,7 +252,7 @@ class BonPrelevement extends CommonObject function getErrorString($error) { global $langs; - + $errors = array(); $errors[1027] = $langs->trans("DateInvalid"); @@ -813,7 +813,7 @@ class BonPrelevement extends CommonObject dol_syslog(__METHOD__."::Read invoices error ".$this->db->error(), LOG_ERR); } } - + if (! $error) { require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; @@ -834,7 +834,7 @@ class BonPrelevement extends CommonObject { $bac = new CompanyBankAccount($this->db); $bac->fetch(0,$soc->id); - + if ($bac->verif() >= 1) //if (true) { @@ -867,7 +867,7 @@ class BonPrelevement extends CommonObject } $ok=0; - + // Withdraw invoices in factures_prev array $out=count($factures_prev)." invoices will be withdrawn."; //print $out."\n"; @@ -920,7 +920,7 @@ class BonPrelevement extends CommonObject $dir=$conf->prelevement->dir_output.'/receipts'; if (! is_dir($dir)) dol_mkdir($dir); - + $this->filename = $dir.'/'.$ref.'.xml'; // Create withdraw receipt in database @@ -1028,7 +1028,7 @@ class BonPrelevement extends CommonObject $this->emetteur_bic = $account->bic; $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; - + $this->raison_sociale = $account->proprio; } @@ -1272,16 +1272,6 @@ class BonPrelevement extends CommonObject * section Debiteur (sepa Debiteurs bloc lines) */ - /*$tmp_invoices = array(); - - $sql = "SELECT f.facnumber as fac FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."prelevement_facture as pf, ".MAIN_DB_PREFIX."societe as soc, ".MAIN_DB_PREFIX."c_country as p, ".MAIN_DB_PREFIX."societe_rib as rib WHERE pl.fk_prelevement_bons = ".$this->id." AND pl.rowid = pf.fk_prelevement_lignes AND pf.fk_facture = f.rowid AND soc.fk_pays = p.rowid AND soc.rowid = f.fk_soc AND rib.fk_soc = f.fk_soc AND rib.default_rib = 1"; - $resql=$this->db->query($sql); - if ($resql) { - while ($objfac = $this->db->fetch_object($resql)) { - $tmp_invoices[] = $objfac->fac; - } - }*/ - $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,"; $sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; $sql.= " f.facnumber as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum"; @@ -1365,35 +1355,6 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ''.$CrLf); - - /*$sql = "SELECT pl.amount"; - $sql.= " FROM"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; - $sql.= " ".MAIN_DB_PREFIX."facture as f,"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_facture as pf"; - $sql.= " WHERE pl.fk_prelevement_bons = ".$this->id; - $sql.= " AND pl.rowid = pf.fk_prelevement_lignes"; - $sql.= " AND pf.fk_facture = f.rowid"; - - //Lines - $i = 0; - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $this->total = $this->total + $obj->amount; - $i++; - } - } - else - { - $result = -2; - }*/ - } // Build file for Other Countries with unknow format @@ -1580,11 +1541,11 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.strtoupper(dol_string_unaccent($row_nom)).''.$CrLf; + $XML_DEBITOR .=' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$row_country_code.''.$CrLf; - $XML_DEBITOR .=' '.dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))).''.$CrLf; - $XML_DEBITOR .=' '.dol_string_unaccent($row_zip.' '.$row_town).''.$CrLf; + $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).''.$CrLf; + $XML_DEBITOR .=' '.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1679,7 +1640,7 @@ class BonPrelevement extends CommonObject * @return string String with SEPA Sender */ function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n') - { + { // SEPA INITIALISATION global $conf; @@ -1698,12 +1659,12 @@ class BonPrelevement extends CommonObject $this->emetteur_number_key = $account->cle_rib; $this->emetteur_iban = $account->iban; $this->emetteur_bic = $account->bic; - + $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; - + $this->raison_sociale = $account->proprio; } - + // Récupération info demandeur $sql = "SELECT rowid, ref"; $sql.= " FROM"; diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 076978a86fb..8b4d3299f9c 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2003 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2011-2014 Alexandre Spangaro + * Copyright (C) 2011-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->load("compta"); $langs->load("bills"); @@ -94,10 +95,10 @@ llxHeader('', $langs->trans("VATPayments")); $form = new Form($db); $formother=new FormOther($db); $tva_static = new Tva($db); -$accountstatic = new Account($db); +$bankstatic = new Account($db); $sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,"; -$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; +$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; @@ -227,19 +228,22 @@ if ($result) { print ''; if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; - $accountstatic->label=$obj->blabel; - print $accountstatic->getNomUrl(1); - } - else print ' '; - print ''; - } + { + $bankstatic->id=$obj->bid; + $bankstatic->ref=$obj->bref; + $bankstatic->number=$obj->bnumber; + $bankstatic->account_number=$obj->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($obj->fk_accountancy_journal); + $bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + + $bankstatic->label=$obj->blabel; + print $bankstatic->getNomUrl(1); + } + else print ' '; + print ''; + } // Amount $total = $total + $obj->amount; print "".price($obj->amount).""; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9632d1766e6..d40e41013dd 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -46,7 +46,7 @@ class Contrat extends CommonObject public $fk_element='fk_contrat'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='contract'; - + /** * {@inheritdoc} */ @@ -530,7 +530,7 @@ class Contrat extends CommonObject $this->fin_validite = $this->db->jdate($result["fin_validite"]); $this->date_cloture = $this->db->jdate($result["date_cloture"]); - + $this->user_author_id = $result["fk_user_author"]; $this->commercial_signature_id = $result["fk_commercial_signature"]; @@ -613,7 +613,7 @@ class Contrat extends CommonObject $this->lines=array(); $pos = 0; - + // Selectionne les lignes contrats liees a un produit $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,"; $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; @@ -1858,7 +1858,7 @@ class Contrat extends CommonObject $url = DOL_URL_ROOT.'/contrat/card.php?id='.$this->id; $picto = 'contract'; $label = ''; - + if ($user->rights->contrat->lire) { $label = ''.$langs->trans("ShowContract").''; $label .= '
'.$langs->trans('Ref').': '.$this->ref; @@ -1874,7 +1874,7 @@ class Contrat extends CommonObject $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); } } - + $linkclose=''; if (empty($notooltip) && $user->rights->contrat->lire) { @@ -1890,7 +1890,7 @@ class Contrat extends CommonObject $linkstart = ''; $linkend=''; - + if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); if ($withpicto && $withpicto != 2) $result.=' '; $result.=$linkstart.$this->ref.$linkend; @@ -2225,7 +2225,11 @@ class Contrat extends CommonObject $line->total_ht=90; $line->total_ttc=107.64; // 90 * 1.196 $line->total_tva=17.64; - if ($num_prods > 0) + $line->date_ouverture = dol_now() - 200000; + $line->date_ouverture_prevue = dol_now() - 500000; + $line->date_fin_validite = dol_now() + 500000; + $line->date_cloture = dol_now() - 100000; + if ($num_prods > 0) { $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; @@ -2233,11 +2237,6 @@ class Contrat extends CommonObject $this->lines[$xnbp]=$line; $xnbp++; } - - $this->amount_ht = $xnbp*100; - $this->total_ht = $xnbp*100; - $this->total_tva = $xnbp*19.6; - $this->total_ttc = $xnbp*119.6; } /** @@ -2750,6 +2749,8 @@ class ContratLigne extends CommonObjectLine if (empty($this->total_ht)) $this->total_ht = 0; if (empty($this->total_tva)) $this->total_tva = 0; if (empty($this->total_ttc)) $this->total_ttc = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; // Check parameters // Put here code to add control on parameters values diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 92d1011b923..fde828fd6d4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -24,20 +24,22 @@ // $massaction must be defined // $objectclass and $$objectlabel must be defined -// $uploaddir (example $conf->projet->dir_output . "/";) +// $parameters, $object, $action must be defined for the hook. + +// $uploaddir may be defined (example to $conf->projet->dir_output."/";) // $toselect may be defined // Protection -if (empty($objectclass) || empty($uploaddir)) +if (empty($objectclass) || empty($uploaddir)) { dol_print_error(null, 'include of actions_massactions.inc.php is done but var $massaction or $objectclass or $uploaddir was not defined'); exit; } -// Mass actions. Controls on number of lines checked -$maxformassaction=1000; +// Mass actions. Controls on number of lines checked. +$maxformassaction=(empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS)?1000:$conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); if (! empty($massaction) && count($toselect) < 1) { $error++; @@ -87,7 +89,7 @@ if (! $error && $massaction == 'confirm_presend') } } //var_dump($listofobjectthirdparties);exit; - + foreach ($listofobjectthirdparties as $thirdpartyid) { $result = $thirdparty->fetch($thirdpartyid); @@ -144,7 +146,7 @@ if (! $error && $massaction == 'confirm_presend') { //var_dump($object); //var_dump($thirdpartyid.' - '.$objectid.' - '.$object->statut); - + if ($objectclass == 'Facture' && $object->statut != Facture::STATUS_VALIDATED) { $nbignored++; @@ -157,7 +159,7 @@ if (! $error && $massaction == 'confirm_presend') $resaction.='
'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction',$object->ref).'

'; continue; } - + // Read document // TODO Use future field $object->fullpathdoc to know where is stored default file // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. @@ -202,7 +204,7 @@ if (! $error && $massaction == 'confirm_presend') dol_syslog('Failed to read file: '.$file, LOG_WARNING); continue; } - + //var_dump($listofqualifiedref); } @@ -252,9 +254,9 @@ if (! $error && $massaction == 'confirm_presend') $filepath = $attachedfiles['paths']; $filename = $attachedfiles['names']; $mimetype = $attachedfiles['mimes']; - + //var_dump($filepath); - + // Send mail require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'); $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1); @@ -280,7 +282,7 @@ if (! $error && $massaction == 'confirm_presend') if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO'; if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ - + $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { @@ -290,7 +292,7 @@ if (! $error && $massaction == 'confirm_presend') $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=''; - + // Initialisation donnees $object->sendtoid = 0; $object->actionmsg = $actionmsg; // Long text @@ -335,7 +337,7 @@ if (! $error && $massaction == 'confirm_presend') $resaction.=$langs->trans("NbSelected").': '.count($toselect)."\n
"; $resaction.=$langs->trans("NbIgnored").': '.($nbignored?$nbignored:0)."\n
"; $resaction.=$langs->trans("NbSent").': '.($nbsent?$nbsent:0)."\n
"; - + if ($nbsent) { $action=''; // Do not show form post if there was at least one successfull sent @@ -359,7 +361,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - + $objecttmp=new $objectclass($db); $listofobjectid=array(); $listofobjectthirdparties=array(); @@ -425,21 +427,21 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se if (count($files)>0) { - + $now=dol_now(); $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; - + $input_files = ''; foreach($files as $f) { $input_files.=' '.escapeshellarg($f); } - + $cmd = 'pdftk '.$input_files.' cat output '.escapeshellarg($file); exec($cmd); - + if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - + $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); } @@ -447,7 +449,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se { setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } - + } else { // Create empty PDF @@ -481,7 +483,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se // Defined name of merged file $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); $filename=preg_replace('/\s/','_',$filename); - + // Save merged file if ($filter=='paye:0') { @@ -565,6 +567,11 @@ if (! $error && $massaction == 'delete' && $permtodelete) //var_dump($listofobjectthirdparties);exit; } +$parameters['toselect']=$toselect; +$parameters['uploaddir']=$uploaddir; + +$reshook=$hookmanager->executeHooks('doMassActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php new file mode 100644 index 00000000000..03b33b19eb1 --- /dev/null +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -0,0 +1,86 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/actions_setnotes.inc.php + * \brief Code for actions on setting notes of object page + */ + + +// $action must be defined +// $_FILES may be defined +// $nomessageinsetmoduleoptions can be set to 1 + +// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) +if ($action == 'setModuleOptions') +{ + $db->begin(); + + // Process common param fields + foreach($_POST as $key => $val) + { + if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... + { + $param=GETPOST("param".$reg[1],'alpha'); + $value=GETPOST("value".$reg[1],'alpha'); + if ($param) + { + $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + } + } + + // Process upload fields + if (GETPOST('upload','alpha') && GETPOST('keyforuploaddir','aZ09')) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $keyforuploaddir=GETPOST('keyforuploaddir','aZ09'); + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->$keyforuploaddir))); + foreach($listofdir as $key=>$tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); + if (! $tmpdir) { + unset($listofdir[$key]); continue; + } + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); + else + { + $upload_dir=$tmpdir; + } + } + if ($upload_dir) + { + $result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', ''); + if ($result <= 0) $error++; + } + } + + if (! $error) + { + $db->commit(); + if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + $db->rollback(); + if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } +} + diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 4fb973160d4..4fad0149a5b 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -24,7 +24,18 @@ /** - * Parent class of graph classes + * Class to build graphs. + * Usage is: + * $dolgraph=new DolGraph(); + * $dolgraph->SetTitle($langs->transnoentities('Tracking_Projects_Pourcent').'
'.$langs->transnoentities('Tracking_IndicatorDefGraph').'%'); + * $dolgraph->SetMaxValue(50); + * $dolgraph->SetData($data); + * $dolgraph->setShowLegend(1); + * $dolgraph->setShowPercent(1); + * $dolgraph->SetType(array('pie')); + * $dolgraph->setWidth('100%'); + * $dolgraph->draw('idofgraph'); + * print $dolgraph->show(); */ class DolGraph { @@ -780,9 +791,9 @@ class DolGraph /** * Build a graph using JFlot library. Input when calling this method should be: - * $this->data = array(array( 0=>'labelxA', 1=>yA), array('labelxB',yB)); or + * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); + * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // TODO Syntax not supported. Removed when dol_print_graph_removed - * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // when there is n series to show for each x * $this->legend= array("Val1",...,"Valn"); // list of n series name * $this->type = array('bars',...'lines'); or array('pie') * $this->mode = 'depth' ??? @@ -798,7 +809,7 @@ class DolGraph { global $artichow_defaultfont; - dol_syslog(get_class($this)."::draw_jflot this->type=".join(',',$this->type)); + dol_syslog(get_class($this)."::draw_jflot this->type=".join(',',$this->type)." this->MaxValue=".$this->MaxValue); if (empty($this->width) && empty($this->height)) { @@ -808,7 +819,7 @@ class DolGraph $legends=array(); $nblot=count($this->data[0])-1; // -1 to remove legend - if ($nblot < 0) dol_print_error('Bad value for property ->data. Must be set by mydolgraph->SetData before callinf mydolgrapgh->draw'); + if ($nblot < 0) dol_print_error('', 'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw'); $firstlot=0; // Works with line but not with bars //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c89fc593745..bd1daca8886 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1681,7 +1681,7 @@ class ExtraFields // Clean parameters $value_key=dol_mktime($_POST[$keysuffix."options_".$key.$keyprefix."hour"], $_POST[$keysuffix."options_".$key.$keyprefix."min"], 0, $_POST[$keysuffix."options_".$key.$keyprefix."month"], $_POST[$keysuffix."options_".$key.$keyprefix."day"], $_POST[$keysuffix."options_".$key.$keyprefix."year"]); } - else if (in_array($key_type,array('checkbox'))) + else if (in_array($key_type,array('checkbox', 'chkbxlst'))) { $value_arr=GETPOST($keysuffix."options_".$key.$keyprefix); // Make sure we get an array even if there's only one checkbox diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 590f8060296..40ed4153060 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -133,11 +133,14 @@ class HookManager if (in_array( $method, array( - 'addMoreActionsButtons', + 'addCalendarChoice', + 'addMoreActionsButtons', + 'addMoreMassActions', 'addSearchEntry', 'addStatisticLine', - 'deleteFile', + 'deleteFile', 'doActions', + 'doMassActions', 'formCreateThirdpartyOptions', 'formObjectOptions', 'formattachOptions', @@ -169,7 +172,6 @@ class HookManager 'printSearchForm', 'printTabsHead', 'formatEvent', - 'addCalendarChoice', 'printObjectLine', 'printObjectSubLine', 'createDictionaryFieldList', @@ -181,14 +183,16 @@ class HookManager if ($method == 'insertExtraFields') { - $hooktype='returnvalue'; // deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available. + $hooktype='returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available. dol_syslog("Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)", LOG_WARNING); } + // Init return properties + $this->resPrint=''; $this->resArray=array(); + // Loop on each hook to qualify modules that have declared context $modulealreadyexecuted=array(); $resaction=0; $error=0; $result=''; - $this->resPrint=''; $this->resArray=array(); foreach($this->hooks as $context => $modules) // $this->hooks is an array with context as key and value is an array of modules that handle this context { if (! empty($modules)) @@ -202,9 +206,9 @@ class HookManager // test to avoid running twice a hook, when a module implements several active contexts if (in_array($module,$modulealreadyexecuted)) continue; - + dol_syslog(get_class($this).'::executeHooks a qualified hook was found for method='.$method.' module='.$module." action=".$action." context=".$context); - + $modulealreadyexecuted[$module]=$module; // Use the $currentcontext in method to avoid running twice // Clean class (an error may have been set from a previous call of another method for same module/hook) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1244001da57..b2f831a1cbb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -545,11 +545,20 @@ class Form $disabled=0; $ret='
'; $ret.=''; // Warning: if you set submit button to disabled, post using 'Enter' will no more work. $ret.=''; @@ -1391,7 +1400,7 @@ class Form * @deprecated * @see select_dolusers() */ - function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0) + function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude=null,$disabled=0,$include='',$enableonly='',$force_entity=0) { print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly,$force_entity); } @@ -1411,13 +1420,13 @@ class Form * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @param string $morefilter Add more filters into sql request * @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list - * @param string $enableonlytext If option $enableonly is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. + * @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. * @param string $morecss More css * @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on). * @return string HTML select string * @see select_dolgroups */ - function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0) + function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0) { global $conf,$user,$langs; @@ -1613,7 +1622,7 @@ class Form * @return string HTML select string * @see select_dolgroups */ - function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='') + function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='') { global $conf,$user,$langs; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 3ab47e1994b..131cdae3952 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -358,7 +358,7 @@ class FormCompany * * @param string $selected Title preselected * @param string $htmlname Name of HTML select combo field - * @param string $morecss Add more css on SELECT element + * @param string $morecss Add more css on SELECT element * @return string String with HTML select */ function select_civility($selected='',$htmlname='civility_id',$morecss='maxwidth100') @@ -563,11 +563,11 @@ class FormCompany $events=array(); // Add an entry 'method' to say 'yes, we must execute url with param action = method'; // Add an entry 'url' to say which url to execute - // Add an entry htmlname to say which element we must change once url is called - // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines + // Add an entry htmlname to say which element we must change once url is called + // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines // To refresh contacts list on thirdparty list change $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); - + if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events { print ''; + + // Loan card - + $linkback = '' . $langs->trans("BackToList") . ''; - + $morehtmlref='
'; // Ref loan $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); @@ -458,7 +470,7 @@ if ($id > 0) } } $morehtmlref.='
'; - + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -652,7 +664,7 @@ if ($id > 0) while ($i < $num) { $objp = $db->fetch_object($resql); - + print ''; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; @@ -713,31 +725,33 @@ if ($id > 0) if (empty($reshook)) { print '
'; - + // Edit if ($user->rights->loan->write) { + print ''.$langs->trans('CreateCalcSchedule').''; + print ''.$langs->trans("Modify").''; } - + // Emit payment if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) { print ''.$langs->trans("DoPayment").''; } - + // Classify 'paid' if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) { print ''.$langs->trans("ClassifyPaid").''; } - + // Delete if ($user->rights->loan->delete) { print ''.$langs->trans("Delete").''; } - + print "
"; } } diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php new file mode 100644 index 00000000000..fb6df8fcb6c --- /dev/null +++ b/htdocs/loan/class/loanschedule.class.php @@ -0,0 +1,542 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/loan/class/loanschedule.class.php + * \ingroup facture + * \brief File of class to manage schedule of loans + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + + +/** + * Class to manage Schedule of loans + */ +class LoanSchedule extends CommonObject +{ + public $element='loan_schedule'; //!< Id that identify managed objects + public $table_element='loan_schedule'; //!< Name of table without prefix where object is stored + + var $fk_loan; + var $datec=''; + var $tms=''; + var $datep=''; + var $amounts=array(); // Array of amounts + var $amount_capital; // Total amount of payment + var $amount_insurance; + var $amount_interest; + var $fk_typepayment; + var $num_payment; + var $fk_bank; + var $fk_user_creat; + var $fk_user_modif; + var $lines=array(); + + /** + * @deprecated + * @see amount, amounts + */ + var $total; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + /** + * Create payment of loan into database. + * Use this->amounts to have list of lines for the payment + * + * @param User $user User making payment + * @return int <0 if KO, id of payment if OK + */ + function create($user) + { + global $conf, $langs; + + $error=0; + + $now=dol_now(); + + // Validate parameters + if (! $this->datepaid) + { + $this->error='ErrorBadValueForParameter'; + return -1; + } + + // Clean parameters + if (isset($this->fk_loan)) $this->fk_loan = trim($this->fk_loan); + if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital?$this->amount_capital:0); + if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance?$this->amount_insurance:0); + if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest?$this->amount_interest:0); + if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment); + if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat = trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif = trim($this->fk_user_modif); + + $totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest; + $totalamount = price2num($totalamount); + + // Check parameters + if ($totalamount == 0) { + $this->errors[]='step1'; + return -1; // Negative amounts are accepted for reject prelevement but not null + } + + + $this->db->begin(); + + if ($totalamount != 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,"; + $sql.= " fk_typepayment, fk_user_creat, fk_bank)"; + $sql.= " VALUES (".$this->fk_loan.", '".$this->db->idate($now)."',"; + $sql.= " '".$this->db->idate($this->datepaid)."',"; + $sql.= " ".$this->amount_capital.","; + $sql.= " ".$this->amount_insurance.","; + $sql.= " ".$this->amount_interest.","; + $sql.= " ".$this->fk_typepayment.", "; + $sql.= " ".$user->id.","; + $sql.= " ".$this->fk_bank . ")"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan"); + } + else + { + $this->error=$this->db->lasterror(); + $error++; + } + + } + + if ($totalamount != 0 && ! $error) + { + $this->amount_capital=$totalamount; + $this->total=$totalamount; // deprecated + $this->db->commit(); + return $this->id; + } + else + { + $this->errors[]=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + function fetch($id) + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.fk_loan,"; + $sql.= " t.datec,"; + $sql.= " t.tms,"; + $sql.= " t.datep,"; + $sql.= " t.amount_capital,"; + $sql.= " t.amount_insurance,"; + $sql.= " t.amount_interest,"; + $sql.= " t.fk_typepayment,"; + $sql.= " t.num_payment,"; + $sql.= " t.note_private,"; + $sql.= " t.note_public,"; + $sql.= " t.fk_bank,"; + $sql.= " t.fk_user_creat,"; + $sql.= " t.fk_user_modif,"; + $sql.= " pt.code as type_code, pt.libelle as type_libelle,"; + $sql.= ' b.fk_account'; + $sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX.$this->table_element." as t)"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id"; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + + $this->fk_loan = $obj->fk_loan; + $this->datec = $this->db->jdate($obj->datec); + $this->tms = $this->db->jdate($obj->tms); + $this->datep = $this->db->jdate($obj->datep); + $this->amount_capital = $obj->amount_capital; + $this->amount_insurance = $obj->amount_insurance; + $this->amount_interest = $obj->amount_interest; + $this->fk_typepayment = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_creat = $obj->fk_user_creat; + $this->fk_user_modif = $obj->fk_user_modif; + + $this->type_code = $obj->type_code; + $this->type_libelle = $obj->type_libelle; + + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user=0, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan); + if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital); + if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance); + if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest); + if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); + if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); + if (isset($this->note_private)) $this->note_private=trim($this->note_private); + if (isset($this->note_public)) $this->note_public=trim($this->note_public); + if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); + if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); + if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; + + $sql.= " fk_loan=".(isset($this->fk_loan)?$this->fk_loan:"null").","; + $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql.= " amount_capital=".(isset($this->amount_capital)?$this->amount_capital:"null").","; + $sql.= " amount_insurance=".(isset($this->amount_insurance)?$this->amount_insurance:"null").","; + $sql.= " amount_interest=".(isset($this->amount_interest)?$this->amount_interest:"null").","; + $sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").","; + $sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").","; + $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; + $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; + $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; + $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; + $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; + + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + $this->db->begin(); + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + function calc_mens($capital,$rate,$nbterm) + { + $result=''; + + if (!empty($capital)&&!empty($rate)&&!empty($nbterm)) + { + $result=($capital*($rate/12))/(1-pow((1+($rate/12)),($nbterm*-1))); + } + + return $result; + } + + + /** + * Load all object in memory from database + * + * @param int $loanid Id object + * @return int <0 if KO, >0 if OK + */ + function fetchall($loanid) + { + global $langs; + + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.fk_loan,"; + $sql.= " t.datec,"; + $sql.= " t.tms,"; + $sql.= " t.datep,"; + $sql.= " t.amount_capital,"; + $sql.= " t.amount_insurance,"; + $sql.= " t.amount_interest,"; + $sql.= " t.fk_typepayment,"; + $sql.= " t.num_payment,"; + $sql.= " t.note_private,"; + $sql.= " t.note_public,"; + $sql.= " t.fk_bank,"; + $sql.= " t.fk_user_creat,"; + $sql.= " t.fk_user_modif"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql.= " WHERE t.fk_loan = ".$loanid; + + dol_syslog(get_class($this)."::fetchall", LOG_DEBUG); + $resql=$this->db->query($sql); + + if ($resql) + { + while($obj = $this->db->fetch_object($resql)) + { + $line = New LoanSchedule($this->db); + $line->id = $obj->rowid; + $line->ref = $obj->rowid; + + $line->fk_loan = $obj->fk_loan; + $line->datec = $this->db->jdate($obj->datec); + $line->tms = $this->db->jdate($obj->tms); + $line->datep = $this->db->jdate($obj->datep); + $line->amount_capital = $obj->amount_capital; + $line->amount_insurance = $obj->amount_insurance; + $line->amount_interest = $obj->amount_interest; + $line->fk_typepayment = $obj->fk_typepayment; + $line->num_payment = $obj->num_payment; + $line->note_private = $obj->note_private; + $line->note_public = $obj->note_public; + $line->fk_bank = $obj->fk_bank; + $line->fk_user_creat = $obj->fk_user_creat; + $line->fk_user_modif = $obj->fk_user_modif; + + $this->lines[] = $line; + } + $this->db->free($resql); + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + /** + * trans_paiment + * + * @return void + */ + function trans_paiment() + { + require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + $toinsert = array(); + + $sql = "SELECT l.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."loan as l "; + $sql.= " WHERE l.paid = 0"; + $resql=$this->db->query($sql); + + if($resql){ + while($obj = $this->db->fetch_object($resql)){ + $lastrecorded = $this->lastpaiment($obj->rowid); + $toinsert = $this->paimenttorecord($obj->rowid, $lastrecorded); + if(count($toinsert)>0){ + foreach ($toinsert as $echid){ + $this->db->begin(); + $sql = "INSERT INTO " .MAIN_DB_PREFIX . "payment_loan "; + $sql.= "(fk_loan,datec,tms,datep,amount_capital,amount_insurance,amount_interest,fk_typepayment,num_payment,note_private,note_public,fk_bank,fk_user_creat,fk_user_modif) "; + $sql.= "SELECT fk_loan,datec,tms,datep,amount_capital,amount_insurance,amount_interest,fk_typepayment,num_payment,note_private,note_public,fk_bank,fk_user_creat,fk_user_modif FROM " . MAIN_DB_PREFIX . "loan_schedule WHERE rowid =" .$echid; + $res=$this->db->query($sql); + if($res){ + $this->db->commit(); + }else { + $this->db->rollback(); + } + } + } + } + } + } + + + /** + * trans_paiment + * + * @param int $loanid Loan id + * @return int < 0 if KO, Date > 0 if OK + */ + function lastpaiment($loanid) + { + $sql = "SELECT p.datep"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_loan as p "; + $sql.= " WHERE p.fk_loan = " . $loanid; + $sql.= " ORDER BY p.datep DESC "; + $sql.= " LIMIT 1 "; + + $resql=$this->db->query($sql); + + if($resql){ + $obj = $this->db->fetch_object($resql); + return $this->db->jdate($obj->datep); + }else{ + return -1; + } + } + + /** + * paimenttorecord + * + * @param int $loanid Loan id + * @param int $datemax Date max + * @return array Array of id + */ + function paimenttorecord($loanid, $datemax) + { + $sql = "SELECT p.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p "; + $sql.= " WHERE p.fk_loan = " . $loanid; + if (!empty($datemax)) { $sql.= " AND p.datep > '" . $this->db->idate($datemax) ."'";} + $sql.= " AND p.datep <= '" . $this->db->idate(dol_now()). "'"; + + $resql=$this->db->query($sql); + + if($resql){ + while($obj = $this->db->fetch_object($resql)) + { + $result[] = $obj->rowid; + } + + } + + return $result; + } +} + diff --git a/htdocs/loan/createschedule.php b/htdocs/loan/createschedule.php new file mode 100644 index 00000000000..596cc9fd536 --- /dev/null +++ b/htdocs/loan/createschedule.php @@ -0,0 +1,208 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/loan/createecheancier.php + * \ingroup loan + * \brief Schedule card + */ + +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; + +global $user; + +$loanid = GETPOST('loanid', 'int'); +$action = GETPOST('action'); + +$object = new Loan($db); +$object->fetch($loanid); + +$langs->load('loan'); + +if ($action == 'createecheancier') { + + $i=1; + while($i <$object->nbterm+1){ + + $date = GETPOST('hi_date'.$i,'int'); + $mens = GETPOST('mens'.$i); + $int = GETPOST('hi_interets'.$i); + + $echeance = new LoanSchedule($db); + + $echeance->fk_loan = $object->id; + $echeance->datec = dol_now(); + $echeance->tms = dol_now(); + $echeance->datepaid = $date; + $echeance->amount_capital = $mens-$int; + $echeance->amount_insurance = 0; + $echeance->amount_interest = $int; + $echeance->fk_typepayment = 3; + $echeance->fk_bank = 1; + $echeance->fk_user_creat = $user->id; + $echeance->fk_user_modif = $user->id; + $result=$echeance->create($user); + if ($result<0) { + setEventMessages(null, $echeance->errors,'errors'); + } + $i++; + } +} + +if ($action == 'updateecheancier') { + + $i=1; + while($i <$object->nbterm+1){ + + $mens = GETPOST('mens'.$i); + $int = GETPOST('hi_interets'.$i); + $id = GETPOST('hi_rowid'.$i); + $echeance = new LoanSchedule($db); + $echeance->fetch($id); + $echeance->tms = dol_now(); + $echeance->amount_capital = $mens-$int; + $echeance->amount_insurance = 0; + $echeance->amount_interest = $int; + $echeance->fk_user_modif = $user->id; + $result= $echeance->update($user,0); + if ($result<0) { + setEventMessages(null, $echeance->errors,'errors'); + } + $i++; + } +} + +$echeance = new LoanSchedule($db); +$echeance->fetchall($object->id); + +top_htmlhead('', ''); +$var = ! $var; + + +?> + +'; +print ''; +print ''; +if(count($echeance->lines)>0){ + print ''; +}else{ + print ''; +} +print ''; +print ''; +print '"; +print ''; + +print ''; +Print ''; +Print ''; +Print ''; +Print ''; +Print ''; +print ''; + +if ($object->nbterm > 0 && count($echeance->lines)==0) +{ + $i=1; + $capital = $object->capital; + while($i <$object->nbterm+1){ + $mens = round($echeance->calc_mens($capital, $object->rate/100, $object->nbterm-$i+1),2,PHP_ROUND_HALF_UP); + $int = ($capital*($object->rate/12))/100; + $int = round($int,2,PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + $capital = $cap_rest; + } +}elseif(count($echeance->lines)>0){ + $i=1; + $capital = $object->capital; + foreach ($echeance->lines as $line){ + $mens = $line->amount_capital+$line->amount_insurance+$line->amount_interest; + $int = $line->amount_interest; + $cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP); + print ''; + print ''; + print ''; + if($line->datep > dol_now()){ + print ''; + }else{ + print ''; + } + print ''; + print ''; + print ''; + $i++; + $capital = $cap_rest; + } +} + +print '
' . "Création d'échéancier
Echéance Date Montant Intérêts Capital restant du
' . $i .'' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . ''.price($int,0,'',1).' €'.price($cap_rest).' €
' . $i .'' . dol_print_date($line->datep,'day') . '' . price($mens) . ' €'.price($int,0,'',1).' €'.price($cap_rest).' €
'; +print '
'; +print '
'; +print '
'; +print ''; + +llxFooter(); +$db->close(); + + + diff --git a/htdocs/modulebuilder/index.html b/htdocs/modulebuilder/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index e11ff31a303..b3b2c8dac77 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -115,9 +115,60 @@ if ($dircustom && $action == 'initmodule' && $modulename) if ($dircustom && $action == 'generatepackage') { - $dir = $dircustom.'/'.$modulename; + $modulelowercase=strtolower($module); + // Dir for module + $dir = $dircustom.'/'.$modulelowercase; + // Zip file to build + $FILENAMEZIP=''; + + // Load module + dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); + $class='mod'.$module; + if (class_exists($class)) + { + try { + $moduleobj = new $class($db); + } + catch(Exception $e) + { + $error++; + dol_print_error($e->getMessage()); + } + } + else + { + $error++; + $langs->load("errors"); + dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + exit; + } + + $arrayversion=explode('.',$moduleobj->version,3); + if (count($arrayversion)) + { + $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; + $outputfile = $conf->admin->dir_temp.'/'.$FILENAMEZIP; + + $result = dol_compress_dir($dir, $outputfile, 'zip'); + if ($result > 0) + { + setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfile), null); + } + else + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfile), null, 'errors'); + } + } + else + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorCheckVersionIsDefined"), null, 'errors'); + } } @@ -434,6 +485,12 @@ elseif (! empty($module)) if ($tab == 'buildpackage') { + if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) + { + print img_warning().' '.$langs->trans("ErrNoZipEngine"); + print '
'; + } + print '
'; print ''; print ''; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 63b92bc6468..b3f2cc87d73 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -39,20 +39,23 @@ require_once '../lib/mymodule.lib.php'; $langs->load("mymodule@mymodule"); // Access control -if (! $user->admin) { - accessforbidden(); -} +if (! $user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + + /* * View */ + $page_name = "MyModuleSetup"; llxHeader('', $langs->trans($page_name)); diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index f3ce5963aa6..7f1897c80ae 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -62,24 +62,101 @@ class ActionsMyModule */ public function doActions($parameters, &$object, &$action, $hookmanager) { + global $conf, $user, $langs; + $error = 0; // Error counter - $myvalue = 'test'; // A result value + /* print_r($parameters); - echo "action: " . $action; print_r($object); + echo "action: " . $action; + */ + + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + - if (in_array('somecontext', explode(':', $parameters['context']))) { - // do something only for the context 'somecontext' } if (! $error) { - $this->results = array('myreturn' => $myvalue); + $this->results = array('myreturn' => 999); $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code + return 0; // or return 1 to replace standard code } else { $this->errors[] = 'Error message'; return -1; } } + + + /** + * Overloading the doActions function : replacing the parent's function with the one below + * + * @param array() $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; + + $error = 0; // Error counter + + /* + print_r($parameters); + print_r($object); + echo "action: " . $action; + */ + + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' + + foreach($parameters['toselect'] as $objectid) + { + // Do action on each object id + + } + } + + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } + + + /** + * Overloading the addMoreMassActions function : replacing the parent's function with the one below + * + * @param array() $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; + + $error = 0; // Error counter + + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext' + { + $this->resprints = ''; + } + + if (! $error) { + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } + + + } diff --git a/htdocs/modulebuilder/template/img/object_mytest.png b/htdocs/modulebuilder/template/img/object_mytest.png new file mode 100644 index 00000000000..5a307bfc62f Binary files /dev/null and b/htdocs/modulebuilder/template/img/object_mytest.png differ diff --git a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang index 53c6205386c..c33f2453fc4 100644 --- a/htdocs/modulebuilder/template/langs/en_US/mymodule.lang +++ b/htdocs/modulebuilder/template/langs/en_US/mymodule.lang @@ -18,12 +18,10 @@ # Generic # -# Module label 'ModuleXXXName' -# (where XXX is value of numeric property 'numero' of module) -Module500000Name = My module -# Module description 'ModuleXXXDesc' -# (where XXX is value of numeric property 'numero' of module) -Module500000Desc = My module description +# Module label 'ModuleMyModuleName' +ModuleMyModuleName = My module +# Module description 'ModuleMyModuleDesc' +ModuleMyModuleDesc = My module description # # Admin page diff --git a/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang b/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang index d15d37f0ebf..06e7ba33885 100644 --- a/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang +++ b/htdocs/modulebuilder/template/langs/fr_FR/mymodule.lang @@ -18,12 +18,10 @@ # Générique # -# Module label 'ModuleXXXName' -# (where XXX is value of numeric property 'numero' of module) -Module500000Name = Mon module -# Module description 'ModuleXXXDesc' -# (where XXX is value of numeric property 'numero' of module) -Module500000Desc = Description de mon module +# Module label 'ModuleMyModuleName' +ModuleMyModuleName = Mon module +# Module description 'ModuleMyModuleDesc' +ModuleMyModuleDesc = Description de mon module # # Page d'administration diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 5183eeb3382..172bdd9354c 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -74,6 +74,9 @@ $error = 0; * Actions */ +$nomessageinsetmoduleoptions=1; +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'setcodeproduct') { if (dolibarr_set_const($db, "PRODUCT_CODEPRODUCT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) @@ -87,36 +90,6 @@ if ($action == 'setcodeproduct') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - //setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - // message yet present at the bottom if($action) - //setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') >= 0) { $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", GETPOST('value_PRODUIT_LIMIT_SIZE'),'chaine',0,'',$conf->entity); @@ -278,7 +251,7 @@ if ($action) } else { - setEventMessages($langs->trans("Error"), null, 'errors'); + setEventMessages($langs->trans("SetupNotError"), null, 'errors'); } } @@ -543,7 +516,7 @@ foreach ($dirmodels as $reldir) print ''; print "
"; - + /* * Other conf */ @@ -598,7 +571,7 @@ print ''; // multiprix nombre de prix a proposer if (! empty($conf->global->PRODUIT_MULTIPRICES)) { - + print ''; print ''.$langs->trans("MultiPricesNumPrices").''; print ''; @@ -640,7 +613,7 @@ print ''; if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { - + print ''; print ''.$langs->trans("NumberOfProductShowInSelect").''; print ''; @@ -681,7 +654,7 @@ print ''; // View product description in thirdparty language if (! empty($conf->global->MAIN_MULTILANGS)) { - + print ''; print ''.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").''; print ''; @@ -723,7 +696,7 @@ if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) if ($conf->$module->enabled) { - + print ""; print $object->description; diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 5465c04d9a9..e1d1ccd7888 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -320,6 +320,7 @@ class StockMovements extends DolibarrApi unset($object->user); unset($object->fk_project); unset($object->project); + unset($object->canvas); //unset($object->eatby); Filled correctly in read mode //unset($object->sellby); Filled correctly in read mode diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index a2b3f1cc667..9cda69560d5 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->load('projects'); +$langs->load('users'); $action=GETPOST('action','aZ09'); $mode=GETPOST("mode"); @@ -62,6 +63,8 @@ $month=GETPOST('remonth')?GETPOST('remonth'):(GETPOST("month","int")?GETPOST("mo $day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d")); $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); + +$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); $search_project_ref=GETPOST('search_project_ref', 'alpha'); @@ -75,6 +78,17 @@ $daytoparse = $now; if ($yearofday && $monthofday && $dayofday) $daytoparse=dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' else if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day, $year); // this are value submited after submit of action 'submitdateselect' +if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) +{ + $usertoprocess=$user; +} +else +{ + $usertoprocess=new User($db); + $usertoprocess->fetch($search_usertoprocessid); +} +$search_usertoprocessid=$usertoprocess->id; + $object=new Task($db); @@ -83,9 +97,10 @@ $object=new Task($db); */ // Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $action = ''; + $search_usertoprocessid = ''; $search_task_ref = ''; $search_task_label = ''; $search_project_ref = ''; @@ -125,7 +140,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } if (! $error) { - $idfortaskuser=$user->id; + $idfortaskuser=$usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); if ($result >= 0 || $result == -2) // Contact add ok or already contact of task @@ -143,7 +158,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $project->fetch($object->fk_project); // Get type $listofprojcontact=$project->liste_type_contact('internal'); - + if (count($listofprojcontact)) { $typeforprojectcontact=reset(array_keys($listofprojcontact)); @@ -151,7 +166,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } } - else + else { dol_print_error($db); } @@ -175,6 +190,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') if (! $error) { setEventMessages("TaskAssignedToEnterTime", null); + $taskid=0; } $action=''; @@ -247,12 +263,12 @@ if ($action == 'addtime' && $user->rights->projet->lire) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].($projectid?'?id='.$projectid:'?').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday); exit; } } - else - { + else + { setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); } } @@ -286,8 +302,6 @@ $next_day = $next['mday']; $title=$langs->trans("TimeSpent"); if ($mine) $title=$langs->trans("MyTimeSpent"); -$usertoprocess = $user; - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) @@ -314,8 +328,9 @@ llxHeader("",$title,""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); $param=''; -$param.=($mode?'&mode='.$mode:''); -$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($mode?'&mode='.$mode:''); +$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($search_userassignedid > 0?'&search_userassignedid='.$search_usertoprocessid:''); // Show navigation bar $nav =''.img_previous($langs->trans("Previous"))."\n"; @@ -337,7 +352,7 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode); +$head=project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperday', '', -1, 'task'); // Show description of content @@ -360,45 +375,17 @@ print '
'; dol_fiche_end(); - -// Filter on user -/* dol_fiche_head(''); - print ''; - print ''; - print '
'.$langs->trans("User").''; - if ($mine) print $user->getLoginUrl(1); - print '
'; - dol_fiche_end(); -*/ - -// Filter on user -/* dol_fiche_head(''); - print ''; - print ''; - print '
'.$langs->trans("User").''; - if ($mine) print $user->getLoginUrl(1); - print '
'; - dol_fiche_end(); -*/ - - -// Add a new project/task -//print '
'; -//print ''; -//print ''; -//print ''; -//print ''; -//print ''; -//print ''; - -print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. +print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. print '
'; -print $langs->trans("AssignTaskToMe").'
'; +$titleassigntask = $langs->trans("AssignTaskToMe"); +if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs)); +print '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); -print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0); -print ''; -//print ''; +print '
'; +print ' '; +print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); +print ''; print '
'; print '
'; @@ -408,6 +395,11 @@ print '
'; print ''."\n"; print ''; +print ''; print ''; print ''; print ''; @@ -427,6 +419,7 @@ print ''; print "\n"; print ''; +print ''; print ''; print ''; print ''; @@ -436,12 +429,15 @@ if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) } print ''; print ''; -print ''; +/*print ''; if ($usertoprocess->id == $user->id) print ''; -else print ''; +else print '';*/ +print ''; +print ''; print ''; -print ''; +print ''; print ''; +print ''; print "\n"; @@ -455,7 +451,7 @@ if (count($tasksarray) > 0) } else { - print ''; + print ''; } print "
'; +$usersettoshow='hierarchyme'; +if ($user->rights->projet->all->lire) $usersettoshow=''; +print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150'); +print '
'.$langs->trans("User").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')
'.$langs->trans("TimeSpent").''.$langs->trans("HourStart").''.$langs->trans("Duration").''.$langs->trans("Duration").''.$langs->trans("Note").'
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; print '
'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index da5303511ad..4a2156430af 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -58,11 +58,14 @@ $nowtmp=dol_getdate($now); $nowday=$nowtmp['mday']; $nowmonth=$nowtmp['mon']; $nowyear=$nowtmp['year']; + $year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y")); $month=GETPOST('remonth')?GETPOST('remonth','int'):(GETPOST("month")?GETPOST("month","int"):date("m")); $day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d")); $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); + +$search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); $search_project_ref=GETPOST('search_project_ref', 'alpha'); @@ -88,7 +91,16 @@ $next_day = $next['day']; $firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); -$usertoprocess=$user; +if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) +{ + $usertoprocess=$user; +} +else +{ + $usertoprocess=new User($db); + $usertoprocess->fetch($search_usertoprocessid); +} +$search_usertoprocessid=$usertoprocess->id; $object=new Task($db); @@ -98,9 +110,10 @@ $object=new Task($db); */ // Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $action = ''; + $search_usertoprocessid = ''; $search_task_ref = ''; $search_task_label = ''; $search_project_ref = ''; @@ -137,13 +150,13 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors'); $error++; } - + if (! $error) { - $idfortaskuser=$user->id; + $idfortaskuser=$usertoprocess->id; $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); - if (! $result || $result == -2) // Contact add ok or already contact of task + if ($result >= 0 || $result == -2) // Contact add ok or already contact of task { // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project) $sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact'; @@ -158,7 +171,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $project->fetch($object->fk_project); // Get type $listofprojcontact=$project->liste_type_contact('internal'); - + if (count($listofprojcontact)) { $typeforprojectcontact=reset(array_keys($listofprojcontact)); @@ -166,7 +179,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') } } } - else + else { dol_print_error($db); } @@ -190,6 +203,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') if (! $error) { setEventMessages("TaskAssignedToEnterTime", null); + $taskid=0; } $action=''; @@ -233,16 +247,16 @@ if ($action == 'addtime' && $user->rights->projet->lire) $error++; break; } - + $updateoftaskdone++; } } } - + if (! $updateoftaskdone) // Check to update progress if no update were done on task. { $object->fetch($taskid); - //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; + //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit; if ($object->progress != GETPOST($taskid . 'progress', 'int')) { $object->progress = GETPOST($taskid . 'progress', 'int'); @@ -262,7 +276,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].($projectid?'?id='.$projectid:'?').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:'')); + header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:'')); exit; } } @@ -312,14 +326,15 @@ llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); $param=''; -$param.=($mode?'&mode='.$mode:''); -$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($mode?'&mode='.$mode:''); +$param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); +$param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:''); // Show navigation bar -$nav =''.img_previous($langs->trans("Previous"))."\n"; +$nav =''.img_previous($langs->trans("Previous"))."\n"; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("WeekShort")." ".$week." \n"; -$nav.=''.img_next($langs->trans("Next"))."\n"; -$nav.="   (".$langs->trans("Today").")"; +$nav.=''.img_next($langs->trans("Next"))."\n"; +$nav.="   (".$langs->trans("Today").")"; $nav.='
'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' '; $nav.=' '; @@ -333,7 +348,7 @@ print ''; print ''; print ''; -$head=project_timesheet_prepare_head($mode); +$head=project_timesheet_prepare_head($mode, $usertoprocess); dol_fiche_head($head, 'inputperweek', '', -1, 'task'); // Show description of content @@ -356,44 +371,17 @@ print ''; dol_fiche_end(); -// Filter on user -/* dol_fiche_head(''); - print ''; - print ''; - print '
'.$langs->trans("User").''; - if ($mine) print $user->getLoginUrl(1); - print '
'; - dol_fiche_end(); -*/ - -// Filter on user -/* dol_fiche_head(''); - print ''; - print ''; - print '
'.$langs->trans("User").''; - if ($mine) print $user->getLoginUrl(1); - print '
'; - dol_fiche_end(); -*/ - - -// Add a new project/task -//print '
'; -//print '
'; -//print ''; -//print ''; -//print ''; -//print ''; -//print ''; - -print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. +print '
'.$nav.'
'; // We move this before the assign to components so, the default submit button is not the assign to. print '
'; -print $langs->trans("AssignTaskToMe").'
'; +$titleassigntask = $langs->trans("AssignTaskToMe"); +if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs)); +print '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); -print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0); -print ''; -//print ''; +print '
'; +print ' '; +print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); +print ''; print '
'; print '
'; @@ -403,6 +391,11 @@ print '
'; print ''."\n"; print ''; +print ''; print ''; print ''; print ''; @@ -423,6 +416,7 @@ print ''; print "\n"; print ''; +print ''; print ''; print ''; print ''; @@ -432,9 +426,11 @@ if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) } print ''; print ''; +/*print ''; + if ($usertoprocess->id == $user->id) print ''; + else print '';*/ +print ''; print ''; -if ($usertoprocess->id == $user->id) print ''; -else print ''; $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); @@ -452,16 +448,16 @@ if (count($tasksarray) > 0) { //var_dump($tasksarray); //var_dump($tasksrole); - + $j=0; $level=0; projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask); - $colspan=7; + $colspan=8; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++; - + print ' - + @@ -474,7 +470,7 @@ if (count($tasksarray) > 0) } else { - print ''; + print ''; } print "
'; +$usersettoshow='hierarchyme'; +if ($user->rights->projet->all->lire) $usersettoshow=''; +print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150'); +print '
'.$langs->trans("User").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')
'.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").'
'.$langs->trans("Total").''.$langs->trans("Total").'
 
 
 
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; print '
'; diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index fbcecf032cf..9e35ea77e0b 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -51,6 +51,8 @@ $type='project'; * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'setmainoptions') { if (GETPOST('PROJECT_USE_OPPORTUNITIES')) dolibarr_set_const($db, "PROJECT_USE_OPPORTUNITIES",GETPOST('PROJECT_USE_OPPORTUNITIES'),'chaine',0,'',$conf->entity); @@ -104,7 +106,7 @@ else if ($action == 'specimen') $project = new Project($db); $project->initAsSpecimen(); - + // Search template files $file=''; $classname=''; $filefound=0; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); @@ -188,35 +190,6 @@ else if ($action == 'specimentask') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a model else if ($action == 'set') { @@ -414,7 +387,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - + print ''.$module->name."\n"; print $module->info(); print ''; @@ -518,7 +491,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS)) if ($module->isEnabled()) { - + print ''.$module->name."\n"; print $module->info(); print ''; @@ -660,7 +633,7 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - + print ''; print (empty($module->name)?$name:$module->name); print "\n"; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index f6355ec5566..0b45a0d0696 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -134,7 +134,7 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - + if (! $error) { $error=0; @@ -308,8 +308,8 @@ if (empty($reshook)) setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors'); } } - - + + if ($error) { $db->rollback(); @@ -322,7 +322,7 @@ if (empty($reshook)) if (GETPOST('socid','int') > 0) $object->fetch_thirdparty(GETPOST('socid','int')); else unset($object->thirdparty); } - + } // Build doc @@ -623,7 +623,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print '     '; print ''; - } + } print ''; print ''; @@ -645,12 +645,12 @@ if ($action == 'create' && $user->rights->projet->creer) }); '; } -elseif ($object->id > 0) +elseif ($object->id > 0) { /* * Show or edit */ - + $res=$object->fetch_optionals($object->id,$extralabels); // To verify role of users @@ -711,10 +711,11 @@ elseif ($object->id > 0) print ''; $head=project_prepare_head($object); - dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); if ($action == 'edit' && $userWrite > 0) { + dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); + print ''; // Ref @@ -835,27 +836,30 @@ elseif ($object->id > 0) } else { + dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); + // Project card - + $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; // Title $morehtmlref.=$object->title; // Thirdparty - if ($object->thirdparty->id > 0) + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : '; + if ($object->thirdparty->id > 0) { - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -889,7 +893,7 @@ elseif ($object->id > 0) if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency); print ''; } - + // Date start - end print ''; - + // Budget print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start,'dayhour'); @@ -899,7 +903,7 @@ elseif ($object->id > 0) print ($end?$end:'?'); if ($object->hasDelay()) print img_warning("Late"); print '
'.$langs->trans("Budget").''; if (strcmp($object->budget_amount, '')) print price($object->budget_amount,0,$langs,1,0,0,$conf->currency); @@ -908,16 +912,16 @@ elseif ($object->id > 0) // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'; - + print ''; print '
'; print '
'; print '
'; - + print ''; - + // Description print '"; } - + print '
'.$langs->trans("Description").''; print nl2br($object->description); @@ -929,13 +933,13 @@ elseif ($object->id > 0) print $form->showCategories($object->id,'project',1); print "
'; - + print '
'; print '
'; print ''; - + print '
'; } @@ -954,9 +958,10 @@ elseif ($object->id > 0) // Change probability from status if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + // Default value to close or not when we set opp to 'WON'. $defaultcheckedwhenoppclose=1; if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0; - + print ''; print ''; */ - + // Personalized checkout print ''; - + print ' - +
'; @@ -1106,11 +1116,11 @@ if (preg_match('/^dopayment/',$action)) print ''; print ''."\n"; print ''."\n"; - + print '
- +
@@ -1126,22 +1136,22 @@ if (preg_match('/^dopayment/',$action))
- +
- + - + '; + print ''; } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 63ba12197fd..5c84be25521 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -42,6 +42,9 @@ if (!$user->admin) accessforbidden(); /* * Actions */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'setcodeclient') { if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) @@ -101,35 +104,6 @@ if ($action == 'updateoptions') } } -// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) -if ($action == 'setModuleOptions') -{ - $post_size=count($_POST); - - $db->begin(); - - for($i=0;$i < $post_size;$i++) - { - if (array_key_exists('param'.$i,$_POST)) - { - $param=GETPOST("param".$i,'alpha'); - $value=GETPOST("value".$i,'alpha'); - if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; - } - } - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} - // Activate a document generator module if ($action == 'set') { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 35914750ddc..e3f873476ba 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -356,11 +356,13 @@ class SupplierProposal extends CommonObject * @param array $array_option extrafields array * @param string $ref_fourn Supplier price reference * @param int $fk_unit Id of the unit to use. + * @param string $origin 'order', 'supplier_proposal', ... + * @param int $origin_id Id of origin line * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$array_option=0, $ref_fourn='', $fk_unit='') + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$array_option=0, $ref_fourn='', $fk_unit='', $origin='', $origin_id=0) { global $mysoc; @@ -462,7 +464,8 @@ class SupplierProposal extends CommonObject $this->line->special_code=$special_code; $this->line->fk_parent_line=$fk_parent_line; $this->line->fk_unit=$fk_unit; - + $this->line->origin=$origin; + $this->line->origin_id=$origin_id; $this->line->ref_fourn = $this->db->escape($ref_fourn); // infos marge @@ -880,7 +883,10 @@ class SupplierProposal extends CommonObject $this->lines[$i]->pa_ht, $this->lines[$i]->label, $this->lines[$i]->array_options, - $this->lines[$i]->ref_fourn + $this->lines[$i]->ref_fourn, + $this->lines[$i]->fk_unit, + 'supplier_proposal', + $this->lines[$i]->rowid ); if ($result < 0) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 33bba8f1404..3912a9b80ff 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -39,7 +39,7 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); $colorbackhmenu1='80,90,120'; // topmenu $colorbackvmenu1='255,255,255'; // vmenu $colortopbordertitle1='120,120,120'; // top border of title -$colorbacktitle1='230,230,230'; // title of tables,list +$colorbacktitle1='230,230,233'; // title of tables,list $colorbacktabcard1='255,255,255'; // card $colorbacktabactive='234,234,234'; $colorbacklineimpair1='255,255,255'; // line impair @@ -56,7 +56,7 @@ $fontsize='13'; $fontsizesmaller='12'; if (defined('THEME_ONLY_CONSTANT')) return; - + session_cache_limiter(FALSE); require_once '../../main.inc.php'; @@ -272,8 +272,8 @@ input[type=submit] { margin-left: 5px; } input, input.flat, form.flat select, select, select.flat, .dataTables_length label select { - global->THEME_ELDY_SHOW_BORDER_INPUT)) - print "border: none;" + global->THEME_ELDY_SHOW_BORDER_INPUT)) + print "border: none;" ?> } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { @@ -340,9 +340,9 @@ input.buttongen { vertical-align: middle; } span.timesheetalreadyrecorded input { - /*font-size: smaller;*/ border: none; - /*background: transparent;*/ + border-bottom: solid 1px rgba(0,0,0,0.4); + margin-right: 1px !important; } select.flat, form.flat select { @@ -363,8 +363,10 @@ select.flat, form.flat select { .opacitytransp { opacity: 0; } -select:invalid { color: gray; } - input:disabled { +select:invalid { + color: gray; +} +input:disabled { background:#ddd; } @@ -712,6 +714,7 @@ div.fiche>form>div.div-table-responsive { align-self: flex-start; } + /* ============================================================================== */ /* Styles to hide objects */ /* ============================================================================== */ @@ -901,7 +904,7 @@ td.showDragHandle { #id-right, #id-left { padding-top: 16px; padding-bottom: 16px; - + display: table-cell; /* DOL_XXX Empeche fonctionnement correct du scroll horizontal sur tableau, avec datatable ou CSS */ float: none; vertical-align: top; @@ -987,7 +990,7 @@ div.fiche { div.fiche { margin-: px; - margin-: dol_optimize_smallscreen)?'16':'6')); ?>px; + margin-: dol_optimize_smallscreen)?'16':'12')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'."\n"; ?> dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?> } @@ -1529,7 +1532,7 @@ foreach($mainmenuusedarray as $val) display: table; position: absolute; height: 100%; - width: 100%; + width: 100%; } .login_center { display: table-cell; @@ -1754,12 +1757,12 @@ div.vmenu, td.vmenu { } -/* Force vmenusearchselectcombo with type=text differently than without because beautify with select2 affect vmenusearchselectcombo differently */ +/* Force vmenusearchselectcombo with type=text differently than without because beautify with select2 affect vmenusearchselectcombo differently */ input.vmenusearchselectcombo[type=text] { width: 180px !important; } .vmenusearchselectcombo { - width: 188px; + width: 188px; } .menu_contenu { @@ -1926,7 +1929,7 @@ td.ecmroot { background-image: -webkit-linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important; background-image: -ms-linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important; background-image: linear-gradient(bottom, rgba(200,200,200,0.1) 0%, rgba(255,255,255,0.3) 120%) !important; - + background: #FFF; background-repeat: repeat-x !important; */ @@ -1939,7 +1942,7 @@ td.ecmroot { -webkit-box-shadow: 2px 2px 4px #DDD; box-shadow: 2px 2px 4px #DDD; */ - + padding: 10px 4px 14px 4px !important; min-height: 32px; } @@ -1969,7 +1972,7 @@ div.tabs { padding-right: 6px !important; clear:both; height:100%; - /* background-image: linear-gradient(to top,#f6f6f6 0,#fff 8px); */ + /* background-image: linear-gradient(to top,#f6f6f6 0,#fff 8px); */ } div.tabsElem { margin-top: 1px; @@ -1987,12 +1990,12 @@ div.tabBar { background: rgb(); } div.tabBar div.titre { - padding-top: 10px; + padding-top: 10px; } div.tabBarWithBottom { padding-bottom: 18px; - border-bottom: 1px solid #aaa; + border-bottom: 1px solid #aaa; } div.tabBar table.tableforservicepart2:last-child { border-bottom: 1px solid #aaa; @@ -2623,7 +2626,7 @@ div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_se background: rgb(); font-weight: ; border-bottom: 1px solid #ddd; - + color: rgb(); font-family: ; text-align: ; @@ -2682,7 +2685,7 @@ input.liste_titre { } .noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total { - /* background: #F0F0F0; */ + height: 32px; } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div { color: #552266; @@ -2734,7 +2737,7 @@ div.tabBar .noborder { /* Prepare to remove class pair - impair */ -.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { +.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { background: linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); @@ -2761,7 +2764,7 @@ div.tabBar .noborder { /* * Boxes */ - + .ficheaddleft div.boxstats { border: none; } @@ -2775,19 +2778,19 @@ div.tabBar .noborder { text-align: center; border-radius: 2px; } -.boxstats, .boxstats130, .boxstatscontent { +.boxstats, .boxstats130, .boxstatscontent { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .boxstats { padding: 3px; - width: 105px; + width: 105px; } .boxstats130 { - width: 160px; + width: 160px; height: 48px; - padding: 3px + padding: 3px } .boxstatscontent { padding: 3px; @@ -2795,13 +2798,16 @@ div.tabBar .noborder { @media only screen and (max-width: 767px) { + .thumbstat { + flex: 1 1 110px; + } .thumbstat150 { flex: 1 1 110px; } .boxstats, .boxstats130 { - width: 90px; + width: 90px; } - .dashboardlineindicator { + .dashboardlineindicator { float: left; padding-left: 5px; } @@ -2833,7 +2839,7 @@ span.dashboardlineko { color: #FFF; /*color: #8c4446 ! important; padding-left: 1px;*/ - + font-size: 80%; } .dashboardlinelatecoin { @@ -2842,9 +2848,9 @@ span.dashboardlineko { text-align: right; top: -24px; padding: 1px 2px 1px 2px; - border-radius: .25em; + border-radius: .25em; - background-color: #af4705; + background-color: #9f4705; padding: 0px 5px 0px 5px; top: -26px; } @@ -2854,7 +2860,7 @@ span.dashboardlineko { margin-right: 2px; background-color: #8c4446; color: #FFFFFF ! important; - border-radius: .25em; + border-radius: .25em; display: inline-block; vertical-align: middle; } @@ -3955,7 +3961,7 @@ div.dataTables_length select { border-top: 1px solid #ccc; border-bottom: solid 1px rgba(0,0,0,.2); } -.select2-container-active .select2-choice, .select2-container-active .select2-choices +.select2-container-active .select2-choice, .select2-container-active .select2-choices { outline: none; border-top: none; @@ -4039,7 +4045,7 @@ a span.select2-chosen border-right: none; border-top: none; border-left: none; - + } @@ -4593,7 +4599,12 @@ div.tabsElem a.tab { z-index: 201; background: #FFF; } - + + .login_vertical_align { + padding-left: 20px; + padding-right: 20px; + } + /* Reduce login top right info */ .help { @@ -4628,7 +4639,7 @@ div.tabsElem a.tab { vertical-align: middle; background: #FFF; height: 42px; - + z-index: 202; min-width: 190px; max-width: 190px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a1851dc4a76..d3f822bcca2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -317,7 +317,7 @@ textarea { border-left:solid 1px rgba(0,0,0,.1); border-right:solid 1px rgba(0,0,0,.1); border-bottom:solid 1px rgba(0,0,0,.2); - + background-color: #FFF; padding:4px; margin-left:1px; @@ -337,9 +337,9 @@ input.buttongen { vertical-align: middle; } span.timesheetalreadyrecorded input { - /*font-size: smaller;*/ border: none; - /*background: transparent;*/ + border-bottom: solid 1px rgba(0,0,0,0.1); + margin-right: 1px !important; } select.flat, form.flat select { @@ -867,10 +867,10 @@ div.fiche>form>div.div-table-responsive { width: 20px; object-fit: contain; } - + div.statusref { padding-right: 10px; - } + } } .linkobject { cursor: pointer; } @@ -1027,7 +1027,7 @@ div.fiche { div.fiche { margin-: px; - margin-: dol_optimize_smallscreen)?'16':'4')); ?>px; + margin-: dol_optimize_smallscreen)?'16':'12')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; } @@ -1557,12 +1557,12 @@ foreach($mainmenuusedarray as $val) display: table; position: absolute; height: 100%; - width: 100%; + width: 100%; } .login_center { display: table-cell; vertical-align: middle; -} +} .login_vertical_align { padding: 10px; padding-bottom: 80px; @@ -1992,14 +1992,14 @@ div.tabBar { border-top: 1px solid #CCC; width: auto; background: rgb(); - border-bottom: 1px solid #aaa; + border-bottom: 1px solid #aaa; } div.tabBar div.titre { - padding-top: 10px; + padding-top: 10px; } div.tabBarWithBottom { padding-bottom: 18px; - border-bottom: 1px solid #aaa; + border-bottom: 1px solid #aaa; } div.tabBar table.tableforservicepart2:last-child { border-bottom: 1px solid #aaa; @@ -2720,7 +2720,7 @@ tr.liste_titre th, tr.liste_titre td, th.liste_titre, form.liste_titre div, div. { border-bottom: 1px solid #; } -/* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */ +/* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */ tr:first-child th.liste_titre { border-bottom: 1px solid #FFF ! important; } @@ -2769,7 +2769,7 @@ input.liste_titre { } .noborder tr.liste_total, .noborder tr.liste_total td, tr.liste_total, form.liste_total { - /* background: #F0F0F0; */ + height: 32px; } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div { /* border-top: 1px solid #f4f4f4; */ @@ -2777,7 +2777,6 @@ input.liste_titre { font-weight: normal; white-space: nowrap; padding: 4px; - height: 20px; } tr.liste_sub_total, tr.liste_sub_total td { border-bottom: 2px solid #aaa; @@ -2826,7 +2825,7 @@ div .tdtop { /* Prepare to remove class pair - impair */ -.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { +.noborder > tbody > tr:nth-child(even):not(.liste_titre), .liste > tbody > tr:nth-child(even):not(.liste_titre) { background: linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); @@ -2852,7 +2851,7 @@ div .tdtop { /* * Boxes */ - + .ficheaddleft div.boxstats { border: none; } @@ -2866,29 +2865,32 @@ div .tdtop { text-align: center; border-radius: 2px; } -.boxstats, .boxstats130, .boxstatscontent { +.boxstats, .boxstats130, .boxstatscontent { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .boxstats { padding: 3px; - width: 105px; + width: 105px; } .boxstats130 { - width: 135px; + width: 135px; height: 48px; - padding: 3px + padding: 3px } @media only screen and (max-width: 767px) { + .thumbstat { + flex: 1 1 110px; + } .thumbstat150 { flex: 1 1 110px; } .boxstats, .boxstats130 { - width: 90px; + width: 90px; } - .dashboardlineindicator { + .dashboardlineindicator { float: left; padding-left: 5px; } @@ -2927,7 +2929,7 @@ span.dashboardlineko { padding: 1px 6px 1px 6px; background-color: #8c4446; color: #FFFFFF ! important; - border-radius: .25em; + border-radius: .25em; } .boxtable { margin-bottom: 8px !important; @@ -4047,7 +4049,7 @@ div.dataTables_length select { border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; } -.select2-container-active .select2-choice, .select2-container-active .select2-choices +.select2-container-active .select2-choice, .select2-container-active .select2-choices { outline: none; border-top: none; diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index c6123df3e77..c56f76af246 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -143,16 +143,16 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); - foreach ($listofsqldir as $dir) + foreach ($listofsqldir as $dir) { print 'Process dir '.$dir."\n"; $filesarray = scandir($dir); - - foreach($filesarray as $key => $file) + + foreach($filesarray as $key => $file) { if (! preg_match('/\.sql$/',$file)) continue; - + print 'Check sql file '.$file."\n"; $filecontent=file_get_contents($dir.'/'.$file); @@ -167,7 +167,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase $result=strpos($filecontent,'ON DELETE CASCADE'); print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n"; $this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.'); - + if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') { // Test for migration files only @@ -176,16 +176,20 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase else { if (preg_match('/\.key\.sql$/',$file)) - { - // Test for files key files only - + { + // Test for key files only + } else { - // Test for files non key files only + // Test for non key files only $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY ') == 0); print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n"; $this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.'); + + $result=stripos($filecontent,'ENGINE=innodb'); + print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n"; + $this->assertGreaterThan(0, $result, 'The ENGINE=innodb was not found into '.$file.'. Add it or just fix syntax to match case.'); } } } diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 02d85164d79..645993d8659 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -179,32 +179,32 @@ class DateLibTest extends PHPUnit_Framework_TestCase $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + // With same hours - Tuesday/Wednesday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 1, 2013); $date2=dol_mktime(0, 0, 0, 1, 2, 2013); - + $result=num_public_holiday($date1,$date2,'FR',1); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for FR'); // 1 closed days - + $result=num_public_holiday($date1,$date2,'XX',1); print __METHOD__." result=".$result."\n"; $this->assertEquals(0,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for XX'); // no closed days (country unknown) - + // With same hours - Friday/Sunday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 4, 2013); $date2=dol_mktime(0, 0, 0, 1, 6, 2013); - + $result=num_public_holiday($date1,$date2,'FR',1); print __METHOD__." result=".$result."\n"; - $this->assertEquals(2,$result,'NumPublicHoliday for FR'); // 1 opened day, 2 closed days - + $this->assertEquals(2,$result,'NumPublicHoliday for FR'); // 1 opened day, 2 closed days + $result=num_public_holiday($date1,$date2,'XX',1); print __METHOD__." result=".$result."\n"; $this->assertEquals(2,$result,'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) } - + /** * testNumOpenDay * @@ -217,32 +217,32 @@ class DateLibTest extends PHPUnit_Framework_TestCase $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - + // With same hours - Tuesday/Wednesday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 1, 2013); $date2=dol_mktime(0, 0, 0, 1, 2, 2013); - + $result=num_open_day($date1,$date2,0,1,0,'FR'); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for FR'); // 1 opened days - + $result=num_open_day($date1,$date2,0,1,0,'XX'); print __METHOD__." result=".$result."\n"; $this->assertEquals(2,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for XX'); // 2 opened days (country unknown) - + // With same hours - Friday/Sunday jan 2013 $date1=dol_mktime(0, 0, 0, 1, 4, 2013); $date2=dol_mktime(0, 0, 0, 1, 6, 2013); - + $result=num_open_day($date1,$date2,0,1,0,'FR'); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumOpenDay for FR'); // 1 opened day, 2 closed - + $result=num_open_day($date1,$date2,'XX',1); print __METHOD__." result=".$result."\n"; $this->assertEquals(1,$result,'NumOpenDay for XX'); // 1 opened day, 2 closes (even if country unknown) } - + /** * testConvertTime2Seconds * @@ -335,6 +335,11 @@ class DateLibTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; $this->assertEquals('02/01/1970 00:00',$result); + // Check %a and %b format for fr_FR + $result=dol_print_date(0,'%a %b %B',true,$outputlangs); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('Jeu Jan. Janvier',$result); + // Check day format for en_US $outputlangs=new Translate('',$conf); $outputlangs->setDefaultLang('en_US'); @@ -345,9 +350,9 @@ class DateLibTest extends PHPUnit_Framework_TestCase $this->assertEquals('01/02/1970',$result); // Check %a and %b format for en_US - $result=dol_print_date(0,'%a %b',true,$outputlangs); + $result=dol_print_date(0,'%a %b %B',true,$outputlangs); print __METHOD__." result=".$result."\n"; - $this->assertEquals('Thu Jan',$result); + $this->assertEquals('Thu Jan January',$result); return $result; } diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 8c57e8a178a..4e98ce0b3bc 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -377,6 +377,14 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $after=dol_string_nohtmltag($text,1); $this->assertEquals("A string Another string",$after,"test5"); + $text='ABC'; + $after=dol_string_nohtmltag($text,1); + $this->assertEquals("ABC",$after,"test6"); + + $text='DEF'; + $after=dol_string_nohtmltag($text,1); + $this->assertEquals("DEF",$after,"test7"); + return true; }