develop_mc
This commit is contained in:
Regis Houssin 2017-06-03 11:45:15 +02:00
commit 2df33d1df3
112 changed files with 4050 additions and 1829 deletions

View File

@ -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. 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) * 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 ***** ***** ChangeLog for 5.0.2 compared to 5.0.1 *****
FIX: #6468 + Fix missing translation FIX: #6468 + Fix missing translation
FIX: #6517 #6525 Autocompletion of thirdparty after n chars not implemented 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). - 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 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 ***** ***** ChangeLog for 4.0.5 to 4.0.4 *****

View File

@ -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. 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." 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.

View File

@ -4,7 +4,12 @@ dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jsgantt/*
dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jstz/* dolibarr: source-contains-prebuilt-javascript-object htdocs/includes/jstz/*
# Those are false positives, the files are their own sources since # Those are false positives, the files are their own sources since
# they are not minified # they are not minified
source-is-missing htdocs/includes/jsgantt/jsgantt.js * source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/a11yhelp/dialogs/lang/*.js
source-is-missing htdocs/includes/jquery/plugins/colorpicker/jquery.colorpicker.js * source-is-missing htdocs/includes/ckeditor/ckeditor/plugins/specialchar/dialogs/lang/*.js
source-is-missing htdocs/includes/jquery/plugins/select2/select2.js * source-is-missing htdocs/includes/ckeditor/ckeditor/lang/*.js
source-is-missing htdocs/includes/jquery/plugins/select2/select2_locale_ar.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

View File

@ -14,7 +14,7 @@
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
use Cwd; use Cwd;
use Term::ANSIColor;
# Change this to defined target for option 98 and 99 # Change this to defined target for option 98 and 99
$PROJECT="dolibarr"; $PROJECT="dolibarr";
@ -313,20 +313,6 @@ foreach my $target (sort keys %CHOOSEDTARGET) {
print "\n"; 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"; #print join(',',sort keys %CHOOSEDTARGET)."\n";
@ -335,7 +321,10 @@ if ($CHOOSEDTARGET{'-CHKSUM'})
$nboftargetok=0; $nboftargetok=0;
$nboftargetneedbuildroot=0; $nboftargetneedbuildroot=0;
$nbofpublishneedtag=0; $nbofpublishneedtag=0;
$nbofpublishneedchangelog=0;
foreach my $target (sort keys %CHOOSEDTARGET) { foreach my $target (sort keys %CHOOSEDTARGET) {
if ($target eq '-CHKSUM') { $nbofpublishneedchangelog++; }
if ($CHOOSEDTARGET{$target} < 0) { next; } if ($CHOOSEDTARGET{$target} < 0) { next; }
if ($target ne 'EXE' && $target ne 'EXEDOLIWAMP' && $target ne '-CHKSUM') 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) { foreach my $target (sort keys %CHOOSEDPUBLISH) {
if ($CHOOSEDPUBLISH{$target} < 0) { next; } if ($CHOOSEDPUBLISH{$target} < 0) { next; }
if ($target eq 'ASSO') { $nbofpublishneedtag++; } if ($target eq 'ASSO') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; }
if ($target eq 'SF') { $nbofpublishneedtag++; } if ($target eq 'SF') { $nbofpublishneedchangelog++; $nbofpublishneedtag++; }
$nboftargetok++; $nboftargetok++;
} }
if ($nboftargetok) { if ($nboftargetok) {
# Update GIT tag if required # Check Changelog
#--------------------------- #----------------
if ($nbofpublishneedtag) if ($nbofpublishneedchangelog)
{ {
print "Go to directory $SOURCE\n";
$olddir=getcwd();
chdir("$SOURCE");
# Test that the ChangeLog is ok # Test that the ChangeLog is ok
$TMPBUILDTOCHECKCHANGELOG=$BUILD; $TMPBUILDTOCHECKCHANGELOG=$BUILD;
$TMPBUILDTOCHECKCHANGELOG =~ s/\-rc\d*//; $TMPBUILDTOCHECKCHANGELOG =~ s/\-rc\d*//;
$TMPBUILDTOCHECKCHANGELOG =~ s/\-beta\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`; $ret=`grep "ChangeLog for $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG" "$SOURCE/ChangeLog" 2>&1`;
if (! $ret) 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 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 if (! $BUILD || $BUILD eq '0-rc') # For a major version
{ {
@ -385,8 +371,38 @@ if ($nboftargetok) {
print "\n"; print "\n";
if (! $ret) if (! $ret)
{ {
exit; print "\nPress F to force and continue anyway (or other key to stop)... ";
my $WAITKEY=<STDIN>;
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"; 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`; $ret=`git tag -a -m "$MAJOR.$MINOR.$BUILD" "$MAJOR.$MINOR.$BUILD" 2>&1`;
@ -517,6 +533,7 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimed*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimed*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimod*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/dolimod*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/factory*`; $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/lead*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/management*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/management*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/multicompany*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/multicompany*`;

View File

@ -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 . '/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.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 . '/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 . '/don/class/paymentdonation.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.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. // Now loop on each link of record in bank.
foreach ( $links as $key => $val ) { 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 // We save tabtype for a future use, to remember what kind of payment it is
$tabtype[$obj->rowid] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type'];
@ -278,13 +279,15 @@ if ($result) {
} else if ($links[$key]['type'] == 'payment_donation') { } else if ($links[$key]['type'] == 'payment_donation') {
$paymentdonstatic->id = $links[$key]['url_id']; $paymentdonstatic->id = $links[$key]['url_id'];
$paymentdonstatic->fk_donation = $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; $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount;
} else if ($links[$key]['type'] == 'payment_vat') { } else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id'];
$paymentvatstatic->label = $links[$key]['label']; $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; $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount;
} else if ($links[$key]['type'] == 'payment_salary') { } else if ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->id = $links[$key]['url_id'];
@ -415,6 +418,12 @@ if (! $error && $action == 'writebookkeeping') {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport $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); $result = $bookkeeping->create($user);
@ -475,7 +484,6 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice } 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 = 'SELECT facf.ref_supplier,facf.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $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); $objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; $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; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'banktransfert') { } else if ($tabtype[$key] == 'payment_vat') {
$bookkeeping->code_tiers = ''; $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; $bookkeeping->numero_compte = $k;
} else { } else {
// FIXME Should be a temporary account ??? // FIXME Should be a temporary account ???
@ -724,6 +740,8 @@ if (empty($action) || $action == 'view') {
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
$invoicesupplierstatic = new FactureFournisseur($db); $invoicesupplierstatic = new FactureFournisseur($db);
$expensereportstatic = new ExpenseReport($db); $expensereportstatic = new ExpenseReport($db);
$vatstatic = new Tva($db);
$donationstatic = new Don($db);
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));
@ -850,6 +868,34 @@ if (empty($action) || $action == 'view') {
} }
else dol_print_error($db); 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; /*$invoicestatic->id = $key;
@ -871,7 +917,7 @@ if (empty($action) || $action == 'view') {
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
if ($val['soclib'] == '') { if ($val['soclib'] == '') {
print "<td>" . $bankstatic->label . " - " . $val["ref"] . "</td>"; print "<td>" . $bankstatic->label . " - " . $reflabel . "</td>";
} else { } else {
print "<td>" . $bankstatic->label . " - " . $val['soclib'] . "</td>"; print "<td>" . $bankstatic->label . " - " . $val['soclib'] . "</td>";
} }

View File

@ -49,6 +49,8 @@ $type = 'action';
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (preg_match('/set_(.*)/',$action,$reg)) if (preg_match('/set_(.*)/',$action,$reg))
{ {
$code=$reg[1]; $code=$reg[1];
@ -77,21 +79,6 @@ if (preg_match('/del_(.*)/',$action,$reg))
dol_print_error($db); 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') if ($action == 'set')
{ {
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);

View File

@ -39,6 +39,8 @@ $action = GETPOST('action','alpha');
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setbarcodeproducton') if ($action == 'setbarcodeproducton')
{ {
$res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", GETPOST('value'), 'chaine', 0, '', $conf->entity); $res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", GETPOST('value'), 'chaine', 0, '', $conf->entity);
@ -75,32 +77,6 @@ else if ($action == 'updateengine')
} }
// 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') if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
{ {
if (! $res > 0) $error++; if (! $res > 0) $error++;

View File

@ -77,7 +77,7 @@ if ($action == 'setmod')
if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') 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); $res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);

View File

@ -54,6 +54,8 @@ $type = 'order';
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstorder=GETPOST('maskconstorder','alpha'); $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 // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -207,7 +180,7 @@ else if ($action == 'set_COMMANDE_DRAFT_WATERMARK')
else if ($action == 'set_ORDER_FREE_TEXT') 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); $res = dolibarr_set_const($db, "ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);

View File

@ -50,6 +50,8 @@ if (empty($conf->global->CONTRACT_ADDON))
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst = GETPOST('maskconstcontract','alpha'); $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 // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -185,7 +158,7 @@ else if ($action == 'setmod')
else if ($action == 'set_other') 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); $res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
$draft= GETPOST('CONTRACT_DRAFT_WATERMARK','alpha'); $draft= GETPOST('CONTRACT_DRAFT_WATERMARK','alpha');
@ -501,7 +474,7 @@ print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=true; $var=true;
$substitutionarray=pdf_getSubstitutionArray($langs); $substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'));
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';

View File

@ -264,22 +264,14 @@ if ($mode != 'focus')
{ {
if ($mode != 'sortorder') if ($mode != 'sortorder')
{ {
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
// See list into GETPOST foreach($substitutionarray as $key => $val)
$texthelp.='__USERID__<br>'; {
$texthelp.='__SUPERVISORID__<br>'; $texthelp.=$key.'<br>';
$texthelp.='__MYCOUNTRYID__<br>'; }
$texthelp.='__DAY__<br>'; $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click
$texthelp.='__MONTH__<br>';
$texthelp.='__YEAR__<br>';
$texthelp.='__PREVIOUS_DAY__<br>';
$texthelp.='__PREVIOUS_MONTH__<br>';
$texthelp.='__PREVIOUS_YEAR__<br>';
$texthelp.='__NEXT_DAY__<br>';
$texthelp.='__NEXT_MONTH__<br>';
$texthelp.='__NEXT_YEAR__<br>';
if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__<br>';
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, '');
} }
else else
{ {

View File

@ -57,6 +57,9 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst=GETPOST('maskconstexpedition','alpha'); $maskconst=GETPOST('maskconstexpedition','alpha');
@ -75,7 +78,7 @@ if ($action == 'updateMask')
else if ($action == 'set_param') 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); $res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if ($res <= 0) 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 // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {

View File

@ -51,6 +51,9 @@ $type='expensereport';
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst=GETPOST('maskconst','alpha'); $maskconst=GETPOST('maskconst','alpha');
@ -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 // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -194,7 +168,7 @@ else if ($action == 'setoptions')
{ {
$db->begin(); $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); $res1 = dolibarr_set_const($db, "EXPENSEREPORT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
$draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK','alpha'); $draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK','alpha');

View File

@ -51,6 +51,8 @@ $type='invoice';
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstinvoice=GETPOST('maskconstinvoice','alpha'); $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 // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -229,7 +206,7 @@ if ($action == 'set_FACTURE_DRAFT_WATERMARK')
if ($action == 'set_INVOICE_FREE_TEXT') 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); $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);

View File

@ -51,6 +51,9 @@ $type='ficheinter';
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst=GETPOST('maskconst','alpha'); $maskconst=GETPOST('maskconst','alpha');
@ -114,35 +117,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 // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {
@ -186,7 +160,7 @@ else if ($action == 'setmod')
else if ($action == 'set_FICHINTER_FREE_TEXT') else if ($action == 'set_FICHINTER_FREE_TEXT')
{ {
$freetext= GETPOST('FICHINTER_FREE_TEXT'); // No alpha here, we want exact string $freetext= GETPOST('FICHINTER_FREE_TEXT','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;

View File

@ -349,7 +349,19 @@ if ($action == 'edit') // Edit
print '</tr>'; print '</tr>';
// Message of the day on home page // Message of the day on home page
print '<tr><td class="titlefield">'.$langs->trans("MessageOfDay").'</td><td colspan="2">'; $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object'));
complete_substitutions_array($substitutionarray, $langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
print '<tr><td class="titlefield">';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
}
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, '');
print '</td><td colspan="2">';
$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 = 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(); $doleditor->Create();
@ -367,7 +379,17 @@ if ($action == 'edit') // Edit
print '</tr>'; print '</tr>';
// Message on login page // Message on login page
print '<tr><td>'.$langs->trans("MessageLogin").'</td><td colspan="2">'; $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','user'));
complete_substitutions_array($substitutionarray, $langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
print '<tr><td>';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
}
print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, '');
print '</td><td colspan="2">';
$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 = 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(); $doleditor->Create();
print '</td></tr>'."\n"; print '</td></tr>'."\n";

View File

@ -47,10 +47,13 @@ $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$type='delivery'; $type='delivery';
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstdelivery=GETPOST('maskconstdelivery','alpha'); $maskconstdelivery=GETPOST('maskconstdelivery','alpha');
@ -71,7 +74,7 @@ if ($action == 'updateMask')
if ($action == 'set_DELIVERY_FREE_TEXT') 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); $res=dolibarr_set_const($db, "DELIVERY_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; 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') if ($action == 'set')
{ {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);

View File

@ -59,8 +59,8 @@ $acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"),'switch_off'); $actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
$actl[1] = img_picto($langs->trans("Activated"),'switch_on'); $actl[1] = img_picto($langs->trans("Activated"),'switch_on');
$listoffset=GETPOST('listoffset'); $listoffset=GETPOST('listoffset','alpha');
$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; $listlimit=GETPOST('listlimit','alpha')>0?GETPOST('listlimit','alpha'):1000;
$active = 1; $active = 1;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
@ -119,14 +119,14 @@ $formmail=new FormMail($db);
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{ {
$tmp=FormMail::getAvailableSubstitKey('formemail'); $tmp=FormMail::getAvailableSubstitKey('formemail');
$tmp['__(AnyTransKey)__']='__(AnyTransKey)__'; $tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp); $helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp); $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
} }
else else
{ {
$tmp=FormMail::getAvailableSubstitKey('formemailwithlines'); $tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
$tmp['__(AnyTransKey)__']='__(AnyTransKey)__'; $tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp); $helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
$tmp=FormMail::getAvailableSubstitKey('formemailforlines'); $tmp=FormMail::getAvailableSubstitKey('formemailforlines');
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp); $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);

View File

@ -430,7 +430,6 @@ print "<br>\n";
if ($mode == 'common') if ($mode == 'common')
{ {
print '<form method="GET" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="GET" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -763,13 +762,20 @@ if ($mode == 'common')
} }
print "</tr>\n"; print "</tr>\n";
} }
print "</table>\n"; if ($oldfamily)
print '</div>'; {
print "</table>\n";
print '</div>';
}
dol_fiche_end(); dol_fiche_end();
// Show warning about external users
print info_admin(showModulesExludedForExternal($modules))."\n";
print '</form>';
} }
if ($mode == 'marketplace') 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(); llxFooter();

View File

@ -71,7 +71,7 @@ if ($action == 'setmod')
if ($action == 'setparams') 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); $res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS",$freetext,'chaine',0,'',$conf->entity);
@ -81,19 +81,6 @@ if ($action == 'setparams')
{ {
setEventMessages($langs->trans("Error"), null, 'errors'); 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) if (! $error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');

View File

@ -49,6 +49,9 @@ $type='propal';
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
$error=0; $error=0;
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
@ -132,7 +135,7 @@ if ($action == 'set_PROPALE_DRAFT_WATERMARK')
if ($action == 'set_PROPOSAL_FREE_TEXT') 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); $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 // Activate a model
if ($action == 'set') if ($action == 'set')
{ {

View File

@ -172,7 +172,7 @@ if ($action == 'addcat')
if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') 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); $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);

View File

@ -169,7 +169,7 @@ else if ($action == 'addcat')
else if ($action == 'set_SUPPLIER_ORDER_OTHER') 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 = GETPOST('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED','alpha');
$doubleapproval = price2num($doubleapproval ); $doubleapproval = price2num($doubleapproval );

View File

@ -47,6 +47,8 @@ $type='supplier_payment';
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstsupplierpayment=GETPOST('maskconstsupplierpayment','alpha'); $maskconstsupplierpayment=GETPOST('maskconstsupplierpayment','alpha');
@ -68,31 +70,6 @@ if ($action == 'updateMask')
dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); 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 // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {

View File

@ -41,10 +41,15 @@ $label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha'); $scandir = GETPOST('scandir','alpha');
$type='supplier_proposal'; $type='supplier_proposal';
$error=0;
/* /*
* Actions * Actions
*/ */
$error=0;
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstsupplier_proposal=GETPOST('maskconstsupplier_proposal','alpha'); $maskconstsupplier_proposal=GETPOST('maskconstsupplier_proposal','alpha');
@ -127,7 +132,7 @@ if ($action == 'set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK')
if ($action == 'set_SUPPLIER_PROPOSAL_FREE_TEXT') 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); $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 // Activate a model
if ($action == 'set') if ($action == 'set')
{ {

View File

@ -47,37 +47,9 @@ $type='user';
* Action * 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 == 'set_default')
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')
{ {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
$res = true; $res = true;

View File

@ -47,37 +47,9 @@ $type='group';
* Action * 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 == 'set_default')
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')
{ {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
$res = true; $res = true;

View File

@ -1208,7 +1208,7 @@ if ($id > 0)
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); $out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>'; $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); $out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>'; $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); $out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>'; $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
$linkback.=$out; $linkback.=$out;

View File

@ -361,6 +361,7 @@ class Facture extends CommonInvoice
'__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'), '__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'),
); );
$substitutionisok=true;
complete_substitutions_array($substitutionarray, $outputlangs); complete_substitutions_array($substitutionarray, $outputlangs);
$this->note_public=make_substitutions($this->note_public,$substitutionarray); $this->note_public=make_substitutions($this->note_public,$substitutionarray);
@ -2650,7 +2651,7 @@ class Facture extends CommonInvoice
* @param double $pu_ht_devise Unit price in currency * @param double $pu_ht_devise Unit price in currency
* @return int < 0 if KO, > 0 if OK * @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; global $conf,$user;
// Deprecation warning // Deprecation warning

