Merge remote-tracking branch 'refs/remotes/Dolibarr/develop' into develop

This commit is contained in:
Darkjeff 2017-10-02 09:56:19 +02:00
commit c6d0cad2f5
298 changed files with 11287 additions and 7475 deletions

View File

@ -11,13 +11,55 @@ NEW: complete_head_from_modules() in ldap_prepare_head()
WARNING:
Following changes may create regression for some external modules, but were necessary to make Dolibarr better:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* The methode "cloture" on contact were renamed into "closeAll".
* The substitution key for reference of object is now __REF__ whatever is the object (it replaces __ORDERREF__,
__PROPALREF__, ...)
* Some REST API to access the dictionary (country, town, ...) were moved into a common API.
***** ChangeLog for 6.0.1 compared to 6.0.* *****
FIX: #7000 Dashboard link for late pending payment supplier invoices do not work
FIX: #7325 Default VAT rate when editing template invoices is 0%
FIX: #7330
FIX: #7359
FIX: #7367
FIX: #7368
FIX: #7391
FIX: #7420
FIX: Add some missing attributes in Adherent:makeSubstitution (type, phone…
FIX: Bad const name
FIX: Bad link to unpayed suppliers invoices
FIX: Better protection to no send email when we change limit
FIX: Calculation in the activity box
FIX: Clean bad parameters when inserting line of template invoice
FIX: dateSelector was not taken into account
FIX: hidden option MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN
FIX: journalization for bank journal should not rely on a label.
FIX: menu enty when url is external link
FIX: missing supplier qty and supplier discount in available fields for product export.
FIX: multicompany better accuracy in rounding and with revenue stamp.
FIX: Must use pdf format page as default for merging PDF.
FIX: PDF output was sharing 2 different currencies in same total
FIX: Position of signature on strato template
FIX: Protection to avoid to apply credit note discount > remain to pay
FIX: Remove warning when using log into syslog
FIX: Responsive
FIX: Security fixes (filter onload js, less verbose error message in
FIX: SEPA recording payment must save one payment in bank per customer
FIX: Several problem with the last event box on project/tasks
FIX: Sign of amount in origin currency on credit note created from lines
FIX: Some page of admin were not responsive
FIX: SQL injection
FIX: time.php crashed without project id in param
FIX: transfer of line extrafields from order to invoice
FIX: Upgrade missing on field
FIX: View of timespent for another user
FIX: ODT generation
FIX: CVE-2017-9840, CVE-2017-14238, CVE-2017-14239, CVE-2017-14240, CVE-2017-14241,
CVE-2017-14242
***** ChangeLog for 6.0.0 compared to 5.0.* *****
NEW: Add experimental BlockeLog module (to log business events in a non reversible log file).
NEW: Add a payment module for Stripe.
NEW: Add module "Product variant" (like red, blue for the product shoes)

View File

@ -366,7 +366,9 @@ if ($nboftargetok) {
}
else # For a maintenance release
{
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
#print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. | grep -v "Merge branch" | grep -v "Merge pull" | grep "^ " | sed -e "s/^[0-9a-z]* *//" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa';
}
print "\n";
if (! $ret)

View File

@ -60,14 +60,14 @@ $db->begin();
require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
// Create invoice object
// Create user object
$obj = new User($db);
//$obj->initAsSpecimen();
$obj->login = 'ABCDEF';
$obj->nom = 'ABCDEF';
// Create invoice
// Create user
$idobject=$obj->create($user);
if ($idobject > 0)
{

View File

@ -67,7 +67,7 @@ $db->begin();
require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
// Create invoice object
// Create contract object
$obj = new Contrat($db);
$obj->socid=$argv[1];

View File

@ -53,12 +53,10 @@ if (! $user->rights->accounting->chartofaccount) accessforbidden();
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'sortorder');
$page = GETPOST("page", 'int');
if ($page == - 1) {
$page = 0;
}
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;

View File

@ -740,15 +740,6 @@ if ($id)
print '</td>';
print "</tr>";
if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates')
{
print '<tr><td colspan="8">* '.$langs->trans("AvailableVariables").": ";
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$tmp=FormMail::getAvailableSubstitKey('formemail');
print implode(', ', $tmp);
print '</td></tr>';
}
$colspan=count($fieldlist)+3;
if ($id == 4) $colspan++;

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -37,10 +37,10 @@ $langs->load("bills");
$langs->load("admin");
$langs->load("accountancy");
// Security check
if (empty($user->admin) && empty($user->rights->accounting->chartofaccount))
// Security access
if (empty($user->rights->accounting->chartofaccount))
{
accessforbidden();
accessforbidden();
}
$action = GETPOST('action', 'alpha');
@ -53,13 +53,6 @@ $main_option = array (
$model_option = array (
'ACCOUNTING_EXPORT_SEPARATORCSV',
'ACCOUNTING_EXPORT_DATE'
/*
'ACCOUNTING_EXPORT_PIECE',
'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT',
'ACCOUNTING_EXPORT_LABEL',
'ACCOUNTING_EXPORT_AMOUNT',
'ACCOUNTING_EXPORT_DEVISE'
*/
);
/*
@ -121,17 +114,13 @@ llxHeader();
$form = new Form($db);
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
// $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
$head = admin_accounting_prepare_head();
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'cron');
$var = true;
/*
@ -245,8 +234,6 @@ if ($num2) {
print "</table>\n";
}
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Modify')) . '" name="button"></div>';
print '</form>';

View File

@ -37,10 +37,9 @@ $langs->load("compta");
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy");
$langs->load("salaries");
// Security check
if (empty($user->admin))
// Security access
if (empty($user->rights->accounting->chartofaccount))
{
accessforbidden();
}
@ -160,18 +159,13 @@ llxHeader();
$form = new Form($db);
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
//$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
$head = admin_accounting_prepare_head($accounting);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'general', $langs->trans("Configuration"), -1, 'cron');
// Default mode for calculating turnover (parameter ACCOUNTING_MODE)
print '<table class="noborder" width="100%">';
@ -287,18 +281,11 @@ foreach ($list as $key)
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '<br>';
print '<br>';
print '<div class="opacitymedium">'.$langs->trans("AccountancySetupDoneFromAccountancyMenu", $langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")).'</div>';
print '<br>';
print '</form>';

View File

@ -210,7 +210,7 @@ else {
print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Solde", $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n";
@ -280,4 +280,4 @@ else {
llxFooter();
}
$db->close();
$db->close();

View File

@ -114,11 +114,11 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
}
// Mass actions
$objectclass='Skeleton';
$objectlabel='Skeleton';
$permtoread = $user->rights->accounting->read;
$permtodelete = $user->rights->accounting->delete;
$uploaddir = $conf->accounting->dir_output;
$objectclass='ExpenseReport';
$objectlabel='ExpenseReport';
$permtoread = $user->rights->expensereport->read;
$permtodelete = $user->rights->expensereport->delete;
$uploaddir = $conf->expensereport->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'ventil') {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2016 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
@ -121,14 +121,22 @@ $hookmanager->initHooks(array('membercard','globalcard'));
* Actions
*/
if ($cancel) $action='';
$parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if ($cancel)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
$action='';
}
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
{
$error=0;
@ -230,6 +238,7 @@ if (empty($reshook))
}
}
/*
if ($action == 'confirm_sendinfo' && $confirm == 'yes')
{
if ($object->email)
@ -242,7 +251,7 @@ if (empty($reshook))
$langs->load("mails");
setEventMessages($langs->trans("MailSuccessfulySent", $from, $object->email), null, 'mesgs');
}
}
}*/
if ($action == 'update' && ! $cancel && $user->rights->adherent->creer)
{
@ -715,10 +724,21 @@ if (empty($reshook))
}
}
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to build doc
$upload_dir = $conf->adherent->dir_output;
$permissioncreate=$user->rights->adherent->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$trigger_name='MEMBER_SENTBYMAIL';
$paramname='id';
$mode='emailfrommember';
$trackid='mem'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
@ -813,6 +833,7 @@ else
print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
dol_fiche_head('');
@ -954,11 +975,18 @@ else
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
print '</div>';
print '<div class="center">';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">';
print '&nbsp;&nbsp;';
if (! empty($backtopage))
{
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
}
else
{
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
}
print '</div>';
print "</form>\n";
}
@ -1225,7 +1253,7 @@ else
print '<div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -1344,10 +1372,10 @@ else
}
// Confirm send card by mail
if ($action == 'sendinfo')
/*if ($action == 'sendinfo')
{
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
}
}*/
// Confirm terminate
if ($action == 'resign')
@ -1590,6 +1618,31 @@ else
if (empty($reshook)) {
if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty')
{
// Send
if ($object->statut == 1) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendByMail') . '</a></div>';
}
// Send card by email
// TODO Remove this to replace with a template
/*
if ($user->rights->adherent->creer)
{
if ($object->statut >= 1)
{
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a></div>\n";
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a></div>\n";
}
else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}
}
else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}*/
// Modify
if ($user->rights->adherent->creer)
{
@ -1626,24 +1679,6 @@ else
}
}
// Send card by email
if ($user->rights->adherent->creer)
{
if ($object->statut >= 1)
{
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a></div>\n";
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a></div>\n";
}
else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}
}
else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}
// Terminate
if ($object->statut >= 1)
{
@ -1720,52 +1755,65 @@ else
}
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// Documents generes
$filename = dol_sanitizeFileName($object->ref);
//$filename = 'tmp_cards.php';
//$filedir = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 0, $object, 'member') . dol_sanitizeFileName($object->ref);
$filedir = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 0, $object, 'member');
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
$genallowed = $user->rights->adherent->creer;
$delallowed = $user->rights->adherent->supprimer;
print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object);
$somethingshown = $formfile->numoffiles;
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
//$somethingshown = $form->showLinkedObjectBlock($object, '');
// Show links to link elements
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
*/
// Shon online payment link
$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
if ($useonlinepayment)
{
print '<br>';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
print showOnlinePaymentUrl('membersubscription', $object->ref);
// Select mail models is same action as presend
if (GETPOST('modelselected')) {
$action = 'presend';
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// List of actions on element
/* Already in tab Agenda/Events
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'member', $socid, 1);
*/
print '</div></div></div>';
// Documents generes
$filename = dol_sanitizeFileName($object->ref);
//$filename = 'tmp_cards.php';
//$filedir = $conf->adherent->dir_output . '/' . get_exdir($object->id, 2, 0, 0, $object, 'member') . dol_sanitizeFileName($object->ref);
$filedir = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 0, $object, 'member');
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
$genallowed = $user->rights->adherent->creer;
$delallowed = $user->rights->adherent->supprimer;
print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object);
$somethingshown = $formfile->numoffiles;
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
//$somethingshown = $form->showLinkedObjectBlock($object, '');
// Show links to link elements
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
*/
// Shon online payment link
$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
if ($useonlinepayment)
{
print '<br>';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
print showOnlinePaymentUrl('membersubscription', $object->ref);
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', 10);
print '</div></div></div>';
}
// Presend form
$modelmail='member';
$defaulttopic='SendMemberRef';
$diroutput = $conf->adherent->dir_output;
$trackid = 'mem'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
}

View File

@ -46,6 +46,10 @@ $mesg='';
$adherentstatic=new Adherent($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('adherent');
/*
* Actions
@ -65,9 +69,14 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
$sql.= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
$sql.= " t.libelle as type,";
$sql.= " c.code as country_code, c.label as country";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val)
$sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
$sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
$sql.= " AND d.entity IN (".getEntity('adherent').")";
if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid;
if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'";
$sql.= " ORDER BY d.rowid ASC";
@ -84,9 +93,27 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
if ($objp->country == '-') $objp->country='';
$adherentstatic->id=$objp->rowid;
$adherentstatic->lastname=$objp->lastname;
$adherentstatic->firstname=$objp->firstname;
// format extrafiled so they can be parsed in function complete_substitutions_array
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
$adherentstatic->array_options = array();
foreach($extrafields->attribute_label as $key => $val)
{
$tmpkey='options_'.$key;
if (!empty($objp->$tmpkey))
{
$adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
}
//if (!empty($objp->$key))
// $objp->array_options[$tmpkey] = $objp->$key;
//$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey;
}
}
// List of values to scan for a replacement
$substitutionarray = array (
'%ID%'=>$objp->rowid,
@ -109,7 +136,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
);
complete_substitutions_array($substitutionarray, $langs);
complete_substitutions_array($substitutionarray, $langs, $adherentstatic);
// For business cards
if (empty($mode) || $mode=='card' || $mode=='cardlogin')
@ -123,7 +150,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
{
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
if ($nb <= 0) $nb=1; // Protection to avoid empty page
for($j=0;$j<$nb;$j++)
{
$arrayofmembers[]=array(

View File

@ -213,51 +213,23 @@ class Adherent extends CommonObject
// Substitutions
$substitutionarray=array(
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
'__ID__'=>$msgishtml?dol_htmlentitiesbr($this->id):$this->id,
'__CIVILITY__'=>$this->getCivilityLabel(),
'__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
'__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs),
'__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address,
'__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'__TOWN_'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'__COUNTRY__'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
'__EMAIL__'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email,
'__BIRTH__'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday,
'__PHOTO__'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
'__LOGIN__'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
'__PASSWORD__'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass,
// For backward compatibility
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
'%ID%'=>$msgishtml?dol_htmlentitiesbr($this->id):$this->id,
'%CIVILITY%'=>$this->getCivilityLabel(),
'%FIRSTNAME%'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'%LASTNAME%'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
'%FULLNAME%'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs),
'%COMPANY%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'%ADDRESS%'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address,
'%ZIP%'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'%TOWN%'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'%COUNTRY%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
'%EMAIL%'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email,
'%BIRTH%'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday,
'%PHOTO%'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
'%LOGIN%'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
'%PASSWORD%'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass,
'%TYPE%'=>$msgishtml?dol_htmlentitiesbr($this->type):$this->type,
'%PHONE_PRO%'=>$msgishtml?dol_htmlentitiesbr($this->phone):$this->phone,
'%PHONE_PERSO%'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):$this->phone_perso,
'%PHONE_MOBILE%'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):$this->phone_mobile,
// For backward compatibility
'%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos,
'%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'%PRENOM%'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'%NOM%'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
'%CP%'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'%VILLE%'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'%PAYS%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
'__CIVILITY__'=>$this->getCivilityLabel(),
'__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
'__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs),
'__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address,
'__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'__TOWN__'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'__COUNTRY__'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
'__EMAIL__'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email,
'__BIRTH__'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday,
'__PHOTO__'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
'__LOGIN__'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
'__PASSWORD__'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass,
'__PHONE__'=>$msgishtml?dol_htmlentitiesbr($this->phone):$this->phone,
'__PHONEPRO__'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):$this->phone_perso,
'__PHONEMOBILE__'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):$this->phone_mobile,
);
complete_substitutions_array($substitutionarray, $langs, $this);
@ -447,33 +419,33 @@ class Adherent extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql.= " civility = ".(!is_null($this->civility_id)?$this->db->escape($this->civility_id):"null");
$sql.= " civility = ".($this->civility_id>0?$this->db->escape($this->civility_id):"null");
$sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null");
$sql.= ", lastname=" .($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
$sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null");
$sql.= ", fk_soc=" .($this->fk_soc > 0?$this->db->escape($this->fk_soc):"null");
$sql.= ", address=" .($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", zip=" .($this->zip?"'".$this->db->escape($this->zip)."'":"null");
$sql.= ", town=" .($this->town?"'".$this->db->escape($this->town)."'":"null");
$sql.= ", country=".($this->country_id>0?$this->db->escape($this->country_id):"null");
$sql.= ", state_id=".($this->state_id>0?$this->db->escape($this->state_id):"null");
$sql.= ", email='".$this->db->escape($this->email)."'";
$sql.= ", skype='".$this->db->escape($this->skype)."'";
$sql.= ", phone=" .($this->phone?"'".$this->db->escape($this->phone)."'":"null");
$sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
$sql.= ", phone_mobile=" .($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null");
$sql.= ", note_private=" .($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", note_public=" .($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", photo=" .($this->photo?"'".$this->db->escape($this->photo)."'":"null");
$sql.= ", public='".$this->db->escape($this->public)."'";
$sql.= ", statut=" .$this->statut;
$sql.= ", fk_adherent_type=".$this->typeid;
$sql.= ", morphy='".$this->db->escape($this->morphy)."'";
$sql.= ", birth=" .($this->birth?"'".$this->db->idate($this->birth)."'":"null");
if ($this->datefin) $sql.= ", datefin='".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
if ($this->datevalid) $sql.= ", datevalid='".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member
$sql.= ", fk_user_mod=".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest
$sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
$sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", societe = ".($this->societe?"'".$this->db->escape($this->societe)."'":"null");
$sql.= ", fk_soc = ".($this->fk_soc > 0?$this->db->escape($this->fk_soc):"null");
$sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null");
$sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null");
$sql.= ", country = ".($this->country_id>0?$this->db->escape($this->country_id):"null");
$sql.= ", state_id = ".($this->state_id>0?$this->db->escape($this->state_id):"null");
$sql.= ", email = '".$this->db->escape($this->email)."'";
$sql.= ", skype = '".$this->db->escape($this->skype)."'";
$sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null");
$sql.= ", phone_perso = ".($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
$sql.= ", phone_mobile = ".($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null");
$sql.= ", note_private = ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null");
$sql.= ", public = '".$this->db->escape($this->public)."'";
$sql.= ", statut = ".$this->statut;
$sql.= ", fk_adherent_type = ".$this->typeid;
$sql.= ", morphy = '".$this->db->escape($this->morphy)."'";
$sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null");
if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
if ($this->datevalid) $sql.= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member
$sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update update member", LOG_DEBUG);
@ -714,15 +686,15 @@ class Adherent extends CommonObject
* Fonction qui supprime l'adherent et les donnees associees
*
* @param int $rowid Id of member to delete
* @param User $user User object
* @param User $user User object
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, 0=nothing to do, >0 if OK
*/
function delete($rowid, $user, $notrigger=0)
{
global $conf, $langs;
function delete($rowid, $user, $notrigger=0)
{
global $conf, $langs;
$result = 0;
$result = 0;
$error=0;
$errorflag=0;
@ -739,84 +711,83 @@ class Adherent extends CommonObject
// End call triggers
}
// Remove category
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
$this->error .= $this->db->lasterror();
$errorflag=-1;
// Remove category
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
$this->error .= $this->db->lasterror();
$errorflag=-1;
}
}
// Remove subscription
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
$this->error .= $this->db->lasterror();
$errorflag=-2;
}
}
// Remove subscription
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
$this->error .= $this->db->lasterror();
$errorflag=-2;
}
}
// Remove linked user
if (! $error)
{
$ret=$this->setUserId(0);
if ($ret < 0)
{
$error++;
$this->error .= $this->db->lasterror();
$errorflag=-3;
}
}
// Remove linked user
if (! $error)
{
$ret=$this->setUserId(0);
if ($ret < 0)
{
$error++;
$this->error .= $this->db->lasterror();
$errorflag=-3;
}
}
// Removed extrafields
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
$errorflag=-4;
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
}
}
// Removed extrafields
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
$errorflag=-4;
dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
}
}
// Remove adherent
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
$this->error .= $this->db->lasterror();
$errorflag=-5;
}
}
// Remove adherent
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
$this->error .= $this->db->lasterror();
$errorflag=-5;
}
}
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return $errorflag;
}
}
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return $errorflag;
}
}
/**
@ -1192,7 +1163,7 @@ class Adherent extends CommonObject
// Load other properties
$result=$this->fetch_subscriptions();
return $result;
return $this->id;
}
else
{

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
@ -22,7 +22,6 @@
* \file htdocs/adherents/class/adherent_type.class.php
* \ingroup member
* \brief File of class to manage members types
* \author Rodolphe Quiedeville
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
@ -62,228 +61,331 @@ class AdherentType extends CommonObject
public $vote;
/** @var bool Email sent during validation */
public $mail_valid;
/** @var array Array of members */
public $members=array();
/**
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->statut = 1;
}
*/
function __construct($db)
{
$this->db = $db;
$this->statut = 1;
}
/**
* Fonction qui permet de creer le status de l'adherent
*
* @param User $user User making creation
* @return int >0 if OK, < 0 if KO
*/
function create($user)
{
global $conf;
/**
* Fonction qui permet de creer le status de l'adherent
*
* @param User $user User making creation
* @param int $notrigger 1=do not execute triggers, 0 otherwise
* @return int >0 if OK, < 0 if KO
*/
function create($user,$notrigger=0)
{
global $conf;
$this->statut=(int) $this->statut;
$this->label=(!empty($this->libelle)?trim($this->libelle):trim($this->label));
$error=0;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
$sql.= "libelle";
$sql.= ", entity";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->label)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
$this->statut=(int) $this->statut;
$this->label=trim($this->label);
dol_syslog("Adherent_type::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type");
return $this->update($user);
}
else
{
$this->error=$this->db->error().' sql='.$sql;
return -1;
}
}
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
$sql.= "libelle";
$sql.= ", entity";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->label)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
/**
* Met a jour en base donnees du type
*
* @param User $user Object user making change
* @return int >0 if OK, < 0 if KO
*/
function update($user)
{
global $hookmanager,$conf;
dol_syslog("Adherent_type::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type");
$error=0;
$result = $this->update($user,1);
if ($result < 0)
{
$this->db->rollback();
return -3;
}
$this->label=(!empty($this->libelle)?trim($this->libelle):trim($this->label));
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
$sql.= "SET ";
$sql.= "statut = ".$this->statut.",";
$sql.= "libelle = '".$this->db->escape($this->label) ."',";
$sql.= "subscription = '".$this->db->escape($this->subscription)."',";
$sql.= "note = '".$this->db->escape($this->note)."',";
$sql.= "vote = '".$this->db->escape($this->vote)."',";
$sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
$sql.= " WHERE rowid =".$this->id;
if (! $error)
{
$this->db->commit();
return $this->id;
}
else
{
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
}
$result = $this->db->query($sql);
if ($result)
{
$action='update';
/**
* Met a jour en base donnees du type
*
* @param User $user Object user making change
* @param int $notrigger 1=do not execute triggers, 0 otherwise
* @return int >0 if OK, < 0 if KO
*/
function update($user,$notrigger=0)
{
global $conf, $hookmanager;
// Actions on extra fields (by external module or standard code)
$hookmanager->initHooks(array('membertypedao'));
$parameters=array('membertype'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
else if ($reshook < 0) $error++;
$error=0;
$this->label=trim($this->label);
return 1;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
return -1;
}
}
$this->db->begin();
/**
* Fonction qui permet de supprimer le status de l'adherent
*
* @param int $rowid Id of member type to delete
* @return int >0 if OK, 0 if not found, < 0 if KO
*/
function delete($rowid='')
{
if (empty($rowid)) $rowid=$this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
$sql.= "SET ";
$sql.= "statut = ".$this->statut.",";
$sql.= "libelle = '".$this->db->escape($this->label) ."',";
$sql.= "subscription = '".$this->db->escape($this->subscription)."',";
$sql.= "note = '".$this->db->escape($this->note)."',";
$sql.= "vote = '".$this->db->escape($this->vote)."',";
$sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
$sql.= " WHERE rowid =".$this->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type WHERE rowid = ".$rowid;
$result = $this->db->query($sql);
if ($result)
{
$action='update';
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->affected_rows($resql))
{
return 1;
}
else
{
return 0;
}
}
else
{
print "Err : ".$this->db->error();
return 0;
}
}
// Actions on extra fields (by external module or standard code)
$hookmanager->initHooks(array('membertypedao'));
$parameters=array('membertype'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
else if ($reshook < 0) $error++;
/**
* Fonction qui permet de recuperer le status de l'adherent
*
* @param int $rowid Id of member type to load
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid)
{
$sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.rowid = ".$rowid;
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
dol_syslog("Adherent_type::fetch", LOG_DEBUG);
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -$error;
}
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
}
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
/**
* Fonction qui permet de supprimer le status de l'adherent
*
* @return int >0 if OK, 0 if not found, < 0 if KO
*/
function delete()
{
global $user;
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->label = $obj->label;
$this->libelle = $obj->label; // For backward compatibility
$this->statut = $obj->statut;
$this->subscription = $obj->subscription;
$this->mail_valid = $obj->mail_valid;
$this->note = $obj->note;
$this->vote = $obj->vote;
}
return 1;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE rowid = ".$this->id;
/**
* Return list of members' type
*
* @return array List of types of members
*/
function liste_array()
{
global $conf,$langs;
$resql=$this->db->query($sql);
if ($resql)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_DELETE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -2; }
// End call triggers
$adherenttypes = array();
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
return -1;
}
}
$sql = "SELECT rowid, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE entity IN (".getEntity('adherent').")";
/**
* Fonction qui permet de recuperer le status de l'adherent
*
* @param int $rowid Id of member type to load
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid)
{
$sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.rowid = ".$rowid;
$resql=$this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
dol_syslog("Adherent_type::fetch", LOG_DEBUG);
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($resql);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$adherenttypes[$obj->rowid] = $langs->trans($obj->libelle);
$i++;
}
}
}
else
{
print $this->db->error();
}
return $adherenttypes;
}
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->label = $obj->label;
$this->statut = $obj->statut;
$this->subscription = $obj->subscription;
$this->mail_valid = $obj->mail_valid;
$this->note = $obj->note;
$this->vote = $obj->vote;
}
return 1;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
/**
* Return list of members' type
*
* @return array List of types of members
*/
function liste_array()
{
global $conf,$langs;
$adherenttypes = array();
$sql = "SELECT rowid, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE entity IN (".getEntity('adherent').")";
$resql=$this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($resql);
$adherenttypes[$obj->rowid] = $langs->trans($obj->label);
$i++;
}
}
}
else
{
print $this->db->error();
}
return $adherenttypes;
}
/**
* Return array of Member objects for member type this->id (or all if this->id not defined)
*
* @param string $excludefilter Filter to exclude
* @param int $mode 0=Return array of member instance, 1=Return array of members id only
* @return mixed Array of members or -1 on error
*/
function listMembersForMemberType($excludefilter='', $mode=0)
{
global $conf, $user;
$ret=array();
$sql = "SELECT a.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.entity IN (".getEntity('member').")";
$sql.= " AND a.fk_adherent_type = ".$this->id;
if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')';
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
if (! array_key_exists($obj->rowid, $ret))
{
if ($mode != 1)
{
$memberstatic=new Adherent($this->db);
$memberstatic->fetch($obj->rowid);
$ret[$obj->rowid]=$memberstatic;
}
else $ret[$obj->rowid]=$obj->rowid;
}
}
$this->db->free($resql);
$this->members=$ret;
return $ret;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
/**
* Return clicable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $maxlen length max libelle
* @param int $maxlen length max label
* @return string String with URL
*/
function getNomUrl($withpicto=0,$maxlen=0)
@ -291,7 +393,7 @@ class AdherentType extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowTypeCard",$this->libelle);
$label=$langs->trans("ShowTypeCard",$this->label);
$link = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
@ -300,75 +402,159 @@ class AdherentType extends CommonObject
if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
$result.=$link.($maxlen?dol_trunc($this->libelle,$maxlen):$this->libelle).$linkend;
$result.=$link.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend;
return $result;
}
/**
* getLibStatut
*
* @return string Return status of a type of member
*/
function getLibStatut()
{
return '';
}
function getLibStatut()
{
return '';
}
/**
* getMailOnValid
*
* @return string Return mail model
*/
function getMailOnValid()
{
global $conf;
/**
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
*
* @param array $info Info array loaded by _load_ldap_info
* @param int $mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
* 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
* 2=Return key only (uid=qqq)
* @return string DN
*/
function _load_ldap_dn($info,$mode=0)
{
global $conf;
$dn='';
if ($mode==0) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode==1) $dn=$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode==2) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
return $dn;
}
if (! empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid)))
{
return $this->mail_valid;
}
else
{
return $conf->global->ADHERENT_MAIL_VALID;
}
}
/**
* getMailOnSubscription
*
* @return string Return mail model
*/
function getMailOnSubscription()
{
global $conf;
// mail_subscription not defined so never used
if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined
{
return $this->mail_subscription;
}
else
{
return $conf->global->ADHERENT_MAIL_COTIS;
}
}
/**
* Initialize the info array (array of LDAP values) that will be used to call LDAP functions
*
* @return array Tableau info des attributs
*/
function _load_ldap_info()
{
global $conf,$langs;
$info=array();
// Object classes
$info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
// Champs
if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = $this->note;
if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
{
$valueofldapfield=array();
foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database.
{
$member=new Adherent($this->db);
$member->fetch($val->id);
$info2 = $member->_load_ldap_info();
$valueofldapfield[] = $member->_load_ldap_dn($info2);
}
$info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
}
return $info;
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
*/
function initAsSpecimen()
{
global $conf, $user, $langs;
// Initialise parametres
$this->id = 0;
$this->ref = 0;
$this->specimen=1;
$this->label='MEMBERS TYPE SPECIMEN';
$this->note='This is a note';
$this->mail_valid='This is welcome email';
$this->subscription=1;
$this->vote=0;
$this->statut=1;
// Members of this member type is just me
$this->members=array(
$user->id => $user
);
}
/**
* getMailOnValid
*
* @return string Return mail model
*/
function getMailOnValid()
{
global $conf;
if (! empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid)))
{
return $this->mail_valid;
}
else
{
return $conf->global->ADHERENT_MAIL_VALID;
}
}
/**
* getMailOnSubscription
*
* @return string Return mail model
*/
function getMailOnSubscription()
{
global $conf;
// mail_subscription not defined so never used
if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined
{
return $this->mail_subscription;
}
else
{
return $conf->global->ADHERENT_MAIL_COTIS;
}
}
/**
* getMailOnResiliate
*
* @return string Return mail model
*/
function getMailOnResiliate()
{
global $conf;
// NOTE mail_resiliate not defined so never used
if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined
{
return $this->mail_resiliate;
}
else
{
return $conf->global->ADHERENT_MAIL_RESIL;
}
}
/**
* getMailOnResiliate
*
* @return string Return mail model
*/
function getMailOnResiliate()
{
global $conf;
// NOTE mail_resiliate not defined so never used
if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined
{
return $this->mail_resiliate;
}
else
{
return $conf->global->ADHERENT_MAIL_RESIL;
}
}
}

