Merge branch 'develop' of github.com:Dolibarr/dolibarr into develop_atm
This commit is contained in:
commit
7c965cb2c7
@ -152,12 +152,6 @@ source_file = htdocs/langs/en_US/hrm.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.incoterm]
|
||||
file_filter = htdocs/langs/<lang>/incoterm.lang
|
||||
source_file = htdocs/langs/en_US/incoterm.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.install]
|
||||
file_filter = htdocs/langs/<lang>/install.lang
|
||||
source_file = htdocs/langs/en_US/install.lang
|
||||
|
||||
102
ChangeLog
102
ChangeLog
@ -17,8 +17,75 @@ Following changes may create regressions for some external modules, but were nec
|
||||
* PHP 5.3 is no more supported. Minimum PHP is now 5.4+
|
||||
* Remove the old deprecated code of doActions and getInstanceDao in canvas. The doActions of standard hooks are
|
||||
already available and are better.
|
||||
* Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better.
|
||||
|
||||
|
||||
***** ChangeLog for 7.0.1 compared to 7.0.0 *****
|
||||
FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php
|
||||
FIX: #8200
|
||||
FIX: #8219
|
||||
FIX: #8232
|
||||
FIX: #8269
|
||||
FIX: #8277
|
||||
FIX: #8285 Extrafields now reported by /api/index.php/agendaevents/{id}
|
||||
FIX: #8289 add a configuration for stock calculation
|
||||
FIX: Activate all also if there are inactive services
|
||||
FIX: add planned delivery to order exports
|
||||
FIX: approval date was not visible if leave was canceled after
|
||||
FIX: avoid "Array" on screen
|
||||
FIX: Avoid empty value to fk_multicurrency attribute
|
||||
FIX: Bad var for substitution of free text
|
||||
FIX: Can't activate tasks on projects configuration
|
||||
FIX: Can use odx templates that does not include lines tags
|
||||
FIX: check shipping on delete order
|
||||
FIX: check verif exped on delete order
|
||||
FIX: comment on tasks
|
||||
FIX: country must not be mandatory for accounting report groups
|
||||
FIX: css
|
||||
FIX: Delete tasks on project delete will now trigger TASK_DELETE
|
||||
FIX: Do not lose filter when editing comment of a time spent in task view
|
||||
FIX: duplicate confirm message. Missing reposition class
|
||||
FIX: Duplicate product_type asignement on order addline
|
||||
FIX: email use the validate user instead of approver in holiday approval
|
||||
FIX: Error management in leave request
|
||||
FIX: for nondisplay of fk_element 's id in REST API response
|
||||
FIX: Generic substitution of constant disabled for sensitive constant
|
||||
FIX: if we make a mistake with situation_percent, now we can correct it. before situation_final was always set to 1 and no way to go back
|
||||
FIX: Import process must stop after ending line nb to import
|
||||
FIX: Infinite loop on deletion of temp file when there is symbolic links
|
||||
FIX: Input of holiday for subordinates was ko
|
||||
FIX: invoice creation fails when next date not defined
|
||||
FIX: Label of event show twice
|
||||
FIX: letter for month March
|
||||
FIX: Look and feel v7
|
||||
FIX: Make a redirect after the remove_file action to avoid deletion done
|
||||
FIX: migration script for product photo
|
||||
FIX: missing email of customer in stripe info payments
|
||||
FIX: missing object entity in fetch
|
||||
FIX: Missing restore_lastsearch_values
|
||||
FIX: multicompany compatibility and fix reports
|
||||
FIX: natural search double quote
|
||||
FIX: navigation and filters on holiday list
|
||||
FIX: Parameter must be an array or an object that implements Countable
|
||||
FIX: Payment mode not correctly set in donation and document
|
||||
FIX: Permission in list of holiday
|
||||
FIX: Properties updated if update successfull.
|
||||
FIX: reverse field to have object loaded in doaction
|
||||
FIX: Saving wrong localtax on order addline
|
||||
FIX: Search criteria on vat
|
||||
FIX: security report by DIGITEMIS CYBERSECURITY & PRIVACY
|
||||
FIX: show status on societe banner
|
||||
FIX: solve column mismatch in user card with multicompany transverse mode + code cleanup
|
||||
FIX: Subscription events not recorded into agenda
|
||||
FIX: Subscription not correctly log in blockedlog
|
||||
FIX: Temporary dir for mail files must be cleaned at beginning of form
|
||||
FIX: Trad and creation date in subscription create
|
||||
FIX: translation of holiday types
|
||||
FIX: Unknown column 'pl.amount_requested' in compta/prelevement/factures.php
|
||||
FIX: Useless clean of tree
|
||||
FIX: Use of undefined constant _ROWS_2
|
||||
FIX: warning when adding ECM files using old photo path
|
||||
|
||||
|
||||
***** ChangeLog for 7.0.0 compared to 6.0.5 *****
|
||||
For users:
|
||||
@ -307,6 +374,41 @@ Following changes may create regressions for some external modules, but were nec
|
||||
multicompany module to a version that support Dolibarr v7, everything should work as expected.
|
||||
|
||||
|
||||
|
||||
***** ChangeLog for 6.0.6 compared to 6.0.6 *****
|
||||
FIX: #7974 Contract - Invalid reference on the document
|
||||
FIX: #8139
|
||||
FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php
|
||||
FIX: #8151
|
||||
FIX: #8200
|
||||
FIX: add planned delivery to order exports
|
||||
FIX: a discount is a percent, not an amount, so we use vatrate not price
|
||||
FIX: Avoid empty value to fk_multicurrency attribute
|
||||
FIX: Bad localtaxes assignment in cashdesk
|
||||
FIX: check shipping on delete order
|
||||
FIX: check verif exped on delete order
|
||||
FIX: creer into lire
|
||||
FIX: Delete tasks on project delete will now trigger TASK_DELETE
|
||||
FIX: Global on $user parameter reset the variable
|
||||
FIX: if we make a mistake with situation_percent, now we can correct…
|
||||
FIX: if we make a mistake with situation_percent, now we can correct it. before situation_final was always set to 1 and no way to go back
|
||||
FIX: Import process must stop after ending line nb to import
|
||||
FIX: migration script for product photo
|
||||
FIX: natural search double quote
|
||||
FIX: reverse field to have object loaded in doaction
|
||||
FIX: Saving wrong localtax on order addline
|
||||
FIX: show status on societe banner
|
||||
FIX: solve column mismatch in user card's usergroup list + code cleanup
|
||||
FIX: solve column mismatch in user card with multicompany transverse mode + code cleanup
|
||||
FIX: unset categorie
|
||||
FIX: update_extras on fourn card
|
||||
FIX: warning when adding ECM files using old photo path
|
||||
FIX: Withdrawals lines not filter by company name and not respect dropdown limit lines by page
|
||||
NEW: Add sale representative einstein_pdf_modules
|
||||
NEW_einstein_pdf_modules
|
||||
NEW: field commerciaux and categ export CustomersInvoicesAndPayments
|
||||
|
||||
|
||||
***** ChangeLog for 6.0.5 compared to 6.0.4 *****
|
||||
FIX: security vulnerability reported by ADLab of Venustech
|
||||
CVE-2017-17897, CVE-2017-17898, CVE-2017-17899, CVE-2017-17900
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file build/generate_filecheck_xml.php
|
||||
* \file build/generate_filelist_xml.php
|
||||
* \ingroup dev
|
||||
* \brief This script create a xml checksum file
|
||||
*/
|
||||
@ -45,7 +45,7 @@ $includeconstants=array();
|
||||
|
||||
if (empty($argv[1]))
|
||||
{
|
||||
print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
print "Usage: ".$script_file." release=auto|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n";
|
||||
exit -1;
|
||||
}
|
||||
@ -68,11 +68,20 @@ while ($i < $argc)
|
||||
$i++;
|
||||
}
|
||||
|
||||
// If release is auto, we take current version
|
||||
$tmpver=explode('-', $release, 2);
|
||||
if ($tmpver[0] == 'auto')
|
||||
{
|
||||
$release=DOL_VERSION;
|
||||
if ($tmpver[1]) $release.='-'.$tmpver[1];
|
||||
}
|
||||
|
||||
if (empty($includecustom))
|
||||
{
|
||||
if (DOL_VERSION != $release)
|
||||
$tmpver=explode('-', $release, 2);
|
||||
if (DOL_VERSION != $tmpver[0])
|
||||
{
|
||||
print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$release.')'."\n";
|
||||
print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpver[0].')'."\n";
|
||||
print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n";
|
||||
exit -1;
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ if ($nboftargetok) {
|
||||
#-----------------------
|
||||
if ($CHOOSEDTARGET{'-CHKSUM'})
|
||||
{
|
||||
print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filecheck_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n";
|
||||
print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filelist_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n";
|
||||
$ret=`php $SOURCE/build/generate_filelist_xml.php release=$MAJOR.$MINOR.$BUILD`;
|
||||
print $ret."\n";
|
||||
# Copy to final dir
|
||||
|
||||
@ -176,6 +176,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/core
|
||||
%_datadir/dolibarr/htdocs/cron
|
||||
%_datadir/dolibarr/htdocs/custom
|
||||
%_datadir/dolibarr/htdocs/dav
|
||||
%_datadir/dolibarr/htdocs/don
|
||||
%_datadir/dolibarr/htdocs/ecm
|
||||
%_datadir/dolibarr/htdocs/expedition
|
||||
|
||||
@ -256,6 +256,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/core
|
||||
%_datadir/dolibarr/htdocs/cron
|
||||
%_datadir/dolibarr/htdocs/custom
|
||||
%_datadir/dolibarr/htdocs/dav
|
||||
%_datadir/dolibarr/htdocs/don
|
||||
%_datadir/dolibarr/htdocs/ecm
|
||||
%_datadir/dolibarr/htdocs/expedition
|
||||
|
||||
@ -173,6 +173,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/core
|
||||
%_datadir/dolibarr/htdocs/cron
|
||||
%_datadir/dolibarr/htdocs/custom
|
||||
%_datadir/dolibarr/htdocs/dav
|
||||
%_datadir/dolibarr/htdocs/don
|
||||
%_datadir/dolibarr/htdocs/ecm
|
||||
%_datadir/dolibarr/htdocs/expedition
|
||||
|
||||
@ -184,6 +184,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/core
|
||||
%_datadir/dolibarr/htdocs/cron
|
||||
%_datadir/dolibarr/htdocs/custom
|
||||
%_datadir/dolibarr/htdocs/dav
|
||||
%_datadir/dolibarr/htdocs/don
|
||||
%_datadir/dolibarr/htdocs/ecm
|
||||
%_datadir/dolibarr/htdocs/expedition
|
||||
|
||||
@ -47,15 +47,24 @@ if ($user->societe_id > 0)
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
// Filter
|
||||
$year = GETPOST("year",'int');
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
|
||||
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
|
||||
if (GETPOST("year",'int')) $year_start = GETPOST("year",'int');
|
||||
else
|
||||
{
|
||||
$year_start = dol_print_date(dol_now(), '%Y');
|
||||
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
|
||||
}
|
||||
$year_end = $year_start + 1;
|
||||
$month_end = $month_start - 1;
|
||||
if ($month_end < 1)
|
||||
{
|
||||
$month_end = 12;
|
||||
$year_end--;
|
||||
}
|
||||
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
|
||||
$search_date_end = dol_get_last_day($year_end, $month_end);
|
||||
$year_current = $year_start;
|
||||
|
||||
// Validate History
|
||||
$action = GETPOST('action','aZ09');
|
||||
@ -116,8 +125,8 @@ if ($action == 'validatehistory') {
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql1.= " SET fk_code_ventilation = 0";
|
||||
$sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f";
|
||||
$sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
||||
$sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
|
||||
$sql1.= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql1.= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")";
|
||||
$sql1.=")";
|
||||
|
||||
@ -170,30 +179,12 @@ print $langs->trans("DescVentilCustomer") . '<br>';
|
||||
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
|
||||
print '<br>';
|
||||
|
||||
$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " , " . MAIN_DB_PREFIX . "facture as f";
|
||||
$sql .= " WHERE fd.fk_code_ventilation = 0";
|
||||
$sql .= " AND f.rowid = fd.fk_facture";
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog('htdocs/accountancy/customer/index.php');
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$row = $db->fetch_row($result);
|
||||
$nbfac = $row[0];
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
|
||||
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
||||
$buttonreset = '';
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
||||
|
||||
|
||||
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
|
||||
@ -203,21 +194,26 @@ print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
|
||||
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(fd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NULL";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
@ -262,6 +258,7 @@ if ($resql) {
|
||||
print "</table>\n";
|
||||
print '</div>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
@ -272,22 +269,27 @@ print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
|
||||
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(fd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
@ -319,7 +321,7 @@ if ($resql) {
|
||||
else print $row[1];
|
||||
print '</td>';
|
||||
|
||||
for($i = 2; $i <= 12; $i ++) {
|
||||
for($i = 2; $i <= 12; $i++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
}
|
||||
print '<td align="right">' . price($row[13]) . '</td>';
|
||||
@ -345,20 +347,25 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(fd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
@ -392,20 +399,25 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
@ -37,27 +38,36 @@ $langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
// Filter
|
||||
$year = GETPOST('year', 'int');
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
|
||||
if (GETPOST("year",'int')) $year_start = GETPOST("year",'int');
|
||||
else
|
||||
{
|
||||
$year_start = dol_print_date(dol_now(), '%Y');
|
||||
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
|
||||
}
|
||||
$year_end = $year_start + 1;
|
||||
$month_end = $month_start - 1;
|
||||
if ($month_end < 1)
|
||||
{
|
||||
$month_end = 12;
|
||||
$year_end--;
|
||||
}
|
||||
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
|
||||
$search_date_end = dol_get_last_day($year_end, $month_end);
|
||||
$year_current = $year_start;
|
||||
|
||||
// Validate History
|
||||
$action = GETPOST('action','aZ09');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -112,8 +122,8 @@ if ($action == 'validatehistory') {
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
|
||||
$sql1.= " SET fk_code_ventilation = 0";
|
||||
$sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er";
|
||||
$sql1.= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
||||
$sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
|
||||
$sql1.= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql1.= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")";
|
||||
$sql1.=")";
|
||||
|
||||
@ -130,6 +140,7 @@ if ($action == 'validatehistory') {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -141,10 +152,6 @@ $textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_cur
|
||||
|
||||
print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
|
||||
|
||||
print $langs->trans("DescVentilExpenseReport") . '<br>';
|
||||
print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
|
||||
print '<br>';
|
||||
|
||||
// Clean database
|
||||
$db->begin();
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
|
||||
@ -165,37 +172,45 @@ if (! $resql1) {
|
||||
}
|
||||
// End clean database
|
||||
|
||||
print $langs->trans("DescVentilExpenseReport") . '<br>';
|
||||
print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
|
||||
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
||||
$buttonreset = '';
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
||||
|
||||
|
||||
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
|
||||
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
|
||||
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(erd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
|
||||
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND er.fk_statut > 0 ";
|
||||
$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
|
||||
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NULL";
|
||||
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
@ -203,9 +218,9 @@ $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $row = $db->fetch_row($resql)) {
|
||||
while ( $row = $db->fetch_row($resql)) {
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
if ($row[0] == 'tobind')
|
||||
@ -246,22 +261,26 @@ print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
|
||||
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " ROUND(SUM(erd.total_ht),2) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
|
||||
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND er.fk_statut > 0 ";
|
||||
$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
|
||||
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NOT NULL";
|
||||
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
@ -269,9 +288,9 @@ $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
dol_syslog('htdocs/accountancy/expensereport/index.php');
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $row = $db->fetch_row($resql)) {
|
||||
while ( $row = $db->fetch_row($resql)) {
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
if ($row[0] == 'tobind')
|
||||
@ -280,6 +299,7 @@ if ($resql) {
|
||||
}
|
||||
else print length_accountg($row[0]);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
if ($row[0] == 'tobind')
|
||||
{
|
||||
@ -303,7 +323,7 @@ print '</div>';
|
||||
|
||||
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
|
||||
{
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
@ -314,20 +334,24 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(erd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
|
||||
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND er.fk_statut > 0 ";
|
||||
$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
|
||||
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog('htdocs/accountancy/expensereport/index.php');
|
||||
@ -335,7 +359,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $row = $db->fetch_row($resql)) {
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
|
||||
@ -164,10 +164,10 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
|
||||
$sql .= " , " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||
$sql .= " , " . MAIN_DB_PREFIX . "expensereport_det as erd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
|
||||
$sql .= " WHERE er.rowid = erd.fk_expensereport and er.fk_statut >= 5 AND erd.fk_code_ventilation <> 0 ";
|
||||
$sql .= " WHERE er.rowid = erd.fk_expensereport and er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <> 0 ";
|
||||
$sql .= " AND aa.rowid = erd.fk_code_ventilation";
|
||||
if (strlen(trim($search_expensereport))) {
|
||||
$sql .= " AND er.ref like '%" . $search_expensereport . "%'";
|
||||
$sql .= natural_search("er.ref", $search_expensereport);
|
||||
}
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= natural_search("f.label", $search_label);
|
||||
|
||||
@ -201,7 +201,7 @@ $sql.= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
|
||||
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport";
|
||||
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
|
||||
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
|
||||
$sql.= " WHERE er.fk_statut > 4 AND erd.fk_code_ventilation <= 0";
|
||||
$sql.= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
|
||||
// Add search filter like
|
||||
if (strlen(trim($search_expensereport))) {
|
||||
$sql .= natural_search("er.ref",$search_expensereport);
|
||||
|
||||
@ -104,8 +104,8 @@ $idpays = $mysoc->country_id;
|
||||
|
||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,";
|
||||
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
|
||||
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop_company,";
|
||||
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop_user,";
|
||||
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
|
||||
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, bu2.type as typeop_user,";
|
||||
$sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
|
||||
@ -212,6 +212,7 @@ if ($result) {
|
||||
'id' => $obj->socid,
|
||||
'name' => $obj->name,
|
||||
'code_compta' => $compta_soc,
|
||||
'email' => $obj->email
|
||||
);
|
||||
|
||||
// Set accountancy code for user
|
||||
@ -222,7 +223,8 @@ if ($result) {
|
||||
'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
|
||||
'lastname' => $obj->lastname,
|
||||
'firstname' => $obj->firstname,
|
||||
'accountancy_code' => $compta_user,
|
||||
'email' => $obj->useremail,
|
||||
'accountancy_code' => $compta_user
|
||||
);
|
||||
|
||||
// Variable bookkeeping ($obj->rowid is Bank Id)
|
||||
@ -237,7 +239,7 @@ if ($result) {
|
||||
} else {
|
||||
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
|
||||
}
|
||||
$links = $object->get_url($obj->rowid);
|
||||
$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
|
||||
|
||||
//var_dump($i);
|
||||
//var_dump($tabpay);
|
||||
@ -282,11 +284,15 @@ if ($result) {
|
||||
} else if ($links[$key]['type'] == 'company') {
|
||||
$societestatic->id = $links[$key]['url_id'];
|
||||
$societestatic->name = $links[$key]['label'];
|
||||
$societestatic->email = $tabcompany[$obj->rowid]['email'];
|
||||
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
|
||||
if ($compta_soc) $tabtp[$obj->rowid][$compta_soc] += $obj->amount;
|
||||
} else if ($links[$key]['type'] == 'user') {
|
||||
$userstatic->id = $links[$key]['url_id'];
|
||||
$userstatic->name = $links[$key]['label'];
|
||||
$userstatic->email = $tabuser[$obj->rowid]['email'];
|
||||
$userstatic->firstname = $tabuser[$obj->rowid]['firstname'];
|
||||
$userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
|
||||
if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30);
|
||||
else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment.
|
||||
if ($compta_user) $tabtp[$obj->rowid][$compta_user] += $obj->amount;
|
||||
@ -341,7 +347,7 @@ if ($result) {
|
||||
$tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
|
||||
} else if ($links[$key]['type'] == 'payment_expensereport') {
|
||||
$paymentexpensereportstatic->id = $links[$key]['url_id'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2);
|
||||
$tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2);
|
||||
$tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id;
|
||||
} else if ($links[$key]['type'] == 'payment_various') {
|
||||
$paymentvariousstatic->id = $links[$key]['url_id'];
|
||||
@ -825,7 +831,7 @@ if (empty($action) || $action == 'view') {
|
||||
//$description = $langs->trans("DescFinanceJournal") . '<br>';
|
||||
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
|
||||
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
|
||||
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
|
||||
@ -140,9 +140,9 @@ if ($result) {
|
||||
$compta_fees = $obj->compte;
|
||||
|
||||
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
|
||||
$compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat);
|
||||
$compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
$compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
$compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
|
||||
$compta_localtax1 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
$compta_localtax2 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
|
||||
|
||||
// Define array to display all VAT rates that use this accounting account $compta_tva
|
||||
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
|
||||
@ -531,7 +531,7 @@ if (empty($action) || $action == 'view') {
|
||||
$builddate=dol_now();
|
||||
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
|
||||
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
|
||||
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
|
||||
@ -723,7 +723,7 @@ if (empty($action) || $action == 'view') {
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
}
|
||||
|
||||
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
|
||||
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
|
||||
@ -653,7 +653,7 @@ if (empty($action) || $action == 'view') {
|
||||
else
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
|
||||
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
|
||||
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
|
||||
$period = $form->select_date($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
|
||||
@ -38,25 +38,35 @@ $langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
if (! $user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
|
||||
// Filter
|
||||
$year = GETPOST("year",'int');
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
|
||||
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
|
||||
if (GETPOST("year",'int')) $year_start = GETPOST("year",'int');
|
||||
else
|
||||
{
|
||||
$year_start = dol_print_date(dol_now(), '%Y');
|
||||
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
|
||||
}
|
||||
$year_end = $year_start + 1;
|
||||
$month_end = $month_start - 1;
|
||||
if ($month_end < 1)
|
||||
{
|
||||
$month_end = 12;
|
||||
$year_end--;
|
||||
}
|
||||
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
|
||||
$search_date_end = dol_get_last_day($year_end, $month_end);
|
||||
$year_current = $year_start;
|
||||
|
||||
// Validate History
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$action = GETPOST('action','aZ09');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -141,10 +151,6 @@ $textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_cur
|
||||
|
||||
print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
|
||||
|
||||
print $langs->trans("DescVentilSupplier") . '<br>';
|
||||
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
|
||||
print '<br>';
|
||||
|
||||
// Clean database
|
||||
$db->begin();
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
|
||||
@ -165,11 +171,15 @@ if (! $resql1) {
|
||||
}
|
||||
// End clean database
|
||||
|
||||
print $langs->trans("DescVentilSupplier") . '<br>';
|
||||
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
|
||||
print '<br>';
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
|
||||
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
||||
$buttonreset = '';
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
||||
|
||||
|
||||
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
|
||||
@ -179,22 +189,26 @@ print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
|
||||
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(ffd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0 ";
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0";
|
||||
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NULL";
|
||||
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
@ -245,22 +259,26 @@ print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
|
||||
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(ffd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0 ";
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0";
|
||||
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NOT NULL";
|
||||
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
@ -286,7 +304,7 @@ if ($resql) {
|
||||
}
|
||||
else print $row[1];
|
||||
print '</td>';
|
||||
for($i = 2; $i <= 12; $i ++) {
|
||||
for($i = 2; $i <= 12; $i++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
}
|
||||
print '<td align="right">' . price($row[13]) . '</td>';
|
||||
@ -313,20 +331,24 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("Total") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
|
||||
if ($j > 12) $j-=12;
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(ffd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0 ";
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0";
|
||||
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog('htdocs/accountancy/supplier/index.php');
|
||||
@ -334,9 +356,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $row = $db->fetch_row($resql)) {
|
||||
|
||||
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
@ -344,7 +364,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
|
||||
@ -39,7 +39,7 @@ $langs->load("members");
|
||||
if (! $user->admin) accessforbidden();
|
||||
|
||||
|
||||
$type=array('yesno','texte','chaine');
|
||||
$oldtypetonewone=array('texte'=>'text','chaine'=>'string'); // old type to new ones
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
|
||||
@ -53,20 +53,7 @@ if ($action == 'updateall')
|
||||
{
|
||||
$db->begin();
|
||||
$res1=$res2=$res3=$res4=$res5=$res6=0;
|
||||
$res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res2=dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res3=dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res4=dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
// Use vat for invoice creation
|
||||
if ($conf->facture->enabled)
|
||||
{
|
||||
$res4=dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res5=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
||||
{
|
||||
$res6=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
}
|
||||
$res1=dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0)
|
||||
{
|
||||
setEventMessages('ErrorFailedToSaveDate', null, 'errors');
|
||||
@ -82,19 +69,16 @@ if ($action == 'updateall')
|
||||
// Action mise a jour ou ajout d'une constante
|
||||
if ($action == 'update' || $action == 'add')
|
||||
{
|
||||
$constlineid = GETPOST('rowid','int');
|
||||
$constname=GETPOST('constname','alpha');
|
||||
$constvalue=(GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
|
||||
|
||||
if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE' || $constname=='ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue='';
|
||||
if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
|
||||
{
|
||||
if ($constvalue) $constvalue=0;
|
||||
else $constvalue=1;
|
||||
}
|
||||
$constvalue=(GETPOSTISSET('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname, 'alpha') : GETPOST('constvalue'));
|
||||
$consttype=(GETPOSTISSET('consttype_'.$constname) ? GETPOST('consttype_'.$constname, 'alphanohtml') : GETPOST('consttype'));
|
||||
$constnote=(GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote'));
|
||||
|
||||
$consttype=GETPOST('consttype','alpha');
|
||||
$constnote=GETPOST('constnote');
|
||||
$res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity);
|
||||
$typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
|
||||
|
||||
$res=dolibarr_set_const($db,$constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
@ -111,7 +95,7 @@ if ($action == 'update' || $action == 'add')
|
||||
// Action activation d'un sous module du module adherent
|
||||
if ($action == 'set')
|
||||
{
|
||||
$result=dolibarr_set_const($db, GETPOST('name','alpha'),GETPOST('value'),'',0,'',$conf->entity);
|
||||
$result=dolibarr_set_const($db, GETPOST('name','alpha'), GETPOST('value'), '', 0, '', $conf->entity);
|
||||
if ($result < 0)
|
||||
{
|
||||
print $db->error();
|
||||
@ -157,23 +141,15 @@ print '<input type="hidden" name="action" value="updateall">';
|
||||
* Editing global variables not related to a specific theme
|
||||
*/
|
||||
$constantes=array(
|
||||
'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT',
|
||||
'ADHERENT_AUTOREGISTER_NOTIF_MAIL',
|
||||
'ADHERENT_AUTOREGISTER_MAIL_SUBJECT',
|
||||
'ADHERENT_AUTOREGISTER_MAIL',
|
||||
'ADHERENT_MAIL_VALID_SUBJECT',
|
||||
'ADHERENT_MAIL_VALID',
|
||||
'ADHERENT_MAIL_COTIS_SUBJECT',
|
||||
'ADHERENT_MAIL_COTIS',
|
||||
'ADHERENT_MAIL_RESIL_SUBJECT',
|
||||
'ADHERENT_MAIL_RESIL',
|
||||
'ADHERENT_MAIL_FROM',
|
||||
);
|
||||
|
||||
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
|
||||
$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
|
||||
$helptext.='__YEAR__, __MONTH__, __DAY__';
|
||||
'ADHERENT_MAIL_FROM'=>'string',
|
||||
'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
|
||||
'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
|
||||
'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER' =>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
|
||||
'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
|
||||
'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
|
||||
'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
|
||||
'ADHERENT_EMAIL_TEMPLATE_CANCELATION' =>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
|
||||
);
|
||||
|
||||
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
|
||||
|
||||
@ -238,21 +238,6 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if ($action == 'confirm_sendinfo' && $confirm == 'yes')
|
||||
{
|
||||
if ($object->email)
|
||||
{
|
||||
$from=$conf->email_from;
|
||||
if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM;
|
||||
|
||||
$result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent"));
|
||||
|
||||
$langs->load("mails");
|
||||
setEventMessages($langs->trans("MailSuccessfulySent", $from, $object->email), null, 'mesgs');
|
||||
}
|
||||
}*/
|
||||
|
||||
if ($action == 'update' && ! $cancel && $user->rights->adherent->creer)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
@ -630,7 +615,34 @@ if (empty($reshook))
|
||||
// Send confirmation email (according to parameters of member type. Otherwise generic)
|
||||
if ($object->email && GETPOST("send_mail"))
|
||||
{
|
||||
$result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2);
|
||||
$subject = '';
|
||||
$msg= '';
|
||||
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail=new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content fro mtemplae
|
||||
$arraydefaultmessage=null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
|
||||
|
||||
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||
|
||||
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
||||
{
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
|
||||
|
||||
$result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, 2);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
@ -674,7 +686,34 @@ if (empty($reshook))
|
||||
{
|
||||
if ($object->email && GETPOST("send_mail"))
|
||||
{
|
||||
$result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1);
|
||||
$subject = '';
|
||||
$msg= '';
|
||||
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail=new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content fro mtemplae
|
||||
$arraydefaultmessage=null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
|
||||
|
||||
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||
|
||||
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
||||
{
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
|
||||
|
||||
$result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1);
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -1339,7 +1378,7 @@ else
|
||||
array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
|
||||
);
|
||||
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 'yes');
|
||||
}
|
||||
|
||||
// Confirm validate member
|
||||
@ -1350,10 +1389,34 @@ else
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($object->typeid);
|
||||
|
||||
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT);
|
||||
$texttosend=$object->makeSubstitution($adht->getMailOnValid());
|
||||
$subject = '';
|
||||
$msg= '';
|
||||
|
||||
$tmp=$langs->trans("SendAnEMailToMember");
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail=new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content fro mtemplae
|
||||
$arraydefaultmessage=null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION;
|
||||
|
||||
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||
|
||||
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
||||
{
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
|
||||
|
||||
$tmp=$langs->trans("SendingAnEMailToMember");
|
||||
$tmp.='<br>'.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
|
||||
$tmp.='<br>'.$langs->trans("MailRecipient").': <b>'.$object->email.'</b>';
|
||||
$helpcontent='';
|
||||
@ -1375,15 +1438,9 @@ else
|
||||
if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) {
|
||||
$formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>'');
|
||||
}
|
||||
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1,1);
|
||||
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 220);
|
||||
}
|
||||
|
||||
// Confirm send card by mail
|
||||
/*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')
|
||||
{
|
||||
@ -1392,10 +1449,34 @@ else
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($object->typeid);
|
||||
|
||||
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT);
|
||||
$texttosend=$object->makeSubstitution($adht->getMailOnResiliate());
|
||||
$subject = '';
|
||||
$msg= '';
|
||||
|
||||
$tmp=$langs->trans("SendAnEMailToMember");
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail=new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content fro mtemplae
|
||||
$arraydefaultmessage=null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
|
||||
|
||||
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||
|
||||
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
||||
{
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
|
||||
|
||||
$tmp=$langs->trans("SendingAnEMailToMember");
|
||||
$tmp.='<br>('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
|
||||
$tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
|
||||
$helpcontent='';
|
||||
@ -1412,7 +1493,7 @@ else
|
||||
$formquestion=array();
|
||||
if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false'));
|
||||
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
|
||||
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion,'no',1);
|
||||
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resign", $formquestion, 'no', 1, 220);
|
||||
}
|
||||
|
||||
// Confirm remove member
|
||||
@ -1420,7 +1501,7 @@ else
|
||||
{
|
||||
$formquestion=array();
|
||||
if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]));
|
||||
print $form->formconfirm("card.php?rowid=".$id,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1);
|
||||
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1);
|
||||
}
|
||||
|
||||
// Confirm add in spip
|
||||
@ -1623,7 +1704,7 @@ else
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
|
||||
if (empty($reshook)) {
|
||||
if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty')
|
||||
if ($action != 'editlogin' && $action != 'editthirdparty')
|
||||
{
|
||||
// Send
|
||||
if ($object->statut == 1) {
|
||||
|
||||
@ -147,9 +147,11 @@ class Adherent extends CommonObject
|
||||
if ($msgishtml == -1)
|
||||
{
|
||||
$msgishtml = 0;
|
||||
if (dol_textishtml($text,1)) $msgishtml = 1;
|
||||
if (dol_textishtml($text,0)) $msgishtml = 1;
|
||||
}
|
||||
|
||||
dol_syslog('send_an_email msgishtml='.$msgishtml);
|
||||
|
||||
$texttosend=$this->makeSubstitution($text);
|
||||
$subjecttosend=$this->makeSubstitution($subject);
|
||||
if ($msgishtml) $texttosend=dol_htmlentitiesbr($texttosend);
|
||||
@ -1331,7 +1333,7 @@ class Adherent extends CommonObject
|
||||
* Do complementary actions after subscription recording.
|
||||
*
|
||||
* @param int $subscriptionid Id of created subscription
|
||||
* @param string $option Which action ('bankdirect', 'invoiceonly', ...)
|
||||
* @param string $option Which action ('bankdirect', 'bankviainvoice', 'invoiceonly', ...)
|
||||
* @param int $accountid Id bank account
|
||||
* @param int $datesubscription Date of subscription
|
||||
* @param int $paymentdate Date of payment
|
||||
@ -1341,7 +1343,7 @@ class Adherent extends CommonObject
|
||||
* @param string $num_chq Numero cheque (if Id bank account provided)
|
||||
* @param string $emetteur_nom Name of cheque writer
|
||||
* @param string $emetteur_banque Name of bank of cheque
|
||||
* @param string $autocreatethirdparty Auto create new thirdparty if member not linked to a thirdparty.
|
||||
* @param string $autocreatethirdparty Auto create new thirdparty if member not linked to a thirdparty and we request an option that generate invoice.
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom='', $emetteur_banque='', $autocreatethirdparty=0)
|
||||
@ -1352,6 +1354,8 @@ class Adherent extends CommonObject
|
||||
|
||||
$this->invoice = null; // This will contains invoice if an invoice is created
|
||||
|
||||
dol_syslog("subscriptionComplementaryActions subscriptionid=".$subscriptionid." option=".$option." accountid=".$accountid." datesubscription=".$datesubscription." paymentdate=".$paymentdate." label=".$label." amount=".$amount." num_chq=".$num_chq." autocreatethirdparty=".$autocreatethirdparty);
|
||||
|
||||
// Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect'
|
||||
if ($option == 'bankdirect' && $accountid)
|
||||
{
|
||||
@ -1407,7 +1411,7 @@ class Adherent extends CommonObject
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! ($this->fk_soc > 0))
|
||||
if (! ($this->fk_soc > 0)) // If not yet linked to a company
|
||||
{
|
||||
if ($autocreatethirdparty)
|
||||
{
|
||||
@ -1668,6 +1672,8 @@ class Adherent extends CommonObject
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
// End call triggers
|
||||
|
||||
$this->datevalid = $now;
|
||||
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
@ -1892,6 +1898,8 @@ class Adherent extends CommonObject
|
||||
$label.= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
if (! empty($this->firstname) || ! empty($this->lastname))
|
||||
$label.= '<br><b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs);
|
||||
if (! empty($this->societe))
|
||||
$label.= '<br><b>' . $langs->trans('Company') . ':</b> ' . $this->societe;
|
||||
$label.='</div>';
|
||||
|
||||
$url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id;
|
||||
@ -2492,4 +2500,134 @@ class Adherent extends CommonObject
|
||||
return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Send reminders by emails before subscription end
|
||||
* CAN BE A CRON TASK
|
||||
*
|
||||
* @param int $daysbeforeend Nb of days before end of subscription (negative number = after subscription)
|
||||
* @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
|
||||
*/
|
||||
public function sendReminderForExpiredSubscription($daysbeforeend=10)
|
||||
{
|
||||
global $conf, $langs, $mysoc, $user;
|
||||
|
||||
$error = 0;
|
||||
$this->output = '';
|
||||
$this->error='';
|
||||
|
||||
$blockingerrormsg = '';
|
||||
|
||||
/*if (empty($conf->global->MEMBER_REMINDER_EMAIL))
|
||||
{
|
||||
$langs->load("agenda");
|
||||
$this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Adherent"));
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$tmp=dol_getdate($now);
|
||||
$datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), -1 * $daysbeforeend, 'd');
|
||||
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent';
|
||||
$sql.= " WHERE datefin = '".$this->db->idate($datetosearchfor)."'";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_rows = $this->db->num_rows($resql);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$adherent = new Adherent($this->db);
|
||||
$formmail=new FormMail($db);
|
||||
|
||||
$i=0;
|
||||
$nbok = 0;
|
||||
$nbko = 0;
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$adherent->fetch($obj->rowid);
|
||||
|
||||
if (empty($adherent->email))
|
||||
{
|
||||
$nbko++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$adherent->fetch_thirdparty();
|
||||
|
||||
// Send reminder email
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang);
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
|
||||
$arraydefaultmessage=null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION;
|
||||
|
||||
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||
|
||||
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
||||
{
|
||||
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $adherent);
|
||||
//if (is_array($adherent->thirdparty)) $substitutionarraycomp = ...
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $adherent);
|
||||
|
||||
$subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
|
||||
$msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
|
||||
$from = $conf->global->ADHERENT_MAIL_FROM;
|
||||
$to = $adherent->email;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
|
||||
$result = $cmail->sendfile();
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
$this->error = $cmail->error;
|
||||
$this->errors += $cmail->errors;
|
||||
$nbko++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$nbok++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$blockingerrormsg="Can't find email template, defined into member module setup, to use for reminding";
|
||||
$nbko++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($blockingerrormsg)
|
||||
{
|
||||
$this->error = $blockingerrormsg;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->output = 'Found '.($nbok + $nbko).' members to send reminder to.';
|
||||
$this->output.= ' Send email successfuly to '.$nbok.' members';
|
||||
if ($nbko) $this->output.= ' - Canceled for '.$nbko.' member (no email or email sending error)';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -499,7 +499,7 @@ class AdherentType extends CommonObject
|
||||
/**
|
||||
* getMailOnValid
|
||||
*
|
||||
* @return string Return mail model
|
||||
* @return string Return mail content of type or empty
|
||||
*/
|
||||
function getMailOnValid()
|
||||
{
|
||||
@ -509,16 +509,14 @@ class AdherentType extends CommonObject
|
||||
{
|
||||
return $this->mail_valid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $conf->global->ADHERENT_MAIL_VALID;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* getMailOnSubscription
|
||||
*
|
||||
* @return string Return mail model
|
||||
* @return string Return mail content of type or empty
|
||||
*/
|
||||
function getMailOnSubscription()
|
||||
{
|
||||
@ -529,16 +527,14 @@ class AdherentType extends CommonObject
|
||||
{
|
||||
return $this->mail_subscription;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $conf->global->ADHERENT_MAIL_COTIS;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* getMailOnResiliate
|
||||
*
|
||||
* @return string Return mail model
|
||||
* @return string Return mail model content of type or empty
|
||||
*/
|
||||
function getMailOnResiliate()
|
||||
{
|
||||
@ -549,10 +545,8 @@ class AdherentType extends CommonObject
|
||||
{
|
||||
return $this->mail_resiliate;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $conf->global->ADHERENT_MAIL_RESIL;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -593,7 +593,6 @@ while ($i < min($num, $limit))
|
||||
$memberstatic->ref=$obj->rowid;
|
||||
$memberstatic->lastname=$obj->lastname;
|
||||
$memberstatic->firstname=$obj->firstname;
|
||||
$memberstatic->societe=$obj->company;
|
||||
$memberstatic->statut=$obj->statut;
|
||||
$memberstatic->datefin= $datefin;
|
||||
$memberstatic->socid = $obj->fk_soc;
|
||||
@ -605,6 +604,7 @@ while ($i < min($num, $limit))
|
||||
} else {
|
||||
$companyname=$obj->company;
|
||||
}
|
||||
$memberstatic->societe = $companyname;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
|
||||
@ -349,8 +349,32 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
|
||||
// Send confirmation Email
|
||||
if ($object->email && $sendalsoemail)
|
||||
{
|
||||
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
|
||||
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
|
||||
$subject = '';
|
||||
$msg= '';
|
||||
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail=new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content fro mtemplae
|
||||
$arraydefaultmessage=null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
|
||||
|
||||
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||
|
||||
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
||||
{
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
|
||||
|
||||
// Attach a file ?
|
||||
$file='';
|
||||
@ -1018,8 +1042,33 @@ if ($rowid > 0)
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($object->typeid);
|
||||
|
||||
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
|
||||
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
|
||||
// Send subscription email
|
||||
$subject = '';
|
||||
$msg= '';
|
||||
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail=new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content fro mtemplae
|
||||
$arraydefaultmessage=null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
|
||||
|
||||
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
|
||||
|
||||
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
||||
{
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
|
||||
|
||||
$tmp='<input name="sendmail" type="checkbox"'.(GETPOST('sendmail','alpha')?' checked':(! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>';
|
||||
$helpcontent='';
|
||||
|
||||
@ -91,17 +91,17 @@ $tabsqlsort[25]="label ASC, lang ASC, position ASC";
|
||||
|
||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||
$tabfield=array();
|
||||
$tabfield[25]= "label,type_template,lang,fk_user,private,position,topic,joinfiles,content";
|
||||
$tabfield[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
|
||||
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25].=',content_lines';
|
||||
|
||||
// Nom des champs d'edition pour modification d'un enregistrement
|
||||
$tabfieldvalue=array();
|
||||
$tabfieldvalue[25]= "label,type_template,fk_user,lang,private,position,topic,joinfiles,content";
|
||||
$tabfieldvalue[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
|
||||
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25].=',content_lines';
|
||||
|
||||
// Nom des champs dans la table pour insertion d'un enregistrement
|
||||
$tabfieldinsert=array();
|
||||
$tabfieldinsert[25]= "label,type_template,fk_user,lang,private,position,topic,joinfiles,content";
|
||||
$tabfieldinsert[25]= "label,lang,type_template,fk_user,private,position,topic,joinfiles,content";
|
||||
if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25].=',content_lines';
|
||||
$tabfieldinsert[25].=',entity'; // Must be at end because not into other arrays
|
||||
|
||||
@ -233,8 +233,7 @@ if (empty($reshook))
|
||||
$ok=0;
|
||||
$fieldnamekey=$listfield[$f];
|
||||
// We take translate key of field
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
|
||||
if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments';
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Code';
|
||||
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
|
||||
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
|
||||
if ($fieldnamekey == 'type_template') $fieldnamekey = 'TypeOfTemplate';
|
||||
@ -478,7 +477,7 @@ foreach ($fieldlist as $field => $value)
|
||||
if ($fieldlist[$field]=='lang') { $valuetoshow=(empty($conf->global->MAIN_MULTILANGS) ? ' ' : $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"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Code"); }
|
||||
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
|
||||
if ($fieldlist[$field]=='private') { $align='center'; }
|
||||
if ($fieldlist[$field]=='position') { $align='center'; }
|
||||
@ -646,7 +645,7 @@ if ($resql)
|
||||
elseif ($value == 'lang')
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1);
|
||||
print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth150');
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($value == 'fk_user')
|
||||
@ -661,7 +660,7 @@ if ($resql)
|
||||
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>';
|
||||
print '<td class="liste_titre">'.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200 maxwidth100onsmartphone').'</td>';
|
||||
}
|
||||
elseif (! in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
|
||||
}
|
||||
@ -695,7 +694,7 @@ if ($resql)
|
||||
if ($fieldlist[$field]=='fk_user') { $valuetoshow=$langs->trans("Owner"); }
|
||||
if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); }
|
||||
if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Code"); }
|
||||
if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); }
|
||||
if ($fieldlist[$field]=='private') { $align='center'; }
|
||||
if ($fieldlist[$field]=='position') { $align='center'; }
|
||||
@ -867,7 +866,7 @@ if ($resql)
|
||||
print "</td>";
|
||||
|
||||
// Modify link / Delete link
|
||||
print '<td align="center" width="64">';
|
||||
print '<td class="center nowraponall" width="64">';
|
||||
if ($canbemodified) print '<a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a>';
|
||||
if ($iserasable)
|
||||
{
|
||||
@ -990,7 +989,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
{
|
||||
$selectedlang = $langs->defaultlang;
|
||||
if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]};
|
||||
print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1);
|
||||
print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1016,7 +1015,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
}
|
||||
else
|
||||
{
|
||||
print $form->selectarray('type_template', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
|
||||
print $form->selectarray('type_template', $elementList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth200');
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -38,10 +38,6 @@ if (!$user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
|
||||
// Other parameters
|
||||
$list = array (
|
||||
'ACCOUNTING_VAT_PAY_ACCOUNT'
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
@ -76,35 +72,38 @@ if ($action == 'update') {
|
||||
switch ($tax_mode)
|
||||
{
|
||||
case 0:
|
||||
$value = 'payment';
|
||||
$valuesellproduct = 'invoice';
|
||||
$valuebuyproduct = 'invoice';
|
||||
$valuesellservice = 'payment';
|
||||
$valuebuyservice = 'payment';
|
||||
break;
|
||||
case 1:
|
||||
$value = 'invoice';
|
||||
$valuesellproduct = 'invoice';
|
||||
$valuebuyproduct = 'invoice';
|
||||
$valuesellservice = 'invoice';
|
||||
$valuebuyservice = 'invoice';
|
||||
break;
|
||||
case 2:
|
||||
$valuesellproduct = 'payment';
|
||||
$valuebuyproduct = 'payment';
|
||||
$valuesellservice = 'payment';
|
||||
$valuebuyservice = 'payment';
|
||||
break;
|
||||
}
|
||||
|
||||
$res = dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
|
||||
$res = dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', $valuesellproduct,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
|
||||
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', $valuebuyproduct,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
$res = dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', $value,'chaine',0,'',$conf->entity);
|
||||
$res = dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', $valuesellservice, 'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $value,'chaine',0,'',$conf->entity);
|
||||
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $valuebuyservice, 'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'alpha'),'chaine',0,'',$conf->entity);
|
||||
|
||||
dolibarr_set_const($db, "MAIN_INFO_VAT_RETURN", GETPOST("MAIN_INFO_VAT_RETURN",'alpha'),'chaine',0,'',$conf->entity);
|
||||
|
||||
// Others options
|
||||
foreach ($list as $constname) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
@ -157,10 +156,11 @@ else
|
||||
else
|
||||
{
|
||||
print '<td width="120">';
|
||||
$listval=array('0'=>$langs->trans(""),
|
||||
'1'=>$langs->trans("Monthly"),
|
||||
'2'=>$langs->trans("Quarterly"),
|
||||
'3'=>$langs->trans("Annual"),
|
||||
$listval=array(
|
||||
'0'=>$langs->trans(""),
|
||||
'1'=>$langs->trans("Monthly"),
|
||||
'2'=>$langs->trans("Quarterly"),
|
||||
'3'=>$langs->trans("Annual"),
|
||||
);
|
||||
print $form->selectarray("MAIN_INFO_VAT_RETURN", $listval, $conf->global->MAIN_INFO_VAT_RETURN);
|
||||
print "</td>";
|
||||
@ -177,54 +177,77 @@ else
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="titlefield">'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
|
||||
print "</tr>\n";
|
||||
print '<tr class="oddeven"><td width="200"><input type="radio" name="tax_mode" value="0"'.($tax_mode != 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
|
||||
// Standard
|
||||
print '<tr class="oddeven"><td><input type="radio" name="tax_mode" value="0"'.(empty($tax_mode) ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
|
||||
print '<td>'.nl2br($langs->trans('OptionVatDefaultDesc'));
|
||||
print "</td></tr>\n";
|
||||
print '<tr class="oddeven"><td width="200"><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
|
||||
// On debit for services
|
||||
print '<tr class="oddeven"><td><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
|
||||
print '<td>'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
|
||||
|
||||
// On payment for both products and services
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
|
||||
{
|
||||
print '<tr class="oddeven"><td><input type="radio" name="tax_mode" value="2"'.($tax_mode == 2 ? ' checked' : '').'> '.$langs->trans('OptionPaymentForProductAndServices').'</td>';
|
||||
print '<td>'.nl2br($langs->trans('OptionPaymentForProductAndServicesDesc'))."</td></tr>\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
print '<br>';
|
||||
print ' -> '.$langs->trans("SummaryOfVatExigibilityUsedByDefault");
|
||||
print load_fiche_titre('', '', '', 0, 0, '', '-> '.$langs->trans("SummaryOfVatExigibilityUsedByDefault"));
|
||||
//print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')';
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td class="titlefield"> </td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
|
||||
print '<tr class="oddeven"><td class="titlefield"> </td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
|
||||
|
||||
// Products
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("Product").'</td>';
|
||||
print '<td>';
|
||||
print $langs->trans("OnDelivery");
|
||||
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
|
||||
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment')
|
||||
{
|
||||
print $langs->trans("OnPayment");
|
||||
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("OnDelivery");
|
||||
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $langs->trans("OnDelivery");
|
||||
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment')
|
||||
{
|
||||
print $langs->trans("OnPayment");
|
||||
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("OnDelivery");
|
||||
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Services
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("Services").'</td>';
|
||||
print '<td>';
|
||||
if ($tax_mode == 0)
|
||||
if ($conf->global->TAX_MODE_BUY_SERVICE == 'payment')
|
||||
{
|
||||
print $langs->trans("OnPayment");
|
||||
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
|
||||
}
|
||||
if ($tax_mode == 1)
|
||||
else
|
||||
{
|
||||
print $langs->trans("OnInvoice");
|
||||
print ' ('.$langs->trans("InvoiceDateUsed").')';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($tax_mode == 0)
|
||||
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment')
|
||||
{
|
||||
print $langs->trans("OnPayment");
|
||||
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
|
||||
}
|
||||
if ($tax_mode == 1)
|
||||
else
|
||||
{
|
||||
print $langs->trans("OnInvoice");
|
||||
print ' ('.$langs->trans("InvoiceDateUsed").')';
|
||||
@ -237,51 +260,21 @@ else
|
||||
print "<br>\n";
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Others params
|
||||
*/
|
||||
|
||||
print load_fiche_titre($langs->trans("OtherOptions"),'','');
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="titlefield">' . $langs->trans('Parameters') . '</td>';
|
||||
print '<td><td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ($list as $key)
|
||||
{
|
||||
print '<tr class="oddeven value">';
|
||||
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
print '<td><label for="'.$key.'">'.$label.'</label></td>';
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
if (! empty($conf->accounting->enabled))
|
||||
{
|
||||
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
//dol_fiche_end();
|
||||
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="button">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
|
||||
|
||||
if (! empty($conf->accounting->enabled))
|
||||
{
|
||||
$langs->load("accountancy");
|
||||
print '<br><br><span class="opacitymedium">'.$langs->trans("AccountingAccountForSalesTaxAreDefinedInto", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup")).'</span>';
|
||||
}
|
||||
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -183,7 +183,7 @@ $langs->load("cashdesk");
|
||||
else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />';
|
||||
print '</div>';
|
||||
print '<div class="inline-block" style="margin: 6px;">';
|
||||
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0)
|
||||
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")).'" />';
|
||||
@ -191,7 +191,7 @@ $langs->load("cashdesk");
|
||||
else print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />';
|
||||
print '</div>';
|
||||
print '<div class="inline-block" style="margin: 6px;">';
|
||||
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0)
|
||||
if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete")).'" />';
|
||||
|
||||
@ -1654,7 +1654,8 @@ class ActionComm extends CommonObject
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$this->output = '';
|
||||
$error = 0;
|
||||
$this->output = '';
|
||||
$this->error='';
|
||||
|
||||
if (empty($conf->global->AGENDA_REMINDER_EMAIL))
|
||||
@ -1668,6 +1669,8 @@ class ActionComm extends CommonObject
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done
|
||||
|
||||
|
||||
@ -1676,7 +1679,9 @@ class ActionComm extends CommonObject
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'";
|
||||
$this->db->query($sql);
|
||||
|
||||
return 0;
|
||||
$this->db->commit();
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -32,10 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||
|
||||
$langs->load("users");
|
||||
$langs->load("companies");
|
||||
$langs->load("agenda");
|
||||
$langs->load("commercial");
|
||||
$langs->loadLangs(array("users","companies","agenda","commercial"));
|
||||
|
||||
$action=GETPOST('action','alpha');
|
||||
$resourceid=GETPOST("resourceid","int");
|
||||
@ -57,6 +54,7 @@ else
|
||||
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
|
||||
}
|
||||
if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
|
||||
$search_id=GETPOST('search_id','alpha');
|
||||
$search_title=GETPOST('search_title','alpha');
|
||||
|
||||
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int'));
|
||||
@ -170,7 +168,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
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
|
||||
{
|
||||
//$actioncode='';
|
||||
$search_title='';
|
||||
$search_id='';
|
||||
$search_title='';
|
||||
$datestart='';
|
||||
$dateend='';
|
||||
$status='';
|
||||
@ -199,24 +198,25 @@ llxHeader('',$langs->trans("Agenda"),$help_url);
|
||||
$listofextcals=array();
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
|
||||
if ($actioncode != '') {
|
||||
if(is_array($actioncode)) {
|
||||
foreach($actioncode as $str_action) $param.="&actioncode[]=".$str_action;
|
||||
} else $param.="&actioncode=".$actioncode;
|
||||
foreach($actioncode as $str_action) $param.="&actioncode[]=".urlencode($str_action);
|
||||
} else $param.="&actioncode=".urlencode($actioncode);
|
||||
}
|
||||
if ($resourceid > 0) $param.="&resourceid=".$resourceid;
|
||||
if ($status != '' && $status > -1) $param.="&status=".$status;
|
||||
if ($filter) $param.="&filter=".$filter;
|
||||
if ($filtert) $param.="&filtert=".$filtert;
|
||||
if ($socid) $param.="&socid=".$socid;
|
||||
if ($resourceid > 0) $param.="&resourceid=".urlencode($resourceid);
|
||||
if ($status != '' && $status > -1) $param.="&status=".urlencode($status);
|
||||
if ($filter) $param.="&filter=".urlencode($filter);
|
||||
if ($filtert) $param.="&filtert=".urlencode($filtert);
|
||||
if ($socid) $param.="&socid=".urlencode($socid);
|
||||
if ($showbirthday) $param.="&showbirthday=1";
|
||||
if ($pid) $param.="&projectid=".$pid;
|
||||
if ($type) $param.="&type=".$type;
|
||||
if ($usergroup) $param.="&usergroup=".$usergroup;
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
if ($search_title != '') $param.='&search_title='.$search_title;
|
||||
if ($pid) $param.="&projectid=".urlencode($pid);
|
||||
if ($type) $param.="&type=".urlencode($type);
|
||||
if ($usergroup) $param.="&usergroup=".urlencode($usergroup);
|
||||
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||
if ($search_id != '') $param.='&search_title='.urlencode($search_id);
|
||||
if ($search_title != '') $param.='&search_title='.urlencode($search_title);
|
||||
if (GETPOST('datestartday','int')) $param.='&datestartday='.GETPOST('datestartday','int');
|
||||
if (GETPOST('datestartmonth','int')) $param.='&datestartmonth='.GETPOST('datestartmonth','int');
|
||||
if (GETPOST('datestartyear','int')) $param.='&datestartyear='.GETPOST('datestartyear','int');
|
||||
@ -293,6 +293,7 @@ if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // R
|
||||
if ($status == '100') { $sql.= " AND a.percent = 100"; }
|
||||
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
|
||||
if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
|
||||
if ($search_id) $sql.=natural_search("a.id", $search_id, 1);
|
||||
if ($search_title) $sql.=natural_search("a.label", $search_title);
|
||||
// We must filter on assignement table
|
||||
if ($filtert > 0 || $usergroup > 0)
|
||||
@ -421,7 +422,7 @@ if ($resql)
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
print '<tr class="liste_titre_filter">';
|
||||
if (! empty($arrayfields['a.id']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (! empty($arrayfields['a.id']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
|
||||
if (! empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (! empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (! empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
|
||||
@ -492,7 +493,6 @@ if ($resql)
|
||||
$caction=new CActionComm($db);
|
||||
$arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1);
|
||||
|
||||
$var=true;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
@ -660,8 +660,6 @@ if ($object->id > 0)
|
||||
*/
|
||||
if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
|
||||
{
|
||||
$propal_static = new Propal($db);
|
||||
|
||||
$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht";
|
||||
$sql.= ", p.tva as total_tva";
|
||||
$sql.= ", p.total as total_ttc";
|
||||
@ -676,9 +674,9 @@ if ($object->id > 0)
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$var=true;
|
||||
$num = $db->num_rows($resql);
|
||||
$propal_static = new Propal($db);
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num > 0)
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
@ -727,8 +725,6 @@ if ($object->id > 0)
|
||||
*/
|
||||
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
|
||||
{
|
||||
$commande_static=new Commande($db);
|
||||
|
||||
$sql = "SELECT s.nom, s.rowid";
|
||||
$sql.= ", c.rowid as cid, c.total_ht";
|
||||
$sql.= ", c.tva as total_tva";
|
||||
@ -744,9 +740,9 @@ if ($object->id > 0)
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$var=true;
|
||||
$num = $db->num_rows($resql);
|
||||
$commande_static=new Commande($db);
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num > 0)
|
||||
{
|
||||
// Check if there are orders billable
|
||||
@ -808,9 +804,8 @@ if ($object->id > 0)
|
||||
/*
|
||||
* Last shipments
|
||||
*/
|
||||
if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
|
||||
$sendingstatic = new Expedition($db);
|
||||
|
||||
if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire)
|
||||
{
|
||||
$sql = 'SELECT e.rowid as id';
|
||||
$sql.= ', e.ref';
|
||||
$sql.= ', e.date_creation';
|
||||
@ -829,10 +824,11 @@ if ($object->id > 0)
|
||||
$sql.= " ORDER BY e.date_creation DESC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$var = true;
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($resql)
|
||||
{
|
||||
$sendingstatic = new Expedition($db);
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num > 0) {
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -843,12 +839,16 @@ if ($object->id > 0)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
while ($i < $num && $i < $MAXLIST) {
|
||||
$i = 0;
|
||||
while ($i < $num && $i < $MAXLIST)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
|
||||
$sendingstatic->id = $objp->id;
|
||||
$sendingstatic->ref = $objp->ref;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
print $sendingstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
if ($objp->date_creation > 0) {
|
||||
@ -875,9 +875,7 @@ if ($object->id > 0)
|
||||
*/
|
||||
if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
|
||||
{
|
||||
$contratstatic=new Contrat($db);
|
||||
|
||||
$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc, c.date_contrat as dcon, c.ref_supplier as refsup";
|
||||
$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
|
||||
$sql.= " WHERE c.fk_soc = s.rowid ";
|
||||
$sql.= " AND s.rowid = ".$object->id;
|
||||
@ -887,9 +885,10 @@ if ($object->id > 0)
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$var=true;
|
||||
$contrat=new Contrat($db);
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num >0 )
|
||||
if ($num >0)
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -900,17 +899,19 @@ if ($object->id > 0)
|
||||
print '</tr></table></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num && $i < $MAXLIST)
|
||||
{
|
||||
$contrat=new Contrat($db);
|
||||
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$contrat->id=$objp->id;
|
||||
$contrat->ref=$objp->ref?$objp->ref:$objp->id;
|
||||
$contrat->ref_customer=$objp->refcus;
|
||||
$contrat->ref_supplier=$objp->refsup;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
$contrat->id=$objp->id;
|
||||
$contrat->ref=$objp->ref?$objp->ref:$objp->id;
|
||||
print $contrat->getNomUrl(1,12);
|
||||
print "</td>\n";
|
||||
print '<td class="nowrap">'.dol_trunc($objp->refsup,12)."</td>\n";
|
||||
@ -946,12 +947,11 @@ if ($object->id > 0)
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= " ORDER BY f.tms DESC";
|
||||
|
||||
$fichinter_static=new Fichinter($db);
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$var=true;
|
||||
$fichinter_static=new Fichinter($db);
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num > 0)
|
||||
{
|
||||
@ -962,8 +962,8 @@ if ($object->id > 0)
|
||||
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/fichinter/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
|
||||
print '</tr></table></td>';
|
||||
print '</tr>';
|
||||
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num && $i < $MAXLIST)
|
||||
{
|
||||
@ -996,8 +996,6 @@ if ($object->id > 0)
|
||||
*/
|
||||
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
$invoicetemplate = new FactureRec($db);
|
||||
|
||||
$sql = 'SELECT f.rowid as id, f.titre as ref, f.amount';
|
||||
$sql.= ', f.total as total_ht';
|
||||
$sql.= ', f.tva as total_tva';
|
||||
@ -1020,9 +1018,9 @@ if ($object->id > 0)
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$var=true;
|
||||
$invoicetemplate = new FactureRec($db);
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num > 0)
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
@ -1033,12 +1031,11 @@ if ($object->id > 0)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num && $i < $MAXLIST)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
$invoicetemplate->id = $objp->id;
|
||||
$invoicetemplate->ref = $objp->ref;
|
||||
$invoicetemplate->suspended = $objp->suspended;
|
||||
@ -1047,6 +1044,9 @@ if ($object->id > 0)
|
||||
$invoicetemplate->total_ht = $objp->total_ht;
|
||||
$invoicetemplate->total_tva = $objp->total_tva;
|
||||
$invoicetemplate->total_ttc = $objp->total_ttc;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
print $invoicetemplate->getNomUrl(1);
|
||||
print '</td>';
|
||||
if ($objp->frequency && $objp->date_last_gen > 0)
|
||||
@ -1097,8 +1097,6 @@ if ($object->id > 0)
|
||||
*/
|
||||
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
$facturestatic = new Facture($db);
|
||||
|
||||
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount';
|
||||
$sql.= ', f.total as total_ht';
|
||||
$sql.= ', f.tva as total_tva';
|
||||
@ -1118,9 +1116,9 @@ if ($object->id > 0)
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$var=true;
|
||||
$facturestatic = new Facture($db);
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num > 0)
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
@ -1132,18 +1130,20 @@ if ($object->id > 0)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num && $i < $MAXLIST)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
$facturestatic->id = $objp->facid;
|
||||
$facturestatic->ref = $objp->facnumber;
|
||||
$facturestatic->type = $objp->type;
|
||||
$facturestatic->total_ht = $objp->total_ht;
|
||||
$facturestatic->total_tva = $objp->total_tva;
|
||||
$facturestatic->total_ttc = $objp->total_ttc;
|
||||
$facturestatic->total_ht = $objp->total_ht;
|
||||
$facturestatic->total_tva = $objp->total_tva;
|
||||
$facturestatic->total_ttc = $objp->total_ttc;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
print $facturestatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
if ($objp->df > 0)
|
||||
|
||||
@ -1980,17 +1980,17 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
|
||||
@ -1530,8 +1530,8 @@ class Commande extends CommonOrder
|
||||
{
|
||||
$prod = new Product($this->db);
|
||||
$prod->fetch($idproduct);
|
||||
$prod -> get_sousproduits_arbo ();
|
||||
$prods_arbo = $prod->get_each_prod();
|
||||
$prod -> get_sousproduits_arbo();
|
||||
$prods_arbo = $prod->get_arbo_each_prod();
|
||||
if(count($prods_arbo) > 0)
|
||||
{
|
||||
foreach($prods_arbo as $key => $value)
|
||||
|
||||
@ -332,7 +332,7 @@ class Account extends CommonObject
|
||||
* @param int $fk_bank To search using bank transaction id
|
||||
* @param int $url_id To search using link to
|
||||
* @param string $type To search using type
|
||||
* @return array|-1 Array of links or -1 on error
|
||||
* @return array|-1 Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error
|
||||
*/
|
||||
function get_url($fk_bank='', $url_id='', $type='')
|
||||
{
|
||||
|
||||
@ -3988,7 +3988,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'discount_vat') {
|
||||
print '<tr><td colspan="' . $nbcols . '" align="right" class="nowrap">';
|
||||
print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1);
|
||||
print '</td><td align="right">' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . '</td><td> </td></tr>';
|
||||
print '</td><td align="right">' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . '</td><td> </td></tr>';
|
||||
$resteapayeraffiche = 0;
|
||||
$cssforamountpaymentcomplete = '';
|
||||
}
|
||||
@ -3996,7 +3996,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'badcustomer') {
|
||||
print '<tr><td colspan="' . $nbcols . '" align="right" class="nowrap">';
|
||||
print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1);
|
||||
print '</td><td align="right">' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . '</td><td> </td></tr>';
|
||||
print '</td><td align="right">' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . '</td><td> </td></tr>';
|
||||
// $resteapayeraffiche=0;
|
||||
$cssforamountpaymentcomplete = '';
|
||||
}
|
||||
@ -4004,7 +4004,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'product_returned') {
|
||||
print '<tr><td colspan="' . $nbcols . '" align="right" class="nowrap">';
|
||||
print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1);
|
||||
print '</td><td align="right">' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . '</td><td> </td></tr>';
|
||||
print '</td><td align="right">' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . '</td><td> </td></tr>';
|
||||
$resteapayeraffiche = 0;
|
||||
$cssforamountpaymentcomplete = '';
|
||||
}
|
||||
@ -4015,7 +4015,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
if ($object->close_note)
|
||||
$text .= '<br><br><b>' . $langs->trans("Reason") . '</b>:' . $object->close_note;
|
||||
print $form->textwithpicto($langs->trans("Abandoned") . ':', $text, - 1);
|
||||
print '</td><td align="right">' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . '</td><td> </td></tr>';
|
||||
print '</td><td align="right">' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . '</td><td> </td></tr>';
|
||||
$resteapayeraffiche = 0;
|
||||
$cssforamountpaymentcomplete = '';
|
||||
}
|
||||
|
||||
@ -68,6 +68,13 @@ class FactureRec extends CommonInvoice
|
||||
|
||||
var $usenewprice=0;
|
||||
|
||||
var $suspended; // status
|
||||
|
||||
const STATUS_NOTSUSPENDED = 0;
|
||||
const STATUS_SUSPENDED = 1;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -95,6 +102,7 @@ class FactureRec extends CommonInvoice
|
||||
// Clean parameters
|
||||
$this->titre=trim($this->titre);
|
||||
$this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice;
|
||||
if (empty($this->suspended)) $this->suspended=0;
|
||||
|
||||
// No frequency defined then no next date to execution
|
||||
if (empty($this->frequency))
|
||||
@ -147,6 +155,7 @@ class FactureRec extends CommonInvoice
|
||||
$sql.= ", fk_multicurrency";
|
||||
$sql.= ", multicurrency_code";
|
||||
$sql.= ", multicurrency_tx";
|
||||
$sql.= ", suspended";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$this->db->escape($this->titre)."'";
|
||||
$sql.= ", ".$facsrc->socid;
|
||||
@ -167,13 +176,14 @@ class FactureRec extends CommonInvoice
|
||||
$sql.= ", '".$this->db->escape($this->unit_frequency)."'";
|
||||
$sql.= ", ".(!empty($this->date_when)?"'".$this->db->idate($this->date_when)."'":'NULL');
|
||||
$sql.= ", ".(!empty($this->date_last_gen)?"'".$this->db->idate($this->date_last_gen)."'":'NULL');
|
||||
$sql.= ", ".$this->nb_gen_done;
|
||||
$sql.= ", ".$this->nb_gen_max;
|
||||
$sql.= ", ".$this->auto_validate;
|
||||
$sql.= ", ".$this->generate_pdf;
|
||||
$sql.= ", ".$facsrc->fk_multicurrency;
|
||||
$sql.= ", '".$facsrc->multicurrency_code."'";
|
||||
$sql.= ", ".$facsrc->multicurrency_tx;
|
||||
$sql.= ", ".$this->db->escape($this->nb_gen_done);
|
||||
$sql.= ", ".$this->db->escape($this->nb_gen_max);
|
||||
$sql.= ", ".$this->db->escape($this->auto_validate);
|
||||
$sql.= ", ".$this->db->escape($this->generate_pdf);
|
||||
$sql.= ", ".$this->db->escape($facsrc->fk_multicurrency);
|
||||
$sql.= ", '".$this->db->escape($facsrc->multicurrency_code)."'";
|
||||
$sql.= ", ".$this->db->escape($facsrc->multicurrency_tx);
|
||||
$sql.= ", ".$this->db->escape($this->suspended);
|
||||
$sql.= ")";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
@ -1149,49 +1159,69 @@ class FactureRec extends CommonInvoice
|
||||
$prefix='';
|
||||
if ($recur)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Disabled'); // credit note
|
||||
if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled');
|
||||
else return $langs->trans('Active');
|
||||
}
|
||||
else return $langs->trans("Draft");
|
||||
else
|
||||
{
|
||||
if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled');
|
||||
else return $langs->trans("Draft");
|
||||
}
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
$prefix='Short';
|
||||
if ($recur)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Disabled');
|
||||
if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled');
|
||||
else return $langs->trans('Active');
|
||||
}
|
||||
else return $langs->trans("Draft");
|
||||
else
|
||||
{
|
||||
if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled');
|
||||
else return $langs->trans("Draft");
|
||||
}
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($recur)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
|
||||
if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
|
||||
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
|
||||
}
|
||||
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
|
||||
else
|
||||
{
|
||||
if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
|
||||
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
|
||||
}
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($recur)
|
||||
{
|
||||
$prefix='Short';
|
||||
if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6');
|
||||
if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6');
|
||||
else return img_picto($langs->trans('Active'),'statut4');
|
||||
}
|
||||
else return img_picto($langs->trans('Draft'),'statut0');
|
||||
else
|
||||
{
|
||||
if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6');
|
||||
else return img_picto($langs->trans('Draft'),'statut0');
|
||||
}
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
$prefix='';
|
||||
if ($recur)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
|
||||
if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
|
||||
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
|
||||
}
|
||||
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
|
||||
else
|
||||
{
|
||||
if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
|
||||
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
|
||||
}
|
||||
}
|
||||
if ($mode == 5 || $mode == 6)
|
||||
{
|
||||
@ -1199,10 +1229,14 @@ class FactureRec extends CommonInvoice
|
||||
if ($mode == 5) $prefix='Short';
|
||||
if ($recur)
|
||||
{
|
||||
if ($status == 1) return '<span class="xhideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'),'statut6');
|
||||
if ($status == self::STATUS_SUSPENDED) return '<span class="xhideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'),'statut6');
|
||||
else return '<span class="xhideonsmartphone">'.$langs->trans('Active').' </span>'.img_picto($langs->trans('Active'),'statut4');
|
||||
}
|
||||
else return $langs->trans('Draft').' '.img_picto($langs->trans('Active'),'statut0');
|
||||
else
|
||||
{
|
||||
if ($status == self::STATUS_SUSPENDED) return '<span class="xhideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'),'statut6');
|
||||
else return $langs->trans('Draft').' '.img_picto($langs->trans('Active'),'statut0');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@ class Paiement extends CommonObject
|
||||
{
|
||||
if ($accountid <= 0)
|
||||
{
|
||||
$this->error='Bad value for parameter accountid';
|
||||
$this->error='Bad value for parameter accountid='.$accountid;
|
||||
dol_syslog(get_class($this).'::addPaymentToBank '.$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ $langs->load("compta");
|
||||
$langs->load("companies");
|
||||
$langs->load("products");
|
||||
$langs->load("other");
|
||||
$langs->load("admin");
|
||||
|
||||
// Date range
|
||||
$year=GETPOST("year");
|
||||
@ -132,24 +133,28 @@ $fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
|
||||
$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
|
||||
$fsearch.=' <input type="text" name="min" id="min" value="'.$min.'" size="6">';
|
||||
|
||||
$description='';
|
||||
|
||||
$calcmode='';
|
||||
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
|
||||
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
|
||||
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
|
||||
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
|
||||
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||
}
|
||||
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
|
||||
|
||||
// Affiche en-tete du rapport
|
||||
if ($modetax==1) { // Calculate on invoice for goods and services
|
||||
$name=$langs->trans("VATReportByCustomersInDueDebtMode");
|
||||
$calcmode=$langs->trans("CalcModeVATDebt");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
//$name.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=0">','</a>').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATDueServices");
|
||||
$description.='<br>';
|
||||
$description.=$langs->trans("RulesVATDueProducts");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||
} else {
|
||||
$description.='<br>'.$langs->trans("DepositsAreIncluded");
|
||||
}
|
||||
$description.=$fsearch;
|
||||
$description.='<br>'
|
||||
. '<input type="radio" name="extra_report" value="0" '.($special_report?'':'checked="checked"').'> '
|
||||
@ -178,20 +183,8 @@ if ($modetax==1) { // Calculate on invoice for goods and services
|
||||
}
|
||||
if ($modetax==0) { // Invoice for goods, payment for services
|
||||
$name=$langs->trans("VATReportByCustomersInInputOutputMode");
|
||||
$calcmode=$langs->trans("CalcModeVATEngagement");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
//$name.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=1">','</a>').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATInServices");
|
||||
$description.=' '.$langs->trans("DepositsAreIncluded");
|
||||
$description.='<br>';
|
||||
$description.=$langs->trans("RulesVATInProducts");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description .= ' ' . $langs->trans("DepositsAreNotIncluded");
|
||||
} else {
|
||||
$description .= ' ' . $langs->trans("DepositsAreIncluded");
|
||||
}
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
$description.=$fsearch;
|
||||
|
||||
@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
$langs->loadLangs(array("other","compta","banks","bills","companies"));
|
||||
$langs->loadLangs(array("other","compta","banks","bills","companies","admin"));
|
||||
|
||||
$year=GETPOST("year","int");
|
||||
if ($year == 0)
|
||||
@ -107,9 +107,23 @@ function pt ($db, $sql, $date)
|
||||
$tva = new Tva($db);
|
||||
|
||||
$name = $langs->trans("ReportByMonth");
|
||||
$description = $langs->trans("VATSummary");
|
||||
$calcmode = $langs->trans("VATReportBuildWithOptionDefinedInModule").' ';
|
||||
$calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
|
||||
$calcmode='';
|
||||
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
|
||||
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
|
||||
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
|
||||
$description = $langs->trans("VATSummary").'<br>';
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
|
||||
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
|
||||
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||
}
|
||||
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
|
||||
|
||||
$builddate=dol_now();
|
||||
|
||||
llxHeader('', $name);
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007, 2015 Yannick Warnier <ywarnier@beeznest.org>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@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
|
||||
@ -21,10 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/tva/quadri_detail.php
|
||||
* \ingroup tax
|
||||
* \file htdocs/compta/tva/quadri_detail.php
|
||||
* \ingroup tax
|
||||
* \brief Trimestrial page - detailed version
|
||||
* TODO Deal with recurrent invoices as well
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
@ -46,6 +44,7 @@ $langs->load("companies");
|
||||
$langs->load("products");
|
||||
$langs->load("trips");
|
||||
$langs->load("other");
|
||||
$langs->load("admin");
|
||||
|
||||
// Date range
|
||||
$year=GETPOST("year","int");
|
||||
@ -68,11 +67,11 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); }
|
||||
else
|
||||
{
|
||||
$month_current = strftime("%m",dol_now());
|
||||
if ($month_current >= 10) $q=4;
|
||||
elseif ($month_current >= 7) $q=3;
|
||||
elseif ($month_current >= 4) $q=2;
|
||||
else $q=1;
|
||||
$month_current = strftime("%m",dol_now());
|
||||
if ($month_current >= 10) $q=4;
|
||||
elseif ($month_current >= 7) $q=3;
|
||||
elseif ($month_current >= 4) $q=2;
|
||||
else $q=1;
|
||||
}
|
||||
}
|
||||
if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
|
||||
@ -103,7 +102,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
|
||||
$morequerystring='';
|
||||
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
|
||||
foreach($listofparams as $param)
|
||||
foreach ($listofparams as $param)
|
||||
{
|
||||
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
|
||||
}
|
||||
@ -130,86 +129,60 @@ $fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
|
||||
//$fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
||||
|
||||
|
||||
// Affiche en-tete du rapport
|
||||
if ($modetax==1) // Calculate on invoice for goods and services
|
||||
{
|
||||
$name=$langs->trans("VATReportByQuartersInDueDebtMode");
|
||||
$calcmode=$langs->trans("CalcModeVATDebt");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
if ($prevquarter > 1) $prevquarter--;
|
||||
else { $prevquarter=4; $prevyear--; }
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) $nextquarter++;
|
||||
else { $nextquarter=1; $nextyear++; }
|
||||
//$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATDueServices");
|
||||
$description.='<br>';
|
||||
$description.=$langs->trans("RulesVATDueProducts");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||
else $description.='<br>'.$langs->trans("DepositsAreIncluded");
|
||||
$description.=$fsearch;
|
||||
$builddate=dol_now();
|
||||
//$exportlink=$langs->trans("NotYetAvailable");
|
||||
|
||||
// Customers invoices
|
||||
$elementcust=$langs->trans("CustomersInvoices");
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
|
||||
// Suppliers invoices
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("ProductOrService");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPaid");
|
||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
|
||||
// Show report header
|
||||
$name=$langs->trans("VATReportByPeriods");
|
||||
$calcmode='';
|
||||
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
|
||||
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
|
||||
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
// Set period
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
if ($prevquarter > 1) {
|
||||
$prevquarter--;
|
||||
} else {
|
||||
$prevquarter=4; $prevyear--;
|
||||
}
|
||||
if ($modetax==0) // Invoice for goods, payment for services
|
||||
{
|
||||
$name=$langs->trans("VATReportByQuartersInInputOutputMode");
|
||||
$calcmode=$langs->trans("CalcModeVATEngagement");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
if ($prevquarter > 1) $prevquarter--;
|
||||
else { $prevquarter=4; $prevyear--; }
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) $nextquarter++;
|
||||
else { $nextquarter=1; $nextyear++; }
|
||||
//$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATInServices");
|
||||
$description.=' '.$langs->trans("DepositsAreIncluded");
|
||||
$description.='<br>';
|
||||
$description.=$langs->trans("RulesVATInProducts");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded");
|
||||
else $description.=' '.$langs->trans("DepositsAreIncluded");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
$description.=$fsearch;
|
||||
$builddate=dol_now();
|
||||
//$exportlink=$langs->trans("NotYetAvailable");
|
||||
|
||||
// Customers invoices
|
||||
$elementcust=$langs->trans("CustomersInvoices");
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
|
||||
// Suppliers invoices
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("ProductOrService");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPaid");
|
||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) {
|
||||
$nextquarter++;
|
||||
} else {
|
||||
$nextquarter=1; $nextyear++;
|
||||
}
|
||||
$description.=$fsearch;
|
||||
$builddate=dol_now();
|
||||
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
|
||||
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
|
||||
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||
}
|
||||
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
|
||||
|
||||
// Customers invoices
|
||||
$elementcust=$langs->trans("CustomersInvoices");
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
$namecust=$langs->trans("Name");
|
||||
if ($mysoc->tva_assuj) {
|
||||
$vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
}
|
||||
|
||||
// Suppliers invoices
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$productcust;
|
||||
$amountsup=$amountcust;
|
||||
$vatsup=$langs->trans("VATPaid");
|
||||
$namesup=$namecust;
|
||||
if ($mysoc->tva_assuj) {
|
||||
$vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
|
||||
|
||||
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
|
||||
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
@ -222,6 +195,7 @@ print '<table class="noborder" width="100%">';
|
||||
$y = $year_current;
|
||||
$total = 0;
|
||||
$i=0;
|
||||
$columns = 5;
|
||||
|
||||
// Load arrays of datas
|
||||
$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
|
||||
@ -230,60 +204,63 @@ $x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
|
||||
if (! is_array($x_coll) || ! is_array($x_paye))
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($x_coll == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($x_coll == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($x_coll == -1) {
|
||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '</td></tr>';
|
||||
} else if ($x_coll == -2) {
|
||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("FeatureNotYetAvailable") . '</td></tr>';
|
||||
} else {
|
||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("Error") . '</td></tr>';
|
||||
}
|
||||
} else {
|
||||
$x_both = array();
|
||||
//now, from these two arrays, get another array with one rate per line
|
||||
foreach(array_keys($x_coll) as $my_coll_rate)
|
||||
{
|
||||
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
|
||||
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
|
||||
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
|
||||
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
|
||||
$x_both[$my_coll_rate]['paye']['vat'] = 0;
|
||||
$x_both[$my_coll_rate]['coll']['links'] = '';
|
||||
$x_both[$my_coll_rate]['coll']['detail'] = array();
|
||||
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy)
|
||||
{
|
||||
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
|
||||
$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
|
||||
$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
|
||||
$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
|
||||
$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
|
||||
$x_both[$my_coll_rate]['coll']['detail'][] = array(
|
||||
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
|
||||
'descr' =>$x_coll[$my_coll_rate]['descr'][$id],
|
||||
'pid' =>$x_coll[$my_coll_rate]['pid'][$id],
|
||||
'pref' =>$x_coll[$my_coll_rate]['pref'][$id],
|
||||
'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id],
|
||||
'payment_id' =>$x_coll[$my_coll_rate]['payment_id'][$id],
|
||||
'payment_amount' =>$x_coll[$my_coll_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc' =>$x_coll[$my_coll_rate]['ftotal_ttc'][$id],
|
||||
'dtotal_ttc' =>$x_coll[$my_coll_rate]['dtotal_ttc'][$id],
|
||||
'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id],
|
||||
'ddate_start' =>$x_coll[$my_coll_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id],
|
||||
'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
||||
'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_customer->getNomUrl(1,'',12));
|
||||
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
|
||||
'descr' =>$x_coll[$my_coll_rate]['descr'][$id],
|
||||
'pid' =>$x_coll[$my_coll_rate]['pid'][$id],
|
||||
'pref' =>$x_coll[$my_coll_rate]['pref'][$id],
|
||||
'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id],
|
||||
'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id],
|
||||
'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id],
|
||||
'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id],
|
||||
'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id],
|
||||
'datef' =>$x_coll[$my_coll_rate]['datef'][$id],
|
||||
'datep' =>$x_coll[$my_coll_rate]['datep'][$id],
|
||||
'company_link'=>$company_static->getNomUrl(1,'',20),
|
||||
'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id],
|
||||
'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
||||
'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_customer->getNomUrl(1,'',12)
|
||||
);
|
||||
}
|
||||
}
|
||||
// tva paid
|
||||
foreach(array_keys($x_paye) as $my_paye_rate){
|
||||
foreach (array_keys($x_paye) as $my_paye_rate) {
|
||||
$x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
|
||||
$x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
|
||||
if(!isset($x_both[$my_paye_rate]['coll']['totalht'])){
|
||||
if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
|
||||
$x_both[$my_paye_rate]['coll']['totalht'] = 0;
|
||||
$x_both[$my_paye_rate]['coll']['vat'] = 0;
|
||||
}
|
||||
$x_both[$my_paye_rate]['paye']['links'] = '';
|
||||
$x_both[$my_paye_rate]['paye']['detail'] = array();
|
||||
|
||||
foreach($x_paye[$my_paye_rate]['facid'] as $id=>$dummy)
|
||||
foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy)
|
||||
{
|
||||
// ExpenseReport
|
||||
if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment')
|
||||
@ -293,21 +270,21 @@ else
|
||||
$expensereport->type=$x_paye[$my_paye_rate]['type'][$id];
|
||||
|
||||
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
||||
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
||||
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
||||
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
||||
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
||||
'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id],
|
||||
'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
||||
'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
||||
'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
||||
'link' =>$expensereport->getNomUrl(1)
|
||||
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
||||
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
||||
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
||||
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
||||
'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id],
|
||||
'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
||||
'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
||||
'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
||||
'link' =>$expensereport->getNomUrl(1)
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -315,22 +292,26 @@ else
|
||||
$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
|
||||
$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
|
||||
$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
|
||||
$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]);
|
||||
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
||||
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
||||
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
||||
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
||||
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
||||
'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id],
|
||||
'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
||||
'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
||||
'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_supplier->getNomUrl(1,'',12)
|
||||
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
||||
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
||||
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
||||
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
||||
'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id],
|
||||
'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
||||
'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
||||
'datef' =>$x_paye[$my_paye_rate]['datef'][$id],
|
||||
'datep' =>$x_paye[$my_paye_rate]['datep'][$id],
|
||||
'company_link'=>$company_static->getNomUrl(1,'',20),
|
||||
'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_supplier->getNomUrl(1,'',12)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -345,16 +326,20 @@ else
|
||||
$x_paye_sum = 0;
|
||||
$x_paye_ht = 0;
|
||||
|
||||
$span=3;
|
||||
if ($modetax == 0) $span+=2;
|
||||
$span=$columns;
|
||||
if ($modetax != 1) $span+=2;
|
||||
|
||||
//print '<tr><td colspan="'.($span+1).'">'..')</td></tr>';
|
||||
|
||||
// Customers invoices
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$elementcust.'</td>';
|
||||
print '<td align="left">'.$langs->trans("DateInvoice").'</td>';
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '<td align="left">'.$langs->trans("DatePayment").'</td>';
|
||||
else print '<td></td>';
|
||||
print '<td align="left">'.$namecust.'</td>';
|
||||
print '<td align="left">'.$productcust.'</td>';
|
||||
if ($modetax == 0)
|
||||
if ($modetax != 1)
|
||||
{
|
||||
print '<td align="right">'.$amountcust.'</td>';
|
||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
||||
@ -374,8 +359,7 @@ else
|
||||
$hookmanager->initHooks(array('externalbalance'));
|
||||
$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
foreach(array_keys($x_coll) as $rate)
|
||||
{
|
||||
foreach (array_keys($x_coll) as $rate) {
|
||||
$subtot_coll_total_ht = 0;
|
||||
$subtot_coll_vat = 0;
|
||||
|
||||
@ -384,17 +368,20 @@ else
|
||||
// VAT Rate
|
||||
$var=true;
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.($span+1).'"></td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
foreach($x_both[$rate]['coll']['detail'] as $index => $fields)
|
||||
{
|
||||
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
|
||||
// Define type
|
||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($fields['ddate_start'])) $type=1;
|
||||
if (! empty($fields['ddate_end'])) $type=1;
|
||||
if (!empty($fields['ddate_start'])) {
|
||||
$type=1;
|
||||
}
|
||||
if (!empty($fields['ddate_end'])) {
|
||||
$type=1;
|
||||
}
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
@ -402,6 +389,16 @@ else
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||
|
||||
// Invoice date
|
||||
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
|
||||
|
||||
// Payment date
|
||||
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
|
||||
else print '<td></td>';
|
||||
|
||||
// Company name
|
||||
print '<td align="left">' . $fields['company_link'] . '</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid'])
|
||||
@ -410,17 +407,25 @@ else
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['ptype'];
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
if (dol_string_nohtmltag($fields['descr'])) {
|
||||
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg))
|
||||
{
|
||||
if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
||||
elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
||||
else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
||||
if ($type) {
|
||||
$text = img_object($langs->trans('Service'),'service');
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'),'product');
|
||||
}
|
||||
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
|
||||
if ($reg[1]=='DEPOSIT') {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
||||
} elseif ($reg[1]=='CREDIT_NOTE') {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
||||
} else {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
||||
}
|
||||
}
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
|
||||
@ -430,7 +435,7 @@ else
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax == 0)
|
||||
if ($modetax != 1)
|
||||
{
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
@ -445,9 +450,8 @@ else
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax == 0)
|
||||
if ($modetax != 1)
|
||||
{
|
||||
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
print '<td class="nowrap" align="right">';
|
||||
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||
@ -455,28 +459,31 @@ else
|
||||
$payment_static->id=$fields['payment_id'];
|
||||
print $payment_static->getNomUrl(2);
|
||||
}
|
||||
if ($type == 0)
|
||||
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|
||||
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
|
||||
{
|
||||
print $langs->trans("NotUsedForGoods");
|
||||
}
|
||||
else {
|
||||
print price($fields['payment_amount']);
|
||||
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
print $langs->trans("NA");
|
||||
} else {
|
||||
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
|
||||
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
}
|
||||
print price(price2num($fields['payment_amount'],'MT'));
|
||||
if (isset($fields['payment_amount'])) {
|
||||
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Total collected
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_ht=$fields['totalht'];
|
||||
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht,'MT'),1);
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat=$fields['vat'];
|
||||
if ($type == 1) $temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_vat,'MT'),1);
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
@ -487,45 +494,45 @@ else
|
||||
$x_coll_sum += $temp_vat;
|
||||
}
|
||||
}
|
||||
// Total customers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_coll_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_coll_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
// Total customers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="4"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_coll_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_coll_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (count($x_coll) == 0) // Show a total ine if nothing shown
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
if (count($x_coll) == 0) // Show a total ine if nothing shown
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="4"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Blank line
|
||||
// Blank line
|
||||
print '<tr><td colspan="'.($span+1).'"> </td></tr>';
|
||||
|
||||
//print table headers for this quadri - expenses now
|
||||
//imprime les en-tete de tables pour ce quadri - maintenant les d<>penses
|
||||
// Print table headers for this quadri - expenses now
|
||||
print '<tr class="liste_titre liste_titre_topborder">';
|
||||
print '<td align="left">'.$elementsup.'</td>';
|
||||
print '<td align="left">'.$langs->trans("Date").'</td>';
|
||||
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '<td align="left">'.$langs->trans("DatePayment").'</td>';
|
||||
else print '<td></td>';
|
||||
print '<td align="left">'.$namesup.'</td>';
|
||||
print '<td align="left">'.$productsup.'</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
if ($modetax != 1) {
|
||||
print '<td align="right">'.$amountsup.'</td>';
|
||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
||||
}
|
||||
@ -533,25 +540,29 @@ else
|
||||
print '<td align="right">'.$vatsup.'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
foreach(array_keys($x_paye) as $rate)
|
||||
foreach (array_keys($x_paye) as $rate)
|
||||
{
|
||||
$subtot_paye_total_ht = 0;
|
||||
$subtot_paye_vat = 0;
|
||||
|
||||
if(is_array($x_both[$rate]['paye']['detail']))
|
||||
if (is_array($x_both[$rate]['paye']['detail']))
|
||||
{
|
||||
$var=true;
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.($span+1).'"></td>';
|
||||
print '</tr>'."\n";
|
||||
foreach($x_both[$rate]['paye']['detail'] as $index=>$fields)
|
||||
{
|
||||
|
||||
foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) {
|
||||
// Define type
|
||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($fields['ddate_start'])) $type=1;
|
||||
if (! empty($fields['ddate_end'])) $type=1;
|
||||
if (!empty($fields['ddate_start'])) {
|
||||
$type=1;
|
||||
}
|
||||
if (!empty($fields['ddate_end'])) {
|
||||
$type=1;
|
||||
}
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
@ -559,6 +570,16 @@ else
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||
|
||||
// Invoice date
|
||||
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
|
||||
|
||||
// Payment date
|
||||
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
|
||||
else print '<td></td>';
|
||||
|
||||
// Company name
|
||||
print '<td align="left">' . $fields['company_link'] . '</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid'])
|
||||
@ -567,12 +588,17 @@ else
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['ptype'];
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
if (dol_string_nohtmltag($fields['descr'])) {
|
||||
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
if ($type) {
|
||||
$text = img_object($langs->trans('Service'),'service');
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'),'product');
|
||||
}
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
|
||||
// Show range
|
||||
@ -581,7 +607,7 @@ else
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax == 0)
|
||||
if ($modetax != 1)
|
||||
{
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
@ -596,83 +622,84 @@ else
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax == 0)
|
||||
if ($modetax != 1)
|
||||
{
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
print '<td class="nowrap" align="right">';
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||
{
|
||||
$paymentfourn_static->id=$fields['payment_id'];
|
||||
print $paymentfourn_static->getNomUrl(2);
|
||||
}
|
||||
if ($type == 0)
|
||||
|
||||
if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')
|
||||
|| ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice'))
|
||||
{
|
||||
print $langs->trans("NotUsedForGoods");
|
||||
print $langs->trans("NA");
|
||||
}
|
||||
else
|
||||
{
|
||||
print price($fields['payment_amount']);
|
||||
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
|
||||
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
}
|
||||
print price(price2num($fields['payment_amount'],'MT'));
|
||||
if (isset($fields['payment_amount'])) {
|
||||
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// VAT paid
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_ht=$fields['totalht'];
|
||||
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht,'MT'),1);
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat=$fields['vat'];
|
||||
if ($type == 1) $temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_vat,'MT'),1);
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_paye_total_ht += $temp_ht;
|
||||
$subtot_paye_vat += $temp_vat;
|
||||
$x_paye_sum += $temp_vat;
|
||||
$subtot_paye_vat += $temp_vat;
|
||||
$x_paye_sum += $temp_vat;
|
||||
}
|
||||
}
|
||||
// Total suppliers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_paye_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_paye_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
// Total suppliers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="4"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_paye_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_paye_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (count($x_paye) == 0) // Show a total line if nothing shown
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
if (count($x_paye) == 0) { // Show a total line if nothing shown
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="4"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax != 1) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
|
||||
// Total to pay
|
||||
print '<br><br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
$diff = $x_coll_sum - $x_paye_sum;
|
||||
print '<br><br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
$diff = $x_coll_sum - $x_paye_sum;
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
|
||||
print '<td class="liste_total nowrap" align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
|
||||
@ -680,7 +707,7 @@ else
|
||||
|
||||
$i++;
|
||||
}
|
||||
echo '</table>';
|
||||
print '</table>';
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -1,713 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007, 2015 Yannick Warnier <ywarnier@beeznest.org>
|
||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@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/compta/tva/quadri_detail.php
|
||||
* \ingroup tax
|
||||
* \brief Trimestrial page - detailed version
|
||||
* TODO Deal with recurrent invoices as well
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.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.'/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("bills");
|
||||
$langs->load("compta");
|
||||
$langs->load("companies");
|
||||
$langs->load("products");
|
||||
$langs->load("other");
|
||||
|
||||
// Date range
|
||||
$year=GETPOST('year', 'int');
|
||||
if (empty($year)) {
|
||||
$year_current = strftime("%Y",dol_now());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
|
||||
$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
|
||||
// Quarter
|
||||
if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
|
||||
$q=GETPOST('q', 'int');
|
||||
if (empty($q)) {
|
||||
if (isset($_REQUEST["month"])) {
|
||||
$date_start=dol_get_first_day($year_start,$_REQUEST["month"],false);
|
||||
$date_end=dol_get_last_day($year_start,$_REQUEST["month"],false);
|
||||
} else {
|
||||
$month_current = strftime("%m",dol_now());
|
||||
if ($month_current >= 10) $q=4;
|
||||
elseif ($month_current >= 7) $q=3;
|
||||
elseif ($month_current >= 4) $q=2;
|
||||
else $q=1;
|
||||
}
|
||||
}
|
||||
if ($q==1) {
|
||||
$date_start=dol_get_first_day($year_start,1,false);
|
||||
$date_end=dol_get_last_day($year_start,3,false);
|
||||
}
|
||||
if ($q==2) {
|
||||
$date_start=dol_get_first_day($year_start,4,false);
|
||||
$date_end=dol_get_last_day($year_start,6,false);
|
||||
}
|
||||
if ($q==3) {
|
||||
$date_start=dol_get_first_day($year_start,7,false);
|
||||
$date_end=dol_get_last_day($year_start,9,false);
|
||||
}
|
||||
if ($q==4) {
|
||||
$date_start=dol_get_first_day($year_start,10,false);
|
||||
$date_end=dol_get_last_day($year_start,12,false);
|
||||
}
|
||||
}
|
||||
|
||||
$min = GETPOST("min");
|
||||
if (empty($min)) {
|
||||
$min = 0;
|
||||
}
|
||||
|
||||
// Define modetax (0 or 1)
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$modetax = $conf->global->TAX_MODE;
|
||||
if (isset($_REQUEST["modetax"])) {
|
||||
$modetax=$_REQUEST["modetax"];
|
||||
}
|
||||
if (empty($modetax)) {
|
||||
$modetax=0;
|
||||
}
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST('socid','int');
|
||||
if ($user->societe_id) {
|
||||
$socid=$user->societe_id;
|
||||
}
|
||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$morequerystring='';
|
||||
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
|
||||
foreach ($listofparams as $param) {
|
||||
if (GETPOST($param)!='') {
|
||||
$morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
|
||||
}
|
||||
}
|
||||
|
||||
llxHeader('','','','',0,0,'','',$morequerystring);
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
$company_static=new Societe($db);
|
||||
$invoice_customer=new Facture($db);
|
||||
$invoice_supplier=new FactureFournisseur($db);
|
||||
$product_static=new Product($db);
|
||||
$payment_static=new Paiement($db);
|
||||
$paymentfourn_static=new PaiementFourn($db);
|
||||
|
||||
//print load_fiche_titre($langs->trans("VAT"),"");
|
||||
|
||||
//$fsearch.='<br>';
|
||||
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">';
|
||||
$fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
|
||||
//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
|
||||
//$fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
||||
|
||||
|
||||
// Affiche en-tete du rapport
|
||||
if ($modetax==1) { // Calculate on invoice for goods and services
|
||||
$name=$langs->trans("VATReportByQuartersInDueDebtMode");
|
||||
$calcmode=$langs->trans("CalcModeVATDebt");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
if ($prevquarter > 1) {
|
||||
$prevquarter--;
|
||||
} else {
|
||||
$prevquarter=4; $prevyear--;
|
||||
}
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) {
|
||||
$nextquarter++;
|
||||
} else {
|
||||
$nextquarter=1; $nextyear++;
|
||||
}
|
||||
//$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATDueServices");
|
||||
$description.='<br>';
|
||||
$description.=$langs->trans("RulesVATDueProducts");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||
} else {
|
||||
$description.='<br>'.$langs->trans("DepositsAreIncluded");
|
||||
}
|
||||
$description.=$fsearch;
|
||||
$builddate=dol_now();
|
||||
//$exportlink=$langs->trans("NotYetAvailable");
|
||||
|
||||
$elementcust=$langs->trans("CustomersInvoices");
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
$namecust=$langs->trans("Name");
|
||||
if ($mysoc->tva_assuj) {
|
||||
$vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
}
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$langs->trans("ProductOrService");
|
||||
$amountsup=$langs->trans("AmountHT");
|
||||
$vatsup=$langs->trans("VATPaid");
|
||||
$namesup=$namecust;
|
||||
if ($mysoc->tva_assuj) {
|
||||
$vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
}
|
||||
if ($modetax==0) { // Invoice for goods, payment for services
|
||||
$name=$langs->trans("VATReportByQuartersInInputOutputMode");
|
||||
$calcmode=$langs->trans("CalcModeVATEngagement");
|
||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
if ($prevquarter > 1) {
|
||||
$prevquarter--;
|
||||
} else {
|
||||
$prevquarter=4; $prevyear--;
|
||||
}
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) {
|
||||
$nextquarter++;
|
||||
} else {
|
||||
$nextquarter=1; $nextyear++;
|
||||
}
|
||||
//$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATInServices");
|
||||
$description.=' '.$langs->trans("DepositsAreIncluded");
|
||||
$description.='<br>';
|
||||
$description.=$langs->trans("RulesVATInProducts");
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$description.=' '.$langs->trans("DepositsAreNotIncluded");
|
||||
} else {
|
||||
$description.=' '.$langs->trans("DepositsAreIncluded");
|
||||
}
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||
$description.=$fsearch;
|
||||
$builddate=dol_now();
|
||||
//$exportlink=$langs->trans("NotYetAvailable");
|
||||
|
||||
$elementcust=$langs->trans("CustomersInvoices");
|
||||
$productcust=$langs->trans("ProductOrService");
|
||||
$amountcust=$langs->trans("AmountHT");
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
$namecust=$langs->trans("Name");
|
||||
if ($mysoc->tva_assuj) {
|
||||
$vatcust.=' ('.$langs->trans("ToPay").')';
|
||||
}
|
||||
$elementsup=$langs->trans("SuppliersInvoices");
|
||||
$productsup=$productcust;
|
||||
$amountsup=$amountcust;
|
||||
$vatsup=$langs->trans("VATPaid");
|
||||
$namesup=$namecust;
|
||||
if ($mysoc->tva_assuj) {
|
||||
$vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||
}
|
||||
}
|
||||
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
|
||||
|
||||
$vatcust=$langs->trans("VATReceived");
|
||||
$vatsup=$langs->trans("VATPaid");
|
||||
|
||||
|
||||
// VAT Received and paid
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
$y = $year_current;
|
||||
$total = 0;
|
||||
$i=0;
|
||||
$columns = 6;
|
||||
|
||||
// Load arrays of datas
|
||||
$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
|
||||
$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
|
||||
|
||||
if (!is_array($x_coll) || !is_array($x_paye)) {
|
||||
$langs->load("errors");
|
||||
if ($x_coll == -1) {
|
||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '</td></tr>';
|
||||
} else if ($x_coll == -2) {
|
||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("FeatureNotYetAvailable") . '</td></tr>';
|
||||
} else {
|
||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("Error") . '</td></tr>';
|
||||
}
|
||||
} else {
|
||||
$x_both = array();
|
||||
//now, from these two arrays, get another array with one rate per line
|
||||
foreach(array_keys($x_coll) as $my_coll_rate) {
|
||||
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
|
||||
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
|
||||
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
|
||||
$x_both[$my_coll_rate]['paye']['vat'] = 0;
|
||||
$x_both[$my_coll_rate]['coll']['links'] = '';
|
||||
$x_both[$my_coll_rate]['coll']['detail'] = array();
|
||||
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
|
||||
$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
|
||||
$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
|
||||
$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
|
||||
$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
|
||||
$x_both[$my_coll_rate]['coll']['detail'][] = array(
|
||||
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
|
||||
'descr' =>$x_coll[$my_coll_rate]['descr'][$id],
|
||||
'pid' =>$x_coll[$my_coll_rate]['pid'][$id],
|
||||
'pref' =>$x_coll[$my_coll_rate]['pref'][$id],
|
||||
'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id],
|
||||
'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id],
|
||||
'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id],
|
||||
'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id],
|
||||
'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id],
|
||||
'datef' =>$x_coll[$my_coll_rate]['datef'][$id],
|
||||
'company_link'=>$company_static->getNomUrl(1,'',20),
|
||||
'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id],
|
||||
'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
||||
'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_customer->getNomUrl(1,'',12)
|
||||
);
|
||||
}
|
||||
}
|
||||
// tva paid
|
||||
foreach (array_keys($x_paye) as $my_paye_rate) {
|
||||
$x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
|
||||
$x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
|
||||
if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
|
||||
$x_both[$my_paye_rate]['coll']['totalht'] = 0;
|
||||
$x_both[$my_paye_rate]['coll']['vat'] = 0;
|
||||
}
|
||||
$x_both[$my_paye_rate]['paye']['links'] = '';
|
||||
$x_both[$my_paye_rate]['paye']['detail'] = array();
|
||||
|
||||
foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) {
|
||||
$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
|
||||
$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
|
||||
$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
|
||||
$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]);
|
||||
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
||||
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
||||
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
||||
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
||||
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
||||
'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id],
|
||||
'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
||||
'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
||||
'datef' =>$x_paye[$my_paye_rate]['datef'][$id],
|
||||
'company_link'=>$company_static->getNomUrl(1,'',20),
|
||||
'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_supplier->getNomUrl(1,'',12)
|
||||
);
|
||||
}
|
||||
}
|
||||
//now we have an array (x_both) indexed by rates for coll and paye
|
||||
|
||||
|
||||
//print table headers for this quadri - incomes first
|
||||
|
||||
$x_coll_sum = 0;
|
||||
$x_coll_ht = 0;
|
||||
$x_paye_sum = 0;
|
||||
$x_paye_ht = 0;
|
||||
|
||||
$span=$columns-3;
|
||||
if ($modetax == 0) $span+=2;
|
||||
|
||||
//print '<tr><td colspan="'.($span+1).'">'..')</td></tr>';
|
||||
|
||||
// Customers invoices
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$elementcust.'</td>';
|
||||
print '<td align="left">'.$langs->trans("Date").'</td>';
|
||||
print '<td align="left">'.$namecust.'</td>';
|
||||
print '<td align="left">'.$productcust.'</td>';
|
||||
if ($modetax == 0) {
|
||||
print '<td align="right">'.$amountcust.'</td>';
|
||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
||||
}
|
||||
print '<td align="right">'.$langs->trans("AmountHTVATRealReceived").'</td>';
|
||||
print '<td align="right">'.$vatcust.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$action = "tvadetail";
|
||||
$parameters["mode"] = $modetax;
|
||||
$parameters["start"] = $date_start;
|
||||
$parameters["end"] = $date_end;
|
||||
$parameters["type"] = 'vat';
|
||||
|
||||
$object = array(&$x_coll, &$x_paye, &$x_both);
|
||||
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('externalbalance'));
|
||||
$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
foreach (array_keys($x_coll) as $rate) {
|
||||
$subtot_coll_total_ht = 0;
|
||||
$subtot_coll_vat = 0;
|
||||
|
||||
if (is_array($x_both[$rate]['coll']['detail'])) {
|
||||
// VAT Rate
|
||||
$var=true;
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
|
||||
// Define type
|
||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (!empty($fields['ddate_start'])) {
|
||||
$type=1;
|
||||
}
|
||||
if (!empty($fields['ddate_end'])) {
|
||||
$type=1;
|
||||
}
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||
|
||||
// Invoice date
|
||||
print '<td align="left">' . $fields['datef'] . '</td>';
|
||||
// Company name
|
||||
print '<td align="left">' . $fields['company_link'] . '</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid']) {
|
||||
$product_static->id=$fields['pid'];
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['ptype'];
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) {
|
||||
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
}
|
||||
} else {
|
||||
if ($type) {
|
||||
$text = img_object($langs->trans('Service'),'service');
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'),'product');
|
||||
}
|
||||
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
|
||||
if ($reg[1]=='DEPOSIT') {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
||||
} elseif ($reg[1]=='CREDIT_NOTE') {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
||||
} else {
|
||||
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
||||
}
|
||||
}
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax == 0) {
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
if (price2num($fields['ftotal_ttc'])) {
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax == 0) {
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
|
||||
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
}
|
||||
print '<td class="nowrap" align="right">';
|
||||
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
|
||||
$payment_static->id=$fields['payment_id'];
|
||||
print $payment_static->getNomUrl(2);
|
||||
}
|
||||
if ($type == 0) {
|
||||
print $langs->trans("NotUsedForGoods");
|
||||
} else {
|
||||
print $fields['payment_amount'];
|
||||
if (isset($fields['payment_amount'])) {
|
||||
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Total collected
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_ht=$fields['totalht'];
|
||||
if ($type == 1) {
|
||||
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
}
|
||||
print price(price2num($temp_ht,'MT'),1);
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat=$fields['vat'];
|
||||
if ($type == 1) {
|
||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
}
|
||||
print price(price2num($temp_vat,'MT'),1);
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_coll_total_ht += $temp_ht;
|
||||
$subtot_coll_vat += $temp_vat;
|
||||
$x_coll_sum += $temp_vat;
|
||||
}
|
||||
}
|
||||
// Total customers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="'.$span.'"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_coll_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_coll_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (count($x_coll) == 0) { // Show a total ine if nothing shown
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="'.$span.'"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Blank line
|
||||
print '<tr><td colspan="'.($span+1).'"> </td></tr>';
|
||||
|
||||
// Print table headers for this quadri - expenses now
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$elementsup.'</td>';
|
||||
print '<td align="left">'.$langs->trans("Date").'</td>';
|
||||
print '<td align="left">'.$namesup.'</td>';
|
||||
print '<td align="left">'.$productsup.'</td>';
|
||||
if ($modetax == 0) {
|
||||
print '<td align="right">'.$amountsup.'</td>';
|
||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
||||
}
|
||||
print '<td align="right">'.$langs->trans("AmountHTVATRealPaid").'</td>';
|
||||
print '<td align="right">'.$vatsup.'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
foreach (array_keys($x_paye) as $rate) {
|
||||
$subtot_paye_total_ht = 0;
|
||||
$subtot_paye_vat = 0;
|
||||
|
||||
if (is_array($x_both[$rate]['paye']['detail'])) {
|
||||
$var=true;
|
||||
print "<tr>";
|
||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) {
|
||||
// Define type
|
||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (!empty($fields['ddate_start'])) {
|
||||
$type=1;
|
||||
}
|
||||
if (!empty($fields['ddate_end'])) {
|
||||
$type=1;
|
||||
}
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||
// Invoice date
|
||||
print '<td align="left">' . $fields['datef'] . '</td>';
|
||||
// Company name
|
||||
print '<td align="left">' . $fields['company_link'] . '</td>';
|
||||
|
||||
// Description
|
||||
print '<td align="left">';
|
||||
if ($fields['pid']) {
|
||||
$product_static->id=$fields['pid'];
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['ptype'];
|
||||
print $product_static->getNomUrl(1);
|
||||
if (dol_string_nohtmltag($fields['descr'])) {
|
||||
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
}
|
||||
} else {
|
||||
if ($type) {
|
||||
$text = img_object($langs->trans('Service'),'service');
|
||||
} else {
|
||||
$text = img_object($langs->trans('Product'),'product');
|
||||
}
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax == 0) {
|
||||
print '<td class="nowrap" align="right">';
|
||||
print price($fields['totalht']);
|
||||
if (price2num($fields['ftotal_ttc'])) {
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Payment
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax == 0) {
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
|
||||
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
}
|
||||
print '<td class="nowrap" align="right">';
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
|
||||
$paymentfourn_static->id=$fields['payment_id'];
|
||||
print $paymentfourn_static->getNomUrl(2);
|
||||
}
|
||||
if ($type == 0) {
|
||||
print $langs->trans("NotUsedForGoods");
|
||||
} else {
|
||||
print $fields['payment_amount'];
|
||||
if (isset($fields['payment_amount'])) {
|
||||
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// VAT paid
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_ht=$fields['totalht'];
|
||||
if ($type == 1) {
|
||||
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
}
|
||||
print price(price2num($temp_ht,'MT'),1);
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td class="nowrap" align="right">';
|
||||
$temp_vat=$fields['vat'];
|
||||
if ($type == 1) {
|
||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
}
|
||||
print price(price2num($temp_vat,'MT'),1);
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$subtot_paye_total_ht += $temp_ht;
|
||||
$subtot_paye_vat += $temp_vat;
|
||||
$x_paye_sum += $temp_vat;
|
||||
}
|
||||
}
|
||||
// Total suppliers for this vat rate
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="'.$span.'"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num($subtot_paye_total_ht,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_paye_vat,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (count($x_paye) == 0) { // Show a total line if nothing shown
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="'.$span.'"></td>';
|
||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||
if ($modetax == 0) {
|
||||
print '<td class="nowrap" align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
}
|
||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
// Total to pay
|
||||
print '<br><br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
$diff = $x_coll_sum - $x_paye_sum;
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
|
||||
print '<td class="liste_total nowrap" align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -955,19 +955,35 @@ if (empty($reshook))
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
$result = $object->setValueFrom('ref', GETPOST('ref','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY');
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = 'editref';
|
||||
} else {
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
|
||||
exit;
|
||||
}
|
||||
$old_ref = $object->ref;
|
||||
|
||||
$result = $object->setValueFrom('ref', GETPOST('ref','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY');
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = 'editref';
|
||||
} else {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$old_filedir = $conf->contrat->dir_output . '/' . dol_sanitizeFileName($old_ref);
|
||||
$new_filedir = $conf->contrat->dir_output . '/' . dol_sanitizeFileName($object->ref);
|
||||
|
||||
$files = dol_dir_list($old_filedir);
|
||||
if (!empty($files))
|
||||
{
|
||||
if (!is_dir($new_filedir)) dol_mkdir($new_filedir);
|
||||
foreach ($files as $file)
|
||||
{
|
||||
dol_move($file['fullname'], $new_filedir.'/'.$file['name']);
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
elseif ($action=='setdate_contrat')
|
||||
{
|
||||
@ -1705,14 +1721,11 @@ else
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
// Display lines extrafields
|
||||
if (is_array($extralabelslines) && count($extralabelslines)>0) {
|
||||
print '<tr '.$bcnd[$var].'>';
|
||||
$line = new ContratLigne($db);
|
||||
$line->fetch_optionals($objp->rowid);
|
||||
print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan));
|
||||
print '</tr>';
|
||||
print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
|
||||
}
|
||||
}
|
||||
// Ligne en mode update
|
||||
@ -1767,7 +1780,8 @@ else
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Modify").'">';
|
||||
print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
$colspan=6;
|
||||
if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) $colspan++;
|
||||
if($conf->global->PRODUCT_USE_UNITS) $colspan++;
|
||||
@ -1780,16 +1794,13 @@ else
|
||||
print ' '.$langs->trans("DateEndPlanned").' ';
|
||||
$form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update");
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
if (is_array($extralabelslines) && count($extralabelslines)>0) {
|
||||
print '<tr '.$bcnd[$var].'>';
|
||||
$line = new ContratLigne($db);
|
||||
$line->fetch_optionals($objp->rowid);
|
||||
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan));
|
||||
print '</tr>';
|
||||
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$db->free($result);
|
||||
|
||||
@ -205,8 +205,6 @@ $formother = new FormOther($db);
|
||||
$socstatic = new Societe($db);
|
||||
$contracttmp = new Contrat($db);
|
||||
|
||||
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.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
|
||||
@ -309,489 +307,504 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
if (! $resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
if ($socid > 0)
|
||||
// Direct jump if only one record found
|
||||
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$id = $obj->rowid;
|
||||
header("Location: ".DOL_URL_ROOT.'/contrat/card.php?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// Output page
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
llxHeader('', $langs->trans("Contracts"));
|
||||
|
||||
$i = 0;
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
|
||||
if ($socid > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
if (empty($search_name)) $search_name = $soc->name;
|
||||
}
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall != '') $param.='&sall='.urlencode($sall);
|
||||
if ($search_contract != '') $param.='&search_contract='.urlencode($search_contract);
|
||||
if ($search_name != '') $param.='&search_name='.urlencode($search_name);
|
||||
if ($search_email != '') $param.='&search_email='.urlencode($search_email);
|
||||
if ($search_ref_customer != '') $param.='&search_ref_customer='.urlencode($search_ref_customer);
|
||||
if ($search_ref_supplier != '') $param.='&search_ref_supplier='.urlencode($search_ref_supplier);
|
||||
if ($search_op2df != '') $param.='&search_op2df='.urlencode($search_op2df);
|
||||
if ($search_dfyear != '') $param.='&search_dfyear='.urlencode($search_dfyear);
|
||||
if ($search_dfmonth != '') $param.='&search_dfmonth='.urlencode($search_dfmonth);
|
||||
if ($search_sale != '') $param.='&search_sale=' .urlencode($search_sale);
|
||||
if ($search_user != '') $param.='&search_user=' .urlencode($search_user);
|
||||
if ($search_product_category != '') $param.='&search_product_category=' .urlencode($search_product_category);
|
||||
if ($show_files) $param.='&show_files=' .urlencode($show_files);
|
||||
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
'presend'=>$langs->trans("SendByMail"),
|
||||
'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
|
||||
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
print '<form method="POST" 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_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit);
|
||||
|
||||
$topicmail="SendContractRef";
|
||||
$modelmail="contract";
|
||||
$objecttmp=new Contrat($db);
|
||||
$trackid='con'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
||||
}
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
// If the user can view prospects other than his'
|
||||
if ($user->rights->societe->client->voir || $socid)
|
||||
{
|
||||
$langs->load("commercial");
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
|
||||
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user,0,1,'maxwidth200');
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
// If the user can view other users
|
||||
if ($user->rights->user->user->lire)
|
||||
{
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
|
||||
$moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
// If the user can view categories of products
|
||||
if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
|
||||
$moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
if (! empty($moreforfilter))
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
print '<tr class="liste_titre_filter">';
|
||||
if (! empty($arrayfields['c.ref']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">';
|
||||
print '</td>';
|
||||
}
|
||||
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 '</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 '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['s.nom']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
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
|
||||
if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
|
||||
// State
|
||||
if (! empty($arrayfields['state.nom']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Country
|
||||
if (! empty($arrayfields['country.code_iso']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print $form->select_country($search_country,'search_country','',0,'maxwidth100');
|
||||
print '</td>';
|
||||
}
|
||||
// Company type
|
||||
if (! empty($arrayfields['typent.code']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
|
||||
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['sale_representative']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
if (! empty($arrayfields['c.date_contrat']['checked']))
|
||||
{
|
||||
// Date contract
|
||||
print '<td class="liste_titre center nowraponall">';
|
||||
//print $langs->trans('Month').': ';
|
||||
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.'">';
|
||||
//print ' '.$langs->trans('Year').': ';
|
||||
$syear = $year;
|
||||
print $formother->selectyear($syear,'year',1, 20, 5, 0, 0, '', 'widthauto');
|
||||
print '</td>';
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
// 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['c.datec']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Date modification
|
||||
if (! empty($arrayfields['c.tms']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// First end date
|
||||
if (! empty($arrayfields['lower_planned_end_date']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" align="center">';
|
||||
$arrayofoperators=array('0'=>'','='=>'=','<='=>'<=','>='=>'>=');
|
||||
print $form->selectarray('search_op2df',$arrayofoperators,$search_op2df,0);
|
||||
print '</br>';
|
||||
print $formother->select_month($search_dfmonth, 'search_dfmonth', 1);
|
||||
print ' ';
|
||||
$formother->select_year($search_dfyear, 'search_dfyear', 1, 20, 5);
|
||||
print '</td>';
|
||||
}
|
||||
// Status
|
||||
if (! empty($arrayfields['status']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" colspan="4" align="right"></td>';
|
||||
}
|
||||
print '<td class="liste_titre" align="middle">';
|
||||
$searchpicto=$form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
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_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.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);
|
||||
if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "","","$param",'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['c.date_contrat']['checked'])) print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat","","$param",'align="center"',$sortfield,$sortorder);
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['lower_planned_end_date']['checked'])) print_liste_field_titre($arrayfields['lower_planned_end_date']['label'],$_SERVER["PHP_SELF"],"lower_planned_end_date","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['status']['checked']))
|
||||
{
|
||||
print_liste_field_titre($staticcontratligne->LibStatut(0,3), '', '', '', '', 'width="16"');
|
||||
print_liste_field_titre($staticcontratligne->LibStatut(4,3,0), '', '', '', '', 'width="16"');
|
||||
print_liste_field_titre($staticcontratligne->LibStatut(4,3,1), '', '', '', '', 'width="16"');
|
||||
print_liste_field_titre($staticcontratligne->LibStatut(5,3), '', '', '', '', 'width="16"');
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$contracttmp->ref=$obj->ref;
|
||||
$contracttmp->id=$obj->rowid;
|
||||
$contracttmp->ref_customer=$obj->ref_customer;
|
||||
$contracttmp->ref_supplier=$obj->ref_supplier;
|
||||
|
||||
if ($obj->socid > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
if (empty($search_name)) $search_name = $soc->name;
|
||||
$result=$socstatic->fetch($obj->socid);
|
||||
}
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall != '') $param.='&sall='.urlencode($sall);
|
||||
if ($search_contract != '') $param.='&search_contract='.urlencode($search_contract);
|
||||
if ($search_name != '') $param.='&search_name='.urlencode($search_name);
|
||||
if ($search_email != '') $param.='&search_email='.urlencode($search_email);
|
||||
if ($search_ref_customer != '') $param.='&search_ref_customer='.urlencode($search_ref_customer);
|
||||
if ($search_ref_supplier != '') $param.='&search_ref_supplier='.urlencode($search_ref_supplier);
|
||||
if ($search_op2df != '') $param.='&search_op2df='.urlencode($search_op2df);
|
||||
if ($search_dfyear != '') $param.='&search_dfyear='.urlencode($search_dfyear);
|
||||
if ($search_dfmonth != '') $param.='&search_dfmonth='.urlencode($search_dfmonth);
|
||||
if ($search_sale != '') $param.='&search_sale=' .urlencode($search_sale);
|
||||
if ($search_user != '') $param.='&search_user=' .urlencode($search_user);
|
||||
if ($search_product_category != '') $param.='&search_product_category=' .urlencode($search_product_category);
|
||||
if ($show_files) $param.='&show_files=' .urlencode($show_files);
|
||||
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
'presend'=>$langs->trans("SendByMail"),
|
||||
'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
|
||||
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
print '<form method="POST" 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_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit);
|
||||
|
||||
$topicmail="SendContractRef";
|
||||
$modelmail="contract";
|
||||
$objecttmp=new Contrat($db);
|
||||
$trackid='con'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
||||
}
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
// If the user can view prospects other than his'
|
||||
if ($user->rights->societe->client->voir || $socid)
|
||||
{
|
||||
$langs->load("commercial");
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
|
||||
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user,0,1,'maxwidth200');
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
// If the user can view other users
|
||||
if ($user->rights->user->user->lire)
|
||||
{
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
|
||||
$moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
// If the user can view categories of products
|
||||
if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
|
||||
$moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
if (! empty($moreforfilter))
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
print '<tr class="liste_titre_filter">';
|
||||
print '<tr class="oddeven">';
|
||||
if (! empty($arrayfields['c.ref']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">';
|
||||
print '<td class="nowrap">';
|
||||
print $contracttmp->getNomUrl(1);
|
||||
if ($obj->nb_late) print img_warning($langs->trans("Late"));
|
||||
if (!empty($obj->note_private) || !empty($obj->note_public))
|
||||
{
|
||||
print ' <span class="note">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/contrat/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
|
||||
print '</span>';
|
||||
}
|
||||
|
||||
$filename=dol_sanitizeFileName($obj->ref);
|
||||
$filedir=$conf->contrat->dir_output . '/' . dol_sanitizeFileName($obj->ref);
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
|
||||
print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
|
||||
print '</td>';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
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 '</td>';
|
||||
print '<td>'.$obj->ref_customer.'</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 '</td>';
|
||||
print '<td>'.$obj->ref_supplier.'</td>';
|
||||
}
|
||||
if (! empty($arrayfields['s.nom']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
|
||||
print '<td>';
|
||||
//print '<a href="../comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a>';
|
||||
if ($obj->socid > 0)
|
||||
{
|
||||
print $socstatic->getNomUrl(1, '');
|
||||
}
|
||||
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>';
|
||||
print '<td>'.$obj->email.'</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>';
|
||||
if (! empty($arrayfields['s.town']['checked']))
|
||||
{
|
||||
print '<td class="nocellnopadd">';
|
||||
print $obj->town;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Zip
|
||||
if (! empty($arrayfields['s.zip']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.'"></td>';
|
||||
if (! empty($arrayfields['s.zip']['checked']))
|
||||
{
|
||||
print '<td class="nocellnopadd">';
|
||||
print $obj->zip;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// State
|
||||
if (! empty($arrayfields['state.nom']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
|
||||
print '</td>';
|
||||
print "<td>".$obj->state_name."</td>\n";
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Country
|
||||
if (! empty($arrayfields['country.code_iso']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print $form->select_country($search_country,'search_country','',0,'maxwidth100');
|
||||
print '<td align="center">';
|
||||
$tmparray=getCountry($obj->fk_pays,'all');
|
||||
print $tmparray['label'];
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Company type
|
||||
// Type ent
|
||||
if (! empty($arrayfields['typent.code']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
|
||||
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
|
||||
print '<td align="center">';
|
||||
if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
|
||||
print $typenArray[$obj->typent_code];
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
if (! empty($arrayfields['sale_representative']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
if (! empty($arrayfields['c.date_contrat']['checked']))
|
||||
{
|
||||
// Date contract
|
||||
print '<td class="liste_titre center nowraponall">';
|
||||
//print $langs->trans('Month').': ';
|
||||
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.'">';
|
||||
//print ' '.$langs->trans('Year').': ';
|
||||
$syear = $year;
|
||||
print $formother->selectyear($syear,'year',1, 20, 5, 0, 0, '', 'widthauto');
|
||||
// Sales representatives
|
||||
print '<td>';
|
||||
if ($obj->socid > 0)
|
||||
{
|
||||
$listsalesrepresentatives=$socstatic->getSalesRepresentatives($user);
|
||||
if ($listsalesrepresentatives < 0) dol_print_error($db);
|
||||
$nbofsalesrepresentative=count($listsalesrepresentatives);
|
||||
if ($nbofsalesrepresentative > 3) // We print only number
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$socstatic->id.'">';
|
||||
print $nbofsalesrepresentative;
|
||||
print '</a>';
|
||||
}
|
||||
else if ($nbofsalesrepresentative > 0)
|
||||
{
|
||||
$userstatic=new User($db);
|
||||
$j=0;
|
||||
foreach($listsalesrepresentatives as $val)
|
||||
{
|
||||
$userstatic->id=$val['id'];
|
||||
$userstatic->lastname=$val['lastname'];
|
||||
$userstatic->firstname=$val['firstname'];
|
||||
$userstatic->email=$val['email'];
|
||||
$userstatic->statut=$val['statut'];
|
||||
$userstatic->entity=$val['entity'];
|
||||
$userstatic->photo=$val['photo'];
|
||||
|
||||
//print '<div class="float">':
|
||||
print $userstatic->getNomUrl(-2);
|
||||
$j++;
|
||||
if ($j < $nbofsalesrepresentative) print ' ';
|
||||
//print '</div>';
|
||||
}
|
||||
}
|
||||
//else print $langs->trans("NoSalesRepresentativeAffected");
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
// Date
|
||||
if (! empty($arrayfields['c.date_contrat']['checked']))
|
||||
{
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzuser').'</td>';
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Date creation
|
||||
if (! empty($arrayfields['c.datec']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Date modification
|
||||
if (! empty($arrayfields['c.tms']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// First end date
|
||||
// Date lower end date
|
||||
if (! empty($arrayfields['lower_planned_end_date']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" align="center">';
|
||||
$arrayofoperators=array('0'=>'','='=>'=','<='=>'<=','>='=>'>=');
|
||||
print $form->selectarray('search_op2df',$arrayofoperators,$search_op2df,0);
|
||||
print '</br>';
|
||||
print $formother->select_month($search_dfmonth, 'search_dfmonth', 1);
|
||||
print ' ';
|
||||
$formother->select_year($search_dfyear, 'search_dfyear', 1, 20, 5);
|
||||
print '</td>';
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Status
|
||||
if (! empty($arrayfields['status']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" colspan="4" align="right"></td>';
|
||||
print '<td align="center">'.($obj->nb_initial>0?$obj->nb_initial:'').'</td>';
|
||||
print '<td align="center">'.($obj->nb_running>0?$obj->nb_running:'').'</td>';
|
||||
print '<td align="center">'.($obj->nb_expired>0?$obj->nb_expired:'').'</td>';
|
||||
print '<td align="center">'.($obj->nb_closed>0 ?$obj->nb_closed:'').'</td>';
|
||||
}
|
||||
// Action column
|
||||
print '<td class="nowrap" align="center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
$selected=0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '<td class="liste_titre" align="middle">';
|
||||
$searchpicto=$form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
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_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.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);
|
||||
if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "","","$param",'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['c.date_contrat']['checked'])) print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat","","$param",'align="center"',$sortfield,$sortorder);
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['lower_planned_end_date']['checked'])) print_liste_field_titre($arrayfields['lower_planned_end_date']['label'],$_SERVER["PHP_SELF"],"lower_planned_end_date","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['status']['checked']))
|
||||
{
|
||||
print_liste_field_titre($staticcontratligne->LibStatut(0,3), '', '', '', '', 'width="16"');
|
||||
print_liste_field_titre($staticcontratligne->LibStatut(4,3,0), '', '', '', '', 'width="16"');
|
||||
print_liste_field_titre($staticcontratligne->LibStatut(4,3,1), '', '', '', '', 'width="16"');
|
||||
print_liste_field_titre($staticcontratligne->LibStatut(5,3), '', '', '', '', 'width="16"');
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$contracttmp->ref=$obj->ref;
|
||||
$contracttmp->id=$obj->rowid;
|
||||
$contracttmp->ref_customer=$obj->ref_customer;
|
||||
$contracttmp->ref_supplier=$obj->ref_supplier;
|
||||
|
||||
if ($obj->socid > 0)
|
||||
{
|
||||
$result=$socstatic->fetch($obj->socid);
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
if (! empty($arrayfields['c.ref']['checked']))
|
||||
{
|
||||
print '<td class="nowrap">';
|
||||
print $contracttmp->getNomUrl(1);
|
||||
if ($obj->nb_late) print img_warning($langs->trans("Late"));
|
||||
if (!empty($obj->note_private) || !empty($obj->note_public))
|
||||
{
|
||||
print ' <span class="note">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/contrat/note.php?id='.$obj->rowid.'">'.img_picto($langs->trans("ViewPrivateNote"),'object_generic').'</a>';
|
||||
print '</span>';
|
||||
}
|
||||
|
||||
$filename=dol_sanitizeFileName($obj->ref);
|
||||
$filedir=$conf->contrat->dir_output . '/' . dol_sanitizeFileName($obj->ref);
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
|
||||
print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
|
||||
print '</td>';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['c.ref_customer']['checked']))
|
||||
{
|
||||
print '<td>'.$obj->ref_customer.'</td>';
|
||||
}
|
||||
if (! empty($arrayfields['c.ref_supplier']['checked']))
|
||||
{
|
||||
print '<td>'.$obj->ref_supplier.'</td>';
|
||||
}
|
||||
if (! empty($arrayfields['s.nom']['checked']))
|
||||
{
|
||||
print '<td>';
|
||||
//print '<a href="../comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a>';
|
||||
if ($obj->socid > 0)
|
||||
{
|
||||
print $socstatic->getNomUrl(1, '');
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['s.email']['checked']))
|
||||
{
|
||||
print '<td>'.$obj->email.'</td>';
|
||||
}
|
||||
// Town
|
||||
if (! empty($arrayfields['s.town']['checked']))
|
||||
{
|
||||
print '<td class="nocellnopadd">';
|
||||
print $obj->town;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Zip
|
||||
if (! empty($arrayfields['s.zip']['checked']))
|
||||
{
|
||||
print '<td class="nocellnopadd">';
|
||||
print $obj->zip;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// State
|
||||
if (! empty($arrayfields['state.nom']['checked']))
|
||||
{
|
||||
print "<td>".$obj->state_name."</td>\n";
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Country
|
||||
if (! empty($arrayfields['country.code_iso']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
$tmparray=getCountry($obj->fk_pays,'all');
|
||||
print $tmparray['label'];
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Type ent
|
||||
if (! empty($arrayfields['typent.code']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
|
||||
print $typenArray[$obj->typent_code];
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
if (! empty($arrayfields['sale_representative']['checked']))
|
||||
{
|
||||
// Sales representatives
|
||||
print '<td>';
|
||||
if ($obj->socid > 0)
|
||||
{
|
||||
$listsalesrepresentatives=$socstatic->getSalesRepresentatives($user);
|
||||
if ($listsalesrepresentatives < 0) dol_print_error($db);
|
||||
$nbofsalesrepresentative=count($listsalesrepresentatives);
|
||||
if ($nbofsalesrepresentative > 3) // We print only number
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$socstatic->id.'">';
|
||||
print $nbofsalesrepresentative;
|
||||
print '</a>';
|
||||
}
|
||||
else if ($nbofsalesrepresentative > 0)
|
||||
{
|
||||
$userstatic=new User($db);
|
||||
$j=0;
|
||||
foreach($listsalesrepresentatives as $val)
|
||||
{
|
||||
$userstatic->id=$val['id'];
|
||||
$userstatic->lastname=$val['lastname'];
|
||||
$userstatic->firstname=$val['firstname'];
|
||||
$userstatic->email=$val['email'];
|
||||
$userstatic->statut=$val['statut'];
|
||||
$userstatic->entity=$val['entity'];
|
||||
$userstatic->photo=$val['photo'];
|
||||
|
||||
//print '<div class="float">':
|
||||
print $userstatic->getNomUrl(-2);
|
||||
$j++;
|
||||
if ($j < $nbofsalesrepresentative) print ' ';
|
||||
//print '</div>';
|
||||
}
|
||||
}
|
||||
//else print $langs->trans("NoSalesRepresentativeAffected");
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
// Date
|
||||
if (! empty($arrayfields['c.date_contrat']['checked']))
|
||||
{
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzuser').'</td>';
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Date creation
|
||||
if (! empty($arrayfields['c.datec']['checked']))
|
||||
{
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Date modification
|
||||
if (! empty($arrayfields['c.tms']['checked']))
|
||||
{
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Date lower end date
|
||||
if (! empty($arrayfields['lower_planned_end_date']['checked']))
|
||||
{
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Status
|
||||
if (! empty($arrayfields['status']['checked']))
|
||||
{
|
||||
print '<td align="center">'.($obj->nb_initial>0?$obj->nb_initial:'').'</td>';
|
||||
print '<td align="center">'.($obj->nb_running>0?$obj->nb_running:'').'</td>';
|
||||
print '<td align="center">'.($obj->nb_expired>0?$obj->nb_expired:'').'</td>';
|
||||
print '<td align="center">'.($obj->nb_closed>0 ?$obj->nb_closed:'').'</td>';
|
||||
}
|
||||
// Action column
|
||||
print '<td class="nowrap" align="center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
$selected=0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
$hidegeneratedfilelistifempty=1;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
|
||||
|
||||
// Show list of available documents
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||
$urlsource.=str_replace('&','&',$param);
|
||||
|
||||
$filedir=$diroutputmassaction;
|
||||
$genallowed=$user->rights->contrat->lire;
|
||||
$delallowed=$user->rights->contrat->lire;
|
||||
|
||||
print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
$hidegeneratedfilelistifempty=1;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
|
||||
|
||||
// Show list of available documents
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||
$urlsource.=str_replace('&','&',$param);
|
||||
|
||||
$filedir=$diroutputmassaction;
|
||||
$genallowed=$user->rights->contrat->lire;
|
||||
$delallowed=$user->rights->contrat->lire;
|
||||
|
||||
print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -63,7 +63,7 @@ if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST[
|
||||
$row->table_element_line = $table_element_line;
|
||||
$row->fk_element = $fk_element;
|
||||
$row->id = $element_id;
|
||||
$row->line_ajaxorder($newrowordertab); // This update field rank or position in table table_element_line
|
||||
$row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line
|
||||
|
||||
// Reorder line to have position of children lines sharing same counter than parent lines
|
||||
// This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database.
|
||||
|
||||
@ -2841,7 +2841,6 @@ abstract class CommonObject
|
||||
$sql.= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')";
|
||||
}
|
||||
$sql .= ' ORDER BY sourcetype';
|
||||
//print $sql;
|
||||
|
||||
dol_syslog(get_class($this)."::fetchObjectLink", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -3086,9 +3085,10 @@ abstract class CommonObject
|
||||
* @param int $status Status to set
|
||||
* @param int $elementId Id of element to force (use this->id by default)
|
||||
* @param string $elementType Type of element to force (use this->table_element by default)
|
||||
* @param string $trigkey Trigger key to use for trigger
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function setStatut($status,$elementId=null,$elementType='')
|
||||
function setStatut($status, $elementId=null, $elementType='', $trigkey='')
|
||||
{
|
||||
global $user,$langs,$conf;
|
||||
|
||||
@ -3100,6 +3100,7 @@ abstract class CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
$fieldstatus="fk_statut";
|
||||
if ($elementTable == 'facture_rec') $fieldstatus="suspended";
|
||||
if ($elementTable == 'mailing') $fieldstatus="statut";
|
||||
if ($elementTable == 'cronjob') $fieldstatus="status";
|
||||
if ($elementTable == 'user') $fieldstatus="statut";
|
||||
@ -3117,13 +3118,16 @@ abstract class CommonObject
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$trigkey='';
|
||||
if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class
|
||||
if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class
|
||||
if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class
|
||||
if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE';
|
||||
if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED';
|
||||
if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED';
|
||||
// Try autoset of trigkey
|
||||
if (empty($trigkey))
|
||||
{
|
||||
if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class
|
||||
if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class
|
||||
if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class
|
||||
if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE';
|
||||
if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED';
|
||||
if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED';
|
||||
}
|
||||
|
||||
if ($trigkey)
|
||||
{
|
||||
@ -5908,15 +5912,15 @@ abstract class CommonObject
|
||||
/**
|
||||
* Function to show lines of extrafields with output datas
|
||||
*
|
||||
* @param Extrafields $extrafields Extrafield Object
|
||||
* @param string $mode Show output (view) or input (edit) for extrafield
|
||||
* @param array $params Optional parameters
|
||||
* @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names)
|
||||
*
|
||||
* @return string
|
||||
* @param Extrafields $extrafields Extrafield Object
|
||||
* @param string $mode Show output (view) or input (edit) for extrafield
|
||||
* @param array $params Optional parameters
|
||||
* @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $onetrtd All fields in same tr td
|
||||
* @return string
|
||||
*/
|
||||
function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='')
|
||||
function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='', $onetrtd=0)
|
||||
{
|
||||
global $_POST, $conf, $langs, $action;
|
||||
|
||||
@ -5980,15 +5984,13 @@ abstract class CommonObject
|
||||
$csstyle=$params['style'];
|
||||
}
|
||||
}
|
||||
if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
|
||||
|
||||
$out .= '<tr '.$class.$csstyle.' class="'.$this->element.'_extras_'.$key.'">';
|
||||
if (empty($onetrtd))
|
||||
{
|
||||
$out .= '<tr '.$class.$csstyle.' class="'.$this->element.'_extras_'.$key.'">';
|
||||
$colspan='0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= '<tr '.$class.$csstyle.' class="'.$this->element.'_extras_'.$key.'">';
|
||||
if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; }
|
||||
}
|
||||
|
||||
// Convert date into timestamp format (value in memory must be a timestamp)
|
||||
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
|
||||
{
|
||||
@ -6006,10 +6008,17 @@ abstract class CommonObject
|
||||
{
|
||||
$labeltoshow = '<span'.($mode != 'view' ? ' class="fieldrequired"':'').'>'.$labeltoshow.'</span>';
|
||||
}
|
||||
$out .= '<td>'.$labeltoshow.'</td>';
|
||||
|
||||
if (empty($onetrtd)) $out .= '<td>';
|
||||
else $out .= '<td'.($colspan?' colspan="'.($colspan+1).'"':'').'>';
|
||||
|
||||
$out .= $labeltoshow;
|
||||
|
||||
if (empty($onetrtd)) $out .= '</td><td'.($colspan?' colspan="'.($colspan).'"':'').'>';
|
||||
else $out.=' ';
|
||||
|
||||
$html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : '';
|
||||
$out .='<td id="'.$html_id.'" class="'.$this->element.'_extras_'.$key.'" '.($colspan?' colspan="'.$colspan.'"':'').'>';
|
||||
$out .='<span id="'.$html_id.'" class="'.$this->element.'_extras_'.$key.'">';
|
||||
|
||||
switch($mode) {
|
||||
case "view":
|
||||
@ -6021,9 +6030,8 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
$out .= '</td>';
|
||||
$out .= '</tr>';
|
||||
|
||||
if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
|
||||
else $out .= '</tr>';
|
||||
$e++;
|
||||
}
|
||||
}
|
||||
@ -6190,6 +6198,243 @@ abstract class CommonObject
|
||||
return $buyPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show photos of an object (nbmax maximum), into several columns
|
||||
*
|
||||
* @param string $modulepart 'product', 'ticketsup', ...
|
||||
* @param string $sdir Directory to scan (full absolute path)
|
||||
* @param int $size 0=original size, 1='small' use thumbnail if possible
|
||||
* @param int $nbmax Nombre maximum de photos (0=pas de max)
|
||||
* @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1.
|
||||
* @param int $showfilename 1=Show filename
|
||||
* @param int $showaction 1=Show icon with action links (resize, delete)
|
||||
* @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image.
|
||||
* @param int $maxWidth Max width of original image when size='small'
|
||||
* @param int $nolink Do not add a href link to view enlarged imaged into a new tab
|
||||
* @param int $notitle Do not add title tag on image
|
||||
* @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead)
|
||||
* @return string Html code to show photo. Number of photos shown is saved in this->nbphoto
|
||||
*/
|
||||
function show_photos($modulepart, $sdir, $size=0, $nbmax=0, $nbbyrow=5, $showfilename=0, $showaction=0, $maxHeight=120, $maxWidth=160, $nolink=0, $notitle=0, $usesharelink=0)
|
||||
{
|
||||
global $conf,$user,$langs;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
|
||||
include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
|
||||
|
||||
$sortfield='position_name';
|
||||
$sortorder='asc';
|
||||
|
||||
$dir = $sdir . '/';
|
||||
$pdir = '/';
|
||||
if ($modulepart == 'ticketsup')
|
||||
{
|
||||
$dir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->track_id.'/';
|
||||
$pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->track_id.'/';
|
||||
}
|
||||
else
|
||||
{
|
||||
$dir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/';
|
||||
$pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/';
|
||||
}
|
||||
|
||||
// For backward compatibility
|
||||
if ($modulepart == 'product' && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
|
||||
{
|
||||
$dir = $sdir . '/'. get_exdir($this->id,2,0,0,$this,$modulepart) . $this->id ."/photos/";
|
||||
$pdir = '/' . get_exdir($this->id,2,0,0,$this,$modulepart) . $this->id ."/photos/";
|
||||
}
|
||||
|
||||
// Defined relative dir to DOL_DATA_ROOT
|
||||
$relativedir = '';
|
||||
if ($dir)
|
||||
{
|
||||
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir);
|
||||
$relativedir = preg_replace('/^[\\/]/','',$relativedir);
|
||||
$relativedir = preg_replace('/[\\/]$/','',$relativedir);
|
||||
}
|
||||
|
||||
$dirthumb = $dir.'thumbs/';
|
||||
$pdirthumb = $pdir.'thumbs/';
|
||||
|
||||
$return ='<!-- Photo -->'."\n";
|
||||
$nbphoto=0;
|
||||
|
||||
$filearray=dol_dir_list($dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
||||
|
||||
/*if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs
|
||||
{
|
||||
$filearrayold=dol_dir_list($dirold,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
||||
$filearray=array_merge($filearray, $filearrayold);
|
||||
}*/
|
||||
|
||||
completeFileArrayWithDatabaseInfo($filearray, $relativedir);
|
||||
|
||||
if (count($filearray))
|
||||
{
|
||||
if ($sortfield && $sortorder)
|
||||
{
|
||||
$filearray=dol_sort_array($filearray, $sortfield, $sortorder);
|
||||
}
|
||||
|
||||
foreach($filearray as $key => $val)
|
||||
{
|
||||
$photo='';
|
||||
$file = $val['name'];
|
||||
|
||||
//if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory
|
||||
|
||||
//if (dol_is_file($dir.$file) && image_format_supported($file) >= 0)
|
||||
if (image_format_supported($file) >= 0)
|
||||
{
|
||||
$nbphoto++;
|
||||
$photo = $file;
|
||||
$viewfilename = $file;
|
||||
|
||||
if ($size == 1 || $size == 'small') { // Format vignette
|
||||
|
||||
// Find name of thumb file
|
||||
$photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small'));
|
||||
if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette='';
|
||||
|
||||
// Get filesize of original file
|
||||
$imgarray=dol_getImageSize($dir.$photo);
|
||||
|
||||
if ($nbbyrow > 0)
|
||||
{
|
||||
if ($nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
|
||||
|
||||
if ($nbphoto % $nbbyrow == 1) $return.= '<tr align=center valign=middle border=1>';
|
||||
$return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
|
||||
}
|
||||
else if ($nbbyrow < 0) $return .= '<div class="inline-block">';
|
||||
|
||||
$return.= "\n";
|
||||
|
||||
$relativefile=preg_replace('/^\//', '', $pdir.$photo);
|
||||
if (empty($nolink))
|
||||
{
|
||||
$urladvanced=getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity);
|
||||
if ($urladvanced) $return.='<a href="'.$urladvanced.'">';
|
||||
else $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
|
||||
}
|
||||
|
||||
// Show image (width height=$maxHeight)
|
||||
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
|
||||
$alt=$langs->transnoentitiesnoconv('File').': '.$relativefile;
|
||||
$alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
|
||||
if ($notitle) $alt='';
|
||||
|
||||
if ($usesharelink)
|
||||
{
|
||||
if ($val['share'])
|
||||
{
|
||||
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
|
||||
{
|
||||
$return.= '<!-- Show original file (thumb not yet available with shared links) -->';
|
||||
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
}
|
||||
else {
|
||||
$return.= '<!-- Show original file -->';
|
||||
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return.= '<!-- Show nophoto file (because file is not shared) -->';
|
||||
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
|
||||
{
|
||||
$return.= '<!-- Show thumb -->';
|
||||
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
}
|
||||
else {
|
||||
$return.= '<!-- Show original file -->';
|
||||
$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($nolink)) $return.= '</a>';
|
||||
$return.="\n";
|
||||
|
||||
if ($showfilename) $return.= '<br>'.$viewfilename;
|
||||
if ($showaction)
|
||||
{
|
||||
$return.= '<br>';
|
||||
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
|
||||
if ($photo_vignette && (image_format_supported($photo) > 0) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight))
|
||||
{
|
||||
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' </a>';
|
||||
}
|
||||
// Special cas for product
|
||||
if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||
{
|
||||
// Link to resize
|
||||
$return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> ';
|
||||
|
||||
// Link to delete
|
||||
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=delete&file='.urlencode($pdir.$viewfilename).'">';
|
||||
$return.= img_delete().'</a>';
|
||||
}
|
||||
}
|
||||
$return.= "\n";
|
||||
|
||||
if ($nbbyrow > 0)
|
||||
{
|
||||
$return.= '</td>';
|
||||
if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>';
|
||||
}
|
||||
else if ($nbbyrow < 0) $return.='</div>';
|
||||
}
|
||||
|
||||
if (empty($size)) { // Format origine
|
||||
$return.= '<img class="photo photowithmargin" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">';
|
||||
|
||||
if ($showfilename) $return.= '<br>'.$viewfilename;
|
||||
if ($showaction)
|
||||
{
|
||||
// Special case for product
|
||||
if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||
{
|
||||
// Link to resize
|
||||
$return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> ';
|
||||
|
||||
// Link to delete
|
||||
$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=delete&file='.urlencode($pdir.$viewfilename).'">';
|
||||
$return.= img_delete().'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// On continue ou on arrete de boucler ?
|
||||
if ($nbmax && $nbphoto >= $nbmax) break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($size==1 || $size=='small')
|
||||
{
|
||||
if ($nbbyrow > 0)
|
||||
{
|
||||
// Ferme tableau
|
||||
while ($nbphoto % $nbbyrow)
|
||||
{
|
||||
$return.= '<td width="'.ceil(100/$nbbyrow).'%"> </td>';
|
||||
$nbphoto++;
|
||||
}
|
||||
|
||||
if ($nbphoto) $return.= '</table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->nbphoto = $nbphoto;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -6224,7 +6469,6 @@ abstract class CommonObject
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function test if type is date
|
||||
*
|
||||
@ -6307,7 +6551,7 @@ abstract class CommonObject
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function set_save_query()
|
||||
protected function set_save_query()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -6361,7 +6605,7 @@ abstract class CommonObject
|
||||
*
|
||||
* @param stdClass $obj Contain data of object from database
|
||||
*/
|
||||
private function setVarsFromFetchObj(&$obj)
|
||||
protected function setVarsFromFetchObj(&$obj)
|
||||
{
|
||||
foreach ($this->fields as $field => $info)
|
||||
{
|
||||
@ -6406,7 +6650,7 @@ abstract class CommonObject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_field_list()
|
||||
protected function get_field_list()
|
||||
{
|
||||
$keys = array_keys($this->fields);
|
||||
return implode(',', $keys);
|
||||
|
||||
@ -73,7 +73,7 @@ abstract class CommonOrderLine extends CommonObjectLine
|
||||
|
||||
/**
|
||||
* Quantity
|
||||
* @var int
|
||||
* @var float
|
||||
*/
|
||||
public $qty;
|
||||
|
||||
|
||||
@ -425,7 +425,7 @@ class Conf
|
||||
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR';
|
||||
$this->currency=$this->global->MAIN_MONNAIE;
|
||||
|
||||
if (empty($conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
|
||||
if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
|
||||
|
||||
// conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
|
||||
if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
|
||||
@ -584,13 +584,15 @@ class Conf
|
||||
if (! isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT=0;
|
||||
|
||||
// Save inconsistent option
|
||||
if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && (! isset($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $conf->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
|
||||
if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (! isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
|
||||
{
|
||||
$conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
|
||||
$this->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
|
||||
}
|
||||
|
||||
$conf->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com';
|
||||
$conf->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567';
|
||||
if (! isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1;
|
||||
|
||||
$this->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com';
|
||||
$this->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567';
|
||||
|
||||
// For backward compatibility
|
||||
if (isset($this->product)) $this->produit=$this->product;
|
||||
|
||||
@ -1447,7 +1447,7 @@ class Form
|
||||
/**
|
||||
* Return select list of users
|
||||
*
|
||||
* @param string $selected User id or user object of user preselected. If -1, we use id of current user.
|
||||
* @param string $selected User id or user object of user preselected. If 0 or < -2, we use id of current user. If -1, keep unselected (if empty is allowed)
|
||||
* @param string $htmlname Field name in form
|
||||
* @param int $show_empty 0=list with no empty value, 1=add also an empty value into list
|
||||
* @param array $exclude Array list of users id to exclude
|
||||
@ -1462,10 +1462,11 @@ class Form
|
||||
* @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty.
|
||||
* @param string $morecss More css
|
||||
* @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on).
|
||||
* @param int $outputmode 0=HTML select string, 1=Array
|
||||
* @return string HTML select string
|
||||
* @see select_dolgroups
|
||||
*/
|
||||
function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0)
|
||||
function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0, $outputmode=0)
|
||||
{
|
||||
global $conf,$user,$langs;
|
||||
|
||||
@ -1491,6 +1492,7 @@ class Form
|
||||
}
|
||||
|
||||
$out='';
|
||||
$outarray = array();
|
||||
|
||||
// Forge request to select users
|
||||
$sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
|
||||
@ -1618,6 +1620,7 @@ class Form
|
||||
$out.=' - '.$disableline; // This is text from $enableonlytext parameter
|
||||
}
|
||||
$out.= '</option>';
|
||||
$outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -1634,6 +1637,7 @@ class Form
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
if ($outputmode) return $outarray;
|
||||
return $out;
|
||||
}
|
||||
|
||||
@ -3593,7 +3597,7 @@ class Form
|
||||
* @param string $action Action
|
||||
* @param array $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , ))
|
||||
* type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', ...
|
||||
* @param string $selectedchoice "" or "no" or "yes"
|
||||
* @param string $selectedchoice '' or 'no' or 'yes' or '1' or '0'
|
||||
* @param int $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
|
||||
* @param int $height Force height of box
|
||||
* @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
|
||||
@ -5417,23 +5421,23 @@ class Form
|
||||
* Return a HTML select string, built from an array of key+value.
|
||||
* Note: Do not apply langs->trans function on returned content, content may be entity encoded twice.
|
||||
*
|
||||
* @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect
|
||||
* @param array $array Array (key => value)
|
||||
* @param string|string[] $id Preselected key or preselected keys for multiselect
|
||||
* @param int|string $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (key is -1 and value is '' or ' ' if 1, key is -1 and value is text if string), <0 to add an empty value with key that is this value.
|
||||
* @param int $key_in_label 1 to show key into label with format "[key] value"
|
||||
* @param int $value_as_key 1 to use value as key
|
||||
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
|
||||
* @param int $translate 1=Translate and encode value
|
||||
* @param int $maxlen Length maximum for labels
|
||||
* @param int $disabled Html select box is disabled
|
||||
* @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order
|
||||
* @param string $morecss Add more class to css styles
|
||||
* @param int $addjscombo Add js combo
|
||||
* @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set
|
||||
* @param int $disablebademail Check if an email is found into value and if not disable and colorize entry
|
||||
* @param int $nohtmlescape No html escaping.
|
||||
* @return string HTML select string.
|
||||
* @param string $htmlname Name of html select area. Must start with "multi" if this is a multiselect
|
||||
* @param array $array Array (key => value)
|
||||
* @param string|string[] $id Preselected key or preselected keys for multiselect
|
||||
* @param int|string $show_empty 0 no empty value allowed, 1 or string to add an empty value into list (key is -1 and value is '' or ' ' if 1, key is -1 and value is text if string), <0 to add an empty value with key that is this value.
|
||||
* @param int $key_in_label 1 to show key into label with format "[key] value"
|
||||
* @param int $value_as_key 1 to use value as key
|
||||
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
|
||||
* @param int $translate 1=Translate and encode value
|
||||
* @param int $maxlen Length maximum for labels
|
||||
* @param int $disabled Html select box is disabled
|
||||
* @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order
|
||||
* @param string $morecss Add more class to css styles
|
||||
* @param int $addjscombo Add js combo
|
||||
* @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set
|
||||
* @param int $disablebademail Check if an email is found into value and if not disable and colorize entry
|
||||
* @param int $nohtmlescape No html escaping.
|
||||
* @return string HTML select string.
|
||||
* @see multiselectarray
|
||||
*/
|
||||
static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0, $moreparamonempty='',$disablebademail=0, $nohtmlescape=0)
|
||||
@ -6458,7 +6462,7 @@ class Form
|
||||
else if ($object->element == 'member')
|
||||
{
|
||||
$fullname=$object->getFullName($langs);
|
||||
if ($object->morphy == 'mor') {
|
||||
if ($object->morphy == 'mor' && $object->societe) {
|
||||
$ret.= dol_htmlentities($object->societe) . ((! empty($fullname) && $object->societe != $fullname)?' ('.dol_htmlentities($fullname).')':'');
|
||||
} else {
|
||||
$ret.= dol_htmlentities($fullname) . ((! empty($object->societe) && $object->societe != $fullname)?' ('.dol_htmlentities($object->societe).')':'');
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
* \ingroup Advanced accountancy
|
||||
* \brief File of class with all html predefined components
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -865,7 +865,7 @@ class FormMail extends Form
|
||||
}
|
||||
}
|
||||
|
||||
// Complete substitution array
|
||||
// Complete substitution array with the url to make online payment
|
||||
$paymenturl='';
|
||||
if (empty($this->substit['__REF__']))
|
||||
{
|
||||
@ -877,13 +877,13 @@ class FormMail extends Form
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
$langs->load('paypal');
|
||||
$typeforonlinepayment='free';
|
||||
if ($this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template
|
||||
if ($this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template
|
||||
if ($this->param["models"]=='member_send') $typeforonlinepayment='member'; // TODO use detection on something else than template
|
||||
if ($this->param["models"]=='order' || $this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template
|
||||
if ($this->param["models"]=='invoice' || $this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template
|
||||
if ($this->param["models"]=='member') $typeforonlinepayment='member'; // TODO use detection on something else than template
|
||||
$url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']);
|
||||
$paymenturl=$url;
|
||||
$paymenturl=$url;
|
||||
}
|
||||
|
||||
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?$langs->trans("PredefinedMailContentLink", $paymenturl):'');
|
||||
$this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl;
|
||||
|
||||
//Add lines substitution key from each line
|
||||
@ -994,12 +994,12 @@ class FormMail extends Form
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $type_template Get message for type=$type_template, type='all' also included.
|
||||
* @param string $user Use template public or limited to this user
|
||||
* @param string $user Get template public or limited to this user
|
||||
* @param Translate $outputlangs Output lang object
|
||||
* @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position or -2 for exact match with label (no aswer if not found)
|
||||
* @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found)
|
||||
* @param int $active 1=Only active template, 0=Only disabled, -1=All
|
||||
* @param string $label Label of template
|
||||
* @return ModelMail
|
||||
* @return ModelMail One instance of ModelMail
|
||||
*/
|
||||
public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1, $label='')
|
||||
{
|
||||
@ -1011,7 +1011,7 @@ class FormMail extends Form
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT label, topic, joinfiles, content, content_lines, lang";
|
||||
$sql = "SELECT rowid, label, topic, joinfiles, content, content_lines, lang";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
|
||||
$sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')";
|
||||
$sql.= " AND entity IN (".getEntity('c_email_templates').")";
|
||||
@ -1033,6 +1033,7 @@ class FormMail extends Form
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
if ($obj) {
|
||||
$ret->id = $obj->rowid;
|
||||
$ret->label = $obj->label;
|
||||
$ret->lang = $obj->lang;
|
||||
$ret->topic = $obj->topic;
|
||||
@ -1153,6 +1154,7 @@ class FormMail extends Form
|
||||
$line->topic=$obj->topic;
|
||||
$line->content=$obj->content;
|
||||
$line->content_lines=$obj->content_lines;
|
||||
|
||||
$this->lines_model[]=$line;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
@ -808,7 +808,7 @@ class FormTicketsup
|
||||
|
||||
|
||||
// External users can't send message email
|
||||
if ($user->rights->ticketsup->write && !$user->societe_id) {
|
||||
if ($user->rights->ticketsup->write && !$user->socid) {
|
||||
print '<tr><td width="30%"></td><td colspan="2">';
|
||||
$checkbox_selected = ( GETPOST('send_email') == "1" ? ' checked' : '');
|
||||
print '<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.'/> ';
|
||||
@ -839,7 +839,7 @@ class FormTicketsup
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
if (!$user->societe_id) {
|
||||
if (! $user->socid) {
|
||||
print '<tr><td width="30%"></td><td>';
|
||||
$checkbox_selected = ( GETPOST('private_message') == "1" ? ' checked' : '');
|
||||
print '<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.'/> ';
|
||||
@ -902,7 +902,7 @@ class FormTicketsup
|
||||
|
||||
// Intro
|
||||
// External users can't send message email
|
||||
if ($user->rights->ticketsup->write && !$user->societe_id) {
|
||||
if ($user->rights->ticketsup->write && !$user->socid) {
|
||||
$mail_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKETS_MESSAGE_MAIL_INTRO;
|
||||
print '<tr class="email_line"><td><label for="mail_intro">' . $langs->trans("TicketMessageMailIntro") . '</label>';
|
||||
|
||||
@ -945,7 +945,7 @@ class FormTicketsup
|
||||
$doleditor = new DolEditor('message', $defaultmessage, '100%', 350, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
|
||||
$doleditor->Create();
|
||||
print '</td><td align="center">';
|
||||
if ($user->rights->ticketsup->write && !$user->societe_id) {
|
||||
if ($user->rights->ticketsup->write && !$user->socid) {
|
||||
print $form->textwithpicto('', $langs->trans("TicketMessageHelp"), 1, 'help');
|
||||
}
|
||||
|
||||
@ -953,7 +953,7 @@ class FormTicketsup
|
||||
|
||||
// Signature
|
||||
// External users can't send message email
|
||||
if ($user->rights->ticketsup->write && !$user->societe_id) {
|
||||
if ($user->rights->ticketsup->write && !$user->socid) {
|
||||
$mail_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE;
|
||||
print '<tr class="email_line"><td><label for="mail_intro">' . $langs->trans("TicketMessageMailSignature") . '</label>';
|
||||
|
||||
|
||||
@ -169,12 +169,12 @@ class Interfaces
|
||||
|
||||
if (method_exists($objMod, 'runTrigger')) // New method to implement
|
||||
{
|
||||
dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_INFO);
|
||||
//dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG);
|
||||
$result=$objMod->runTrigger($action,$object,$user,$langs,$conf);
|
||||
}
|
||||
elseif (method_exists($objMod, 'run_trigger')) // Deprecated method
|
||||
{
|
||||
dol_syslog(get_class($this)."::run_triggers action=".$action." Launch run_trigger for file '".$files[$key]."'", LOG_INFO);
|
||||
dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING);
|
||||
$result=$objMod->run_trigger($action,$object,$user,$langs,$conf);
|
||||
}
|
||||
else
|
||||
|
||||
@ -177,20 +177,10 @@ class Ldap
|
||||
if ($connected) break;
|
||||
if (empty($host)) continue;
|
||||
|
||||
if (preg_match('/^ldap/',$host))
|
||||
{
|
||||
if ($this->serverPing($host) === true) {
|
||||
$this->connection = ldap_connect($host);
|
||||
}
|
||||
else continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->serverPing($host, $this->serverPort) === true) {
|
||||
$this->connection = ldap_connect($host,$this->serverPort);
|
||||
}
|
||||
else continue;
|
||||
if ($this->serverPing($host, $this->serverPort) === true) {
|
||||
$this->connection = ldap_connect($host, $this->serverPort);
|
||||
}
|
||||
else continue;
|
||||
|
||||
if (is_resource($this->connection))
|
||||
{
|
||||
@ -742,6 +732,10 @@ class Ldap
|
||||
if (preg_match('/^ldaps:\/\/([^\/]+)\/?$/',$host, $regs)) {
|
||||
$host = 'ssl://'.$regs[1];
|
||||
}
|
||||
// Remove ldap://
|
||||
if (preg_match('/^ldap:\/\/([^\/]+)\/?$/',$host, $regs)) {
|
||||
$host = $regs[1];
|
||||
}
|
||||
$op = @fsockopen($host, $port, $errno, $errstr, $timeout);
|
||||
if (!$op) return false; //DC is N/A
|
||||
else {
|
||||
|
||||
@ -47,7 +47,7 @@ class Utils
|
||||
* Purge files into directory of data files.
|
||||
* CAN BE A CRON TASK
|
||||
*
|
||||
* @param string $choice Choice of purge mode ('tempfiles', 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfile')
|
||||
* @param string $choice Choice of purge mode ('tempfiles', '' or 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfile')
|
||||
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
|
||||
*/
|
||||
function purgeFiles($choice='tempfilesold')
|
||||
@ -129,7 +129,7 @@ class Utils
|
||||
}
|
||||
elseif ($filesarray[$key]['type'] == 'file')
|
||||
{
|
||||
// If (file that is not logfile) or (if logfile with option logfile)
|
||||
// If (file that is not logfile) or (if mode is logfile)
|
||||
if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile')
|
||||
{
|
||||
$result=dol_delete_file($filesarray[$key]['fullname'], 1, 1);
|
||||
@ -138,7 +138,10 @@ class Utils
|
||||
$count++;
|
||||
$countdeleted++;
|
||||
}
|
||||
else $counterror++;
|
||||
else
|
||||
{
|
||||
$counterror++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -446,7 +449,6 @@ class Utils
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -672,8 +674,8 @@ class Utils
|
||||
/**
|
||||
* This saves syslog files and compresses older ones
|
||||
* Used from cronjob
|
||||
*
|
||||
* @return int 0 if OK, < 0 if KO
|
||||
*
|
||||
* @return int 0 if OK, < 0 if KO
|
||||
*/
|
||||
function compressSyslogs() {
|
||||
global $conf;
|
||||
@ -683,6 +685,7 @@ class Utils
|
||||
}
|
||||
|
||||
if(! function_exists('gzopen')) {
|
||||
$this->error = 'Support for gzopen not available in this PHP';
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -690,7 +693,7 @@ class Utils
|
||||
|
||||
$nbSaves = ! empty($conf->global->SYSLOG_FILE_SAVES) ? intval($conf->global->SYSLOG_FILE_SAVES) : 14;
|
||||
|
||||
if(empty($conf->global->SYSLOG_FILE)) {
|
||||
if (empty($conf->global->SYSLOG_FILE)) {
|
||||
$mainlogdir = DOL_DATA_ROOT;
|
||||
$mainlog = 'dolibarr.log';
|
||||
} else {
|
||||
@ -707,7 +710,7 @@ class Utils
|
||||
$logname = $file['name'];
|
||||
$logpath = $file['path'];
|
||||
|
||||
// Handle already compressed files
|
||||
// Handle already compressed files to rename them and add +1
|
||||
|
||||
$filter = '^'.preg_quote($logname, '/').'\.([0-9]+)\.gz$';
|
||||
|
||||
@ -726,7 +729,7 @@ class Utils
|
||||
krsort($gzfiles, SORT_NUMERIC);
|
||||
|
||||
foreach($gzfiles as $numsave => $dummy) {
|
||||
if(dol_is_file($logpath.'/'.$logname.'.'.($numsave+1).'.gz')) {
|
||||
if (dol_is_file($logpath.'/'.$logname.'.'.($numsave+1).'.gz')) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
@ -738,18 +741,19 @@ class Utils
|
||||
}
|
||||
|
||||
// Compress last save
|
||||
|
||||
if(dol_is_file($logpath.'/'.$logname.'.1')) {
|
||||
if (dol_is_file($logpath.'/'.$logname.'.1')) {
|
||||
if($nbSaves > 1) {
|
||||
$gzfilehandle = gzopen($logpath.'/'.$logname.'.2.gz', 'wb9');
|
||||
|
||||
if(empty($gzfilehandle)) {
|
||||
if (empty($gzfilehandle)) {
|
||||
$this->error = 'Failted to open file '.$logpath.'/'.$logname.'.2.gz';
|
||||
return -3;
|
||||
}
|
||||
|
||||
$sourcehandle = fopen($logpath.'/'.$logname.'.1', 'r');
|
||||
|
||||
if(empty($sourcehandle)) {
|
||||
if (empty($sourcehandle)) {
|
||||
$this->error = 'Failed to open file '.$logpath.'/'.$logname.'.1';
|
||||
return -4;
|
||||
}
|
||||
|
||||
@ -766,14 +770,16 @@ class Utils
|
||||
|
||||
// Compress current file et recreate it
|
||||
|
||||
if(dol_is_file($logpath.'/'.$logname)) {
|
||||
if(dol_move($logpath.'/'.$logname, $logpath.'/'.$logname.'.1', 0, 1, 0, 0)) {
|
||||
if (dol_is_file($logpath.'/'.$logname)) {
|
||||
if (dol_move($logpath.'/'.$logname, $logpath.'/'.$logname.'.1', 0, 1, 0, 0))
|
||||
{
|
||||
$newlog = fopen($logpath.'/'.$logname, 'a+');
|
||||
fclose($newlog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output = 'Archive log files (keeping last SYSLOG_FILE_SAVES='.$nbSaves.' files) done.';
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1321,14 +1321,15 @@ function complete_elementList_with_modules(&$elementList)
|
||||
/**
|
||||
* Show array with constants to edit
|
||||
*
|
||||
* @param array $tableau Array of constants
|
||||
* @param array $tableau Array of constants array('key'=>type, ) where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ...
|
||||
* @param int $strictw3c 0=Include form into table (deprecated), 1=Form is outside table to respect W3C (no form into table), 2=No form nor button at all
|
||||
* @param string $helptext Help
|
||||
* @return void
|
||||
*/
|
||||
function form_constantes($tableau, $strictw3c=0, $helptext='')
|
||||
{
|
||||
global $db,$bc,$langs,$conf,$_Avery_Labels;
|
||||
global $db,$bc,$langs,$conf,$user;
|
||||
global $_Avery_Labels;
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
@ -1343,11 +1344,20 @@ function form_constantes($tableau, $strictw3c=0, $helptext='')
|
||||
print '</td>';
|
||||
if (empty($strictw3c)) print '<td align="center" width="80">'.$langs->trans("Action").'</td>';
|
||||
print "</tr>\n";
|
||||
$var=true;
|
||||
|
||||
$listofparam=array();
|
||||
foreach($tableau as $const) // Loop on each param
|
||||
foreach($tableau as $key => $const) // Loop on each param
|
||||
{
|
||||
// $const is a const key like 'MYMODULE_ABC'
|
||||
if (is_numeric($key)) {
|
||||
$type = 'string';
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = $const;
|
||||
$const = $key;
|
||||
}
|
||||
|
||||
$sql = "SELECT ";
|
||||
$sql.= "rowid";
|
||||
$sql.= ", ".$db->decrypt('name')." as name";
|
||||
@ -1355,7 +1365,7 @@ function form_constantes($tableau, $strictw3c=0, $helptext='')
|
||||
$sql.= ", type";
|
||||
$sql.= ", note";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$db->decrypt('name')." = '".$const."'";
|
||||
$sql.= " WHERE ".$db->decrypt('name')." = '".$db->escape($const)."'";
|
||||
$sql.= " AND entity IN (0, ".$conf->entity.")";
|
||||
$sql.= " ORDER BY name ASC, entity DESC";
|
||||
$result = $db->query($sql);
|
||||
@ -1365,23 +1375,26 @@ function form_constantes($tableau, $strictw3c=0, $helptext='')
|
||||
{
|
||||
$obj = $db->fetch_object($result); // Take first result of select
|
||||
|
||||
|
||||
// For avoid warning in strict mode
|
||||
if (empty($obj)) {
|
||||
$obj = (object) array('rowid'=>'','name'=>'','value'=>'','type'=>'','note'=>'');
|
||||
if (empty($obj)) // If not yet into table
|
||||
{
|
||||
$obj = (object) array('rowid'=>'','name'=>$const,'value'=>'','type'=>$type,'note'=>'');
|
||||
}
|
||||
|
||||
if (empty($strictw3c)) print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
if (empty($strictw3c))
|
||||
{
|
||||
print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Show constant
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
if (empty($strictw3c)) print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="rowid'.(empty($strictw3c)?'':'[]').'" value="'.$obj->rowid.'">';
|
||||
print '<input type="hidden" name="constname'.(empty($strictw3c)?'':'[]').'" value="'.$const.'">';
|
||||
print '<input type="hidden" name="constnote'.(empty($strictw3c)?'':'[]').'" value="'.nl2br(dol_escape_htmltag($obj->note)).'">';
|
||||
print '<input type="hidden" name="constnote_'.$obj->name.'" value="'.nl2br(dol_escape_htmltag($obj->note)).'">';
|
||||
print '<input type="hidden" name="consttype_'.$obj->name.'" value="'.($obj->type?$obj->type:'string').'">';
|
||||
|
||||
print $langs->trans('Desc'.$const);
|
||||
|
||||
@ -1428,34 +1441,57 @@ function form_constantes($tableau, $strictw3c=0, $helptext='')
|
||||
}
|
||||
print $form->selectarray('constvalue'.(empty($strictw3c)?'':'[]'),$arrayoflabels,($obj->value?$obj->value:'CARD'),1,0,0);
|
||||
print '<input type="hidden" name="consttype" value="yesno">';
|
||||
print '<input type="hidden" name="constnote'.(empty($strictw3c)?'':'[]').'" value="'.nl2br(dol_escape_htmltag($obj->note)).'">';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>';
|
||||
if (in_array($const,array('ADHERENT_CARD_TEXT','ADHERENT_CARD_TEXT_RIGHT','ADHERENT_ETIQUETTE_TEXT')))
|
||||
print '<input type="hidden" name="consttype'.(empty($strictw3c)?'':'[]').'" value="'.($obj->type?$obj->type:'string').'">';
|
||||
print '<input type="hidden" name="constnote'.(empty($strictw3c)?'':'[]').'" value="'.nl2br(dol_escape_htmltag($obj->note)).'">';
|
||||
if ($obj->type == 'textarea' || in_array($const,array('ADHERENT_CARD_TEXT','ADHERENT_CARD_TEXT_RIGHT','ADHERENT_ETIQUETTE_TEXT')))
|
||||
{
|
||||
print '<textarea class="flat" name="constvalue'.(empty($strictw3c)?'':'[]').'" cols="50" rows="5" wrap="soft">'."\n";
|
||||
print $obj->value;
|
||||
print "</textarea>\n";
|
||||
print '<input type="hidden" name="consttype" value="texte">';
|
||||
}
|
||||
else if (in_array($const,array('ADHERENT_AUTOREGISTER_NOTIF_MAIL','ADHERENT_AUTOREGISTER_MAIL','ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL')))
|
||||
elseif ($obj->type == 'html')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor('constvalue_'.$const.(empty($strictw3c)?'':'[]'),$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,ROWS_5,'90%');
|
||||
$doleditor->Create();
|
||||
print '<input type="hidden" name="consttype'.(empty($strictw3c)?'':'[]').'" value="texte">';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor=new DolEditor('constvalue_'.$const.(empty($strictw3c)?'':'[]'),$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,ROWS_5,'90%');
|
||||
$doleditor->Create();
|
||||
}
|
||||
else if ($obj->type == 'yesno')
|
||||
elseif ($obj->type == 'yesno')
|
||||
{
|
||||
print $form->selectyesno('constvalue'.(empty($strictw3c)?'':'[]'),$obj->value,1);
|
||||
print '<input type="hidden" name="consttype'.(empty($strictw3c)?'':'[]').'" value="yesno">';
|
||||
print $form->selectyesno('constvalue'.(empty($strictw3c)?'':'[]'),$obj->value,1);
|
||||
}
|
||||
else
|
||||
elseif (preg_match('/emailtemplate/', $obj->type))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
|
||||
$tmp=explode(':', $obj->type);
|
||||
|
||||
$nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, -1); // We set lang=null to get in priority record with no lang
|
||||
//$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
|
||||
$arrayofmessagename=array();
|
||||
if (is_array($formmail->lines_model))
|
||||
{
|
||||
foreach($formmail->lines_model as $modelmail)
|
||||
{
|
||||
//var_dump($modelmail);
|
||||
$moreonlabel='';
|
||||
if (! empty($arrayofmessagename[$modelmail->label])) $moreonlabel=' <span class="opacitymedium">('.$langs->trans("SeveralLangugeVariatFound").')</span>';
|
||||
$arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/','',$modelmail->label)).$moreonlabel;
|
||||
}
|
||||
}
|
||||
//var_dump($arraydefaultmessage);
|
||||
//var_dump($arrayofmessagename);
|
||||
print $form->selectarray('constvalue_'.$obj->name, $arrayofmessagename, $obj->value, 'None', 1, 0, '', 0, 0, 0, '', '', 1);
|
||||
}
|
||||
else // type = 'string' ou 'chaine'
|
||||
{
|
||||
print '<input type="text" class="flat" size="48" name="constvalue'.(empty($strictw3c)?'':'[]').'" value="'.dol_escape_htmltag($obj->value).'">';
|
||||
print '<input type="hidden" name="consttype'.(empty($strictw3c)?'':'[]').'" value="chaine">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ function societe_prepare_head(Societe $object)
|
||||
}
|
||||
|
||||
// Related items
|
||||
if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fichinter->enabled) || ! empty($conf->fournisseur->enabled))
|
||||
if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->ficheinter->enabled) || ! empty($conf->fournisseur->enabled))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Referers");
|
||||
@ -1530,10 +1530,17 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
$out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||
$out.='</tr>';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
|
||||
$caction=new CActionComm($db);
|
||||
$arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1);
|
||||
|
||||
foreach ($histo as $key=>$value)
|
||||
{
|
||||
$actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo
|
||||
|
||||
$actionstatic->type_picto=$histo[$key]['apicto'];
|
||||
$actionstatic->type_code=$histo[$key]['acode'];
|
||||
|
||||
$out.='<tr class="oddeven">';
|
||||
|
||||
// Done or todo
|
||||
@ -1564,26 +1571,26 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
$out.='<td>';
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
if ($histo[$key]['apicto']) $out.=img_picto('', $histo[$key]['apicto']);
|
||||
if ($actionstatic->type_picto) print img_picto('', $actionstatic->type_picto);
|
||||
else {
|
||||
if ($histo[$key]['acode'] == 'AC_TEL') $out.=img_picto('', 'object_phoning').' ';
|
||||
if ($histo[$key]['acode'] == 'AC_FAX') $out.=img_picto('', 'object_phoning_fax').' ';
|
||||
if ($histo[$key]['acode'] == 'AC_EMAIL') $out.=img_picto('', 'object_email').' ';
|
||||
if ($actionstatic->type_code == 'AC_RDV') $out.= img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
|
||||
elseif ($actionstatic->type_code == 'AC_TEL') $out.= img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
|
||||
elseif ($actionstatic->type_code == 'AC_FAX') $out.= img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
|
||||
elseif ($actionstatic->type_code == 'AC_EMAIL') $out.= img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
|
||||
elseif ($actionstatic->type_code == 'AC_INT') $out.= img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
|
||||
elseif (! preg_match('/_AUTO/', $actionstatic->type_code)) $out.= img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' ';
|
||||
}
|
||||
$out.=$actionstatic->type;
|
||||
}
|
||||
else {
|
||||
$typelabel = $actionstatic->type;
|
||||
if ($histo[$key]['acode'] != 'AC_OTH_AUTO') $typelabel = $langs->trans("ActionAC_MANUAL");
|
||||
$out.=$typelabel;
|
||||
}
|
||||
$labeltype=$actionstatic->type_code;
|
||||
if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype='AC_OTH';
|
||||
if (! empty($arraylist[$labeltype])) $labeltype=$arraylist[$labeltype];
|
||||
$out.= dol_trunc($labeltype,28);
|
||||
$out.='</td>';
|
||||
|
||||
// Title
|
||||
$out.='<td>';
|
||||
if (isset($histo[$key]['type']) && $histo[$key]['type']=='action')
|
||||
{
|
||||
$actionstatic->type_code=$histo[$key]['acode'];
|
||||
$transcode=$langs->trans("Action".$histo[$key]['acode']);
|
||||
$libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:$histo[$key]['alabel']);
|
||||
//$actionstatic->libelle=$libelle;
|
||||
@ -1635,7 +1642,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
$propalstatic->type=$histo[$key]['ftype'];
|
||||
$out.=$propalstatic->getNomUrl(1);
|
||||
} else {
|
||||
$out.= $langs->trans("ProposalDeleted");
|
||||
//$out.= '<span class="opacitymedium">'.$langs->trans("ProposalDeleted").'</span>';
|
||||
}
|
||||
}
|
||||
elseif (($histo[$key]['elementtype'] == 'order' || $histo[$key]['elementtype'] == 'commande') && ! empty($conf->commande->enabled))
|
||||
@ -1646,7 +1653,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
$orderstatic->type=$histo[$key]['ftype'];
|
||||
$out.=$orderstatic->getNomUrl(1);
|
||||
} else {
|
||||
$out.= $langs->trans("OrderDeleted");
|
||||
//$out.= '<span class="opacitymedium">'.$langs->trans("OrderDeleted").'<span>';
|
||||
}
|
||||
}
|
||||
elseif (($histo[$key]['elementtype'] == 'invoice' || $histo[$key]['elementtype'] == 'facture') && ! empty($conf->facture->enabled))
|
||||
@ -1657,7 +1664,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
$facturestatic->type=$histo[$key]['ftype'];
|
||||
$out.=$facturestatic->getNomUrl(1,'compta');
|
||||
} else {
|
||||
$out.= $langs->trans("InvoiceDeleted");
|
||||
//$out.= '<span class="opacitymedium">'.$langs->trans("InvoiceDeleted").'</span>';
|
||||
}
|
||||
}
|
||||
else $out.=' ';
|
||||
|
||||
@ -1278,6 +1278,7 @@ function dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$
|
||||
$result=dol_delete_file("$dir/$item", 1, $nophperrors);
|
||||
$count++;
|
||||
if ($result) $countdeleted++;
|
||||
//else print 'Error on '.$item."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1288,6 +1289,7 @@ function dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$
|
||||
$result=dol_delete_dir($dir, $nophperrors);
|
||||
$count++;
|
||||
if ($result) $countdeleted++;
|
||||
//else print 'Error on '.$dir."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1327,7 +1327,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
$showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
|
||||
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
|
||||
if ($conf->browser->phone) $maxvisiblephotos=1;
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos('product', $conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
else
|
||||
{
|
||||
if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
|
||||
@ -1346,7 +1346,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
$showimage=$object->is_photo_available($conf->ticketsup->dir_output.'/'.$object->track_id);
|
||||
$maxvisiblephotos=(isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO)?$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO:2);
|
||||
if ($conf->browser->phone) $maxvisiblephotos=1;
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->ticketsup->dir_output,'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos('ticketsup', $conf->ticketsup->dir_output,'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
else
|
||||
{
|
||||
if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
|
||||
@ -3082,7 +3082,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
||||
$pictowithoutext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto);
|
||||
|
||||
//if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on')))
|
||||
if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow')))
|
||||
if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow')))
|
||||
{
|
||||
$fakey = $pictowithoutext; $facolor=''; $fasize='';
|
||||
if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; }
|
||||
@ -3095,7 +3095,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
||||
elseif ($pictowithoutext == 'resize') { $fakey = 'fa-crop'; $facolor='#444'; }
|
||||
elseif ($pictowithoutext == 'uparrow') { $fakey = 'fa-mail-forward'; $facolor='#555'; }
|
||||
elseif ($pictowithoutext == 'unlink') { $fakey = 'fa-chain-broken'; $facolor='#555'; }
|
||||
else { $fakey = 'fa-'.$pictowithoutext; $facolor='#999'; }
|
||||
elseif ($pictowithoutext == 'playdisabled') { $fakey = 'fa-play'; $facolor='#ccc'; }
|
||||
else { $fakey = 'fa-'.$pictowithoutext; $facolor='#444'; }
|
||||
|
||||
if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss.=($morecss?' ':'').$reg[1]; }
|
||||
$enabledisablehtml ='<span class="fa '.$fakey.' marginleftonly valignmiddle'.($morecss?' '.$morecss:'').'" style="'.($fasize?('font-size: '.$fasize.';'):'').($facolor?(' color: '.$facolor.';'):'').'" alt="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'"'.($moreatt?' '.$moreatt:'').'">';
|
||||
@ -5685,6 +5686,7 @@ function dol_textishtml($msg,$option=0)
|
||||
elseif (preg_match('/<h[0-9]>/i',$msg)) return true;
|
||||
elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
|
||||
elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -5728,11 +5730,31 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
|
||||
$substitutionarray=array();
|
||||
|
||||
if (empty($exclude) || ! in_array('system', $exclude))
|
||||
if (empty($exclude) || ! in_array('user', $exclude))
|
||||
{
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$outputlangs->trans('TranslationOfKey');
|
||||
$substitutionarray['__[AnyConstantKey]__']=$outputlangs->trans('ValueOfConstant');
|
||||
$substitutionarray['__DOL_MAIN_URL_ROOT__']=DOL_MAIN_URL_ROOT;
|
||||
// Add SIGNATURE into substitutionarray first, so, when we will make the substitution,
|
||||
// this will include signature content first and then replace var found into content of signature
|
||||
$signature = $user->signature;
|
||||
$substitutionarray=array_merge($substitutionarray, array(
|
||||
'__USER_SIGNATURE__' => (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '')
|
||||
)
|
||||
);
|
||||
// For backward compatibility
|
||||
if ($onlykey != 2)
|
||||
{
|
||||
$substitutionarray['__SIGNATURE__'] = (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '');
|
||||
}
|
||||
|
||||
$substitutionarray=array_merge($substitutionarray, array(
|
||||
'__USER_ID__' => (string) $user->id,
|
||||
'__USER_LOGIN__' => (string) $user->login,
|
||||
'__USER_LASTNAME__' => (string) $user->lastname,
|
||||
'__USER_FIRSTNAME__' => (string) $user->firstname,
|
||||
'__USER_FULLNAME__' => (string) $user->getFullName($outputlangs),
|
||||
'__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'),
|
||||
'__USER_REMOTE_IP__' => (string) $_SERVER['REMOTE_ADDR']
|
||||
)
|
||||
);
|
||||
}
|
||||
if ((empty($exclude) || ! in_array('mycompany', $exclude)) && is_object($mysoc))
|
||||
{
|
||||
@ -5754,6 +5776,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
'__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id
|
||||
));
|
||||
}
|
||||
|
||||
if (($onlykey || is_object($object)) && (empty($exclude) || ! in_array('object', $exclude)))
|
||||
{
|
||||
if ($onlykey)
|
||||
@ -5768,8 +5791,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
$substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__';
|
||||
$substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__';
|
||||
|
||||
if (is_object($object) && $object->element == 'shipping')
|
||||
if (is_object($object) && $object->element == 'member')
|
||||
{
|
||||
$substitutionarray['__MEMBER_ID__'] = '__MEMBER_ID__';
|
||||
$substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__';
|
||||
$substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__';
|
||||
$substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__';
|
||||
@ -5783,7 +5807,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = 'Lowest data for planned expiration of service';
|
||||
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = 'Lowest date and hour for planned expiration of service';
|
||||
|
||||
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'LinkToPayOnlineIfApplicable';
|
||||
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'UrlToPayOnlineIfApplicable';
|
||||
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = 'TextAndUrlToPayOnlineIfApplicable';
|
||||
$substitutionarray['__SECUREKEYPAYMENT__'] = 'Security key (if key is not unique per record)';
|
||||
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = 'Security key for payment on a member subscription (one key per member)';
|
||||
$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = 'Security key for payment on an order';
|
||||
@ -5803,11 +5828,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
$substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : ''));
|
||||
$substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : '');
|
||||
|
||||
// TODO USe this ?
|
||||
// TODO Use this ?
|
||||
$msgishtml = 0;
|
||||
|
||||
$birthday = dol_print_date($object->birth,'day');
|
||||
|
||||
$substitutionarray['__MEMBER_ID__']=$object->id;
|
||||
if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
|
||||
$substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname;
|
||||
$substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname;
|
||||
@ -5880,7 +5906,27 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
}
|
||||
}
|
||||
|
||||
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'TODO';
|
||||
// Complete substitution array with the url to make online payment
|
||||
$paymenturl='';
|
||||
if (empty($substitutionarray['__REF__']))
|
||||
{
|
||||
$paymenturl='';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the online payment url link into __ONLINE_PAYMENT_URL__ key
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
$outputlangs->load('paypal');
|
||||
$typeforonlinepayment='free';
|
||||
if (is_object($object) && $object->element == 'commande') $typeforonlinepayment='order';
|
||||
if (is_object($object) && $object->element == 'facture') $typeforonlinepayment='invoice';
|
||||
if (is_object($object) && $object->element == 'member') $typeforonlinepayment='member';
|
||||
$url=getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']);
|
||||
$paymenturl=$url;
|
||||
}
|
||||
|
||||
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?$outputlangs->trans("PredefinedMailContentLink", $paymenturl):'');
|
||||
$substitutionarray['__ONLINE_PAYMENT_URL__']=$paymenturl;
|
||||
}
|
||||
}
|
||||
if (empty($exclude) || ! in_array('objectamount', $exclude))
|
||||
@ -5930,31 +5976,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
));
|
||||
}
|
||||
|
||||
if (empty($exclude) || ! in_array('user', $exclude))
|
||||
if (empty($exclude) || ! in_array('system', $exclude))
|
||||
{
|
||||
// Add SIGNATURE into substitutionarray first, so, when we will make the substitution,
|
||||
// this will also replace var found into content of signature
|
||||
$signature = $user->signature;
|
||||
$substitutionarray=array_merge($substitutionarray, array(
|
||||
'__USER_SIGNATURE__' => (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '')
|
||||
)
|
||||
);
|
||||
// For backward compatibility
|
||||
if ($onlykey != 2)
|
||||
{
|
||||
$substitutionarray['__SIGNATURE__'] = (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '');
|
||||
}
|
||||
|
||||
$substitutionarray=array_merge($substitutionarray, array(
|
||||
'__USER_ID__' => (string) $user->id,
|
||||
'__USER_LOGIN__' => (string) $user->login,
|
||||
'__USER_LASTNAME__' => (string) $user->lastname,
|
||||
'__USER_FIRSTNAME__' => (string) $user->firstname,
|
||||
'__USER_FULLNAME__' => (string) $user->getFullName($outputlangs),
|
||||
'__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'),
|
||||
'__USER_REMOTE_IP__' => (string) $_SERVER['REMOTE_ADDR']
|
||||
)
|
||||
);
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$outputlangs->trans('TranslationOfKey');
|
||||
$substitutionarray['__[AnyConstantKey]__']=$outputlangs->trans('ValueOfConstant');
|
||||
$substitutionarray['__DOL_MAIN_URL_ROOT__']=DOL_MAIN_URL_ROOT;
|
||||
}
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
@ -5965,8 +5991,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
}
|
||||
|
||||
/**
|
||||
* Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newval).
|
||||
* Texts like __(TranslationKey|langfile)__ and __[ConstantKey]__ are also replaced.
|
||||
* Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newval),
|
||||
* and texts like __(TranslationKey|langfile)__ and __[ConstantKey]__ are also replaced.
|
||||
* Example of usage:
|
||||
* $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $thirdparty);
|
||||
* complete_substitutions_array($substitutionarray, $langs, $thirdparty);
|
||||
|
||||
@ -802,15 +802,15 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
}
|
||||
|
||||
// Personalized field {XXX-1} à {XXX-9}
|
||||
/*$maskperso=array();
|
||||
$maskperso=array();
|
||||
$maskpersonew=array();
|
||||
$tmpmask=$mask;
|
||||
while (preg_match('/\{([A-Z]+)\-([1-9])\}/i',$tmpmask,$regKey))
|
||||
while (preg_match('/\{([A-Z]+)\-([1-9])\}/',$tmpmask,$regKey))
|
||||
{
|
||||
$maskperso[$regKey[1]]='\{'.$regKey[1]+'\-'.$regKey[2].'\}';
|
||||
$maskpersonew[$regKey[1]]=str_pad('', '_', $regKey[2], STR_PAD_RIGHT);
|
||||
$tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew, $tmpmask);
|
||||
}*/
|
||||
$maskperso[$regKey[1]]='{'.$regKey[1].'-'.$regKey[2].'}';
|
||||
$maskpersonew[$regKey[1]]=str_pad('', $regKey[2], '_', STR_PAD_RIGHT);
|
||||
$tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask);
|
||||
}
|
||||
|
||||
if (strstr($mask,'user_extra_'))
|
||||
{
|
||||
@ -827,10 +827,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
$maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i',$maskrefclient,$maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{(t+)\}/i',$masktype_value,$maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{(u+)\}/i',$maskuser_value,$maskwithonlyymcode);
|
||||
/*foreach($maskperso as $key => $val)
|
||||
foreach($maskperso as $key => $val)
|
||||
{
|
||||
$maskwithonlyymcode=preg_replace('/'.$val.'/i', $maskpersonew[$key], $maskwithonlyymcode);
|
||||
}*/
|
||||
$maskwithonlyymcode=preg_replace('/'.preg_quote($val,'/').'/i', $maskpersonew[$key], $maskwithonlyymcode);
|
||||
}
|
||||
$maskwithnocode=$maskwithonlyymcode;
|
||||
$maskwithnocode=preg_replace('/\{yyyy\}/i','yyyy',$maskwithnocode);
|
||||
$maskwithnocode=preg_replace('/\{yy\}/i','yy',$maskwithnocode);
|
||||
@ -974,6 +974,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike);
|
||||
if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike);
|
||||
if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike);
|
||||
foreach($maskperso as $key => $val)
|
||||
{
|
||||
$maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike);
|
||||
}
|
||||
|
||||
// Get counter in database
|
||||
$counter=0;
|
||||
|
||||
@ -55,9 +55,11 @@ function member_prepare_head(Adherent $object)
|
||||
|
||||
if (! empty($user->rights->adherent->cotisation->lire))
|
||||
{
|
||||
$nbSubscription = is_array($object->subscriptions)?count($object->subscriptions):0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Subscriptions");
|
||||
$head[$h][2] = 'subscription';
|
||||
if ($nbSubscription > 0) $head[$h][1].= ' <span class="badge">'.$nbSubscription.'</span>';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
@ -190,7 +190,7 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($type == 'membersubscription')
|
||||
if ($type == 'member' || $type == 'membersubscription')
|
||||
{
|
||||
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':'');
|
||||
if ($mode == 1) $out.='member_ref';
|
||||
@ -210,7 +210,7 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo
|
||||
}
|
||||
|
||||
// For multicompany
|
||||
if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
|
||||
if (! empty($out) && ! empty($conf->multicompany->enabled)) $out.="&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
|
||||
|
||||
return $out;
|
||||
}
|
||||
@ -227,7 +227,7 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo
|
||||
* @param Object $object Object related to payment
|
||||
* @return void
|
||||
*/
|
||||
function htmlPrintOnlinePaymentFooter($fromcompany,$langs,$addformmessage=0,$suffix='',$object=null)
|
||||
function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
@ -236,12 +236,13 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
|
||||
$total_localtax1='total_localtax1';
|
||||
$total_localtax2='total_localtax2';
|
||||
|
||||
// CAS DES BIENS
|
||||
|
||||
// CAS DES BIENS/PRODUITS
|
||||
|
||||
// Define sql request
|
||||
$sql='';
|
||||
if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services
|
||||
if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|
||||
|| ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice'))
|
||||
{
|
||||
// Count on delivery date (use invoice date as delivery is unknown)
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
@ -273,44 +274,48 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
}
|
||||
else // Option vat on delivery for goods (payments) and payments for services
|
||||
else
|
||||
{
|
||||
// Count on delivery date (use invoice date as delivery is unknown)
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef as date_f, s.nom as company_name, s.rowid as company_id,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
$sql.= " 0 as payment_id, 0 as payment_amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
$sql.= " AND f.rowid = d.".$fk_facture;
|
||||
$sql.= " AND s.rowid = f.fk_soc";
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
//print $sql;
|
||||
// Count on payments date
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
$sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,";
|
||||
$sql.= " pa.datep as datep";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
$sql.= " AND f.rowid = d.".$fk_facture;
|
||||
$sql.= " AND s.rowid = f.fk_soc";
|
||||
$sql.= " AND pf.".$fk_facture2." = f.rowid";
|
||||
$sql.= " AND pa.rowid = pf.".$fk_payment;
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
||||
}
|
||||
|
||||
//print $sql.'<br>';
|
||||
@ -342,7 +347,8 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
}
|
||||
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
|
||||
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
|
||||
$list[$assoc['rate']]['datef'][] = $assoc['datef'];
|
||||
$list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']);
|
||||
$list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']);
|
||||
$list[$assoc['rate']]['company_name'][] = $assoc['company_name'];
|
||||
$list[$assoc['rate']]['company_id'][] = $assoc['company_id'];
|
||||
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
||||
@ -381,7 +387,8 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
|
||||
// Define sql request
|
||||
$sql='';
|
||||
if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services
|
||||
if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')
|
||||
|| ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice'))
|
||||
{
|
||||
// Count on invoice date
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
@ -414,9 +421,9 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND (d.product_type = 1"; // Limit to services
|
||||
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
}
|
||||
else // Option vat on delivery for goods (payments) and payments for services
|
||||
else
|
||||
{
|
||||
// Count on payments date
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
@ -424,7 +431,8 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
$sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount";
|
||||
$sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,";
|
||||
$sql.= " pa.datep as datep";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,";
|
||||
@ -451,7 +459,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND (d.product_type = 1"; // Limit to services
|
||||
$sql.= " AND (d.product_type = 1"; // Limit to services
|
||||
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
||||
}
|
||||
@ -487,7 +495,8 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
}
|
||||
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
|
||||
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
|
||||
$list[$assoc['rate']]['datef'][] = $assoc['datef'];
|
||||
$list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']);
|
||||
$list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']);
|
||||
$list[$assoc['rate']]['company_name'][] = $assoc['company_name'];
|
||||
$list[$assoc['rate']]['company_id'][] = $assoc['company_id'];
|
||||
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
||||
@ -550,7 +559,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND (d.product_type = -1";
|
||||
$sql.= " AND (d.product_type = -1";
|
||||
$sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY e.rowid";
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ function ticketsup_prepare_head($object)
|
||||
|
||||
// History
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticketsup/history.php?track_id=' . $object->track_id;
|
||||
$head[$h][1] = $langs->trans('TicketHistory');
|
||||
$head[$h][1] = $langs->trans('Events');
|
||||
$head[$h][2] = 'tabTicketLogs';
|
||||
$h++;
|
||||
|
||||
|
||||
@ -352,7 +352,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?&action=request', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5002__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'List', 1, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?select_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?search_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5004__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?&action=request', 'MenuConfCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 2, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5005__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/view_log.php?&action=request', 'MenuLogCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 3, __ENTITY__);
|
||||
-- HRM - Trips and expenses (old module)
|
||||
|
||||
@ -237,9 +237,16 @@ class MenuManager
|
||||
{
|
||||
$substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
|
||||
$substitarray['__USERID__'] = $user->id; // For backward compatibility
|
||||
$val2['url'] = make_substitutions($val2['url'], $substitarray);
|
||||
$val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__
|
||||
|
||||
$relurl2=dol_buildpath($val2['url'],1);
|
||||
if (! preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url']))
|
||||
{
|
||||
$relurl2=dol_buildpath($val2['url'],1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$relurl2=$val2['url'];
|
||||
}
|
||||
$canonurl2=preg_replace('/\?.*$/','',$val2['url']);
|
||||
//var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']);
|
||||
if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2='';
|
||||
|
||||
@ -1371,12 +1371,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
$newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm');
|
||||
$newmenu->add("/holiday/card.php?action=request", $langs->trans("New"), 1,$user->rights->holiday->write);
|
||||
$newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("List"), 1,$user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read);
|
||||
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read);
|
||||
$newmenu->add("/holiday/define_holiday.php?action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read);
|
||||
$newmenu->add("/holiday/month_report.php", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read_all);
|
||||
$newmenu->add("/holiday/view_log.php?action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday);
|
||||
}
|
||||
|
||||
|
||||
@ -185,6 +185,7 @@ class MenuManager
|
||||
$tmpleftmenu='all';
|
||||
$submenu=new Menu();
|
||||
print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home)
|
||||
// Note: $submenu contains menu entry with substitution not yet done
|
||||
//if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; }
|
||||
//if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; }
|
||||
$nexturl=dol_buildpath($submenu->liste[0]['url'],1);
|
||||
@ -247,9 +248,16 @@ class MenuManager
|
||||
{
|
||||
$substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
|
||||
$substitarray['__USERID__'] = $user->id; // For backward compatibility
|
||||
$val2['url'] = make_substitutions($val2['url'], $substitarray);
|
||||
$val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__
|
||||
|
||||
$relurl2=dol_buildpath($val2['url'],1);
|
||||
if (! preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url']))
|
||||
{
|
||||
$relurl2=dol_buildpath($val2['url'],1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$relurl2=$val2['url'];
|
||||
}
|
||||
$canonurl2=preg_replace('/\?.*$/','',$val2['url']);
|
||||
//var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']);
|
||||
if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2='';
|
||||
|
||||
@ -1209,12 +1209,10 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
|
||||
{
|
||||
global $conf,$langs,$hookmanager;
|
||||
|
||||
// Translations
|
||||
$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
|
||||
|
||||
$outputlangs->load("main");
|
||||
$outputlangs->load("bills");
|
||||
$outputlangs->load("propal");
|
||||
$outputlangs->load("companies");
|
||||
$outputlangs->load("orders");
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
|
||||
|
||||
@ -493,12 +493,11 @@ class pdf_strato extends ModelePDFContract
|
||||
function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$outputlangs->load("main");
|
||||
$outputlangs->load("dict");
|
||||
$outputlangs->load("companies");
|
||||
$outputlangs->load("contract");
|
||||
|
||||
// Translations
|
||||
$outputlangs->loadLangs(array("main", "dict", "contract", "companies"));
|
||||
|
||||
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
|
||||
|
||||
|
||||
@ -385,9 +385,9 @@ class pdf_merou extends ModelePdfExpedition
|
||||
{
|
||||
global $langs;
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("bills");
|
||||
|
||||
// Translations
|
||||
$langs->loadLangs(array("main", "bills"));
|
||||
|
||||
if (empty($hidetop))
|
||||
{
|
||||
|
||||
@ -38,10 +38,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
*/
|
||||
class pdf_standard extends ModeleExpenseReport
|
||||
{
|
||||
var $db;
|
||||
var $name;
|
||||
var $description;
|
||||
var $type;
|
||||
/**
|
||||
* @var DoliDb Database handler
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string model name
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var string model description (short text)
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* @var string document type
|
||||
*/
|
||||
public $type;
|
||||
|
||||
var $phpmin = array(4,3,0); // Minimum version of PHP required by module
|
||||
var $version = 'dolibarr';
|
||||
@ -512,10 +527,10 @@ class pdf_standard extends ModeleExpenseReport
|
||||
function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
|
||||
{
|
||||
global $conf,$langs,$hookmanager;
|
||||
|
||||
// Translations
|
||||
$outputlangs->loadLangs(array("main", "trips", "companies"));
|
||||
|
||||
$outputlangs->load("main");
|
||||
$outputlangs->load("trips");
|
||||
$outputlangs->load("companies");
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
/*
|
||||
|
||||
@ -42,24 +42,52 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
*/
|
||||
class pdf_crabe extends ModelePDFFactures
|
||||
{
|
||||
var $db;
|
||||
var $name;
|
||||
var $description;
|
||||
var $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template
|
||||
var $type;
|
||||
/**
|
||||
* @var DoliDb Database handler
|
||||
*/
|
||||
public $db;
|
||||
|
||||
var $phpmin = array(4,3,0); // Minimum version of PHP required by module
|
||||
var $version = 'dolibarr';
|
||||
/**
|
||||
* @var string model name
|
||||
*/
|
||||
public $name;
|
||||
|
||||
var $page_largeur;
|
||||
var $page_hauteur;
|
||||
var $format;
|
||||
var $marge_gauche;
|
||||
var $marge_droite;
|
||||
var $marge_haute;
|
||||
var $marge_basse;
|
||||
/**
|
||||
* @var string model description (short text)
|
||||
*/
|
||||
public $description;
|
||||
|
||||
var $emetteur; // Objet societe qui emet
|
||||
/**
|
||||
* @var int Save the name of generated file as the main doc when generating a doc with this template
|
||||
*/
|
||||
public $update_main_doc_field;
|
||||
|
||||
/**
|
||||
* @var string document type
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var array() Minimum version of PHP required by module.
|
||||
* e.g.: PHP ≥ 5.3 = array(5, 3)
|
||||
*/
|
||||
public $phpmin = array(5, 2);
|
||||
|
||||
/**
|
||||
* Dolibarr version of the loaded document
|
||||
* @public string
|
||||
*/
|
||||
public $version = 'dolibarr';
|
||||
|
||||
public $page_largeur;
|
||||
public $page_hauteur;
|
||||
public $format;
|
||||
public $marge_gauche;
|
||||
public $marge_droite;
|
||||
public $marge_haute;
|
||||
public $marge_basse;
|
||||
|
||||
public $emetteur; // Objet societe qui emet
|
||||
|
||||
/**
|
||||
* @var bool Situation invoice type
|
||||
@ -1514,12 +1542,10 @@ class pdf_crabe extends ModelePDFFactures
|
||||
*/
|
||||
function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$outputlangs->load("main");
|
||||
$outputlangs->load("bills");
|
||||
$outputlangs->load("propal");
|
||||
$outputlangs->load("companies");
|
||||
global $conf, $langs;
|
||||
|
||||
// Translations
|
||||
$outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
|
||||
@ -83,34 +83,7 @@ class modAdherent extends DolibarrModules
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_MAIL_RESIL";
|
||||
$this->const[$r][1] = "texte";
|
||||
$this->const[$r][2] = "Votre adhésion vient d'être résiliée.\r\nNous espérons vous revoir très bientôt";
|
||||
$this->const[$r][3] = "Mail de résiliation";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_MAIL_VALID";
|
||||
$this->const[$r][1] = "texte";
|
||||
$this->const[$r][2] = "Votre adhésion vient d'être validée. \r\nVoici le rappel de vos coordonnées (toute information erronée entrainera la non validation de votre inscription) :\r\n\r\n__INFOS__\r\n\r\n";
|
||||
$this->const[$r][3] = "Mail de validation";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_MAIL_VALID_SUBJECT";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "Votre adhésion a été validée";
|
||||
$this->const[$r][3] = "Sujet du mail de validation";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_MAIL_RESIL_SUBJECT";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "Résiliation de votre adhésion";
|
||||
$this->const[$r][3] = "Sujet du mail de résiliation";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
// For emails
|
||||
$this->const[$r][0] = "ADHERENT_MAIL_FROM";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "";
|
||||
@ -118,20 +91,35 @@ class modAdherent extends DolibarrModules
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_MAIL_COTIS";
|
||||
$this->const[$r][1] = "texte";
|
||||
$this->const[$r][2] = "Bonjour __FIRSTNAME__,\r\nCet email confirme que votre cotisation a été reçue\r\net enregistrée";
|
||||
$this->const[$r][3] = "Mail de validation de cotisation";
|
||||
$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER";
|
||||
$this->const[$r][1] = "emailtemplate:member";
|
||||
$this->const[$r][2] = "(SendingEmailOnAutoSubscription)";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_MAIL_COTIS_SUBJECT";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "Reçu de votre cotisation";
|
||||
$this->const[$r][3] = "Sujet du mail de validation de cotisation";
|
||||
$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION";
|
||||
$this->const[$r][1] = "emailtemplate:member";
|
||||
$this->const[$r][2] = "(SendingEmailOnNewSubscription)";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION";
|
||||
$this->const[$r][1] = "emailtemplate:member";
|
||||
$this->const[$r][2] = "(SendingReminderForExpiredSubscription)";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_CANCELATION";
|
||||
$this->const[$r][1] = "emailtemplate:member";
|
||||
$this->const[$r][2] = "(SendingEmailOnCancelation)";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
// For cards
|
||||
$this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "__YEAR__";
|
||||
@ -160,20 +148,6 @@ class modAdherent extends DolibarrModules
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_BANK_ACCOUNT";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "";
|
||||
$this->const[$r][3] = "ID du Compte banquaire utilise";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_BANK_CATEGORIE";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "";
|
||||
$this->const[$r][3] = "ID de la catégorie bancaire des cotisations";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_ETIQUETTE_TYPE";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "L7163";
|
||||
@ -188,6 +162,22 @@ class modAdherent extends DolibarrModules
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
// For subscriptions
|
||||
$this->const[$r][0] = "ADHERENT_BANK_ACCOUNT";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "";
|
||||
$this->const[$r][3] = "ID of bank account to use";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "ADHERENT_BANK_CATEGORIE";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "";
|
||||
$this->const[$r][3] = "ID of bank transaction category to use";
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
|
||||
// Boxes
|
||||
//-------
|
||||
$this->boxes = array(0=>array('file'=>'box_members.php','enabledbydefaulton'=>'Home'));
|
||||
@ -324,6 +314,12 @@ class modAdherent extends DolibarrModules
|
||||
$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
|
||||
$this->import_regex_array[$r]=array('a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
|
||||
$this->import_examplevalues_array[$r]=array('a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d'));
|
||||
|
||||
// Cronjobs
|
||||
$this->cronjobs = array(
|
||||
0=>array('label'=>'SendReminderForExpiredSubscription', 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', 'objectname'=>'Adherent', 'method'=>'sendReminderForExpiredSubscription', 'parameters'=>'10', 'comment'=>'sendReminderForExpiredSubscription', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, 'priority'=>50, 'status'=>0, 'test'=>true),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
340
htdocs/core/modules/modDav.class.php
Normal file
340
htdocs/core/modules/modDav.class.php
Normal file
@ -0,0 +1,340 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2018 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup dav Module dav
|
||||
* \brief dav module descriptor.
|
||||
*
|
||||
* \file htdocs/dav/core/modules/modDav.class.php
|
||||
* \ingroup dav
|
||||
* \brief Description and activation file for module dav
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
||||
|
||||
|
||||
// The class name should start with a lower case mod for Dolibarr to pick it up
|
||||
// so we ignore the Squiz.Classes.ValidClassName.NotCamelCaps rule.
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Description and activation class for module dav
|
||||
*/
|
||||
class modDav extends DolibarrModules
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
/**
|
||||
* Constructor. Define names, constants, directories, boxes, permissions
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
// Id for module (must be unique).
|
||||
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
|
||||
$this->numero = 50310; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
|
||||
// Key text used to identify module (for permissions, menus, etc...)
|
||||
$this->rights_class = 'dav';
|
||||
|
||||
// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
|
||||
// It is used to group modules by family in module setup page
|
||||
$this->family = "interface";
|
||||
// Module position in the family on 2 digits ('01', '10', '20', ...)
|
||||
$this->module_position = '90';
|
||||
// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
|
||||
//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
|
||||
|
||||
// Module label (no space allowed), used if translation string 'ModuledavName' not found (MyModue is name of module).
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
// Module description, used if translation string 'ModuledavDesc' not found (MyModue is name of module).
|
||||
$this->description = "davDescription";
|
||||
// Used only if file README.md and README-LL.md not found.
|
||||
$this->descriptionlong = "davDescription (Long)";
|
||||
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
|
||||
$this->version = 'experimental';
|
||||
// Key used in llx_const table to save module status enabled/disabled (where DAV is value of property name of module in uppercase)
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
// Name of image file used for this module.
|
||||
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
|
||||
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
|
||||
$this->picto='generic';
|
||||
|
||||
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
|
||||
// for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable)
|
||||
// for specific path of parts (eg: /dav/core/modules/barcode)
|
||||
// for specific css file (eg: /dav/css/dav.css.php)
|
||||
$this->module_parts = array(
|
||||
'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
|
||||
'login' => 0, // Set this to 1 if module has its own login method file (core/login)
|
||||
'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions)
|
||||
'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
|
||||
'theme' => 0, // Set this to 1 if module has its own theme directory (theme)
|
||||
'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
|
||||
'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
|
||||
'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
|
||||
'css' => array(''), // Set this to relative path of css file if module has its own css file
|
||||
'js' => array(''), // Set this to relative path of js file if module must load a js on all pages
|
||||
'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
|
||||
);
|
||||
|
||||
// Data directories to create when module is enabled.
|
||||
// Example: this->dirs = array("/dav/temp","/dav/subdir");
|
||||
$this->dirs = array("/dav/temp","/dav/public");
|
||||
|
||||
// Config pages. Put here list of php page, stored into dav/admin directory, to use to setup module.
|
||||
$this->config_page_url = array("dav.php");
|
||||
|
||||
// Dependencies
|
||||
$this->hidden = false; // A condition to hide module
|
||||
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
|
||||
$this->requiredby = array(); // List of module ids to disable if this one is disabled
|
||||
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
|
||||
$this->langfiles = array("admin");
|
||||
$this->phpmin = array(5,4); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(7,0); // Minimum version of Dolibarr required by module
|
||||
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
|
||||
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
|
||||
//$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice');
|
||||
//$this->always_enabled = true; // If true, can't be disabled
|
||||
|
||||
// Constants
|
||||
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
|
||||
// Example: $this->const=array(0=>array('DAV_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
|
||||
// 1=>array('DAV_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
|
||||
// );
|
||||
$this->const = array(
|
||||
1=>array('DAV_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
|
||||
);
|
||||
|
||||
|
||||
if (! isset($conf->dav) || ! isset($conf->dav->enabled))
|
||||
{
|
||||
$conf->dav=new stdClass();
|
||||
$conf->dav->enabled=0;
|
||||
}
|
||||
|
||||
|
||||
// Array to add new pages in new tabs
|
||||
$this->tabs = array();
|
||||
// Example:
|
||||
// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@dav:$user->rights->dav->read:/dav/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
|
||||
// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dav:$user->rights->othermodule->read:/dav/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
|
||||
// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
|
||||
//
|
||||
// Where objecttype can be
|
||||
// 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
|
||||
// 'contact' to add a tab in contact view
|
||||
// 'contract' to add a tab in contract view
|
||||
// 'group' to add a tab in group view
|
||||
// 'intervention' to add a tab in intervention view
|
||||
// 'invoice' to add a tab in customer invoice view
|
||||
// 'invoice_supplier' to add a tab in supplier invoice view
|
||||
// 'member' to add a tab in fundation member view
|
||||
// 'opensurveypoll' to add a tab in opensurvey poll view
|
||||
// 'order' to add a tab in customer order view
|
||||
// 'order_supplier' to add a tab in supplier order view
|
||||
// 'payment' to add a tab in payment view
|
||||
// 'payment_supplier' to add a tab in supplier payment view
|
||||
// 'product' to add a tab in product view
|
||||
// 'propal' to add a tab in propal view
|
||||
// 'project' to add a tab in project view
|
||||
// 'stock' to add a tab in stock view
|
||||
// 'thirdparty' to add a tab in third party view
|
||||
// 'user' to add a tab in user view
|
||||
|
||||
|
||||
// Dictionaries
|
||||
$this->dictionaries=array();
|
||||
/* Example:
|
||||
$this->dictionaries=array(
|
||||
'langs'=>'mylangfile@dav',
|
||||
'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor
|
||||
'tablib'=>array("Table1","Table2","Table3"), // Label of tables
|
||||
'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields
|
||||
'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order
|
||||
'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary)
|
||||
'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record)
|
||||
'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert)
|
||||
'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid')
|
||||
'tabcond'=>array($conf->dav->enabled,$conf->dav->enabled,$conf->dav->enabled) // Condition to show each dictionary
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
// Boxes/Widgets
|
||||
// Add here list of php file(s) stored in dav/core/boxes that contains class to show a widget.
|
||||
$this->boxes = array(
|
||||
//0=>array('file'=>'davwidget1.php@dav','note'=>'Widget provided by dav','enabledbydefaulton'=>'Home'),
|
||||
//1=>array('file'=>'davwidget2.php@dav','note'=>'Widget provided by dav'),
|
||||
//2=>array('file'=>'davwidget3.php@dav','note'=>'Widget provided by dav')
|
||||
);
|
||||
|
||||
|
||||
// Cronjobs (List of cron jobs entries to add when module is enabled)
|
||||
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
|
||||
$this->cronjobs = array(
|
||||
//0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/dav/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
|
||||
);
|
||||
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
|
||||
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
|
||||
// );
|
||||
|
||||
|
||||
// Permissions
|
||||
$this->rights = array(); // Permission array used by this module
|
||||
|
||||
/*
|
||||
$r=0;
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Read myobject of dav'; // Permission label
|
||||
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Create/Update myobject of dav'; // Permission label
|
||||
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Delete myobject of dav'; // Permission label
|
||||
$this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->dav->level1->level2)
|
||||
*/
|
||||
|
||||
// Main menu entries
|
||||
$this->menu = array(); // List of menus to add
|
||||
$r=0;
|
||||
|
||||
// Add here entries to declare new menus
|
||||
|
||||
/* BEGIN MODULEBUILDER TOPMENU */
|
||||
/*$this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||
'type'=>'top', // This is a Top menu entry
|
||||
'titre'=>'dav',
|
||||
'mainmenu'=>'dav',
|
||||
'leftmenu'=>'',
|
||||
'url'=>'/dav/davindex.php',
|
||||
'langs'=>'dav@dav', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>1000+$r,
|
||||
'enabled'=>'$conf->dav->enabled', // Define condition to show or hide menu entry. Use '$conf->dav->enabled' if entry must be visible if module is enabled.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->dav->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
*/
|
||||
/* END MODULEBUILDER TOPMENU */
|
||||
|
||||
/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
|
||||
$this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=dav', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'List MyObject',
|
||||
'mainmenu'=>'dav',
|
||||
'leftmenu'=>'dav_myobject_list',
|
||||
'url'=>'/dav/myobject_list.php',
|
||||
'langs'=>'dav@dav', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>1000+$r,
|
||||
'enabled'=>'$conf->dav->enabled', // Define condition to show or hide menu entry. Use '$conf->dav->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->dav->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=dav,fk_leftmenu=dav', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'New MyObject',
|
||||
'mainmenu'=>'dav',
|
||||
'leftmenu'=>'dav_myobject_new',
|
||||
'url'=>'/dav/myobject_page.php?action=create',
|
||||
'langs'=>'dav@dav', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>1000+$r,
|
||||
'enabled'=>'$conf->dav->enabled', // Define condition to show or hide menu entry. Use '$conf->dav->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->dav->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
END MODULEBUILDER LEFTMENU MYOBJECT */
|
||||
|
||||
|
||||
// Exports
|
||||
$r=1;
|
||||
|
||||
/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
|
||||
/*
|
||||
$langs->load("dav@dav");
|
||||
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
|
||||
$this->export_icon[$r]='myobject@dav';
|
||||
$keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject';
|
||||
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
|
||||
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject';
|
||||
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
|
||||
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
|
||||
$this->export_sql_end[$r] .=' WHERE 1 = 1';
|
||||
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
|
||||
$r++; */
|
||||
/* END MODULEBUILDER EXPORT MYOBJECT */
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when module is enabled.
|
||||
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||
* It also creates data directories
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
public function init($options='')
|
||||
{
|
||||
$this->_load_tables();
|
||||
|
||||
// Create extrafields
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
|
||||
//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
|
||||
//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
|
||||
//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
|
||||
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1 '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
|
||||
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
|
||||
|
||||
$sql = array();
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when module is disabled.
|
||||
* Remove from database constants, boxes and permissions from Dolibarr database.
|
||||
* Data directories are not deleted
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
public function remove($options = '')
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
return $this->_remove($sql, $options);
|
||||
}
|
||||
|
||||
}
|
||||
@ -228,7 +228,7 @@ class modResource extends DolibarrModules
|
||||
'langs'=> 'resource',
|
||||
'position'=> 101,
|
||||
'enabled'=> '1',
|
||||
'perms'=> '$user->rights->resource->read',
|
||||
'perms'=> '$user->rights->resource->write',
|
||||
'target'=> '',
|
||||
'user'=> 0
|
||||
);
|
||||
|
||||
@ -82,7 +82,7 @@ class modSyslog extends DolibarrModules
|
||||
|
||||
// Cronjobs
|
||||
$this->cronjobs = array(
|
||||
0=>array('label'=>'CompressSyslogs', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'compressSyslogs', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, 'priority'=>50, 'status'=>0, 'test'=>true),
|
||||
0=>array('label'=>'CompressSyslogs', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'compressSyslogs', 'parameters'=>'', 'comment'=>'Compress and archive log files', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, 'priority'=>50, 'status'=>0, 'test'=>true),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ class modTicketsup extends DolibarrModules
|
||||
// Set this to 1 if module has its own models directory
|
||||
'models' => 1,
|
||||
// Set this to relative path of css if module has its own css file
|
||||
'css' => '/ticketsup/css/ticketsup.css',
|
||||
//'css' => '',
|
||||
// Set here all hooks context managed by module
|
||||
'hooks' => array('admin')
|
||||
// Set here all workflow context managed by module
|
||||
|
||||
@ -108,6 +108,7 @@ if ($action == 'presend')
|
||||
// Create form for email
|
||||
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'));
|
||||
|
||||
@ -178,13 +179,7 @@ if ($action == 'presend')
|
||||
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
|
||||
$formmail->param['fileinit'] = array($file);
|
||||
|
||||
// Init list of files
|
||||
/*if (GETPOST('mode','alpha') == 'init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
|
||||
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
|
||||
}*/
|
||||
$formmail->withsubstit = 1;
|
||||
|
||||
// Show form
|
||||
print $formmail->get_form();
|
||||
|
||||
@ -86,8 +86,10 @@ $formfile->form_attach_new_file(
|
||||
$savingdocmask
|
||||
);
|
||||
|
||||
// Drag and drop for up and down allowed on product, thirdparty, ...
|
||||
// The drag and drop call the page core/ajax/row.php
|
||||
$disablemove=1;
|
||||
if (in_array($modulepart, array('product', 'produit', 'societe', 'user'))) $disablemove=0; // Drag and drop for up and down allowed on product, thirdparty, ...
|
||||
if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticketsup'))) $disablemove=0;
|
||||
|
||||
// List of document
|
||||
$formfile->list_of_documents(
|
||||
|
||||
@ -79,7 +79,7 @@ print '<div class="tagtable border table-border centpercent">'."\n";
|
||||
if ($module != 'product') {
|
||||
// No public note yet on products
|
||||
print '<div class="tagtr pair table-border-row">'."\n";
|
||||
print '<div class="tagtd tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
|
||||
print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
|
||||
print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0);
|
||||
print '</div>'."\n";
|
||||
print '<div class="tagtd table-val-border-col">'."\n";
|
||||
@ -89,7 +89,7 @@ if ($module != 'product') {
|
||||
}
|
||||
if (empty($user->societe_id)) {
|
||||
print '<div class="tagtr '.($module != 'product'?'impair':'pair').' table-border-row">'."\n";
|
||||
print '<div class="tagtd tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
|
||||
print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
|
||||
print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0);
|
||||
print '</div>'."\n";
|
||||
print '<div class="tagtd table-val-border-col">'."\n";
|
||||
|
||||
@ -58,6 +58,37 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
||||
$colspan = 3; // Col total ht + col edit + col delete
|
||||
if (in_array($object->element,array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
|
||||
//print $object->element;
|
||||
|
||||
// Lines for extrafield
|
||||
$objectline = null;
|
||||
if (!empty($extrafieldsline))
|
||||
{
|
||||
if ($this->table_element_line=='commandedet') {
|
||||
$objectline = new OrderLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='propaldet') {
|
||||
$objectline = new PropaleLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='supplier_proposaldet') {
|
||||
$objectline = new SupplierProposalLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet') {
|
||||
$objectline = new FactureLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='contratdet') {
|
||||
$objectline = new ContratLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='commande_fournisseurdet') {
|
||||
$objectline = new CommandeFournisseurLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facture_fourn_det') {
|
||||
$objectline = new SupplierInvoiceLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet_rec') {
|
||||
$objectline = new FactureLigneRec($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
|
||||
@ -384,41 +415,14 @@ else {
|
||||
<td class="nobottom linecoledit" align="center" valign="middle" colspan="<?php echo $colspan; ?>">
|
||||
<input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline" id="addline">
|
||||
</td>
|
||||
<?php
|
||||
// Lines for extrafield
|
||||
if (!empty($extrafieldsline))
|
||||
{
|
||||
if ($this->table_element_line=='commandedet') {
|
||||
$newline = new OrderLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='propaldet') {
|
||||
$newline = new PropaleLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='supplier_proposaldet') {
|
||||
$newline = new SupplierProposalLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet') {
|
||||
$newline = new FactureLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='contratdet') {
|
||||
$newline = new ContratLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='commande_fournisseurdet') {
|
||||
$newline = new CommandeFournisseurLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facture_fourn_det') {
|
||||
$newline = new SupplierInvoiceLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet_rec') {
|
||||
$newline = new FactureLigneRec($this->db);
|
||||
}
|
||||
if (is_object($newline)) {
|
||||
print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8));
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if (is_object($objectline)) {
|
||||
print $objectline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
|
||||
{
|
||||
|
||||
@ -240,16 +240,16 @@ $coldisplay=-1; // We remove first td
|
||||
<input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
|
||||
<input type="submit" class="button" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
|
||||
</td>
|
||||
|
||||
<?php
|
||||
//Line extrafield
|
||||
if (!empty($extrafieldsline))
|
||||
{
|
||||
print $line->showOptionals($extrafieldsline,'edit',array('style'=>$bc[$var],'colspan'=>$coldisplay));
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
//Line extrafield
|
||||
if (!empty($extrafieldsline))
|
||||
{
|
||||
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if (! empty($conf->service->enabled) && $line->product_type == 1 && $dateSelector) { ?>
|
||||
<tr id="service_duration_area" <?php echo $bc[$var]; ?>>
|
||||
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
|
||||
|
||||
@ -308,14 +308,14 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0;
|
||||
<td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
|
||||
<?php } ?>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
//Line extrafield
|
||||
if (!empty($extrafieldsline))
|
||||
{
|
||||
print $line->showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay));
|
||||
print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcdd[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
|
||||
}
|
||||
?>
|
||||
|
||||
</tr>
|
||||
|
||||
<!-- END PHP TEMPLATE objectline_view.tpl.php -->
|
||||
|
||||
@ -760,7 +760,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
$langs->load("projects");
|
||||
|
||||
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
|
||||
$object->actionmsg=$langs->transnoentities("ProjectModifieddInDolibarr",$object->ref);
|
||||
$object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
|
||||
$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
|
||||
|
||||
$object->sendtoid=0;
|
||||
|
||||
@ -93,7 +93,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
||||
|
||||
/**
|
||||
* Function called when a Dolibarrr business event is done.
|
||||
* All functions "run_trigger" are triggered if file is inside directory htdocs/core/triggers
|
||||
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers
|
||||
*
|
||||
* @param string $action Event action code
|
||||
* @param Object $object Object
|
||||
|
||||
@ -311,8 +311,8 @@ if ($action == 'execute')
|
||||
$arrayofmassactions = array(
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
'enable'=>$langs->trans("Enable"),
|
||||
'disable'=>$langs->trans("Disable"),
|
||||
'enable'=>$langs->trans("CronStatusActiveBtn"),
|
||||
'disable'=>$langs->trans("CronStatusInactiveBtn"),
|
||||
);
|
||||
if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=$langs->trans("Delete");
|
||||
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
|
||||
@ -527,16 +527,16 @@ if ($num > 0)
|
||||
}
|
||||
if ($user->rights->cron->execute)
|
||||
{
|
||||
if (!empty($obj->status)) print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$obj->rowid."&action=execute".(empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY).($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'),"play")."</a>";
|
||||
else print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('JobDisabled'))."\">".img_picto($langs->trans('JobDisabled'),"playdisabled")."</a>";
|
||||
if (!empty($obj->status)) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=execute'.(empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY).($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'),"play").'</a>';
|
||||
else print '<a href="#" class="cursordefault" title="'.dol_escape_htmltag($langs->trans('JobDisabled')).'">'.img_picto($langs->trans('JobDisabled'),"playdisabled").'</a>';
|
||||
} else {
|
||||
print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'),"playdisabled")."</a>";
|
||||
print '<a href="#" class="cursornotallowed" title="'.dol_escape_htmltag($langs->trans('NotEnoughPermissions')).'">'.img_picto($langs->trans('NotEnoughPermissions'),"playdisabled").'</a>';
|
||||
}
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
$selected=0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||
print ' <input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||
print ' <input id="cb'.$obj->rowid.'" class="flat checkforselect valignmiddle" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
294
htdocs/dav/dav.class.php
Normal file
294
htdocs/dav/dav.class.php
Normal file
@ -0,0 +1,294 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Destailleur Laurent <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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/dav/dav.class.php
|
||||
* \ingroup dav
|
||||
* \brief Server DAV
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Define Common function to access calendar items
|
||||
* And format it in vCalendar
|
||||
* */
|
||||
|
||||
class CdavLib
|
||||
{
|
||||
|
||||
private $db;
|
||||
|
||||
private $user;
|
||||
|
||||
private $langs;
|
||||
|
||||
function __construct($user, $db, $langs)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->db = $db;
|
||||
$this->langs = $langs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base sql request for calendar events
|
||||
*
|
||||
* @param int calendar user id
|
||||
* @param int actioncomm object id
|
||||
* @return string
|
||||
*/
|
||||
public function getSqlCalEvents($calid, $oid=false, $ouri=false)
|
||||
{
|
||||
// TODO : replace GROUP_CONCAT by
|
||||
$sql = 'SELECT
|
||||
a.tms AS lastupd,
|
||||
a.*,
|
||||
sp.firstname,
|
||||
sp.lastname,
|
||||
sp.address,
|
||||
sp.zip,
|
||||
sp.town,
|
||||
co.label country_label,
|
||||
sp.phone,
|
||||
sp.phone_perso,
|
||||
sp.phone_mobile,
|
||||
s.nom AS soc_nom,
|
||||
s.address soc_address,
|
||||
s.zip soc_zip,
|
||||
s.town soc_town,
|
||||
cos.label soc_country_label,
|
||||
s.phone soc_phone,
|
||||
ac.sourceuid,
|
||||
(SELECT GROUP_CONCAT(u.login) FROM '.MAIN_DB_PREFIX.'actioncomm_resources ar
|
||||
LEFT OUTER JOIN '.MAIN_DB_PREFIX.'user AS u ON (u.rowid=fk_element)
|
||||
WHERE ar.element_type=\'user\' AND fk_actioncomm=a.id) AS other_users
|
||||
FROM '.MAIN_DB_PREFIX.'actioncomm AS a';
|
||||
if (! $this->user->rights->societe->client->voir )//FIXME si 'voir' on voit plus de chose ?
|
||||
{
|
||||
$sql.=' LEFT OUTER JOIN '.MAIN_DB_PREFIX.'societe_commerciaux AS sc ON (a.fk_soc = sc.fk_soc AND sc.fk_user='.$this->user->id.')
|
||||
LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON (s.rowid = sc.fk_soc)
|
||||
LEFT JOIN '.MAIN_DB_PREFIX.'socpeople AS sp ON (sp.fk_soc = sc.fk_soc AND sp.rowid = a.fk_contact)
|
||||
LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_cdav AS ac ON (a.id = ac.fk_object)';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.=' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON (s.rowid = a.fk_soc)
|
||||
LEFT JOIN '.MAIN_DB_PREFIX.'socpeople AS sp ON (sp.rowid = a.fk_contact)
|
||||
LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_cdav AS ac ON (a.id = ac.fk_object)';
|
||||
}
|
||||
|
||||
$sql.=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON co.rowid = sp.fk_pays
|
||||
LEFT JOIN '.MAIN_DB_PREFIX.'c_country as cos ON cos.rowid = s.fk_pays
|
||||
WHERE a.id IN (SELECT ar.fk_actioncomm FROM '.MAIN_DB_PREFIX.'actioncomm_resources ar WHERE ar.element_type=\'user\' AND ar.fk_element='.intval($calid).')
|
||||
AND a.code IN (SELECT cac.code FROM '.MAIN_DB_PREFIX.'c_actioncomm cac WHERE cac.type<>\'systemauto\')
|
||||
AND a.entity IN ('.getEntity('societe', 1).')';
|
||||
if($oid!==false) {
|
||||
if($ouri===false)
|
||||
{
|
||||
$sql.=' AND a.id = '.intval($oid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.=' AND (a.id = '.intval($oid).' OR ac.uuidext = \''.$this->db->escape($ouri).'\')';
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert calendar row to VCalendar string
|
||||
*
|
||||
* @param row object
|
||||
* @return string
|
||||
*/
|
||||
public function toVCalendar($calid, $obj)
|
||||
{
|
||||
|
||||
$categ = [];
|
||||
/*if($obj->soc_client)
|
||||
{
|
||||
$nick[] = $obj->soc_code_client;
|
||||
$categ[] = $this->langs->transnoentitiesnoconv('Customer');
|
||||
}*/
|
||||
|
||||
$location=$obj->location;
|
||||
|
||||
// contact address
|
||||
if(empty($location) && !empty($obj->address))
|
||||
{
|
||||
$location = trim(str_replace(array("\r","\t","\n"),' ', $obj->address));
|
||||
$location = trim($location.', '.$obj->zip);
|
||||
$location = trim($location.' '.$obj->town);
|
||||
$location = trim($location.', '.$obj->country_label);
|
||||
}
|
||||
|
||||
// contact address
|
||||
if(empty($location) && !empty($obj->soc_address))
|
||||
{
|
||||
$location = trim(str_replace(array("\r","\t","\n"),' ', $obj->soc_address));
|
||||
$location = trim($location.', '.$obj->soc_zip);
|
||||
$location = trim($location.' '.$obj->soc_town);
|
||||
$location = trim($location.', '.$obj->soc_country_label);
|
||||
}
|
||||
|
||||
$address=explode("\n",$obj->address,2);
|
||||
foreach($address as $kAddr => $vAddr)
|
||||
{
|
||||
$address[$kAddr] = trim(str_replace(array("\r","\t"),' ', str_replace("\n",' | ', trim($vAddr))));
|
||||
}
|
||||
$address[]='';
|
||||
$address[]='';
|
||||
|
||||
if($obj->percent==-1 && trim($obj->datep)!='')
|
||||
$type='VEVENT';
|
||||
else
|
||||
$type='VTODO';
|
||||
|
||||
$timezone = date_default_timezone_get();
|
||||
|
||||
$caldata ="BEGIN:VCALENDAR\n";
|
||||
$caldata.="VERSION:2.0\n";
|
||||
$caldata.="METHOD:PUBLISH\n";
|
||||
$caldata.="PRODID:-//Dolibarr CDav//FR\n";
|
||||
$caldata.="BEGIN:".$type."\n";
|
||||
$caldata.="CREATED:".gmdate('Ymd\THis', strtotime($obj->datec))."Z\n";
|
||||
$caldata.="LAST-MODIFIED:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
|
||||
$caldata.="DTSTAMP:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
|
||||
if($obj->sourceuid=='')
|
||||
$caldata.="UID:".$obj->id.'-ev-'.$calid.'-cal-'.CDAV_URI_KEY."\n";
|
||||
else
|
||||
$caldata.="UID:".$obj->sourceuid."\n";
|
||||
$caldata.="SUMMARY:".$obj->label."\n";
|
||||
$caldata.="LOCATION:".$location."\n";
|
||||
$caldata.="PRIORITY:".$obj->priority."\n";
|
||||
if($obj->fulldayevent)
|
||||
{
|
||||
$caldata.="DTSTART;VALUE=DATE:".date('Ymd', strtotime($obj->datep))."\n";
|
||||
if($type=='VEVENT')
|
||||
{
|
||||
if(trim($obj->datep2)!='')
|
||||
$caldata.="DTEND;VALUE=DATE:".date('Ymd', strtotime($obj->datep2)+1)."\n";
|
||||
else
|
||||
$caldata.="DTEND;VALUE=DATE:".date('Ymd', strtotime($obj->datep)+(25*3600))."\n";
|
||||
}
|
||||
elseif(trim($obj->datep2)!='')
|
||||
$caldata.="DUE;VALUE=DATE:".date('Ymd', strtotime($obj->datep2)+1)."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$caldata.="DTSTART;TZID=".$timezone.":".strtr($obj->datep,array(" "=>"T", ":"=>"", "-"=>""))."\n";
|
||||
if($type=='VEVENT')
|
||||
{
|
||||
if(trim($obj->datep2)!='')
|
||||
$caldata.="DTEND;TZID=".$timezone.":".strtr($obj->datep2,array(" "=>"T", ":"=>"", "-"=>""))."\n";
|
||||
else
|
||||
$caldata.="DTEND;TZID=".$timezone.":".strtr($obj->datep,array(" "=>"T", ":"=>"", "-"=>""))."\n";
|
||||
}
|
||||
elseif(trim($obj->datep2)!='')
|
||||
$caldata.="DUE;TZID=".$timezone.":".strtr($obj->datep2,array(" "=>"T", ":"=>"", "-"=>""))."\n";
|
||||
}
|
||||
$caldata.="CLASS:PUBLIC\n";
|
||||
if($obj->transparency==1)
|
||||
$caldata.="TRANSP:TRANSPARENT\n";
|
||||
else
|
||||
$caldata.="TRANSP:OPAQUE\n";
|
||||
|
||||
if($type=='VEVENT')
|
||||
$caldata.="STATUS:CONFIRMED\n";
|
||||
elseif($obj->percent==0)
|
||||
$caldata.="STATUS:NEEDS-ACTION\n";
|
||||
elseif($obj->percent==100)
|
||||
$caldata.="STATUS:COMPLETED\n";
|
||||
else
|
||||
{
|
||||
$caldata.="STATUS:IN-PROCESS\n";
|
||||
$caldata.="PERCENT-COMPLETE:".$obj->percent."\n";
|
||||
}
|
||||
|
||||
$caldata.="DESCRIPTION:";
|
||||
$caldata.=strtr($obj->note, array("\n"=>"\\n", "\r"=>""));
|
||||
if(!empty($obj->soc_nom))
|
||||
$caldata.="\\n*DOLIBARR-SOC: ".$obj->soc_nom;
|
||||
if(!empty($obj->soc_phone))
|
||||
$caldata.="\\n*DOLIBARR-SOC-TEL: ".$obj->soc_phone;
|
||||
if(!empty($obj->firstname) || !empty($obj->lastname))
|
||||
$caldata.="\\n*DOLIBARR-CTC: ".trim($obj->firstname.' '.$obj->lastname);
|
||||
if(!empty($obj->phone) || !empty($obj->phone_perso) || !empty($obj->phone_mobile))
|
||||
$caldata.="\\n*DOLIBARR-CTC-TEL: ".trim($obj->phone.' '.$obj->phone_perso.' '.$obj->phone_mobile);
|
||||
if(strpos($obj->other_users,',')) // several
|
||||
$caldata.="\\n*DOLIBARR-USR: ".$obj->other_users;
|
||||
$caldata.="\n";
|
||||
|
||||
$caldata.="END:".$type."\n";
|
||||
$caldata.="END:VCALENDAR\n";
|
||||
|
||||
return $caldata;
|
||||
}
|
||||
|
||||
public function getFullCalendarObjects($calendarId, $bCalendarData)
|
||||
{
|
||||
|
||||
$calid = ($calendarId*1);
|
||||
$calevents = [] ;
|
||||
|
||||
if(! $this->user->rights->agenda->myactions->read)
|
||||
return $calevents;
|
||||
|
||||
if($calid!=$this->user->id && (!isset($this->user->rights->agenda->allactions->read) || !$this->user->rights->agenda->allactions->read))
|
||||
return $calevents;
|
||||
|
||||
$sql = $this->getSqlCalEvents($calid);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($result))
|
||||
{
|
||||
$calendardata = $this->toVCalendar($calid, $obj);
|
||||
|
||||
if($bCalendarData)
|
||||
{
|
||||
$calevents[] = [
|
||||
'calendardata' => $calendardata,
|
||||
'uri' => $obj->id.'-ev-'.CDAV_URI_KEY,
|
||||
'lastmodified' => strtotime($obj->lastupd),
|
||||
'etag' => '"'.md5($calendardata).'"',
|
||||
'calendarid' => $calendarId,
|
||||
'size' => strlen($calendardata),
|
||||
'component' => strpos($calendardata, 'BEGIN:VEVENT')>0 ? 'vevent' : 'vtodo',
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$calevents[] = [
|
||||
// 'calendardata' => $calendardata, not necessary because etag+size are present
|
||||
'uri' => $obj->id.'-ev-'.CDAV_URI_KEY,
|
||||
'lastmodified' => strtotime($obj->lastupd),
|
||||
'etag' => '"'.md5($calendardata).'"',
|
||||
'calendarid' => $calendarId,
|
||||
'size' => strlen($calendardata),
|
||||
'component' => strpos($calendardata, 'BEGIN:VEVENT')>0 ? 'vevent' : 'vtodo',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $calevents;
|
||||
}
|
||||
|
||||
}
|
||||
40
htdocs/dav/dav.lib.php
Normal file
40
htdocs/dav/dav.lib.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Destailleur Laurent <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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/dav/dav.lib.php
|
||||
* \ingroup dav
|
||||
* \brief Server DAV
|
||||
*/
|
||||
|
||||
// define CDAV_CONTACT_TAG if not
|
||||
if(!defined('CDAV_CONTACT_TAG'))
|
||||
{
|
||||
if(isset($conf->global->CDAV_CONTACT_TAG))
|
||||
define('CDAV_CONTACT_TAG', $conf->global->CDAV_CONTACT_TAG);
|
||||
else
|
||||
define('CDAV_CONTACT_TAG', '');
|
||||
}
|
||||
|
||||
// define CDAV_URI_KEY if not
|
||||
if(!defined('CDAV_URI_KEY'))
|
||||
{
|
||||
if(isset($conf->global->CDAV_URI_KEY))
|
||||
define('CDAV_URI_KEY', $conf->global->CDAV_URI_KEY);
|
||||
else
|
||||
define('CDAV_URI_KEY', substr(md5($_SERVER['HTTP_HOST']),0,8));
|
||||
}
|
||||
153
htdocs/dav/fileserver.php
Normal file
153
htdocs/dav/fileserver.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Destailleur Laurent <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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/dav/fileserver.php
|
||||
* \ingroup dav
|
||||
* \brief Server DAV
|
||||
*/
|
||||
|
||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
define("NOLOGIN",1); // This means this output page does not require to be logged.
|
||||
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
||||
|
||||
require ("../main.inc.php");
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/dav/dav.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
|
||||
|
||||
|
||||
$user = new User($db);
|
||||
if(isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']!='')
|
||||
{
|
||||
$user->fetch('',$_SERVER['PHP_AUTH_USER']);
|
||||
$user->getrights();
|
||||
}
|
||||
|
||||
$langs->loadLangs(array("main","other"));
|
||||
|
||||
|
||||
if(empty($conf->dav->enabled))
|
||||
accessforbidden();
|
||||
|
||||
|
||||
// settings
|
||||
$publicDir = $conf->dav->dir_output.'/public';
|
||||
$tmpDir = $conf->dav->dir_output.'/tmp';
|
||||
|
||||
// Authentication callback function
|
||||
$authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $password)
|
||||
{
|
||||
global $user;
|
||||
global $conf;
|
||||
global $dolibarr_main_authentication;
|
||||
|
||||
if (empty($user->login))
|
||||
return false;
|
||||
if ($user->socid > 0)
|
||||
return false;
|
||||
if ($user->login != $username)
|
||||
return false;
|
||||
|
||||
// Authentication mode
|
||||
if (empty($dolibarr_main_authentication))
|
||||
$dolibarr_main_authentication='http,dolibarr';
|
||||
$authmode = explode(',',$dolibarr_main_authentication);
|
||||
$entity = (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1));
|
||||
|
||||
if (checkLoginPassEntity($username,$password,$entity,$authmode) != $username)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
$authBackend->setRealm(constant('DOL_APPLICATION_TITLE'));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions and View
|
||||
*/
|
||||
|
||||
// Create the root node
|
||||
// Setting up the directory tree //
|
||||
$nodes = array();
|
||||
|
||||
// Enable directories and features according to DAV setup
|
||||
// / Public docs
|
||||
$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/public');
|
||||
|
||||
// Principals Backend
|
||||
//$principalBackend = new \Sabre\DAVACL\PrincipalBackend\Dolibarr($user,$db);
|
||||
// /principals
|
||||
//$nodes[] = new \Sabre\DAVACL\PrincipalCollection($principalBackend);
|
||||
// CardDav & CalDav Backend
|
||||
//$carddavBackend = new \Sabre\CardDAV\Backend\Dolibarr($user,$db,$langs);
|
||||
//$caldavBackend = new \Sabre\CalDAV\Backend\Dolibarr($user,$db,$langs, $cdavLib);
|
||||
// /addressbook
|
||||
//$nodes[] = new \Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend);
|
||||
// /calendars
|
||||
//$nodes[] = new \Sabre\CalDAV\CalendarRoot($principalBackend, $caldavBackend);
|
||||
|
||||
|
||||
// The rootnode needs in turn to be passed to the server class
|
||||
$server = new \Sabre\DAV\Server($nodes);
|
||||
|
||||
// If you want to run the SabreDAV server in a custom location (using mod_rewrite for instance)
|
||||
// You can override the baseUri here.
|
||||
$baseUri = DOL_URL_ROOT.'/dav/fileserver.php/';
|
||||
if (isset($baseUri)) $server->setBaseUri($baseUri);
|
||||
|
||||
// Add authentication function
|
||||
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
|
||||
|
||||
// Support for LOCK and UNLOCK
|
||||
$lockBackend = new \Sabre\DAV\Locks\Backend\File($tmpDir . '/.locksdb');
|
||||
$lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend);
|
||||
$server->addPlugin($lockPlugin);
|
||||
|
||||
// Support for html frontend
|
||||
$browser = new \Sabre\DAV\Browser\Plugin();
|
||||
$server->addPlugin($browser);
|
||||
|
||||
// Automatically guess (some) contenttypes, based on extension
|
||||
//$server->addPlugin(new \Sabre\DAV\Browser\GuessContentType());
|
||||
|
||||
//$server->addPlugin(new \Sabre\CardDAV\Plugin());
|
||||
//$server->addPlugin(new \Sabre\CalDAV\Plugin());
|
||||
//$server->addPlugin(new \Sabre\DAVACL\Plugin());
|
||||
|
||||
// Temporary file filter
|
||||
/*$tempFF = new \Sabre\DAV\TemporaryFileFilterPlugin($tmpDir);
|
||||
$server->addPlugin($tempFF);
|
||||
*/
|
||||
|
||||
// And off we go!
|
||||
$server->exec();
|
||||
|
||||
if (is_object($db)) $db->close();
|
||||
@ -705,7 +705,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).'<br>';
|
||||
$description.= $product_static->show_photos($conf->product->multidir_output[$product_static->entity],1,1,0,0,0,80);
|
||||
$description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
|
||||
print $form->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
|
||||
@ -1128,11 +1128,17 @@ if (empty($reshook))
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors');
|
||||
}
|
||||
// Warning if date out of range
|
||||
if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1)))
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings');
|
||||
}
|
||||
|
||||
// S'il y'a eu au moins une erreur
|
||||
if (! $error)
|
||||
{
|
||||
$type = 0; // TODO What if service ?
|
||||
$type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees
|
||||
|
||||
// Insert line
|
||||
$result = $object->addline($qty,$value_unit,$fk_c_type_fees,$vatrate,$date,$comments,$fk_projet,$fk_c_exp_tax_cat,$type);
|
||||
@ -1243,6 +1249,12 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors');
|
||||
$action='';
|
||||
}
|
||||
// Warning if date out of range
|
||||
if ($date < $object->date_debut || $date > ($object->date_fin + (24 * 3600 - 1)))
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
@ -1272,8 +1284,8 @@ if (empty($reshook))
|
||||
|
||||
$result = $object->recalculer($id);
|
||||
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
//header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
//exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -92,6 +92,7 @@ class PaymentExpenseReport extends CommonObject
|
||||
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
|
||||
if (! empty($this->fk_expensereport)) $this->chid = $this->fk_expensereport;
|
||||
|
||||
$totalamount = 0;
|
||||
foreach ($this->amounts as $key => $value) // How payment is dispatch
|
||||
@ -108,9 +109,6 @@ class PaymentExpenseReport extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
//Fix me fields
|
||||
$this->chid = $this->fk_expensereport;
|
||||
|
||||
if ($totalamount != 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,";
|
||||
@ -515,7 +513,7 @@ class PaymentExpenseReport extends CommonObject
|
||||
//Fix me field
|
||||
$this->total = $this->amount;
|
||||
$total = $this->total;
|
||||
|
||||
|
||||
if ($mode == 'payment_expensereport') $amount=$total;
|
||||
|
||||
// Insert payment into llx_bank
|
||||
|
||||
@ -31,7 +31,7 @@ $langs->load("bills");
|
||||
$langs->load("banks");
|
||||
$langs->load("trips");
|
||||
|
||||
$chid=GETPOST("id",'int');
|
||||
$id=GETPOST("id",'int');
|
||||
$ref=GETPOST('ref','alpha');
|
||||
$action=GETPOST('action','aZ09');
|
||||
$amounts = array();
|
||||
@ -55,13 +55,18 @@ if ($action == 'add_payment')
|
||||
|
||||
if ($_POST["cancel"])
|
||||
{
|
||||
$loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$chid;
|
||||
$loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id;
|
||||
header("Location: ".$loc);
|
||||
exit;
|
||||
}
|
||||
|
||||
$expensereport = new ExpenseReport($db);
|
||||
$expensereport->fetch($chid, $ref);
|
||||
$result = $expensereport->fetch($id, $ref);
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($expensereport->error, $expensereport->errors, 'errors');
|
||||
}
|
||||
|
||||
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
|
||||
@ -108,7 +113,7 @@ if ($action == 'add_payment')
|
||||
|
||||
// Create a line of payments
|
||||
$payment = new PaymentExpenseReport($db);
|
||||
$payment->chid = $chid;
|
||||
$payment->chid = $expensereport->id;
|
||||
$payment->datepaid = $datepaid;
|
||||
$payment->amounts = $amounts; // Tableau de montant
|
||||
$payment->total = $total;
|
||||
@ -121,7 +126,7 @@ if ($action == 'add_payment')
|
||||
$paymentid = $payment->create($user);
|
||||
if ($paymentid < 0)
|
||||
{
|
||||
$errmsg=$payment->error;
|
||||
setEventMessages($payment->error, $payment->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -131,7 +136,7 @@ if ($action == 'add_payment')
|
||||
$result=$payment->addPaymentToBank($user,'payment_expensereport','(ExpenseReportPayment)',$accountid,'','');
|
||||
if (! $result > 0)
|
||||
{
|
||||
$errmsg=$payment->error;
|
||||
setEventMessages($payment->error, $payment->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -141,7 +146,7 @@ if ($action == 'add_payment')
|
||||
if ($expensereport->total_ttc - $payment->amount == 0) {
|
||||
$result = $expensereport->set_paid($expensereport->id, $user);
|
||||
if (!$result > 0) {
|
||||
$errmsg = $payment->error;
|
||||
setEventMessages($payment->error, $payment->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -151,7 +156,7 @@ if ($action == 'add_payment')
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
$loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$chid;
|
||||
$loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$id;
|
||||
header('Location: '.$loc);
|
||||
exit;
|
||||
}
|
||||
@ -179,7 +184,7 @@ $form=new Form($db);
|
||||
if ($action == 'create' || empty($action))
|
||||
{
|
||||
$expensereport = new ExpenseReport($db);
|
||||
$expensereport->fetch($chid, $ref);
|
||||
$expensereport->fetch($id, $ref);
|
||||
|
||||
$total = $expensereport->total_ttc;
|
||||
|
||||
@ -187,8 +192,8 @@ if ($action == 'create' || empty($action))
|
||||
|
||||
print '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="id" value="'.$chid.'">';
|
||||
print '<input type="hidden" name="chid" value="'.$chid.'">';
|
||||
print '<input type="hidden" name="id" value="'.$expensereport->id.'">';
|
||||
print '<input type="hidden" name="chid" value="'.$expensereport->id.'">';
|
||||
print '<input type="hidden" name="action" value="add_payment">';
|
||||
|
||||
dol_fiche_head(null, '0', '', -1);
|
||||
@ -208,7 +213,7 @@ if ($action == 'create' || empty($action))
|
||||
|
||||
$sql = "SELECT sum(p.amount) as total";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e";
|
||||
$sql.= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$chid;
|
||||
$sql.= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$id;
|
||||
$sql.= ' AND e.entity IN ('.getEntity('expensereport').')';
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -124,7 +124,7 @@ class Interventions extends DolibarrApi
|
||||
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('fichinter').')';
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('intervention').')';
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
||||
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
||||
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
|
||||
@ -128,7 +128,7 @@ class Fichinter extends CommonObject
|
||||
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||
$clause = "AND";
|
||||
}
|
||||
$sql.= " ".$clause." fi.entity IN (".getEntity($this->element).")";
|
||||
$sql.= " ".$clause." fi.entity IN (".getEntity('intervention').")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -348,7 +348,10 @@ class Fichinter extends CommonObject
|
||||
$sql.= " f.tms as datem,";
|
||||
$sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
|
||||
if ($ref) $sql.= " WHERE f.ref='".$this->db->escape($ref)."'";
|
||||
if ($ref) {
|
||||
$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
|
||||
$sql.= " AND f.ref='".$this->db->escape($ref)."'";
|
||||
}
|
||||
else $sql.= " WHERE f.rowid=".$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
@ -782,7 +785,6 @@ class Fichinter extends CommonObject
|
||||
$sql.= " f.fk_user_valid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
|
||||
$sql.= " WHERE f.rowid = ".$id;
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -886,7 +888,6 @@ class Fichinter extends CommonObject
|
||||
// Delete object
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog("Fichinter::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -950,7 +951,6 @@ class Fichinter extends CommonObject
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
|
||||
$sql.= " SET datei = '".$this->db->idate($date_delivery)."'";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " AND fk_statut = 0";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
@ -984,7 +984,6 @@ class Fichinter extends CommonObject
|
||||
$sql.= " SET description = '".$this->db->escape($description)."',";
|
||||
$sql.= " fk_user_modif = ".$user->id;
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
@ -1017,7 +1016,6 @@ class Fichinter extends CommonObject
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
|
||||
$sql.= " SET fk_contrat = '".$contractid."'";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
@ -1395,7 +1393,7 @@ class FichinterLigne extends CommonObjectLine
|
||||
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$this->id=$this->rowid;
|
||||
$this->id=$this->id;
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -1457,7 +1455,7 @@ class FichinterLigne extends CommonObjectLine
|
||||
$sql.= ",date='".$this->db->idate($this->datei)."'";
|
||||
$sql.= ",duree=".$this->duration;
|
||||
$sql.= ",rang='".$this->db->escape($this->rang)."'";
|
||||
$sql.= " WHERE rowid = ".$this->rowid;
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog("FichinterLigne::update", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -1466,7 +1464,7 @@ class FichinterLigne extends CommonObjectLine
|
||||
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$this->id=$this->rowid;
|
||||
$this->id=$this->id;
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -1535,7 +1533,6 @@ class FichinterLigne extends CommonObjectLine
|
||||
$sql.= " , dateo = ".(! empty($obj->dateo)?"'".$this->db->idate($obj->dateo)."'":"null");
|
||||
$sql.= " , datee = ".(! empty($obj->datee)?"'".$this->db->idate($obj->datee)."'":"null");
|
||||
$sql.= " WHERE rowid = ".$this->fk_fichinter;
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -1574,10 +1571,10 @@ class FichinterLigne extends CommonObjectLine
|
||||
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
dol_syslog(get_class($this)."::deleteline lineid=".$this->rowid);
|
||||
dol_syslog(get_class($this)."::deleteline lineid=".$this->id);
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->rowid;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->id;
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
|
||||
@ -81,8 +81,8 @@ $sql = "SELECT count(f.rowid), f.fk_statut";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."fichinter 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('societe').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
if ($user->societe_id) $sql.=' AND f.fk_soc = '.$user->societe_id;
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
$sql.= " GROUP BY f.fk_statut";
|
||||
@ -180,8 +180,8 @@ if (! empty($conf->ficheinter->enabled))
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
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('intervention').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.fk_statut = 0";
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
@ -228,8 +228,8 @@ $sql.= " s.nom as name, s.rowid as socid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||
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('commande').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
//$sql.= " AND c.fk_statut > 2";
|
||||
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
@ -299,8 +299,8 @@ if (! empty($conf->ficheinter->enabled))
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."fichinter as f";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
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('intervention').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.fk_statut = 1";
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
@ -194,8 +194,8 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
|
||||
if (! $user->rights->societe->client->voir && empty($socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid ";
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity('intervention').")";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
if ($search_ref) {
|
||||
$sql .= natural_search('f.ref', $search_ref);
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ $cancelbutton = GETPOST('cancel','alpha');
|
||||
// Security check
|
||||
$id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
|
||||
if ($user->societe_id) $id=$user->societe_id;
|
||||
$result = restrictedArea($user, 'societe&fournisseur', $id, '&societe');
|
||||
$result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid');
|
||||
|
||||
$object = new Fournisseur($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
@ -50,6 +50,18 @@ $now=dol_now();
|
||||
|
||||
$langs->load("holiday");
|
||||
|
||||
$childids = $user->getAllChildIds(1);
|
||||
|
||||
$cancreate = 0;
|
||||
if (! empty($user->rights->holiday->write_all)) $cancreate=1;
|
||||
if (! empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate=1;
|
||||
|
||||
$candelete = 0;
|
||||
if (! empty($user->rights->holiday->delete)) $candelete=1;
|
||||
|
||||
$morefilter = 'AND employee = 1';
|
||||
if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = '';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -61,8 +73,7 @@ if ($action == 'create')
|
||||
$object = new Holiday($db);
|
||||
|
||||
// If no right to create a request
|
||||
$fuserid = GETPOST('fuserid','int');
|
||||
if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all)))
|
||||
if (! $cancreate)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans('CantCreateCP'), null, 'errors');
|
||||
@ -201,13 +212,11 @@ if ($action == 'update')
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id);
|
||||
|
||||
$canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all));
|
||||
|
||||
// If under validation
|
||||
if ($object->statut == 1)
|
||||
{
|
||||
// If this is the requestor or has read/write rights
|
||||
if ($canedit)
|
||||
if ($cancreate)
|
||||
{
|
||||
$valideur = $_POST['valideur'];
|
||||
$description = trim($_POST['description']);
|
||||
@ -252,21 +261,28 @@ if ($action == 'update')
|
||||
|
||||
// Update
|
||||
$verif = $object->update($user);
|
||||
if ($verif > 0)
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise we display the request form with the SQL error message
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=SQL_Create&msg='.$object->error);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($verif <= 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'warnings');
|
||||
$action='edit';
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorBadStatus"), null, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,19 +296,19 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights-
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id);
|
||||
|
||||
$canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all));
|
||||
|
||||
// If this is a rough draft, approved, canceled or refused
|
||||
if ($object->statut == 1 || $object->statut == 4 || $object->statut == 5)
|
||||
{
|
||||
// Si l'utilisateur à le droit de lire cette demande, il peut la supprimer
|
||||
if ($canedit)
|
||||
if ($candelete)
|
||||
{
|
||||
$result=$object->delete($user);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = $langs->trans('ErrorCantDeleteCP');
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorCantDeleteCP'), null, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,10 +330,8 @@ if ($action == 'confirm_send')
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id);
|
||||
|
||||
$canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all));
|
||||
|
||||
// Si brouillon et créateur
|
||||
if($object->statut == 1 && $canedit)
|
||||
if($object->statut == 1 && $cancreate)
|
||||
{
|
||||
$object->statut = 2;
|
||||
|
||||
@ -388,24 +402,26 @@ if ($action == 'confirm_send')
|
||||
|
||||
$trackid='leav'.$object->id;
|
||||
|
||||
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, null, null, null, '', '', 0, 0, '', '', $trackid);
|
||||
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid);
|
||||
|
||||
// Envoi du mail
|
||||
$result=$mail->sendfile();
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=mail&error_content='.$mail->error);
|
||||
exit;
|
||||
setEventMessages($mail->error, $mail->errors, 'warnings');
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sinon on affiche le formulaire de demande avec le message d'erreur SQL
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=SQL_Create&msg='.$object->error);
|
||||
exit;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -476,31 +492,33 @@ if ($action == 'confirm_valid')
|
||||
|
||||
$trackid='leav'.$object->id;
|
||||
|
||||
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, null, null, null, '', '', 0, 0, '', '', $trackid);
|
||||
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid);
|
||||
|
||||
// Envoi du mail
|
||||
$result=$mail->sendfile();
|
||||
|
||||
if (!$result) {
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=mail&error_content='.$mail->error);
|
||||
exit;
|
||||
if (!$result)
|
||||
{
|
||||
setEventMessages($mail->error, $mail->errors, 'warnings');
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
} else {
|
||||
// Sinon on affiche le formulaire de demande avec le message d'erreur SQL
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=SQL_Create&msg='.$object->error);
|
||||
exit;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($action == 'confirm_refuse')
|
||||
if ($action == 'confirm_refuse' && GETPOST('confirm','alpha') == 'yes')
|
||||
{
|
||||
if (! empty($_POST['detail_refuse']))
|
||||
if (! empty($_POST['detail_refuse']))
|
||||
{
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id);
|
||||
@ -508,10 +526,10 @@ if ($action == 'confirm_refuse')
|
||||
// Si statut en attente de validation et valideur = utilisateur
|
||||
if ($object->statut == 2 && $user->id == $object->fk_validator)
|
||||
{
|
||||
$object->date_refuse = date('Y-m-d H:i:s', time());
|
||||
$object->date_refuse = dol_print_date('dayhour', dol_now());
|
||||
$object->fk_user_refuse = $user->id;
|
||||
$object->statut = 5;
|
||||
$object->detail_refuse = $_POST['detail_refuse'];
|
||||
$object->detail_refuse = GETPOST('detail_refuse','alphanohtml');
|
||||
|
||||
$verif = $object->update($user);
|
||||
|
||||
@ -553,29 +571,31 @@ if ($action == 'confirm_refuse')
|
||||
|
||||
$trackid='leav'.$object->id;
|
||||
|
||||
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, null, null, null, '', '', 0, 0, '', '', $trackid);
|
||||
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid);
|
||||
|
||||
// Envoi du mail
|
||||
$result=$mail->sendfile();
|
||||
|
||||
if(!$result) {
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=mail&error_content='.$mail->error);
|
||||
exit;
|
||||
if (!$result)
|
||||
{
|
||||
setEventMessages($mail->error, $mail->errors, 'warnings');
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
} else {
|
||||
// Sinon on affiche le formulaire de demande avec le message d'erreur SQL
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=SQL_Create&msg='.$object->error);
|
||||
exit;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=NoMotifRefuse');
|
||||
exit;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DetailRefusCP")), null, 'errors');
|
||||
$action='refuse';
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,6 +603,8 @@ if ($action == 'confirm_refuse')
|
||||
// Si Validation de la demande
|
||||
if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id);
|
||||
|
||||
@ -592,7 +614,8 @@ if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes')
|
||||
$result = $object->update($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error = $langs->trans('ErrorBackToDraft');
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorBackToDraft').' '.$object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
@ -611,11 +634,13 @@ if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes')
|
||||
// Si Validation de la demande
|
||||
if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id);
|
||||
|
||||
// Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres
|
||||
if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all)))
|
||||
if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all)))
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
@ -642,7 +667,8 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes')
|
||||
|
||||
if ($result1 < 0 || $result2 < 0)
|
||||
{
|
||||
$error = $langs->trans('ErrorCantDeleteCP');
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorCantDeleteCP').' '.$object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -692,27 +718,22 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes')
|
||||
|
||||
$trackid='leav'.$object->id;
|
||||
|
||||
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, null, null, null, '', '', 0, 0, '', '', $trackid);
|
||||
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid);
|
||||
|
||||
// Envoi du mail
|
||||
$result=$mail->sendfile();
|
||||
|
||||
if(!$result)
|
||||
if (!$result)
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=mail&error_content='.$mail->error);
|
||||
exit;
|
||||
setEventMessages($mail->error, $mail->errors, 'warnings');
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sinon on affiche le formulaire de demande avec le message d'erreur SQL
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=SQL_Create&msg='.$object->error);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -849,10 +870,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
|
||||
print '<td>';
|
||||
if (empty($user->rights->holiday->write_all))
|
||||
{
|
||||
print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">';
|
||||
print $form->select_dolusers(($fuserid?$fuserid:$user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth300');
|
||||
//print '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">';
|
||||
}
|
||||
else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id, 'fuserid', 0, '', 0, '', '', 0, 0, 0, 'AND employee = 1');
|
||||
else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id, 'fuserid', 0, '', 0, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth300');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -957,8 +978,6 @@ else
|
||||
{
|
||||
$object->fetch($id);
|
||||
|
||||
$canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all));
|
||||
|
||||
$valideur = new User($db);
|
||||
$valideur->fetch($object->fk_validator);
|
||||
|
||||
@ -1005,50 +1024,10 @@ else
|
||||
}
|
||||
|
||||
// On vérifie si l'utilisateur à le droit de lire cette demande
|
||||
if ($canedit)
|
||||
if ($cancreate)
|
||||
{
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($user->rights->holiday->delete)
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleDeleteCP"),$langs->trans("ConfirmDeleteCP"),"confirm_delete", '', 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Si envoi en validation
|
||||
if ($action == 'sendToValidate' && $object->statut == 1)
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 1, 1);
|
||||
}
|
||||
|
||||
// Si validation de la demande
|
||||
if ($action == 'valid')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 1, 1);
|
||||
}
|
||||
|
||||
// Si refus de la demande
|
||||
if ($action == 'refuse')
|
||||
{
|
||||
$array_input = array(array('type'=>"text",'label'=> $langs->trans('DetailRefusCP'),'name'=>"detail_refuse",'size'=>"50",'value'=>""));
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), $langs->trans('ConfirmRefuseCP'), "confirm_refuse", $array_input, 1, 0);
|
||||
}
|
||||
|
||||
// Si annulation de la demande
|
||||
if ($action == 'cancel')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1);
|
||||
}
|
||||
|
||||
// Si back to draft
|
||||
if ($action == 'backtodraft')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleSetToDraft"),$langs->trans("ConfirmSetToDraft"),"confirm_draft", '', 1, 1);
|
||||
}
|
||||
|
||||
$head=holiday_prepare_head($object);
|
||||
|
||||
|
||||
if ($action == 'edit' && $object->statut == 1)
|
||||
{
|
||||
$edit = true;
|
||||
@ -1071,6 +1050,7 @@ else
|
||||
print '<table class="border centpercent">';
|
||||
print '<tbody>';
|
||||
|
||||
// User
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans("User").'</td>';
|
||||
print '<td>';
|
||||
@ -1133,6 +1113,7 @@ else
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Nb of days
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('NbUseDaysCP').'</td>';
|
||||
print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>';
|
||||
@ -1239,10 +1220,51 @@ else
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
// Confirmation messages
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($user->rights->holiday->delete)
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleDeleteCP"),$langs->trans("ConfirmDeleteCP"),"confirm_delete", '', 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Si envoi en validation
|
||||
if ($action == 'sendToValidate' && $object->statut == 1)
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 1, 1);
|
||||
}
|
||||
|
||||
// Si validation de la demande
|
||||
if ($action == 'valid')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 1, 1);
|
||||
}
|
||||
|
||||
// Si refus de la demande
|
||||
if ($action == 'refuse')
|
||||
{
|
||||
$array_input = array(array('type'=>"text",'label'=> $langs->trans('DetailRefusCP'),'name'=>"detail_refuse",'size'=>"50",'value'=>""));
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), $langs->trans('ConfirmRefuseCP'), "confirm_refuse", $array_input, 1, 0);
|
||||
}
|
||||
|
||||
// Si annulation de la demande
|
||||
if ($action == 'cancel')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1);
|
||||
}
|
||||
|
||||
// Si back to draft
|
||||
if ($action == 'backtodraft')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleSetToDraft"),$langs->trans("ConfirmSetToDraft"),"confirm_draft", '', 1, 1);
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'edit' && $object->statut == 1)
|
||||
{
|
||||
print '<div align="center">';
|
||||
if ($canedit && $object->statut == 1)
|
||||
if ($cancreate && $object->statut == 1)
|
||||
{
|
||||
print '<input type="submit" value="'.$langs->trans("Save").'" class="button">';
|
||||
}
|
||||
@ -1257,11 +1279,11 @@ else
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Boutons d'actions
|
||||
if ($canedit && $object->statut == 1)
|
||||
if ($cancreate && $object->statut == 1)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit" class="butAction">'.$langs->trans("EditCP").'</a>';
|
||||
}
|
||||
if ($canedit && $object->statut == 1)
|
||||
if ($cancreate && $object->statut == 1) // If draft
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=sendToValidate" class="butAction">'.$langs->trans("Validate").'</a>';
|
||||
}
|
||||
@ -1270,7 +1292,7 @@ else
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>';
|
||||
}
|
||||
|
||||
if ($object->statut == 2)
|
||||
if ($object->statut == 2) // If validated
|
||||
{
|
||||
if ($user->id == $object->fk_validator)
|
||||
{
|
||||
@ -1284,13 +1306,13 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
if (($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved
|
||||
if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved
|
||||
{
|
||||
if (($object->date_debut > dol_now()) || $user->admin) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
else print '<a href="#" class="butActionRefused" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
}
|
||||
|
||||
if ($canedit && $object->statut == 4)
|
||||
if ($cancreate && $object->statut == 4)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'</a>';
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class Holiday extends CommonObject
|
||||
var $date_fin=''; // Date end in PHP server TZ
|
||||
var $date_debut_gmt=''; // Date start in GMT
|
||||
var $date_fin_gmt=''; // Date end in GMT
|
||||
var $halfday='';
|
||||
var $halfday=''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning
|
||||
var $statut=''; // 1=draft, 2=validated, 3=approved
|
||||
var $fk_validator;
|
||||
var $date_valid='';
|
||||
@ -276,12 +276,12 @@ class Holiday extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* List holidays for a particular user
|
||||
* List holidays for a particular user or list of users
|
||||
*
|
||||
* @param int $user_id ID of user to list
|
||||
* @param string $order Sort order
|
||||
* @param string $filter SQL Filter
|
||||
* @return int -1 if KO, 1 if OK, 2 if no result
|
||||
* @param int|string $user_id ID of user to list, or comma separated list of IDs of users to list
|
||||
* @param string $order Sort order
|
||||
* @param string $filter SQL Filter
|
||||
* @return int -1 if KO, 1 if OK, 2 if no result
|
||||
*/
|
||||
function fetchByUser($user_id, $order='', $filter='')
|
||||
{
|
||||
@ -321,8 +321,8 @@ class Holiday extends CommonObject
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua";
|
||||
$sql.= " WHERE cp.entity IN (".getEntity('holiday').")";
|
||||
$sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau
|
||||
$sql.= " AND cp.fk_user = ".$user_id;
|
||||
$sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau
|
||||
$sql.= " AND cp.fk_user IN (".$user_id.")";
|
||||
|
||||
// Filtre de séléction
|
||||
if(!empty($filter)) {
|
||||
@ -553,7 +553,7 @@ class Holiday extends CommonObject
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
$sql.= " halfday = ".$this->halfday.",";
|
||||
$sql.= " halfday = ".$this->halfday.",";
|
||||
if(!empty($this->statut) && is_numeric($this->statut)) {
|
||||
$sql.= " statut = ".$this->statut.",";
|
||||
} else {
|
||||
@ -714,10 +714,10 @@ class Holiday extends CommonObject
|
||||
if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays
|
||||
if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays
|
||||
/*
|
||||
var_dump("--");
|
||||
var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']);
|
||||
var_dump("new: ".dol_print_date($dateStart,'dayhour').' '.dol_print_date($dateEnd,'dayhour').' '.$halfday);
|
||||
*/
|
||||
var_dump("--");
|
||||
var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']);
|
||||
var_dump("new: ".dol_print_date($dateStart,'dayhour').' '.dol_print_date($dateEnd,'dayhour').' '.$halfday);
|
||||
*/
|
||||
|
||||
if ($halfday == 0)
|
||||
{
|
||||
@ -797,7 +797,7 @@ class Holiday extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp";
|
||||
$sql.= " WHERE cp.entity IN (".getEntity('holiday').")";
|
||||
$sql.= " AND cp.fk_user = ".(int) $fk_user;
|
||||
$sql.= " AND date_debut <= '".$this->db->idate($timestamp)."' AND date_fin >= '".$this->db->idate($timestamp)."'";
|
||||
$sql.= " AND date_debut <= '".$this->db->idate($timestamp)."' AND date_fin >= '".$this->db->idate($timestamp)."'";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -837,7 +837,7 @@ class Holiday extends CommonObject
|
||||
}
|
||||
else dol_print_error($this->db);
|
||||
|
||||
return array('morning'=>$isavailablemorning, 'afternoon'=>$isavailableafternoon);
|
||||
return array('morning'=>$isavailablemorning, 'afternoon'=>$isavailableafternoon);
|
||||
}
|
||||
|
||||
|
||||
@ -860,10 +860,10 @@ class Holiday extends CommonObject
|
||||
|
||||
//if ($option != 'nolink')
|
||||
//{
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
|
||||
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
|
||||
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
|
||||
//}
|
||||
|
||||
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
@ -958,7 +958,7 @@ class Holiday extends CommonObject
|
||||
* Affiche un select HTML des statuts de congés payés
|
||||
*
|
||||
* @param int $selected Id of preselected status
|
||||
* @param string $select_statut Name of HTML select field
|
||||
* @param string $htmlname Name of HTML select field
|
||||
* @return string Show select of status
|
||||
*/
|
||||
function selectStatutCP($selected='', $htmlname='select_statut') {
|
||||
@ -1147,15 +1147,15 @@ class Holiday extends CommonObject
|
||||
}
|
||||
|
||||
if ($result)
|
||||
{
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1210,7 +1210,7 @@ class Holiday extends CommonObject
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1395,7 +1395,7 @@ class Holiday extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
// We want only list of vacation balance for user ids
|
||||
// We want only list of vacation balance for user ids
|
||||
$sql = "SELECT DISTINCT cpu.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE cpu.fk_user = u.user";
|
||||
@ -1427,7 +1427,7 @@ class Holiday extends CommonObject
|
||||
return $stringlist;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
// Erreur SQL
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
@ -1454,46 +1454,46 @@ class Holiday extends CommonObject
|
||||
else
|
||||
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
|
||||
|
||||
$sql.= " AND u.statut > 0";
|
||||
if ($filters) $sql.=$filters;
|
||||
$sql.= " AND u.statut > 0";
|
||||
if ($filters) $sql.=$filters;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
// Si pas d'erreur SQL
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$tab_result = $this->holiday;
|
||||
$num = $this->db->num_rows($resql);
|
||||
// Si pas d'erreur SQL
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$tab_result = $this->holiday;
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
// Boucles du listage des utilisateurs
|
||||
while($i < $num) {
|
||||
// Boucles du listage des utilisateurs
|
||||
while($i < $num) {
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$tab_result[$i]['rowid'] = $obj->rowid;
|
||||
$tab_result[$i]['name'] = $obj->lastname; // deprecated
|
||||
$tab_result[$i]['lastname'] = $obj->lastname;
|
||||
$tab_result[$i]['firstname'] = $obj->firstname;
|
||||
$tab_result[$i]['gender'] = $obj->gender;
|
||||
$tab_result[$i]['status'] = $obj->statut;
|
||||
$tab_result[$i]['employee'] = $obj->employee;
|
||||
$tab_result[$i]['photo'] = $obj->photo;
|
||||
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
||||
//$tab_result[$i]['type'] = $obj->type;
|
||||
//$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
||||
$tab_result[$i]['rowid'] = $obj->rowid;
|
||||
$tab_result[$i]['name'] = $obj->lastname; // deprecated
|
||||
$tab_result[$i]['lastname'] = $obj->lastname;
|
||||
$tab_result[$i]['firstname'] = $obj->firstname;
|
||||
$tab_result[$i]['gender'] = $obj->gender;
|
||||
$tab_result[$i]['status'] = $obj->statut;
|
||||
$tab_result[$i]['employee'] = $obj->employee;
|
||||
$tab_result[$i]['photo'] = $obj->photo;
|
||||
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
||||
//$tab_result[$i]['type'] = $obj->type;
|
||||
//$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
||||
|
||||
$i++;
|
||||
$i++;
|
||||
}
|
||||
// Retoune le tableau des utilisateurs
|
||||
return $tab_result;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Erreur SQL
|
||||
$this->errors[]="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
// Retoune le tableau des utilisateurs
|
||||
return $tab_result;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Erreur SQL
|
||||
$this->errors[]="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1637,32 +1637,32 @@ class Holiday extends CommonObject
|
||||
$sql.= ")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$error++; $this->errors[]="Error ".$this->db->lasterror();
|
||||
}
|
||||
if (! $resql)
|
||||
{
|
||||
$error++; $this->errors[]="Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs");
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs");
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::addLogCP ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::addLogCP ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->optRowid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1702,43 +1702,43 @@ class Holiday extends CommonObject
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
// Si pas d'erreur SQL
|
||||
if ($resql) {
|
||||
if ($resql) {
|
||||
|
||||
$i = 0;
|
||||
$tab_result = $this->logs;
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
$tab_result = $this->logs;
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
// Si pas d'enregistrement
|
||||
if(!$num) {
|
||||
// Si pas d'enregistrement
|
||||
if(!$num) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
// On liste les résultats et on les ajoutent dans le tableau
|
||||
while($i < $num) {
|
||||
// On liste les résultats et on les ajoutent dans le tableau
|
||||
while($i < $num) {
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$tab_result[$i]['rowid'] = $obj->rowid;
|
||||
$tab_result[$i]['date_action'] = $obj->date_action;
|
||||
$tab_result[$i]['fk_user_action'] = $obj->fk_user_action;
|
||||
$tab_result[$i]['fk_user_update'] = $obj->fk_user_update;
|
||||
$tab_result[$i]['type_action'] = $obj->type_action;
|
||||
$tab_result[$i]['prev_solde'] = $obj->prev_solde;
|
||||
$tab_result[$i]['new_solde'] = $obj->new_solde;
|
||||
$tab_result[$i]['fk_type'] = $obj->fk_type;
|
||||
$tab_result[$i]['rowid'] = $obj->rowid;
|
||||
$tab_result[$i]['date_action'] = $obj->date_action;
|
||||
$tab_result[$i]['fk_user_action'] = $obj->fk_user_action;
|
||||
$tab_result[$i]['fk_user_update'] = $obj->fk_user_update;
|
||||
$tab_result[$i]['type_action'] = $obj->type_action;
|
||||
$tab_result[$i]['prev_solde'] = $obj->prev_solde;
|
||||
$tab_result[$i]['new_solde'] = $obj->new_solde;
|
||||
$tab_result[$i]['fk_type'] = $obj->fk_type;
|
||||
|
||||
$i++;
|
||||
}
|
||||
// Retourne 1 et ajoute le tableau à la variable
|
||||
$this->logs = $tab_result;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Erreur SQL
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Retourne 1 et ajoute le tableau à la variable
|
||||
$this->logs = $tab_result;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Erreur SQL
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -220,6 +220,7 @@ if (!empty($search_name)) {
|
||||
$filters.=natural_search(array('u.firstname','u.lastname'), $search_name);
|
||||
}
|
||||
if ($search_supervisor > 0) $filters.=natural_search(array('u.fk_user'), $search_supervisor, 2);
|
||||
$filters.= ' AND employee = 1'; // Only employee users are visible
|
||||
|
||||
$listUsers = $holiday->fetchUsers(false, true, $filters);
|
||||
if (is_numeric($listUsers) && $listUsers < 0)
|
||||
@ -356,8 +357,10 @@ else
|
||||
print '<td>';
|
||||
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
|
||||
print '</td>';
|
||||
|
||||
// Button modify
|
||||
print '<td>';
|
||||
if (! empty($user->rights->holiday->define_holiday))
|
||||
if (! empty($user->rights->holiday->define_holiday)) // Allowed to set the balance of any user
|
||||
{
|
||||
print '<input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Update")).'" class="button"/>';
|
||||
}
|
||||
|
||||
@ -48,6 +48,18 @@ $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectl
|
||||
$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
|
||||
$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
|
||||
|
||||
$childids = $user->getAllChildIds(1);
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) // Protection if external user
|
||||
{
|
||||
//$socid = $user->societe_id;
|
||||
accessforbidden();
|
||||
}
|
||||
$result = restrictedArea($user, 'holiday', $id, '');
|
||||
$id = GETPOST('id','int');
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield','alpha');
|
||||
@ -71,7 +83,6 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search
|
||||
if (! $sortfield) $sortfield="cp.rowid";
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
|
||||
$id = GETPOST('id','int');
|
||||
|
||||
$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
|
||||
$search_ref = GETPOST('search_ref','alpha');
|
||||
@ -160,9 +171,6 @@ $holiday = new Holiday($db);
|
||||
$holidaystatic=new Holiday($db);
|
||||
$fuser = new User($db);
|
||||
|
||||
$childids = $user->getAllChildIds();
|
||||
$childids[]=$user->id;
|
||||
|
||||
// Update sold
|
||||
$result = $holiday->updateBalance();
|
||||
|
||||
@ -266,14 +274,16 @@ if ($id > 0)
|
||||
$search_employee = $user_id;
|
||||
}
|
||||
|
||||
// Récupération des congés payés de l'utilisateur ou de tous les users
|
||||
// Récupération des congés payés de l'utilisateur ou de tous les users de sa hierarchy
|
||||
// Load array $holiday->holiday
|
||||
if (empty($user->rights->holiday->read_all) || $id > 0)
|
||||
{
|
||||
$result = $holiday->fetchByUser($user_id,$order,$filter); // Load array $holiday->holiday
|
||||
if ($id > 0) $result = $holiday->fetchByUser($id, $order, $filter);
|
||||
else $result = $holiday->fetchByUser(join(',',$childids), $order, $filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $holiday->fetchAll($order,$filter); // Load array $holiday->holiday
|
||||
$result = $holiday->fetchAll($order, $filter);
|
||||
}
|
||||
// Si erreur SQL
|
||||
if ($result == '-1')
|
||||
@ -302,7 +312,7 @@ if ($search_year_create) $param.='&search_year_create='.urlencode($searc
|
||||
if ($search_search_day_start) $param.='&search_day_start='.urlencode($search_day_start);
|
||||
if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start);
|
||||
if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start);
|
||||
if ($day_end) $param.='&day_end='.urlencode($day_end);
|
||||
if ($search_day_end) $param.='&search_day_end='.urlencode($search_day_end);
|
||||
if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end);
|
||||
if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end);
|
||||
if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee);
|
||||
@ -401,23 +411,35 @@ print '<input class="flat" type="text" size="1" maxlength="2" name="search_month
|
||||
$formother->select_year($search_year_create,'search_year_create',1, $min_year, 0);
|
||||
print '</td>';
|
||||
|
||||
|
||||
$morefilter = 'AND employee = 1';
|
||||
if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = '';
|
||||
|
||||
// User
|
||||
if ($user->rights->holiday->write_all)
|
||||
$disabled=0;
|
||||
// If into the tab holiday of a user ($id is set in such a case)
|
||||
if ($id && ! GETPOSTISSET('search_employee'))
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="left">';
|
||||
print $form->select_dolusers($search_employee,"search_employee",1,"",0,'','',0,0,0,'',0,'','maxwidth200');
|
||||
$search_employee=$id;
|
||||
$disabled=1;
|
||||
}
|
||||
if (! empty($user->rights->holiday->read_all)) // Can see all
|
||||
{
|
||||
if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee','int');
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="left">';
|
||||
print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
//print '<td class="liste_titre"> </td>';
|
||||
if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee','int');
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="left">';
|
||||
print $form->select_dolusers($user->id,"search_employee",1,"",1,'','',0,0,0,'',0,'','maxwidth200');
|
||||
print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Approve
|
||||
if($user->rights->holiday->write_all)
|
||||
if ($user->rights->holiday->read_all)
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="left">';
|
||||
|
||||
@ -426,7 +448,7 @@ if($user->rights->holiday->write_all)
|
||||
$valideurobjects = $validator->listUsersForGroup($excludefilter);
|
||||
$valideurarray = array();
|
||||
foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id;
|
||||
print $form->select_dolusers($search_valideur,"search_valideur",1,"",0,$valideurarray,'', 0, 0, 0, '', 0, '', 'maxwidth200');
|
||||
print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
@ -481,7 +503,7 @@ print_liste_field_titre("DateCreateCP",$_SERVER["PHP_SELF"],"cp.date_create","",
|
||||
print_liste_field_titre("Employee",$_SERVER["PHP_SELF"],"cp.fk_user","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("ValidatorCP",$_SERVER["PHP_SELF"],"cp.fk_validator","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],'','',$pram,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("NbUseDaysCPShort",$_SERVER["PHP_SELF"],'','',$pram,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateDebCP",$_SERVER["PHP_SELF"],"cp.date_debut","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateFinCP",$_SERVER["PHP_SELF"],"cp.date_fin","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"cp.statut","",$param,'align="right"',$sortfield,$sortorder);
|
||||
@ -490,8 +512,16 @@ print "</tr>\n";
|
||||
|
||||
$listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon"));
|
||||
|
||||
|
||||
// If we ask a dedicated card and not allow to see it, we forc on user.
|
||||
if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids))
|
||||
{
|
||||
$langs->load("errors");
|
||||
print '<tr class="oddeven opacitymediuem"><td colspan="10">'.$langs->trans("NotEnoughPermissions").'</td></tr>';
|
||||
$result = 0;
|
||||
}
|
||||
// Lines
|
||||
if (! empty($holiday->holiday))
|
||||
elseif (! empty($holiday->holiday))
|
||||
{
|
||||
$userstatic = new User($db);
|
||||
$approbatorstatic = new User($db);
|
||||
@ -527,7 +557,7 @@ if (! empty($holiday->holiday))
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $holidaystatic->getNomUrl(1);
|
||||
print $holidaystatic->getNomUrl(1, 1);
|
||||
print '</td>';
|
||||
print '<td style="text-align: center;">'.dol_print_date($date,'day').'</td>';
|
||||
print '<td>'.$userstatic->getNomUrl(-1, 'leave').'</td>';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user