View File

@ -1272,16 +1272,6 @@ class BonPrelevement extends CommonObject
* section Debiteur (sepa Debiteurs bloc lines) * 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 = "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.= " 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"; $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, ' </PmtInf>'.$CrLf); fputs($this->file, ' </PmtInf>'.$CrLf);
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf); fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
fputs($this->file, '</Document>'.$CrLf); fputs($this->file, '</Document>'.$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 // Build file for Other Countries with unknow format
@ -1580,11 +1541,11 @@ class BonPrelevement extends CommonObject
$XML_DEBITOR .=' </FinInstnId>'.$CrLf; $XML_DEBITOR .=' </FinInstnId>'.$CrLf;
$XML_DEBITOR .=' </DbtrAgt>'.$CrLf; $XML_DEBITOR .=' </DbtrAgt>'.$CrLf;
$XML_DEBITOR .=' <Dbtr>'.$CrLf; $XML_DEBITOR .=' <Dbtr>'.$CrLf;
$XML_DEBITOR .=' <Nm>'.strtoupper(dol_string_unaccent($row_nom)).'</Nm>'.$CrLf; $XML_DEBITOR .=' <Nm>'.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).'</Nm>'.$CrLf;
$XML_DEBITOR .=' <PstlAdr>'.$CrLf; $XML_DEBITOR .=' <PstlAdr>'.$CrLf;
$XML_DEBITOR .=' <Ctry>'.$row_country_code.'</Ctry>'.$CrLf; $XML_DEBITOR .=' <Ctry>'.$row_country_code.'</Ctry>'.$CrLf;
$XML_DEBITOR .=' <AdrLine>'.dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))).'</AdrLine>'.$CrLf; $XML_DEBITOR .=' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).'</AdrLine>'.$CrLf;
$XML_DEBITOR .=' <AdrLine>'.dol_string_unaccent($row_zip.' '.$row_town).'</AdrLine>'.$CrLf; $XML_DEBITOR .=' <AdrLine>'.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).'</AdrLine>'.$CrLf;
$XML_DEBITOR .=' </PstlAdr>'.$CrLf; $XML_DEBITOR .=' </PstlAdr>'.$CrLf;
$XML_DEBITOR .=' </Dbtr>'.$CrLf; $XML_DEBITOR .=' </Dbtr>'.$CrLf;
$XML_DEBITOR .=' <DbtrAcct>'.$CrLf; $XML_DEBITOR .=' <DbtrAcct>'.$CrLf;

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");
@ -94,10 +95,10 @@ llxHeader('', $langs->trans("VATPayments"));
$form = new Form($db); $form = new Form($db);
$formother=new FormOther($db); $formother=new FormOther($db);
$tva_static = new Tva($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 = "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.= " 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."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"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
@ -227,19 +228,22 @@ if ($result)
{ {
print '<td>'; print '<td>';
if ($obj->fk_bank > 0) if ($obj->fk_bank > 0)
{ {
//$accountstatic->fetch($obj->fk_bank); $bankstatic->id=$obj->bid;
$accountstatic->id=$obj->bid; $bankstatic->ref=$obj->bref;
$accountstatic->ref=$obj->bref; $bankstatic->number=$obj->bnumber;
$accountstatic->number=$obj->bnumber; $bankstatic->account_number=$obj->account_number;
$accountstatic->accountancy_number=$obj->account_number;
$accountstatic->accountancy_journal=$obj->accountancy_journal; $accountingjournal = new AccountingJournal($db);
$accountstatic->label=$obj->blabel; $accountingjournal->fetch($obj->fk_accountancy_journal);
print $accountstatic->getNomUrl(1); $bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1);
}
else print '&nbsp;'; $bankstatic->label=$obj->blabel;
print '</td>'; print $bankstatic->getNomUrl(1);
} }
else print '&nbsp;';
print '</td>';
}
// Amount // Amount
$total = $total + $obj->amount; $total = $total + $obj->amount;
print "<td align=\"right\">".price($obj->amount)."</td>"; print "<td align=\"right\">".price($obj->amount)."</td>";

View File

@ -2225,7 +2225,11 @@ class Contrat extends CommonObject
$line->total_ht=90; $line->total_ht=90;
$line->total_ttc=107.64; // 90 * 1.196 $line->total_ttc=107.64; // 90 * 1.196
$line->total_tva=17.64; $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); $prodid = mt_rand(1, $num_prods);
$line->fk_product=$prodids[$prodid]; $line->fk_product=$prodids[$prodid];
@ -2233,11 +2237,6 @@ class Contrat extends CommonObject
$this->lines[$xnbp]=$line; $this->lines[$xnbp]=$line;
$xnbp++; $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_ht)) $this->total_ht = 0;
if (empty($this->total_tva)) $this->total_tva = 0; if (empty($this->total_tva)) $this->total_tva = 0;
if (empty($this->total_ttc)) $this->total_ttc = 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 // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values

View File

@ -24,7 +24,9 @@
// $massaction must be defined // $massaction must be defined
// $objectclass and $$objectlabel 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 // $toselect may be defined
@ -36,8 +38,8 @@ if (empty($objectclass) || empty($uploaddir))
} }
// Mass actions. Controls on number of lines checked // Mass actions. Controls on number of lines checked.
$maxformassaction=1000; $maxformassaction=(empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS)?1000:$conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
if (! empty($massaction) && count($toselect) < 1) if (! empty($massaction) && count($toselect) < 1)
{ {
$error++; $error++;
@ -565,6 +567,11 @@ if (! $error && $massaction == 'delete' && $permtodelete)
//var_dump($listofobjectthirdparties);exit; //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');

View File

@ -0,0 +1,86 @@
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
* 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');
}
}

View File