View File

@ -272,7 +272,6 @@ class MembersTypes extends DolibarrApi
$object = parent::_cleanObjectDatas($object);
unset($object->cotisation);
unset($object->libelle);
unset($object->array_options);
unset($object->linkedObjectsIds);

View File

@ -59,7 +59,7 @@ $AdherentsResilies=array();
$AdherentType=array();
// Liste les adherents
$sql = "SELECT t.rowid, t.libelle, t.subscription,";
$sql = "SELECT t.rowid, t.libelle as label, t.subscription,";
$sql.= " d.statut, count(d.rowid) as somme";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d";
@ -81,7 +81,7 @@ if ($result)
$adhtype=new AdherentType($db);
$adhtype->id=$objp->rowid;
$adhtype->subscription=$objp->subscription;
$adhtype->libelle=$objp->libelle;
$adhtype->label=$objp->label;
$AdherentType[$objp->rowid]=$adhtype;
if ($objp->statut == -1) { $MemberToValidate[$objp->rowid]=$objp->somme; }
@ -273,7 +273,7 @@ $max=5;
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql.= " a.tms as datem, datefin as date_end_subscription,";
$sql.= " ta.rowid as typeid, ta.libelle, ta.subscription";
$sql.= " ta.rowid as typeid, ta.libelle as label, ta.subscription";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
$sql.= " WHERE a.entity IN (".getEntity('adherent').")";
$sql.= " AND a.fk_adherent_type = ta.rowid";
@ -310,7 +310,7 @@ if ($resql)
}
$staticmember->ref=$staticmember->getFullName($langs);
$statictype->id=$obj->typeid;
$statictype->libelle=$obj->libelle;
$statictype->label=$obj->label;
print '<td>'.$staticmember->getNomUrl(1,32).'</td>';
print '<td>'.$statictype->getNomUrl(1,32).'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datem),'dayhour').'</td>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2017 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
@ -218,13 +218,11 @@ if ($result > 0)
}
else
{
dol_print_error('',$ldap->error);
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
print '</table>';
llxFooter();
$db->close();

View File

@ -129,7 +129,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -315,7 +315,7 @@ if ($search_type > 0)
{
$membertype=new AdherentType($db);
$result=$membertype->fetch(GETPOST("type",'int'));
$titre.=" (".$membertype->libelle.")";
$titre.=" (".$membertype->label.")";
}
$param='';
@ -698,7 +698,7 @@ while ($i < min($num, $limit))
if (! empty($arrayfields['t.libelle']['checked']))
{
$membertypestatic->id=$obj->type_id;
$membertypestatic->libelle=$obj->type;
$membertypestatic->label=$obj->type;
print '<td class="nowrap">';
print $membertypestatic->getNomUrl(1,32);
print '</td>';

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
@ -37,6 +37,7 @@ $langs->load("members");
$rowid = GETPOST('rowid','int');
$action = GETPOST('action','alpha');
$cancel = GETPOST('cancel','alpha');
$backtopage = GETPOST('backtopage','alpha');
$search_lastname = GETPOST('search_lastname','alpha');
$search_login = GETPOST('search_login','alpha');
@ -64,6 +65,8 @@ $mail_valid=GETPOST("mail_valid");
// Security check
$result=restrictedArea($user,'adherent',$rowid,'adherent_type');
$object = new AdherentType($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
@ -87,73 +90,113 @@ $hookmanager->initHooks(array('membertypecard','globalcard'));
* Actions
*/
if ($cancel) {
$action='';
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
}
if ($action == 'add' && $user->rights->adherent->configurer)
{
if (! $cancel)
$object->label = trim($label);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = trim($mail_valid);
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++;
if (empty($object->label)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), null, 'errors');
}
else {
$sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
}
if ($num) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorLabelAlreadyExists",$login), null, 'errors');
}
}
if (! $error)
{
$object = new AdherentType($db);
$object->label = trim($label);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid);
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++;
if ($object->label)
$id=$object->create($user);
if ($id > 0)
{
$id=$object->create($user);
if ($id > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
$mesg=$object->error;
$action = 'create';
}
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create';
}
}
else
{
$action = 'create';
}
}
if ($action == 'update' && $user->rights->adherent->configurer)
{
if (! $cancel)
$object->fetch($rowid);
$object->oldcopy = clone $object;
$object->label = trim($label);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = trim($mail_valid);
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++;
$ret=$object->update($user);
if ($ret >= 0 && ! count($object->errors))
{
$object = new AdherentType($db);
$object->id = $rowid;
$object->label = trim($label);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid);
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++;
$object->update($user);
header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]);
exit;
setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
exit;
}
if ($action == 'delete' && $user->rights->adherent->configurer)
if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
{
$object = new AdherentType($db);
$object->delete($rowid);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
$object->fetch($rowid);
$res=$object->delete();
if ($res > 0)
{
setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
$action='';
}
}
@ -308,7 +351,15 @@ if ($rowid > 0)
{
$object = new AdherentType($db);
$object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels);
$object->fetch_optionals($object->id,$extralabels);
/*
* Confirmation suppression
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id,$langs->trans("DeleteAMemberType"),$langs->trans("ConfirmDeleteMemberType",$object->label),"confirm_delete", '',0,1);
}
$head = member_type_prepare_head($object);
@ -337,15 +388,14 @@ if ($rowid > 0)
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
print nl2br($object->mail_valid)."</td></tr>";
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '</div>';
dol_fiche_end();
/*
* Buttons
*/
@ -359,7 +409,7 @@ if ($rowid > 0)
}
// Add
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'">'.$langs->trans("AddMember").'</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
// Delete
if ($user->rights->adherent->configurer)
@ -459,7 +509,7 @@ if ($rowid > 0)
$titre.=" (".$membertype->label.")";
}
$param="&rowid=".$rowid;
$param="&rowid=".$object->id;
if (! empty($status)) $param.="&status=".$status;
if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname;
if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname;
@ -473,7 +523,7 @@ if ($rowid > 0)
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input class="flat" type="hidden" name="rowid" value="'.$rowid.'" size="12"></td>';
print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
print '<br>';
print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
@ -593,12 +643,12 @@ if ($rowid > 0)
print '<td align="center">';
if ($user->rights->adherent->creer)
{
print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&return=list.php">'.img_edit().'</a>';
print '<a href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
}
print '&nbsp;';
if ($user->rights->adherent->supprimer)
{
print '<a href="card.php?rowid='.$objp->rowid.'&action=resign&return=list.php">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
}
print "</td>";
@ -631,15 +681,14 @@ if ($rowid > 0)
if ($action == 'edit')
{
$object = new AdherentType($db);
$object->id = $rowid;
$object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels);
$object->fetch_optionals($object->id,$extralabels);
$head = member_type_prepare_head($object);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'">';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="hidden" name="rowid" value="'.$object->id.'">';
print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
@ -706,7 +755,7 @@ if ($rowid > 0)
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'">';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</div>';
print "</form>";

View File

@ -0,0 +1,191 @@
<?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2017 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/>.
*/
/**
* \file htdocs/adherents/type_ldap.php
* \ingroup ldap
* \brief Page fiche LDAP members types
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
$langs->load("members");
$langs->load("admin");
$langs->load("ldap");
$id = GETPOST('rowid', 'int');
$action = GETPOST('action','alpha');
// Security check
$result=restrictedArea($user,'adherent',$id,'adherent_type');
$object = new AdherentType($db);
$object->fetch($id);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membertypeldapcard','globalcard'));
/*
* Actions
*/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if ($action == 'dolibarr2ldap')
{
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result > 0)
{
$object->listMembersForMemberType();
$info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info);
$olddn = $dn; // We can say that old dn = dn as we force synchro
$result = $ldap->update($dn, $info, $user, $olddn);
}
if ($result >= 0) {
setEventMessages($langs->trans("MemberTypeSynchronized"), null, 'mesgs');
}
else {
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
$head = member_type_prepare_head($object);
dol_fiche_head($head, 'ldap', $langs->trans("MemberType"), -1, 'group');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// LDAP DN
print '<tr><td>LDAP '.$langs->trans("LDAPMemberTypeDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_TYPE_DN."</td></tr>\n";
// LDAP Cle
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_MEMBERS_TYPES."</td></tr>\n";
// LDAP Server
print '<tr><td>LDAP '.$langs->trans("Type").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_TYPE."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("Version").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PROTOCOLVERSION."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
print '</table>';
print '</div>';
dol_fiche_end();
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
}
print "</div>\n";
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) print "<br>\n";
// Affichage attributs LDAP
print load_fiche_titre($langs->trans("LDAPInformationsForThisMemberType"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("LDAPAttributes").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '</tr>';
// Lecture LDAP
$ldap=new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info,1);
$search = "(".$object->_load_ldap_dn($info,2).")";
$records = $ldap->getAttribute($dn,$search);
//print_r($records);
// Affichage arbre
if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{
if (! is_array($records))
{
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
}
else
{
$result=show_ldap_content($records,0,$records['count'],true);
}
}
else
{
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
}
$ldap->unbind();
$ldap->close();
}
else
{
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
print '</table>';
llxFooter();
$db->close();

View File

@ -165,6 +165,8 @@ if (! empty($triggers))
if ($module == 'shipping') $module = 'expedition_bon';
if ($module == 'member') $module = 'adherent';
if ($module == 'project') $module = 'projet';
if ($module == 'proposal_supplier') $module = 'supplier_proposal';
//print 'module='.$module.'<br>';
if (! empty($conf->$module->enabled))
{

View File

@ -373,11 +373,12 @@ $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AG
print '</td></tr>'."\n";
// AGENDA_DEFAULT_FILTER_STATUS
// TODO Remove to use the default generic feature
print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'."\n";
$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2);
$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100');
print '</td></tr>'."\n";
// AGENDA_DEFAULT_VIEW

View File

@ -269,12 +269,12 @@ if ($mode != 'focus')
{
if ($mode != 'sortorder')
{
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount')); // Must match list into GETPOST
unset($substitutionarray['__USER_SIGNATURE__']);
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
$texthelp.=$key.' -> '.$val.'<br>';
}
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click
}

View File

@ -137,7 +137,17 @@ if ($action == 'update')
}
}
dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE",GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"),'chaine',0,'',$conf->entity);
// For update value with percentage
$plus='';
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
// Update values
for($i=0;$i<4;$i++) {
if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity);
}
}
@ -196,13 +206,6 @@ if ($action == 'edit')
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . '</td></tr>';
print '</table>';
print '<br>';
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
print '<br>';
print '</form>';
}
else
{
@ -244,21 +247,30 @@ else
print '</table>';
print '<br>';
// Boutons d'action
print '<div class="tabsAction">';
print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';
}
print '<br>';
// Show logo for weather
print $langs->trans("DescWeather").'<br>';
if($action == 'edit') {
$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoPercentageMod'));
$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoStdMod'));
if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
else $str_mode_enabled = $str_mode_percentage;
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
print '<br><br>';
} else {
if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
else print $langs->trans('MeteoPercentageModEnabled');
print '<br><br>';
}
$offset=0;
$cursor=10; // By default
//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
@ -267,36 +279,143 @@ $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level
$level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
$level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
$level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
$text=''; $options='height="60px"';
print '<table>';
print '<tr>';
print '<td>';
print img_weather($text,'weather-clear.png',$options);
print '</td><td>= '.$level0.'</td>';
print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
print '<td>';
print img_weather($text,'weather-few-clouds.png',$options);
print '</td><td>&lt;= '.$level1.'</td>';
print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
print '<td>';
print img_weather($text,'weather-clouds.png',$options);
print '</td><td>&lt;= '.$level2.'</td>';
print '</tr>';
$text=''; $options='class="valignmiddle" height="60px"';
print '<tr><td>';
print img_weather($text,'weather-many-clouds.png',$options);
print '</td><td>&lt;= '.$level3.'</td>';
print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
print '<td>';
print img_weather($text,'weather-storm.png',$options);
print '</td><td>&gt; '.$level3.'</td>';
print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
print '</tr>';
print '</table>';
if ($action == 'edit') {
print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-clear.png', $options);
print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-few-clouds.png',$options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-clouds.png',$options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-many-clouds.png',$options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
print '</div>';
print '</div>';
print '</div>';
print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-clear.png',$options);
print '= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-few-clouds.png',$options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-clouds.png',$options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-many-clouds.png',$options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>';
print '</div>';
print '</div>';
print '</div>';
?>
<script type="text/javascript">
$(document).ready(function() {
$("#change_mode").click(function() {
var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
var str_mode_std = "<?php print $str_mode_std; ?>";
var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
if(use_percent.val() == 1) {
use_percent.val(0);
$("#standard").show();
$("#percentage").hide();
$(this).html(str_mode_std);
} else {
use_percent.val(1);
$("#standard").hide();
$("#percentage").show();
$(this).html(str_mode_percentage);
}
});
});
</script>
<?php
} else {
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-clear.png',$options);
print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-few-clouds.png',$options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-clouds.png',$options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-many-clouds.png',$options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-storm.png',$options);
print '&gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
print '</div>';
print '</div>';
} else {
print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-clear.png',$options);
print '= '.$level0;
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-few-clouds.png',$options);
print '&lt;= '.$level1;
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-clouds.png',$options);
print '&lt;= '.$level2;
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-many-clouds.png',$options);
print '&lt;= '.$level3;
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text,'weather-storm.png',$options);
print '&gt; '.$level3;
print '</div>';
print '</div>';
}
}
print '</div>';
if($action == 'edit') {
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
print '<br></form>';
} else {
// Boutons d'action
print '<br><div class="tabsAction">';
print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a></div>';
}
llxFooter();
$db->close();

View File

@ -620,7 +620,8 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue;
if ($value == 'color' && empty($_POST['color'])) continue;
if ($value == 'formula' && empty($_POST['formula'])) continue;
if ((! isset($_POST[$value]) || $_POST[$value]=='')
if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position'
if ((! isset($_POST[$value]) || $_POST[$value]=='')
&& (! in_array($listfield[$f], array('decalage','module','accountancy_code','accountancy_code_sell','accountancy_code_buy')) // Fields that are not mandatory
&& (! ($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10
)
@ -735,7 +736,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position'
{
$sql.="'".(int) $db->escape($_POST['position'])."'";
}
elseif ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
@ -784,7 +789,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
if ($listfieldvalue[$i] == 'sortorder') // For column name 'sortorder', we use the field name 'position'
{
$sql.="'".(int) $db->escape($_POST['position'])."'";
}
elseif ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
@ -1903,6 +1912,8 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
}
else
{
if ($fieldlist[$field]=='sortorder') $fieldlist[$field]='position';
$classtd=''; $class='';
if ($fieldlist[$field]=='code') $classtd='width100';
if ($fieldlist[$field]=='affect') $class='maxwidth50';

View File

@ -64,4 +64,5 @@ try {
if ($trace[0]['args'][0] == 404) die('Bad ID');
else if ($trace[0]['args'][0] == 401) die('Bad auth key');
else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
}
}

View File

@ -211,11 +211,11 @@ class Dolistore
// add image or default ?
if ($product->id_default_image != '') {
$image_url = DOL_URL_ROOT.'/dolistore/ajax/image.php?id_product='.$product->id.'&id_image='.$product->id_default_image;
$image_url = DOL_URL_ROOT.'/admin/dolistore/ajax/image.php?id_product='.$product->id.'&id_image='.$product->id_default_image;
$images = '<a href="'.$image_url.'" class="fancybox" rel="gallery'.$product->id.'" title="'.$product->name->language[$this->lang].', '.$langs->trans('Version').' '.$product->module_version.'">'.
'<img src="'.$image_url.'&quality=home_default" style="max-height:250px;max-width: 210px;" alt="" /></a>';
} else {
$images = '<img src="'.DOL_URL_ROOT.'/dolistore/img/NoImageAvailable.png" />';
$images = '<img src="'.DOL_URL_ROOT.'/admin/dolistore/img/NoImageAvailable.png" />';
}
// free or pay ?

View File

@ -1,72 +0,0 @@
<html><head><title>CRUD Tutorial - Customer's list</title></head><body>
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
* PrestaShop Webservice Library
* @package PrestaShopWebservice
*/
// Here we define constants /!\ You need to replace this parameters
//https://dolistorecatalogpublickey1234567@vmdevwww.dolistore.com/api/
define('DEBUG', true); // Debug mode
define('PS_SHOP_PATH', 'https://www.dolistore.com/'); // Root path of your PrestaShop store
define('PS_WS_AUTH_KEY', 'dolistorecatalogpublickey1234567'); // Auth key (Get it in your Back Office)
require_once('./PSWebServiceLibrary.php');
// Here we make the WebService Call
try
{
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
// Here we set the option array for the Webservice : we want customers resources
$opt['resource'] = 'categories';
$opt['id'] = '1';
// Call
$xml = $webService->get($opt);
// Here we get the elements from children of customers markup "customer"
$resources = $xml->categories->children();
}
catch (PrestaShopWebserviceException $e)
{
// Here we are dealing with errors
$trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) echo 'Bad ID';
else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';
else echo 'Other error';
}
// We set the Title
echo "<h1>Categories's List</h1>";
echo '<table border="5">';
// if $resources is set we can lists element in it otherwise do nothing cause there's an error
if (isset($resources))
{
echo '<tr><th>Id</th></tr>';
foreach ($resources as $resource)
{
// Iterates on the found IDs
echo '<tr><td>'.$resource->attributes().'</td></tr>';
}
}
echo '</table>';
?>
</body></html>

View File

@ -82,8 +82,8 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK
if ($action == 'update')
{
dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["main_lang_default"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["main_multilangs"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"],'chaine',0,'',$conf->entity);
@ -230,15 +230,15 @@ if ($action == 'edit') // Edit
print '</tr>';
// Default language
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'main_lang_default', 1, 0, 0, 0, 0, 'minwidth300');
print '<tr><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300');
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Multilingual GUI
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1);
print '<tr><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print $form->selectyesno('MAIN_MULTILANGS',$conf->global->MAIN_MULTILANGS,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
@ -349,9 +349,8 @@ if ($action == 'edit') // Edit
print '</tr>';
// Message of the day on home page
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object'));
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'));
complete_substitutions_array($substitutionarray, $langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans('TranslationKey');
print '<tr><td class="titlefield">';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
@ -359,7 +358,7 @@ if ($action == 'edit') // Edit
{
$texthelp.=$key.'<br>';
}
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, '');
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
print '</td><td colspan="2">';
@ -379,16 +378,15 @@ if ($action == 'edit') // Edit
print '</tr>';
// Message on login page
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','user'));
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','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 $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin');
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->Create();

View File

@ -68,6 +68,7 @@ if (empty($reshook))
if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',GETPOST("activesynchro"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',GETPOST("activecontact"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE',GETPOST("activemembers"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE',GETPOST("activememberstypes"),'chaine',0,'',$conf->entity)) $error++;
if (! $error)
{
@ -135,7 +136,6 @@ print '</td></tr>';
// Synchro contact active
if (! empty($conf->societe->enabled))
{
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnContactActive").'</td><td>';
$arraylist=array();
$arraylist['0']=$langs->trans("No");
@ -147,7 +147,6 @@ if (! empty($conf->societe->enabled))
// Synchro member active
if (! empty($conf->adherent->enabled))
{
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberActive").'</td><td>';
$arraylist=array();
$arraylist['0']=$langs->trans("No");
@ -157,6 +156,18 @@ if (! empty($conf->adherent->enabled))
print '</td><td>'.$langs->trans("LDAPDnMemberActiveExample").'</td></tr>';
}
// Synchro member type active
if (! empty($conf->adherent->enabled))
{
print '<tr class="oddeven"><td>'.$langs->trans("LDAPDnMemberTypeActive").'</td><td>';
$arraylist=array();
$arraylist['0']=$langs->trans("No");
$arraylist['1']=$langs->trans("DolibarrToLDAP");
$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
print $form->selectarray('activememberstypes',$arraylist,$conf->global->LDAP_MEMBER_TYPE_ACTIVE);
print '</td><td>'.$langs->trans("LDAPDnMemberTypeActiveExample").'</td></tr>';
}
// Fields from hook
$parameters=array();
$reshook=$hookmanager->executeHooks('addAdminLdapOptions',$parameters); // Note that $action and $object may have been modified by hook

View File

@ -220,8 +220,9 @@ if (function_exists("ldap_connect"))
$dn=$object->_load_ldap_dn($info);
// Get a gid number for objectclass PosixGroup
if(in_array('posixGroup',$info['objectclass']))
$info['gidNumber'] = $ldap->getNextGroupGid();
if (in_array('posixGroup',$info['objectclass'])) {
$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
}
$result1=$ldap->delete($dn); // To be sure to delete existing records
$result2=$ldap->add($dn,$info,$user); // Now the test

View File

@ -0,0 +1,252 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
*
* 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/admin/ldap_members_types.php
* \ingroup ldap
* \brief Page to setup LDAP synchronization for members types
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
$langs->load("admin");
$langs->load("errors");
if (!$user->admin)
accessforbidden();
$action = GETPOST('action','aZ09');
/*
* Actions
*/
if ($action == 'setvalue' && $user->admin)
{
$error=0;
$db->begin();
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN',GETPOST("membertype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME',GETPOST("fieldfullname"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS',GETPOST("fieldmembertypemembers"),'chaine',0,'',$conf->entity)) $error++;
// This one must be after the others
$valkey='';
$key=GETPOST("key");
if ($key) $valkey=$conf->global->$key;
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES',$valkey,'chaine',0,'',$conf->entity)) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
dol_print_error($db);
}
}
/*
* View
*/
llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("LDAPSetup"),$linkback,'title_setup');
$head = ldap_prepare_head();
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
}
dol_fiche_head($head, 'memberstypes', $langs->trans("LDAPSetup"), -1);
print $langs->trans("LDAPDescMembersTypes").'<br>';
print '<br>';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$form=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembersTypes").'</td>';
print "</tr>\n";
// DN pour les types de membres
print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberTypeDn").'</span></td><td>';
print '<input size="48" type="text" name="membertype" value="'.$conf->global->LDAP_MEMBER_TYPE_DN.'">';
print '</td><td>'.$langs->trans("LDAPMemberTypepDnExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// List of object class used to define attributes in structure
print '<tr class="oddeven"><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberTypeObjectClassList").'</span></td><td>';
print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS.'">';
print '</td><td>'.$langs->trans("LDAPMemberTypeObjectClassListExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
print '</table>';
print '<br>';
print '<table class="noborder" width="100%">';
$var=true;
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
// Filtre
// Common name
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldName").'</td><td>';
print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldCommonNameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)?' checked':'')."></td>";
print '</tr>';
// Description
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION.'">';
print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBER_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)?' checked':'')."></td>";
print '</tr>';
// User group
print '<tr class="oddeven"><td>'.$langs->trans("LDAPFieldGroupMembers").'</td><td>';
print '<input size="25" type="text" name="fieldmembertypemembers" value="'.$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS.'">';
print '</td><td>'.$langs->trans("LDAPFieldGroupMembersExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_MEMBERS_TYPES && $conf->global->LDAP_KEY_MEMBERS_TYPES==$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)?' checked':'')."></td>";
print '</tr>';
print '</table>';
print info_admin($langs->trans("LDAPDescValues"));
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
/*
* Test de la connexion
*/
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
{
$butlabel=$langs->trans("LDAPTestSynchroMemberType");
$testlabel='testmembertype';
$key=$conf->global->LDAP_KEY_MEMBERS_TYPES;
$dn=$conf->global->LDAP_MEMBER_TYPE_DN;
$objectclass=$conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS;
show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass);
}
if (function_exists("ldap_connect"))
{
if ($_GET["action"] == 'testmembertype')
{
// Creation objet
$object=new AdherentType($db);
$object->initAsSpecimen();
// Test synchro
$ldap=new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info);
// Get a gid number for objectclass PosixGroup
if (in_array('posixGroup',$info['objectclass'])) {
$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPES');
}
$result1=$ldap->delete($dn); // To be sure to delete existing records
$result2=$ldap->add($dn,$info,$user); // Now the test
$result3=$ldap->delete($dn); // Clean what we did
if ($result2 > 0)
{
print img_picto('','info').' ';
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
}
else
{
print img_picto('','error').' ';
print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
print ': '.$ldap->error;
print '</font><br>';
print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
}
print "<br>\n";
print "LDAP input file used for test:<br><br>\n";
print nl2br($ldap->dump_content($dn,$info));
print "\n<br>";
}
else
{
print img_picto('','error').' ';
print '<font class="error">'.$langs->trans("LDAPSynchroKO");
print ': '.$ldap->error;
print '</font><br>';
print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
}
}
}
llxFooter();
$db->close();

View File

@ -78,6 +78,9 @@ $offset = $listlimit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (empty($sortfield)) $sortfield='label, lang, position';
if (empty($sortorder)) $sortorder='ASC';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('emailtemplates'));
@ -87,7 +90,7 @@ $tabname[25]= MAIN_DB_PREFIX."c_email_templates";
// Criteria to sort dictionaries
$tabsqlsort=array();
$tabsqlsort[25]="label ASC";
$tabsqlsort[25]="label ASC, lang ASC, position ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@ -122,17 +125,30 @@ $formmail=new FormMail($db);
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES))
{
$tmp=FormMail::getAvailableSubstitKey('formemail');
$tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
$tmp['__(AnyTranslationKey)__']='Translation';
$helpsubstit = $langs->trans("AvailableVariables").':<br>';
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
foreach($tmp as $key => $val)
{
$helpsubstit.=$key.' -> '.$val.'<br>';
$helpsubstitforlines.=$key.' -> '.$val.'<br>';
}
}
else
{
$tmp=FormMail::getAvailableSubstitKey('formemailwithlines');
$tmp['__(AnyTranslationKey)__']='__(AnyTranslationKey)__';
$helpsubstit = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
$tmp['__(AnyTranslationKey)__']='Translation';
$helpsubstit = $langs->trans("AvailableVariables").':<br>';
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
foreach($tmp as $key => $val)
{
$helpsubstit.=$key.' -> '.$val.'<br>';
}
$tmp=FormMail::getAvailableSubstitKey('formemailforlines');
$helpsubstitforlines = $langs->trans("AvailableVariables").':<br>'.implode('<br>', $tmp);
foreach($tmp as $key => $val)
{
$helpsubstitforlines.=$key.' -> '.$val.'<br>';
}
}
@ -159,8 +175,9 @@ if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$l
if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder');
if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice');
if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty');
if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember');
if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
$elementList['all']=$langs->trans('VisibleEverywhere');
$elementList['all'] =$langs->trans('VisibleEverywhere');
$elementList['none']=$langs->trans('VisibleNowhere');
@ -217,7 +234,7 @@ if (empty($reshook))
if ($value == 'content') $value='content-'.$rowid;
if ($value == 'content_lines') $value='content_lines-'.$rowid;
if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user')
if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position')
{
$ok=0;
$fieldnamekey=$listfield[$f];
@ -270,16 +287,15 @@ if (empty($reshook))
$i=0;
foreach ($listfieldinsert as $f => $value)
{
//var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
$keycode=$listfieldvalue[$i];
if ($value == 'lang') $keycode='langcode';
//var_dump($i.' - '.$listfieldvalue[$i].' - '.$_POST[$listfieldvalue[$i]].' - '.$value);
if ($value == 'entity') $_POST[$keycode] = $conf->entity;
if ($i) $sql.=",";
if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]='';
if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0';
if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1';
if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = ''
if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work
else $sql.="'".$db->escape($_POST[$keycode])."'";
$i++;
}
@ -469,7 +485,7 @@ if (! $user->admin)
}
if (empty($conf->global->MAIN_MULTILANGS))
{
$sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL)";
$sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL OR lang = '')";
}
if ($search_label) $sql.=natural_search('label', $search_label);
if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_search('type_template', $search_type_template);
@ -520,7 +536,7 @@ foreach ($fieldlist as $field => $value)
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$align="left";
if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner");}
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
if ($fieldlist[$field]=='lang') { $valuetoshow=(empty($conf->global->MAIN_MULTILANGS) ? '&nbsp;' : $langs->trans("Language")); }
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
@ -573,7 +589,7 @@ $errors = $hookmanager->errors;
if (empty($reshook))
{
if ($tabname[$id] == MAIN_DB_PREFIX . 'c_email_templates' && $action == 'edit') {
if ($action == 'edit') {
fieldList($fieldlist, $obj, $tabname[$id], 'hide');
} else {
fieldList($fieldlist, $obj, $tabname[$id], 'add');
@ -681,6 +697,10 @@ if ($resql)
print '</td>';
}
elseif ($value == 'topic') print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
elseif ($value == 'type_template')
{
print '<td class="liste_titre">'.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100onsmartphone').'</td>';
}
elseif (! in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
}
if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
@ -829,6 +849,8 @@ if ($resql)
if ($value == 'private')
{
$align="center";
if ($valuetoshow) $valuetoshow=yn($valuetoshow);
else $valuetoshow='';
}
if ($value == 'position')
{
@ -1032,9 +1054,17 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
print '<td'.($classtd?' class="'.$classtd.'"':'').'>';
if ($fieldlist[$field]=='private' && empty($user->admin))
if ($fieldlist[$field]=='private')
{
print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="1" name="'.$fieldlist[$field].'">';
if (empty($user->admin))
{
print $form->selectyesno($fieldlist[$field], '1', 1);
}
else
{
//print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="1" name="'.$fieldlist[$field].'">';
print $form->selectyesno($fieldlist[$field], (isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
}
}
else
{

View File

@ -254,7 +254,7 @@ if ($action == 'reset' && $user->admin)
$form = new Form($db);
$morejs = array("/admin/dolistore/js/dolistore.js.php");
//$morejs = array("/admin/dolistore/js/dolistore.js.php");
$morecss = array("/admin/dolistore/css/dolistore.css");
// Set dir where external modules are installed

View File

@ -78,23 +78,35 @@ if (preg_match('/del_(.*)/',$action,$reg))
if ($action == 'add_currency')
{
$error=0;
$langs->loadCacheCurrencies('');
$code = GETPOST('code', 'alpha');
$rate = GETPOST('rate', 'alpha');
$rate = price2num(GETPOST('rate', 'alpha'));
$currency = new MultiCurrency($db);
$currency->code = $code;
$currency->name = !empty($langs->cache_currencies[$code]['label']) ? $langs->cache_currencies[$code]['label'].' ('.$langs->getCurrencySymbol($code).')' : $code;
if ($currency->create($user) > 0)
if (empty($rate))
{
if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array());
else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors');
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
$error++;
}
if (! $error)
{
if ($currency->create($user) > 0)
{
if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array());
else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors');
}
else setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors');
}
else setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors');
}
elseif ($action == 'update_currency')
{
$error = 0;
$submit = GETPOST('submit', 'alpha');
if ($submit == $langs->trans('Modify'))
@ -103,9 +115,17 @@ elseif ($action == 'update_currency')
$rate = price2num(GETPOST('rate', 'alpha'));
$currency = new MultiCurrency($db);
if ($currency->fetch($fk_multicurrency) > 0)
if (empty($rate))
{
$currency->updateRate($rate);
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Rate")), null, 'errors');
$error++;
}
if (! $error)
{
if ($currency->fetch($fk_multicurrency) > 0)
{
$currency->updateRate($rate);
}
}
}
elseif ($submit == $langs->trans('Delete'))
@ -279,7 +299,6 @@ if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
print '</form>';
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
@ -325,8 +344,7 @@ print '</td></form></tr>';
foreach ($TCurrency as &$currency)
{
if($currency->code == $conf->currency) continue;
if ($currency->code == $conf->currency) continue;
print '<tr class="oddeven">';
print '<td>'.$currency->code.' - '.$currency->name.'</td>';

View File

@ -45,6 +45,10 @@ if($action)
{
$db->begin();
if ($action == 'STOCK_SUPPORTS_SERVICES')
{
$res = dolibarr_set_const($db, "STOCK_SUPPORTS_SERVICES", GETPOST('STOCK_SUPPORTS_SERVICES','alpha'),'chaine',0,'',$conf->entity);
}
if ($action == 'STOCK_USERSTOCK_AUTOCREATE')
{
$res = dolibarr_set_const($db, "STOCK_USERSTOCK_AUTOCREATE", GETPOST('STOCK_USERSTOCK_AUTOCREATE','alpha'),'chaine',0,'',$conf->entity);
@ -164,8 +168,8 @@ $found=0;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("DeStockOnBill").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("DeStockOnBill").'</td>';
print '<td align="right">';
if (! empty($conf->facture->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
@ -184,8 +188,8 @@ $found++;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("DeStockOnValidateOrder").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("DeStockOnValidateOrder").'</td>';
print '<td align="right">';
if (! empty($conf->commande->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
@ -206,8 +210,8 @@ $found++;
//{
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("DeStockOnShipment").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("DeStockOnShipment").'</td>';
print '<td align="right">';
if (! empty($conf->expedition->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
@ -226,8 +230,8 @@ $found++;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
print '<td align="right">';
if (! empty($conf->expedition->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
@ -268,8 +272,8 @@ $found=0;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("ReStockOnBill").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("ReStockOnBill").'</td>';
print '<td align="right">';
if (! empty($conf->fournisseur->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
@ -289,8 +293,8 @@ $found++;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("ReStockOnValidateOrder").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("ReStockOnValidateOrder").'</td>';
print '<td align="right">';
if (! empty($conf->fournisseur->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
@ -309,8 +313,8 @@ $found++;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("ReStockOnDispatchOrder").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
print '<td align="right">';
if (! empty($conf->fournisseur->enabled))
{
print "<form method=\"post\" action=\"stock.php\">";
@ -346,8 +350,8 @@ print '</tr>'."\n";
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_ALLOW_NEGATIVE_TRANSFER\">";
@ -361,8 +365,8 @@ print "</tr>\n";
if($conf->invoice->enabled) {
$var = !$var;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("StockMustBeEnoughForInvoice").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("StockMustBeEnoughForInvoice").'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_MUST_BE_ENOUGH_FOR_INVOICE\">";
@ -376,8 +380,8 @@ if($conf->invoice->enabled) {
if($conf->order->enabled) {
$var = !$var;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("StockMustBeEnoughForOrder").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("StockMustBeEnoughForOrder").'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_MUST_BE_ENOUGH_FOR_ORDER\">";
@ -391,8 +395,8 @@ if($conf->order->enabled) {
if($conf->expedition->enabled) {
$var = !$var;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("StockMustBeEnoughForShipment").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("StockMustBeEnoughForShipment").'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT\">";
@ -404,6 +408,9 @@ if($conf->expedition->enabled) {
}
print '</table>';
print '<br>';
$virtualdiffersfromphysical=0;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
|| ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
@ -411,7 +418,6 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
if ($virtualdiffersfromphysical)
{
print '<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print " <td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help',$langs->trans("VirtualDiffersFromPhysical"))."</td>\n";
@ -419,8 +425,8 @@ if ($virtualdiffersfromphysical)
print '</tr>'."\n";
$var = !$var;
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("UseVirtualStockByDefault").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("UseVirtualStockByDefault").'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USE_VIRTUAL_STOCK\">";
@ -430,9 +436,70 @@ if ($virtualdiffersfromphysical)
print "</td>\n";
print "</tr>\n";
print '</table>';
print '<br>';
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print " <td>".$langs->trans("Other")."</td>\n";
print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
print '</tr>'."\n";
print '<tr class="oddeven">';
print '<td>'.$langs->trans("UserWarehouseAutoCreate").'</td>';
print '<td class="width100" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK_AUTOCREATE\">";
print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
print '<tr class="oddeven">';
print '<td>';
print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc")).'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_SUPPORTS_SERVICES\">";
print $form->selectyesno("STOCK_SUPPORTS_SERVICES",$conf->global->STOCK_SUPPORTS_SERVICES,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
print '<tr class="oddeven">';
print '<td>'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE\">";
print $form->selectyesno("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE",$conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
print '<tr class="oddeven">';
print '<td>'.$langs->trans("UseDispatchStatus").'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"SUPPLIER_ORDER_USE_DISPATCH_STATUS\">";
print $form->selectyesno("SUPPLIER_ORDER_USE_DISPATCH_STATUS",$conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n";
print "</td>\n</tr>\n";
}
print '</table>';
print '<br>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
@ -484,54 +551,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '</table>';
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print " <td>".$langs->trans("Other")."</td>\n";
print " <td align=\"right\" width=\"160\">&nbsp;</td>\n";
print '</tr>'."\n";
if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("UseDispatchStatus").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"SUPPLIER_ORDER_USE_DISPATCH_STATUS\">";
print $form->selectyesno("SUPPLIER_ORDER_USE_DISPATCH_STATUS",$conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n";
print "</td>\n</tr>\n";
}
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("UserWarehouseAutoCreate").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_USERSTOCK_AUTOCREATE\">";
print $form->selectyesno("STOCK_USERSTOCK_AUTOCREATE",$conf->global->STOCK_USERSTOCK_AUTOCREATE,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE\">";
print $form->selectyesno("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE",$conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print "</td>\n";
print "</tr>\n";
print '<br>';
/* I keep the option/feature, but hidden to end users for the moment. If feature is used by module, no need to have users see it.
If not used by a module, I still need to understand in which case user may need this now we can set rule on product page.
if ($conf->global->PRODUIT_SOUSPRODUITS)
@ -539,9 +558,8 @@ if ($conf->global->PRODUIT_SOUSPRODUITS)
print '<tr class="oddeven">';
print '<td width="60%">'.$langs->trans("IndependantSubProductStock").'</td>';
print '<td width="160" align="right">';
print '<td>'.$langs->trans("IndependantSubProductStock").'</td>';
print '<td align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"INDEPENDANT_SUBPRODUCT_STOCK\">";
@ -553,8 +571,6 @@ if ($conf->global->PRODUIT_SOUSPRODUITS)
}
*/
print '</table>';
llxFooter();

View File

@ -336,7 +336,7 @@ jQuery(document).ready(function() {
var compjsphpstring;
getjsphpurl = $.ajax({
type: "GET",
url: \''.DOL_URL_ROOT.'/core/js/datepicker.js.php\',
url: \''.DOL_URL_ROOT.'/core/js/lib_head.js.php\',
cache: false,
/* async: false, */
/* crossDomain: true,*/

View File

@ -77,6 +77,8 @@ if ($action == 'setproductionmode')
}
}
dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge
/*
* View
@ -128,7 +130,7 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain
// Show message
$message='';
$url=$urlwithroot.'/api/index.php/login?login=<strong>auserlogin</strong>&userpassword=<strong>thepassword</strong>[&reset=1]';
$url=$urlwithroot.'/api/index.php/login?login=<strong>auserlogin</strong>&password=<strong>thepassword</strong>[&reset=1]';
$message.=$langs->trans("UrlToGetKeyToUseAPIs").':<br>';
$message.=img_picto('','object_globe.png').' '.$url;
print $message;

View File

@ -48,7 +48,7 @@ class DolibarrApi
*/
function __construct($db, $cachedir='', $refreshCache=false)
{
global $conf;
global $conf, $dolibarr_main_url_root;
if (empty($cachedir)) $cachedir = $conf->api->dir_temp;
Defaults::$cacheDirectory = $cachedir;
@ -56,7 +56,9 @@ class DolibarrApi
$this->db = $db;
$production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
$this->r = new Restler($production_mode, $refreshCache);
$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
$this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot);
$this->r->setAPIVersion(1);
}

View File

@ -0,0 +1,519 @@
<?php
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2017 Neil Orley <neil.orley@oeris.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/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
/**
* API class for dictionaries
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class Dictionary extends DolibarrApi
{
private $translations = null;
/**
* Constructor
*/
function __construct()
{
global $db;
$this->db = $db;
}
/**
* Get the list of payments types.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number {@min 0}
* @param int $active Payment type is active or not {@min 0} {@max 1}
* @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')"
*
* @url GET payment/types
*
* @return array [List of payment types]
*
* @throws 400 RestException
* @throws 200 OK
*/
function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
$list = array();
$sql = "SELECT id, code, type, libelle as label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t";
$sql.= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(400, $this->db->lasterror());
}
return $list;
}
/**
* Get the list of countries.
*
* The names of the countries will be translated to the given language if
* the $lang parameter is provided. The value of $lang must be a language
* code supported by Dolibarr, for example 'en_US' or 'fr_FR'.
* The returned list is sorted by country ID.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param string $filter To filter the countries by name
* @param string $lang Code of the language the label of the countries must be translated to
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of countries
*
* @url GET countries
*
* @throws RestException
*/
function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '')
{
$list = array();
// Note: The filter is not applied in the SQL request because it must
// be applied to the translated names, not to the names in database.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
$sql.=" WHERE 1 = 1";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$obj = $this->db->fetch_object($result);
$country = new Ccountry($this->db);
if ($country->fetch($obj->rowid) > 0) {
// Translate the name of the country if needed
// and then apply the filter if there is one.
$this->translateLabel($country, $lang);
if (empty($filter) || stripos($country->label, $filter) !== FALSE) {
$list[] = $this->_cleanObjectDatas($country);
}
}
}
} else {
throw new RestException(503, 'Error when retrieving list of countries : '.$country->error);
}
return $list;
}
/**
* Get country by ID.
*
* @param int $id ID of country
* @param string $lang Code of the language the name of the
* country must be translated to
*
* @url GET countries/{id}
*
* @throws RestException
*/
function getCountryByID($id, $lang = '')
{
$country = new Ccountry($this->db);
if ($country->fetch($id) < 0) {
throw new RestException(503, 'Error when retrieving country : '.$country->error);
}
else if ($country->fetch($id) == 0) {
throw new RestException(404, 'country not found');
}
$this->translateLabel($country, $lang);
return $this->_cleanObjectDatas($country);
}
/**
* Clean sensible object datas
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object)
{
$object = parent::_cleanObjectDatas($object);
unset($object->error);
unset($object->errors);
return $object;
}
/**
* Translate the name of the country to the given language.
*
* @param Ccountry $country Country
* @param string $lang Code of the language the name of the
* country must be translated to
*/
private function translateLabel($country, $lang)
{
if (!empty($lang)) {
// Load the translations if this is a new language.
if ($this->translations == null || $this->translations->getDefaultLang() !== $lang) {
global $conf;
$this->translations = new Translate('', $conf);
$this->translations->setDefaultLang($lang);
$this->translations->load('dict');
}
if ($country->code) {
$key = 'Country'.$country->code;
$translation = $this->translations->trans($key);
if ($translation != $key) {
$country->label = html_entity_decode($translation);
}
}
}
}
/**
* Get the list of events types.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param string $type To filter on type of event
* @param string $module To filter on module events
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of events types
*
* @url GET events
*
* @throws RestException
*/
function getListOfEvents($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $sqlfilters = '')
{
$list = array();
$sql = "SELECT id, code, type, libelle as label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
$sql.= " WHERE t.active = 1";
if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(503, 'Error when retrieving list of events types : '.$this->db->lasterror());
}
return $list;
}
/**
* Get the list of extra fields.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...)
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')"
* @return List of events types
*
* @url GET extrafields
*
* @throws RestException
*/
function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '')
{
$list = array();
if ($type == 'thirdparty') $type='societe';
if ($type == 'contact') $type='socpeople';
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t";
$sql.= " WHERE t.entity IN (".getEntity('extrafields').")";
if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
while ($tab = $this->db->fetch_object($resql))
{
// New usage
$list[$tab->elementtype][$tab->name]['type']=$tab->type;
$list[$tab->elementtype][$tab->name]['label']=$tab->label;
$list[$tab->elementtype][$tab->name]['size']=$tab->size;
$list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype;
$list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault;
$list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed;
$list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique;
$list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired;
$list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : '');
$list[$tab->elementtype][$tab->name]['pos']=$tab->pos;
$list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable;
$list[$tab->elementtype][$tab->name]['perms']=$tab->perms;
$list[$tab->elementtype][$tab->name]['list']=$tab->list;
$list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden;
}
}
}
else
{
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
}
if (! count($list))
{
throw new RestException(404, 'No extrafield found');
}
return $list;
}
/**
* Get the list of towns.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param string $zipcode To filter on zipcode
* @param string $town To filter on city name
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of towns
*
* @url GET towns
*
* @throws RestException
*/
function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $sqlfilters = '')
{
$list = array();
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
$sql.= " WHERE t.active = 1";
if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(503, 'Error when retrieving list of towns : '.$this->db->lasterror());
}
return $list;
}
/**
* Get the list of payments terms.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number {@min 0}
* @param int $active Payment term is active or not {@min 0} {@max 1}
* @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')"
*
* @url GET payment/terms
*
* @return array List of payment terms
*
* @throws 400 RestException
* @throws 200 OK
*/
function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
$list = array();
$sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
$sql.= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(400, $this->db->lasterror());
}
return $list;
}
}

View File

@ -1,184 +0,0 @@
<?php
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
* Copyright (C) 2016 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/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
/**
* API class for countries
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class DictionaryCountries extends DolibarrApi
{
private $translations = null;
/**
* Constructor
*/
function __construct()
{
global $db;
$this->db = $db;
}
/**
* Get the list of countries.
*
* The names of the countries will be translated to the given language if
* the $lang parameter is provided. The value of $lang must be a language
* code supported by Dolibarr, for example 'en_US' or 'fr_FR'.
* The returned list is sorted by country ID.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param string $filter To filter the countries by name
* @param string $lang Code of the language the label of the countries must be translated to
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of countries
*
* @throws RestException
*/
function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '')
{
$list = array();
// Note: The filter is not applied in the SQL request because it must
// be applied to the translated names, not to the names in database.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
$sql.=" WHERE 1 = 1";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$obj = $this->db->fetch_object($result);
$country = new Ccountry($this->db);
if ($country->fetch($obj->rowid) > 0) {
// Translate the name of the country if needed
// and then apply the filter if there is one.
$this->translateLabel($country, $lang);
if (empty($filter) || stripos($country->label, $filter) !== FALSE) {
$list[] = $this->_cleanObjectDatas($country);
}
}
}
} else {
throw new RestException(503, 'Error when retrieving list of countries : '.$country->error);
}
return $list;
}
/**
* Get country by ID.
*
* @param int $id ID of country
* @param string $lang Code of the language the name of the
* country must be translated to
*
* @throws RestException
*/
function get($id, $lang = '')
{
$country = new Ccountry($this->db);
if ($country->fetch($id) < 0) {
throw new RestException(503, 'Error when retrieving country : '.$country->error);
}
else if ($country->fetch($id) == 0) {
throw new RestException(404, 'country not found');
}
$this->translateLabel($country, $lang);
return $this->_cleanObjectDatas($country);
}
/**
* Clean sensible object datas
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object)
{
$object = parent::_cleanObjectDatas($object);
unset($object->error);
unset($object->errors);
return $object;
}
/**
* Translate the name of the country to the given language.
*
* @param Ccountry $country Country
* @param string $lang Code of the language the name of the
* country must be translated to
*/
private function translateLabel($country, $lang)
{
if (!empty($lang)) {
// Load the translations if this is a new language.
if ($this->translations == null || $this->translations->getDefaultLang() !== $lang) {
global $conf;
$this->translations = new Translate('', $conf);
$this->translations->setDefaultLang($lang);
$this->translations->load('dict');
}
if ($country->code) {
$key = 'Country'.$country->code;
$translation = $this->translations->trans($key);
if ($translation != $key) {
$country->label = html_entity_decode($translation);
}
}
}
}
}

View File

@ -1,100 +0,0 @@
<?php
/* Copyright (C) 2017 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/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
/**
* API class for events type (content of the actioncomm dictionary)
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class DictionaryEvents extends DolibarrApi
{
/**
* Constructor
*/
function __construct()
{
global $db;
$this->db = $db;
}
/**
* Get the list of events types.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param string $type To filter on type of event
* @param string $module To filter on module events
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of events types
*
* @throws RestException
*/
function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $sqlfilters = '')
{
$list = array();
$sql = "SELECT id, code, type, libelle as label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
$sql.= " WHERE t.active = 1";
if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(503, 'Error when retrieving list of events types : '.$this->db->lasterror());
}
return $list;
}
}

View File

@ -1,112 +0,0 @@
<?php
/* Copyright (C) 2017 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/>.
*/
use Luracast\Restler\RestException;
//require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
/**
* API class for extra fields (content of the extrafields)
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class DictionaryExtraFields extends DolibarrApi
{
/**
* Constructor
*/
function __construct()
{
global $db;
$this->db = $db;
}
/**
* Get the list of extra fields.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...)
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')"
* @return List of events types
*
* @throws RestException
*/
function index($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '')
{
$list = array();
if ($type == 'thirdparty') $type='societe';
if ($type == 'contact') $type='socpeople';
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t";
$sql.= " WHERE t.entity IN (".getEntity('extrafields').")";
if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
while ($tab = $this->db->fetch_object($resql))
{
// New usage
$list[$tab->elementtype][$tab->name]['type']=$tab->type;
$list[$tab->elementtype][$tab->name]['label']=$tab->label;
$list[$tab->elementtype][$tab->name]['size']=$tab->size;
$list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype;
$list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault;
$list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed;
$list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique;
$list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired;
$list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : '');
$list[$tab->elementtype][$tab->name]['pos']=$tab->pos;
$list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable;
$list[$tab->elementtype][$tab->name]['perms']=$tab->perms;
$list[$tab->elementtype][$tab->name]['list']=$tab->list;
$list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden;
}
}
}
else
{
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
}
if (! count($list))
{
throw new RestException(404, 'No extrafield found');
}
return $list;
}
}

View File

@ -1,102 +0,0 @@
<?php
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
* Copyright (C) 2016 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/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
/**
* API class for towns (content of the ziptown dictionary)
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class DictionaryTowns extends DolibarrApi
{
/**
* Constructor
*/
function __construct()
{
global $db;
$this->db = $db;
}
/**
* Get the list of towns.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param string $zipcode To filter on zipcode
* @param string $town To filter on city name
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of towns
*
* @throws RestException
*/
function index($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $sqlfilters = '')
{
$list = array();
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
$sql.= " WHERE t.active = 1";
if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(503, 'Error when retrieving list of towns : '.$this->db->lasterror());
}
return $list;
}
}

View File

@ -22,6 +22,7 @@ use Luracast\Restler\Format\UploadFormat;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
/**
* API class for receive files
@ -54,13 +55,57 @@ class Documents extends DolibarrApi
*
* @param string $module_part Name of module or area concerned by file download ('facture', ...)
* @param string $ref Reference of object (This will define subdir automatically)
* @param string $subdir Subdirectory (Only if ref not provided)
* @param string $subdir NOT YET AVAILABLE : Subdirectory (Only if ref not provided)
* @return array List of documents
*
* @throws RestException
* @throws 400
* @throws 401
* @throws 200 OK
*/
public function index($module_part, $ref='', $subdir='') {
return array('note'=>'FeatureNotYetAvailable');
global $conf;
if (empty($module_part)) {
throw new RestException(400, 'bad value for parameter modulepart');
}
if (empty($ref) && empty($subdir)) {
throw new RestException(400, 'bad value for parameter ref or subdir');
}
if (empty($ref)) {
throw new RestException(404, 'FeatureNotYetAvailable');
}
if (!DolibarrApiAccess::$user->rights->ecm->read) {
throw new RestException(401);
}
$original_file = str_replace("../","/", $ref.'/'.$ref.'.pdf');
$refname=basename(dirname($original_file)."/");
$entity=$conf->entity;
$check_access = dol_check_secure_access_document($module_part,$original_file,$entity,DolibarrApiAccess::$user);
$accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file'];
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
{
throw new RestException(401);
}
if (!$accessallowed) {
throw new RestException(401);
}
$filename = basename($original_file);
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
if (! file_exists($original_file_osencoded))
{
throw new RestException(404, 'File not found');
}
$file_content=file_get_contents($original_file_osencoded);
return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' );
}

View File

@ -397,7 +397,7 @@ if ($action == 'update')
$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
$object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm');
$object->type_id = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm');
$object->label = GETPOST("label");
$object->datep = $datep;
$object->datef = $datef;
@ -407,8 +407,6 @@ if ($action == 'update')
$object->location = GETPOST('location');
$object->socid = GETPOST("socid");
$object->contactid = GETPOST("contactid",'int');
//$object->societe->id = $_POST["socid"]; // deprecated
//$object->contact->id = $_POST["contactid"]; // deprecated
$object->fk_project = GETPOST("projectid",'int');
$object->note = GETPOST("note");
$object->pnote = GETPOST("note");
@ -773,9 +771,9 @@ if ($action == 'create')
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
//For external user force the company to user company
if (!empty($user->societe_id)) {
print $form->select_thirdparty_list($user->societe_id, 'socid', '', 1, 1, 0, $events);
print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events);
} else {
print $form->select_thirdparty_list('', 'socid', '', 'SelectThirdParty', 1, 0, $events);
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events);
}
}
@ -783,7 +781,7 @@ if ($action == 'create')
// Related contact
print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
$form->select_contacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
$form->selectcontacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
print '</td></tr>';
@ -826,7 +824,7 @@ if ($action == 'create')
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('note',(GETPOST('note')?GETPOST('note'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,'90%');
$doleditor=new DolEditor('note',(GETPOST('note','none')?GETPOST('note','none'):$object->note),'',180,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,'90%');
$doleditor->Create();
print '</td></tr>';
@ -869,7 +867,7 @@ if ($id > 0)
$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
$object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm');
$object->type_id = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm');
$object->label = GETPOST("label");
$object->datep = $datep;
$object->datef = $datef;
@ -879,8 +877,6 @@ if ($id > 0)
$object->location = GETPOST('location');
$object->socid = GETPOST("socid");
$object->contactid = GETPOST("contactid",'int');
//$object->societe->id = $_POST["socid"]; // deprecated
//$object->contact->id = $_POST["contactid"]; // deprecated
$object->fk_project = GETPOST("projectid",'int');
$object->note = GETPOST("note");
@ -1206,14 +1202,13 @@ if ($id > 0)
// Link to other agenda views
$out='';
$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
$out.='<br>';
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.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.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
$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.='</li><li class="noborder litext">'.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>';
$linkback.=$out;

View File

@ -754,7 +754,7 @@ class ActionComm extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
$sql.= " SET percent = '".$this->db->escape($this->percentage)."'";
if ($this->fk_action > 0) $sql.= ", fk_action = '".$this->db->escape($this->fk_action)."'";
if ($this->type_id > 0) $sql.= ", fk_action = '".$this->db->escape($this->type_id)."'";
$sql.= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'":"null");
$sql.= ", datep = ".(strval($this->datep)!='' ? "'".$this->db->idate($this->datep)."'" : 'null');
$sql.= ", datep2 = ".(strval($this->datef)!='' ? "'".$this->db->idate($this->datef)."'" : 'null');
@ -851,7 +851,8 @@ class ActionComm extends CommonObject
}
/**
* Load all objects with filters
* Load all objects with filters.
* WARNING: This make a fetch on all records instead of making one request with a join.
*
* @param DoliDb $db Database handler
* @param int $socid Filter by thirdparty
@ -906,59 +907,66 @@ class ActionComm extends CommonObject
return $db->lasterror();
}
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
* @param User $user Objet user
* @param int $load_state_board Charge indicateurs this->nb de tableau de bord
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
function load_board($user)
function load_board($user, $load_state_board=0)
{
global $conf, $langs;
$sql = "SELECT a.id, a.datep as dp";
$sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a";
$sql.= ")";
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql.= " WHERE a.percent >= 0 AND a.percent < 100";
$sql.= " AND a.entity IN (".getEntity('agenda').")";
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
$resql=$this->db->query($sql);
if ($resql)
{
$agenda_static = new ActionComm($this->db);
$response = new WorkboardResponse();
$response->warning_delay = $conf->agenda->warning_delay/60/60/24;
$response->label = $langs->trans("ActionsToDo");
$response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&amp;mainmenu=agenda';
if ($user->rights->agenda->allactions->read) $response->url.='&amp;filtert=-1';
$response->img = img_object('',"action",'class="inline-block valigntextmiddle"');
// This assignment in condition is not a bug. It allows walking the results.
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
$agenda_static->datep = $this->db->jdate($obj->dp);
if ($agenda_static->hasDelay()) {
$response->nbtodolate++;
}
}
return $response;
}
else
{
$this->error=$this->db->error();
return -1;
}
global $conf, $langs;
if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp";
else {
$this->nb=array();
$sql = "SELECT count(a.id) as nb";
}
$sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a";
$sql.= ")";
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql.= " WHERE 1";
if(empty($load_state_board)) $sql.= " AND a.percent >= 0 AND a.percent < 100";
$sql.= " AND a.entity IN (".getEntity('agenda').")";
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
$resql=$this->db->query($sql);
if ($resql)
{
if(empty($load_state_board)) {
$agenda_static = new ActionComm($this->db);
$response = new WorkboardResponse();
$response->warning_delay = $conf->agenda->warning_delay/60/60/24;
$response->label = $langs->trans("ActionsToDo");
$response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&amp;mainmenu=agenda';
if ($user->rights->agenda->allactions->read) $response->url.='&amp;filtert=-1';
$response->img = img_object('',"action",'class="inline-block valigntextmiddle"');
}
// This assignment in condition is not a bug. It allows walking the results.
while ($obj=$this->db->fetch_object($resql))
{
if(empty($load_state_board)) {
$response->nbtodo++;
$agenda_static->datep = $this->db->jdate($obj->dp);
if ($agenda_static->hasDelay()) $response->nbtodolate++;
} else $this->nb["actionscomm"]=$obj->nb;
}
$this->db->free($resql);
if(empty($load_state_board)) return $response;
else return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}

View File

@ -128,14 +128,13 @@ if ($object->id > 0)
// Link to other agenda views
$out='';
$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
$out.='<br>';
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.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.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.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.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.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>';
$linkback.=$out;

View File

@ -51,6 +51,8 @@ $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|
* View
*/
$form=new Form($db);
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url);
@ -66,14 +68,13 @@ $linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php">'.$langs->trans("B
// Link to other agenda views
$out='';
$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
$out.='<br>';
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.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.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.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.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
$out.='</li><li class="noborder litext">'.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>';
$linkback.=$out;