@ -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').'<br>'.$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 class DolGraph
{ {
@ -780,9 +791,9 @@ class DolGraph
/** /**
* Build a graph using JFlot library. Input when calling this method should be: * 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('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->legend= array("Val1",...,"Valn"); // list of n series name
* $this->type = array('bars',...'lines'); or array('pie') * $this->type = array('bars',...'lines'); or array('pie')
* $this->mode = 'depth' ??? * $this->mode = 'depth' ???
@ -798,7 +809,7 @@ class DolGraph
{ {
global $artichow_defaultfont; 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)) if (empty($this->width) && empty($this->height))
{ {
@ -808,7 +819,7 @@ class DolGraph
$legends=array(); $legends=array();
$nblot=count($this->data[0])-1; // -1 to remove legend $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; $firstlot=0;
// Works with line but not with bars // 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 //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x

View File

@ -1681,7 +1681,7 @@ class ExtraFields
// Clean parameters // 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"]); $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); $value_arr=GETPOST($keysuffix."options_".$key.$keyprefix);
// Make sure we get an array even if there's only one checkbox // Make sure we get an array even if there's only one checkbox

View File

@ -133,11 +133,14 @@ class HookManager
if (in_array( if (in_array(
$method, $method,
array( array(
'addMoreActionsButtons', 'addCalendarChoice',
'addMoreActionsButtons',
'addMoreMassActions',
'addSearchEntry', 'addSearchEntry',
'addStatisticLine', 'addStatisticLine',
'deleteFile', 'deleteFile',
'doActions', 'doActions',
'doMassActions',
'formCreateThirdpartyOptions', 'formCreateThirdpartyOptions',
'formObjectOptions', 'formObjectOptions',
'formattachOptions', 'formattachOptions',
@ -169,7 +172,6 @@ class HookManager
'printSearchForm', 'printSearchForm',
'printTabsHead', 'printTabsHead',
'formatEvent', 'formatEvent',
'addCalendarChoice',
'printObjectLine', 'printObjectLine',
'printObjectSubLine', 'printObjectSubLine',
'createDictionaryFieldList', 'createDictionaryFieldList',
@ -181,14 +183,16 @@ class HookManager
if ($method == 'insertExtraFields') 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); 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 // Loop on each hook to qualify modules that have declared context
$modulealreadyexecuted=array(); $modulealreadyexecuted=array();
$resaction=0; $error=0; $result=''; $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 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)) if (! empty($modules))

View File

@ -545,11 +545,20 @@ class Form
$disabled=0; $disabled=0;
$ret='<div class="centpercent center">'; $ret='<div class="centpercent center">';
$ret.='<select data-role="none" class="flat'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>'; $ret.='<select data-role="none" class="flat'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>';
$ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>';
foreach($arrayofaction as $code => $label) // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks.
{ $parameters=array();
$ret.='<option value="'.$code.'"'.($disabled?' disabled="disabled"':'').'>'.$label.'</option>'; $reshook=$hookmanager->executeHooks('addMoreMassActions',$parameters); // Note that $action and $object may have been modified by hook
} if (empty($reshook))
{
$ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>';
foreach($arrayofaction as $code => $label)
{
$ret.='<option value="'.$code.'"'.($disabled?' disabled="disabled"':'').'>'.$label.'</option>';
}
}
$ret.=$hookmanager->resPrint;
$ret.='</select>'; $ret.='</select>';
// Warning: if you set submit button to disabled, post using 'Enter' will no more work. // Warning: if you set submit button to disabled, post using 'Enter' will no more work.
$ret.='<input type="submit" data-role="none" name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; $ret.='<input type="submit" data-role="none" name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
@ -1391,7 +1400,7 @@ class Form
* @deprecated * @deprecated
* @see select_dolusers() * @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); 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 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 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 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 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). * @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 * @return string HTML select string
* @see select_dolgroups * @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; global $conf,$user,$langs;
@ -1613,7 +1622,7 @@ class Form
* @return string HTML select string * @return string HTML select string
* @see select_dolgroups * @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; global $conf,$user,$langs;

View File

@ -693,16 +693,17 @@ class FormCompany
* @param string $source Source ('internal' or 'external') * @param string $source Source ('internal' or 'external')
* @param string $sortorder Sort criteria ('position', 'code', ...) * @param string $sortorder Sort criteria ('position', 'code', ...)
* @param int $showempty 1=Add en empty line * @param int $showempty 1=Add en empty line
* @param string $morecss Add more css to select component
* @return void * @return void
*/ */
function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0) function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0, $morecss='')
{ {
global $user, $langs; global $user, $langs;
if (is_object($object) && method_exists($object, 'liste_type_contact')) if (is_object($object) && method_exists($object, 'liste_type_contact'))
{ {
$lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1);
print '<select class="flat valignmiddle" name="'.$htmlname.'" id="'.$htmlname.'">'; print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($showempty) print '<option value="0"></option>'; if ($showempty) print '<option value="0"></option>';
foreach($lesTypes as $key=>$value) foreach($lesTypes as $key=>$value)
{ {

View File

@ -1059,10 +1059,11 @@ class FormMail extends Form
} }
/** /**
* Get list of substition keys available. * Get list of substition keys available for emails.
* This include the complete_substitutions_array. TODO Include the getCommonSubstitutionArray().
* *
* @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ... * @param string $mode 'formemail', 'formemailwithlines', 'formemailforlines', 'emailing', ...
* @return void * @return array Array of substitution values for emails.
*/ */
static function getAvailableSubstitKey($mode='formemail') static function getAvailableSubstitKey($mode='formemail')
{ {
@ -1134,8 +1135,8 @@ class FormMail extends Form
} }
} }
$tmparray=array();
$parameters=array('mode'=>$mode); $parameters=array('mode'=>$mode);
$tmparray=getCommonSubstitutionArray($langs);
complete_substitutions_array($tmparray, $langs, null, $parameters); complete_substitutions_array($tmparray, $langs, null, $parameters);
foreach($tmparray as $key => $val) foreach($tmparray as $key => $val)
{ {

View File

@ -170,21 +170,19 @@ class FormProjets
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$minmax='maxwidth500'; $morecss='maxwidth500';
// Use select2 selector // Use select2 selector
$nodatarole='';
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus); $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
$out.=$comboenhancement; $out.=$comboenhancement;
$nodatarole=($comboenhancement?' data-role="none"':''); $morecss='minwidth100 maxwidth300';
$minmax='minwidth100 maxwidth300';
} }
if (empty($option_only)) { if (empty($option_only)) {
$out.= '<select class="flat'.($minmax?' '.$minmax:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlid.'" name="'.$htmlname.'"'.$nodatarole.'>'; $out.= '<select class="flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlid.'" name="'.$htmlname.'">';
} }
if (!empty($show_empty)) { if (!empty($show_empty)) {
$out.= '<option value="0">&nbsp;</option>'; $out.= '<option value="0">&nbsp;</option>';
@ -302,13 +300,14 @@ class FormProjets
* @param string $htmlname Name of HTML select * @param string $htmlname Name of HTML select
* @param int $maxlength Maximum length of label * @param int $maxlength Maximum length of label
* @param int $option_only Return only html options lines without the select tag * @param int $option_only Return only html options lines without the select tag
* @param int $show_empty Add an empty line * @param string $show_empty Add an empty line ('1' or string to show for empty line)
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
* @param int $forcefocus Force focus on field (works with javascript only) * @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled * @param int $disabled Disabled
* @param string $morecss More css added to the select component
* @return int Nbr of project if OK, <0 if KO * @return int Nbr of project if OK, <0 if KO
*/ */
function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0) function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500')
{ {
global $user,$conf,$langs; global $user,$conf,$langs;
@ -339,28 +338,26 @@ class FormProjets
if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
$sql.= " ORDER BY p.ref, t.ref ASC"; $sql.= " ORDER BY p.ref, t.ref ASC";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$minmax='maxwidth500';
// Use select2 selector // Use select2 selector
$nodatarole='';
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
$out.=$comboenhancement; $out.=$comboenhancement;
$nodatarole=($comboenhancement?' data-role="none"':''); $morecss='minwidth200 maxwidth500';
$minmax='minwidth200 maxwidth500';
} }
if (empty($option_only)) { if (empty($option_only)) {
$out.= '<select class="valignmiddle flat'.($minmax?' '.$minmax:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>'; $out.= '<select class="valignmiddle flat'.($morecss?' '.$morecss:'').'"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.$htmlname.'">';
} }
if (!empty($show_empty)) { if (! empty($show_empty)) {
$out.= '<option value="0">&nbsp;</option>'; $out.= '<option value="0" class="optiongrey">';
if (! is_numeric($show_empty)) $out.=$show_empty;
else $out.='&nbsp;';
$out.= '</option>';
} }
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
@ -370,7 +367,7 @@ class FormProjets
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire))
{ {
// Do nothing // Do nothing
} }
@ -382,7 +379,7 @@ class FormProjets
continue; continue;
} }
$labeltoshow=dol_trunc($obj->ref,18); $labeltoshow=dol_trunc($obj->ref,18); // Project ref
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')';
$labeltoshow.=' '.dol_trunc($obj->title,$maxlength); $labeltoshow.=' '.dol_trunc($obj->title,$maxlength);
@ -532,7 +529,6 @@ class FormProjets
$sql.= " ORDER BY ref DESC"; $sql.= " ORDER BY ref DESC";
dol_syslog(get_class($this).'::select_element', LOG_DEBUG); dol_syslog(get_class($this).'::select_element', LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2014 delcroip <delcroip@gmail.com> /* Copyright (C) 2014 delcroip <delcroip@gmail.com>
* Laurent Destailleur 2015 <eldy@users.sourceforge.net> * Copyright (C) 2015-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -588,7 +588,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
if (empty($srcfile) || empty($destfile)) return -1; if (empty($srcfile) || empty($destfile)) return -1;
$destexists=dol_is_dir($destfile); $destexists=dol_is_dir($destfile);
//if (! $overwriteifexists && $destexists) return 0; // The overwriteifexists is for files only, so propaated to dol_copy only. //if (! $overwriteifexists && $destexists) return 0; // The overwriteifexists is for files only, so propagated to dol_copy only.
if (! $destexists) if (! $destexists)
{ {
@ -839,8 +839,8 @@ function dolCheckVirus($src_file)
* If there is errors (virus found, antivir in error, bad filename), file is not moved. * If there is errors (virus found, antivir in error, bad filename), file is not moved.
* Note: * Note:
* - This function can be used only into a HTML page context. Use dol_move if you are outside. * - This function can be used only into a HTML page context. Use dol_move if you are outside.
* - Database of files is not updated.
* - Test on antivirus is always done (if antivirus set). * - Test on antivirus is always done (if antivirus set).
* - Database of files is NOT updated.
* *
* @param string $src_file Source full path filename ($_FILES['field']['tmp_name']) * @param string $src_file Source full path filename ($_FILES['field']['tmp_name'])
* @param string $dest_file Target full path filename ($_FILES['field']['name']) * @param string $dest_file Target full path filename ($_FILES['field']['name'])
@ -1685,6 +1685,91 @@ function dol_uncompress($inputfile,$outputdir)
} }
/**
* Compress a directory and subdirectories into a package file.
*
* @param string $inputdir Source dir name
* @param string $outputfile Target file name
* @param string $mode 'zip'
* @return int <0 if KO, >0 if OK
*/
function dol_compress_dir($inputdir, $outputfile, $mode="zip")
{
$foundhandler=0;
dol_syslog("Try to zip dir ".$inputdir." into ".$outputdir." mode=".$mode);
try
{
if ($mode == 'gz') { $foundhandler=0; }
elseif ($mode == 'bz') { $foundhandler=0; }
elseif ($mode == 'zip')
{
/*if (defined('ODTPHP_PATHTOPCLZIP'))
{
$foundhandler=0; // TODO implement this
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
$archive = new PclZip($outputfile);
$archive->add($inputfile, PCLZIP_OPT_REMOVE_PATH, dirname($inputfile));
//$archive->add($inputfile);
return 1;
}
else*/
if (class_exists('ZipArchive'))
{
$foundhandler=1;
// Initialize archive object
$zip = new ZipArchive();
$zip->open($outputfile, ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($inputdir),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
// Skip directories (they would be added automatically)
if (!$file->isDir())
{
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($inputdir) + 1);
// Add current file to archive
$zip->addFile($filePath, $relativePath);
}
}
// Zip archive will be created only after closing object
$zip->close();
return 1;
}
}
if (! $foundhandler)
{
dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR);
return -2;
}
}
catch (Exception $e)
{
global $langs, $errormsg;
$langs->load("errors");
dol_syslog("Failed to open file ".$outputfile, LOG_ERR);
dol_syslog($e->getMessage(), LOG_ERR);
$errormsg=$langs->trans("ErrorFailedToWriteInDir",$outputfile);
return -1;
}
}
/** /**
* Return file(s) into a directory (by default most recent) * Return file(s) into a directory (by default most recent)
* *

View File

@ -100,7 +100,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
} }
/** /**
* Get list of entity id to use * Get list of entity id to use.
* *
* @param string $element Current element * @param string $element Current element
* 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', * 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource',
@ -110,10 +110,10 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
* 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey',
* 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project',
* 'email_template', 'event', * 'email_template', 'event',
* @param int $shared true=Return id entity + shared entities (by default), false=Return id of current entity or referent entity if current element is "societe" * @param int $shared 1=Return id of current entity + shared entities (default), 0=Return id of current entity only
* @return mixed Entity id(s) to use * @return mixed Entity id(s) to use
*/ */
function getEntity($element=false, $shared=true) function getEntity($element=false, $shared=1)
{ {
global $conf, $mc; global $conf, $mc;
@ -239,7 +239,7 @@ function dol_shutdown()
/** /**
* Return value of a param into GET or POST supervariable. * Return value of a param into GET or POST supervariable.
* Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder'] * Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder']
* Note: The property $user->default_values is loaded by the main when loading the user. * Note: The property $user->default_values is loaded by main.php when loading the user.
* *
* @param string $paramname Name of parameter to found * @param string $paramname Name of parameter to found
* @param string $check Type of check * @param string $check Type of check
@ -359,32 +359,34 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
if (! empty($check)) if (! empty($check))
{ {
// Replace vars like __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__, ... // Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable paramaters)
if (! is_array($out)) // Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__, ...
// We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text.
if (! is_array($out) && empty($_POST[$paramname]))
{ {
$maxloop=20; $loopnb=0; // Protection against infinite loop $maxloop=20; $loopnb=0; // Protection against infinite loop
while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side. while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
{ {
$loopnb++; $newout = ''; $loopnb++; $newout = '';
if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; } if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; }
elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; } elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; }
elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; } elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; }
elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); }
elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); }
elseif ($reg[1] == 'MYCOUNTRYID') elseif ($reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID')
{ {
$newout = $mysoc->country_id; $newout = $mysoc->country_id;
} }
elseif ($reg[1] == 'USERID') elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID')
{ {
$newout = $user->id; $newout = $user->id;
} }
elseif ($reg[1] == 'SUPERVISORID') elseif ($reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID')
{ {
$newout = $user->fk_user; $newout = $user->fk_user;
} }
@ -1586,7 +1588,8 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
if (preg_match('/__b__/i',$format)) if (preg_match('/__b__/i',$format))
{ {
// Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs.
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Remove this $month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
$month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'.
if ($encodetooutput) if ($encodetooutput)
{ {
$monthtext=$outputlangs->transnoentities('Month'.$month); $monthtext=$outputlangs->transnoentities('Month'.$month);
@ -2554,6 +2557,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$picto = $regs[1]; $picto = $regs[1];
$path = $regs[2]; // $path is $mymodule $path = $regs[2]; // $path is $mymodule
} }
// Clean parameters // Clean parameters
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png'; if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png';
// If alt path are defined, define url where img file is, according to physical path // If alt path are defined, define url where img file is, according to physical path
@ -2792,7 +2796,7 @@ function img_printer($titlealt = "default", $other='')
} }
/** /**
* Show delete logo * Show split logo
* *
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title. * @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
* @param string $other Add more attributes on img * @param string $other Add more attributes on img
@ -3233,15 +3237,19 @@ function dol_print_error($db='',$error='',$errors=null)
* Show a public email and error code to contact if technical error * Show a public email and error code to contact if technical error
* *
* @param string $prefixcode Prefix of public error code * @param string $prefixcode Prefix of public error code
* @param string $errormessage Complete error message
* @return void * @return void
*/ */
function dol_print_error_email($prefixcode) function dol_print_error_email($prefixcode, $errormessage='')
{ {
global $langs,$conf; global $langs,$conf;
$langs->load("errors"); $langs->load("errors");
$now=dol_now(); $now=dol_now();
print '<br><div class="error">'.$langs->trans("ErrorContactEMail", $conf->global->MAIN_INFO_SOCIETE_MAIL, $prefixcode.dol_print_date($now,'%Y%m%d')).'</div>'; print '<br><div class="center login_main_message"><div class="error">';
print $langs->trans("ErrorContactEMail", $conf->global->MAIN_INFO_SOCIETE_MAIL, $prefixcode.dol_print_date($now,'%Y%m%d'));
if ($errormessage) print '<br><br>'.$errormessage;
print '</div></div>';
} }
/** /**
@ -4704,7 +4712,12 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
$pattern = "/<[^<>]+>/"; $pattern = "/<[^<>]+>/";
$StringHtml = preg_replace('/<br[^>]*>/', "\n", $StringHtml); $StringHtml = preg_replace('/<br[^>]*>/', "\n", $StringHtml);
$temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto); $temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto);
$temp = preg_replace($pattern,"",$temp);
// Exemple of $temp: <a href="/myurl" title="<u>A title</u>">0000-021</a>
$temp = preg_replace($pattern,"",$temp); // pass 1
// $temp after pass 1: <a href="/myurl" title="A title">0000-021
$temp = preg_replace($pattern,"",$temp); // pass 2
// $temp after pass 2: 0000-021
// Supprime aussi les retours // Supprime aussi les retours
if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp); if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp);
@ -5009,8 +5022,100 @@ function dol_concatdesc($text1,$text2,$forxml=false)
return $ret; return $ret;
} }
/** /**
* Make substition into a string replacing key with vals from $substitutionarray (oldval=>newval) * Return array of possible common substitutions.
*
* @param Translate $outputlangs Output language
* @param int $onlykey Do not calculate heavy values of keys (performance enhancement when we need only the keys)
* @param array $exclude Array of family keys we want to exclude. For example array('mycompany', 'objectamount', 'date', 'user', ...)
* @param Object $object Object for keys on object
* @return array Array of substitutions
*/
function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
{
global $conf, $mysoc, $user;
$substitutionarray=array();
if (empty($exclude) || ! in_array('mycompany', $exclude))
{
$substitutionarray=array_merge($substitutionarray, array(
'__MYCOMPANY_NAME__' => $mysoc->name,
'__MYCOMPANY_EMAIL__' => $mysoc->email,
'__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
'__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
'__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
'__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
'__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
'__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
'__MYCOMPANY_CAPITAL__' => $mysoc->capital,
'__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id
));
}
if (empty($exclude) || ! in_array('objectamount', $exclude))
{
if (is_object($object)) // For backward compatibility
{
$substitutionarray['__TOTAL_TTC__'] =is_object($object)?$object->total_ttc:'';
$substitutionarray['__TOTAL_HT__'] =is_object($object)?$object->total_ht:'';
$substitutionarray['__TOTAL_VAT__'] =is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):'';
}
$substitutionarray['__AMOUNT__'] =is_object($object)?$object->total_ttc:'';
$substitutionarray['__AMOUNT_WO_TAX__']=is_object($object)?$object->total_ht:'';
$substitutionarray['__AMOUNT_VAT__'] =is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):'';
}
if (empty($exclude) || ! in_array('date', $exclude))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($onlykey))
{
$tmp=$tmp2=$tmp3=$tmp4=$tmp5=array();
}
else
{
$tmp=dol_getdate(dol_now(), true);
$tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp3=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
$tmp5=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']);
}
$substitutionarray=array_merge($substitutionarray, array(
'__DAY__' => $tmp['mday'],
'__MONTH__' => $tmp['mon'],
'__YEAR__' => $tmp['year'],
'__PREVIOUS_DAY__' => $tmp2['day'],
'__PREVIOUS_MONTH__' => $tmp3['month'],
'__PREVIOUS_YEAR__' => ($tmp['year'] - 1),
'__NEXT_DAY__' => $tmp4['day'],
'__NEXT_MONTH__' => $tmp5['month'],
'__NEXT_YEAR__' => ($tmp['year'] + 1),
));
}
if (empty($exclude) || ! in_array('user', $exclude))
{
$substitutionarray=array_merge($substitutionarray, array(
'__USER_ID__' => $user->id,
'__USER_LOGIN__' => $user->login,
'__USER_LASTNAME__' => $user->lastname,
'__USER_FIRSTNAME__' => $user->firstname,
'__USER_FULLNAME__' => $user->getFullName($outputlangs),
'__USER_SUPERVISOR_ID__' => $user->fk_user
));
}
if (! empty($conf->multicompany->enabled))
{
$substitutionarray=array_merge($substitutionarray, array('__ENTITY_ID__' => $conf->entity));
}
return $substitutionarray;
}
/**
* Make substition into a text string, replacing keys with vals from $substitutionarray (oldval=>newval).
* *
* @param string $text Source string in which we must do substitution * @param string $text Source string in which we must do substitution
* @param array $substitutionarray Array with key->val to substitute * @param array $substitutionarray Array with key->val to substitute
@ -5029,11 +5134,16 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
// Make substitution for language keys // Make substitution for language keys
if (is_object($outputlangs)) if (is_object($outputlangs))
{ {
while (preg_match('/__\((.*)\)__/', $text, $reg)) while (preg_match('/__\(([^\)]*)\)__/', $text, $reg))
{ {
// If key is __(TranslationKey|langfile)__, then force load of langfile.lang
$tmp=explode('|',$reg[1]);
if (! empty($tmp[1])) $outputlangs->load($tmp[1]);
$msgishtml = 0; $msgishtml = 0;
if (dol_textishtml($text,1)) $msgishtml = 1; if (dol_textishtml($text,1)) $msgishtml = 1;
$text = preg_replace('/__\('.preg_quote($reg[1]).'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
$text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
} }
} }

20
htdocs/core/lib/functions2.lib.php Normal file → Executable file
View File

@ -711,7 +711,7 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti
*/ */
function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true) function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true)
{ {
global $conf; global $conf,$user;
if (! is_object($objsoc)) $valueforccc=$objsoc; if (! is_object($objsoc)) $valueforccc=$objsoc;
else if($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur; else if($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur;
@ -791,6 +791,15 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
$tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew, $tmpmask); $tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew, $tmpmask);
}*/ }*/
if (strstr($mask,'user_extra_'))
{
$start = "{user_extra_";
$end = "\}";
$extra= get_string_between($mask, "user_extra_", "}");
if(!empty($user->array_options['options_'.$extra])){
$mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask);
}
}
$maskwithonlyymcode=$mask; $maskwithonlyymcode=$mask;
$maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode); $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode);
$maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode); $maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode);
@ -1110,7 +1119,14 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
dol_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG); dol_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG);
return $numFinal; return $numFinal;
} }
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
/** /**
* Check value * Check value
* *

View File

@ -588,38 +588,26 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
/** /**
* Return array of possible substitutions * Return array of possible substitutions for PDF content (without external module substitutions).
* *
* @param Translate $outputlangs Output language * @param Translate $outputlangs Output language
* @param array $exclude Array of family keys we want to exclude. For example array('mycompany', 'object', 'date', 'user', ...)
* @param Object $object Object
* @return array Array of substitutions * @return array Array of substitutions
*/ */
function pdf_getSubstitutionArray($outputlangs) function pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null)
{ {
global $conf, $mysoc, $user; $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $exclude, $object);
$substitutionarray=array( $substitutionarray['__FROM_NAME__']='__FROM_NAME__';
'__MYCOMPANY_NAME__' => $mysoc->name, $substitutionarray['__FROM_EMAIL__']='__FROM_EMAIL__';
'__MYCOMPANY_EMAIL__' => $mysoc->email, return $substitutionarray;
'__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
'__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
'__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
'__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
'__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
'__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
'__MYCOMPANY_CAPITAL__' => $mysoc->capital,
'__USER_ID__' => $user->id,
'__USER_LOGIN__' => $user->login,
'__USER_LASTNAME__' => $user->lastname,
'__USER_FIRSTNAME__' => $user->firstname,
'__USER_FULLNAME__' => $user->getFullName($outputlangs)
);
return $substitutionarray;
} }
/** /**
* Add a draft watermark on PDF files * Add a draft watermark on PDF files
* *
* @param TCPDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param Translate $outputlangs Object lang * @param Translate $outputlangs Object lang
* @param int $h Height of PDF * @param int $h Height of PDF
* @param int $w Width of PDF * @param int $w Width of PDF
@ -638,9 +626,9 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
elseif ($unit=='in') $k=72; elseif ($unit=='in') $k=72;
// Make substitution // Make substitution
$substitutionarray=pdf_getSubstitutionArray($outputlangs); $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, null);
complete_substitutions_array($substitutionarray,$outputlangs,$object); complete_substitutions_array($substitutionarray, $outputlangs, null);
$text=make_substitutions($text,$substitutionarray,$outputlangs); $text=make_substitutions($text, $substitutionarray, $outputlangs);
$text=$outputlangs->convToOutputCharset($text); $text=$outputlangs->convToOutputCharset($text);
$savx=$pdf->getX(); $savy=$pdf->getY(); $savx=$pdf->getX(); $savy=$pdf->getY();
@ -867,15 +855,12 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
// Line of free text // Line of free text
if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext)) if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext))
{ {
$substitutionarray=pdf_getSubstitutionArray($outputlangs); $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
// More substitution keys // More substitution keys
$substitutionarray['__FROM_NAME__']=$fromcompany->name; $substitutionarray['__FROM_NAME__']=$fromcompany->name;
$substitutionarray['__FROM_EMAIL__']=$fromcompany->email; $substitutionarray['__FROM_EMAIL__']=$fromcompany->email;
$substitutionarray['__TOTAL_TTC__']=$object->total_ttc; complete_substitutions_array($substitutionarray, $outputlangs, $object);
$substitutionarray['__TOTAL_HT__']=$object->total_ht; $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs);
$substitutionarray['__TOTAL_VAT__']=$object->total_vat;
complete_substitutions_array($substitutionarray,$outputlangs,$object);
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray,$outputlangs);
$line.=$outputlangs->convToOutputCharset($newfreetext); $line.=$outputlangs->convToOutputCharset($newfreetext);
} }

View File

@ -208,9 +208,10 @@ function task_prepare_head($object)
* Prepare array with list of tabs * Prepare array with list of tabs
* *
* @param string $mode Mode * @param string $mode Mode
* @param string $fuser Filter on user
* @return array Array of tabs to show * @return array Array of tabs to show
*/ */
function project_timesheet_prepare_head($mode) function project_timesheet_prepare_head($mode, $fuser=null)
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
$h = 0; $h = 0;
@ -218,9 +219,13 @@ function project_timesheet_prepare_head($mode)
$h = 0; $h = 0;
$param='';
$param.=($mode?'&mode='.$mode:'');
if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id;
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
{ {
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($mode?'?mode='.$mode:''); $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:'');
$head[$h][1] = $langs->trans("InputPerWeek"); $head[$h][1] = $langs->trans("InputPerWeek");
$head[$h][2] = 'inputperweek'; $head[$h][2] = 'inputperweek';
$h++; $h++;
@ -228,7 +233,7 @@ function project_timesheet_prepare_head($mode)
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
{ {
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:''); $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:'');
$head[$h][1] = $langs->trans("InputPerDay"); $head[$h][1] = $langs->trans("InputPerDay");
$head[$h][2] = 'inputperday'; $head[$h][2] = 'inputperday';
$h++; $h++;
@ -621,7 +626,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$taskstatic->id=$lines[$i]->id; $taskstatic->id=$lines[$i]->id;
print "<tr ".$bc[$var].">\n"; print '<tr class="oddeven">'."\n";
// User
print '<td class="nowrap">';
print $fuser->getNomUrl(1, 'withproject', 'time');
print '</td>';
// Ref // Ref
print '<td>'; print '<td>';
@ -707,7 +717,10 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '<td class="nowrap" align="center">'; print '<td class="nowrap" align="center">';
$tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask); $tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask);
print $tableCell; print $tableCell;
print '</td><td align="right">'; print '</td>';
// Duration
print '<td align="right">';
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
$alreadyspent=''; $alreadyspent='';
@ -723,13 +736,14 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject")); print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>';
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou")); print '</textarea>';
print '</td>'; print '</td>';
// Warning
print '<td align="right">'; print '<td align="right">';
print '<textarea name="'.$lines[$i]->id.'note" rows="2" id="note">'; if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
print '</textarea>'; else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $langs->transnoentitiesnoconv("AssignTaskToUser", '...')));
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -818,7 +832,12 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$workloadforid[$projectstatic->id]=1; $workloadforid[$projectstatic->id]=1;
} }
print "<tr ".$bc[$var].">\n"; print '<tr class="oddeven">'."\n";
// User
print '<td class="nowrap">';
print $fuser->getNomUrl(1, 'withproject', 'time');
print '</td>';
// Ref // Ref
print '<td class="nowrap">'; print '<td class="nowrap">';
@ -842,7 +861,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
print "</td>\n"; print "</td>\n";
// Project // Project
print '<td class="nowrap">'.$var; print '<td class="nowrap">';
$projectstatic->id=$lines[$i]->fk_project; $projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref; $projectstatic->ref=$lines[$i]->projectref;
$projectstatic->title=$lines[$i]->projectlabel; $projectstatic->title=$lines[$i]->projectlabel;
@ -935,9 +954,10 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
print $tableCell; print $tableCell;
} }
// Warning
print '<td align="right">'; print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject")); if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou")); else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $langs->transnoentitiesnoconv("AssignTaskToUser", '...')));
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -345,7 +345,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
* This function is also called by restrictedArea * This function is also called by restrictedArea
* *
* @param User $user User to check * @param User $user User to check
* @param array $featuresarray Features/modules to check. Example: ('user','service') * @param array $featuresarray Features/modules to check. Example: ('user','service','member','project','task',...)
* @param int $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional). * @param int $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
* @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional). * @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional).
* @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. * @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
@ -369,11 +369,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
// For backward compatibility // For backward compatibility
if ($feature == 'member') $feature='adherent'; if ($feature == 'member') $feature='adherent';
if ($feature == 'project') $feature='projet';
if ($feature == 'task') $feature='projet_task';
$check = array('adherent','banque','user','usergroup','produit','service','produit|service','categorie'); // Test on entity only (Objects with no link to company) $check = array('adherent','banque','user','usergroup','produit','service','produit|service','categorie'); // Test on entity only (Objects with no link to company)
$checksoc = array('societe'); // Test for societe object $checksoc = array('societe'); // Test for societe object
$checkother = array('contact'); // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...). $checkother = array('contact'); // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
$checkproject = array('projet'); // Test for project object $checkproject = array('projet','project'); // Test for project object
$checktask = array('projet_task');
$nocheck = array('barcode','stock','fournisseur'); // No test $nocheck = array('barcode','stock','fournisseur'); // No test
$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). $checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
@ -453,7 +456,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
} }
else if (in_array($feature,$checkproject)) else if (in_array($feature,$checkproject))
{ {
if (! empty($conf->projet->enabled) && ! $user->rights->projet->all->lire) if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
{ {
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projectstatic=new Project($db); $projectstatic=new Project($db);
@ -469,6 +472,27 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
} }
} }
else if (in_array($feature,$checktask))
{
if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
{
$task = new Task($db);
$task->fetch($objectid);
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projectstatic=new Project($db);
$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
$tmparray=explode(',',$tmps);
if (! in_array($task->fk_project,$tmparray)) return false;
}
else
{
$sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
}
}
else if (! in_array($feature,$nocheck)) // By default we check with link to third party else if (! in_array($feature,$nocheck)) // By default we check with link to third party
{ {
// If external user: Check permission for external users // If external user: Check permission for external users

View File

@ -265,15 +265,11 @@ function dol_loginfunction($langs,$conf,$mysoc)
$main_home=''; $main_home='';
if (! empty($conf->global->MAIN_HOME)) if (! empty($conf->global->MAIN_HOME))
{ {
$i=0; $substitutionarray=getCommonSubstitutionArray($langs);
while (preg_match('/__\(([a-zA-Z|@]+)\)__/i',$conf->global->MAIN_HOME,$reg) && $i < 100) complete_substitutions_array($substitutionarray, $langs);
{ $texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs);
$tmp=explode('|',$reg[1]);
if (! empty($tmp[1])) $langs->load($tmp[1]); $main_home=dol_htmlcleanlastbr($texttoshow);
$conf->global->MAIN_HOME=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i',$langs->trans($tmp[0]),$conf->global->MAIN_HOME);
$i++;
}
$main_home=dol_htmlcleanlastbr($conf->global->MAIN_HOME);
} }
// Google AD // Google AD

View File

@ -288,6 +288,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3701__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/tasks.php?leftmenu=projects&amp;action=create', 'NewTask', 1, 'projects', '$user->rights->projet->creer', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3701__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/tasks.php?leftmenu=projects&amp;action=create', 'NewTask', 1, 'projects', '$user->rights->projet->creer', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3702__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/tasks/list.php?leftmenu=projects', 'List', 1, 'projects', '$user->rights->projet->lire', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3702__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/tasks/list.php?leftmenu=projects', 'List', 1, 'projects', '$user->rights->projet->lire', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3703__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/activity/perweek.php?leftmenu=projects', 'NewTimeSpent', 1, 'projects', '$user->rights->projet->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3703__+MAX_llx_menu__, 'project', '', 3700__+MAX_llx_menu__, '/projet/activity/perweek.php?leftmenu=projects', 'NewTimeSpent', 1, 'projects', '$user->rights->projet->lire', '', 2, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3704__+MAX_llx_menu__, 'project', '', 3600__+MAX_llx_menu__, '/projet/tasks/stats/index.php?leftmenu=projects', 'Statistics', 1, 'projects', '$user->rights->projet->lire', '', 2, 4, __ENTITY__);
-- Project - Categories -- Project - Categories
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3804__+MAX_llx_menu__, 'project', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&amp;type=6', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3804__+MAX_llx_menu__, 'project', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&amp;type=6', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__);