View File

@ -45,13 +45,13 @@ if (! empty($conf->categorie->enabled)) {
if (! $user->rights->mailing->lire || $user->societe_id > 0)
accessforbidden();
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if ($page == - 1) {
$page = 0;
}
$offset = $conf->liste_limit * $page;
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder)

View File

@ -57,24 +57,17 @@ $hookmanager->initHooks(array('mailingcard','globalcard'));
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$object->substitutionarray=FormMail::getAvailableSubstitKey('emailing');
$object->substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$object->substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord',
//'__EMAIL__' => 'TESTEMail', // Done into "send" action
'__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname',
'__MAILTOEMAIL__' => 'TESTMailtoEmail',
'__OTHER1__' => 'TESTOther1',
'__OTHER2__' => 'TESTOther2',
'__OTHER3__' => 'TESTOther3',
'__OTHER4__' => 'TESTOther4',
'__OTHER5__' => 'TESTOther5',
'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''),
'__CHECK_READ__' => 'TagCheckMail',
'__UNSUBSCRIBE__' => 'TagUnsubscribe'
//,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet
);
// Set $object->substitutionarrayfortest
$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
$targetobject = null; // Not defined with mass emailing
$parameters=array('mode'=>'emailing');
$substitutionarray=FormMail::getAvailableSubstitKey('emailing', $targetobject);
$object->substitutionarrayfortest = $substitutionarray;
// List of sending methods
$listofmethods=array();
@ -205,24 +198,28 @@ if (empty($reshook))
$tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]);
$signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'');
// Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions)
$substitutionarray=array(
'__ID__' => $obj->source_id,
'__EMAIL__' => $obj->email,
'__LASTNAME__' => $obj->lastname,
'__FIRSTNAME__' => $obj->firstname,
'__MAILTOEMAIL__' => '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>',
'__OTHER1__' => $other1,
'__OTHER2__' => $other2,
'__OTHER3__' => $other3,
'__OTHER4__' => $other4,
'__OTHER5__' => $other5,
'__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter)
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'
);
$targetobject = null; // Not defined with mass emailing
$parameters=array('mode'=>'emailing');
$substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$substitutionarray['__ID__'] = $obj->source_id;
$substitutionarray['__EMAIL__'] = $obj->email;
$substitutionarray['__LASTNAME__'] = $obj->lastname;
$substitutionarray['__FIRSTNAME__'] = $obj->firstname;
$substitutionarray['__MAILTOEMAIL__'] = '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>';
$substitutionarray['__OTHER1__'] = $other1;
$substitutionarray['__OTHER2__'] = $other2;
$substitutionarray['__OTHER3__'] = $other3;
$substitutionarray['__OTHER4__'] = $other4;
$substitutionarray['__OTHER5__'] = $other5;
$substitutionarray['__SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
$onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
@ -230,18 +227,20 @@ if (empty($reshook))
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
$substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
{
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
}
else
{
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
$substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
$substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
}
/* For backward compatibility */
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
@ -261,6 +260,7 @@ if (empty($reshook))
else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
//$substitutionisok=true;
complete_substitutions_array($substitutionarray, $langs);
$newsubject=make_substitutions($subject,$substitutionarray);
$newmessage=make_substitutions($message,$substitutionarray);
@ -431,9 +431,12 @@ if (empty($reshook))
$msgishtml=-1; // Inconnu par defaut
if (preg_match('/[\s\t]*<html>/i',$object->body)) $msgishtml=1;
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; // other are set at begin of page
// other are set at begin of page
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto;
$object->substitutionarrayfortest['__MAILTOEMAIL__'] = '<a href="mailto:'.$object->sendto.'">'.$object->sendto.'</a>';
// Pratique les substitutions sur le sujet et message
complete_substitutions_array($object->substitutionarrayfortest, $langs);
$tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest);
$tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest);
@ -1073,7 +1076,7 @@ else
$formmail->substit=$object->substitutionarrayfortest;
// Tableau des parametres complementaires du post
$formmail->param["action"]="send";
$formmail->param["models"]="body";
$formmail->param["models"]='none';
$formmail->param["mailid"]=$object->id;
$formmail->param["returnurl"]=$_SERVER['PHP_SELF']."?id=".$object->id;
@ -1224,7 +1227,6 @@ else
// Print mail content
print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic');
dol_fiche_head(null, '', '', -1);
print '<table class="border" width="100%">';

View File

@ -125,7 +125,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
if ($cancel) $action = '';
if ($cancel)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
$action='';
}
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
@ -350,8 +358,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public','none');
$object->statut = Propal::STATUS_DRAFT;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -378,8 +386,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public','none');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
@ -638,16 +646,10 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
/*
* Send mail
*/
// Actions to send emails
$actiontypecode='AC_OTH_AUTO';
$trigger_name='PROPAL_SENTBYMAIL';
$paramname='id';
$mode='emailfromproposal';
$autocopy='MAIN_MAIL_AUTOCOPY_PROPOSAL_TO';
$trackid='pro'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
@ -977,7 +979,7 @@ if (empty($reshook))
$info_bits |= 0x01;
// Clean parameters
$description = dol_htmlcleanlastbr(GETPOST('product_desc'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc','none'));
// Define vat_rate
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
@ -1528,13 +1530,7 @@ if ($action == 'create')
}
// Other attributes
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
print $object->showOptionals($extrafields, 'edit');
}
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
// Lines from source
if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
@ -2361,123 +2357,13 @@ if ($action == 'create')
print '</div></div></div>';
}
/*
* Action presend
*/
if ($action == 'presend')
{
$object->fetch_projet();
// Presend form
$modelmail='propal_send';
$defaulttopic='SendPropalRef';
$diroutput = $conf->propal->dir_output;
$trackid = 'pro'.$object->id;
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('commercial');
}
// Build document if it not exists
if (! $file || ! is_readable($file)) {
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
dol_print_error($db, $object->error, $object->errors);
exit();
}
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>';
print '<br>';
print load_fiche_titre($langs->trans('SendPropalByMail'));
dol_fiche_head('');
// Create form object
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
$formmail->trackid='pro'.$object->id;
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'pro'.$object->id);
}
$formmail->withfrom = 1;
$liste = array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
$liste [$key] = $value;
$formmail->withto = GETPOST("sendto") ? GETPOST("sendto") : $liste;
$formmail->withtocc = $liste;
$formmail->withtoccc = (! empty($conf->global->MAIN_EMAIL_USECCC) ? $conf->global->MAIN_EMAIL_USECCC : false);
if (empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__');
} else if (! empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendPropalRef', '__PROPREF__ (__REFCLIENT__)');
}
$formmail->withfile = 2;
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
// Tableau des substitutions
$formmail->setSubstitFromObject($object);
$formmail->substit['__PROPREF__'] = $object->ref; // For backward compatibility
// Find the good contact adress
$custcontact = '';
$contactarr = array();
$contactarr = $object->liste_contact(- 1, 'external');
if (is_array($contactarr) && count($contactarr) > 0) {
foreach ($contactarr as $contact) {
if ($contact ['libelle'] == $langs->trans('TypeContact_propal_external_CUSTOMER')) { // TODO Use code and not label
$contactstatic = new Contact($db);
$contactstatic->fetch($contact ['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
}
}
if (! empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
}
}
// Tableau des parametres complementaires
$formmail->param['action'] = 'send';
$formmail->param['models'] = 'propal_send';
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['id'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
if (GETPOST("mode") == 'init') {
$formmail->clear_attached_files();
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
}
print $formmail->get_form();
dol_fiche_end();
}
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
// End of page

View File

@ -1404,7 +1404,7 @@ class Propal extends CommonObject
{
$this->lines=array();
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
$sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,';
$sql.= ' d.fk_unit,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
@ -1443,6 +1443,8 @@ class Propal extends CommonObject
$line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx;
$line->localtax1_type = $objp->localtax1_type;
$line->localtax2_type = $objp->localtax2_type;
$line->subprice = $objp->subprice;
$line->fk_remise_except = $objp->fk_remise_except;
$line->remise_percent = $objp->remise_percent;
@ -3366,8 +3368,8 @@ class Propal extends CommonObject
$this->lines = array();
$sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,';
$sql.= ' pt.qty, pt.vat_src_code, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,';
$sql.= ' pt.qty, pt.vat_src_code, pt.tva_tx, pt.localtax1_tx, pt.localtax2_tx, pt.localtax1_type, pt.localtax2_type, pt.remise_percent, pt.subprice, pt.info_bits,';
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.total_localtax1, pt.total_localtax2, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code,';
$sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,';
$sql.= ' pt.fk_unit,';
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.description as product_desc, p.tobatch as product_tobatch,';
@ -3411,11 +3413,17 @@ class Propal extends CommonObject
$this->lines[$i]->vat_src_code = $obj->vat_src_code;
$this->lines[$i]->tva_tx = $obj->tva_tx;
$this->lines[$i]->localtax1_tx = $obj->localtax1_tx;
$this->lines[$i]->localtax2_tx = $obj->localtax2_tx;
$this->lines[$i]->localtax1_type = $obj->localtax1_type;
$this->lines[$i]->localtax2_type = $obj->localtax2_type;
$this->lines[$i]->info_bits = $obj->info_bits;
$this->lines[$i]->total_ht = $obj->total_ht;
$this->lines[$i]->total_tva = $obj->total_tva;
$this->lines[$i]->total_ttc = $obj->total_ttc;
$this->lines[$i]->fk_fournprice = $obj->fk_fournprice;
$this->lines[$i]->total_localtax1 = $obj->total_localtax1;
$this->lines[$i]->total_localtax2 = $obj->total_localtax2;
$this->lines[$i]->fk_fournprice = $obj->fk_fournprice;
$marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht);
$this->lines[$i]->pa_ht = $marginInfos[0];
$this->lines[$i]->marge_tx = $marginInfos[1];

View File

@ -96,8 +96,8 @@ $pagenext = $page + 1;
if (! $sortfield) $sortfield='p.ref';
if (! $sortorder) $sortorder='DESC';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$contextpage='proposallist';
// Initialize technical object to manage context to save list fields
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'proposallist';
// Security check
$module='propal';
@ -158,7 +158,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -413,6 +413,7 @@ if ($resql)
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);

View File

@ -125,7 +125,7 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
if ($res > 0 && $newid1 > 0 && $newid2 > 0)
{
$db->commit();
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage?'&backtopage='.urlencode($backtopage):'')); // To avoid pb whith back
exit;
}
else
@ -275,13 +275,13 @@ if ($socid > 0)
print '</table>';
print '</div>';
if ($user->rights->societe->creer)
{
print '<br>';
print load_fiche_titre($langs->trans("NewGlobalDiscount"),'','');
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("AmountHT").'</td>';
@ -292,8 +292,8 @@ if ($socid > 0)
print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object);
print '</td></tr>';
print '<tr><td class="fieldrequired" >'.$langs->trans("NoteReason").'</td>';
print '<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST('desc').'"></td></tr>';
print '<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST('desc','none').'"></td></tr>';
print "</table>";
}
@ -362,7 +362,7 @@ if ($socid > 0)
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
@ -408,14 +408,14 @@ if ($socid > 0)
if ($user->rights->societe->creer || $user->rights->facture->creer)
{
print '<td class="nowrap">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=split&amp;remid='.$obj->rowid.'">'.img_split($langs->trans("SplitDiscount")).'</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=split&remid='.$obj->rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_split($langs->trans("SplitDiscount")).'</a>';
print ' &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=remove&amp;remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&remid='.$obj->rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
print '</td>';
}
else print '<td>&nbsp;</td>';
print '</tr>';
if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid)
{
$showconfirminfo['rowid']=$obj->rowid;
@ -427,7 +427,7 @@ if ($socid > 0)
else
{
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
}
$db->free($resql);
print "</table>";
@ -441,7 +441,7 @@ if ($socid > 0)
array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5')
);
$langs->load("dict");
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'], $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($showconfirminfo['amount_ttc']),$langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0);
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage?'&backtopage='.urlencode($backtopage):''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($showconfirminfo['amount_ttc']),$langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0);
}
}
else
@ -590,7 +590,7 @@ if ($socid > 0)
{
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "</table>";
}
else

View File

@ -118,16 +118,11 @@ if (empty($reshook))
{
if ($cancel)
{
if ($action != 'addlink' && $action != 'updateline')
if (! empty($backtopage))
{
$urltogo=$backtopage?$backtopage:dol_buildpath('/commande/list.php',1);
header("Location: ".$urltogo);
header("Location: ".$backtopage);
exit;
}
if ($id > 0 || ! empty($ref)) {
$ret = $object->fetch($id,$ref);
$object->fetch_thirdparty();
}
$action='';
}
@ -261,8 +256,8 @@ if (empty($reshook))
$db->begin();
$object->date_commande = $datecommande;
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public','none');
$object->source = GETPOST('source_id');
$object->fk_project = GETPOST('projectid');
$object->ref_client = GETPOST('ref_client');
@ -932,7 +927,7 @@ if (empty($reshook))
$date_end='';
$date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description=dol_htmlcleanlastbr(GETPOST('product_desc'));
$description=dol_htmlcleanlastbr(GETPOST('product_desc','none'));
$pu_ht=GETPOST('price_ht');
$vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0);
$pu_ht_devise = GETPOST('multicurrency_subprice');
@ -1215,11 +1210,6 @@ if (empty($reshook))
}
}
// Actions to build doc
$upload_dir = $conf->commande->dir_output;
$permissioncreate = $user->rights->commande->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($action == 'update_extras')
{
// Fill array 'array_options' with data from update form
@ -1256,13 +1246,18 @@ if (empty($reshook))
exit();
}
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to build doc
$upload_dir = $conf->commande->dir_output;
$permissioncreate = $user->rights->commande->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$trigger_name='ORDER_SENTBYMAIL';
$paramname='id';
$mode='emailfromorder';
$autocopy='MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add
$trackid='ord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
@ -2497,7 +2492,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! empty($conf->expedition->enabled)) {
$numshipping = $object->nb_expedition();
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfProductsLines() > 0) {
if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) {
if ($user->rights->expedition->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/expedition/shipment.php?id=' . $object->id . '">' . $langs->trans('CreateShipment') . '</a></div>';
@ -2596,134 +2591,13 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</div></div></div>';
}
/*
* Action presend
*/
if ($action == 'presend')
{
$object->fetch_projet();
// Presend form
$modelmail='order_send';
$defaulttopic='SendOrderRef';
$diroutput = $conf->commande->dir_output;
$trackid = 'ord'.$object->id;
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('commercial');
}
// Show email form
// By default if $action=='presend'
$titreform='SendOrderByMail';
$topicmail='';
if (empty($object->ref_client)) {
$topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__');
} else if (! empty($object->ref_client)) {
$topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)');
}
$action='send';
$modelmail='order_send';
// Build document if it not exists
if (! $file || ! is_readable($file)) {
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
dol_print_error($db, $object->error, $object->errors);
exit();
}
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>';
print '<br>';
print load_fiche_titre($langs->trans($titreform));
dol_fiche_head('');
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
$formmail->trackid='ord'.$object->id;
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id);
}
$formmail->withfrom = 1;
$liste = array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
$liste [$key] = $value;
$formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
$formmail->withtocc = $liste;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic = $topicmail;
$formmail->withfile = 2;
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
// Tableau des substitutions
$formmail->setSubstitFromObject($object);
$formmail->substit ['__ORDERREF__'] = $object->ref;
$custcontact = '';
$contactarr = array();
$contactarr = $object->liste_contact(- 1, 'external');
if (is_array($contactarr) && count($contactarr) > 0)
{
foreach ($contactarr as $contact)
{
if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { // TODO Use code and not label
$contactstatic = new Contact($db);
$contactstatic->fetch($contact ['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
}
}
if (! empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
}
}
// Tableau des parametres complementaires
$formmail->param['action'] = $action;
$formmail->param['models'] = $modelmail;
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['orderid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
if (GETPOST("mode") == 'init') {
$formmail->clear_attached_files();
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
}
// Show form
print $formmail->get_form();
dol_fiche_end();
}
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
}

View File

@ -42,6 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$langs->loadLangs(array("orders",'sendings','deliveries','companies','compta','bills'));
@ -82,6 +83,7 @@ $result = restrictedArea($user, 'commande', $id,'');
$diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id;
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@ -118,7 +120,8 @@ $checkedtypetiers=0;
$arrayfields=array(
'c.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'c.ref_client'=>array('label'=>$langs->trans("RefCustomerOrder"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
@ -139,7 +142,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -186,6 +189,7 @@ if (empty($reshook))
$search_deliveryday='';
$search_deliverymonth='';
$search_deliveryyear='';
$search_project_ref='';
$viewstatut='';
$billed='';
$toselect='';
@ -203,7 +207,8 @@ if (empty($reshook))
$permtoread = $user->rights->commande->lire;
$permtodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
$trigger_name='ORDER_SENTBYMAIL';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// TODO Move this into mass action include
if ($massaction == 'confirm_createbills') {
@ -438,6 +443,7 @@ $formother = new FormOther($db);
$formfile = new FormFile($db);
$companystatic = new Societe($db);
$formcompany=new FormCompany($db);
$projectstatic=new Project($db);
$title=$langs->trans("Orders");
$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
@ -450,7 +456,8 @@ $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,';
$sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,';
$sql.= ' c.date_creation as date_creation, c.tms as date_update';
$sql.= ' c.date_creation as date_creation, c.tms as date_update,';
$sql.= " p.rowid as project_id, p.ref as project_ref";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@ -465,6 +472,7 @@ $sql.= ', '.MAIN_DB_PREFIX.'commande as c';
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)";
if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande';
if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet";
// We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($search_user > 0)
@ -539,6 +547,7 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user;
if ($search_total_ht != '') $sql.= natural_search('c.total_ht', $search_total_ht, 1);
if ($search_project_ref != '') $sql.= natural_search("p.ref",$search_project_ref);
// Add where from extra fields
foreach ($search_array_options as $key => $val)
{
@ -626,7 +635,8 @@ if ($resql)
if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht;
if ($search_total_vat != '') $param.='&search_total_vat='.$search_total_vat;
if ($search_total_ttc != '') $param.='&search_total_ttc='.$search_total_ttc;
if ($show_files) $param.='&show_files=' .$show_files;
if ($search_project_ref >= 0) $param.="&search_project_ref=".$search_project_ref;
if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($billed != '') $param.='&billed='.$billed;
// Add $param from extra fields
@ -670,6 +680,7 @@ if ($resql)
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php';
}
if ($massaction == 'createbills')
{
//var_dump($_REQUEST);
@ -787,6 +798,11 @@ if ($resql)
print '<input class="flat" type="text" size="6" name="search_ref_customer" value="'.$search_ref_customer.'">';
print '</td>';
}
// Project ref
if (! empty($arrayfields['p.project_ref']['checked']))
{
print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'"></td>';
}
// Thirpdarty
if (! empty($arrayfields['s.nom']['checked']))
{
@ -930,6 +946,7 @@ if ($resql)
print '<tr class="liste_titre">';
if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'],$_SERVER["PHP_SELF"],'c.ref','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'],$_SERVER["PHP_SELF"],'c.ref_client','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],'s.nom','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
@ -979,27 +996,35 @@ if ($resql)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
$notshippable=0;
$warning = 0;
$text_info='';
$text_warning='';
$nbprod=0;
$companystatic->id=$obj->socid;
$companystatic->code_client = $obj->code_client;
$companystatic->name=$obj->name;
$companystatic->client=$obj->client;
$companystatic->email=$obj->email;
$generic_commande->id=$obj->rowid;
$generic_commande->ref=$obj->ref;
$generic_commande->statut = $obj->fk_statut;
$generic_commande->date_commande = $db->jdate($obj->date_commande);
$generic_commande->date_livraison = $db->jdate($obj->date_delivery);
$generic_commande->ref_client = $obj->ref_client;
$generic_commande->total_ht = $obj->total_ht;
$generic_commande->total_tva = $obj->total_tva;
$generic_commande->total_ttc = $obj->total_ttc;
print '<tr class="oddeven">';
// Ref
if (! empty($arrayfields['c.ref']['checked']))
{
print '<td class="nowrap">';
$generic_commande->id=$obj->rowid;
$generic_commande->ref=$obj->ref;
$generic_commande->statut = $obj->fk_statut;
$generic_commande->date_commande = $db->jdate($obj->date_commande);
$generic_commande->date_livraison = $db->jdate($obj->date_delivery);
$generic_commande->ref_client = $obj->ref_client;
$generic_commande->total_ht = $obj->total_ht;
$generic_commande->total_tva = $obj->total_tva;
$generic_commande->total_ttc = $obj->total_ttc;
$generic_commande->lines=array();
$generic_commande->getLinesArray();
@ -1144,11 +1169,16 @@ if ($resql)
if (! $i) $totalarray['nbfield']++;
}
$companystatic->id=$obj->socid;
$companystatic->code_client = $obj->code_client;
$companystatic->name=$obj->name;
$companystatic->client=$obj->client;
$companystatic->email=$obj->email;
// Project
if (! empty($arrayfields['p.project_ref']['checked']))
{
$projectstatic->id=$obj->project_id;
$projectstatic->ref=$obj->project_ref;
print '<td>';
if ($obj->project_id > 0) print $projectstatic->getNomUrl(1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Third party
if (! empty($arrayfields['s.nom']['checked']))

View File

@ -104,9 +104,9 @@ if (! $sortfield) $sortfield='b.datev, b.dateo, b.rowid';
$mode_balance_ok=false;
//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected
if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid'))
if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid'))
{
$sortfield = 'b.datev, b.dateo, b.rowid';
$sortfield = 'b.datev,b.dateo,b.rowid';
if ($id > 0 || ! empty($ref) || $account > 0) $mode_balance_ok = true;
}
if (strtolower($sortorder) == 'desc') $mode_balance_ok = false;
@ -151,7 +151,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -743,7 +743,7 @@ if ($resql)
// Title
$bankcateg=new BankCateg($db);
$morehtml='<div data-role="fieldcontain">';
$morehtml='<div>';
$morehtml.= '<label for="pageplusone">'.$langs->trans("Page")."</label> "; // ' Page ';
$morehtml.='<input type="text" name="pageplusone" id="pageplusone" size="1" class="flat" value="'.($page+1).'">';
$morehtml.='/'.$nbtotalofpages.' ';
@ -887,7 +887,7 @@ if ($resql)
if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'],$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev, b.dateo, b.rowid','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev,b.dateo,b.rowid','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'],$_SERVER['PHP_SELF'],'b.num_chq','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'],$_SERVER['PHP_SELF'],'bu.label','',$param,'',$sortfield,$sortorder);
@ -1065,7 +1065,7 @@ if ($resql)
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref;
print ' ('.$langs->trans("TransferFrom").' ';
print $bankstatic->getNomUrl(1,'transactions');
print $bankstatic->getNomUrl(1);
print ' '.$langs->trans("toward").' ';
$bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref;
@ -1082,7 +1082,7 @@ if ($resql)
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref;
print $bankstatic->getNomUrl(1,'transactions');
print $bankstatic->getNomUrl(1);
print ')';
}
//var_dump($links);

View File

@ -145,7 +145,7 @@ if ($action == 'add')
if ($id > 0)
{
// Category association
$categories = GETPOST('categories');
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
$_GET["id"]=$id; // Force chargement page en mode visu
@ -239,7 +239,7 @@ if ($action == 'update')
if ($result >= 0)
{
// Category association
$categories = GETPOST('categories');
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu

View File

@ -925,7 +925,8 @@ class Account extends CommonObject
}
else
{
dol_print_error($this->db);
$this->error=$this->db->lasterror;
$this->errors[]=$this->error;
return -1;
}
}
@ -1150,7 +1151,7 @@ class Account extends CommonObject
return $solde;
}
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@ -1160,50 +1161,88 @@ class Account extends CommonObject
*/
function load_board(User $user, $filteraccountid = 0)
{
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
$sql = "SELECT b.rowid, b.datev as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.rappro=0";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
$sql.= " AND clos = 0";
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
$resql=$this->db->query($sql);
if ($resql)
{
$langs->load("banks");
$now=dol_now();
require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
$response = new WorkboardResponse();
$response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
$response->label=$langs->trans("TransactionsToConciliate");
$response->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&amp;mainmenu=bank';
$response->img=img_object('',"payment");
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
$response->nbtodolate++;
}
}
return $response;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
$sql = "SELECT b.rowid, b.datev as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.rappro=0";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
$sql.= " AND clos = 0";
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
$resql=$this->db->query($sql);
if ($resql)
{
$langs->load("banks");
$now=dol_now();
require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
$response = new WorkboardResponse();
$response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
$response->label=$langs->trans("TransactionsToConciliate");
$response->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&amp;mainmenu=bank';
$response->img=img_object('',"payment");
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
$response->nbtodolate++;
}
}
return $response;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/**
* Charge indicateurs this->nb de tableau de bord
* @param int $filteraccountid To get info for a particular account id
* @return int <0 if ko, >0 if ok
*/
function load_state_board($filteraccountid = 0)
{
global $user;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
$sql = "SELECT count(b.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
$sql.= " AND clos = 0";
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["banklines"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
@ -1255,6 +1294,7 @@ class Account extends CommonObject
$label = '<u>' . $langs->trans("ShowAccount") . '</u>';
$label .= '<br><b>' . $langs->trans('BankAccount') . ':</b> ' . $this->label;
$label .= '<br><b>' . $langs->trans('AccountNumber') . ':</b> ' . $this->number;
$label .= '<br><b>' . $langs->trans("AccountCurrency") . ':</b> ' . $this->currency_code;
if (! empty($conf->accounting->enabled))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';

View File

@ -46,7 +46,7 @@ $toselect = GETPOST('toselect', 'array');
$search_ref=GETPOST('search_ref','alpha');
$search_label=GETPOST('search_label','alpha');
$search_number=GETPOST('search_number','alpha');
$statut=GETPOST('statut')?GETPOST('statut', 'alpha'):'opened'; // 'all' or ''='opened'
$search_status=GETPOST('search_status')?GETPOST('search_status', 'alpha'):'opened'; // 'all' or ''='opened'
$optioncss = GETPOST('optioncss','alpha');
// Security check
@ -92,7 +92,8 @@ $arrayfields=array(
'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled),
'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled),
'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1),
'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0),
'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010),
@ -102,7 +103,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -121,13 +122,12 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$statut = 'all';
$search_ref='';
$search_label='';
$search_number='';
$search_statut='';
$search_status='';
}
@ -143,7 +143,7 @@ $title=$langs->trans('BankAccounts');
// Load array of financial accounts (opened by default)
$accounts = array();
$sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, datec as date_creation, tms as date_update";
$sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, currency_code, datec as date_creation, tms as date_update";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@ -153,8 +153,8 @@ $sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bankcacount_extrafields as ef on (c.rowid = ef.fk_object)";
$sql.= " WHERE entity IN (".getEntity('bank_account').")";
if ($statut == 'opened') $sql.= " AND clos = 0";
if ($statut == 'closed') $sql.= " AND clos = 1";
if ($search_status == 'opened') $sql.= " AND clos = 0";
if ($search_status == 'closed') $sql.= " AND clos = 1";
if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref);
if ($search_label != '') $sql.=natural_search('b.label', $search_label);
if ($search_number != '') $sql.=natural_search('b.number', $search_number);
@ -222,7 +222,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_ref != '') $param.='&search_ref='.$search_ref;
if ($search_label != '') $param.='&search_label='.$search_label;
if ($search_number != '') $param.='&search_number='.$search_number;
if ($statut != '') $param.='&statut='.$statut;
if ($search_status != '') $param.='&search_status='.$search_status;
if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
@ -338,6 +338,12 @@ if (! empty($arrayfields['toreconcile']['checked']))
print '<td class="liste_titre">';
print '</td>';
}
// Currency
if (! empty($arrayfields['b.currency_code']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
@ -377,7 +383,7 @@ if (! empty($arrayfields['b.tms']['checked']))
print '<td class="liste_titre">';
print '</td>';
}
// Statut
// Status
if (! empty($arrayfields['b.clos']['checked']))
{
print '<td class="liste_titre center">';
@ -385,7 +391,7 @@ if (! empty($arrayfields['b.clos']['checked']))
'opened'=>$langs->trans("Opened"),
'closed'=>$langs->trans("Closed")
);
print $form->selectarray("statut", $array, $statut, 1);
print $form->selectarray("search_status", $array, $search_status, 1);
print '</td>';
}
// Balance
@ -408,6 +414,7 @@ if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titr
if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'],$_SERVER["PHP_SELF"],'b.number','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'],$_SERVER["PHP_SELF"],'b.account_number','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.fk_accountancy_journal','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
@ -443,19 +450,19 @@ foreach ($accounts as $key=>$type)
$found++;
$acc = new Account($db);
$acc->fetch($key);
$obj = new Account($db);
$obj->fetch($key);
$var = !$var;
$solde = $acc->solde(1);
$solde = $obj->solde(1);
if (! empty($lastcurrencycode) && $lastcurrencycode != $acc->currency_code)
if (! empty($lastcurrencycode) && $lastcurrencycode != $obj->currency_code)
{
$lastcurrencycode='various'; // We found several different currencies
}
if ($lastcurrencycode != 'various')
{
$lastcurrencycode=$acc->currency_code;
$lastcurrencycode=$obj->currency_code;
}
print '<tr class="oddeven">';
@ -463,14 +470,14 @@ foreach ($accounts as $key=>$type)
// Ref
if (! empty($arrayfields['b.ref']['checked']))
{
print '<td>'.$acc->getNomUrl(1).'</td>';
print '<td>'.$obj->getNomUrl(1).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Label
if (! empty($arrayfields['b.label']['checked']))
{
print '<td>'.$acc->label.'</td>';
print '<td>'.$obj->label.'</td>';
if (! $i) $totalarray['nbfield']++;
}
@ -478,7 +485,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['accountype']['checked']))
{
print '<td>';
print $acc->type_lib[$acc->type];
print $obj->type_lib[$obj->type];
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
@ -486,7 +493,7 @@ foreach ($accounts as $key=>$type)
// Number
if (! empty($arrayfields['b.number']['checked']))
{
print '<td>'.$acc->number.'</td>';
print '<td>'.$obj->number.'</td>';
if (! $i) $totalarray['nbfield']++;
}
@ -497,12 +504,12 @@ foreach ($accounts as $key=>$type)
if (! empty($conf->accounting->enabled))
{
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('',$acc->account_number);
$accountingaccount->fetch('',$obj->account_number);
print $accountingaccount->getNomUrl(0,1,1,'',1);
}
else
{
print $acc->account_number;
print $obj->account_number;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
@ -515,7 +522,7 @@ foreach ($accounts as $key=>$type)
if (! empty($conf->accounting->enabled))
{
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($acc->fk_accountancy_journal);
$accountingjournal->fetch($obj->fk_accountancy_journal);
print $accountingjournal->getNomUrl(0,1,1,'',1);
}
else
@ -526,15 +533,24 @@ foreach ($accounts as $key=>$type)
if (! $i) $totalarray['nbfield']++;
}
// Currency
if (! empty($arrayfields['b.currency_code']['checked']))
{
print '<td align="center">';
print $obj->currency_code;
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Transactions to reconcile
if (! empty($arrayfields['toreconcile']['checked']))
{
print '<td align="center">';
if ($acc->rappro)
if ($obj->rappro)
{
$result=$acc->load_board($user,$acc->id);
$result=$obj->load_board($user,$obj->id);
if ($result<0) {
setEventMessages($acc->error, $acc->errors, 'errors');
setEventMessages($obj->error, $obj->errors, 'errors');
} else {
print $result->nbtodo;
if ($result->nbtodolate) print ' &nbsp; ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
@ -571,7 +587,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['b.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($acc->date_creation, 'dayhour');
print dol_print_date($obj->date_creation, 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
@ -579,15 +595,15 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['b.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($acc->date_update, 'dayhour');
print dol_print_date($obj->date_update, 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Statut
// Status
if (! empty($arrayfields['b.clos']['checked']))
{
print '<td align="center">'.$acc->getLibStatut(5).'</td>';
print '<td align="center">'.$obj->getLibStatut(5).'</td>';
if (! $i) $totalarray['nbfield']++;
}
@ -595,7 +611,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['balance']['checked']))
{
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$obj->id.'">'.price($solde, 0, $langs, 0, 0, -1, $obj->currency_code).'</a>';
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
@ -615,7 +631,7 @@ foreach ($accounts as $key=>$type)
print '</tr>';
$total[$acc->currency_code] += $solde;
$total[$obj->currency_code] += $solde;
$i++;
}

View File

@ -30,8 +30,7 @@ require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->loadLangs(array("banks", "categories", "multicurrency"));
if (! $user->rights->banque->transfer)
accessforbidden();
@ -44,14 +43,14 @@ $error = 0;
* Actions
*/
if ($action == 'add_confirm')
if ($action == 'add')
{
$langs->load("errors");
$dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
$label = GETPOST('label','alpha');
$amount= GETPOST('amount');
$amount_to= GETPOST('amount_to');
$amountto= GETPOST('amountto');
if (! $label)
{
@ -83,7 +82,17 @@ if ($action == 'add_confirm')
$accountto=new Account($db);
$accountto->fetch(GETPOST('account_to','int'));
if ($accountto->id != $accountfrom->id)
if ($accountto->currency_code == $accountfrom->currency_code) {
$amountto=$amount;
} else {
if (! $amountto)
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")), null, 'errors');
}
}
if (($accountto->id != $accountfrom->id) && empty($error))
{
$db->begin();
@ -103,8 +112,7 @@ if ($action == 'add_confirm')
if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user);
if (! ($bank_line_id_from > 0)) $error++;
if ((! $error) && ($accountto->currency_code == $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user);
if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user);
if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amountto), '', '', $user);
if (! ($bank_line_id_to > 0)) $error++;
if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
@ -114,7 +122,7 @@ if ($action == 'add_confirm')
if (! $error)
{
$mesgs = $langs->trans("TransferFromToDone","<a href=\"card.php?id=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"card.php?id=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
$mesgs = $langs->trans("TransferFromToDone",'<a href="bankentries.php?id='.$accountfrom->id.'&sortfield=b.datev,b.dateo,b.rowid&sortorder=desc">'.$accountfrom->label."</a>",'<a href="bankentries.php?id='.$accountto->id.'">'.$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
setEventMessages($mesgs, null, 'mesgs');
$db->commit();
}
@ -139,6 +147,58 @@ if ($action == 'add_confirm')
*/
llxHeader();
print ' <script type="text/javascript">
$(document).ready(function () {
$(".selectbankaccount").change(function() {
var account1 = $("#selectaccount_from").val();
var account2 = $("#selectaccount_to").val();
var currencycode1="";
var currencycode2="";
$.get("'.DOL_URL_ROOT.'/core/ajax/getaccountcurrency.php", {id: account1})
.done(function( data ) {
if (data != null)
{
var item= $.parseJSON(data);
if (item.num==-1) {
console.error("Error: "+item.error);
} else if (item.num!==0) {
currencycode1 = item.value;
}
$.get("'.DOL_URL_ROOT.'/core/ajax/getaccountcurrency.php", {id: account2})
.done(function( data ) {
if (data != null)
{
var item=$.parseJSON(data);
if (item.num==-1) {
console.error("Error: "+item.error);
} else if (item.num!==0) {
currencycode2 = item.value;
}
if (currencycode2!==currencycode1 && currencycode2!=="" && currencycode1!=="") {
$(".multicurrency").show();
} else {
$(".multicurrency").hide();
}
}
else {
console.error("Error: Ajax url has returned an empty page. Should be an empty json array.");
}
}).fail(function( data ) {
console.error("Error: has returned an empty page. Should be an empty json array.");
});
}
else {
console.error("Error: has returned an empty page. Should be an empty json array.");
}
}).fail(function( data ) {
console.error("Error: has returned an empty page. Should be an empty json array.");
});
});
});
</script>';
$form=new Form($db);
@ -146,9 +206,8 @@ $account_from='';
$account_to='';
$label='';
$amount='';
$amount_to='';
if ($error)
if($error)
{
$account_from = GETPOST('account_from','int');
$account_to = GETPOST('account_to','int');
@ -164,21 +223,21 @@ print "<br><br>";
print '<form name="add" method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add_confirm">';
print '<input type="hidden" name="action" value="add">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>';
print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>';
print '<td style="display:none" class="multicurrency">'.$langs->trans("AmountToOthercurrency").'</td>';
print '</tr>';
$var=false;
print '<tr class="oddeven"><td>';
$form->select_comptes($account_from,'account_from',0,'',1);
$form->select_comptes($account_from, 'account_from', 0, '', 1, '', empty($conf->multicurrency->enabled)?0:1);
print "</td>";
print "<td>\n";
$form->select_comptes($account_to,'account_to',0,'',1);
$form->select_comptes($account_to, 'account_to', 0, '', 1, '', empty($conf->multicurrency->enabled)?0:1);
print "</td>\n";
print "<td>";
@ -186,6 +245,8 @@ $form->select_date((! empty($dateo)?$dateo:''),'','','','','add');
print "</td>\n";
print '<td><input name="label" class="flat quatrevingtpercent" type="text" value="'.$label.'"></td>';
print '<td><input name="amount" class="flat" type="text" size="6" value="'.$amount.'"></td>';
print '<td style="display:none" class="multicurrency"><input name="amountto" class="flat" type="text" size="6" value="'.$amountto.'"></td>';
print "</table>";
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></div>';

View File

@ -132,7 +132,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
if ($cancel) $action='';
if ($cancel)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
$action='';
}
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
@ -378,7 +386,9 @@ if (empty($reshook))
else if ($action == "setabsolutediscount" && $user->rights->facture->creer)
{
// POST[remise_id] ou POST[remise_id_for_payment]
// POST[remise_id] or POST[remise_id_for_payment]
// We use the credit to reduce amount of invoice
if (! empty($_POST["remise_id"])) {
$ret = $object->fetch($id);
if ($ret > 0) {
@ -390,14 +400,28 @@ if (empty($reshook))
dol_print_error($db, $object->error);
}
}
if (! empty($_POST["remise_id_for_payment"])) {
// We use the credit to reduce remain to pay
if (! empty($_POST["remise_id_for_payment"]))
{
require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
$discount = new DiscountAbsolute($db);
$discount->fetch($_POST["remise_id_for_payment"]);
$result = $discount->link_to_invoice(0, $id);
if ($result < 0) {
setEventMessages($discount->error, $discount->errors, 'errors');
//var_dump($object->getRemainToPay(0));
//var_dump($discount->amount_ttc);exit;
if ($discount->amount_ttc > $object->getRemainToPay(0))
{
// TODO Split the discount in 2 automatically
$error++;
setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors');
}
if (! $error)
{
$result = $discount->link_to_invoice(0, $id);
if ($result < 0) {
setEventMessages($discount->error, $discount->errors, 'errors');
}
}
}
@ -580,27 +604,30 @@ if (empty($reshook))
$ventilExportCompta = $object->getVentilExportCompta();
// On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
if ($ventilExportCompta == 0)
{
$result=$object->set_draft($user, $idwarehouse);
if ($result<0) setEventMessages($object->error, $object->errors, 'errors');
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye)))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$result=$object->set_draft($user, $idwarehouse);
if ($result<0) setEventMessages($object->error, $object->errors, 'errors');
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
}
}
@ -882,13 +909,18 @@ if (empty($reshook))
$line->fk_facture = $object->id;
$line->fk_parent_line = $fk_parent_line;
$line->subprice =-$line->subprice; // invert price for object
$line->subprice = -$line->subprice; // invert price for object
$line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here
$line->total_ht=-$line->total_ht;
$line->total_tva=-$line->total_tva;
$line->total_ttc=-$line->total_ttc;
$line->total_localtax1=-$line->total_localtax1;
$line->total_localtax2=-$line->total_localtax2;
$line->total_ht = -$line->total_ht;
$line->total_tva = -$line->total_tva;
$line->total_ttc = -$line->total_ttc;
$line->total_localtax1 = -$line->total_localtax1;
$line->total_localtax2 = -$line->total_localtax2;
$line->multicurrency_subprice = -$line->multicurrency_subprice;
$line->multicurrency_total_ht = -$line->multicurrency_total_ht;
$line->multicurrency_total_tva = -$line->multicurrency_total_tva;
$line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
$result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked
@ -1385,6 +1417,7 @@ if (empty($reshook))
{
$line->origin = $object->origin;
$line->origin_id = $line->id;
$line->fetch_optionals($line->id);
}
}
@ -1406,7 +1439,21 @@ if (empty($reshook))
$object->situation_counter = $object->situation_counter + 1;
$id = $object->createFromCurrent($user);
if ($id <= 0) $mesg = $object->error;
if ($id <= 0)
{
$mesg = $object->error;
}
else
{
$nextSituationInvoice = new Facture($db);
$nextSituationInvoice->fetch($id);
// create extrafields with data from create form
$extralabels = $extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $nextSituationInvoice);
if ($ret > 0) {
$nextSituationInvoice->insertExtraFields();
}
}
}
}
@ -1772,7 +1819,7 @@ if (empty($reshook))
$date_end = '';
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none'));
$pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
@ -1957,20 +2004,17 @@ if (empty($reshook))
exit();
}
/*
* Send mail
*/
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
if (empty($id)) $id=$facid;
$trigger_name='BILL_SENTBYMAIL';
$paramname='id';
$mode='emailfrominvoice';
$autocopy='MAIN_MAIL_AUTOCOPY_INVOICE_TO';
$trackid='inv'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Actions to build doc
$upload_dir = $conf->facture->dir_output;
$permissioncreate=$user->rights->facture->creer;
@ -2003,8 +2047,6 @@ if (empty($reshook))
$action = 'edit_extras';
}
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) {
if ($action == 'addcontact') {
$result = $object->fetch($id);
@ -2526,8 +2568,8 @@ if ($action == 'create')
print $desc;
print '<div id="credit_note_options" class="clearboth">';
print '&nbsp;&nbsp;&nbsp; <input data-role="none" type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '<br>&nbsp;&nbsp;&nbsp; <input data-role="none" type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '<br>&nbsp;&nbsp;&nbsp; <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '</div>';
print '</div></div>';
@ -3221,6 +3263,7 @@ else if ($id > 0 || ! empty($ref))
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
print '</td><td>';
@ -3230,7 +3273,7 @@ else if ($id > 0 || ! empty($ref))
print $langs->trans("CompanyHasNoRelativeDiscount");
// print ' ('.$addrelativediscount.')';
// Is there commercial discount or down payment available ?
// Is there is commercial discount or down payment available ?
if ($absolute_discount > 0) {
print '. ';
if ($object->statut > 0 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) {
@ -3255,7 +3298,7 @@ else if ($id > 0 || ! empty($ref))
} else {
if ($absolute_creditnote > 0) // If not, link will be added later
{
if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT)
if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT)
print ' (' . $addabsolutediscount . ')<br>';
else
print '. ';
@ -3266,7 +3309,7 @@ else if ($id > 0 || ! empty($ref))
if ($absolute_creditnote > 0)
{
// If validated, we show link "add credit note to payment"
if ($object->statut != 1 || $object->type == Facture::TYPE_CREDIT_NOTE) {
if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE) {
if ($object->statut == 0 && $object->type != Facture::TYPE_DEPOSIT) {
$text = $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency));
print $form->textwithpicto($text, $langs->trans("CreditNoteDepositUse"));
@ -3277,13 +3320,13 @@ else if ($id > 0 || ! empty($ref))
// There is credit notes discounts available
if (! $absolute_discount) print '<br>';
// $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
$more=' ('.$addcreditnote.')';
$more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')';
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0, $more); // We allow credit note even if amount is higher
}
}
if (! $absolute_discount && ! $absolute_creditnote) {
print $langs->trans("CompanyHasNoAbsoluteDiscount");
if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT)
if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT)
print ' (' . $addabsolutediscount . ')<br>';
else
print '. ';
@ -4075,28 +4118,35 @@ else if ($id > 0 || ! empty($ref))
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
// Editer une facture deja validee, sans paiement effectue et pas exporte en compta
if ($object->statut == 1)
if ($object->statut == Facture::STATUS_VALIDATED)
{
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
$ventilExportCompta = $object->getVentilExportCompta();
if ($resteapayer == $object->total_ttc && empty($object->paye) && $ventilExportCompta == 0)
if ($ventilExportCompta == 0)
{
if (! $objectidnext && $object->is_last_in_cycle())
if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye)))
{
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
if (! $objectidnext && $object->is_last_in_cycle())
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
} else {
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("NotEnoughPermissions") . '">' . $langs->trans('Modify') . '</span></div>';
}
} else if (!$object->is_last_in_cycle()) {
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("NotLastInCycle") . '">' . $langs->trans('Modify') . '</span></div>';
} else {
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("NotEnoughPermissions") . '">' . $langs->trans('Modify') . '</span></div>';
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('Modify') . '</span></div>';
}
} else if (!$object->is_last_in_cycle()) {
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("NotLastInCycle") . '">' . $langs->trans('Modify') . '</span></div>';
} else {
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('Modify') . '</span></div>';
}
}
else
{
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("DisabledBecauseDispatchedInAccounting") . '">' . $langs->trans('Modify') . '</span></div>';
}
}
$discount = new DiscountAbsolute($db);
@ -4118,7 +4168,7 @@ else if ($id > 0 || ! empty($ref))
}
// Validate
if ($object->statut == 0 && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate)))
{
@ -4335,143 +4385,15 @@ else if ($id > 0 || ! empty($ref))
print '</div></div></div>';
}
else
{
/*
* Action presend (or prerelance)
*/
$object->fetch_projet();
// By default if $action=='presend'
$titreform = 'SendBillByMail';
$topicmail = 'SendBillRef';
$modelmail = 'facture_send';
// Presend form
$modelmail='facture_send';
$defaulttopic='SendBillRef';
$diroutput = $conf->facture->dir_output;
$trackid = 'inv'.$object->id;
if ($action == 'prerelance') // For backward compatibility
{
$titrefrom = 'SendReminderBillByMail';
$topicmail = 'SendReminderBillRef';
$modelmail = 'facture_relance';
$action = 'relance';
} else
$action = 'send';
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('bills');
}
// Build document if it not exists
if (! $file || ! is_readable($file)) {
$result = $object->generateDocument(GETPOST('model','alpha') ? GETPOST('model','alpha') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
dol_print_error($db, $object->error, $object->errors);
exit();
}
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>';
print '<br>';
print load_fiche_titre($langs->trans($titreform));
// Cree l'objet formulaire mail
dol_fiche_head();
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
$formmail->fromtype = (GETPOST('fromtype','alpha')?GETPOST('fromtype','alpha'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
$formmail->trackid='inv'.$object->id;
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'inv'.$object->id);
}
$formmail->withfrom = 1;
$liste = array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) {
$liste [$key] = $value;
}
$formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; // List suggested for send to
$formmail->withtocc = $liste; // List suggested for CC
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
if (empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->transnoentities($topicmail, '__REF__');
} else if (! empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->transnoentities($topicmail, '__REF__ (__REFCLIENT__)');
}
$formmail->withfile = 2;
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
// Tableau des substitutions
$formmail->setSubstitFromObject($object, $outputlangs);
$formmail->substit['__INVREF__'] = $object->ref;
// Find the good contact adress
$custcontact = '';
$contactarr = array();
$contactarr = $object->liste_contact(- 1, 'external');
if (is_array($contactarr) && count($contactarr) > 0) {
foreach ($contactarr as $contact) {
if ($contact['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) { // TODO Use code and not label
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
$contactstatic = new Contact($db);
$contactstatic->fetch($contact ['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
}
}
if (! empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
}
}
// Tableau des parametres complementaires du post
$formmail->param['action'] = $action;
$formmail->param['models'] = $modelmail;
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['facid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
if (GETPOST("mode") == 'init') {
$formmail->clear_attached_files();
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
}
print $formmail->get_form();
dol_fiche_end();
}
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
llxFooter();

View File

@ -192,7 +192,7 @@ class Invoices extends DolibarrApi
foreach($request_data as $field => $value) {
$this->invoice->$field = $value;
}
if(! array_keys($request_data,'date')) {
if(! array_key_exists('date', $request_data)) {
$this->invoice->date = dol_now();
}
/* We keep lines as an array
@ -276,6 +276,107 @@ class Invoices extends DolibarrApi
);
}
/**
* Get lines of a given invoice
*
* @param int $id Id of invoice
*
* @url GET {id}/lines
*
* @return array
*/
function getLines($id) {
if(! DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->invoice->getLinesArray();
$result = array();
foreach ($this->invoice->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
}
/**
* Add a line to a given invoice
*
* Exemple of POST query : { "desc": "Desc", "subprice": "1.00000000", "qty": "1", "tva_tx": "20.000", "localtax1_tx": "0.000", "localtax2_tx": "0.000", "fk_product": "1", "remise_percent": "0", "date_start": "", "date_end": "", "fk_code_ventilation": 0, "info_bits": "0", "fk_remise_except": null, "product_type": "1", "rang": "-1", "special_code": "0", "fk_parent_line": null, "fk_fournprice": null, "pa_ht": "0.00000000", "label": "", "array_options": [], "situation_percent": "100", "fk_prev_id": null, "fk_unit": null }
*
* @param int $id Id of invoice
* @param array $request_data Invoiceline data
*
* @url POST {id}/lines
*
* @return int
*/
function postLine($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
// Reset fk_parent_line for no child products and special product
if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
$request_data->fk_parent_line = 0;
}
$updateRes = $this->invoice->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
$request_data->date_start,
$request_data->date_end,
$request_data->fk_code_ventilation,
$request_data->info_bits,
$request_data->fk_remise_except,
'HT',
0,
$request_data->product_type,
$request_data->rang,
$request_data->special_code,
'facture',
$id,
$request_data->fk_parent_line,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->label,
$request_data->array_options,
$request_data->situation_percent,
$request_data->fk_prev_id,
$request_data->fk_unit
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
}
throw new RestException(400, 'Unable to insert the new line. Check your inputs.');
}
/**
* Validate an order
*

View File

@ -152,8 +152,8 @@ class FactureRec extends CommonInvoice
$sql.= ", '".$this->db->escape($user->id)."'";
$sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null");
$sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null");
$sql.= ", '".$this->db->escape($facsrc->cond_reglement_id)."'";
$sql.= ", '".$this->db->escape($facsrc->mode_reglement_id)."'";
$sql.= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null");
$sql.= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null");
$sql.= ", ".$this->usenewprice;
$sql.= ", ".$this->frequency;
$sql.= ", '".$this->db->escape($this->unit_frequency)."'";
@ -329,7 +329,6 @@ class FactureRec extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
@ -447,7 +446,6 @@ class FactureRec extends CommonInvoice
$line->price = $objp->price;
$line->remise = $objp->remise;
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
@ -715,6 +713,9 @@ class FactureRec extends CommonInvoice
dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
if (empty($remise_percent)) $remise_percent = 0;
// Check parameters
if ($type < 0) return -1;

View File

@ -293,8 +293,8 @@ class Facture extends CommonInvoice
// Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI
$this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project;
$this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public;
$this->note_private = GETPOST('note_private') ? GETPOST('note_private') : $_facrec->note_private;
$this->note_public = GETPOST('note_public','none') ? GETPOST('note_public','none') : $_facrec->note_public;
$this->note_private = GETPOST('note_private','none') ? GETPOST('note_private','none') : $_facrec->note_private;
$this->modelpdf = GETPOST('model') ? GETPOST('model') : $_facrec->modelpdf;
$this->cond_reglement_id = GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $_facrec->cond_reglement_id;
$this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id;
@ -1051,6 +1051,30 @@ class Facture extends CommonInvoice
else return -1;
}
/**
* Return link to download file from a direct external access
*
* @param int $withpicto Add download picto into link
* @return string HTML link to file
*/
function getDirectExternalLink($withpicto=0)
{
global $dolibarr_main_url_root;
// 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
// TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it)
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($this->db);
//$result = $ecmfile->get();
$hashp='todo';
return '<a href="'.$urlwithroot.'/document.php?modulepart=invoice&hashp='.$hashp.'" target="_download" rel="noindex, nofollow">'.$this->ref.'</a>';
}
/**
* Return clicable link of object (with eventually picto)
*
@ -1577,7 +1601,7 @@ class Facture extends CommonInvoice
$facligne->desc=$remise->description; // Description ligne
$facligne->vat_src_code=$remise->vat_src_code;
$facligne->tva_tx=$remise->tva_tx;
$facligne->subprice=-$remise->amount_ht;
$facligne->subprice = -$remise->amount_ht;
$facligne->fk_product=0; // Id produit predefini
$facligne->qty=1;
$facligne->remise_percent=0;
@ -1600,6 +1624,11 @@ class Facture extends CommonInvoice
$facligne->total_tva = -$remise->amount_tva;
$facligne->total_ttc = -$remise->amount_ttc;
$facligne->multicurrency_subprice = -$remise->multicurrency_subprice;
$facligne->multicurrency_total_ht = -$remise->multicurrency_total_ht;
$facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva;
$facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc;
$lineid=$facligne->insert();
if ($lineid > 0)
{
@ -1708,7 +1737,7 @@ class Facture extends CommonInvoice
* @param User $user User making the deletion.
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int $idwarehouse Id warehouse to use for stock change.
* @return int <0 if KO, >0 if OK
* @return int <0 if KO, 0=Refused, >0 if OK
*/
function delete($user, $notrigger=0, $idwarehouse=-1)
{
@ -1719,9 +1748,13 @@ class Facture extends CommonInvoice
dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
// TODO Test if there is at least one payment. If yes, refuse to delete.
// Test to avoid invoice deletion (allowed if draft)
$test = $this->is_erasable();
if ($test <= 0) return $test;
$error=0;
$this->db->begin();
if (! $error && ! $notrigger)
@ -3327,9 +3360,9 @@ class Facture extends CommonInvoice
/**
* Return if an invoice can be deleted
* Rule is:
* If hidden option INVOICE_CAN_ALWAYS_BE_REMOVED is on, we can
* If invoice has a definitive ref, is last, without payment and not dipatched into accountancy -> yes end of rule
* If invoice is draft and ha a temporary ref -> yes
* If hidden option INVOICE_CAN_ALWAYS_BE_REMOVED is on, we can. If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on, we can't.
* If invoice has a definitive ref, is last, without payment and not dipatched into accountancy -> yes end of rule
*
* @return int <0 if KO, 0=no, 1=yes
*/
@ -3337,30 +3370,36 @@ class Facture extends CommonInvoice
{
global $conf;
// on verifie si la facture est en numerotation provisoire
$facref = substr($this->ref, 1, 4);
if ($this->statut == self::STATUS_DRAFT && $facref == 'PROV') // If draft invoice and ref not yet defined
{
return 1;
}
if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) return 1;
if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0;
// on verifie si la facture est en numerotation provisoire
$facref = substr($this->ref, 1, 4);
// TODO Test if there is at least one payment. If yes, refuse to delete.
// ...
// If not a draft invoice and not temporary invoice
if ($facref != 'PROV')
{
$maxfacnumber = $this->getNextNumRef($this->thirdparty,'last');
$ventilExportCompta = $this->getVentilExportCompta();
// If there is no invoice into the reset range and not already dispatched, we can delete
if ($maxfacnumber == '' && $ventilExportCompta == 0) return 1;
// If invoice to delete is last one and not already dispatched, we can delete
if ($maxfacnumber == $this->ref && $ventilExportCompta == 0) return 1;
if ($this->situation_cycle_ref) {
$last = $this->is_last_in_cycle();
return $last;
}
}
else if ($this->statut == self::STATUS_DRAFT && $facref == 'PROV') // Si facture brouillon et provisoire
{
return 1;
}
return 0;
}

View File

@ -70,13 +70,17 @@ $search_societe=GETPOST('search_societe');
$search_montant_ht=GETPOST('search_montant_ht');
$search_montant_vat=GETPOST('search_montant_vat');
$search_montant_ttc=GETPOST('search_montant_ttc');
$search_payment_mode=GETPOST('search_payment_mode');
$search_payment_term=GETPOST('search_payment_term');
$day=GETPOST('day');
$year=GETPOST('year');
$month=GETPOST('month');
$day_date_when=GETPOST('day_date_when');
$year_date_when=GETPOST('year_date_when');
$month_date_when=GETPOST('month_date_when');
$search_frequency=GETPOST('search_frequency');
$search_recurring=GETPOST('search_recurring','int');
$search_frequency=GETPOST('search_frequency','alpha');
$search_unit_frequency=GETPOST('search_unit_frequency','alpha');
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
@ -111,29 +115,6 @@ $permissionnote = $user->rights->facture->creer; // Used by the include of actio
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
$arrayfields=array(
'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1),
'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1),
'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1),
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
/*
* Actions
@ -168,13 +149,17 @@ if (empty($reshook))
$search_montant_ht='';
$search_montant_vat='';
$search_montant_ttc='';
$search_montant_mode='';
$search_montant_term='';
$day='';
$year='';
$month='';
$day_date_when='';
$year_date_when='';
$month_date_when='';
$search_recurring='';
$search_frequency='';
$search_unit_frequency='';
$search_array_options=array();
}
@ -224,8 +209,8 @@ if (empty($reshook))
if (! $error)
{
$object->titre = GETPOST('titre', 'alpha');
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private','none');
$object->note_public = GETPOST('note_public','none');
$object->usenewprice = GETPOST('usenewprice');
$object->frequency = $frequency;
@ -375,7 +360,7 @@ if (empty($reshook))
// For triggers
$line->id = $lineid;
if ($line->delete() > 0)
if ($line->delete($user) > 0)
{
$result=$object->update_price(1);
@ -738,7 +723,7 @@ if (empty($reshook))
$date_end = '';
//$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
//$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none'));
$pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
@ -980,14 +965,17 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>';
print '</tr>';
$note_public=GETPOST('note_public')?GETPOST('note_public'):$object->note_public;
$note_private=GETPOST('note_private')?GETPOST('note_private'):$object->note_private;
$note_public=GETPOST('note_public','none')?GETPOST('note_public','none'):$object->note_public;
$note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private;
// Help of substitution key
$substitutionarray=array(
'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')',
//'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
//'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__AMOUNT_EXCL_TAX__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__AMOUNT_VAT__' => $langs->trans("AmountVAT").' ('.$langs->trans("Example").': '.price($object->total_tva).')',
'__AMOUNT__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')',
'__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')',
'__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')',
'__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')',
@ -1042,7 +1030,7 @@ if ($action == 'create')
// Payment mode
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none');
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1);
print "</td></tr>";
// Project
@ -1077,7 +1065,7 @@ if ($action == 'create')
print '<table class="border" width="100%">';
// Frequency
// Frequency + unit
print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m'));
print "</td></tr>";
@ -1181,7 +1169,7 @@ else
// Recurring invoice content
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/fiche-rec.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/facture/invoicetemplate_list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='';
if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2);
@ -1307,8 +1295,11 @@ else
$dateexample=dol_now();
if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when;
$substitutionarray=array(
'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
//'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
//'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__AMOUNT_EXCL_TAX__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__AMOUNT_VAT__' => $langs->trans("AmountVAT").' ('.$langs->trans("Example").': '.price($object->total_tva).')',
'__AMOUNT__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')',
'__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')',
'__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')',
@ -1549,8 +1540,6 @@ else
{
if ($action != 'editline')
{
$var = true;
// Add free products/services
$object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice
@ -1620,382 +1609,6 @@ else
print '</div></div>';
}
else
{
/*
* List mode
*/
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,";
$sql.= " f.datec, f.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1);
if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
if ($search_frequency > 0) $sql.= natural_search('f.frequency', $search_frequency);
if ($search_frequency == '1') $sql.= ' AND f.frequency > 0';
if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)';
if ($month > 0)
{
if ($year > 0 && empty($day))
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else if ($year > 0 && ! empty($day))
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
else
$sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'";
}
else if ($year > 0)
{
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($month_date_when > 0)
{
if ($year_date_when > 0 && empty($day_date_when))
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'";
else if ($year_date_when > 0 && ! empty($day_date_when))
$sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'";
else
$sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'";
}
else if ($year_date_when > 0)
{
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
}
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->order($sortfield, $sortorder);
$sql.= $db->plimit($limit+1,$offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($socid) $param.='&socid='.$socid;
if ($day) $param.='&day='.$day;
if ($month) $param.='&month='.$month;
if ($year) $param.='&year=' .$year;
if ($day_date_when) $param.='&day_date_when='.$day_date_when;
if ($month_date_when) $param.='&month_date_when='.$month_date_when;
if ($year_date_when) $param.='&year_date_when=' .$year_date_when;
if ($search_ref) $param.='&search_ref=' .$search_ref;
if ($search_societe) $param.='&search_societe=' .$search_societe;
if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht;
if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat;
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc;
if ($search_frequency > 0) $param.='&search_frequency=' .$search_frequency;
if ($option) $param.="&option=".$option;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
//$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
print '<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>';
$i = 0;
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Filters lines
print '<tr class="liste_titre_filter">';
// Ref
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td class="liste_titre" align="left">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
// Thirpdarty
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
}
if (! empty($arrayfields['f.total']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
print '</td>';
}
if (! empty($arrayfields['f.tva']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
print '</td>';
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
print '</td>';
}
if (! empty($arrayfields['f.frequency']['checked']))
{
// Recurring or not
print '<td class="liste_titre" align="center">';
print $form->selectyesno('search_frequency', $search_frequency, 1, false, 1);
print '</td>';
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
{
// Nb generation
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Date invoice
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
}
// Date due
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_date_when" value="'.$day_date_when.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_date_when" value="'.$month_date_when.'">';
$formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5);
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['f.datec']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status
if (! empty($arrayfields['status']['checked']))
{
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Action column
print '<td class="liste_titre" align="middle">';
$searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
print "</tr>\n";
if ($num > 0)
{
$var=true;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
$companystatic->id=$objp->socid;
$companystatic->name=$objp->name;
$invoicerectmp->id=$objp->id;
$invoicerectmp->frequency=$objp->frequency;
$invoicerectmp->suspend=$objp->suspend;
$invoicerectmp->unit_frequency=$objp->unit_frequency;
print '<tr class="oddeven">';
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td><a href="'.$_SERVER['PHP_SELF'].'?id='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
print "</a></td>\n";
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>';
}
if (! empty($arrayfields['f.total']['checked']))
{
print '<td align="right">'.price($objp->total).'</td>'."\n";
}
if (! empty($arrayfields['f.tva']['checked']))
{
print '<td align="right">'.price($objp->total_vat).'</td>'."\n";
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
print '<td align="right">'.price($objp->total_ttc).'</td>'."\n";
}
if (! empty($arrayfields['f.frequency']['checked']))
{
print '<td align="center">'.yn($objp->frequency?1:0).'</td>';
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
}
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
}
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
}
if (! empty($arrayfields['f.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->datec),'dayhour');
print '</td>';
}
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->tms),'dayhour');
print '</td>';
}
if (! empty($arrayfields['status']['checked']))
{
print '<td align="center">';
print $invoicerectmp->getLibStatut(3,0);
print '</td>';
}
// Action column
print '<td align="center">';
if ($user->rights->facture->creer)
{
if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
{
print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
print $langs->trans("CreateBill").'</a>';
}
else
{
print $langs->trans("DateIsNotEnough");
}
}
else
{
print "&nbsp;";
}
print "</td>";
print "</tr>\n";
$i++;
}
}
else
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
print "</table>";
print "</div>";
print "</form>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
}
}
llxFooter();

View File

@ -0,0 +1,700 @@
<?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.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/compta/facture/invoicetemplate_list.php
* \ingroup facture
* \brief Page to show list of template/recurring invoices
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
//require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$langs->load('bills');
$langs->load('compta');
$langs->load('admin');
$langs->load('other');
$action = GETPOST('action','alpha');
$massaction = GETPOST('massaction','alpha');
$show_files = GETPOST('show_files','int');
$confirm = GETPOST('confirm','alpha');
$cancel = GETPOST('cancel', 'alpha');
$toselect = GETPOST('toselect', 'array');
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search
// Security check
$id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int'));
$lineid=GETPOST('lineid','int');
$ref=GETPOST('ref','alpha');
if ($user->societe_id) $socid=$user->societe_id;
$objecttype = 'facture_rec';
if ($action == "create" || $action == "add") $objecttype = '';
$result = restrictedArea($user, 'facture', $id, $objecttype);
$projectid = GETPOST('projectid','int');
$search_ref=GETPOST('search_ref');
$search_societe=GETPOST('search_societe');
$search_montant_ht=GETPOST('search_montant_ht');
$search_montant_vat=GETPOST('search_montant_vat');
$search_montant_ttc=GETPOST('search_montant_ttc');
$search_payment_mode=GETPOST('search_payment_mode');
$search_payment_term=GETPOST('search_payment_term');
$day=GETPOST('day');
$year=GETPOST('year');
$month=GETPOST('month');
$day_date_when=GETPOST('day_date_when');
$year_date_when=GETPOST('year_date_when');
$month_date_when=GETPOST('month_date_when');
$search_recurring=GETPOST('search_recurring','int');
$search_frequency=GETPOST('search_frequency','alpha');
$search_unit_frequency=GETPOST('search_unit_frequency','alpha');
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='f.titre';
$pageprev = $page - 1;
$pagenext = $page + 1;
$object = new FactureRec($db);
if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
{
$ret = $object->fetch($id, $ref);
if (!$ret)
{
setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
}
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('invoicereccard','globalcard'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('facture_rec');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
$arrayfields=array(
'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1),
'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1),
'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0),
'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0),
'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1),
'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1),
'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1),
'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1),
'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1),
'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1),
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
/*
* Actions
*/
if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
$parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if (GETPOST('cancel','alpha')) $action='';
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Do we click on purge search criteria ?
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
{
$search_ref='';
$search_societe='';
$search_montant_ht='';
$search_montant_vat='';
$search_montant_ttc='';
$search_payment_mode='';
$search_payment_term='';
$day='';
$year='';
$month='';
$day_date_when='';
$year_date_when='';
$month_date_when='';
$search_recurring='';
$search_frequency='';
$search_unit_frequency='';
$search_array_options=array();
}
// Mass actions
/*$objectclass='MyObject';
$objectlabel='MyObject';
$permtoread = $user->rights->mymodule->read;
$permtodelete = $user->rights->mymodule->delete;
$uploaddir = $conf->mymodule->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
}
/*
* View
*/
llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec');
$form = new Form($db);
$formother = new FormOther($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
$companystatic = new Societe($db);
$invoicerectmp = new FactureRec($db);
$now = dol_now();
$tmparray=dol_getdate($now);
$today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day
/*
* List mode
*/
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,";
$sql.= " f.datec, f.tms,";
$sql.= " f.fk_cond_reglement, f.fk_mode_reglement";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1);
if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1);
if (! empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1);
if (! empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1);
if ($search_recurring == '1') $sql .= ' AND f.frequency > 0';
if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1);
if ($search_unit_frequency != '') $sql .= natural_search('f.unit_frequency', $search_unit_frequency);
if ($month > 0)
{
if ($year > 0 && empty($day))
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
else if ($year > 0 && ! empty($day))
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
else
$sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'";
}
else if ($year > 0)
{
$sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($month_date_when > 0)
{
if ($year_date_when > 0 && empty($day_date_when))
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'";
else if ($year_date_when > 0 && ! empty($day_date_when))
$sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'";
else
$sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'";
}
else if ($year_date_when > 0)
{
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
}
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->order($sortfield, $sortorder);
$sql.= $db->plimit($limit+1,$offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($socid) $param.='&socid='.urlencode($socid);
if ($day) $param.='&day='.urlencode($day);
if ($month) $param.='&month='.urlencode($month);
if ($year) $param.='&year=' .urlencode($year);
if ($day_date_when) $param.='&day_date_when='.urlencode($day_date_when);
if ($month_date_when) $param.='&month_date_when='.urlencode($month_date_when);
if ($year_date_when) $param.='&year_date_when=' .urlencode($year_date_when);
if ($search_ref) $param.='&search_ref=' .urlencode($search_ref);
if ($search_societe) $param.='&search_societe=' .urlencode($search_societe);
if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht);
if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat);
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode);
if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type);
if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring);
if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency);
if ($search_unit_frequency > 0) $param.='&search_unit_frequency='.urlencode($search_unit_frequency);
if ($option) $param.="&option=".urlencode($option);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
//$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>';
$i = 0;
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Filters lines
print '<tr class="liste_titre_filter">';
// Ref
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td class="liste_titre" align="left">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
// Thirpdarty
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
}
if (! empty($arrayfields['f.total']['checked']))
{
// Amount net
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">';
print '</td>';
}
if (! empty($arrayfields['f.tva']['checked']))
{
// Amount Vat
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">';
print '</td>';
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
// Amount
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">';
print '</td>';
}
if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
{
// Payment term
print '<td class="liste_titre" align="right">';
print $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
print "</td>";
}
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
{
// Payment mode
print '<td class="liste_titre" align="right">';
print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100');
print '</td>';
}
if (! empty($arrayfields['recurring']['checked']))
{
// Recurring or not
print '<td class="liste_titre" align="center">';
print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1);
print '</td>';
}
if (! empty($arrayfields['f.frequency']['checked']))
{
// Recurring or not
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">';
print '</td>';
}
if (! empty($arrayfields['f.unit_frequency']['checked']))
{
// Frequency unit
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">';
print '</td>';
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
{
// Nb generation
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Date invoice
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '</td>';
}
// Date due
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_date_when" value="'.$day_date_when.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_date_when" value="'.$month_date_when.'">';
$formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5);
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['f.datec']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Status
if (! empty($arrayfields['status']['checked']))
{
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Action column
print '<td class="liste_titre" align="middle">';
$searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n";
print "</tr>\n";
if ($num > 0)
{
$i=0;
$totalarray=array();
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
if (empty($objp)) break;
$companystatic->id=$objp->socid;
$companystatic->name=$objp->name;
$invoicerectmp->id=$objp->id;
$invoicerectmp->frequency=$objp->frequency;
$invoicerectmp->suspend=$objp->suspend;
$invoicerectmp->unit_frequency=$objp->unit_frequency;
print '<tr class="oddeven">';
if (! empty($arrayfields['f.titre']['checked']))
{
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/fiche-rec.php?id='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
print "</a></td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.total']['checked']))
{
print '<td align="right">'.price($objp->total).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total';
$totalarray['val']['f.total'] += $objp->total;
}
if (! empty($arrayfields['f.tva']['checked']))
{
print '<td align="right">'.price($objp->total_vat).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva';
$totalarray['val']['f.tva'] += $objp->total_vat;
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
print '<td align="right">'.price($objp->total_ttc).'</td>'."\n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc';
$totalarray['val']['f.total_ttc'] += $objp->total_ttc;
}
// Payment term
if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
{
print '<td align="right">';
print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
print '</td>'."\n";
if (! $i) $totalarray['nbfield']++;
}
// Payment mode
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
{
print '<td align="right">';
print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
print '</td>'."\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['recurring']['checked']))
{
print '<td align="center">'.yn($objp->frequency?1:0).'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.frequency']['checked']))
{
print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.unit_frequency']['checked']))
{
print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.nb_gen_done']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td align="center">';
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->datec),'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->tms),'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['status']['checked']))
{
print '<td align="center">';
print $invoicerectmp->getLibStatut(3,0);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action column
print '<td align="center">';
if ($user->rights->facture->creer)
{
if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
{
print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$objp->socid.'&amp;fac_rec='.$objp->facid.'">';
print $langs->trans("CreateBill").'</a>';
}
else
{
print $langs->trans("DateIsNotEnough");
}
}
else
{
print "&nbsp;";
}
if (! $i) $totalarray['nbfield']++;
print "</td>";
print "</tr>\n";
$i++;
}
}
else
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
//var_dump($totalarray);
// Show total line
if (isset($totalarray['pos']))
{
print '<tr class="liste_total">';
$i=0;
while ($i < $totalarray['nbfield'])
{
$i++;
if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
else
{
if ($i == 1)
{
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
}
else print '<td></td>';
}
}
print '</tr>';
}
print "</table>";
print "</div>";
print "</form>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
llxFooter();
$db->close();