View File

@ -1322,6 +1322,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer); $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer);
$newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user?'&search_project_user='.$search_project_user:''), $langs->trans("List"), 1, $user->rights->projet->lire); $newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user?'&search_project_user='.$search_project_user:''), $langs->trans("List"), 1, $user->rights->projet->lire);
$newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user?'&search_project_user='.$search_project_user:''), $langs->trans("NewTimeSpent"), 1, $user->rights->projet->lire); $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user?'&search_project_user='.$search_project_user:''), $langs->trans("NewTimeSpent"), 1, $user->rights->projet->lire);
$newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
// All project i have permission on // All project i have permission on
/*$newmenu->add("/projet/activity/index.php", $langs->trans("Activities"), 0, $user->rights->projet->lire && $user->rights->projet->lire); /*$newmenu->add("/projet/activity/index.php", $langs->trans("Activities"), 0, $user->rights->projet->lire && $user->rights->projet->lire);

View File

@ -538,8 +538,8 @@ class DolibarrModules // Can not be abstract, because we need to insta
return $langs->trans("Module".$this->numero."Name"); return $langs->trans("Module".$this->numero."Name");
} }
else else
{ {
// If module name translation using it's unique id does not exists, we take use its name to find translation // If module name translation using it's unique id does not exists, we try to use its name to find translation
if (is_array($this->langfiles)) if (is_array($this->langfiles))
{ {
foreach($this->langfiles as $val) foreach($this->langfiles as $val)
@ -547,6 +547,14 @@ class DolibarrModules // Can not be abstract, because we need to insta
if ($val) $langs->load($val); if ($val) $langs->load($val);
} }
} }
if ($langs->trans("Module".$this->name."Name") != ("Module".$this->name."Name"))
{
// If module name translation exists
return $langs->trans("Module".$this->name."Name");
}
// Last change with simple product label
return $langs->trans($this->name); return $langs->trans($this->name);
} }
} }

View File

@ -102,16 +102,10 @@ class doc_generic_contract_odt extends ModelePDFContract
$form = new Form($this->db); $form = new Form($this->db);
$texte = $this->description.".<br>\n"; $texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">'; $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="CONTRACT_ADDON_PDF_ODT_PATH">'; $texte.= '<input type="hidden" name="param1" value="CONTRACT_ADDON_PDF_ODT_PATH">';
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
$texte.= '<input type="hidden" name="param2" value="CONTRACT_ADDON_PDF_ODT_DEFAULT">';
$texte.= '<input type="hidden" name="param3" value="CONTRACT_ADDON_PDF_ODT_TOBILL">';
$texte.= '<input type="hidden" name="param4" value="CONTRACT_ADDON_PDF_ODT_CLOSED">';
}
$texte.= '<table class="nobordernopadding" width="100%">'; $texte.= '<table class="nobordernopadding" width="100%">';
// List of directories area // List of directories area
@ -144,40 +138,21 @@ class doc_generic_contract_odt extends ModelePDFContract
$texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH; $texte.=$conf->global->CONTRACT_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>'; $texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; $texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'" name="Button">';
$texte.= '<br></div></div>'; $texte.= '<br></div></div>';
// Scan directories // Scan directories
if (count($listofdir)) if (count($listofdir))
{ {
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>'; $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
// Model for creation
$liste=ModelePDFContract::liste_modeles($this->db);
$texte.= '<table width="50%;">';
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value2',$liste,$conf->global->CONTRACT_ADDON_PDF_ODT_DEFAULT);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value3',$liste,$conf->global->CONTRACT_ADDON_PDF_ODT_TOBILL);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value4',$liste,$conf->global->CONTRACT_ADDON_PDF_ODT_CLOSED);
$texte.= "</td></tr>";
$texte.= '</table>';
}
} }
// Add select to upload a new template file. TODO Copy this feature on other admin pages.
$texte.= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
$texte.= '<input type="hidden" value="CONTRACT_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
$texte.= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
$texte.= '</div>';
$texte.= '</td>'; $texte.= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';

View File

@ -296,20 +296,23 @@ class pdf_strato extends ModelePDFContract
} }
$txtpredefinedservice=''; $txtpredefinedservice='';
$txtpredefinedservice = $objectligne->product_ref; $txtpredefinedservice = $objectligne->product_label;
if ($objectligne->product_label) if ($objectligne->product_label)
{ {
$txtpredefinedservice .= ' - '; $txtpredefinedservice .= ' - ';
$txtpredefinedservice .= $objectligne->product_label; $txtpredefinedservice .= $objectligne->product_label;
} }
$txt='<strong>'.dol_htmlentitiesbr($outputlangs->transnoentities("DateStartPlannedShort")." : ".$datei." - ".$outputlangs->transnoentities("DateEndPlanned")." : ".$datee,1,$outputlangs->charset_output).'</strong>'; $desc=dol_htmlentitiesbr($objectligne->desc,1); // Desc (not empty for free lines)
$txt='';
$txt.=$outputlangs->transnoentities("Quantity").' : <strong>'.$objectligne->qty.'</strong> - '.$outputlangs->transnoentities("UnitPrice").' : <strong>'.price($objectligne->subprice).'</strong>'; // Desc (not empty for free lines)
$txt.='<br>'; $txt.='<br>';
$txt.='<strong>'.dol_htmlentitiesbr($outputlangs->transnoentities("DateStartRealShort")." : ".$daters,1,$outputlangs->charset_output); $txt.=$outputlangs->transnoentities("DateStartPlannedShort")." : <strong>".$datei."</strong> - ".$outputlangs->transnoentities("DateEndPlanned")." : <strong>".$datee.'</strong>';
if ($objectligne->date_cloture) $txt.=dol_htmlentitiesbr(" - ".$outputlangs->transnoentities("DateEndRealShort")." : ".$datere,1,$outputlangs->charset_output).'</strong>'; $txt.='<br>';
$desc=dol_htmlentitiesbr($objectligne->desc,1); $txt.=$outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
if ($objectligne->date_cloture) $txt.=" - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,dol_concatdesc($txtpredefinedservice,$desc)), 0, 1, 0); $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txtpredefinedservice, dol_concatdesc($txt, $desc)), 0, 1, 0);
$nexY = $pdf->GetY() + 2; $nexY = $pdf->GetY() + 2;
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();

View File

@ -121,7 +121,7 @@ else if ($action == 'del')
// Options // Options
if ($action == 'set_DONATION_ACCOUNTINGACCOUNT') if ($action == 'set_DONATION_ACCOUNTINGACCOUNT')
{ {
$account = GETPOST('DONATION_ACCOUNTINGACCOUNT'); // No alpha here, we want exact string $account = GETPOST('DONATION_ACCOUNTINGACCOUNT','alpha');
$res = dolibarr_set_const($db, "DONATION_ACCOUNTINGACCOUNT",$account,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "DONATION_ACCOUNTINGACCOUNT",$account,'chaine',0,'',$conf->entity);
@ -139,7 +139,7 @@ if ($action == 'set_DONATION_ACCOUNTINGACCOUNT')
if ($action == 'set_DONATION_MESSAGE') if ($action == 'set_DONATION_MESSAGE')
{ {
$freemessage = GETPOST('DONATION_MESSAGE'); // No alpha here, we want exact string $freemessage = GETPOST('DONATION_MESSAGE','none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "DONATION_MESSAGE",$freemessage,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "DONATION_MESSAGE",$freemessage,'chaine',0,'',$conf->entity);

View File

@ -31,7 +31,7 @@
*/ */
if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr');
if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
if (! defined('EURO')) define('EURO',chr(128)); if (! defined('EURO')) define('EURO',chr(128));

View File

@ -570,14 +570,43 @@ if ($action == 'confirm_refuse')
} }
} }
// Si Validation de la demande
if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes')
{
$object = new Holiday($db);
$object->fetch($id);
$oldstatus = $object->statut;
$object->statut = 1;
$result = $object->update($user);
if ($result < 0)
{
$error = $langs->trans('ErrorBackToDraft');
}
if (! $error)
{
$db->commit();
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
else
{
$db->rollback();
}
}
// Si Validation de la demande // Si Validation de la demande
if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes')
{ {
$object = new Holiday($db); $object = new Holiday($db);
$object->fetch($id); $object->fetch($id);
// Si statut en attente de validation et valideur = utilisateur // Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres
if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || $user->id == $object->fk_user)) if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all)))
{ {
$db->begin(); $db->begin();
@ -995,6 +1024,12 @@ else
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1);
} }
// Si back to draft
if ($action == 'backtodraft')
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleSetToDraft"),$langs->trans("ConfirmSetToDraft"),"confirm_draft", '', 1, 1);
}
$head=holiday_prepare_head($object); $head=holiday_prepare_head($object);
@ -1214,18 +1249,31 @@ else
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>';
} }
if ($user->id == $object->fk_validator && $object->statut == 2) if ($object->statut == 2)
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>'; if ($user->id == $object->fk_validator)
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>'; {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>';
}
else
{
print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("Approve").'</a>';
print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("ActionRefuseCP").'</a>';
}
} }
if (($user->id == $object->fk_validator || $user->id == $object->fk_user) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved if (($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved
{ {
if (($object->date_debut > dol_now()) || $user->admin) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>'; if (($object->date_debut > dol_now()) || $user->admin) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
else print '<a href="#" class="butActionRefused" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>'; else print '<a href="#" class="butActionRefused" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>';
} }
if ($canedit && $object->statut == 4)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'</a>';
}
print '</div>'; print '</div>';
} }

View File

@ -88,18 +88,13 @@ if (! empty($conf->global->MAIN_MOTD))
$conf->global->MAIN_MOTD=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$conf->global->MAIN_MOTD); $conf->global->MAIN_MOTD=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$conf->global->MAIN_MOTD);
if (! empty($conf->global->MAIN_MOTD)) if (! empty($conf->global->MAIN_MOTD))
{ {
$i=0; $substitutionarray=getCommonSubstitutionArray($langs);
while (preg_match('/__\(([a-zA-Z|@]+)\)__/i',$conf->global->MAIN_MOTD,$reg) && $i < 100) complete_substitutions_array($substitutionarray, $langs);
{ $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs);
$tmp=explode('|',$reg[1]);
if (! empty($tmp[1])) $langs->load($tmp[1]);
$conf->global->MAIN_MOTD=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i',$langs->trans($tmp[0]),$conf->global->MAIN_MOTD);
$i++;
}
print "\n<!-- Start of welcome text -->\n"; print "\n<!-- Start of welcome text -->\n";
print '<table width="100%" class="notopnoleftnoright"><tr><td>'; print '<table width="100%" class="notopnoleftnoright"><tr><td>';
print dol_htmlentitiesbr($conf->global->MAIN_MOTD); print dol_htmlentitiesbr($texttoshow);
print '</td></tr></table><br>'; print '</td></tr></table><br>';
print "\n<!-- End of welcome text -->\n"; print "\n<!-- End of welcome text -->\n";
} }

View File

@ -46,6 +46,7 @@ ALTER TABLE llx_facture_fourn_det ADD INDEX idx_facture_fourn_det_fk_product (fk
ALTER TABLE llx_facture_rec ADD COLUMN fk_user_modif integer; ALTER TABLE llx_facture_rec ADD COLUMN fk_user_modif integer;
ALTER TABLE llx_expedition ADD COLUMN fk_user_modif integer; ALTER TABLE llx_expedition ADD COLUMN fk_user_modif integer;
ALTER TABLE llx_projet ADD COLUMN fk_user_modif integer;
ALTER TABLE llx_adherent ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_adherent ADD COLUMN model_pdf varchar(255);

View File

@ -159,6 +159,9 @@ CREATE TABLE llx_product_attribute_combination
ALTER TABLE llx_bank_account drop foreign key bank_fk_accountancy_journal; ALTER TABLE llx_bank_account drop foreign key bank_fk_accountancy_journal;
-- Fix missing entity column after init demo
ALTER TABLE llx_accounting_journal ADD COLUMN entity integer DEFAULT 1;
-- Add journal entries -- Add journal entries
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Sale journal', 2, 1); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (1,'VT', 'Sale journal', 2, 1);
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Purchase journal', 3, 1); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (2,'AC', 'Purchase journal', 3, 1);
@ -348,5 +351,31 @@ ALTER TABLE llx_facture ADD COLUMN fk_fac_rec_source integer;
DELETE from llx_c_actioncomm where code in ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm); DELETE from llx_c_actioncomm where code in ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm);
-- Fix: delete orphelin category.
delete from llx_categorie_product where fk_categorie not in (select rowid from llx_categorie where type = 0);
delete from llx_categorie_societe where fk_categorie not in (select rowid from llx_categorie where type in (1, 2));
delete from llx_categorie_member where fk_categorie not in (select rowid from llx_categorie where type = 3);
delete from llx_categorie_contact where fk_categorie not in (select rowid from llx_categorie where type = 4);
delete from llx_categorie_project where fk_categorie not in (select rowid from llx_categorie where type = 5);
ALTER TABLE llx_inventory ADD COLUMN ref varchar(48); ALTER TABLE llx_inventory ADD COLUMN ref varchar(48);
create table llx_loan_schedule
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_loan integer,
datec datetime,
tms timestamp,
datep datetime,
amount_capital real DEFAULT 0,
amount_insurance real DEFAULT 0,
amount_interest real DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50),
note_private text,
note_public text,
fk_bank integer NOT NULL,
fk_user_creat integer,
fk_user_modif integer
)ENGINE=innodb;

View File

@ -28,7 +28,7 @@
-- Requests to clean corrupted database -- Requests to clean corrupted data
UPDATE llx_user set api_key = null where api_key = ''; UPDATE llx_user set api_key = null where api_key = '';
@ -124,6 +124,7 @@ delete from llx_categorie_product where fk_categorie not in (select rowid from l
delete from llx_categorie_societe where fk_categorie not in (select rowid from llx_categorie where type in (1, 2)); delete from llx_categorie_societe where fk_categorie not in (select rowid from llx_categorie where type in (1, 2));
delete from llx_categorie_member where fk_categorie not in (select rowid from llx_categorie where type = 3); delete from llx_categorie_member where fk_categorie not in (select rowid from llx_categorie where type = 3);
delete from llx_categorie_contact where fk_categorie not in (select rowid from llx_categorie where type = 4); delete from llx_categorie_contact where fk_categorie not in (select rowid from llx_categorie where type = 4);
delete from llx_categorie_project where fk_categorie not in (select rowid from llx_categorie where type = 5);
-- Fix: delete orphelin deliveries. Note: deliveries are linked to shipment by llx_element_element only. No other links. -- Fix: delete orphelin deliveries. Note: deliveries are linked to shipment by llx_element_element only. No other links.
@ -337,3 +338,8 @@ drop table tmp_c_shipment_mode;
-- VMYSQL4.1 update llx_expensereport_det as ed set date = (select date_debut from llx_expensereport as e where ed.fk_expensereport = e.rowid) where DATE(STR_TO_DATE(date, '%Y-%m-%d')) < '1000-00-00'; -- VMYSQL4.1 update llx_expensereport_det as ed set date = (select date_debut from llx_expensereport as e where ed.fk_expensereport = e.rowid) where DATE(STR_TO_DATE(date, '%Y-%m-%d')) < '1000-00-00';
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; -- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- Backport a change of value into the hourly rate.
-- update llx_projet_task_time as ptt set ptt.thm = (SELECT thm from llx_user as u where ptt.fk_user = u.rowid) where (ptt.thm is null)

View File

@ -28,4 +28,4 @@ CREATE TABLE llx_advtargetemailing
datec datetime NOT NULL, datec datetime NOT NULL,
fk_user_mod integer NOT NULL, fk_user_mod integer NOT NULL,
tms timestamp NOT NULL tms timestamp NOT NULL
)ENGINE=InnoDB; )ENGINE=innodb;

View File

@ -0,0 +1,37 @@
-- ===================================================================
-- Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
-- Copyright (C) 2015 Frederic France <frederic.france@free.fr>
--
-- 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 <http://www.gnu.org/licenses/>.
--
-- ===================================================================
create table llx_loan_schedule
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_loan integer,
datec datetime, -- creation date
tms timestamp,
datep datetime, -- payment date
amount_capital real DEFAULT 0,
amount_insurance real DEFAULT 0,
amount_interest real DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50),
note_private text,
note_public text,
fk_bank integer NOT NULL,
fk_user_creat integer, -- creation user
fk_user_modif integer -- last modification user
)ENGINE=innodb;

View File

@ -23,4 +23,4 @@ CREATE TABLE llx_product_attribute
label VARCHAR(255) NOT NULL, label VARCHAR(255) NOT NULL,
rang INT DEFAULT 0 NOT NULL, rang INT DEFAULT 0 NOT NULL,
entity INT DEFAULT 1 NOT NULL entity INT DEFAULT 1 NOT NULL
); )ENGINE=innodb;

View File

@ -25,4 +25,4 @@ CREATE TABLE llx_product_attribute_combination
variation_price_percentage INT NULL, variation_price_percentage INT NULL,
variation_weight FLOAT NOT NULL, variation_weight FLOAT NOT NULL,
entity INT DEFAULT 1 NOT NULL entity INT DEFAULT 1 NOT NULL
); )ENGINE=innodb;

View File

@ -22,4 +22,4 @@ CREATE TABLE llx_product_attribute_combination2val
fk_prod_combination INT NOT NULL, fk_prod_combination INT NOT NULL,
fk_prod_attr INT NOT NULL, fk_prod_attr INT NOT NULL,
fk_prod_attr_val INT NOT NULL fk_prod_attr_val INT NOT NULL
); )ENGINE=innodb;

View File

@ -23,4 +23,4 @@ CREATE TABLE llx_product_attribute_value
ref VARCHAR(255) DEFAULT NULL, ref VARCHAR(255) DEFAULT NULL,
value VARCHAR(255) DEFAULT NULL, value VARCHAR(255) DEFAULT NULL,
entity INT DEFAULT 1 NOT NULL entity INT DEFAULT 1 NOT NULL
); )ENGINE=innodb;

View File

@ -23,4 +23,4 @@ CREATE TABLE llx_product_pricerules
fk_level INT NOT NULL, -- Price variations are made over price of X fk_level INT NOT NULL, -- Price variations are made over price of X
var_percent FLOAT NOT NULL, -- Price variation over based price var_percent FLOAT NOT NULL, -- Price variation over based price
var_min_percent FLOAT NOT NULL -- Min price discount over general price var_min_percent FLOAT NOT NULL -- Min price discount over general price
); )ENGINE=innodb;

View File

@ -3945,7 +3945,10 @@ function migrate_delete_old_files($db,$langs,$conf)
DOL_DOCUMENT_ROOT.'/compta/facture/class/api_invoice.class.php', DOL_DOCUMENT_ROOT.'/compta/facture/class/api_invoice.class.php',
DOL_DOCUMENT_ROOT.'/commande/class/api_commande.class.php', DOL_DOCUMENT_ROOT.'/commande/class/api_commande.class.php',
DOL_DOCUMENT_ROOT.'/user/class/api_user.class.php' DOL_DOCUMENT_ROOT.'/user/class/api_user.class.php',
DOL_DOCUMENT_ROOT.'/product/class/api_product.class.php',
DOL_DOCUMENT_ROOT.'/societe/class/api_contact.class.php',
DOL_DOCUMENT_ROOT.'/societe/class/api_thirdparty.class.php'
); );
foreach ($filetodeletearray as $filetodelete) foreach ($filetodeletearray as $filetodelete)

View File

@ -48,6 +48,7 @@ InternalUsers=Internal users
ExternalUsers=External users ExternalUsers=External users
GUISetup=Display GUISetup=Display
SetupArea=Setup area SetupArea=Setup area
UploadNewTemplate=Upload new template(s)
FormToTestFileUploadForm=Form to test file upload (according to setup) FormToTestFileUploadForm=Form to test file upload (according to setup)
IfModuleEnabled=Note: yes is effective only if module <b>%s</b> is enabled IfModuleEnabled=Note: yes is effective only if module <b>%s</b> is enabled
RemoveLock=Remove file <b>%s</b> if it exists to allow usage of the update tool. RemoveLock=Remove file <b>%s</b> if it exists to allow usage of the update tool.
@ -613,7 +614,7 @@ Permission32=Create/modify products
Permission34=Delete products Permission34=Delete products
Permission36=See/manage hidden products Permission36=See/manage hidden products
Permission38=Export products Permission38=Export products
Permission41=Read projects and tasks (shared project and projects i'm contact for). Can also enter time consumed on assigned tasks (timesheet) Permission41=Read projects and tasks (shared project and projects i'm contact for). Can also enter time consumed, for me or my hierarchy, on assigned tasks (Timesheet)
Permission42=Create/modify projects (shared project and projects i'm contact for). Can also create tasks and assign users to project and tasks Permission42=Create/modify projects (shared project and projects i'm contact for). Can also create tasks and assign users to project and tasks
Permission44=Delete projects (shared project and projects i'm contact for) Permission44=Delete projects (shared project and projects i'm contact for)
Permission45=Export projects Permission45=Export projects
@ -873,6 +874,7 @@ DictionaryProspectStatus=Prospection status
DictionaryHolidayTypes=Types of leaves DictionaryHolidayTypes=Types of leaves
DictionaryOpportunityStatus=Opportunity status for project/lead DictionaryOpportunityStatus=Opportunity status for project/lead
SetupSaved=Setup saved SetupSaved=Setup saved
SetupNotSaved=Setup not saved
BackToModuleList=Back to modules list BackToModuleList=Back to modules list
BackToDictionaryList=Back to dictionaries list BackToDictionaryList=Back to dictionaries list
VATManagement=VAT Management VATManagement=VAT Management

View File

@ -19,6 +19,7 @@ ErrorFailToRenameDir=Failed to rename directory '<b>%s</b>' into '<b>%s</b>'.
ErrorFailToCreateDir=Failed to create directory '<b>%s</b>'. ErrorFailToCreateDir=Failed to create directory '<b>%s</b>'.
ErrorFailToDeleteDir=Failed to delete directory '<b>%s</b>'. ErrorFailToDeleteDir=Failed to delete directory '<b>%s</b>'.
ErrorFailToMakeReplacementInto=Failed to make replacement into file '<b>%s</b>'. ErrorFailToMakeReplacementInto=Failed to make replacement into file '<b>%s</b>'.
ErrorFailToGenerateFile=Failed to generate file '<b>%s</b>'.
ErrorThisContactIsAlreadyDefinedAsThisType=This contact is already defined as contact for this type. ErrorThisContactIsAlreadyDefinedAsThisType=This contact is already defined as contact for this type.
ErrorCashAccountAcceptsOnlyCashMoney=This bank account is a cash account, so it accepts payments of type cash only. ErrorCashAccountAcceptsOnlyCashMoney=This bank account is a cash account, so it accepts payments of type cash only.
ErrorFromToAccountsMustDiffers=Source and targets bank accounts must be different. ErrorFromToAccountsMustDiffers=Source and targets bank accounts must be different.
@ -115,7 +116,7 @@ ErrorQtyForCustomerInvoiceCantBeNegative=Quantity for line into customer invoice
ErrorWebServerUserHasNotPermission=User account <b>%s</b> used to execute web server has no permission for that ErrorWebServerUserHasNotPermission=User account <b>%s</b> used to execute web server has no permission for that
ErrorNoActivatedBarcode=No barcode type activated ErrorNoActivatedBarcode=No barcode type activated
ErrUnzipFails=Failed to unzip %s with ZipArchive ErrUnzipFails=Failed to unzip %s with ZipArchive
ErrNoZipEngine=No engine to unzip %s file in this PHP ErrNoZipEngine=No engine to zip/unzip %s file in this PHP
ErrorFileMustBeADolibarrPackage=The file %s must be a Dolibarr zip package ErrorFileMustBeADolibarrPackage=The file %s must be a Dolibarr zip package
ErrorModuleFileRequired=You must select a Dolibarr module package file ErrorModuleFileRequired=You must select a Dolibarr module package file
ErrorPhpCurlNotInstalled=The PHP CURL is not installed, this is essential to talk with Paypal ErrorPhpCurlNotInstalled=The PHP CURL is not installed, this is essential to talk with Paypal
@ -189,6 +190,7 @@ ErrorModuleFileSeemsToHaveAWrongFormat=The module package seems to have a wrong
ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package (<strong>%s</strong>) does not match expected name syntax: <strong>%s</strong> ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package (<strong>%s</strong>) does not match expected name syntax: <strong>%s</strong>
ErrorDuplicateTrigger=Error, duplicate trigger name %s. Already loaded from %s. ErrorDuplicateTrigger=Error, duplicate trigger name %s. Already loaded from %s.
ErrorNoWarehouseDefined=Error, no warehouses defined. ErrorNoWarehouseDefined=Error, no warehouses defined.
ErrorBadLinkSourceSetButBadValueForRef=The link you use is not valid. A 'source' for payment is defined, but value for 'ref' is not valid.
# Warnings # Warnings
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.

View File

@ -16,7 +16,7 @@ CancelCP=Canceled
RefuseCP=Refused RefuseCP=Refused
ValidatorCP=Approbator ValidatorCP=Approbator
ListeCP=List of leaves ListeCP=List of leaves
ReviewedByCP=Will be reviewed by ReviewedByCP=Will be approved by
DescCP=Description DescCP=Description
SendRequestCP=Create leave request SendRequestCP=Create leave request
DelayToRequestCP=Leave requests must be made at least <b>%s day(s)</b> before them. DelayToRequestCP=Leave requests must be made at least <b>%s day(s)</b> before them.

View File

@ -50,3 +50,4 @@ ConfigLoan=Configuration of the module loan
LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accounting account capital by default LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accounting account capital by default
LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accounting account interest by default LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accounting account interest by default
LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accounting account insurance by default LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accounting account insurance by default
CreateCalcSchedule=Créer / Modifier échéancier de pret

View File

@ -775,6 +775,8 @@ ClickToShowHelp=Click to show tooltip help
HR=HR HR=HR
HRAndBank=HR and Bank HRAndBank=HR and Bank
AutomaticallyCalculated=Automatically calculated AutomaticallyCalculated=Automatically calculated
TitleSetToDraft=Go back to draft
ConfirmSetToDraft=Are you sure you want to go back to Draft status ?
# Week day # Week day
Monday=Monday Monday=Monday
Tuesday=Tuesday Tuesday=Tuesday

View File

@ -7,9 +7,9 @@ NewModule=New module
ModuleKey=Key for new module ModuleKey=Key for new module
ModuleInitialized=Module initialized ModuleInitialized=Module initialized
ModuleBuilderDescdescription=Enter here all general information that describe your module ModuleBuilderDescdescription=Enter here all general information that describe your module
ModuleBuilderDescobjects=Define here the new objects you want to manage with our module. A page to list them and a page to create/edit/view a card will be generated. ModuleBuilderDescobjects=Define here the new objects you want to manage with your module. A page to list them and a page to create/edit/view a card will be generated.
ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module. ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module.
ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with our module. ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions you want to provide with your module.
ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE. ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE.
ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to get your module package file. ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to get your module package file.
BuildPackage=Build package BuildPackage=Build package

View File

@ -16,6 +16,7 @@ PreviousMonthOfInvoice=Previous month (number 1-12) of invoice date
TextPreviousMonthOfInvoice=Previous month (text) of invoice date TextPreviousMonthOfInvoice=Previous month (text) of invoice date
NextMonthOfInvoice=Following month (number 1-12) of invoice date NextMonthOfInvoice=Following month (number 1-12) of invoice date
TextNextMonthOfInvoice=Following month (text) of invoice date TextNextMonthOfInvoice=Following month (text) of invoice date
ZipFileGeneratedInto=Zip file generated into <b>%s</b>.
YearOfInvoice=Year of invoice date YearOfInvoice=Year of invoice date
PreviousYearOfInvoice=Previous year of invoice date PreviousYearOfInvoice=Previous year of invoice date

View File

@ -41,6 +41,7 @@ ShowProject=Show project
SetProject=Set project SetProject=Set project
NoProject=No project defined or owned NoProject=No project defined or owned
NbOfProjects=Nb of projects NbOfProjects=Nb of projects
NbOfTasks=Nb of tasks
TimeSpent=Time spent TimeSpent=Time spent
TimeSpentByYou=Time spent by you TimeSpentByYou=Time spent by you
TimeSpentByUser=Time spent by user TimeSpentByUser=Time spent by user
@ -53,7 +54,7 @@ TaskTimeNote=Note
TaskTimeDate=Date TaskTimeDate=Date
TasksOnOpenedProject=Tasks on open projects TasksOnOpenedProject=Tasks on open projects
WorkloadNotDefined=Workload not defined WorkloadNotDefined=Workload not defined
NewTimeSpent=New time spent NewTimeSpent=Time spent
MyTimeSpent=My time spent MyTimeSpent=My time spent
Tasks=Tasks Tasks=Tasks
Task=Task Task=Task
@ -107,6 +108,7 @@ ConfirmReOpenAProject=Are you sure you want to re-open this project?
ProjectContact=Project contacts ProjectContact=Project contacts
ActionsOnProject=Events on project ActionsOnProject=Events on project
YouAreNotContactOfProject=You are not a contact of this private project YouAreNotContactOfProject=You are not a contact of this private project
UserIsNotContactOfProject=User is not a contact of this private project
DeleteATimeSpent=Delete time spent DeleteATimeSpent=Delete time spent
ConfirmDeleteATimeSpent=Are you sure you want to delete this time spent? ConfirmDeleteATimeSpent=Are you sure you want to delete this time spent?
DoNotShowMyTasksOnly=See also tasks not assigned to me DoNotShowMyTasksOnly=See also tasks not assigned to me
@ -115,7 +117,7 @@ TaskRessourceLinks=Resources
ProjectsDedicatedToThisThirdParty=Projects dedicated to this third party ProjectsDedicatedToThisThirdParty=Projects dedicated to this third party
NoTasks=No tasks for this project NoTasks=No tasks for this project
LinkedToAnotherCompany=Linked to other third party LinkedToAnotherCompany=Linked to other third party
TaskIsNotAffectedToYou=Task not assigned to you TaskIsNotAssignedToUser=Task not assigned to user. Use button '<strong>%s</strong>' to assign task now.
ErrorTimeSpentIsEmpty=Time spent is empty ErrorTimeSpentIsEmpty=Time spent is empty
ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (<b>%s</b> tasks at the moment) and all inputs of time spent. ThisWillAlsoRemoveTasks=This action will also delete all tasks of project (<b>%s</b> tasks at the moment) and all inputs of time spent.
IfNeedToUseOhterObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties. IfNeedToUseOhterObjectKeepEmpty=If some objects (invoice, order, ...), belonging to another third party, must be linked to the project to create, keep this empty to have the project being multi third parties.
@ -166,26 +168,30 @@ FirstAddRessourceToAllocateTime=Assign a user resource to task to allocate time
InputPerDay=Input per day InputPerDay=Input per day
InputPerWeek=Input per week InputPerWeek=Input per week
InputPerAction=Input per action InputPerAction=Input per action
TimeAlreadyRecorded=Time spent already recorded for this task/day and user %s TimeAlreadyRecorded=This is time spent already recorded for this task/day and user %s
ProjectsWithThisUserAsContact=Projects with this user as contact ProjectsWithThisUserAsContact=Projects with this user as contact
TasksWithThisUserAsContact=Tasks assigned to this user TasksWithThisUserAsContact=Tasks assigned to this user
ResourceNotAssignedToProject=Not assigned to project ResourceNotAssignedToProject=Not assigned to project
ResourceNotAssignedToTheTask=Not assigned to the task ResourceNotAssignedToTheTask=Not assigned to the task
TasksAssignedTo=Tasks assigned to TasksAssignedTo=Tasks assigned to
AssignTaskToMe=Assign task to me AssignTaskToMe=Assign task to me
AssignTaskToUser=Assign task to %s
SelectTaskToAssign=Select task to assign...
AssignTask=Assign AssignTask=Assign
ProjectOverview=Overview ProjectOverview=Overview
ManageTasks=Use projects to follow tasks and time ManageTasks=Use projects to follow tasks and time
ManageOpportunitiesStatus=Use projects to follow leads/opportinuties ManageOpportunitiesStatus=Use projects to follow leads/opportinuties
ProjectNbProjectByMonth=Nb of created projects by month ProjectNbProjectByMonth=Nb of created projects by month
ProjectNbTaskByMonth=Nb of created tasks by month
ProjectOppAmountOfProjectsByMonth=Amount of opportunities by month ProjectOppAmountOfProjectsByMonth=Amount of opportunities by month
ProjectWeightedOppAmountOfProjectsByMonth=Weighted amount of opportunities by month ProjectWeightedOppAmountOfProjectsByMonth=Weighted amount of opportunities by month
ProjectOpenedProjectByOppStatus=Open project/lead by opportunity status ProjectOpenedProjectByOppStatus=Open project/lead by opportunity status
ProjectsStatistics=Statistics on projects/leads ProjectsStatistics=Statistics on projects/leads
TasksStatistics=Statistics on project/lead tasks
TaskAssignedToEnterTime=Task assigned. Entering time on this task should be possible. TaskAssignedToEnterTime=Task assigned. Entering time on this task should be possible.
IdTaskTime=Id task time IdTaskTime=Id task time
YouCanCompleteRef=If you want to complete the ref with some information (to use it as search filters), it is recommanded to add a - character to separate it, so the automatic numbering will still work correctly for next projects. For example %s-ABC. You may also prefer to add search keys into label. But best practice may be to add a dedicated field, also called complementary attributes. YouCanCompleteRef=If you want to complete the ref with some information (to use it as search filters), it is recommanded to add a - character to separate it, so the automatic numbering will still work correctly for next projects. For example %s-ABC. You may also prefer to add search keys into label. But best practice may be to add a dedicated field, also called complementary attributes.
OpenedProjectsByThirdparties=Open projects by thirdparties OpenedProjectsByThirdparties=Open projects by third parties
OnlyOpportunitiesShort=Only opportunities OnlyOpportunitiesShort=Only opportunities
OpenedOpportunitiesShort=Open opportunities OpenedOpportunitiesShort=Open opportunities
NotAnOpportunityShort=Not an opportunity NotAnOpportunityShort=Not an opportunity