View File

@ -95,8 +95,10 @@ $month_lim = GETPOST('month_lim','int');
$year_lim = GETPOST('year_lim','int');
$option = GETPOST('option');
if ($option == 'late') $filter = 'paye:0';
$filtre = GETPOST('filtre');
if ($option == 'late') {
$search_status = '1';
}
$filtre = GETPOST('filtre','alpha');
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
@ -110,8 +112,8 @@ if (! $sortfield) $sortfield='f.datef';
$pageprev = $page - 1;
$pagenext = $page + 1;
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$contextpage='invoicelist';
// Initialize technical object to manage context to save list fields
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicelist';
// Security check
$fieldid = (! empty($ref)?'facnumber':'rowid');
@ -172,7 +174,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -387,7 +389,7 @@ if ($search_user > 0)
$sql.= ' WHERE f.fk_soc = s.rowid';
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category);
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
if ($userid)
{
@ -400,7 +402,7 @@ if ($filtre)
foreach ($aFilter as $filter)
{
$filt = explode(':', $filter);
$sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]);
$sql .= ' AND ' . $db->escape(trim($filt[0])) . ' = ' . $db->escape(trim($filt[1]));
}
}
if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref);
@ -434,7 +436,7 @@ if ($search_status != '' && $search_status >= 0)
if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed)
if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned
}
if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode;
if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode);
if ($month > 0)
{
if ($year > 0 && empty($day))
@ -462,7 +464,6 @@ else if ($year_lim > 0)
$sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'";
}
if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'";
if ($filter == 'paye:0') $sql.= " AND f.fk_statut = 1";
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale;
if ($search_user > 0)
{
@ -494,7 +495,7 @@ if (! $sall)
$sql.= ' f.datef, f.date_lim_reglement,';
$sql.= ' f.paye, f.fk_statut,';
$sql.= ' f.datec, f.tms,';
$sql.= ' s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.code_client, s.client, typent.code,';
$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.code_client, s.client, typent.code,';
$sql.= ' state.code_departement, state.nom';
foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by
@ -606,6 +607,7 @@ if ($resql)
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit);

View File

@ -60,7 +60,7 @@ if ($action == 'setnote' && $user->rights->facture->paiement)
$db->begin();
$object->fetch($id);
$result = $object->update_note(GETPOST('note'));
$result = $object->update_note(GETPOST('note','none'));
if ($result > 0)
{
$db->commit();

View File

@ -478,20 +478,20 @@ class RemiseCheque extends CommonObject
return "";
}
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
function load_board($user)
{
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
$sql = "SELECT b.rowid, b.datev as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
@ -500,28 +500,28 @@ class RemiseCheque extends CommonObject
$sql.= " AND b.fk_type = 'CHQ'";
$sql.= " AND b.fk_bordereau = 0";
$sql.= " AND b.amount > 0";
$resql=$this->db->query($sql);
if ($resql)
{
$langs->load("banks");
$now=dol_now();
$response = new WorkboardResponse();
$response->warning_delay=$conf->bank->cheque->warning_delay/60/60/24;
$response->label=$langs->trans("BankChecksToReceipt");
$response->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank';
$response->img=img_object('',"payment");
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->cheque->warning_delay)) {
$response->nbtodolate++;
}
}
return $response;
}
else
@ -531,6 +531,45 @@ class RemiseCheque extends CommonObject
return -1;
}
}
/**
* Charge indicateurs this->nb de tableau de bord
*
* @return int <0 if ko, >0 if ok
*/
function load_state_board()
{
global $user;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
$sql = "SELECT count(b.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
$sql.= " AND b.fk_type = 'CHQ'";
$sql.= " AND b.amount > 0";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["cheques"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/**

View File

@ -953,6 +953,7 @@ class BonPrelevement extends CommonObject
{
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
$this->id = $prev_id;
$this->ref = $ref;
}
else
{

View File

@ -80,7 +80,7 @@ if ($action == 'create')
}
else
{
setEventMessages($langs->trans("DirectDebitOrderCreated"), null);
setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
}
}

View File

@ -145,9 +145,9 @@ if ($prev_id > 0 || $ref)
// List of invoices
$sql = "SELECT pf.rowid";
$sql.= ",f.rowid as facid, f.facnumber as ref, f.total_ttc";
$sql.= ", s.rowid as socid, s.nom as name, pl.statut";
$sql = "SELECT pf.rowid,";
$sql.= " f.rowid as facid, f.facnumber as ref, f.total_ttc,";
$sql.= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture as pf";
@ -202,14 +202,14 @@ if ($result)
print '<tr class="liste_titre">';
print_liste_field_titre("Bill",$_SERVER["PHP_SELF"],"p.ref",'',$param,'',$sortfield,$sortorder);
print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom",'',$param,'',$sortfield,$sortorder);
print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre("AmountInvoice",$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre("AmountRequested",$_SERVER["PHP_SELF"],"pl.amount_requested","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre("StatusDebitCredit",$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre('');
print "</tr>\n";
$var=false;
$total = 0;
$totalinvoices = 0;
$totalamount_requested = 0;
while ($i < min($num, $limit))
{
@ -231,9 +231,12 @@ if ($result)
print $thirdpartytmp->getNomUrl(1);
print "</td>\n";
// Amount
// Amount of invoice
print '<td align="right">'.price($obj->total_ttc)."</td>\n";
// Amount requested
print '<td align="right">'.price($obj->amount_requested)."</td>\n";
// Status of requests
print '<td align="center">';
@ -256,7 +259,8 @@ if ($result)
print "</tr>\n";
$total += $obj->total_ttc;
$totalinvoices += $obj->total_ttc;
$totalamount_requested += $obj->amount_requested;
$i++;
}
@ -267,8 +271,11 @@ if ($result)
print '<td>'.$langs->trans("Total").'</td>';
print '<td>&nbsp;</td>';
print '<td align="right">';
if ($total != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");
print price($total);
//if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); // It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only.
if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");
print "</td>\n";
print '<td align="right">';
print price($totalamount_requested);
print "</td>\n";
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';

View File

@ -214,6 +214,12 @@ if ($action == 'create')
$pastmonthyear--;
}
$datespmonth = GETPOST('datespmonth', 'int');
$datespday = GETPOST('datespday', 'int');
$datespyear = GETPOST('datespyear', 'int');
$dateepmonth = GETPOST('dateepmonth', 'int');
$dateepday = GETPOST('dateepday', 'int');
$dateepyear = GETPOST('dateepyear', 'int');
$datesp=dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
$dateep=dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
@ -253,7 +259,7 @@ if ($action == 'create')
// Label
print '<tr><td>';
print fieldLabel('Label','label',1).'</td><td>';
print '<input name="label" id="label" class="minwidth300" value="'.($_POST["label"]?GETPOST("label",'',2):$langs->trans("SalaryPayment")).'">';
print '<input name="label" id="label" class="minwidth300" value="'.(GETPOST("label")?GETPOST("label"):$langs->trans("SalaryPayment")).'">';
print '</td></tr>';
// Date start period

View File

@ -224,7 +224,7 @@ if (empty($reshook))
$action = 'create';
} else {
// Categories association
$contcats = GETPOST( 'contcats', 'array' );
$contcats = GETPOST( 'contcats', 'array');
$object->setCategories($contcats);
}
}
@ -383,7 +383,7 @@ if (empty($reshook))
$db->query( $sql );
// Then we add the associated categories
$categories = GETPOST( 'contcats', 'array' );
$categories = GETPOST( 'contcats', 'array');
$object->setCategories($categories);
$object->old_lastname='';
@ -396,6 +396,15 @@ if (empty($reshook))
$action = 'edit';
}
}
if (! $error && empty($errors))
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
}
}
}
@ -541,7 +550,7 @@ else
{
print '<tr><td><label for="socid">'.$langs->trans("ThirdParty").'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $objsoc->getNomUrl(1);
print $objsoc->getNomUrl(1, 'contact');
print '</td>';
print '<input type="hidden" name="socid" id="socid" value="'.$objsoc->id.'">';
print '</td></tr>';
@ -1063,7 +1072,7 @@ else
$objsoc->fetch($object->socid);
// Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ';
if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1);
if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1, 'contact');
else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany");
}
$morehtmlref.='</div>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2017 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
@ -91,7 +91,7 @@ $head = contact_prepare_head($object);
dol_fiche_head($head, 'ldap', $title, -1, 'contact');
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
@ -196,15 +196,11 @@ if ($result > 0)
}
else
{
dol_print_error('',$ldap->error);
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
print '</table>';
llxFooter();
$db->close();

View File

@ -160,7 +160,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}

View File

@ -676,7 +676,7 @@ if (empty($reshook))
$fk_unit = GETPOST('unit', 'alpha');
$objectline->description=GETPOST('product_desc');
$objectline->description=GETPOST('product_desc','none');
$objectline->price_ht=GETPOST('elprice');
$objectline->subprice=GETPOST('elprice');
$objectline->qty=GETPOST('elqty');
@ -918,51 +918,17 @@ if (empty($reshook))
}
}
// Generation doc (depuis lien ou depuis cartouche doc)
else if ($action == 'builddoc' && $user->rights->contrat->creer) {
if (GETPOST('model')) {
$object->setDocModel($user, GETPOST('model'));
}
// Define output language
$outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) {
$outputlangs = new Translate("", $conf);
$newlang = (GETPOST('lang_id','aZ09') ? GETPOST('lang_id','aZ09') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
}
// Remove file in doc form
else if ($action == 'remove_file' && $user->rights->contrat->creer) {
if ($object->id > 0) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$langs->load("other");
$upload_dir = $conf->contrat->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
}
}
/*
* Send mail
*/
// Actions to build doc
$upload_dir = $conf->contrat->dir_output;
$permissioncreate = $user->rights->contrat->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
$trigger_name='CONTRACT_SENTBYMAIL';
$paramname='id';
$mode='emailfromcontract';
$trackid='cont'.$object->id;
$trackid='con'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
@ -2164,136 +2130,13 @@ else
print '</div></div></div>';
}
/*
* Action presend
*/
if ($action == 'presend')
{
$object->fetch_projet();
$ref = dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_most_recent_file($conf->contrat->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($newlang);
$outputlangs->load('commercial');
}
// Build document if it not exists
if (! $file || ! is_readable($file)) {
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
dol_print_error($db, $object->error, $object->errors);
exit();
}
$fileparams = dol_most_recent_file($conf->contrat->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
}
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
print '<div class="clearboth"></div>';
print '<br>';
print load_fiche_titre($langs->trans('SendByMail'));
dol_fiche_head('');
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
$formmail->trackid='cont'.$object->id;
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id);
}
$formmail->withfrom = 1;
$liste = array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
$liste [$key] = $value;
$formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
$formmail->withtocc = $liste;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
if (empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendContractRef', '__CONTRACTREF__');
} else if (! empty($object->ref_client)) {
$formmail->withtopic = $outputlangs->trans('SendContractRef', '__CONTRACTREF__ (__REFCLIENT__)');
}
$formmail->withfile = 2;
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
// Array of substitutions
$formmail->withsubstit='AvailableVariables';
$formmail->setSubstitFromObject($object);
$datenextexpiration='';
foreach($object->lines as $line)
{
if ($line->statut != 4) continue;
if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue;
}
$formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$formmail->substit['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';
$custcontact = '';
$contactarr = array();
$contactarr = $object->liste_contact(- 1, 'external');
if (is_array($contactarr) && count($contactarr) > 0)
{
foreach ($contactarr as $contact)
{
if ($contact['libelle'] == $langs->trans('TypeContact_contract_external_CUSTOMER')) { // TODO Use code and not label
$contactstatic = new Contact($db);
$contactstatic->fetch($contact['id']);
$custcontact = $contactstatic->getFullName($langs, 1);
}
}
if (! empty($custcontact)) {
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
}
}
// Tableau des parametres complementaires
$formmail->param['action'] = 'send';
$formmail->param['models'] = 'contract_send';
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['contractid'] = $object->id;
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
// Init list of files
if (GETPOST("mode") == 'init') {
$formmail->clear_attached_files();
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
}
// Show form
print $formmail->get_form();
dol_fiche_end();
}
// Presend form
$modelmail='contract';
$defaulttopic='SendContractRef';
$diroutput = $conf->contrat->dir_output;
$trackid = 'con'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
}