72
htdocs/loan/calcmens.php Normal file
View File

@ -0,0 +1,72 @@
<?php
/* TVI
* Copyright (C) 2015 Florian HENRY <florian.henry@open-concept.pro>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file tvi/ajax/list.php
* \brief File to return datables output
*/
if (! defined('NOTOKENRENEWAL'))
define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (! defined('NOREQUIREMENU'))
define('NOREQUIREMENU', '1');
// if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX'))
define('NOREQUIREAJAX', '1');
// if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
// if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
require '../main.inc.php';
require DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php';
$mens=GETPOST('mens');
$capital=GETPOST('capital');
$rate=GETPOST('rate');
$echance=GETPOST('echeance');
$nbterm=GETPOST('nbterm');
top_httphead();
$output=array();
$object = new LoanSchedule($db);
$int = ($capital*($rate/12));
$int = round($int,2,PHP_ROUND_HALF_UP);
$cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP);
$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int,0,'',1),'mens'=>$mens);
$echance++;
$capital=$cap_rest;
while ($echance<=$nbterm) {
$mens = round($object->calc_mens($capital,$rate,$nbterm-$echance+1),2,PHP_ROUND_HALF_UP);
$int = ($capital*($rate/12));
$int = round($int,2,PHP_ROUND_HALF_UP);
$cap_rest = round($capital - ($mens-$int),2,PHP_ROUND_HALF_UP);
$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int,0,'',1),'mens'=>$mens);
$capital=$cap_rest;
$echance++;
}
echo json_encode($output);

View File

@ -417,6 +417,18 @@ if ($id > 0)
dol_fiche_head($head, 'card', $langs->trans("Loan"), 0, 'bill'); dol_fiche_head($head, 'card', $langs->trans("Loan"), 0, 'bill');
print '<script type="text/javascript">' . "\n";
print ' function popEcheancier() {' . "\n";
print ' $div = $(\'<div id="popCalendar"><iframe width="100%" height="100%" frameborder="0" src="createschedule.php?loanid=' . $object->id . '"></iframe></div>\');' . "\n";
print ' $div.dialog({' . "\n";
print ' modal:true' . "\n";
print ' ,width:"90%"' . "\n";
print ' ,height:$(window).height() - 150' . "\n";
print ' });' . "\n";
print ' }' . "\n";
print '</script>';
// Loan card // Loan card
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';
@ -717,6 +729,8 @@ if ($id > 0)
// Edit // Edit
if ($user->rights->loan->write) if ($user->rights->loan->write)
{ {
print '<a href="javascript:popEcheancier()" class="butAction">'.$langs->trans('CreateCalcSchedule').'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
} }

View File

@ -0,0 +1,542 @@
<?php
/* Copyright (C) 2017 Florian HENRY <florian.henry@atm-consulting.fr>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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;
}
}

View File

@ -0,0 +1,208 @@
<?php
/* Copyright (C) 2017 Franck Moreau <franck.moreau@theobald.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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;
?>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('[name^="mens"]').focusout(function() {
var echeance=$(this).attr('ech');
var mens=$(this).val();
var idcap=echeance-1;
idcap = '#hi_capital'+idcap;
var capital=$(idcap).val();
$.ajax({
dataType: 'json',
url: 'calcmens.php',
data: { echeance: echeance, mens: mens, capital:capital, rate:<?php echo $object->rate/100;?> , nbterm : <?php echo $object->nbterm;?>},
success: function(data) {
$.each(data, function(index, element) {
var idcap_res='#hi_capital'+index;
var idcap_res_srt='#capital'+index;
var interet_res='#hi_interets'+index;
var interet_res_str='#interets'+index;
var men_res='#mens'+index;
$(idcap_res).val(element.cap_rest);
$(idcap_res_srt).text(element.cap_rest_str+' €');
$(interet_res).val(element.interet);
$(interet_res_str).text(element.interet_str+' €');
$(men_res).val(element.mens);
});
}
});
});
});
</script>
<?php
print '<form name="createecheancier" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="loanid" value="' . $loanid . '">';
if(count($echeance->lines)>0){
print '<input type="hidden" name="action" value="updateecheancier">';
}else{
print '<input type="hidden" name="action" value="createecheancier">';
}
print '<table class="border" width="100%">';
print '<tr class="liste_titre">';
print '<th align="center" colspan="5">' . "Création d'échéancier</th>";
print '</tr>';
print '<tr class="liste_titre">';
Print '<th width="10%" align="center"> Echéance </th>';
Print '<th width="10%" align="center"> Date </th>';
Print '<th width="10%" align="center"> Montant </th>';
Print '<th width="20%" align="center"> Intérêts </th>';
Print '<th width="40%" align="center"> Capital restant du </th>';
print '</tr>';
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 '<tr>';
print '<td align="center" id="n'.$i.'">' . $i .'</td>';
print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . dol_time_plus_duree($object->datestart, $i-1, 'm') . '">' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'),'day') . '</td>';
print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>';
print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '</tr>';
$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 '<tr>';
print '<td align="center" id="n'.$i.'"><input type="hidden" name="hi_rowid' .$i .'" id ="hi_rowid' .$i .'" value="' . $line->id . '">' . $i .'</td>';
print '<td align="center" id ="date' .$i .'"><input type="hidden" name="hi_date' .$i .'" id ="hi_date' .$i .'" value="' . $line->datep . '">' . dol_print_date($line->datep,'day') . '</td>';
if($line->datep > dol_now()){
print '<td align="center"><input name="mens'.$i.'" id="mens'.$i.'" size="5" value="'.$mens.'" ech="'.$i.'"> €</td>';
}else{
print '<td align="center">' . price($mens) . ' €</td><input type="hidden" name="mens' .$i .'" id ="mens' .$i .'" value="' . $mens . '">';
}
print '<td align="center" id="interets'.$i.'">'.price($int,0,'',1).' €</td><input type="hidden" name="hi_interets' .$i .'" id ="hi_interets' .$i .'" value="' . $int . '">';
print '<td align="center" id="capital'.$i.'">'.price($cap_rest).' €</td><input type="hidden" name="hi_capital' .$i .'" id ="hi_capital' .$i .'" value="' . $cap_rest . '">';
print '</tr>';
$i++;
$capital = $cap_rest;
}
}
print '</table>';
print '</br>';
print '</br>';
print '<div align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'"></div>';
print '</form>';
llxFooter();
$db->close();

View File

View File

@ -115,9 +115,60 @@ if ($dircustom && $action == 'initmodule' && $modulename)
if ($dircustom && $action == 'generatepackage') 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 ($tab == 'buildpackage')
{ {
if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP'))
{
print img_warning().' '.$langs->trans("ErrNoZipEngine");
print '<br>';
}
print '<form name="generatepackage">'; print '<form name="generatepackage">';
print '<input type="hidden" name="action" value="generatepackage">'; print '<input type="hidden" name="action" value="generatepackage">';
print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">'; print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">';

View File

@ -39,20 +39,23 @@ require_once '../lib/mymodule.lib.php';
$langs->load("mymodule@mymodule"); $langs->load("mymodule@mymodule");
// Access control // Access control
if (! $user->admin) { if (! $user->admin) accessforbidden();
accessforbidden();
}
// Parameters // Parameters
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
/* /*
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
/* /*
* View * View
*/ */
$page_name = "MyModuleSetup"; $page_name = "MyModuleSetup";
llxHeader('', $langs->trans($page_name)); llxHeader('', $langs->trans($page_name));

View File

@ -62,24 +62,101 @@ class ActionsMyModule
*/ */
public function doActions($parameters, &$object, &$action, $hookmanager) public function doActions($parameters, &$object, &$action, $hookmanager)
{ {
global $conf, $user, $langs;
$error = 0; // Error counter $error = 0; // Error counter
$myvalue = 'test'; // A result value
/*
print_r($parameters); print_r($parameters);
echo "action: " . $action;
print_r($object); 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) { if (! $error) {
$this->results = array('myreturn' => $myvalue); $this->results = array('myreturn' => 999);
$this->resprints = 'A text to show'; $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 { } else {
$this->errors[] = 'Error message'; $this->errors[] = 'Error message';
return -1; 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 = '<option value="0"'.($disabled?' disabled="disabled"':'').'>'.$langs->trans("MyModuleMassAction").'</option>';
}
if (! $error) {
return 0; // or return 1 to replace standard code
} else {
$this->errors[] = 'Error message';
return -1;
}
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

View File

@ -18,12 +18,10 @@
# Generic # Generic
# #
# Module label 'ModuleXXXName' # Module label 'ModuleMyModuleName'
# (where XXX is value of numeric property 'numero' of module) ModuleMyModuleName = My module
Module500000Name = My module # Module description 'ModuleMyModuleDesc'
# Module description 'ModuleXXXDesc' ModuleMyModuleDesc = My module description
# (where XXX is value of numeric property 'numero' of module)
Module500000Desc = My module description
# #
# Admin page # Admin page

View File

@ -18,12 +18,10 @@
# Générique # Générique
# #
# Module label 'ModuleXXXName' # Module label 'ModuleMyModuleName'
# (where XXX is value of numeric property 'numero' of module) ModuleMyModuleName = Mon module
Module500000Name = Mon module # Module description 'ModuleMyModuleDesc'
# Module description 'ModuleXXXDesc' ModuleMyModuleDesc = Description de mon module
# (where XXX is value of numeric property 'numero' of module)
Module500000Desc = Description de mon module
# #
# Page d'administration # Page d'administration

View File

@ -74,6 +74,9 @@ $error = 0;
* Actions * Actions
*/ */
$nomessageinsetmoduleoptions=1;
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setcodeproduct') if ($action == 'setcodeproduct')
{ {
if (dolibarr_set_const($db, "PRODUCT_CODEPRODUCT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) 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) 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); $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", GETPOST('value_PRODUIT_LIMIT_SIZE'),'chaine',0,'',$conf->entity);
@ -278,7 +251,7 @@ if ($action)
} }
else else
{ {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("SetupNotError"), null, 'errors');
} }
} }

View File

@ -320,6 +320,7 @@ class StockMovements extends DolibarrApi
unset($object->user); unset($object->user);
unset($object->fk_project); unset($object->fk_project);
unset($object->project); unset($object->project);
unset($object->canvas);
//unset($object->eatby); Filled correctly in read mode //unset($object->eatby); Filled correctly in read mode
//unset($object->sellby); Filled correctly in read mode //unset($object->sellby); Filled correctly in read mode

View File

@ -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'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$langs->load('projects'); $langs->load('projects');
$langs->load('users');
$action=GETPOST('action','aZ09'); $action=GETPOST('action','aZ09');
$mode=GETPOST("mode"); $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=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int"):date("d"));
$day = (int) $day; $day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $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_ref=GETPOST('search_task_ref', 'alpha');
$search_task_label=GETPOST('search_task_label', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha');
$search_project_ref=GETPOST('search_project_ref', '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' 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' 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); $object=new Task($db);
@ -83,9 +97,10 @@ $object=new Task($db);
*/ */
// Purge criteria // 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 = ''; $action = '';
$search_usertoprocessid = '';
$search_task_ref = ''; $search_task_ref = '';
$search_task_label = ''; $search_task_label = '';
$search_project_ref = ''; $search_project_ref = '';
@ -125,7 +140,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
} }
if (! $error) if (! $error)
{ {
$idfortaskuser=$user->id; $idfortaskuser=$usertoprocess->id;
$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
if ($result >= 0 || $result == -2) // Contact add ok or already contact of task if ($result >= 0 || $result == -2) // Contact add ok or already contact of task
@ -175,6 +190,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
if (! $error) if (! $error)
{ {
setEventMessages("TaskAssignedToEnterTime", null); setEventMessages("TaskAssignedToEnterTime", null);
$taskid=0;
} }
$action=''; $action='';
@ -247,7 +263,7 @@ if ($action == 'addtime' && $user->rights->projet->lire)
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
// Redirect to avoid submit twice on back // 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; exit;
} }
} }
@ -286,8 +302,6 @@ $next_day = $next['mday'];
$title=$langs->trans("TimeSpent"); $title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent"); 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 $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) if ($id)
@ -314,8 +328,9 @@ llxHeader("",$title,"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
$param=''; $param='';
$param.=($mode?'&amp;mode='.$mode:''); $param.=($mode?'&mode='.$mode:'');
$param.=($search_project_ref?'&amp;search_project_ref='.$search_project_ref:''); $param.=($search_project_ref?'&search_project_ref='.$search_project_ref:'');
$param.=($search_userassignedid > 0?'&search_userassignedid='.$search_usertoprocessid:'');
// Show navigation bar // Show navigation bar
$nav ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n"; $nav ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
@ -337,7 +352,7 @@ print '<input type="hidden" name="addtimeyear" value="'.$tmp['year'].'">';
print '<input type="hidden" name="addtimemonth" value="'.$tmp['mon'].'">'; print '<input type="hidden" name="addtimemonth" value="'.$tmp['mon'].'">';
print '<input type="hidden" name="addtimeday" value="'.$tmp['mday'].'">'; print '<input type="hidden" name="addtimeday" value="'.$tmp['mday'].'">';
$head=project_timesheet_prepare_head($mode); $head=project_timesheet_prepare_head($mode, $usertoprocess);
dol_fiche_head($head, 'inputperday', '', -1, 'task'); dol_fiche_head($head, 'inputperday', '', -1, 'task');
// Show description of content // Show description of content
@ -360,45 +375,17 @@ print '</div>';
dol_fiche_end(); dol_fiche_end();
print '<div class="floatright right'.($conf->dol_optimize_smallscreen?' centpercent':'').'">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
// Filter on user
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
dol_fiche_end();
*/
// Filter on user
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
dol_fiche_end();
*/
// Add a new project/task
//print '<br>';
//print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
//print '<input type="hidden" name="action" value="assigntask">';
//print '<input type="hidden" name="mode" value="'.$mode.'">';
//print '<input type="hidden" name="year" value="'.$year.'">';
//print '<input type="hidden" name="month" value="'.$month.'">';
//print '<input type="hidden" name="day" value="'.$day.'">';
print '<div class="floatright right">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
print '<div class="float valignmiddle">'; print '<div class="float valignmiddle">';
print $langs->trans("AssignTaskToMe").'<br>'; $titleassigntask = $langs->trans("AssignTaskToMe");
if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs));
print '<div class="taskiddiv inline-block">';
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0); print '</div>';
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.$langs->trans("AssignTask").'">'; print ' ';
//print '</form>'; print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200');
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
print '</div>'; print '</div>';
print '<div class="clearboth" style="padding-bottom: 8px;"></div>'; print '<div class="clearboth" style="padding-bottom: 8px;"></div>';
@ -408,6 +395,11 @@ print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">';
$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 '</td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
@ -427,6 +419,7 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("User").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>'; print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>'; print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("ProjectRef").'</td>'; print '<td>'.$langs->trans("ProjectRef").'</td>';
@ -436,12 +429,15 @@ if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
} }
print '<td align="right" class="maxwidth100">'.$langs->trans("PlannedWorkload").'</td>'; print '<td align="right" class="maxwidth100">'.$langs->trans("PlannedWorkload").'</td>';
print '<td align="right" class="maxwidth100">'.$langs->trans("ProgressDeclared").'</td>'; print '<td align="right" class="maxwidth100">'.$langs->trans("ProgressDeclared").'</td>';
print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'</td>'; /*print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByYou").'</td>'; if ($usertoprocess->id == $user->id) print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByUser").'</td>'; else print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpentByUser").'</td>';*/
print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</td>';
print '<td align="right" class="maxwidth100">'.$langs->trans("TimeSpent").'</td>';
print '<td align="center">'.$langs->trans("HourStart").'</td>'; print '<td align="center">'.$langs->trans("HourStart").'</td>';
print '<td align="center" colspan="2">'.$langs->trans("Duration").'</td>'; print '<td align="center">'.$langs->trans("Duration").'</td>';
print '<td align="right">'.$langs->trans("Note").'</td>'; print '<td align="right">'.$langs->trans("Note").'</td>';
print '<td align="center"></td>';
print "</tr>\n"; print "</tr>\n";
@ -455,7 +451,7 @@ if (count($tasksarray) > 0)
} }
else else
{ {
print '<tr><td colspan="10">'.$langs->trans("NoTasks").'</td></tr>'; print '<tr><td colspan="14">'.$langs->trans("NoTasks").'</td></tr>';
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';

View File

@ -58,11 +58,14 @@ $nowtmp=dol_getdate($now);
$nowday=$nowtmp['mday']; $nowday=$nowtmp['mday'];
$nowmonth=$nowtmp['mon']; $nowmonth=$nowtmp['mon'];
$nowyear=$nowtmp['year']; $nowyear=$nowtmp['year'];
$year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y")); $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")); $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=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d"));
$day = (int) $day; $day = (int) $day;
$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $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_ref=GETPOST('search_task_ref', 'alpha');
$search_task_label=GETPOST('search_task_label', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha');
$search_project_ref=GETPOST('search_project_ref', '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); $firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year);
$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); $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); $object=new Task($db);
@ -98,9 +110,10 @@ $object=new Task($db);
*/ */
// Purge criteria // 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 = ''; $action = '';
$search_usertoprocessid = '';
$search_task_ref = ''; $search_task_ref = '';
$search_task_label = ''; $search_task_label = '';
$search_project_ref = ''; $search_project_ref = '';
@ -140,10 +153,10 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
if (! $error) if (! $error)
{ {
$idfortaskuser=$user->id; $idfortaskuser=$usertoprocess->id;
$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal'); $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) // 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'; $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';
@ -190,6 +203,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
if (! $error) if (! $error)
{ {
setEventMessages("TaskAssignedToEnterTime", null); setEventMessages("TaskAssignedToEnterTime", null);
$taskid=0;
} }
$action=''; $action='';
@ -262,7 +276,7 @@ if ($action == 'addtime' && $user->rights->projet->lire)
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
// Redirect to avoid submit twice on back // 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; 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'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
$param=''; $param='';
$param.=($mode?'&amp;mode='.$mode:''); $param.=($mode?'&mode='.$mode:'');
$param.=($search_project_ref?'&amp;search_project_ref='.$search_project_ref:''); $param.=($search_project_ref?'&search_project_ref='.$search_project_ref:'');
$param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:'');
// Show navigation bar // Show navigation bar
$nav ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n"; $nav ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&month=".$prev_month."&day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("WeekShort")." ".$week." </span>\n"; $nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("WeekShort")." ".$week." </span>\n";
$nav.='<a class="inline-block valignmiddle" href="?year='.$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n"; $nav.='<a class="inline-block valignmiddle" href="?year='.$next_year."&month=".$next_month."&day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n";
$nav.=" &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)"; $nav.=" &nbsp; (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$nav.='<br>'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' '; $nav.='<br>'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' ';
$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">'; $nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
@ -333,7 +348,7 @@ print '<input type="hidden" name="day" value="'.$day.'">';
print '<input type="hidden" name="month" value="'.$month.'">'; print '<input type="hidden" name="month" value="'.$month.'">';
print '<input type="hidden" name="year" value="'.$year.'">'; print '<input type="hidden" name="year" value="'.$year.'">';
$head=project_timesheet_prepare_head($mode); $head=project_timesheet_prepare_head($mode, $usertoprocess);
dol_fiche_head($head, 'inputperweek', '', -1, 'task'); dol_fiche_head($head, 'inputperweek', '', -1, 'task');
// Show description of content // Show description of content
@ -356,44 +371,17 @@ print '</div>';
dol_fiche_end(); dol_fiche_end();
// Filter on user print '<div class="floatright right'.($conf->dol_optimize_smallscreen?' centpercent':'').'">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
dol_fiche_end();
*/
// Filter on user
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
dol_fiche_end();
*/
// Add a new project/task
//print '<br>';
//print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
//print '<input type="hidden" name="action" value="assigntask">';
//print '<input type="hidden" name="mode" value="'.$mode.'">';
//print '<input type="hidden" name="year" value="'.$year.'">';
//print '<input type="hidden" name="month" value="'.$month.'">';
//print '<input type="hidden" name="day" value="'.$day.'">';
print '<div class="floatright right">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
print '<div class="float valignmiddle">'; print '<div class="float valignmiddle">';
print $langs->trans("AssignTaskToMe").'<br>'; $titleassigntask = $langs->trans("AssignTaskToMe");
if ($usertoprocess->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", $usertoprocess->getFullName($langs));
print '<div class="taskiddiv inline-block">';
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0); print '</div>';
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.$langs->trans("AssignTask").'">'; print ' ';
//print '</form>'; print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200');
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
print '</div>'; print '</div>';
print '<div class="clearboth" style="padding-bottom: 8px;"></div>'; print '<div class="clearboth" style="padding-bottom: 8px;"></div>';
@ -403,6 +391,11 @@ print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">';
$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 '</td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>'; print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
@ -423,6 +416,7 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("User").'</td>';
print '<td>'.$langs->trans("RefTask").'</td>'; print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>'; print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td>'.$langs->trans("ProjectRef").'</td>'; print '<td>'.$langs->trans("ProjectRef").'</td>';
@ -432,9 +426,11 @@ if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
} }
print '<td align="right" class="maxwidth75">'.$langs->trans("PlannedWorkload").'</td>'; print '<td align="right" class="maxwidth75">'.$langs->trans("PlannedWorkload").'</td>';
print '<td align="right" class="maxwidth75">'.$langs->trans("ProgressDeclared").'</td>'; print '<td align="right" class="maxwidth75">'.$langs->trans("ProgressDeclared").'</td>';
/*print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpentByUser").'</td>';*/
print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</td>';
print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").'</td>'; print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td align="right" class="maxwidth75">'.$langs->trans("TimeSpentByUser").'</td>';
$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); $startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']);
@ -457,11 +453,11 @@ if (count($tasksarray) > 0)
$level=0; $level=0;
projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask); 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++; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++;
print '<tr class="liste_total"> print '<tr class="liste_total">
<td class="liste_total" colspan="'.$colspan.'" align="right">'.$langs->trans("Total").'</td> <td class="liste_total" colspan="'.$colspan.'">'.$langs->trans("Total").'</td>
<td class="liste_total hide0" align="center"><div id="totalDay[0]">&nbsp;</div></td> <td class="liste_total hide0" align="center"><div id="totalDay[0]">&nbsp;</div></td>
<td class="liste_total hide1" align="center"><div id="totalDay[1]">&nbsp;</div></td> <td class="liste_total hide1" align="center"><div id="totalDay[1]">&nbsp;</div></td>
<td class="liste_total hide2" align="center"><div id="totalDay[2]">&nbsp;</div></td> <td class="liste_total hide2" align="center"><div id="totalDay[2]">&nbsp;</div></td>
@ -474,7 +470,7 @@ if (count($tasksarray) > 0)
} }
else else
{ {
print '<tr><td colspan="11">'.$langs->trans("NoTasks").'</td></tr>'; print '<tr><td colspan="16">'.$langs->trans("NoTasks").'</td></tr>';
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';

View File

@ -51,6 +51,8 @@ $type='project';
* Actions * Actions
*/ */
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setmainoptions') if ($action == 'setmainoptions')
{ {
if (GETPOST('PROJECT_USE_OPPORTUNITIES')) dolibarr_set_const($db, "PROJECT_USE_OPPORTUNITIES",GETPOST('PROJECT_USE_OPPORTUNITIES'),'chaine',0,'',$conf->entity); if (GETPOST('PROJECT_USE_OPPORTUNITIES')) dolibarr_set_const($db, "PROJECT_USE_OPPORTUNITIES",GETPOST('PROJECT_USE_OPPORTUNITIES'),'chaine',0,'',$conf->entity);
@ -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 // Activate a model
else if ($action == 'set') else if ($action == 'set')
{ {

View File

@ -711,10 +711,11 @@ elseif ($object->id > 0)
print '<input type="hidden" name="comefromclone" value="'.$comefromclone.'">'; print '<input type="hidden" name="comefromclone" value="'.$comefromclone.'">';
$head=project_prepare_head($object); $head=project_prepare_head($object);
dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project'));
if ($action == 'edit' && $userWrite > 0) if ($action == 'edit' && $userWrite > 0)
{ {
dol_fiche_head($head, 'project', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
@ -835,6 +836,8 @@ elseif ($object->id > 0)
} }
else else
{ {
dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project'));
// Project card // Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
@ -843,9 +846,10 @@ elseif ($object->id > 0)
// Title // Title
$morehtmlref.=$object->title; $morehtmlref.=$object->title;
// Thirdparty // Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ';
if ($object->thirdparty->id > 0) if ($object->thirdparty->id > 0)
{ {
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project');
} }
$morehtmlref.='</div>'; $morehtmlref.='</div>';
@ -954,6 +958,7 @@ elseif ($object->id > 0)
// Change probability from status // Change probability from status
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) 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; $defaultcheckedwhenoppclose=1;
if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0; if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0;
@ -969,12 +974,16 @@ elseif ($object->id > 0)
var oldpercent = \''.dol_escape_js($object->opp_percent).'\'; var oldpercent = \''.dol_escape_js($object->opp_percent).'\';
console.log("We select "+elemcode); console.log("We select "+elemcode);
if (elemcode == \'LOST\') defaultcloseproject = 1;
jQuery("#divtocloseproject").show(); /* Define if checkbox to close is checked or not */
if (defaultcloseproject) jQuery("#inputcloseproject").prop("checked", true); var closeproject = 0;
if (elemcode == \'LOST\') closeproject = 1;
if (elemcode == \'WON\') closeproject = defaultcloseproject;
if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
else jQuery("#inputcloseproject").prop("checked", false); else jQuery("#inputcloseproject").prop("checked", false);
/* Make close project visible or not */ /* Make the close project checkbox visible or not */
console.log("closeproject="+closeproject);
if (elemcode == \'WON\' || elemcode == \'LOST\') if (elemcode == \'WON\' || elemcode == \'LOST\')
{ {
jQuery("#divtocloseproject").show(); jQuery("#divtocloseproject").show();

View File

@ -538,6 +538,9 @@ class Projects extends DolibarrApi
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->titre);
unset($object->datec);
unset($object->datem);
unset($object->barcode_type); unset($object->barcode_type);
unset($object->barcode_type_code); unset($object->barcode_type_code);
unset($object->barcode_type_label); unset($object->barcode_type_label);

View File

@ -41,7 +41,7 @@ class ProjectStats extends Stats
/** /**
* Return all leads grouped by status. * Return all leads grouped by opportunity status.
* Warning: There is no filter on WON/LOST because we want this for statistics. * Warning: There is no filter on WON/LOST because we want this for statistics.
* *
* @param int $limit Limit results * @param int $limit Limit results
@ -56,7 +56,10 @@ class ProjectStats extends Stats
$sql = "SELECT"; $sql = "SELECT";
$sql .= " SUM(t.opp_amount), t.fk_opp_status, cls.code, cls.label"; $sql .= " SUM(t.opp_amount), t.fk_opp_status, cls.code, cls.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t, ".MAIN_DB_PREFIX."c_lead_status as cls"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
if (! $user->rights->societe->client->voir && ! $user->socid)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql .= ", ".MAIN_DB_PREFIX."c_lead_status as cls";
$sql .= $this->buildWhere(); $sql .= $this->buildWhere();
$sql .= " AND t.fk_opp_status = cls.rowid"; $sql .= " AND t.fk_opp_status = cls.rowid";
$sql .= " AND t.fk_statut <> 0"; // We want historic also, so all projects not draft $sql .= " AND t.fk_statut <> 0"; // We want historic also, so all projects not draft
@ -116,7 +119,7 @@ class ProjectStats extends Stats
$sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb, SUM(t.opp_amount) as total, AVG(t.opp_amount) as avg,"; $sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb, SUM(t.opp_amount) as total, AVG(t.opp_amount) as avg,";
$sql.= " SUM(t.opp_amount * ".$this->db->ifsql("t.opp_percent IS NULL".($wonlostfilter?" OR cls.code IN ('WON','LOST')":""), '0', 't.opp_percent')." / 100) as weighted"; $sql.= " SUM(t.opp_amount * ".$this->db->ifsql("t.opp_percent IS NULL".($wonlostfilter?" OR cls.code IN ('WON','LOST')":""), '0', 't.opp_percent')." / 100) as weighted";
$sql.= " FROM " . MAIN_DB_PREFIX . "projet as t LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls ON cls.rowid = t.fk_opp_status"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet as t LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls ON cls.rowid = t.fk_opp_status";
if (! $user->rights->societe->client->voir && ! $user->societe_id) if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql.= $this->buildWhere(); $sql.= $this->buildWhere();
$sql.= " GROUP BY year"; $sql.= " GROUP BY year";
@ -171,7 +174,7 @@ class ProjectStats extends Stats
$sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(*) as nb"; $sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(*) as nb";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
if (! $user->rights->societe->client->voir && ! $user->societe_id) if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql .= $this->buildWhere(); $sql .= $this->buildWhere();
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
@ -198,7 +201,7 @@ class ProjectStats extends Stats
$sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount)"; $sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount)";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
if (! $user->rights->societe->client->voir && ! $user->societe_id) if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql .= $this->buildWhere(); $sql .= $this->buildWhere();
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
@ -321,7 +324,7 @@ class ProjectStats extends Stats
$sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount * ".$this->db->ifsql("t.opp_percent IS NULL".($wonlostfilter?" OR cls.code IN ('WON','LOST')":""), '0', 't.opp_percent')." / 100)"; $sql = "SELECT date_format(t.datec,'%m') as dm, SUM(t.opp_amount * ".$this->db->ifsql("t.opp_percent IS NULL".($wonlostfilter?" OR cls.code IN ('WON','LOST')":""), '0', 't.opp_percent')." / 100)";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t LEFT JOIN ".MAIN_DB_PREFIX.'c_lead_status as cls ON t.fk_opp_status = cls.rowid'; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t LEFT JOIN ".MAIN_DB_PREFIX.'c_lead_status as cls ON t.fk_opp_status = cls.rowid';
if (! $user->rights->societe->client->voir && ! $user->societe_id) if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql .= $this->buildWhere(); $sql .= $this->buildWhere();
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
@ -429,7 +432,7 @@ class ProjectStats extends Stats
$sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)"; $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
if (! $user->rights->societe->client->voir && ! $user->societe_id) if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql .= $this->buildWhere(); $sql .= $this->buildWhere();
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
@ -441,7 +444,7 @@ class ProjectStats extends Stats
$sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)"; $sql = "SELECT date_format(t.datec,'%m') as dm, count(t.opp_amount)";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as t";
if (! $user->rights->societe->client->voir && ! $user->societe_id) if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql .= $this->buildWhere(); $sql .= $this->buildWhere();
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";

View File

@ -0,0 +1,184 @@
<?php
/* Lead
* Copyright (C) 2014-2015 Florian HENRY <florian.henry@open-concept.pro>
*
* 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 <http://www.gnu.org/licenses/>.
*/
include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
/**
* Class to manage statistics on project tasks
*/
class TaskStats extends Stats
{
private $project;
public $userid;
public $socid;
public $year;
function __construct($db)
{
global $conf, $user;
$this->db = $db;
require_once 'task.class.php';
$this->task = new Task($this->db);
}
/**
* Return all tasks grouped by status.
*
* @param int $limit Limit results
* @return array|int Array with value or -1 if error
* @throws Exception
*/
function getAllTaskByStatus($limit = 5)
{
global $conf, $user, $langs;
$datay = array();
$sql = "SELECT";
$sql .= " COUNT(t.rowid), t.priority";
$sql.= " FROM ". MAIN_DB_PREFIX . "projet_task as t INNER JOIN " . MAIN_DB_PREFIX . "projet as p ON p.rowid = t.fk_projet";
if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql .= $this->buildWhere();
//$sql .= " AND t.fk_statut <> 0"; // We want historic also, so all task not draft
$sql .= " GROUP BY t.priority";
$result = array ();
$res = array ();
dol_syslog(get_class($this) . '::' . __METHOD__ . "", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
$other = 0;
while ( $i < $num ) {
$row = $this->db->fetch_row($resql);
if ($i < $limit || $num == $limit)
{
$result[$i] = array(
$row[1],
$row[0]
);
}
else
$other += $row[1];
$i++;
}
if ($num > $limit)
$result[$i] = array (
$langs->transnoentitiesnoconv("Other"),
$other
);
$this->db->free($resql);
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . '::' . __METHOD__ . ' ' . $this->error, LOG_ERR);
return -1;
}
return $result;
}
/**
* Return count, and sum of products
*
* @return array of values
*/
function getAllByYear()
{
global $conf, $user, $langs;
$datay = array ();
$wonlostfilter=0; // No filter on status WON/LOST
$sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb";
$sql.= " FROM ". MAIN_DB_PREFIX . "projet_task as t INNER JOIN " . MAIN_DB_PREFIX . "projet as p ON p.rowid = t.fk_projet";
if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql.= $this->buildWhere();
$sql.= " GROUP BY year";
$sql.= $this->db->order('year', 'DESC');
return $this->_getAllByYear($sql);
}
/**
* Build the where part
*
* @return string
*/
public function buildWhere()
{
$sqlwhere_str = '';
$sqlwhere = array();
$sqlwhere[] = ' t.entity IN (' . getEntity('project') . ')';
if (! empty($this->userid))
$sqlwhere[] = ' t.fk_user_resp=' . $this->userid;
if (! empty($this->socid))
$sqlwhere[] = ' t.fk_soc=' . $this->socid;
if (! empty($this->year) && empty($this->yearmonth))
$sqlwhere[] = " date_format(t.datec,'%Y')='" . $this->db->escape($this->year) . "'";
if (! empty($this->yearmonth))
$sqlwhere[] = " t.datec BETWEEN '" . $this->db->idate(dol_get_first_day($this->yearmonth)) . "' AND '" . $this->db->idate(dol_get_last_day($this->yearmonth)) . "'";
if (! empty($this->status))
$sqlwhere[] = " t.priority IN (" . $this->priority . ")";
if (count($sqlwhere) > 0) {
$sqlwhere_str = ' WHERE ' . implode(' AND ', $sqlwhere);
}
return $sqlwhere_str;
}
/**
* Return Task number by month for a year
*
* @param int $year scan
* @return array of values
*/
function getNbByMonth($year)
{
global $user;
$this->yearmonth = $year;
$sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(t.rowid) as nb";
$sql.= " FROM ". MAIN_DB_PREFIX . "projet_task as t INNER JOIN " . MAIN_DB_PREFIX . "projet as p ON p.rowid = t.fk_projet";
if (! $user->rights->societe->client->voir && ! $user->soc_id)
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=" . $user->id;
$sql .= $this->buildWhere();
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
$this->yearmonth=0;
$res = $this->_getNbByMonth($year, $sql);
// var_dump($res);print '<br>';
return $res;
}
}

View File

@ -0,0 +1,218 @@
<?php
/* Copyright (C) 2014-2015 Florian HENRY <florian.henry@open-concept.pro>
* Copyright (C) 2015 Laurent Destailleur <ldestailleur@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/projet/tasks/stats/index.php
* \ingroup project
* \brief Page for tasks statistics
*/
require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/taskstats.class.php';
// Security check
if (! $user->rights->projet->lire)
accessforbidden();
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
$userid=GETPOST('userid','int');
$socid=GETPOST('socid','int');
// Security check
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$nowyear=strftime("%Y", dol_now());
$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
//$startyear=$year-2;
$startyear=$year-1;
$endyear=$year;
$langs->load('companies');
$langs->load('projects');
/*
* View
*/
$form=new Form($db);
$includeuserlist=array();
llxHeader('', $langs->trans('Tasks'));
$title=$langs->trans("TasksStatistics");
$dir=$conf->projet->dir_output.'/temp';
print load_fiche_titre($title,'','title_project.png');
dol_mkdir($dir);
$stats_tasks= new TaskStats($db);
if (!empty($userid) && $userid!=-1) $stats_tasks->userid=$userid;
if (!empty($socid) && $socid!=-1) $stats_tasks->socid=$socid;
if (!empty($year)) $stats_tasks->year=$year;
// Build graphic number of object
// $data = array(array('Lib',val1,val2,val3),...)
$data = $stats_tasks->getNbByMonthWithPrevYear($endyear,$startyear);
//var_dump($data);
$filenamenb = $conf->project->dir_output . "/stats/tasknbprevyear-".$year.".png";
$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=taskstats&amp;file=tasknbprevyear-'.$year.'.png';
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (! $mesg)
{
$px1->SetData($data);
$px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px1->SetLegend($legend);
$px1->SetMaxValue($px1->GetCeilMaxValue());
$px1->SetWidth($WIDTH);
$px1->SetHeight($HEIGHT);
$px1->SetYLabel($langs->trans("ProjectNbTask"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
$px1->SetPrecisionY(0);
$px1->mode='depth';
$px1->SetTitle($langs->trans("ProjectNbTaskByMonth"));
$px1->draw($filenamenb,$fileurlnb);
}
// Show array
$stats_tasks->year=0;
$data_all_year = $stats_tasks->getAllByYear();
if (!empty($year)) $stats_tasks->year=$year;
$arrayyears=array();
foreach($data_all_year as $val) {
$arrayyears[$val['year']]=$val['year'];
}
if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
$h=0;
$head = array();
$head[$h][0] = DOL_URL_ROOT . '/projet/tasks/stats/index.php?mode='.$mode;
$head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear';
$h++;
complete_head_from_modules($conf,$langs,null,$head,$h,$type);
dol_fiche_head($head,'byyear',$langs->trans("Statistics"), -1, '');
print '<div class="fichecenter"><div class="fichethirdleft">';
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
// Company
/*print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
if ($mode == 'customer') $filter='s.client in (1,2,3)';
if ($mode == 'supplier') $filter='s.fournisseur = 1';
print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"');
print '</td></tr>';
*/
// User
/*print '<tr><td>'.$langs->trans("ProjectCommercial").'</td><td>';
print $form->select_dolusers($userid, 'userid', 1, array(),0,$includeuserlist);
print '</td></tr>';*/
// Year
print '<tr><td>'.$langs->trans("Year").'</td><td>';
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
arsort($arrayyears);
print $form->selectarray('year',$arrayyears,$year,0);
print '</td></tr>';
print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
print '</table>';
print '</form>';
print '<br><br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre" height="24">';
print '<td align="center">'.$langs->trans("Year").'</td>';
print '<td align="right">'.$langs->trans("NbOfTasks").'</td>';
print '</tr>';
$oldyear=0;
$var=true;
foreach ($data_all_year as $val)
{
$year = $val['year'];
while ($year && $oldyear > $year+1)
{ // If we have empty year
$oldyear--;
print '<tr '.$bc[$var].' height="24">';
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&amp;mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$oldyear.'</a></td>';
print '<td align="right">0</td>';
print '</tr>';
}
print '<tr '.$bc[$var].' height="24">';
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid>0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$year.'</a></td>';
print '<td align="right">'.$val['nb'].'</td>';
print '</tr>';
$oldyear=$year;
}
print '</table>';
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
$stringtoshow.= '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; }
else {
$stringtoshow.= $px1->show();
$stringtoshow.= "<br>\n";
}
$stringtoshow.= '</td></tr></table>';
print $stringtoshow;
print '</div></div></div>';
print '<div style="clear:both"></div>';
llxFooter();
$db->close();

View File

@ -0,0 +1,640 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* For paypal test: https://developer.paypal.com/
* For paybox test: ???
*/
/**
* \file htdocs/public/onlinesign/newsign.php
* \ingroup core
* \brief File to offer a way to make an online signature for a particular Dolibarr entity
*/
define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
// TODO This should be useless. Because entity must be retreive from object ref and not from url.
$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) define("DOLENTITY", $entity);
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
// Security check
// No check on module enabled. Done later according to $validpaymentmethod
$langs->load("main");
$langs->load("other");
$langs->load("dict");
$langs->load("bills");
$langs->load("companies");
$langs->load("errors");
$langs->load("paybox"); // File with generic data
$action=GETPOST('action','alpha');
// Input are:
// type ('invoice','order','contractline'),
// id (object id),
// amount (required if id is empty),
// tag (a free text, required if type is empty)
// currency (iso code)
$suffix=GETPOST("suffix",'alpha');
$SOURCE=GETPOST("source",'alpha');
$ref=$REF=GETPOST("ref",'alpha');
if (! $action)
{
if ($source && ! $ref)
{
dol_print_error('',$langs->trans('ErrorBadParameters')." - ref");
exit;
}
}
$paymentmethod='';
$validpaymentmethod=array();
// Define $urlwithroot
//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
// Complete urls for post treatment
$SECUREKEY=GETPOST("securekey"); // Secure key
if (! empty($SOURCE))
{
$urlok.='source='.urlencode($SOURCE).'&';
$urlko.='source='.urlencode($SOURCE).'&';
}
if (! empty($REF))
{
$urlok.='ref='.urlencode($REF).'&';
$urlko.='ref='.urlencode($REF).'&';
}
if (! empty($SECUREKEY))
{
$urlok.='securekey='.urlencode($SECUREKEY).'&';
$urlko.='securekey='.urlencode($SECUREKEY).'&';
}
if (! empty($entity))
{
$urlok.='entity='.urlencode($entity).'&';
$urlko.='entity='.urlencode($entity).'&';
}
$urlok=preg_replace('/&$/','',$urlok); // Remove last &
$urlko=preg_replace('/&$/','',$urlko); // Remove last &
/*
* Actions
*/
if ($action == 'dosign')
{
// TODO
}
/*
* View
*/
$head='';
if (! empty($conf->global->MAIN_SIGN_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->MAIN_SIGN_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n";
$conf->dol_hide_topmenu=1;
$conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
// Check link validity
if (! empty($SOURCE) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
{
$langs->load("errors");
dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $SOURCE, $ref));
llxFooter();
$db->close();
exit;
}
print '<span id="dolpaymentspan"></span>'."\n";
print '<div class="center">'."\n";
print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
print '<input type="hidden" name="action" value="dosign">'."\n";
print '<input type="hidden" name="tag" value="'.GETPOST("tag",'alpha').'">'."\n";
print '<input type="hidden" name="suffix" value="'.GETPOST("suffix",'alpha').'">'."\n";
print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
print '<input type="hidden" name="entity" value="'.$entity.'" />';
print "\n";
print '<!-- Form to sign -->'."\n";
print '<table id="dolpaymenttable" summary="Payment form" class="center">'."\n";
// Show logo (search order: logo defined by PAYBOX_LOGO_suffix, then PAYBOX_LOGO, then small company logo, large company logo, theme logo, common logo)
$width=0;
// Define logo and logosmall
$logosmall=$mysoc->logo_small;
$logo=$mysoc->logo;
$paramlogo='ONLINE_SIGN_LOGO_'.$suffix;
if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo;
else if (! empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall=$conf->global->ONLINE_SIGN_LOGO;
//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
// Define urllogo
$urllogo='';
if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('thumbs/'.$logosmall);
}
elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode($logo);
$width=96;
}
// Output html code for logo
if ($urllogo)
{
print '<tr>';
print '<td align="center"><img id="dolpaymentlogo" title="'.$title.'" src="'.$urllogo.'"';
if ($width) print ' width="'.$width.'"';
print '></td>';
print '</tr>'."\n";
}
// Output introduction text
$text='';
if (! empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT))
{
$langs->load("members");
if (preg_match('/^\((.*)\)$/',$conf->global->ONLINE_SIGN_NEWFORM_TEXT,$reg)) $text.=$langs->trans($reg[1])."<br>\n";
else $text.=$conf->global->ONLINE_SIGN_NEWFORM_TEXT."<br>\n";
$text='<tr><td align="center"><br>'.$text.'<br></td></tr>'."\n";
}
if (empty($text))
{
$text.='<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePage").'</strong><br></td></tr>'."\n";
$text.='<tr><td class="textpublicpayment"><br>'.$langs->trans("ThisScreenAllowsYouToSignDocFrom",$creditor).'<br><br></td></tr>'."\n";
}
print $text;
// Output payment summary form
print '<tr><td align="center">';
print '<table with="100%" id="tablepublicpayment">';
print '<tr class="liste_total"><td align="left" colspan="2">'.$langs->trans("ThisIsInformationOnDocumentToSign").' :</td></tr>'."\n";
$found=false;
$error=0;
$var=false;
// Free payment
if (! GETPOST("source"))
{
$found=true;
$tag=GETPOST("tag");
$fulltag=$tag;
// Creditor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum
// as they don't exists (buyer is unknown, tag is free).
}
// Payment on customer order
if (GETPOST("source") == 'order')
{
$found=true;
$langs->load("orders");
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$order=new Commande($db);
$result=$order->fetch('',$ref);
if ($result < 0)
{
$mesg=$order->error;
$error++;
}
else
{
$result=$order->fetch_thirdparty($order->socid);
}
// Creditor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("ThirdParty");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$order->thirdparty->name.'</b>';
// Object
$text='<b>'.$langs->trans("PaymentOrderRef",$order->ref).'</b>';
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.GETPOST("source",'alpha').'">';
print '<input type="hidden" name="ref" value="'.$order->ref.'">';
print '</td></tr>'."\n";
}
// Payment on customer invoice
if (GETPOST("source") == 'invoice')
{
$found=true;
$langs->load("bills");
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$invoice=new Facture($db);
$result=$invoice->fetch('',$ref);
if ($result < 0)
{
$mesg=$invoice->error;
$error++;
}
else
{
$result=$invoice->fetch_thirdparty($invoice->socid);
}
if ($action != 'dosign') // Do not change amount if we just click on first dosign
{
$amount=price2num($invoice->total_ttc - $invoice->getSommePaiement());
if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
$amount=price2num($amount);
}
// Creditor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("ThirdParty");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$invoice->thirdparty->name.'</b>';
// Object
$text='<b>'.$langs->trans("PaymentInvoiceRef",$invoice->ref).'</b>';
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.GETPOST("source",'alpha').'">';
print '<input type="hidden" name="ref" value="'.$invoice->ref.'">';
print '</td></tr>'."\n";
}
// Payment on contract line
if (GETPOST("source") == 'contractline')
{
$found=true;
$langs->load("contracts");
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$contractline=new ContratLigne($db);
$result=$contractline->fetch('',$ref);
if ($result < 0)
{
$mesg=$contractline->error;
$error++;
}
else
{
if ($contractline->fk_contrat > 0)
{
$contract=new Contrat($db);
$result=$contract->fetch($contractline->fk_contrat);
if ($result > 0)
{
$result=$contract->fetch_thirdparty($contract->socid);
}
else
{
$mesg=$contract->error;
$error++;
}
}
else
{
$mesg='ErrorRecordNotFound';
$error++;
}
}
if ($action != 'dosign') // Do not change amount if we just click on first dosign
{
$amount=$contractline->total_ttc;
if ($contractline->fk_product)
{
$product=new Product($db);
$result=$product->fetch($contractline->fk_product);
// We define price for product (TODO Put this in a method in product class)
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
$pu_ht = $product->multiprices[$contract->thirdparty->price_level];
$pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
$price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
}
else
{
$pu_ht = $product->price;
$pu_ttc = $product->price_ttc;
$price_base_type = $product->price_base_type;
}
$amount=$pu_ttc;
if (empty($amount))
{
dol_print_error('','ErrorNoPriceDefinedForThisProduct');
exit;
}
}
if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
$amount=price2num($amount);
}
$qty=1;
if (GETPOST('qty')) $qty=GETPOST('qty');
// Creditor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("ThirdParty");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$contract->thirdparty->name.'</b>';
// Object
$text='<b>'.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).'</b>';
if ($contractline->fk_product)
{
$text.='<br>'.$product->ref.($product->label?' - '.$product->label:'');
}
if ($contractline->description) $text.='<br>'.dol_htmlentitiesbr($contractline->description);
//if ($contractline->date_fin_validite) {
// $text.='<br>'.$langs->trans("DateEndPlanned").': ';
// $text.=dol_print_date($contractline->date_fin_validite);
//}
if ($contractline->date_fin_validite)
{
$text.='<br>'.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite);
}
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.GETPOST("source",'alpha').'">';
print '<input type="hidden" name="ref" value="'.$contractline->ref.'">';
print '</td></tr>'."\n";
// Quantity
$label=$langs->trans("Quantity");
$qty=1;
$duration='';
if ($contractline->fk_product)
{
if ($product->isService() && $product->duration_value > 0)
{
$label=$langs->trans("Duration");
// TODO Put this in a global method
if ($product->duration_value > 1)
{
$dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("DurationDays"),"w"=>$langs->trans("DurationWeeks"),"m"=>$langs->trans("DurationMonths"),"y"=>$langs->trans("DurationYears"));
}
else
{
$dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("DurationDay"),"w"=>$langs->trans("DurationWeek"),"m"=>$langs->trans("DurationMonth"),"y"=>$langs->trans("DurationYear"));
}
$duration=$product->duration_value.' '.$dur[$product->duration_unit];
}
}
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$label.'</td>';
print '<td class="CTableRow'.($var?'1':'2').'"><b>'.($duration?$duration:$qty).'</b>';
print '<input type="hidden" name="newqty" value="'.dol_escape_htmltag($qty).'">';
print '</b></td></tr>'."\n";
// Amount
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Amount");
if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
print '</td><td class="CTableRow'.($var?'1':'2').'">';
if (empty($amount) || ! is_numeric($amount))
{
print '<input type="hidden" name="amount" value="'.GETPOST("amount",'int').'">';
print '<input class="flat" size=8 type="text" name="newamount" value="'.GETPOST("newamount","int").'">';
}
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";
}
// Payment on member subscription
if (GETPOST("source") == 'membersubscription')
{
$found=true;
$langs->load("members");
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
$member=new Adherent($db);
$result=$member->fetch('',$ref);
if ($result < 0)
{
$mesg=$member->error;
$error++;
}
else
{
$subscription=new Subscription($db);
}
if ($action != 'dosign') // Do not change amount if we just click on first dosign
{
$amount=$subscription->total_ttc;
if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
$amount=price2num($amount);
}
$fulltag='MEM='.$member->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M');
if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; }
$fulltag=dol_string_unaccent($fulltag);
// Creditor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Member");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>';
if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe;
else print $member->getFullName($langs);
print '</b>';
// Object
$text='<b>'.$langs->trans("PaymentSubscription").'</b>';
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.GETPOST("source",'alpha').'">';
print '<input type="hidden" name="ref" value="'.$member->ref.'">';
print '</td></tr>'."\n";
if ($member->last_subscription_date || $member->last_subscription_amount)
{
// Last subscription date
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("LastSubscriptionDate");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.dol_print_date($member->last_subscription_date,'day');
print '</td></tr>'."\n";
// Last subscription amount
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("LastSubscriptionAmount");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.price($member->last_subscription_amount);
print '</td></tr>'."\n";
if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount;
}
// Amount
print '<tr class="CTableRow'.($var?'1':'2').'"><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Amount");
if (empty($amount))
{
print ' ('.$langs->trans("ToComplete");
if (! empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external" target="_blank">'.$langs->trans("SeeHere").'</a>';
print ')';
}
print '</td><td class="CTableRow'.($var?'1':'2').'">';
if (empty($amount) || ! is_numeric($amount))
{
$valtoshow=GETPOST("newamount",'int');
if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow);
print '<input type="hidden" name="amount" value="'.GETPOST("amount",'int').'">';
print '<input class="flat" size="8" type="text" name="newamount" value="'.$valtoshow.'">';
}
else {
$valtoshow=$amount;
if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow);
print '<b>'.price($valtoshow).'</b>';
print '<input type="hidden" name="amount" value="'.$valtoshow.'">';
print '<input type="hidden" name="newamount" value="'.$valtoshow.'">';
}
// Currency
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";
}
if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters");
if ($mesg) print '<tr><td align="center" colspan="2"><br><div class="warning">'.$mesg.'</div></td></tr>'."\n";
print '</table>'."\n";
print "\n";
if ($action != 'dosign')
{
if ($found && ! $error) // We are in a management option and no error
{
}
else
{
dol_print_error_email('ERRORNEWONLINESIGNPAYPAL');
}
}
else
{
// Print
}
print '</td></tr>'."\n";
print '</table>'."\n";
print '</form>'."\n";
print '</div>'."\n";
print '<br>';
htmlPrintOnlinePaymentFooter($mysoc,$langs);
llxFooter('', 'public');
$db->close();

View File

@ -169,13 +169,22 @@ $conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
// Common variables // Common variables
$creditor=$mysoc->name; $creditor=$mysoc->name;
$paramcreditor='PAYBOX_CREDITOR_'.$suffix; $paramcreditor='PAYBOX_CREDITOR_'.$suffix;
if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor; if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
else if (! empty($conf->global->PAYBOX_CREDITOR)) $creditor=$conf->global->PAYBOX_CREDITOR; else if (! empty($conf->global->PAYBOX_CREDITOR)) $creditor=$conf->global->PAYBOX_CREDITOR;
// Check link validity
if (! empty($SOURCE) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
{
$langs->load("errors");
dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $SOURCE, $ref));
llxFooter();
$db->close();
exit;
}
print '<span id="dolpaymentspan"></span>'."\n"; print '<span id="dolpaymentspan"></span>'."\n";
print '<div class="center">'; print '<div class="center">';
print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';

Some files were not shown because too many files have changed in this diff Show More