View File

@ -538,11 +538,13 @@ class Contrat extends CommonObject
/**
* Load a contract from database
*
* @param int $id Id of contract to load
* @param string $ref Ref
* @return int <0 if KO, id of contract if OK
* @param int $id Id of contract to load
* @param string $ref Ref
* @param string $ref_customer Customer ref
* @param string $ref_supplier Supplier ref
* @return int <0 if KO, 0 if not found, Id of contract if OK
*/
function fetch($id,$ref='')
function fetch($id, $ref='', $ref_customer='', $ref_supplier='')
{
$sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,";
$sql.= " ref_supplier, ref_customer,";
@ -553,12 +555,20 @@ class Contrat extends CommonObject
$sql.= " fk_commercial_signature, fk_commercial_suivi,";
$sql.= " note_private, note_public, model_pdf, extraparams";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat";
if (! $id) $sql.=" WHERE entity IN (".getEntity('contract', 0).")";
else $sql.= " WHERE rowid=".$id;
if ($ref_customer)
{
$sql.= " AND ref_customer = '".$this->db->escape($ref_customer)."'";
}
if ($ref_supplier)
{
$sql.= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'";
}
if ($ref)
{
$sql.= " WHERE ref='".$this->db->escape($ref)."'";
$sql.= " AND entity IN (".getEntity('contract', 0).")";
$sql.= " AND ref='".$this->db->escape($ref)."'";
}
else $sql.= " WHERE rowid=".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -628,7 +638,7 @@ class Contrat extends CommonObject
{
dol_syslog(get_class($this)."::Fetch Erreur contrat non trouve");
$this->error="Contract not found";
return -2;
return 0;
}
}
else
@ -780,7 +790,7 @@ class Contrat extends CommonObject
}
// Selectionne les lignes contrat liees a aucun produit
$sql = "SELECT d.rowid, d.fk_contrat, d.statut, d.qty, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.rowid, d.remise_percent, d.subprice,";
$sql = "SELECT d.rowid, d.fk_contrat, d.statut, d.qty, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.rowid, d.remise_percent, d.subprice,";
$sql.= " d.total_ht,";
$sql.= " d.total_tva,";
$sql.= " d.total_localtax1,";
@ -818,6 +828,8 @@ class Contrat extends CommonObject
$line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx;
$line->localtax1_type = $objp->localtax1_type;
$line->localtax2_type = $objp->localtax2_type;
$line->subprice = $objp->subprice;
$line->remise_percent = $objp->remise_percent;
$line->price_ht = $objp->price_ht;
@ -924,7 +936,7 @@ class Contrat extends CommonObject
$sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,";
$sql.= " ref, entity, note_private, note_public, ref_customer, ref_supplier, ref_ext)";
$sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id;
$sql.= ", '".$this->db->idate($this->date_contrat)."'";
$sql.= ", ".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : "NULL");
$sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL");
$sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL");
$sql.= ",".($this->fk_project>0?$this->fk_project:"NULL");
@ -2701,6 +2713,8 @@ class ContratLigne extends CommonObjectLine
$sql.= " t.vat_src_code,";
$sql.= " t.localtax1_tx,";
$sql.= " t.localtax2_tx,";
$sql.= " t.localtax1_type,";
$sql.= " t.localtax2_type,";
$sql.= " t.qty,";
$sql.= " t.remise_percent,";
$sql.= " t.remise,";
@ -2754,6 +2768,8 @@ class ContratLigne extends CommonObjectLine
$this->vat_src_code = $obj->vat_src_code;
$this->localtax1_tx = $obj->localtax1_tx;
$this->localtax2_tx = $obj->localtax2_tx;
$this->localtax1_type = $obj->localtax1_type;
$this->localtax2_type = $obj->localtax2_type;
$this->qty = $obj->qty;
$this->remise_percent = $obj->remise_percent;
$this->remise = $obj->remise;
@ -2834,6 +2850,7 @@ class ContratLigne extends CommonObjectLine
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;
if (empty($this->remise_percent)) $this->remise_percent = 0;
// Check parameters
// Put here code to add control on parameters values

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
@ -47,12 +47,14 @@ $confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$search_name=GETPOST('search_name');
$search_email=GETPOST('search_email');
$search_town=GETPOST('search_town','alpha');
$search_zip=GETPOST('search_zip','alpha');
$search_state=trim(GETPOST("search_state"));
$search_country=GETPOST("search_country",'int');
$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
$search_contract=GETPOST('search_contract');
$search_ref_customer=GETPOST('search_ref_customer','alpha');
$search_ref_supplier=GETPOST('search_ref_supplier','alpha');
$sall=GETPOST('sall', 'alphanohtml');
$search_status=GETPOST('search_status');
@ -115,7 +117,8 @@ $arrayfields=array(
'c.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
'c.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
's.email'=>array('label'=>$langs->trans("ThirdPartyEmail"), 'checked'=>0),
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
@ -130,7 +133,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -155,12 +158,14 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$month='';
$year='';
$search_name="";
$search_town='';
$search_email="";
$search_town='';
$search_zip="";
$search_state="";
$search_type='';
$search_country='';
$search_contract="";
$search_ref_customer="";
$search_ref_supplier="";
$search_user='';
$search_sale='';
@ -197,7 +202,7 @@ llxHeader('', $langs->trans("Contracts"));
$sql = 'SELECT';
$sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,';
@ -244,7 +249,9 @@ else if ($year > 0)
$sql.= " AND c.date_contrat BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
}
if ($search_name) $sql .= natural_search('s.nom', $search_name);
if ($search_email) $sql .= natural_search('s.email', $search_name);
if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract);
if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer'), $search_ref_customer);
if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier);
if ($search_sale > 0)
{
@ -272,14 +279,11 @@ $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // No
$sql.=$hookmanager->resPrint;
$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,";
$sql.= ' s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql.= " typent.code,";
$sql.= " state.code_departement, state.nom";
// Add where from extra fields
foreach ($extrafields->attribute_label as $key => $val)
{
$sql .= ', ef.'.$key;
}
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
@ -324,6 +328,7 @@ if ($resql)
if ($sall != '') $param.='&sall='.$sall;
if ($search_contract != '') $param.='&search_contract='.$search_contract;
if ($search_name != '') $param.='&search_name='.$search_name;
if ($search_email != '') $param.='&search_email='.$search_email;
if ($search_ref_supplier != '') $param.='&search_ref_supplier='.$search_ref_supplier;
if ($search_sale != '') $param.='&search_sale=' .$search_sale;
if ($show_files) $param.='&show_files=' .$show_files;
@ -431,13 +436,13 @@ if ($resql)
if (! empty($arrayfields['c.ref_customer']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_ref_customer value="'.dol_escape_htmltag($search_ref_customer).'">';
print '<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).'">';
print '</td>';
}
if (! empty($arrayfields['c.ref_supplier']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_ref_supplier value="'.dol_escape_htmltag($search_ref_supplier).'">';
print '<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).'">';
print '</td>';
}
if (! empty($arrayfields['s.nom']['checked']))
@ -446,6 +451,12 @@ if ($resql)
print '<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
print '</td>';
}
if (! empty($arrayfields['s.email']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
print '</td>';
}
// Town
if (! empty($arrayfields['s.town']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.'"></td>';
// Zip
@ -542,7 +553,8 @@ if ($resql)
if (! empty($arrayfields['c.ref_customer']['checked'])) print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer","","$param",'',$sortfield,$sortorder);
if (! empty($arrayfields['c.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder);
if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email","","$param",'',$sortfield,$sortorder);
if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
@ -621,6 +633,10 @@ if ($resql)
{
print '<td><a href="../comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
}
if (! empty($arrayfields['s.email']['checked']))
{
print '<td>'.$obj->email.'</td>';
}
// Town
if (! empty($arrayfields['s.town']['checked']))
{

View File

@ -115,6 +115,11 @@ $companystatic=new Societe($db);
$arrayfields=array(
'c.ref'=>array('label'=>$langs->trans("Contract"), 'checked'=>1, 'position'=>80),
'p.description'=>array('label'=>$langs->trans("Service"), 'checked'=>1, 'position'=>80),
'cd.qty'=>array('label'=>$langs->trans("Qty"), 'checked'=>0, 'position'=>100),
'cd.total_ht'=>array('label'=>$langs->trans("TotalHT"), 'checked'=>0, 'position'=>100),
'cd.total_tva'=>array('label'=>$langs->trans("TotalVAT"), 'checked'=>0, 'position'=>100),
'cd.tva_tx'=>array('label'=>$langs->trans("VAT"), 'checked'=>0, 'position'=>100),
'cd.subprice'=>array('label'=>$langs->trans("PriceUHT"), 'checked'=>0, 'position'=>100),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>100),
'cd.date_ouverture_prevue'=>array('label'=>$langs->trans("DateStartPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode == "0")),
'cd.date_ouverture'=>array('label'=>$langs->trans("DateStartRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode > 0)),
@ -129,7 +134,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
{
foreach($extrafields->attribute_label as $key => $val)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -199,7 +204,11 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk
$sql.= " cd.date_ouverture_prevue,";
$sql.= " cd.date_ouverture,";
$sql.= " cd.date_fin_validite,";
$sql.= " cd.date_cloture,";
$sql.= " cd.qty,";
$sql.= " cd.total_ht,";
$sql.= " cd.total_tva,";
$sql.= " cd.tva_tx,";
$sql.= " cd.subprice,";
//$sql.= " cd.date_c as date_creation,";
$sql.= " cd.tms as date_update";
// Add fields from extrafields
@ -285,7 +294,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) &&
llxHeader(null, $langs->trans("Services"));
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_contract) $param.='&amp;search_contract='.urlencode($search_contract);
if ($search_name) $param.='&amp;search_name='.urlencode($search_name);
@ -326,6 +335,7 @@ print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$title=$langs->trans("ListOfServices");
if ($mode == "0") $title=$langs->trans("ListOfInactiveServices"); // Must use == "0"
@ -376,6 +386,11 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
print '<tr class="liste_titre">';
if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'],$_SERVER["PHP_SELF"],"c.ref","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['p.description']['checked'])) print_liste_field_titre($arrayfields['p.description']['label'],$_SERVER["PHP_SELF"],"p.description","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['cd.qty']['checked'])) print_liste_field_titre($arrayfields['cd.qty']['label'],$_SERVER["PHP_SELF"],"cd.qty","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['cd.total_ht']['checked'])) print_liste_field_titre($arrayfields['cd.total_ht']['label'],$_SERVER["PHP_SELF"],"cd.total_ht","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['cd.total_tva']['checked'])) print_liste_field_titre($arrayfields['cd.total_tva']['label'],$_SERVER["PHP_SELF"],"cd.total_tva","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['cd.tva_tx']['checked'])) print_liste_field_titre($arrayfields['cd.tva_tx']['label'],$_SERVER["PHP_SELF"],"cd.tva_tx","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['cd.subprice']['checked'])) print_liste_field_titre($arrayfields['cd.subprice']['label'],$_SERVER["PHP_SELF"],"cd.subprice","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'],$_SERVER["PHP_SELF"],"cd.date_ouverture_prevue","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['cd.date_ouverture']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture']['label'],$_SERVER["PHP_SELF"],"cd.date_ouverture","",$param,'align="center"',$sortfield,$sortorder);
@ -421,6 +436,32 @@ if (! empty($arrayfields['p.description']['checked']))
print '<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).'">';
print '</td>';
}
// detail lines
if (! empty($arrayfields['cd.qty']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
if (! empty($arrayfields['cd.total_ht']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
if (! empty($arrayfields['cd.total_tva']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
if (! empty($arrayfields['cd.tva_tx']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
if (! empty($arrayfields['cd.subprice']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Third party
if (! empty($arrayfields['s.nom']['checked']))
{
@ -428,6 +469,8 @@ if (! empty($arrayfields['s.nom']['checked']))
print '<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
print '</td>';
}
if (! empty($arrayfields['cd.date_ouverture_prevue']['checked']))
{
print '<td class="liste_titre" align="center">';
@ -576,6 +619,38 @@ while ($i < min($num,$limit))
print '</td>';
}
if (! empty($arrayfields['cd.qty']['checked']))
{
print '<td>';
print $obj->qty;
print '</td>';
}
if (! empty($arrayfields['cd.total_ht']['checked']))
{
print '<td>';
print price($obj->total_ht);
print '</td>';
}
if (! empty($arrayfields['cd.total_tva']['checked']))
{
print '<td>';
print price($obj->total_tva);
print '</td>';
}
if (! empty($arrayfields['cd.tva_tx']['checked']))
{
print '<td>';
print price2num($obj->tva_tx).'%';
print '</td>';
}
if (! empty($arrayfields['cd.subprice']['checked']))
{
print '<td>';
print price($obj->subprice);
print '</td>';
}
// Third party
if (! empty($arrayfields['s.nom']['checked']))
{

View File

@ -159,6 +159,7 @@ if ($action == 'add')
$params['options'][$key] = $value;
}
}
$result=$extrafields->addExtraField(
GETPOST('attrname', 'alpha'),
GETPOST('label', 'alpha'),
@ -172,7 +173,7 @@ if ($action == 'add')
$params,
(GETPOST('alwayseditable', 'alpha')?1:0),
(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
(GETPOST('list', 'alpha')?1:0),
GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
(GETPOST('ishidden', 'alpha')?1:0),
GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:''),
@ -334,7 +335,7 @@ if ($action == 'update')
$params,
(GETPOST('alwayseditable', 'alpha')?1:0),
(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
(GETPOST('list', 'alpha')?1:0),
GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
(GETPOST('ishidden', 'alpha')?1:0),
GETPOST('default_value','alpha'),
GETPOST('computed_value','alpha'),

View File

@ -28,7 +28,7 @@
// $cancel must be defined
// $id or $ref must be defined (object is loaded in this file with fetch)
if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && empty($cancel))
if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0))
{
$ret = $object->fetch($id, $ref);
if ($ret > 0)

View File

@ -64,36 +64,63 @@ if (! $error && $massaction == 'confirm_presend')
$langs->load("mails");
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (!$error && !isset($user->email))
{
$error++;
setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings');
}
$listofobjectid=array();
$listofobjectthirdparties=array();
$listofobjectref=array();
if (! $error)
{
$thirdparty=new Societe($db);
if ($objecttmp->element == 'expensereport') $thirdparty=new User($db);
$objecttmp=new $objectclass($db);
$listofobjectid=array();
$listofobjectthirdparties=array();
$listofobjectref=array();
foreach($toselect as $toselectid)
{
$objecttmp=new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use
$objecttmp=new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
$listofobjectid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id;
if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author;
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
$listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
}
}
//var_dump($listofobjectthirdparties);exit;
}
// Check mandatory parameters
if (empty($user->email))
{
$error++;
setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings');
$massaction='presend';
}
// Loop on each thirdparty
$receiver=$_POST['receiver'];
if (! is_array($receiver))
{
if (empty($receiver) || $receiver == '-1') $receiver=array();
else $receiver=array($receiver);
}
if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings');
$massaction='presend';
}
if (! GETPOST('subject','none'))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings');
$massaction='presend';
}
// Loop on each recipient/thirdparty
if (! $error)
{
foreach ($listofobjectthirdparties as $thirdpartyid)
{
$result = $thirdparty->fetch($thirdpartyid);
@ -109,12 +136,6 @@ if (! $error && $massaction == 'confirm_presend')
$sendtoid = array();
// Define $sendto
$receiver=$_POST['receiver'];
if (! is_array($receiver))
{
if ($receiver == '-1') $receiver=array();
else $receiver=array($receiver);
}
$tmparray=array();
if (trim($_POST['sendto']))
{
@ -126,11 +147,11 @@ if (! $error && $massaction == 'confirm_presend')
foreach($receiver as $key=>$val)
{
// Recipient was provided from combo list
if ($val == 'thirdparty') // Id of third party
if ($val == 'thirdparty') // Id of third party or user
{
$tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
}
elseif ($val) // Id du contact
elseif ($val && method_exists($thirdparty, 'contact_get_property')) // Id of contact
{
$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
$sendtoid[] = $val;
@ -203,8 +224,17 @@ if (! $error && $massaction == 'confirm_presend')
// Test recipient
if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send)
{
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
if ($object->element == 'expensereport')
{
$fuser = new User($db);
$fuser->fetch($object->fk_user_author);
$sendto = $fuser->email;
}
else
{
$object->fetch_thirdparty();
$sendto = $object->thirdparty->email;
}
}
if (empty($sendto))
@ -292,100 +322,129 @@ if (! $error && $massaction == 'confirm_presend')
if ($objectclass == 'CommandeFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO);
if ($objectclass == 'FactureFournisseur') $sendtocc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO);
$objecttmp=new $objectclass($db);
$objecttmp->thirdparty = $thirdparty;
// Make substitution in email content
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp);
$substitutionarray['__ID__'] = join(', ',array_keys($listofqualifiedid));
$substitutionarray['__EMAIL__'] = $thirdparty->email;
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__REF__'] = join(', ',$listofqualifiedref);
$parameters=array('mode'=>'formemail');
complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters);
$subject=make_substitutions($subject, $substitutionarray);
$message=make_substitutions($message, $substitutionarray);
$filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
//var_dump($filepath);
// Send mail (substitutionarray must be done just before this)
require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1);
if ($mailfile->error)
// $listofqualifiedid is array with key = object id of qualified objects for the current thirdparty
$oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
$looparray=array();
if (! $oneemailperrecipient)
{
$resaction.='<div class="error">'.$mailfile->error.'</div>';
$looparray = $listofqualifiedid;
}
else
{
$result=$mailfile->sendfile();
if ($result)
{
$resaction.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)).'<br>'; // Must not contain "
$error=0;
// Insert logs into agenda
foreach($listofqualifiedid as $objid => $object)
{
/*if ($objectclass == 'Propale') $actiontypecode='AC_PROP';
if ($objectclass == 'Commande') $actiontypecode='AC_COM';
if ($objectclass == 'Facture') $actiontypecode='AC_FAC';
if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO';
if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD';
if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
if ($message)
{
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $message);
}
$actionmsg2='';
// Initialisation donnees
$object->sendtoid = 0;
$object->actionmsg = $actionmsg; // Long text
$object->actionmsg2 = $actionmsg2; // Short text
$object->fk_element = $objid;
$object->elementtype = $object->element;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $errors=$interface->errors; }
// Fin appel triggers
if ($error)
{
setEventMessages($db->lasterror(), $errors, 'errors');
dol_syslog("Error in trigger BILL_SENTBYMAIL ".$db->lasterror(), LOG_ERR);
}
$nbsent++;
}
}
else
{
$langs->load("other");
if ($mailfile->error)
{
$resaction.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$resaction.='<br><div class="error">'.$mailfile->error.'</div>';
}
else
{
$resaction.='<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
}
}
$objectforloop=new $objectclass($db);
$objectforloop->thirdparty = $thirdparty;
$looparray[0]=$objectforloop;
}
//var_dump($looparray);exit;
foreach ($looparray as $objecttmp) // $objecttmp is a real object or an empty if we choose to send one email per thirdparty instead of per record
{
// Make substitution in email content
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp);
$substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ',array_keys($listofqualifiedid)) : $objecttmp->id);
$substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ',$listofqualifiedref) : $objecttmp->ref);
$substitutionarray['__EMAIL__'] = $thirdparty->email;
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$parameters=array('mode'=>'formemail');
complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters);
$subject=make_substitutions($subject, $substitutionarray);
$message=make_substitutions($message, $substitutionarray);
$filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
//var_dump($filepath);
// Send mail (substitutionarray must be done just before this)
require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1);
if ($mailfile->error)
{
$resaction.='<div class="error">'.$mailfile->error.'</div>';
}
else
{
$result=$mailfile->sendfile();
if ($result)
{
$resaction.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)).'<br>'; // Must not contain "
$error=0;
// Insert logs into agenda
foreach($listofqualifiedid as $objid => $object)
{
/*if ($objectclass == 'Propale') $actiontypecode='AC_PROP';
if ($objectclass == 'Commande') $actiontypecode='AC_COM';
if ($objectclass == 'Facture') $actiontypecode='AC_FAC';
if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO';
if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD';
if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
if ($message)
{
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $message);
}
$actionmsg2='';
// Initialisation donnees
$object->sendtoid = 0;
$object->actionmsg = $actionmsg; // Long text
$object->actionmsg2 = $actionmsg2; // Short text
$object->fk_element = $objid;
$object->elementtype = $object->element;
$triggername = strtoupper(get_class($object)) .'_SENTBYMAIL';
if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL';
if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYEMAIL';
if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYEMAIL';
if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYEMAIL';
if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYEMAIL';
if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYEMAIL';
if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL';
if (! empty($trigger_name))
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers($trigger_name, $object, $user, $langs, $conf);
if ($result < 0) { $error++; $errors=$interface->errors; }
// Fin appel triggers
if ($error)
{
setEventMessages($db->lasterror(), $errors, 'errors');
dol_syslog("Error in trigger ".$trigger_name.' '.$db->lasterror(), LOG_ERR);
}
}
$nbsent++;
}
}
else
{
$langs->load("other");
if ($mailfile->error)
{
$resaction.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$resaction.='<br><div class="error">'.$mailfile->error.'</div>';
}
else
{
$resaction.='<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
}
}
}
}
}
}
@ -407,10 +466,10 @@ if (! $error && $massaction == 'confirm_presend')
//setEventMessages($langs->trans("EMailSentToNRecipients", 0), null, 'warnings'); // May be object has no generated PDF file
setEventMessages($resaction, null, 'warnings');
}
}
$action='list';
$massaction='';
$action='list';
$massaction='';
}
}
if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search'))
@ -481,7 +540,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
$filename=preg_replace('/\s/','_',$filename);
// Save merged file
if ($filter=='paye:0')
if (in_array($object->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
{
if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
@ -553,7 +612,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
$filename=preg_replace('/\s/','_',$filename);
// Save merged file
if ($filter=='paye:0')
if (in_array($object->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
{
if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
@ -592,7 +651,7 @@ if ($action == 'remove_file')
$action='';
}
// Validate records
// Validate records
if (! $error && $massaction == 'validate' && $permtocreate)
{
if ($object->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL))
@ -664,8 +723,19 @@ if (! $error && $massaction == 'delete' && $permtodelete)
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
// Refuse deletion for some status ?
/*
if ($objectclass == 'Facture' && $objecttmp->status == Facture::STATUS_DRAFT)
{
$langs->load("errors");
$nbignored++;
$resaction.='<div class="error">'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$object->ref).'</div><br>';
continue;
}*/
if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
else $result = $objecttmp->delete($user);
if ($result <= 0)
{
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');

View File

@ -18,13 +18,13 @@
/**
* \file htdocs/core/actions_sendmails.inc.php
* \brief Code for actions on sending mails from object page
*/
* \brief Code for actions on sending mails from object page
*/
// $mysoc must be defined
// $id must be defined
// $paramname must be defined
// $mode must be defined
// $mode must be defined (used to know the automatic BCC to add)
// $trigger_name must be set (can be '')
// $actiontypecode can be set
// $object and $uobject may be defined
@ -113,13 +113,18 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$result=$object->fetch($id);
$sendtosocid=0; // Thirdparty on object
if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe')
if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member')))
{
$result=$object->fetch_thirdparty();
if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok
$thirdparty=$object->thirdparty;
$sendtosocid=$thirdparty->id;
}
else if ($object->element == 'member')
{
$thirdparty=$object;
if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
}
else if ($object->element == 'societe')
{
$thirdparty=$object;
@ -268,12 +273,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
$sendtobcc= GETPOST('sendtoccc');
if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
if ($mode == 'emailfromsupplierproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
if ($mode == 'emailfromsupplierorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
if ($mode == 'emailfromsupplierinvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
// Autocomplete the $sendtobcc
// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
if (! empty($autocopy))
{
$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy));
}
$deliveryreceipt = $_POST['deliveryreceipt'];
@ -348,18 +353,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'';
// Add specific substitution for contracts
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
$datenextexpiration='';
foreach($object->lines as $line)
{
if ($line->statut != 4) continue;
if ($line->date_fin_prevue > $datenextexpiration) $datenextexpiration = $line->date_fin_prevue;
}
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
$substitutionarray['__CONTRACT_NEXT_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
$parameters=array('mode'=>'formemail');
complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
@ -367,6 +360,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$subject=make_substitutions($subject, $substitutionarray);
$message=make_substitutions($message, $substitutionarray);
if (method_exists($object, 'makeSubstitution'))
{
$subject = $object->makeSubstitution($subject);
$message = $object->makeSubstitution($message);
}
// Send mail (substitutionarray must be done just before this)
if (empty($sendcontext)) $sendcontext = 'standard';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext);
@ -482,7 +481,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
else
{
$langs->load("other");
setEventMessages($langs->trans('ErrorFailedToReadEntity',$object->element), null, 'errors');
setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors');
dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
$action = 'presend';
}

View File

@ -32,7 +32,7 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel
{
if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public');
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// Set public note
@ -40,6 +40,6 @@ else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('
{
if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private');
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}

View File

@ -0,0 +1,60 @@
<?php
/* Copyright (C) 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/>.
*/
/**
* \file htdocs/core/ajax/vatrates.php
* \brief File to load vat rates combobox
*/
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';
$id = GETPOST('id','int');
/*
* View
*/
top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (! empty($id))
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$account=new Account($db);
$result = $account->fetch($id);
if ($result<0) {
$return['value'] = '';
$return['num'] = $result;
$return['error'] = $account->errors[0];
} else {
$return['value'] = $account->currency_code;
$return['num'] = $result;
$return['error'] = '';
}
echo json_encode($return);
}

View File

@ -77,7 +77,6 @@ class box_activity extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$totalMnt = 0;
$totalnb = 0;
$line = 0;
$cachetime = 3600;
@ -95,8 +94,6 @@ class box_activity extends ModeleBoxes
// compute the year limit to show
$tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m");
$cumuldata = array();
// list the summary of the propals
if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
@ -146,11 +143,10 @@ class box_activity extends ModeleBoxes
$data = dol_readcachefile($cachedir, $filename);
}
$cumuldata=array_merge($cumuldata, $data);
if (! empty($data))
{
$j=0;
while ($line < count($cumuldata))
while ($j < count($data))
{
$this->info_box_contents[$line][0] = array(
'td' => 'align="left" width="16"',
@ -176,7 +172,6 @@ class box_activity extends ModeleBoxes
'td' => 'class="right"',
'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
);
$totalMnt += $data[$j]->Mnttot;
$this->info_box_contents[$line][4] = array(
'td' => 'align="right" width="18"',
'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3),
@ -231,10 +226,9 @@ class box_activity extends ModeleBoxes
$data = dol_readcachefile($cachedir, $filename);
}
$cumuldata=array_merge($cumuldata, $data);
if (! empty($data)) {
$j=0;
while ($line < count($cumuldata)) {
while ($j < count($data)) {
$this->info_box_contents[$line][0] = array(
'td' => 'align="left" width="16"',
'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;viewstatut=".$data[$j]->fk_statut,
@ -259,7 +253,6 @@ class box_activity extends ModeleBoxes
'td' => 'class="right"',
'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
);
$totalMnt += $data[$j]->Mnttot;
$this->info_box_contents[$line][4] = array(
'td' => 'align="right" width="18"',
'text' => $commandestatic->LibStatut($data[$j]->fk_statut,0,3),
@ -290,11 +283,11 @@ class box_activity extends ModeleBoxes
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ")";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " WHERE f.entity IN (".getEntity('facture').')';
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1";
$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1";
$sql.= " GROUP BY f.fk_statut";
$sql.= " ORDER BY f.fk_statut DESC";
@ -317,10 +310,9 @@ class box_activity extends ModeleBoxes
$data = dol_readcachefile($cachedir, $filename);
}
$cumuldata=array_merge($cumuldata, $data);
if (! empty($data)) {
$j=0;
while ($line < count($cumuldata)) {
while ($j < count($data)) {
$billurl="search_status=2&amp;paye=1&amp;year=".$data[$j]->annee;
$this->info_box_contents[$line][0] = array(
'td' => 'align="left" width="16"',
@ -347,10 +339,8 @@ class box_activity extends ModeleBoxes
);
// We add only for the current year
if ($data[$j]->annee == date("Y")) {
$totalnb += $data[$j]->nb;
$totalMnt += $data[$j]->Mnttot;
}
$totalnb += $data[$j]->nb;
$this->info_box_contents[$line][4] = array(
'td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3),
@ -371,12 +361,13 @@ class box_activity extends ModeleBoxes
$refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
$data = array();
if ($refresh) {
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " WHERE f.entity IN (".getEntity('facture').')';
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND paye=0";
$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0";
$sql.= " GROUP BY f.fk_statut";
$sql.= " ORDER BY f.fk_statut DESC";
@ -399,11 +390,11 @@ class box_activity extends ModeleBoxes
$data = dol_readcachefile($cachedir, $filename);
}
$cumuldata=array_merge($cumuldata, $data);
if (! empty($data)) {
$j=0;
$alreadypaid=-1;
while ($line < count($cumuldata)) {
$j=0;
while ($j < count($data)) {
$billurl="search_status=".$data[$j]->fk_statut."&amp;paye=0";
$this->info_box_contents[$line][0] = array(
'td' => 'align="left" width="16"',
@ -428,10 +419,9 @@ class box_activity extends ModeleBoxes
'td' => 'class="right"',
'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
);
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$line][4] = array(
'td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3),
'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid),
);
$line++;
$j++;
@ -441,16 +431,11 @@ class box_activity extends ModeleBoxes
'td' => 'align="center"',
'text'=>$langs->trans("NoRecordedInvoices"),
);
} else {
$this->info_box_contents[0][0] = array(
'td' => '',
'maxlength'=>500, 'text' => ($db->error().' sql='.$sql),
);
}
}
// Add the sum in the bottom of the boxes
$this->info_box_contents[$line][0] = array('tr' => 'class="liste_total"');
$this->info_box_contents[$line][0] = array('tr' => 'class="liste_total_wrap"');
$this->info_box_contents[$line][1] = array('td' => 'align="left" class="liste_total" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead);
$this->info_box_contents[$line][2] = array('td' => 'align="right" class="liste_total" ', 'text' => $totalnb);
$this->info_box_contents[$line][3] = array('td' => 'align="right" class="liste_total" ', 'text' => '');

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2017 Nicolas Zabouri <info@inovea-conseil.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
@ -91,7 +92,7 @@ class box_services_contracts extends ModeleBoxes
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= "INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= ")";
$sql.= " WHERE c.entity = ".$conf->entity;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;

View File

@ -286,7 +286,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
if (isset($contents[$i]))
{
// TR
if (isset($contents[$i][0]['tr'])) $out.= '<tr class="tdtop" '.$contents[$i][0]['tr'].'>';
if (isset($contents[$i][0]['tr'])) $out.= '<tr '.$contents[$i][0]['tr'].'>';
else $out.= '<tr class="oddeven">';
// Loop on each TD

View File

@ -418,6 +418,21 @@ abstract class CommonDocGenerator
$resarray[$array_key.'_total_discount_ht'] = '';
}
// Fetch project information if there is a project assigned to this object
if ($object->element != "project" && ! empty($object->fk_project) && $object->fk_project > 0)
{
if (! is_object($object->project))
{
$object->fetch_projet();
}
$resarray[$array_key.'_project_ref'] = $object->project->ref;
$resarray[$array_key.'_project_title'] = $object->project->title;
$resarray[$array_key.'_project_description'] = $object->project->description;
$resarray[$array_key.'_project_date_start'] = dol_print_date($object->project->date_start, 'day');
$resarray[$array_key.'_project_date_end'] = dol_print_date($object->project->date_end, 'day');
}
// Add vat by rates
if (is_array($object->lines) && count($object->lines)>0)
{

View File

@ -51,7 +51,7 @@ abstract class CommonInvoice extends CommonObject
const TYPE_DEPOSIT = 3;
/**
* Proforma invoice.
* Proforma invoice.
* @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice !
*/
const TYPE_PROFORMA = 4;
@ -89,7 +89,7 @@ abstract class CommonInvoice extends CommonObject
*/
const STATUS_ABANDONED = 3;
/**
* Return remain amount to pay. Property ->id and ->total_ttc must be set.
* This does not include open direct debit requests.
@ -141,7 +141,7 @@ abstract class CommonInvoice extends CommonObject
return -1;
}
}
/**
* Return amount (with tax) of all deposits invoices used by invoice.
* Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended).
@ -154,11 +154,11 @@ abstract class CommonInvoice extends CommonObject
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
// TODO
return 0;
return 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getSumDepositsUsed($this, $multicurrency);
if ($result >= 0)
@ -185,9 +185,9 @@ abstract class CommonInvoice extends CommonObject
// TODO
return 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
if ($result >= 0)
@ -200,7 +200,7 @@ abstract class CommonInvoice extends CommonObject
return -1;
}
}
/**
* Renvoie tableau des ids de facture avoir issus de la facture
*
@ -309,7 +309,7 @@ abstract class CommonInvoice extends CommonObject
* @param int $paye Status field paye
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto
* @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
* @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise)
* @param int $type Type invoice
* @return string Libelle du statut
*/
@ -418,7 +418,7 @@ abstract class CommonInvoice extends CommonObject
if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0');
if (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5');
if (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
if ($alreadypaid <= 0)
if ($alreadypaid <= 0)
{
if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1');
return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1');
@ -497,13 +497,13 @@ abstract class CommonInvoice extends CommonObject
}
elseif($cdr_type == 2 && !empty($cdr_nbjour)) // Application de la règle, le N du mois courant ou suivant
{
$date_piece = dol_mktime(0,0,0,date('m', $this->date),date('d', $this->date),date('Y', $this->date)); // Sans les heures minutes et secondes
$date_lim_current = dol_mktime(0,0,0,date('m', $this->date),$cdr_nbjour,date('Y', $this->date)); // Sans les heures minutes et secondes
$date_lim_next = strtotime(date('Y-m-d', $date_lim_current).' +1month');
$diff = $date_piece - $date_lim_current;
if($diff < 0) $datelim = $date_lim_current;
else $datelim = $date_lim_next;

View File

@ -1563,22 +1563,22 @@ abstract class CommonObject
switch ($this->element) {
case 'propal':
$this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
$this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, ($line->description?$line->description:$line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
break;
case 'commande':
$this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
$this->updateline($line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
break;
case 'facture':
$this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice);
$this->updateline($line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice);
break;
case 'supplier_proposal':
$this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->multicurrency_subprice);
$this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, ($line->description?$line->description:$line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->multicurrency_subprice);
break;
case 'order_supplier':
$this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
$this->updateline($line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
break;
case 'invoice_supplier':
$this->updateline($line->id, $line->desc, $line->subprice, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->qty, 0, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
$this->updateline($line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->qty, 0, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, false, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
break;
default:
dol_syslog(get_class($this).'::setMulticurrencyRate no updateline defined', LOG_DEBUG);
@ -4594,23 +4594,28 @@ abstract class CommonObject
}else {
$colspan='3';
}
switch($mode) {
case "view":
$value=$this->array_options["options_".$key];
break;
case "edit":
if (isset($_POST["options_" . $key])) {
if (is_array($_POST["options_" . $key])) {
// $_POST["options"] is an array but following code expects a comma separated string
$value = implode(",", $_POST["options_" . $key]);
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
$getposttemp = GETPOST('options_'.$key, 'none'); // GETPOST can get value from GET, POST or setup of default values.
if (isset($getposttemp)) {
if (is_array($getposttemp)) {
// $getposttemp is an array but following code expects a comma separated string
$value = implode(",", $getposttemp);
} else {
$value = $_POST["options_" . $key];
$value = $getposttemp;
}
} else {
$value = $this->array_options["options_" . $key];
$value = $this->array_options["options_" . $key]; // No GET, no POST, no default value, so we take value of object.
}
break;
}
//var_dump($value);
if ($extrafields->attribute_type[$key] == 'separate')
{
$out .= $extrafields->showSeparator($key);

View File

@ -254,13 +254,13 @@ class Conf
if (! isset($this->global->LDAP_KEY_GROUPS)) $this->global->LDAP_KEY_GROUPS=$this->global->LDAP_FIELD_FULLNAME;
if (! isset($this->global->LDAP_KEY_CONTACTS)) $this->global->LDAP_KEY_CONTACTS=$this->global->LDAP_FIELD_FULLNAME;
if (! isset($this->global->LDAP_KEY_MEMBERS)) $this->global->LDAP_KEY_MEMBERS=$this->global->LDAP_FIELD_FULLNAME;
if (! isset($this->global->LDAP_KEY_MEMBERS_TYPES)) $this->global->LDAP_KEY_MEMBERS_TYPES=$this->global->LDAP_FIELD_FULLNAME;
// Load translation object with current language
if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US";
// By default, we repeat info on all tabs
if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1;
if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1;
//if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1;
//if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1;
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;
@ -287,15 +287,18 @@ class Conf
{
foreach($this->modules_parts['dir'] as $module => $dirs)
{
foreach($dirs as $type => $name)
if (! empty($this->$module->enabled))
{
$subdir=($type=='temp'?'/temp':'');
// For multicompany sharings
$varname = 'multidir_'.$type;
$this->$module->$varname = array($this->entity => $rootfordata."/".$name.$subdir);
// For backward compatibility
$varname = 'dir_'.$type;
$this->$module->$varname = $rootfordata."/".$name.$subdir;
foreach($dirs as $type => $name)
{
$subdir=($type=='temp'?'/temp':'');
// For multicompany sharings
$varname = 'multidir_'.$type;
$this->$module->$varname = array($this->entity => $rootfordata."/".$name.$subdir);
// For backward compatibility
$varname = 'dir_'.$type;
$this->$module->$varname = $rootfordata."/".$name.$subdir;
}
}
}
}

View File

@ -78,6 +78,7 @@ class DiscountAbsolute
$sql = "SELECT sr.rowid, sr.fk_soc,";
$sql.= " sr.fk_user,";
$sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx,";
$sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,";
$sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.description,";
$sql.= " sr.datec,";
$sql.= " f.facnumber as ref_facture_source";
@ -97,9 +98,15 @@ class DiscountAbsolute
$this->id = $obj->rowid;
$this->fk_soc = $obj->fk_soc;
$this->amount_ht = $obj->amount_ht;
$this->amount_tva = $obj->amount_tva;
$this->amount_ttc = $obj->amount_ttc;
$this->multicurrency_amount_ht = $obj->multicurrency_amount_ht;
$this->multicurrency_amount_tva = $obj->multicurrency_amount_tva;
$this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc;
$this->tva_tx = $obj->tva_tx;
$this->fk_user = $obj->fk_user;
$this->fk_facture_line = $obj->fk_facture_line;

View File

@ -8,6 +8,7 @@
* Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro>
* Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.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
@ -139,14 +140,14 @@ class ExtraFields
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param int $list Into list view by default
* @param int $list Into list view by default (-1, 0 or 1)
* @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table)
* @param string $computed Computed value
* @param string $entity Entity of extrafields
* @param string $langfile Language file
* @return int <=0 if KO, >0 if OK
*/
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $computed='', $entity='', $langfile='')
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $computed='', $entity='', $langfile='')
{
if (empty($attrname)) return -1;
if (empty($label)) return -1;
@ -278,7 +279,7 @@ class ExtraFields
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
* @param int $alwayseditable Is attribute always editable regardless of the document status
* @param string $perms Permission to check
* @param int $list Into list view by default
* @param int $list Into list view by default (-1, 0 or 1)
* @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table)
* @param string $default Default value (in database. use the default_value feature for default value on screen).
* @param string $computed Computed value
@ -286,7 +287,7 @@ class ExtraFields
* @param string $langfile Language file
* @return int <=0 if KO, >0 if OK
*/
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $default='', $computed='',$entity='', $langfile='')
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $default='', $computed='',$entity='', $langfile='')
{
global $conf,$user;
@ -892,13 +893,13 @@ class ExtraFields
if (! is_object($form)) $form=new Form($this->db);
// TODO Must also support $moreparam
$out = $form->select_date($value, $keysuffix.'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
$out = $form->select_date($value, $keysuffix.'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, ($keysuffix != 'search_' ? 1 : 0), 1, 0, 1);
}
elseif (in_array($type,array('int')))
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" " maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
}
elseif ($type == 'varchar')
{
@ -1322,7 +1323,8 @@ class ExtraFields
}
elseif ($type == 'password')
{
$out='<input type="password" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
// If prefix is 'search_', field is used as a filter, we use a common text field.
$out='<input type="'.($keysuffix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
}
if (!empty($hidden)) {
$out='<input type="hidden" value="'.$value.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" id="'.$keysuffix.'options_'.$key.$keyprefix.'"/>';
@ -1708,7 +1710,7 @@ class ExtraFields
if (! empty($onlykey) && $key != $onlykey) continue;
$key_type = $this->attribute_type[$key];
if($this->attribute_required[$key] && !GETPOST("options_$key",2))
if ($this->attribute_required[$key] && empty($_POST["options_".$key])) // Check if empty without GETPOST, value can be alpha, int, array, etc...
{
$nofillrequired++;
$error_field_required[] = $value;
@ -1721,7 +1723,7 @@ class ExtraFields
}
else if (in_array($key_type,array('checkbox','chkbxlst')))
{
$value_arr=GETPOST("options_".$key);
$value_arr=GETPOST("options_".$key, 'array'); // check if an array
if (!empty($value_arr)) {
$value_key=implode($value_arr,',');
}else {
@ -1740,7 +1742,7 @@ class ExtraFields
$object->array_options["options_".$key]=$value_key;
}
if($nofillrequired) {
if ($nofillrequired) {
$langs->load('errors');
setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ',$error_field_required), null, 'errors');
return -1;

View File

@ -544,7 +544,7 @@ class Form
$disabled=0;
$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 class="flat'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>';
// 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();
@ -561,7 +561,7 @@ class Form
$ret.='</select>';
// 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" name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
$ret.='</div>';
if (! empty($conf->use_javascript_ajax))
@ -1256,6 +1256,7 @@ class Form
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param bool $options_only Return options only (for ajax treatment)
* @return int <0 if KO, Nb of contact in list if OK
* @deprected You can use selectcontacts directly (warning order of param was changed)
*/
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0, $forcecombo=0, $events=array(), $options_only=false)
{
@ -1264,7 +1265,8 @@ class Form
}
/**
* Return list of all contacts (for a third party or all)
* Return HTML code of the SELECT of list of all contacts (for a third party or all).
* This also set the number of contacts found into $this->num
*
* @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne
@ -2987,13 +2989,15 @@ class Form
* Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
* See instead to force the default value by the caller.
*
* @param int $selected Id of payment term to preselect by default
* @param string $htmlname Nom de la zone select
* @param int $filtertype Not used
* @param int $addempty Add an empty entry
* @param int $selected Id of payment term to preselect by default
* @param string $htmlname Nom de la zone select
* @param int $filtertype Not used
* @param int $addempty Add an empty entry
* @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
* @param string $morecss Add more CSS on select tag
* @return void
*/
function select_conditions_paiements($selected=0, $htmlname='condid', $filtertype=-1, $addempty=0)
function select_conditions_paiements($selected=0, $htmlname='condid', $filtertype=-1, $addempty=0, $noinfoadmin=0, $morecss='')
{
global $langs, $user, $conf;
@ -3004,7 +3008,7 @@ class Form
// Set default value if not already set by caller
if (empty($selected) && ! empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
print '<select class="flat" name="'.$htmlname.'">';
print '<select id="'.$htmlname.'" class="flat selectpaymentterms'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'">';
if ($addempty) print '<option value="0">&nbsp;</option>';
foreach($this->cache_conditions_paiements as $id => $arrayconditions)
{
@ -3020,7 +3024,7 @@ class Form
print '</option>';
}
print '</select>';
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
if ($user->admin && empty($noinfoadmin)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
@ -3035,7 +3039,7 @@ class Form
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label
* @param int $active Active or not, -1 = all
* @param string $morecss Add more css
* @param string $morecss Add more CSS on select tag
* @return void
*/
function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $active=1, $morecss='')
@ -3275,7 +3279,7 @@ class Form
$return= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
$sql = 'SELECT rowid, label from '.MAIN_DB_PREFIX.'c_units';
$sql = 'SELECT rowid, label, code from '.MAIN_DB_PREFIX.'c_units';
$sql.= ' WHERE active > 0';
$resql = $this->db->query($sql);
@ -3302,21 +3306,22 @@ class Form
/**
* Return a HTML select list of bank accounts
*
* @param string $selected Id account pre-selected
* @param string $htmlname Name of select zone
* @param int $statut Status of searched accounts (0=open, 1=closed, 2=both)
* @param string $filtre To filter list
* @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
* @param string $moreattrib To add more attribute on select
* @param string $selected Id account pre-selected
* @param string $htmlname Name of select zone
* @param int $statut Status of searched accounts (0=open, 1=closed, 2=both)
* @param string $filtre To filter list
* @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
* @param string $moreattrib To add more attribute on select
* @param int $showcurrency Show currency in label
* @return void
*/
function select_comptes($selected='',$htmlname='accountid',$statut=0,$filtre='',$useempty=0,$moreattrib='')
function select_comptes($selected='',$htmlname='accountid',$statut=0,$filtre='',$useempty=0,$moreattrib='',$showcurrency=0)
{
global $langs, $conf;
$langs->load("admin");
$sql = "SELECT rowid, label, bank, clos as status";
$sql = "SELECT rowid, label, bank, clos as status, currency_code";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE entity IN (".getEntity('bank_account').")";
if ($statut != 2) $sql.= " AND clos = '".$statut."'";
@ -3349,6 +3354,7 @@ class Form
print '<option value="'.$obj->rowid.'">';
}
print trim($obj->label);
if ($showcurrency) print ' ('.$obj->currency_code.')';
if ($statut == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')';
print '</option>';
$i++;
@ -3392,7 +3398,7 @@ class Form
require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
$bankstatic=new Account($this->db);
$bankstatic->fetch($selected);
print $this->textwithpicto($bankstatic->getNomUrl(1),$langs->trans("AccountCurrency").'&nbsp;'.$bankstatic->currency_code);
print $bankstatic->getNomUrl(1);
} else {
print "&nbsp;";
}
@ -5041,16 +5047,16 @@ class Form
}
elseif ($typehour=='text' || $typehour=='textselect')
{
$retstring.='<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" size="1" name="'.$prefix.'hour"'.($disabled?' disabled':'').' class="flat maxwidth50" value="'.(($hourSelected != '')?((int) $hourSelected):'').'">';
$retstring.='<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" size="1" name="'.$prefix.'hour"'.($disabled?' disabled':'').' class="flat maxwidth50 inputhour" value="'.(($hourSelected != '')?((int) $hourSelected):'').'">';
}
else return 'BadValueForParameterTypeHour';
if ($typehour!='text') $retstring.=' '.$langs->trans('HourShort');
else $retstring.=':';
else $retstring.='<span class="hideonsmartphone">:</span>';
// Minutes
if ($minunderhours) $retstring.='<br>';
else $retstring.="&nbsp;";
else $retstring.='<span class="hideonsmartphone">&nbsp;</span>';
if ($typehour=='select' || $typehour=='textselect')
{
@ -5065,7 +5071,7 @@ class Form
}
elseif ($typehour=='text' )
{
$retstring.='<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled?' disabled':'').' class="flat maxwidth50" value="'.(($minSelected != '')?((int) $minSelected):'').'">';
$retstring.='<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled?' disabled':'').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '')?((int) $minSelected):'').'">';
}
if ($typehour!='text') $retstring.=' '.$langs->trans('MinuteShort');
@ -5213,15 +5219,16 @@ class Form
*/
static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0)
{
global $langs;
global $conf, $langs;
global $delayedhtmlcontent;
$tmpplugin='select2';
// TODO Use an internal dolibarr component instead of select2
if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return '';
$out='<input type="text" class="'.$htmlname.($morecss?' '.$morecss:'').'" '.($moreparam?$moreparam.' ':'').'name="'.$htmlname.'">';
// TODO Use an internal dolibarr component instead of select2
$outdelayed='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
$tmpplugin='select2';
$outdelayed="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript">
$(document).ready(function () {
@ -5323,7 +5330,7 @@ class Form
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))
{
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
$out.="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript">
function formatResult(record) {'."\n";
if ($elemtype == 'category')
@ -5549,8 +5556,8 @@ class Form
{
$nbofdifferenttypes = count($object->linkedObjects);
print '<br><!-- showLinkedObjectBlock -->';
print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, '');
print '<!-- showLinkedObjectBlock -->';
print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, '', 0, 0, 'showlinkedobjectblock');
print '<div class="div-table-responsive-no-min">';
@ -5826,7 +5833,7 @@ class Form
* @param int $useempty 1=Add empty line
* @return string See option
*/
function selectyesno($htmlname,$value='',$option=0,$disabled=false,$useempty='')
function selectyesno($htmlname, $value='', $option=0, $disabled=false, $useempty='')
{
global $langs;
@ -5966,7 +5973,7 @@ class Form
if ($previous_ref || $next_ref || $morehtml)
{
$ret.='<div class="pagination"><ul>';
$ret.='<div class="pagination paginationref"><ul class="right">';
}
if ($morehtml)
{

View File

@ -150,14 +150,14 @@ class FormActions
/**
* Show list of actions for element
*
* @param Object $object Object
* @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter'
* @param int $socid socid of user
* @param int $forceshowtitle Show title even if there is no actions to show
* @param string $morecss More css on table
* @param int $max Max number of record
* @param Object $object Object
* @param string $typeelement 'invoice','propal','order','invoice_supplier','order_supplier','fichinter'
* @param int $socid Socid of user
* @param int $forceshowtitle Show title even if there is no actions to show
* @param string $morecss More css on table
* @param int $max Max number of record
* @param string $moreparambacktopage More param for the backtopage
* @return int <0 if KO, >=0 if OK
* @return int <0 if KO, >=0 if OK
*/
function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='')
{
@ -175,31 +175,34 @@ class FormActions
$num = count($listofactions);
if ($num || $forceshowtitle)
{
if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill');
if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill');
elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill');
elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal');
elseif ($typeelement == 'supplier_payment') $title=$langs->trans('ActionsOnSupplierPayment');
elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal');
elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder');
elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal');
elseif ($typeelement == 'supplier_payment') $title=$langs->trans('ActionsOnSupplierPayment');
elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal');
elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder');
elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder');
elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping');
elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter');
elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
else $title=$langs->trans("Actions");
elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping');
elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter');
elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
else $title=$langs->trans("LatestLinkedEvents", $max?$max:'');
$urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:'');
$buttontoaddnewevent = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.'&socid='.$object->socid.'&projectid='.$object->fk_project.'&backtopage='.urlencode($urlbacktopage).'">';
$buttontoaddnewevent.= $langs->trans("AddEvent");
$buttontoaddnewevent.= '</a>';
print '<!-- formactions->showactions -->'."\n";
print load_fiche_titre($title, $buttontoaddnewevent, '');
$page=0; $param='';
$total = 0;
print '<div class="div-table-responsive">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">';
print '<tr class="liste_titre">';
print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
@ -213,65 +216,70 @@ class FormActions
$userstatic = new User($this->db);
$cursorevent = 0;
foreach($listofactions as $action)
if (count($listofactions))
{
if ($max && $cursorevent >= $max) break;
$cursorevent = 0;
foreach($listofactions as $action)
{
if ($max && $cursorevent >= $max) break;
$ref=$action->getNomUrl(1,-1);
$label=$action->getNomUrl(0,38);
$ref=$action->getNomUrl(1,-1);
$label=$action->getNomUrl(0,38);
print '<tr class="oddeven">';
print '<td>'.$ref.'</td>';
print '<td>'.$label.'</td>';
print '<td>';
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if ($action->type_picto) print img_picto('', $action->type_picto);
else {
if ($action->type_code == 'AC_RDV') print img_picto('', 'object_group').' ';
if ($action->type_code == 'AC_TEL') print img_picto('', 'object_phoning').' ';
if ($action->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax').' ';
if ($action->type_code == 'AC_EMAIL') print img_picto('', 'object_email').' ';
}
}
print $action->type;
print '</td>';
print '<td align="center">'.dol_print_date($action->datep,'dayhour');
if ($action->datef)
{
$tmpa=dol_getdate($action->datep);
$tmpb=dol_getdate($action->datef);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year'])
print '<tr class="oddeven">';
print '<td>'.$ref.'</td>';
print '<td>'.$label.'</td>';
print '<td>';
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef,'hour');
if ($action->type_picto) print img_picto('', $action->type_picto);
else {
if ($action->type_code == 'AC_RDV') print img_picto('', 'object_group').' ';
if ($action->type_code == 'AC_TEL') print img_picto('', 'object_phoning').' ';
if ($action->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax').' ';
if ($action->type_code == 'AC_EMAIL') print img_picto('', 'object_email').' ';
}
}
else print '-'.dol_print_date($action->datef,'dayhour');
}
print '</td>';
print '<td>';
if (! empty($action->author->id))
{
$userstatic->id = $action->author->id;
$userstatic->firstname = $action->author->firstname;
$userstatic->lastname = $action->author->lastname;
print $userstatic->getNomUrl(1, '', 0, 0, 16, 0, '', '');
}
print '</td>';
print '<td align="right">';
if (! empty($action->author->id))
{
print $action->getLibStatut(3);
}
print '</td>';
print '</tr>';
print $action->type;
print '</td>';
print '<td align="center">'.dol_print_date($action->datep,'dayhour');
if ($action->datef)
{
$tmpa=dol_getdate($action->datep);
$tmpb=dol_getdate($action->datef);
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year'])
{
if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef,'hour');
}
else print '-'.dol_print_date($action->datef,'dayhour');
}
print '</td>';
print '<td>';
if (! empty($action->userownerid))
{
$userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched
print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', '');
}
print '</td>';
print '<td align="right">';
if (! empty($action->author->id))
{
print $action->getLibStatut(3);
}
print '</td>';
print '</tr>';
$cursorevent++;
$cursorevent++;
}
}
else
{
print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
if ($max && $num > $max)
{
print '<tr class="oddeven"><td colspan="6">'.$langs->trans("More").'...</td></tr>';
print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>';
}
print '</table>';

View File

@ -57,21 +57,22 @@ class FormFile
/**
* Show form to upload a new file
*
* @param string $url Url
* @param string $title Title zone (Title or '' or 'none')
* @param string $url Url
* @param string $title Title zone (Title or '' or 'none')
* @param int $addcancel 1=Add 'Cancel' button
* @param int $sectionid If upload must be done inside a particular ECM section
* @param int $perm Value of permission to allow upload
* @param int $size Length of input file area. Deprecated.
* @param Object $object Object to use (when attachment is done on an element)
* @param string $options Add an option column
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used.
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files
* @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
* @param int $size Length of input file area. Deprecated.
* @param Object $object Object to use (when attachment is done on an element)
* @param string $options Add an option column
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used.
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files
* @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
* @param string $accept Specifies the types of files accepted (This is not a security check but an user interface facility. eg '.pdf,image/*' or '.png,.jpg' or 'video/*')
* @return int <0 if KO, >0 if OK
*/
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile')
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile', $accept='')
{
global $conf,$langs, $hookmanager;
$hookmanager->initHooks(array('formfile'));
@ -130,6 +131,7 @@ class FormFile
$out .= '<input class="flat minwidth400" type="file"';
$out .= ((! empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic')?' name="userfile"':' name="userfile[]" multiple');
$out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':'');
$out .= (!empty($accept)?' accept="'.$accept.'"':'accept=""');
$out .= '>';
$out .= ' ';
$out .= '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"';

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