Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Juanjo Menent 2016-07-15 16:10:20 +02:00
commit 00496cd49e
56 changed files with 2540 additions and 782 deletions

View File

@ -287,10 +287,13 @@ script:
php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log
php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade390400-2.log php upgrade2.php 3.9.0 4.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade390400-2.log
php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log
php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log
php upgrade2.php 4.0.0 5.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade400500-2.log
php step5.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-3.log
cd - cd -
set +e set +e
echo echo
#cat $TRAVIS_BUILD_DIR/upgrade390400-2.log #cat $TRAVIS_BUILD_DIR/upgrade400500-2.log
#cat /tmp/dolibarr_install.log #cat /tmp/dolibarr_install.log
- | - |

View File

@ -23,6 +23,7 @@
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Balance of book keeping * \brief Balance of book keeping
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class // Class
@ -184,7 +185,7 @@ else {
print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
@ -213,6 +214,9 @@ else {
$total_debit = 0; $total_debit = 0;
$total_credit = 0; $total_credit = 0;
$sous_total_debit = 0;
$sous_total_credit = 0;
$displayed_account = "";
foreach ( $object->lines as $line ) { foreach ( $object->lines as $line ) {
$var = ! $var; $var = ! $var;
@ -220,11 +224,36 @@ else {
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account $description = $object->get_compte_desc($line->numero_compte); // Search description of the account
$root_account_description = $object->get_compte_racine($line->numero_compte);
if(empty($description)){ if(empty($description)){
$link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() .'</a>'; $link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() .'</a>';
} }
print '<tr'. $bc[$var].'>'; print '<tr'. $bc[$var].'>';
// Permet d'afficher le compte comptable
if ($root_account_description != $displayed_account) {
// Affiche un Sous-Total par compte comptable
if ($displayed_account != "") {
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td><td class="nowrap" align="right">'.price($sous_total_credit-$sous_total_debit).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
}
// Affiche le compte comptable en début de ligne
print "<tr>";
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'. $root_account_description .'</td>';
print '</tr>';
$displayed_account = $root_account_description;
$sous_total_debit = 0;
$sous_total_credit = 0;
}
// $object->get_compte_racine($line->numero_compte);
print '<td>' . length_accountg($line->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . $description . '</td>'; print '<td>' . $description . '</td>';
print '<td align="right">' . number_format($line->debit, 2, ',', ' ') . '</td>'; print '<td align="right">' . number_format($line->debit, 2, ',', ' ') . '</td>';
@ -233,21 +262,22 @@ else {
print '<td align="center">' . $link; print '<td align="center">' . $link;
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Comptabilise le sous-total
$sous_total_debit += $line->debit;
$sous_total_credit += $line->credit;
} }
print '<tr class="liste_total">'; print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td><td class="nowrap" align="right">'.price($sous_total_credit-$sous_total_debit).'</td>';
print '<td></td>'; print "<td>&nbsp;</td>\n";
print '<td></td>';
print '<td align="right">';
print price($total_debit);
print '</td>';
print '<td align="right">';
print price($total_credit);
print '</td>';
print '<td align="right">' . price($total_credit - $total_debit) . '</td>';
print '<td align="right"></td>';
print '</tr>'; print '</tr>';
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("AccountBalance") . ':</td><td class="nowrap" align="right">'.price($total_debit).'</td><td class="nowrap" align="right">'.price($total_credit).'</td><td class="nowrap" align="right">'.price($total_credit-$total_debit).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
print "</table>"; print "</table>";
print '</form>'; print '</form>';

View File

@ -258,7 +258,6 @@ if ($action == 'export_csv') {
*/ */
$title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); $title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end);
llxHeader('', $title_page); llxHeader('', $title_page);
// List // List
@ -315,6 +314,7 @@ print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<div class="tabsAction">' . "\n"; print '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="./listbyaccount.php">' . $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . strtolower($langs->trans("AccountAccounting")) . '</a></div>';
print '<div class="inline-block divButAction"><input type="submit" name="button_delmvt" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>'; print '<div class="inline-block divButAction"><input type="submit" name="button_delmvt" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>';
print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>'; print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>';

View File

@ -0,0 +1,348 @@
<?php
/*
* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* largely based on the great work of :
* - Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* - Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* - Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/bookkeeping/listbyaccount.php
* \ingroup Advanced accountancy
* \brief List operation of book keeping ordered by account number
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
// Langs
$langs->load("accountancy");
$page = GETPOST("page");
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
$action = GETPOST('action', 'alpha');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$search_accountancy_code = GETPOST("search_accountancy_code");
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
if ($search_accountancy_code_start == - 1) {
$search_accountancy_code_start = '';
}
$search_label_account = GETPOST('search_label_account', 'alpha');
$search_mvt_label = GETPOST('search_mvt_label', 'alpha');
$search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
if ($page == -1) { $page = 0 ; }
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$object = new BookKeeping($db);
$formventilation = new FormVentilation($db);
$formother = new FormOther($db);
$form = new Form($db);
if (empty($search_date_start)) {
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
}
if ($sortorder == "")
$sortorder = "ASC";
if ($sortfield == "")
$sortfield = "t.rowid";
$options = '';
$filter = array ();
if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$options .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$options .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
}
if (! empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$options .= '&amp;doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&amp;doc_dateday=' . GETPOST('doc_dateday', 'int') . '&amp;doc_dateyear=' . GETPOST('doc_dateyear', 'int');
}
if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
if (! empty($search_accountancy_code_start)) {
$filter['t.numero_compte'] = $search_accountancy_code_start;
$options .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start;
}
if (! empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account;
$options .= '&amp;search_label_account=' . $search_label_account;
}
if (! empty($search_mvt_label)) {
$filter['t.label_compte'] = $search_mvt_label;
$options .= '&amp;search_mvt_label=' . $search_mvt_label;
}
if (! empty($search_direction)) {
$filter['t.sens'] = $search_direction;
$options .= '&amp;search_direction=' . $search_direction;
}
if (! empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$options .= '&amp;search_ledger_code=' . $search_ledger_code;
}
}
/*
* Action
*/
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$search_doc_date = '';
$search_accountancy_code = '';
$search_accountancy_code_start = '';
$search_label_account = '';
$search_mvt_label = '';
$search_direction = '';
$search_ledger_code = '';
}
if ($action == 'delmouvconfirm') {
$mvt_num = GETPOST('mvt_num', 'int');
if (! empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
Header("Location: listbyaccount.php");
exit();
}
}
/*
* View
*/
$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end);
llxHeader('', $title_page);
// List
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter);
if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$nbtotalofrecords = $result;
if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1);
print $formconfirm;
}
if ($action == 'delbookkeepingyear') {
$form_question = array ();
$delyear = GETPOST('delyear');
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
}
$year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$form_question['delyear'] = array (
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
'values' => $year_array,
'default' => $delyear
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1);
print $formconfirm;
}
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'',0,'','',$limit);
// Reverse sort order
if ( preg_match('/^asc/i', $sortorder) )
$sortorder = "asc";
else
$sortorder = "desc";
print '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>';
print '</div>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("AccountAccounting") . '</td>';
print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder);
print '<td>' . $langs->trans("SuppliersInvoices") . ' / ' . $langs->trans("CustomersInvoices") . '</td>';
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="GET">';
print '<td width >' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . '</td>';
print '<td class="liste_titre">';
print $langs->trans('From') . ': ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
print '<br>';
print $langs->trans('to') . ': ';
print $form->select_date($search_date_end, 'date_end', 0, 0, 1);
print '</td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/></td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_account" value="' . $search_label_account . '"/></td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
print '<td align="right" colspan="2" class="liste_titre">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
print '</td>';
print '</tr>';
$var = True;
$total_debit = 0;
$total_credit = 0;
$sous_total_debit = 0;
$sous_total_credit = 0;
$displayed_account_number = "";
foreach ( $object->lines as $line ) {
$var = ! $var;
$total_debit += $line->debit;
$total_credit += $line->credit;
// Permet d'afficher le compte comptable
if (length_accountg($line->numero_compte) != $displayed_account_number) {
// Affiche un Sous-Total par compte comptable
if ($displayed_account_number != "") {
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("SubTotal").':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
}
// Affiche le compte comptable en début de ligne
print "<tr>";
print '<td colspan="7" style="font-weight:bold; border-bottom: 1pt solid black;">'.length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte).'</td>';
print '</tr>';
$displayed_account_number = length_accountg($line->numero_compte);
$sous_total_debit = 0;
$sous_total_credit = 0;
}
print '<tr'. $bc[$var].'>';
print '<td>&nbsp;</td>';
print '<td align="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
print '<td><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->doc_ref . '</a></td>';
// Affiche un lien vers la facture client/fournisseur
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
if ($line->doc_type == 'supplier_invoice')
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td><a href="/fourn/facture/list.php?search_ref_supplier=' . $doc_ref . '">' . $line->label_compte . '</a></td>' : '<td><a href="/fourn/facture/list.php?search_ref_supplier=' . $doc_ref . '">' . $line->label_compte . '</a><br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
elseif ($line->doc_type == 'customer_invoice')
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td><a href="/compta/facture/list.php?search_ref=' . $doc_ref . '">' . $line->label_compte . '</a></td>' : '<td><a href="/compta/facture/list.php?search_ref=' . $doc_ref . '">' . $line->label_compte . '</a><br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
else
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td>' . $line->label_compte . '</td>' : '<td>' . $line->label_compte . '<br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="center">' . $line->code_journal . '</td>';
print '<td align="center">';
print '<a href="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $options . '&page=' . $page . '">' . img_delete() . '</a>';
print '</td>';
print "</tr>\n";
// Comptabilise le sous-total
$sous_total_debit += $line->debit;
$sous_total_credit += $line->credit;
}
// Affiche un Sous-Total du dernier compte comptable affiché
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("SubTotal").':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
// Affiche le Total
print '<tr class="liste_total">';
print '<td align="right" colspan="4">'.$langs->trans("Total").':</td>';
print '<td align="right">';
print price($total_debit);
print '</td>';
print '<td align="right">';
print price($total_credit);
print '</td>';
print '<td colspan="2"></td>';
print '</tr>';
print "</table>";
print '</form>';
llxFooter();
$db->close();

View File

@ -109,8 +109,6 @@ class BookKeeping extends CommonObject
public function create(User $user, $notrigger = false) { public function create(User $user, $notrigger = false) {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
global $langs;
$error = 0; $error = 0;
// Clean parameters // Clean parameters
@ -168,11 +166,11 @@ class BookKeeping extends CommonObject
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "SELECT count(*) as nb"; $sql = "SELECT count(*) as nb";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; $sql .= " WHERE doc_type = '" . $this->doc_type . "'";
$sql .= " AND fk_docdet = " . $this->fk_docdet; $sql .= " AND fk_docdet = " . $this->fk_docdet;
$sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; $sql .= " AND numero_compte = '" . $this->numero_compte . "'";
dol_syslog(get_class($this) . ":: create ", LOG_DEBUG); dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -204,12 +202,11 @@ class BookKeeping extends CommonObject
$this->piece_num = $objnum->maxpiecenum; $this->piece_num = $objnum->maxpiecenum;
} }
} }
dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG);
if (empty($this->piece_num)) { if (empty($this->piece_num)) {
$this->piece_num = 1; $this->piece_num = 1;
} }
dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG);
$now = dol_now(); $now = dol_now();
if (empty($this->date_create)) { if (empty($this->date_create)) {
$this->date_create = $now; $this->date_create = $now;
@ -236,26 +233,26 @@ class BookKeeping extends CommonObject
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= "'" . $this->db->idate($this->doc_date) . "'"; $sql .= "'" . $this->doc_date . "'";
$sql .= ",'" . $this->db->escape($this->doc_type) . "'"; $sql .= ",'" . $this->doc_type . "'";
$sql .= ",'" . $this->db->escape($this->doc_ref) . "'"; $sql .= ",'" . $this->doc_ref . "'";
$sql .= "," . $this->fk_doc; $sql .= "," . $this->fk_doc;
$sql .= "," . $this->fk_docdet; $sql .= "," . $this->fk_docdet;
$sql .= ",'" . $this->db->escape($this->code_tiers) . "'"; $sql .= ",'" . $this->code_tiers . "'";
$sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; $sql .= ",'" . $this->numero_compte . "'";
$sql .= ",'" . $this->db->escape($this->label_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'";
$sql .= "," . $this->debit; $sql .= "," . $this->debit;
$sql .= "," . $this->credit; $sql .= "," . $this->credit;
$sql .= "," . $this->montant; $sql .= "," . $this->montant;
$sql .= ",'" . $this->db->escape($this->sens) . "'"; $sql .= ",'" . $this->sens . "'";
$sql .= ",'" . $this->fk_user_author . "'"; $sql .= ",'" . $this->fk_user_author . "'";
$sql .= ",'" . $this->date_create . "'"; $sql .= ",'" . $this->date_create . "'";
$sql .= ",'" . $this->db->escape($this->code_journal) . "'"; $sql .= ",'" . $this->code_journal . "'";
$sql .= "," . $this->piece_num; $sql .= "," . $this->piece_num;
$sql .= ")"; $sql .= ")";
dol_syslog(get_class($this) . ":: create", LOG_DEBUG); dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); $id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
@ -267,25 +264,25 @@ class BookKeeping extends CommonObject
$result = - 2; $result = - 2;
$error ++; $error ++;
$this->errors[] = 'Error Create Error ' . $result . ' lecture ID'; $this->errors[] = 'Error Create Error ' . $result . ' lecture ID';
dol_syslog(__METHOD__ . ' $result='.$result.' ' . implode(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
} }
} else { } else {
$result = - 1; $result = - 1;
$error ++; $error ++;
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' $result='.$result.' ' . implode(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
} }
} else { } else {
$result = - 3; $result = - 3;
$error ++; $error ++;
$this->errors[] = $langs->trans('BookeppingLineAlreayExists'); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' $result='.$result.' ' . implode(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
} }
} else { } else {
$result = - 5; $result = - 5;
$error ++; $error ++;
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' $result='.$result.' '. implode(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
} }
if (! $error) { if (! $error) {
@ -531,6 +528,118 @@ class BookKeeping extends CommonObject
} }
} }
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.doc_date,";
$sql .= " t.doc_type,";
$sql .= " t.doc_ref,";
$sql .= " t.fk_doc,";
$sql .= " t.fk_docdet,";
$sql .= " t.code_tiers,";
$sql .= " t.numero_compte,";
$sql .= " t.label_compte,";
$sql .= " t.debit,";
$sql .= " t.credit,";
$sql .= " t.montant,";
$sql .= " t.sens,";
$sql .= " t.fk_user_author,";
$sql .= " t.import_key,";
$sql .= " t.code_journal,";
$sql .= " t.piece_num";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter
$sqlwhere = array ();
if (count($filter) > 0) {
foreach ( $filter as $key => $value ) {
if ($key == 't.doc_date') {
$sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
$sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.code_tiers' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} elseif ($key == 't.label_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
}else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere);
}
// Affichage par compte comptable
$sql .= ' ORDER BY t.numero_compte ASC';
if (! empty($sortfield)) {
$sql .= ', ' . $sortfield . ' ' .$sortorder;
}
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array ();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
$line = new BookKeepingLine();
$line->id = $obj->rowid;
$line->doc_date = $this->db->jdate($obj->doc_date);
$line->doc_type = $obj->doc_type;
$line->doc_ref = $obj->doc_ref;
$line->fk_doc = $obj->fk_doc;
$line->fk_docdet = $obj->fk_docdet;
$line->code_tiers = $obj->code_tiers;
$line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte;
$line->debit = $obj->debit;
$line->credit = $obj->credit;
$line->montant = $obj->montant;
$line->sens = $obj->sens;
$line->fk_user_author = $obj->fk_user_author;
$line->import_key = $obj->import_key;
$line->code_journal = $obj->code_journal;
$line->piece_num = $obj->piece_num;
$this->lines[] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/** /**
* Load object in memory from the database * Load object in memory from the database
* *
@ -947,49 +1056,6 @@ class BookKeeping extends CommonObject
return 1; return 1;
} }
/**
* Delete bookkepping by year
*
* @param string $delyear year to delete
* @param string $deljournal journal to delete
* @return int Result
*/
function deleteByYearAndJournal($delyear,$deljournal) {
$this->db->begin();
$sqlwhere=array();
// first check if line not yet in bookkeeping
$sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
if (!empty($delyear)) {
$sqlwhere[] .= " YEAR(doc_date) = " . $delyear;
}
if (!empty($deljournal)) {
$sqlwhere[] .= " code_journal = '" . $this->db->escape($deljournal)."'";
}
if (count($sqlwhere)>0) {
$sql.=" WHERE ".implode(' AND ', $sqlwhere);
$resql = $this->db->query($sql);
if (! $resql) {
$this->errors[] = "Error " . $this->db->lasterror();
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1;
}
$this->db->commit();
}
return 1;
}
/** /**
* Delete bookkepping by piece number * Delete bookkepping by piece number
* *
@ -1248,6 +1314,122 @@ class BookKeeping extends CommonObject
} }
} }
/**
* Return list of accounts with label by chart of accounts
*
* @param string $selectid Preselected chart of accounts
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number
* @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
*
* @return string String with HTML select
*/
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
global $conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte";
$sql .= " AND aa.active = 1";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $pcgver;
$sql .= " ORDER BY account_number ASC";
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
return -1;
}
$out = ajax_combobox($htmlname, $event);
$options = array();
$selected = null;
while ($obj = $this->db->fetch_object($resql)) {
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
$label = dol_trunc($label, $trunclength);
$select_value_in = $obj->rowid;
$select_value_out = $obj->rowid;
if ($select_in == 1) {
$select_value_in = $obj->account_number;
}
if ($select_out == 1) {
$select_value_out = $obj->account_number;
}
// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
// Because same account_number can be share between different accounting_system and do have the same meaning
if (($selectid != '') && $selectid == $select_value_in) {
$selected = $select_value_out;
}
$options[$select_value_out] = $label;
}
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
$this->db->free($resql);
return $out;
}
/**
* Description of a root accounting account
*
* @param string $account Accounting account
* @return string
*/
function get_compte_racine($account = null)
{
global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT root.account_number, root.label as label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $pcgver;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid";
$sql .= " WHERE aa.account_number = '" . $account . "'";
$sql .= " AND parent.active = 1";
$sql .= " AND root.active = 1";
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$obj = '';
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
}
return $obj->label;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
return -1;
}
}
/** /**
* Description of accounting account * Description of accounting account
* *
@ -1258,7 +1440,6 @@ class BookKeeping extends CommonObject
{ {
global $conf; global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS; $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa ";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
@ -1266,7 +1447,6 @@ class BookKeeping extends CommonObject
$sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND asy.rowid = " . $pcgver;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -1284,7 +1464,6 @@ class BookKeeping extends CommonObject
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error " . $this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
return -1; return -1;
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,12 +17,12 @@
*/ */
$prefix = $conf->global->ACCOUNTING_EXPORT_PREFIX_SPEC; $prefix = $conf->global->ACCOUNTING_EXPORT_PREFIX_SPEC;
$format = $conf->global->ACCOUNTING_EXPORT_FORMAT; $format = $conf->global->ACCOUNTING_EXPORT_FORMAT;
$nodateexport = $conf->global->ACCOUNTING_EXPORT_NO_DATE_IN_FILENAME;
$date_export = dol_print_date($now, '%Y%m%d%H%M%S'); $date_export = dol_print_date($now, '%Y%m%d%H%M%S');
header('Content-Type: text/csv'); header('Content-Type: text/csv');
if ($prefix)
$filename = $prefix . "_" . "journal_" . $journal . $date_export . "." . $format; $filename = ($prefix?$prefix . "_":""). "journal_" . $journal . ($nodateexport?"":$date_export) . "." . $format;
else
$filename = "journal_" . $journal . $date_export . "." . $format;
header('Content-Disposition: attachment;filename=' . $filename); header('Content-Disposition: attachment;filename=' . $filename);

View File

@ -46,6 +46,8 @@ if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherent
if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$langs->load("companies"); $langs->load("companies");
$langs->load('banks');
if (! empty($conf->contrat->enabled)) $langs->load("contracts"); if (! empty($conf->contrat->enabled)) $langs->load("contracts");
if (! empty($conf->commande->enabled)) $langs->load("orders"); if (! empty($conf->commande->enabled)) $langs->load("orders");
if (! empty($conf->expedition->enabled)) $langs->load("sendings"); if (! empty($conf->expedition->enabled)) $langs->load("sendings");
@ -124,6 +126,14 @@ if (empty($reshook))
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
} }
// Bank account
if ($action == 'setbankaccount' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setBankAccount(GETPOST('fk_account','int'));
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
// customer preferred shipping method // customer preferred shipping method
if ($action == 'setshippingmethod' && $user->rights->societe->creer) if ($action == 'setshippingmethod' && $user->rights->societe->creer)
{ {
@ -337,6 +347,26 @@ if ($id > 0)
print "</td>"; print "</td>";
print '</tr>'; print '</tr>';
// Compte bancaire par défaut
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
if (($action != 'editbankaccount') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;socid='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editbankaccount')
{
$form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_account,'fk_account',1);
}
else
{
$form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_account,'none');
}
print "</td>";
print '</tr>';
// Relative discounts (Discounts-Drawbacks-Rebates) // Relative discounts (Discounts-Drawbacks-Rebates)
print '<tr><td class="nowrap">'; print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';

View File

@ -59,24 +59,24 @@ class Propal extends CommonObject
* ID of the client * ID of the client
* @var int * @var int
*/ */
var $socid; public $socid;
var $contactid; public $contactid;
var $author; public $author;
var $ref_client; public $ref_client;
/** /**
* Status of the quote * Status of the quote
* @var int * @var int
* @see Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED * @see Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED
*/ */
var $statut; public $statut;
/** /**
* @deprecated * @deprecated
* @see date_creation * @see date_creation
*/ */
var $datec; public $datec;
/** /**
* Creation date * Creation date
@ -88,7 +88,7 @@ class Propal extends CommonObject
* @deprecated * @deprecated
* @see date_validation * @see date_validation
*/ */
var $datev; public $datev;
/** /**
* Validation date * Validation date
@ -100,70 +100,72 @@ class Propal extends CommonObject
* Date of the quote * Date of the quote
* @var * @var
*/ */
var $date; public $date;
/** /**
* @deprecated * @deprecated
* @see date * @see date
*/ */
var $datep; public $datep;
var $date_livraison; public $date_livraison;
var $fin_validite; public $fin_validite;
var $user_author_id; public $user_author_id;
var $user_valid_id; public $user_valid_id;
var $user_close_id; public $user_close_id;
/** /**
* @deprecated * @deprecated
* @see total_ht * @see total_ht
*/ */
var $price; public $price;
/** /**
* @deprecated * @deprecated
* @see total_tva * @see total_tva
*/ */
var $tva; public $tva;
/** /**
* @deprecated * @deprecated
* @see total_ttc * @see total_ttc
*/ */
var $total; public $total;
var $cond_reglement_code; public $cond_reglement_code;
var $mode_reglement_code; public $mode_reglement_code;
var $remise; public $remise;
var $remise_percent; public $remise_percent;
var $remise_absolue; public $remise_absolue;
var $fk_address; public $fk_address;
var $address_type; public $address_type;
var $address; public $address;
var $availability_id; public $availability_id;
var $availability_code; public $availability_code;
var $demand_reason_id; public $demand_reason_id;
var $demand_reason_code; public $demand_reason_code;
var $products=array(); public $products=array();
var $extraparams=array(); public $extraparams=array();
/** /**
* @var PropaleLigne[] * @var PropaleLigne[]
*/ */
var $lines = array(); public $lines = array();
var $line; public $line;
var $labelstatut=array(); public $labelstatut=array();
var $labelstatut_short=array(); public $labelstatut_short=array();
var $specimen; public $specimen;
// Multicurrency // Multicurrency
var $fk_multicurrency; public $fk_multicurrency;
var $multicurrency_code; public $multicurrency_code;
var $multicurrency_tx; public $multicurrency_tx;
var $multicurrency_total_ht; public $multicurrency_total_ht;
var $multicurrency_total_tva; public $multicurrency_total_tva;
var $multicurrency_total_ttc; public $multicurrency_total_ttc;
public $oldcopy;
/** /**
* Draft status * Draft status
@ -1612,9 +1614,10 @@ class Propal extends CommonObject
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param int $date Date * @param int $date Date
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_date($user, $date) function set_date($user, $date, $notrigger=0)
{ {
if (empty($date)) if (empty($date))
{ {
@ -1625,20 +1628,50 @@ class Propal extends CommonObject
if (! empty($user->rights->propal->creer)) if (! empty($user->rights->propal->creer))
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
dol_syslog(get_class($this)."::set_date", LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
if ($this->db->query($sql) ) $resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->date = $date; $this->date = $date;
$this->datep = $date; // deprecated $this->datep = $date; // deprecated
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->lasterror(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -1648,23 +1681,57 @@ class Propal extends CommonObject
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param int $date_fin_validite End of validity date * @param int $date_fin_validite End of validity date
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_echeance($user, $date_fin_validite) function set_echeance($user, $date_fin_validite, $notrigger=0)
{ {
if (! empty($user->rights->propal->creer)) if (! empty($user->rights->propal->creer))
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null'); $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null');
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
if ($this->db->query($sql) )
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->fin_validite = $date_fin_validite; $this->fin_validite = $date_fin_validite;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -1674,26 +1741,57 @@ class Propal extends CommonObject
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param int $date_livraison Delivery date * @param int $date_livraison Delivery date
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function set_date_livraison($user, $date_livraison) function set_date_livraison($user, $date_livraison, $notrigger=0)
{ {
if (! empty($user->rights->propal->creer)) if (! empty($user->rights->propal->creer))
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal "; $sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null'); $sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null');
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql)) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->date_livraison = $date_livraison; $this->date_livraison = $date_livraison;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
dol_syslog(get_class($this)."::set_date_livraison Erreur SQL"); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -1703,26 +1801,57 @@ class Propal extends CommonObject
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param int $id Availability id * @param int $id Availability id
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_availability($user, $id) function set_availability($user, $id, $notrigger=0)
{ {
if (! empty($user->rights->propal->creer)) if (! empty($user->rights->propal->creer))
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal "; $sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET fk_availability = '".$id."'"; $sql.= " SET fk_availability = '".$id."'";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql)) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->fk_availability = $id; $this->fk_availability = $id;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
dol_syslog(get_class($this)."::set_availability Erreur SQL"); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -1732,26 +1861,59 @@ class Propal extends CommonObject
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param int $id Input reason id * @param int $id Input reason id
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_demand_reason($user, $id) function set_demand_reason($user, $id, $notrigger=0)
{ {
if (! empty($user->rights->propal->creer)) if (! empty($user->rights->propal->creer))
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal "; $sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET fk_input_reason = '".$id."'"; $sql.= " SET fk_input_reason = '".$id."'";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql)) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->fk_input_reason = $id; $this->fk_input_reason = $id;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
dol_syslog(get_class($this)."::set_demand_reason Erreur SQL"); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -1761,26 +1923,56 @@ class Propal extends CommonObject
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param string $ref_client Customer reference * @param string $ref_client Customer reference
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function set_ref_client($user, $ref_client) function set_ref_client($user, $ref_client, $notrigger=0)
{ {
if (! empty($user->rights->propal->creer)) if (! empty($user->rights->propal->creer))
{ {
dol_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); $error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\'');
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql) )
dol_syslog(__METHOD__.' $this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->ref_client = $ref_client; $this->ref_client = $ref_client;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
dol_syslog('Propale::set_ref_client Erreur '.$this->error.' - '.$sql); {
return -2; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
else else
@ -1794,9 +1986,10 @@ class Propal extends CommonObject
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param double $remise Amount discount * @param double $remise Amount discount
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function set_remise_percent($user, $remise) function set_remise_percent($user, $remise, $notrigger=0)
{ {
$remise=trim($remise)?trim($remise):0; $remise=trim($remise)?trim($remise):0;
@ -1804,19 +1997,50 @@ class Propal extends CommonObject
{ {
$remise = price2num($remise); $remise = price2num($remise);
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise; $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
if ($this->db->query($sql) ) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_percent = $remise; $this->remise_percent = $remise;
$this->update_price(1); $this->update_price(1);
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -1827,9 +2051,10 @@ class Propal extends CommonObject
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param double $remise Amount discount * @param double $remise Amount discount
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function set_remise_absolue($user, $remise) function set_remise_absolue($user, $remise, $notrigger=0)
{ {
$remise=trim($remise)?trim($remise):0; $remise=trim($remise)?trim($remise):0;
@ -1837,20 +2062,51 @@ class Propal extends CommonObject
{ {
$remise = price2num($remise); $remise = price2num($remise);
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal "; $sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET remise_absolue = ".$remise; $sql.= " SET remise_absolue = ".$remise;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
if ($this->db->query($sql) ) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_absolue = $remise; $this->remise_absolue = $remise;
$this->update_price(1); $this->update_price(1);
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -1924,9 +2180,10 @@ class Propal extends CommonObject
* @param User $user Object user that close * @param User $user Object user that close
* @param int $statut Statut * @param int $statut Statut
* @param string $note Comment * @param string $note Comment
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function cloture($user, $statut, $note) function cloture($user, $statut, $note, $notrigger=0)
{ {
global $langs,$conf; global $langs,$conf;
@ -1981,15 +2238,24 @@ class Propal extends CommonObject
$this->generateDocument($modelpdf, $outputlangs); $this->generateDocument($modelpdf, $outputlangs);
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut = $statut;
$this->date_cloture = $now;
$this->note_private = $note;
}
if (! $notrigger && empty($error))
{
// Call trigger // Call trigger
$result=$this->call_trigger($trigger_name,$user); $result=$this->call_trigger($trigger_name,$user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
}
if ( ! $error ) if ( ! $error )
{ {
$this->statut = $statut;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2010,20 +2276,55 @@ class Propal extends CommonObject
/** /**
* Class invoiced the Propal * Class invoiced the Propal
* *
* @param User $user Object user
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
*/ */
function classifyBilled() function classifyBilled(User $user, $notrigger=0)
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = '.self::STATUS_BILLED; $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = '.self::STATUS_BILLED;
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT.' ;'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT.' ;';
if ($this->db->query($sql) )
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut=self::STATUS_BILLED; $this->statut=self::STATUS_BILLED;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
dol_print_error($this->db); foreach($this->errors as $errmsg)
{
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
@ -2046,22 +2347,55 @@ class Propal extends CommonObject
* Set draft status * Set draft status
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_draft($user) function set_draft($user, $notrigger=0)
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = ".self::STATUS_DRAFT; $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = ".self::STATUS_DRAFT;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql)) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut = self::STATUS_DRAFT; $this->statut = self::STATUS_DRAFT;
$this->brouillon = 1; $this->brouillon = 1;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
return -1; foreach($this->errors as $errmsg)
{
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
@ -2364,32 +2698,65 @@ class Propal extends CommonObject
* Change the delivery time * Change the delivery time
* *
* @param int $availability_id Id of new delivery time * @param int $availability_id Id of new delivery time
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function availability($availability_id) function availability($availability_id, $notrigger=0)
{ {
dol_syslog('Propale::availability('.$availability_id.')');
if ($this->statut >= self::STATUS_DRAFT) if ($this->statut >= self::STATUS_DRAFT)
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql .= ' SET fk_availability = '.$availability_id; $sql .= ' SET fk_availability = '.$availability_id;
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->availability_id = $availability_id; $this->availability_id = $availability_id;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
dol_syslog('Propale::availability Erreur '.$sql.' - '.$this->db->error()); foreach($this->errors as $errmsg)
$this->error=$this->db->error(); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
else else
{ {
dol_syslog('Propale::availability, etat propale incompatible'); $error_str='Propal status do not meet requirement '.$this->statut;
$this->error='Etat propale incompatible '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error=$error_str;
$this->errors[]= $this->error;
return -2; return -2;
} }
} }
@ -2398,32 +2765,65 @@ class Propal extends CommonObject
* Change source demand * Change source demand
* *
* @param int $demand_reason_id Id of new source demand * @param int $demand_reason_id Id of new source demand
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int >0 si ok, <0 si ko * @return int >0 si ok, <0 si ko
*/ */
function demand_reason($demand_reason_id) function demand_reason($demand_reason_id, $notrigger=0)
{ {
dol_syslog('Propale::demand_reason('.$demand_reason_id.')');
if ($this->statut >= self::STATUS_DRAFT) if ($this->statut >= self::STATUS_DRAFT)
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql .= ' SET fk_input_reason = '.$demand_reason_id; $sql .= ' SET fk_input_reason = '.$demand_reason_id;
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
dol_syslog(__METHOD__.' demand_reason('.$demand_reason_id.')', LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->demand_reason_id = $demand_reason_id; $this->demand_reason_id = $demand_reason_id;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
dol_syslog('Propale::demand_reason Erreur '.$sql.' - '.$this->db->error()); foreach($this->errors as $errmsg)
$this->error=$this->db->error(); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
else else
{ {
dol_syslog('Propale::demand_reason, etat propale incompatible'); $error_str='Propal status do not meet requirement '.$this->statut;
$this->error='Etat propale incompatible '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error=$error_str;
$this->errors[]= $this->error;
return -2; return -2;
} }
} }

View File

@ -57,97 +57,99 @@ class Commande extends CommonOrder
* Client ID * Client ID
* @var int * @var int
*/ */
var $socid; public $socid;
var $ref_client; public $ref_client;
var $ref_int; public $ref_int;
var $contactid; public $contactid;
/** /**
* Status of the order. Check the following constants: * Status of the order. Check the following constants:
* @var int * @var int
* @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED * @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED
*/ */
var $statut; public $statut;
/** /**
* @deprecated * @deprecated
* @see billed * @see billed
*/ */
var $facturee; public $facturee;
var $billed; // billed or not public $billed; // billed or not
var $brouillon; public $brouillon;
var $cond_reglement_code; public $cond_reglement_code;
var $fk_account; public $fk_account;
/** /**
* It holds the label of the payment mode. Use it in case translation cannot be found. * It holds the label of the payment mode. Use it in case translation cannot be found.
* @var string * @var string
*/ */
var $mode_reglement; public $mode_reglement;
/** /**
* Payment mode id * Payment mode id
* @var int * @var int
*/ */
var $mode_reglement_id; public $mode_reglement_id;
/** /**
* Payment mode code * Payment mode code
* @var string * @var string
*/ */
var $mode_reglement_code; public $mode_reglement_code;
/** /**
* Availability delivery time id * Availability delivery time id
* @var int * @var int
*/ */
var $availability_id; public $availability_id;
/** /**
* Availability delivery time code * Availability delivery time code
* @var string * @var string
*/ */
var $availability_code; public $availability_code;
/** /**
* Label of availability delivery time. Use it in case translation cannot be found. * Label of availability delivery time. Use it in case translation cannot be found.
* @var string * @var string
*/ */
var $availability; public $availability;
var $demand_reason_id; public $demand_reason_id;
var $demand_reason_code; public $demand_reason_code;
var $address; public $address;
var $date; // Date commande public $date; // Date commande
/** /**
* @deprecated * @deprecated
* @see date * @see date
*/ */
var $date_commande; public $date_commande;
var $date_livraison; // Date livraison souhaitee public $date_livraison; // Date livraison souhaitee
var $fk_remise_except; public $fk_remise_except;
var $remise_percent; public $remise_percent;
var $remise_absolue; public $remise_absolue;
var $info_bits; public $info_bits;
var $rang; public $rang;
var $special_code; public $special_code;
var $source; // Origin of order public $source; // Origin of order
var $extraparams=array(); public $extraparams=array();
var $linked_objects=array(); public $linked_objects=array();
var $user_author_id; public $user_author_id;
/** /**
* @var OrderLine[] * @var OrderLine[]
*/ */
var $lines = array(); public $lines = array();
// Multicurrency // Multicurrency
var $fk_multicurrency; public $fk_multicurrency;
var $multicurrency_code; public $multicurrency_code;
var $multicurrency_tx; public $multicurrency_tx;
var $multicurrency_total_ht; public $multicurrency_total_ht;
var $multicurrency_total_tva; public $multicurrency_total_tva;
var $multicurrency_total_ttc; public $multicurrency_total_ttc;
public $oldcopy;
/** /**
* ERR Not enough stock * ERR Not enough stock
@ -469,7 +471,7 @@ class Commande extends CommonOrder
if (!$error) { if (!$error) {
// Call trigger // Call trigger
$result=$this->call_trigger('ORDER_SETDRAFT',$user); $result=$this->call_trigger('ORDER_UNVALIDATE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
} }
@ -2044,30 +2046,62 @@ class Commande extends CommonOrder
* *
* @param User $user User qui positionne la remise * @param User $user User qui positionne la remise
* @param float $remise Discount (percent) * @param float $remise Discount (percent)
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_remise($user, $remise) function set_remise($user, $remise, $notrigger=0)
{ {
$remise=trim($remise)?trim($remise):0; $remise=trim($remise)?trim($remise):0;
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error=0;
$this->db->begin();
$remise=price2num($remise); $remise=price2num($remise);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET remise_percent = '.$remise; $sql.= ' SET remise_percent = '.$remise;
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
if ($this->db->query($sql)) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_percent = $remise; $this->remise_percent = $remise;
$this->update_price(1); $this->update_price(1);
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -2078,32 +2112,62 @@ class Commande extends CommonOrder
* *
* @param User $user User qui positionne la remise * @param User $user User qui positionne la remise
* @param float $remise Discount * @param float $remise Discount
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_remise_absolue($user, $remise) function set_remise_absolue($user, $remise, $notrigger=0)
{ {
$remise=trim($remise)?trim($remise):0; $remise=trim($remise)?trim($remise):0;
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error=0;
$this->db->begin();
$remise=price2num($remise); $remise=price2num($remise);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET remise_absolue = '.$remise; $sql.= ' SET remise_absolue = '.$remise;
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
dol_syslog(get_class($this)."::set_remise_absolue", LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($this->db->query($sql)) if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_absolue = $remise; $this->remise_absolue = $remise;
$this->update_price(1); $this->update_price(1);
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -2114,27 +2178,57 @@ class Commande extends CommonOrder
* *
* @param User $user Object user making change * @param User $user Object user making change
* @param int $date Date * @param int $date Date
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_date($user, $date) function set_date($user, $date, $notrigger=0)
{ {
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql.= " SET date_commande = ".($date ? $this->db->idate($date) : 'null'); $sql.= " SET date_commande = ".($date ? $this->db->idate($date) : 'null');
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
dol_syslog(get_class($this)."::set_date",LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->date = $date; $this->date = $date;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
else else
@ -2148,27 +2242,57 @@ class Commande extends CommonOrder
* *
* @param User $user Objet utilisateur qui modifie * @param User $user Objet utilisateur qui modifie
* @param int $date_livraison Date de livraison * @param int $date_livraison Date de livraison
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
*/ */
function set_date_livraison($user, $date_livraison) function set_date_livraison($user, $date_livraison, $notrigger=0)
{ {
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
$sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null');
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::set_date_livraison", LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->date_livraison = $date_livraison; $this->date_livraison = $date_livraison;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
else else
@ -2182,26 +2306,57 @@ class Commande extends CommonOrder
* *
* @param User $user Object user making change * @param User $user Object user making change
* @param int $id If of availability delay * @param int $id If of availability delay
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_availability($user, $id) function set_availability($user, $id, $notrigger=0)
{ {
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande "; $sql = "UPDATE ".MAIN_DB_PREFIX."commande ";
$sql.= " SET fk_availability = '".$id."'"; $sql.= " SET fk_availability = '".$id."'";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql)) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->fk_availability = $id; $this->fk_availability = $id;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
dol_syslog(get_class($this)."::set_availability Erreur SQL"); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -2211,26 +2366,58 @@ class Commande extends CommonOrder
* *
* @param User $user Object user making change * @param User $user Object user making change
* @param int $id Id of source * @param int $id Id of source
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_demand_reason($user, $id) function set_demand_reason($user, $id, $notrigger=0)
{ {
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande "; $sql = "UPDATE ".MAIN_DB_PREFIX."commande ";
$sql.= " SET fk_input_reason = '".$id."'"; $sql.= " SET fk_input_reason = '".$id."'";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql)) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->fk_input_reason = $id; $this->fk_input_reason = $id;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
dol_syslog(get_class($this)."::set_demand_reason Erreur SQL"); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -2309,69 +2496,137 @@ class Commande extends CommonOrder
} }
/** /**
* Change le delai de livraison * Update delivery delay
* *
* @param int $availability_id Id du nouveau mode * @param int $availability_id Id du nouveau mode
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function availability($availability_id) function availability($availability_id, $notrigger=0)
{ {
dol_syslog('Commande::availability('.$availability_id.')'); dol_syslog('Commande::availability('.$availability_id.')');
if ($this->statut >= self::STATUS_DRAFT) if ($this->statut >= self::STATUS_DRAFT)
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_availability = '.$availability_id; $sql .= ' SET fk_availability = '.$availability_id;
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->availability_id = $availability_id; $this->availability_id = $availability_id;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
dol_syslog('Commande::availability Erreur '.$sql.' - '.$this->db->error(), LOG_ERR); foreach($this->errors as $errmsg)
$this->error=$this->db->lasterror(); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
else else
{ {
dol_syslog('Commande::availability, etat facture incompatible', LOG_ERR); $error_str='Command status do not meet requirement '.$this->statut;
$this->error='Etat commande incompatible '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error=$error_str;
$this->errors[]= $this->error;
return -2; return -2;
} }
} }
/** /**
* Change la source de la demande * Update order demand_reason
* *
* @param int $demand_reason_id Id of new demand * @param int $demand_reason_id Id of new demand
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int >0 if ok, <0 if ko * @return int >0 if ok, <0 if ko
*/ */
function demand_reason($demand_reason_id) function demand_reason($demand_reason_id, $notrigger=0)
{ {
dol_syslog('Commande::demand_reason('.$demand_reason_id.')'); dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
if ($this->statut >= self::STATUS_DRAFT) if ($this->statut >= self::STATUS_DRAFT)
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql .= ' SET fk_input_reason = '.$demand_reason_id; $sql .= ' SET fk_input_reason = '.$demand_reason_id;
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->demand_reason_id = $demand_reason_id; $this->demand_reason_id = $demand_reason_id;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
dol_syslog('Commande::demand_reason Erreur '.$sql.' - '.$this->db->error(), LOG_ERR); foreach($this->errors as $errmsg)
$this->error=$this->db->lasterror(); {
return -1; dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
else else
{ {
dol_syslog('Commande::demand_reason, etat facture incompatible', LOG_ERR); $error_str='order status do not meet requirement '.$this->statut;
$this->error='Etat commande incompatible '.$this->statut; dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error=$error_str;
$this->errors[]= $this->error;
return -2; return -2;
} }
} }
@ -2381,27 +2636,57 @@ class Commande extends CommonOrder
* *
* @param User $user User that make change * @param User $user User that make change
* @param string $ref_client Customer ref * @param string $ref_client Customer ref
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_ref_client($user, $ref_client) function set_ref_client($user, $ref_client, $notrigger=0)
{ {
if ($user->rights->commande->creer) if ($user->rights->commande->creer)
{ {
dol_syslog(get_class($this).'::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); $error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET';
$sql.= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); $sql.= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\'');
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql) ) dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->ref_client = $ref_client; $this->ref_client = $ref_client;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->lasterror(); foreach($this->errors as $errmsg)
return -2; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
else else
@ -2414,9 +2699,10 @@ class Commande extends CommonOrder
* Classify the order as invoiced * Classify the order as invoiced
* *
* @param User $user Object user making the change * @param User $user Object user making the change
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function classifyBilled(User $user) function classifyBilled(User $user, $notrigger=0)
{ {
global $user; global $user;
$error = 0; $error = 0;
@ -2428,17 +2714,25 @@ class Commande extends CommonOrder
dol_syslog(get_class($this)."::classifyBilled", LOG_DEBUG); dol_syslog(get_class($this)."::classifyBilled", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{
if (! $error)
{
$this->oldcopy= clone $this;
$this->facturee=1; // deprecated
$this->billed=1;
}
if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('ORDER_CLASSIFY_BILLED',$user); $result=$this->call_trigger('ORDER_CLASSIFY_BILLED',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
}
if (! $error) if (! $error)
{ {
$this->facturee=1; // deprecated
$this->billed=1;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2494,6 +2788,13 @@ class Commande extends CommonOrder
dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG); dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
if (! $error)
{
$this->oldcopy= clone $this;
$this->facturee=1; // deprecated
$this->billed=1;
}
// Call trigger // Call trigger
$result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user); $result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user);
if ($result < 0) $error++; if ($result < 0) $error++;

View File

@ -59,63 +59,63 @@ class Facture extends CommonInvoice
*/ */
protected $table_ref_field = 'facnumber'; protected $table_ref_field = 'facnumber';
var $socid; public $socid;
var $author; public $author;
var $fk_user_author; public $fk_user_author;
var $fk_user_valid; public $fk_user_valid;
var $date; // Date invoice public $date; // Date invoice
var $date_creation; // Creation date public $date_creation; // Creation date
var $date_validation; // Validation date public $date_validation; // Validation date
var $datem; public $datem;
var $ref_client; public $ref_client;
var $ref_int; public $ref_int;
//Check constants for types //Check constants for types
var $type = self::TYPE_STANDARD; public $type = self::TYPE_STANDARD;
//var $amount; //var $amount;
var $remise_absolue; public $remise_absolue;
var $remise_percent; public $remise_percent;
var $total_ht=0; public $total_ht=0;
var $total_tva=0; public $total_tva=0;
var $total_ttc=0; public $total_ttc=0;
var $revenuestamp; public $revenuestamp;
//! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon
//! Fermeture alors que aucun paiement: replaced (si remplace), abandon //! Fermeture alors que aucun paiement: replaced (si remplace), abandon
var $close_code; public $close_code;
//! Commentaire si mis a paye sans paiement complet //! Commentaire si mis a paye sans paiement complet
var $close_note; public $close_note;
//! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) //! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code)
var $paye; public $paye;
//! id of source invoice if replacement invoice or credit note //! id of source invoice if replacement invoice or credit note
var $fk_facture_source; public $fk_facture_source;
var $linked_objects=array(); public $linked_objects=array();
var $date_lim_reglement; public $date_lim_reglement;
var $cond_reglement_code; // Code in llx_c_paiement public $cond_reglement_code; // Code in llx_c_paiement
var $mode_reglement_code; // Code in llx_c_paiement public $mode_reglement_code; // Code in llx_c_paiement
var $fk_bank; // Field to store bank id to use when payment mode is withdraw public $fk_bank; // Field to store bank id to use when payment mode is withdraw
/** /**
* @deprecated * @deprecated
*/ */
var $products=array(); public $products=array();
/** /**
* @var FactureLigne[] * @var FactureLigne[]
*/ */
var $lines=array(); public $lines=array();
var $line; public $line;
var $extraparams=array(); public $extraparams=array();
var $specimen; public $specimen;
var $fac_rec; public $fac_rec;
// Multicurrency // Multicurrency
var $fk_multicurrency; public $fk_multicurrency;
var $multicurrency_code; public $multicurrency_code;
var $multicurrency_tx; public $multicurrency_tx;
var $multicurrency_total_ht; public $multicurrency_total_ht;
var $multicurrency_total_tva; public $multicurrency_total_tva;
var $multicurrency_total_ttc; public $multicurrency_total_ttc;
/** /**
* @var int Situation cycle reference number * @var int Situation cycle reference number
@ -142,6 +142,8 @@ class Facture extends CommonInvoice
*/ */
public $tab_next_situation_invoice=array(); public $tab_next_situation_invoice=array();
public $oldcopy;
/** /**
* Standard invoice * Standard invoice
*/ */
@ -1486,25 +1488,60 @@ class Facture extends CommonInvoice
* Set customer ref * Set customer ref
* *
* @param string $ref_client Customer ref * @param string $ref_client Customer ref
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_ref_client($ref_client) function set_ref_client($ref_client, $notrigger=0)
{ {
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
if (empty($ref_client)) if (empty($ref_client))
$sql .= ' SET ref_client = NULL'; $sql .= ' SET ref_client = NULL';
else else
$sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\''; $sql .= ' SET ref_client = \''.$this->db->escape($ref_client).'\'';
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql))
dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{ {
$this->ref_client = $ref_client; $this->ref_client = $ref_client;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('BILL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->ref_client = $ref_client;
$this->db->commit();
return 1; return 1;
} }
else else
{ {
dol_print_error($this->db); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
@ -2070,7 +2107,7 @@ class Facture extends CommonInvoice
$i++; $i++;
} }
if ($final) { if ($final) {
$this->setFinal(); $this->setFinal($user);
} }
} }
} }
@ -2760,9 +2797,10 @@ class Facture extends CommonInvoice
* *
* @param User $user User that set discount * @param User $user User that set discount
* @param double $remise Discount * @param double $remise Discount
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function set_remise($user, $remise) function set_remise($user, $remise, $notrigger=0)
{ {
// Clean parameters // Clean parameters
if (empty($remise)) $remise=0; if (empty($remise)) $remise=0;
@ -2771,21 +2809,48 @@ class Facture extends CommonInvoice
{ {
$remise=price2num($remise); $remise=price2num($remise);
$error=0;
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET remise_percent = '.$remise; $sql.= ' SET remise_percent = '.$remise;
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
$sql.= ' AND fk_statut = '.self::STATUS_DRAFT; $sql.= ' AND fk_statut = '.self::STATUS_DRAFT;
if ($this->db->query($sql)) dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{
$this->errors[]=$this->db->error();
$error++;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('BILL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{ {
$this->remise_percent = $remise; $this->remise_percent = $remise;
$this->update_price(1); $this->update_price(1);
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -2796,14 +2861,19 @@ class Facture extends CommonInvoice
* *
* @param User $user User that set discount * @param User $user User that set discount
* @param double $remise Discount * @param double $remise Discount
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_remise_absolue($user, $remise) function set_remise_absolue($user, $remise, $notrigger=0)
{ {
if (empty($remise)) $remise=0; if (empty($remise)) $remise=0;
if ($user->rights->facture->creer) if ($user->rights->facture->creer)
{ {
$error=0;
$this->db->begin();
$remise=price2num($remise); $remise=price2num($remise);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
@ -2811,18 +2881,43 @@ class Facture extends CommonInvoice
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
$sql.= ' AND fk_statut = '.self::STATUS_DRAFT; $sql.= ' AND fk_statut = '.self::STATUS_DRAFT;
dol_syslog(get_class($this)."::set_remise_absolue", LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($this->db->query($sql)) if (!$resql)
{ {
$this->errors[]=$this->db->error();
$error++;
}
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_absolue = $remise; $this->remise_absolue = $remise;
$this->update_price(1); $this->update_price(1);
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('BILL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); foreach($this->errors as $errmsg)
return -1; {
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
} }
} }
} }
@ -3819,25 +3914,49 @@ class Facture extends CommonInvoice
/** /**
* Sets the invoice as a final situation * Sets the invoice as a final situation
* *
* @return int 1 if ok, -1 if error * @param User $user Object user
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/ */
function setFinal() function setFinal(User $user, $notrigger=0)
{ {
$error=0;
$this->db->begin(); $this->db->begin();
$this->situation_final = 1; $this->situation_final = 1;
$sql = 'update ' . MAIN_DB_PREFIX . 'facture set situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id;
$resql = $this->db->query($sql);
if ($resql) { dol_syslog(__METHOD__, LOG_DEBUG);
// FIXME: call triggers MODIFY because we modify invoice $resql=$this->db->query($sql);
if (!$resql)
{
$this->errors[]=$this->db->error();
$error++;
}
if (! $notrigger && empty($error))
{
// Call trigger
$result=$this->call_trigger('BILL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { }
$this->error = $this->db->lasterror(); else
dol_syslog(get_class($this) . "::update Error setFinal " . $sql, LOG_ERR); {
foreach($this->errors as $errmsg)
{
dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback(); $this->db->rollback();
return -1; return -1*$error;
} }
} }

View File

@ -904,7 +904,7 @@ else
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td>'; print '<tr><td>'.$langs->trans("Status").'</td>';
print '<td>'; print '<td colspan="3">';
print $object->getLibStatut(4); print $object->getLibStatut(4);
print '</td></tr>'; print '</td></tr>';

View File

@ -35,6 +35,19 @@ $element = GETPOST('element','alpha',2);
$table_element = GETPOST('table_element','alpha',2); $table_element = GETPOST('table_element','alpha',2);
$fk_element = GETPOST('fk_element','alpha',2); $fk_element = GETPOST('fk_element','alpha',2);
/* Example:
field:editval_ref_customer (8 first chars will removed to know name of property)
element:contrat
table_element:contrat
fk_element:4
type:string
value:aaa
loadmethod:
savemethod:
savemethodname:
*/
/* /*
* View * View
*/ */
@ -81,7 +94,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
} }
else $newelement = $element; else $newelement = $element;
if (! empty($user->rights->$newelement->creer) || ! empty($user->rights->$newelement->write) if (! empty($user->rights->$newelement->creer) || ! empty($user->rights->$newelement->create) || ! empty($user->rights->$newelement->write)
|| (isset($subelement) && (! empty($user->rights->$newelement->$subelement->creer) || ! empty($user->rights->$newelement->$subelement->write))) || (isset($subelement) && (! empty($user->rights->$newelement->$subelement->creer) || ! empty($user->rights->$newelement->$subelement->write)))
|| ($element == 'payment' && $user->rights->facture->paiement) || ($element == 'payment' && $user->rights->facture->paiement)
|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer)) || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer))

View File

@ -99,7 +99,7 @@ class DolEditor
$this->editor->Value = $content; $this->editor->Value = $content;
$this->editor->Height = $height; $this->editor->Height = $height;
if (! empty($width)) $this->editor->Width = $width; if (! empty($width)) $this->editor->Width = $width;
$this->editor->ToolbarSet = $shorttoolbarname; $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js
$this->editor->Config['AutoDetectLanguage'] = 'true'; $this->editor->Config['AutoDetectLanguage'] = 'true';
$this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In';
$this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded;

View File

@ -24,8 +24,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
/** /**
* \class GenericObject * Class of a generic business object
* \brief Class of a generic business object
*/ */
class GenericObject extends CommonObject class GenericObject extends CommonObject

View File

@ -142,6 +142,7 @@ class HookManager
'formObjectOptions', 'formObjectOptions',
'formattachOptions', 'formattachOptions',
'formBuilddocLineOptions', 'formBuilddocLineOptions',
'getFormMail',
'getIdProfUrl', 'getIdProfUrl',
'moveUploadedFile', 'moveUploadedFile',
'pdf_build_address', 'pdf_build_address',

View File

@ -79,7 +79,9 @@ function societe_prepare_head(Societe $object)
if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES))
{ {
$head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id;
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
$head[$h][1] = $langs->trans("ContactsAddresses"); $head[$h][1] = $langs->trans("ContactsAddresses");
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }

View File

@ -117,12 +117,24 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
if ($duration_value == 0) return $time; if ($duration_value == 0) return $time;
if ($duration_unit == 'h') return $time + (3600*$duration_value); if ($duration_unit == 'h') return $time + (3600*$duration_value);
if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value); if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value);
if ($duration_value > 0) $deltastring="+".abs($duration_value);
if ($duration_value < 0) $deltastring="-".abs($duration_value); $deltastring='P';
if ($duration_unit == 'd') { $deltastring.=" day"; }
if ($duration_unit == 'm') { $deltastring.=" month"; } if ($duration_value > 0){ $deltastring.=abs($duration_value); $sub= false; }
if ($duration_unit == 'y') { $deltastring.=" year"; } if ($duration_value < 0){ $deltastring.=abs($duration_value); $sub= true; }
return strtotime($deltastring,$time); if ($duration_unit == 'd') { $deltastring.="D"; }
if ($duration_unit == 'm') { $deltastring.="M"; }
if ($duration_unit == 'y') { $deltastring.="Y"; }
$date = new DateTime();
$date->setTimezone(new DateTimeZone('UTC'));
$date->setTimestamp($time);
$interval = new DateInterval($deltastring);
if($sub) $date->sub($interval);
else $date->add( $interval );
return $date->getTimestamp();
} }

View File

@ -4267,7 +4267,7 @@ function picto_required()
* Clean a string from all HTML tags and entities * Clean a string from all HTML tags and entities
* *
* @param string $StringHtml String to clean * @param string $StringHtml String to clean
* @param integer $removelinefeed Replace also all lines feeds by a space, otherwise only last one are removed * @param integer $removelinefeed 1=Replace also all lines feeds by a space, 0=Only last one are removed
* @param string $pagecodeto Encoding of input/output string * @param string $pagecodeto Encoding of input/output string
* @return string String cleaned * @return string String cleaned
* *
@ -5257,7 +5257,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
if (preg_match('/SUBSTITUTION_([^_]+)/i',$values[2],$reg)) if (preg_match('/SUBSTITUTION_([^_]+)/i',$values[2],$reg))
{ {
$substitutionarray=array(); $substitutionarray=array();
complete_substitutions_array($substitutionarray,$langs,$object); complete_substitutions_array($substitutionarray,$langs,$object,array('needforkey'=>$values[2]));
$label=make_substitutions($reg[1], $substitutionarray); $label=make_substitutions($reg[1], $substitutionarray);
} }
else $label=$langs->trans($values[2]); else $label=$langs->trans($values[2]);
@ -5277,7 +5277,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
if (preg_match('/SUBSTITUTION_([^_]+)/i',$values[2],$reg)) if (preg_match('/SUBSTITUTION_([^_]+)/i',$values[2],$reg))
{ {
$substitutionarray=array(); $substitutionarray=array();
complete_substitutions_array($substitutionarray,$langs,$object); complete_substitutions_array($substitutionarray,$langs,$object,array('needforkey'=>$values[2]));
$label=make_substitutions($reg[1], $substitutionarray); $label=make_substitutions($reg[1], $substitutionarray);
} }
else $label=$langs->trans($values[2]); else $label=$langs->trans($values[2]);

View File

@ -1971,6 +1971,11 @@ function getElementProperties($element_type)
$module='resource'; $module='resource';
$subelement='dolresource'; $subelement='dolresource';
} }
if ($element_type == 'propaldet') {
$classpath = 'comm/propal/class';
$module='propal';
$subelement='propaleligne';
}
$classfile = strtolower($subelement); $classfile = strtolower($subelement);
$classname = ucfirst($subelement); $classname = ucfirst($subelement);

View File

@ -206,7 +206,7 @@ class ExportCsv extends ModeleExports
foreach($array_selected_sorted as $code => $value) foreach($array_selected_sorted as $code => $value)
{ {
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded $newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded
$newvalue=$this->csv_clean($newvalue,$outputlangs->charset_output); $newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
fwrite($this->handle,$newvalue.$this->separator); fwrite($this->handle,$newvalue.$this->separator);
} }
@ -250,7 +250,7 @@ class ExportCsv extends ModeleExports
// Translation newvalue // Translation newvalue
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]); if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
$newvalue=$this->csv_clean($newvalue,$outputlangs->charset_output); $newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7)) if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
{ {
@ -292,23 +292,35 @@ class ExportCsv extends ModeleExports
/** /**
* Clean a cell to respect rules of CSV file cells * Clean a cell to respect rules of CSV file cells
* Note: It uses $this->separator
* Note: We keep this function public to be able to test
* *
* @param string $newvalue String to clean * @param string $newvalue String to clean
* @param string $charset Input AND Output character set * @param string $charset Input AND Output character set
* @return string Value cleaned * @return string Value cleaned
*/ */
function csv_clean($newvalue, $charset) public function csvClean($newvalue, $charset)
{ {
global $conf;
$addquote=0; $addquote=0;
// Rule Dolibarr: No HTML // Rule Dolibarr: No HTML
//print $charset.' '.$newvalue."\n"; //print $charset.' '.$newvalue."\n";
$newvalue=dol_string_nohtmltag($newvalue,1,$charset); //$newvalue=dol_string_nohtmltag($newvalue,0,$charset);
$newvalue=dol_htmlcleanlastbr($newvalue);
//print $charset.' '.$newvalue."\n"; //print $charset.' '.$newvalue."\n";
// Rule 1 CSV: No CR, LF in cells // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is on, we can keep record as it is but we must add quotes)
$oldvalue=$newvalue;
$newvalue=str_replace("\r",'',$newvalue); $newvalue=str_replace("\r",'',$newvalue);
$newvalue=str_replace("\n",'\n',$newvalue); $newvalue=str_replace("\n",'\n',$newvalue);
if (! empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
{
// If strict use of CSV rules, we just add quote
$newvalue=$oldvalue;
$addquote=1;
}
// Rule 2 CSV: If value contains ", we must escape with ", and add " // Rule 2 CSV: If value contains ", we must escape with ", and add "
if (preg_match('/"/',$newvalue)) if (preg_match('/"/',$newvalue))

View File

@ -44,7 +44,7 @@ class modAgenda extends DolibarrModules
*/ */
function __construct($db) function __construct($db)
{ {
global $conf; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->numero = 2400; $this->numero = 2400;
@ -392,10 +392,14 @@ class modAgenda extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'actioncomm as ac'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
if(!$user->rights->agenda->allactions->read) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
$this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda',1).')'; $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR ac.fk_soc IS NULL)';
if(!$user->rights->agenda->allactions->read) $this->export_sql_end[$r] .=' AND acr.fk_element = '.$user->id;
$this->export_sql_end[$r] .=' ORDER BY ac.datep'; $this->export_sql_end[$r] .=' ORDER BY ac.datep';
} }

View File

@ -45,7 +45,7 @@ class modCommande extends DolibarrModules
*/ */
function __construct($db) function __construct($db)
{ {
global $conf; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->numero = 25; $this->numero = 25;
@ -191,6 +191,7 @@ class modCommande extends DolibarrModules
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c';
@ -204,6 +205,7 @@ class modCommande extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande',1).')'; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
} }

View File

@ -39,7 +39,7 @@ class modDeplacement extends DolibarrModules
*/ */
function __construct($db) function __construct($db)
{ {
global $conf; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->numero = 75 ; $this->numero = 75 ;
@ -124,8 +124,16 @@ class modDeplacement extends DolibarrModules
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
$this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'deplacement as d'; $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'deplacement as d';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid';
$this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement',1).')'; $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' OR d.fk_soc IS NULL)';
$childids = $user->getAllChildIds();
$childids[]=$user->id;
if (!$user->rights->deplacement->readall && !$user->rights->deplacement->lire_tous) $sql.=' AND d.fk_user IN ('.join(',',$childids).')';
} }

View File

@ -43,7 +43,7 @@ class modExpedition extends DolibarrModules
*/ */
function __construct($db) function __construct($db)
{ {
global $conf; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->numero = 80; $this->numero = 80;
@ -257,6 +257,7 @@ class modExpedition extends DolibarrModules
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expedition as c'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expedition as c';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed';
@ -271,6 +272,7 @@ class modExpedition extends DolibarrModules
} }
$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('shipment',1).')'; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('shipment',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
} }

View File

@ -42,7 +42,7 @@ class modFacture extends DolibarrModules
*/ */
function __construct($db) function __construct($db)
{ {
global $conf; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->numero = 30; $this->numero = 30;
@ -205,6 +205,7 @@ class modFacture extends DolibarrModules
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
@ -217,6 +218,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture',1).')'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r]=$this->rights_class.'_'.$r;
@ -232,6 +234,7 @@ class modFacture extends DolibarrModules
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid';
@ -245,6 +248,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture',1).')'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
$r++; $r++;
} }

View File

@ -42,7 +42,7 @@ class modFournisseur extends DolibarrModules
*/ */
function __construct($db) function __construct($db)
{ {
global $conf; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->numero = 40; $this->numero = 40;
@ -366,6 +366,7 @@ class modFournisseur extends DolibarrModules
// End add extra fields line // End add extra fields line
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
@ -375,6 +376,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r]=$this->rights_class.'_'.$r;
@ -428,6 +430,7 @@ class modFournisseur extends DolibarrModules
// End add extra fields object // End add extra fields object
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
@ -436,6 +439,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
// Order // Order
$r++; $r++;
@ -532,6 +536,7 @@ class modFournisseur extends DolibarrModules
// End add extra fields line // End add extra fields line
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
@ -543,6 +548,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
} }

View File

@ -43,7 +43,7 @@ class modPropale extends DolibarrModules
*/ */
function __construct($db) function __construct($db)
{ {
global $conf; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->numero = 20; $this->numero = 20;
@ -184,6 +184,7 @@ class modPropale extends DolibarrModules
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s ';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'propal as c'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'propal as c';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid';
@ -196,6 +197,7 @@ class modPropale extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal';
$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal',1).')'; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal',1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
} }

View File

@ -43,7 +43,7 @@ class modSociete extends DolibarrModules
*/ */
function __construct($db) function __construct($db)
{ {
global $conf; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->numero = 1; $this->numero = 1;
@ -274,6 +274,7 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid';
$this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')'; $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
// Export list of contacts and attributes // Export list of contacts and attributes
$r++; $r++;
@ -295,10 +296,12 @@ class modSociete extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
$this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')'; $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
// Imports // Imports

View File

@ -99,7 +99,7 @@ class modWebsites extends DolibarrModules
$this->rights[$r][0] = 10002; $this->rights[$r][0] = 10002;
$this->rights[$r][1] = 'Create/modify website content'; $this->rights[$r][1] = 'Create/modify website content';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'create'; $this->rights[$r][4] = 'write';
$r++; $r++;
$this->rights[$r][0] = 10003; $this->rights[$r][0] = 10003;

View File

@ -1924,6 +1924,8 @@ else if ($id || $ref)
// Tableau des substitutions // Tableau des substitutions
$formmail->setSubstitFromObject($object); $formmail->setSubstitFromObject($object);
$formmail->substit['__SHIPPINGREF__']=$object->ref; $formmail->substit['__SHIPPINGREF__']=$object->ref;
$formmail->substit['__SHIPPINGTRACKNUM__']=$object->tracking_number;
$formmail->substit['__SHIPPINGTRACKNUMURL__']=$object->tracking_url;
//Find the good contact adress //Find the good contact adress
if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled)) { if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled)) {

View File

@ -526,7 +526,7 @@ class Export
return -1; return -1;
} }
// Creation de la classe d'export du model ExportXXX // Creation of class to export using model ExportXXX
$dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
$file = "export_".$model.".modules.php"; $file = "export_".$model.".modules.php";
$classname = "Export".$model; $classname = "Export".$model;

View File

@ -638,6 +638,13 @@ if ($step == 2 && $datatoexport)
if ($step == 3 && $datatoexport) if ($step == 3 && $datatoexport)
{ {
if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
{
// Switch to step 2
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
exit;
}
llxHeader('',$langs->trans("NewExport"),'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones'); llxHeader('',$langs->trans("NewExport"),'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones');
/* /*
@ -792,6 +799,13 @@ if ($step == 3 && $datatoexport)
if ($step == 4 && $datatoexport) if ($step == 4 && $datatoexport)
{ {
if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
{
// Switch to step 2
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
exit;
}
asort($array_selected); asort($array_selected);
llxHeader('',$langs->trans("NewExport"),'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones'); llxHeader('',$langs->trans("NewExport"),'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones');
@ -1017,6 +1031,13 @@ if ($step == 4 && $datatoexport)
if ($step == 5 && $datatoexport) if ($step == 5 && $datatoexport)
{ {
if (count($array_selected) < 1) // This occurs when going back to page after sessecion expired
{
// Switch to step 2
header("Location: ".DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport);
exit;
}
asort($array_selected); asort($array_selected);
llxHeader('',$langs->trans("NewExport"),'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones'); llxHeader('',$langs->trans("NewExport"),'EN:Module_Exports_En|FR:Module_Exports|ES:M&oacute;dulo_Exportaciones');

View File

@ -31,7 +31,7 @@
*/ */
if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr');
if (! defined('DOL_VERSION')) define('DOL_VERSION','4.0.0-rc'); if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.0-alpha');
if (! defined('EURO')) define('EURO',chr(128)); if (! defined('EURO')) define('EURO',chr(128));

View File

@ -169,9 +169,6 @@ if ($lastUpdate)
print '<br>'.$langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>'."\n"; print '<br>'.$langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>'."\n";
} }
else print $langs->trans('None'); else print $langs->trans('None');
print "</div><br>\n"; print "</div><br>\n";
$result = $holiday->updateBalance(); // Create users into table holiday if they don't exists. TODO Remove this whif we use field into table user. $result = $holiday->updateBalance(); // Create users into table holiday if they don't exists. TODO Remove this whif we use field into table user.

View File

@ -60,7 +60,14 @@ $log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', " AND date_action BETWEE
print load_fiche_titre($langs->trans('LogCP'), '<div class="pagination"><ul><li class="pagination"><a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'">&lt;</a><li class="pagination"><a href="">'.$langs->trans("Year").' '.$year.'</a></li><li class="pagination"><a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'">&gt;</a></li></lu></div>', 'title_hrm.png'); print load_fiche_titre($langs->trans('LogCP'), '<div class="pagination"><ul><li class="pagination"><a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'">&lt;</a><li class="pagination"><a href="">'.$langs->trans("Year").' '.$year.'</a></li><li class="pagination"><a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'">&gt;</a></li></lu></div>', 'title_hrm.png');
print '<div class="info">'.$langs->trans('LastUpdateCP').': '."\n"; print '<div class="info">'.$langs->trans('LastUpdateCP').': '."\n";
if ($cp->getConfCP('lastUpdate')) print '<strong>'.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')),'dayhour','tzuser').'</strong>'; $lastUpdate = $cp->getConfCP('lastUpdate');
if ($lastUpdate)
{
$monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
$yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3];
print '<strong>'.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')),'dayhour','tzuser').'</strong>';
print '<br>'.$langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>'."\n";
}
else print $langs->trans('None'); else print $langs->trans('None');
print "</div><br>\n"; print "</div><br>\n";
@ -108,8 +115,8 @@ foreach($cp->logs as $logs_CP)
if ($log_holiday == '2') if ($log_holiday == '2')
{ {
print '<tr>'; print '<tr '.$bc[false].'>';
print '<td colspan="8" '.$bc[false].'>'.$langs->trans('None').'</td>'; print '<td colspan="8" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>';
print '</tr>'; print '</tr>';
} }

View File

@ -392,7 +392,8 @@ else
array('from'=>'3.6.0', 'to'=>'3.7.0'), array('from'=>'3.6.0', 'to'=>'3.7.0'),
array('from'=>'3.7.0', 'to'=>'3.8.0'), array('from'=>'3.7.0', 'to'=>'3.8.0'),
array('from'=>'3.8.0', 'to'=>'3.9.0'), array('from'=>'3.8.0', 'to'=>'3.9.0'),
array('from'=>'3.9.0', 'to'=>'4.0.0') array('from'=>'3.9.0', 'to'=>'4.0.0'),
array('from'=>'4.0.0', 'to'=>'5.0.0')
); );
$count=0; $count=0;

View File

@ -369,7 +369,7 @@ if (! empty($force_install_message))
<tr class="hidesqlite"> <tr class="hidesqlite">
<td valign="top" class="label"><?php echo $langs->trans("Port"); ?></td> <td valign="top" class="label"><?php echo $langs->trans("Port"); ?></td>
<td valign="top" class="label"><input type="text" <td valign="top" class="label"><input type="text" id="db_port"
name="db_port<?php print ($force_install_noedit==2 && $force_install_port)?'_bis':''; ?>" name="db_port<?php print ($force_install_noedit==2 && $force_install_port)?'_bis':''; ?>"
<?php if ($force_install_noedit==2 && $force_install_port) print ' disabled'; ?> <?php if ($force_install_noedit==2 && $force_install_port) print ' disabled'; ?>
value="<?php print (! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port; ?>"> value="<?php print (! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port; ?>">
@ -484,9 +484,27 @@ if (! empty($force_install_message))
<script type="text/javascript"> <script type="text/javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#db_type").change(function() { var dbtype = jQuery("#db_type");
if (jQuery("#db_type").val()=='sqlite' || jQuery("#db_type").val()=='sqlite3') { jQuery(".hidesqlite").hide(); }
else { jQuery(".hidesqlite").show(); } dbtype.change(function () {
if (dbtype.val() == 'sqlite' || dbtype.val() == 'sqlite3') {
jQuery(".hidesqlite").hide();
} else {
jQuery(".hidesqlite").show();
}
// Automatically set default database ports and admin user
if (dbtype.val() == 'mysql' || dbtype.val() == 'mysqli') {
jQuery("#db_port").val(3306);
jQuery("#db_user_root").val('root');
} else if (dbtype.val() == 'pgsql') {
jQuery("#db_port").val(5432);
jQuery("#db_user_root").val('postgres');
} else if (dbtype.val() == 'mssql') {
jQuery("#db_port").val(1433);
jQuery("#db_user_root").val('sa');
}
}); });
function init_needroot() function init_needroot()

View File

@ -0,0 +1,35 @@
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
-- when current version is 4.0.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
-- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table
-- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex
-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y
-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y
-- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
-- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
-- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
-- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
-- Note: fields with type BLOB/TEXT can't have default value.
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
ALTER TABLE llx_societe ADD COLUMN fk_account integer;
ALTER TABLE llx_website ADD COLUMN virtualhost varchar(255) after fk_default_home;
ALTER TABLE llx_ecm_files ADD COLUMN gen_or_uploaded varchar(12) after cover;
DROP TABLE llx_document_generator;
DROP TABLE llx_ecm_documents;

View File

@ -27,7 +27,8 @@ CREATE TABLE llx_ecm_files
description text, description text,
keywords text, -- list of keywords, separated with comma keywords text, -- list of keywords, separated with comma
cover text, -- is this file a file to use for a cover cover text, -- is this file a file to use for a cover
extraparams varchar(255), -- for stock other parameters with json format gen_or_uploaded varchar(12), -- 'generated' or 'uploaded'
extraparams varchar(255), -- for stocking other parameters with json format
date_c datetime, date_c datetime,
date_m timestamp, date_m timestamp,
fk_user_c integer, fk_user_c integer,

View File

@ -47,6 +47,7 @@ create table llx_societe
town varchar(50), -- town town varchar(50), -- town
fk_departement integer DEFAULT 0, -- fk_departement integer DEFAULT 0, --
fk_pays integer DEFAULT 0, -- fk_pays integer DEFAULT 0, --
fk_account integer DEFAULT 0, --
phone varchar(20), -- phone number phone varchar(20), -- phone number
fax varchar(20), -- fax number fax varchar(20), -- fax number
url varchar(255), -- url varchar(255), --

View File

@ -25,6 +25,7 @@ CREATE TABLE llx_website
description varchar(255), description varchar(255),
status integer, status integer,
fk_default_home integer, fk_default_home integer,
virtualhost varchar(255),
date_creation datetime, date_creation datetime,
date_modification datetime, date_modification datetime,
tms timestamp tms timestamp

View File

@ -21,3 +21,5 @@ ViewSiteInNewTab=View site in new tab
ViewPageInNewTab=View page in new tab ViewPageInNewTab=View page in new tab
SetAsHomePage=Set as Home page SetAsHomePage=Set as Home page
RealURL=Real URL RealURL=Real URL
ViewWebsiteInProduction=View web site using home URLs
SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on <strong>%s</strong>, define here the virtual hostname so the preview will be done using this direct access instead of Dolibarr URLs wrapper.

View File

@ -1285,7 +1285,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
} }
print '<script type="text/javascript">'; print '<script type="text/javascript">';
print 'var CKEDITOR_BASEPATH = \''.$pathckeditor.'\';'."\n"; print 'var CKEDITOR_BASEPATH = \''.$pathckeditor.'\';'."\n";
print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js',1).'\';'."\n"; // $themesubdir='' in standard usage print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js'.($ext?'?'.$ext:''),1).'\';'."\n"; // $themesubdir='' in standard usage
print 'var ckeditorFilebrowserBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n"; print 'var ckeditorFilebrowserBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n"; print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
print '</script>'."\n"; print '</script>'."\n";

View File

@ -95,6 +95,8 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $projectid, 'projet&project'); $result = restrictedArea($user, 'projet', $projectid, 'projet&project');
$hookmanager->initHooks(array('projectOverview'));
/* /*
* View * View
*/ */
@ -350,6 +352,15 @@ $listofreferent=array(
'test'=>$conf->projet->enabled && $user->rights->projet->lire && $conf->salaries->enabled && empty($conf->global->PROJECT_HIDE_TASKS)), 'test'=>$conf->projet->enabled && $user->rights->projet->lire && $conf->salaries->enabled && empty($conf->global->PROJECT_HIDE_TASKS)),
); );
$parameters=array('listofreferent'=>$listofreferent);
$resHook = $hookmanager->executeHooks('completeListOfReferent',$parameters,$object,$action);
if(!empty($hookmanager->resArray)) {
$listofreferent = array_merge($listofreferent, $hookmanager->resArray);
}
if ($action=="addelement") if ($action=="addelement")
{ {
$tablename = GETPOST("tablename"); $tablename = GETPOST("tablename");
@ -438,6 +449,7 @@ foreach ($listofreferent as $key => $value)
$element = new $classname($db); $element = new $classname($db);
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
if (count($elementarray)>0 && is_array($elementarray)) if (count($elementarray)>0 && is_array($elementarray))
{ {
$total_ht = 0; $total_ht = 0;
@ -453,7 +465,7 @@ foreach ($listofreferent as $key => $value)
$element->fetch($idofelement); $element->fetch($idofelement);
if ($idofelementuser) $elementuser->fetch($idofelementuser); if ($idofelementuser) $elementuser->fetch($idofelementuser);
if ($tablename != 'expensereport_det') $element->fetch_thirdparty(); if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
if ($tablename == 'don') $total_ht_by_line=$element->amount; if ($tablename == 'don') $total_ht_by_line=$element->amount;
elseif ($tablename == 'projet_task') elseif ($tablename == 'projet_task')
@ -679,7 +691,7 @@ foreach ($listofreferent as $key => $value)
if ($tablename != 'expensereport_det') if ($tablename != 'expensereport_det')
{ {
$element->fetch_thirdparty(); if(method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
} }
else else
{ {

View File

@ -1025,7 +1025,7 @@ class Societe extends CommonObject
$sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.fk_forme_juridique as forme_juridique_code';
$sql .= ', s.webservices_url, s.webservices_key'; $sql .= ', s.webservices_url, s.webservices_key';
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj'; $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj';
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.fk_shipping_method'; $sql .= ', s.fk_shipping_method';
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
@ -1157,6 +1157,7 @@ class Societe extends CommonObject
$this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier;
$this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier;
$this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null;
$this->fk_account = $obj->fk_account;
$this->client = $obj->client; $this->client = $obj->client;
$this->fournisseur = $obj->fournisseur; $this->fournisseur = $obj->fournisseur;

View File

@ -28,7 +28,9 @@ CKEDITOR.editorConfig = function( config )
config.toolbar_Full = config.toolbar_Full =
[ [
['Source','-','Save','NewPage','Preview','-','Templates'], ['Templates','NewPage'],
['Save'],
['Source','Maximize','Preview'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'], ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],

View File

@ -603,6 +603,12 @@ div.myavailability {
.minwidth300 { min-width: 300px; } .minwidth300 { min-width: 300px; }
.minwidth400 { min-width: 400px; } .minwidth400 { min-width: 400px; }
.minwidth500 { min-width: 500px; } .minwidth500 { min-width: 500px; }
.minwidth50imp { min-width: 50px !important; }
.minwidth100imp { min-width: 100px !important; }
.minwidth200imp { min-width: 200px !important; }
.minwidth300imp { min-width: 300px !important; }
.minwidth400imp { min-width: 400px !important; }
.minwidth500imp { min-width: 500px !important; }
.maxwidth100 { max-width: 100px; } .maxwidth100 { max-width: 100px; }
.maxwidth150 { max-width: 150px; } .maxwidth150 { max-width: 150px; }
.maxwidth200 { max-width: 200px; } .maxwidth200 { max-width: 200px; }

View File

@ -28,7 +28,9 @@ CKEDITOR.editorConfig = function( config )
config.toolbar_Full = config.toolbar_Full =
[ [
['Source','-','Save','NewPage','Preview','-','Templates'], ['Templates','NewPage'],
['Save'],
['Source','Maximize','Preview'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'], ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 B

After

Width:  |  Height:  |  Size: 410 B

View File

@ -601,6 +601,12 @@ div.myavailability {
.minwidth300 { min-width: 300px; } .minwidth300 { min-width: 300px; }
.minwidth400 { min-width: 400px; } .minwidth400 { min-width: 400px; }
.minwidth500 { min-width: 500px; } .minwidth500 { min-width: 500px; }
.minwidth50imp { min-width: 50px !important; }
.minwidth100imp { min-width: 100px !important; }
.minwidth200imp { min-width: 200px !important; }
.minwidth300imp { min-width: 300px !important; }
.minwidth400imp { min-width: 400px !important; }
.minwidth500imp { min-width: 500px !important; }
.maxwidth100 { max-width: 100px; } .maxwidth100 { max-width: 100px; }
.maxwidth150 { max-width: 150px; } .maxwidth150 { max-width: 150px; }
.maxwidth200 { max-width: 200px; } .maxwidth200 { max-width: 200px; }
@ -746,7 +752,7 @@ td.showDragHandle {
margin-left: 0; margin-left: 0;
} }
div.login_block { div.login_block {
border-right: none ! important; /* border-right: none ! important; */
top: inherit !important; top: inherit !important;
} }
.side-nav { .side-nav {
@ -771,6 +777,7 @@ div.login_block {
#id-left { #id-left {
z-index: 201; z-index: 201;
background: #FFF; background: #FFF;
border-right: 1px solid rgba(0,0,0,0.3);
<?php if ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> <?php if ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?>
top: 50px ! important; top: 50px ! important;
<?php } else { ?> <?php } else { ?>
@ -2664,7 +2671,7 @@ div.tabBar .noborder {
<?php } ?> <?php } ?>
} }
span.boxstatstext { span.boxstatstext {
opacity: 0.9; /* opacity: 0.9; Disabled. This make text on top of left menu in smartphone size */
line-height: 18px; line-height: 18px;
} }
span.boxstatsindicator { span.boxstatsindicator {

View File

@ -85,6 +85,12 @@ class Website extends CommonObject
* @var integer * @var integer
*/ */
public $fk_default_home; public $fk_default_home;
/**
* @var string
*/
public $virtualhost;
public $records; public $records;
/** /**
@ -144,6 +150,7 @@ class Website extends CommonObject
$sql.= 'description,'; $sql.= 'description,';
$sql.= 'status,'; $sql.= 'status,';
$sql.= 'fk_default_home,'; $sql.= 'fk_default_home,';
$sql.= 'virtualhost,';
$sql.= 'date_creation,'; $sql.= 'date_creation,';
$sql.= 'date_modification'; $sql.= 'date_modification';
@ -154,6 +161,7 @@ class Website extends CommonObject
$sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").',';
$sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; $sql .= ' '.(! isset($this->status)?'NULL':$this->status).',';
$sql .= ' '.(! isset($this->fk_default_home)?'NULL':$this->fk_default_home).','; $sql .= ' '.(! isset($this->fk_default_home)?'NULL':$this->fk_default_home).',';
$sql .= ' '.(! isset($this->virtualhost)?'NULL':$this->virtualhost).',';
$sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").',';
$sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'");
@ -214,6 +222,7 @@ class Website extends CommonObject
$sql .= " t.description,"; $sql .= " t.description,";
$sql .= " t.status,"; $sql .= " t.status,";
$sql .= " t.fk_default_home,"; $sql .= " t.fk_default_home,";
$sql .= " t.virtualhost,";
$sql .= " t.date_creation,"; $sql .= " t.date_creation,";
$sql .= " t.date_modification,"; $sql .= " t.date_modification,";
$sql .= " t.tms"; $sql .= " t.tms";
@ -237,6 +246,7 @@ class Website extends CommonObject
$this->description = $obj->description; $this->description = $obj->description;
$this->status = $obj->status; $this->status = $obj->status;
$this->fk_default_home = $obj->fk_default_home; $this->fk_default_home = $obj->fk_default_home;
$this->virtualhost = $obj->virtualhost;
$this->date_creation = $this->db->jdate($obj->date_creation); $this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_modification = $this->db->jdate($obj->date_modification); $this->date_modification = $this->db->jdate($obj->date_modification);
$this->tms = $this->db->jdate($obj->tms); $this->tms = $this->db->jdate($obj->tms);
@ -282,6 +292,7 @@ class Website extends CommonObject
$sql .= " t.description,"; $sql .= " t.description,";
$sql .= " t.status,"; $sql .= " t.status,";
$sql .= " t.fk_default_home,"; $sql .= " t.fk_default_home,";
$sql .= " t.virtualhost,";
$sql .= " t.date_creation,"; $sql .= " t.date_creation,";
$sql .= " t.date_modification,"; $sql .= " t.date_modification,";
$sql .= " t.tms"; $sql .= " t.tms";
@ -321,6 +332,7 @@ class Website extends CommonObject
$line->description = $obj->description; $line->description = $obj->description;
$line->status = $obj->status; $line->status = $obj->status;
$line->fk_default_home = $obj->fk_default_home; $line->fk_default_home = $obj->fk_default_home;
$line->virtualhost = $obj->virtualhost;
$line->date_creation = $this->db->jdate($obj->date_creation); $line->date_creation = $this->db->jdate($obj->date_creation);
$line->date_modification = $this->db->jdate($obj->date_modification); $line->date_modification = $this->db->jdate($obj->date_modification);
$line->tms = $this->db->jdate($obj->tms); $line->tms = $this->db->jdate($obj->tms);
@ -380,6 +392,7 @@ class Website extends CommonObject
$sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").',';
$sql .= ' status = '.(isset($this->status)?$this->status:"null").','; $sql .= ' status = '.(isset($this->status)?$this->status:"null").',';
$sql .= ' fk_default_home = '.(($this->fk_default_home > 0)?$this->fk_default_home:"null").','; $sql .= ' fk_default_home = '.(($this->fk_default_home > 0)?$this->fk_default_home:"null").',';
$sql .= ' virtualhost = '.(($this->virtualhost != '')?$this->virtualhost:"null").',';
$sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').',';
$sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').',';
$sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'");
@ -627,6 +640,7 @@ class Website extends CommonObject
$this->description = 'A specimen website'; $this->description = 'A specimen website';
$this->status = ''; $this->status = '';
$this->fk_default_home = null; $this->fk_default_home = null;
$this->virtualhost = 'http://myvirtualhost';
$this->date_creation = dol_now(); $this->date_creation = dol_now();
$this->date_modification = dol_now(); $this->date_modification = dol_now();
$this->tms = dol_now(); $this->tms = dol_now();
@ -665,6 +679,10 @@ class WebsiteLine
* @var int * @var int
*/ */
public $fk_default_home; public $fk_default_home;
/**
* @var string
*/
public $virtualhost;
/** /**
* @var mixed * @var mixed
*/ */

View File

@ -454,6 +454,8 @@ print '<div class="centpercent websitebar">';
if (count($object->records) > 0) if (count($object->records) > 0)
{ {
// ***** Part for web sites
print '<div class="websiteselection">'; print '<div class="websiteselection">';
print $langs->trans("Website").': '; print $langs->trans("Website").': ';
print '</div>'; print '</div>';
@ -478,15 +480,56 @@ if (count($object->records) > 0)
} }
$out.='</select>'; $out.='</select>';
print $out; print $out;
print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Refresh").'">'; print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">';
if ($website) if ($website)
{ {
print ' - '.$langs->trans("RealURL").' ';
$realurl=$urlwithroot.'/public/websites/index.php?website='.$website; $realurl=$urlwithroot.'/public/websites/index.php?website='.$website;
$dataroot=DOL_DATA_ROOT.'/websites/'.$website;
if (! empty($object->virtualhost)) $realurl=$object->virtualhost;
// TODO If virtual url defined, we use it
/*print ' - '.$langs->trans("RealURL").' ';
print '<input type="text" name="realurl" value="'.$realurl.'"> '; print '<input type="text" name="realurl" value="'.$realurl.'"> ';
print '<a href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>'; print '<a href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>';*/
print ' &nbsp; ';
print $langs->trans("ViewWebsiteInProduction").': ';
print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" value="'.$realurl.'">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext);
print '<a class="button" id="previewsite" href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>';
// Example : Adding jquery code
if (! empty($conf->use_javascript_ajax))
{
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#previewsite").click(function() {
newurl=jQuery("#previewsiteurl").val();
console.log("Open url "+newurl);
/* Save url */
jQuery.ajax({
method: "POST",
url: "'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
data: {
field: \'editval_virtualhost\',
element: \'websites\',
table_element: \'website\',
fk_element: '.$object->id.',
value: newurl,
},
context: document.body
});
$(this).attr("href",newurl);
});
});
</script>';
} }
}
print '</div>'; print '</div>';
// Button for websites // Button for websites
@ -513,7 +556,8 @@ if (count($object->records) > 0)
print '</div>'; print '</div>';
// Part for pages // ***** Part for pages
if ($website) if ($website)
{ {
print '</div>'; print '</div>';
@ -555,7 +599,7 @@ if (count($object->records) > 0)
else $out.='<option value="-1">&nbsp;</option>'; else $out.='<option value="-1">&nbsp;</option>';
$out.='</select>'; $out.='</select>';
print $out; print $out;
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Refresh").'"'.($atleastonepage?'':' disabled="disabled"').'>'; print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>'; print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
//print $form->selectarray('page', $array); //print $form->selectarray('page', $array);
@ -563,8 +607,9 @@ if (count($object->records) > 0)
{ {
print ' - '.$langs->trans("RealURL").' '; print ' - '.$langs->trans("RealURL").' ';
$realurl=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; $realurl=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
print '<input type="text" name="realurl" value="'.$realurl.'"> '; print '<input type="text" name="realurl" class="minwidth200imp" disabled="disabled" value="'.$realurl.'"> ';
print '<a href="'.$realurl.'" target="tab'.$website.'">'.$langs->trans("ViewPageInNewTab").'</a>'; print '<a href="'.$realurl.'" class="button" target="tab'.$website.'">'.$langs->trans("ViewPageInNewTab").'</a>';
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
} }
print '</div>'; print '</div>';

View File

@ -120,9 +120,96 @@ class ExportTest extends PHPUnit_Framework_TestCase
} }
/**
* Other tests
*
* @return void
*/
public function testExportOther()
{
global $conf,$user,$langs,$db;
$model='csv';
// Creation of class to export using model ExportXXX
$dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
$file = "export_".$model.".modules.php";
$classname = "Export".$model;
require_once $dir.$file;
$objmodel = new $classname($this->db);
// First test without option USE_STRICT_CSV_RULES
unset($conf->global->USE_STRICT_CSV_RULES);
$valtotest='A simple string';
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, 'A simple string');
$valtotest='A string with , and ; inside';
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, '"A string with , and ; inside"');
$valtotest='A string with " inside';
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, '"A string with "" inside"');
$valtotest='A string with " inside and '."\r\n".' carriage returns';
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, '"A string with "" inside and \n carriage returns"');
$valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, '"A string with <a href=""aaa""><strong>html<br>content</strong></a> inside"');
// Same tests with strict mode
$conf->global->USE_STRICT_CSV_RULES=1;
$valtotest='A simple string';
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, 'A simple string');
$valtotest='A string with , and ; inside';
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, '"A string with , and ; inside"');
$valtotest='A string with " inside';
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, '"A string with "" inside"');
$valtotest='A string with " inside and '."\r\n".' carriage returns';
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\"");
$valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
print __METHOD__." valtotest=".$valtotest."\n";
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result, '"A string with <a href=""aaa""><strong>html<br>content</strong></a> inside"');
}
/** /**
* Test export function for a personalized dataset * Test export function for a personalized dataset
* *
* @depends testExportOther
* @return void * @return void
*/ */
public function testExportPersonalizedExport() public function testExportPersonalizedExport()
@ -266,4 +353,5 @@ class ExportTest extends PHPUnit_Framework_TestCase
return true; return true;
} }
} }

View File

@ -54,7 +54,8 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
protected $savlangs; protected $savlangs;
protected $savdb; protected $savdb;
protected $soapclient; protected $soapclient;
protected $socid;
private static $socid;
protected $ns = 'http://www.dolibarr.org/ns/'; protected $ns = 'http://www.dolibarr.org/ns/';
@ -72,10 +73,9 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$this->savuser=$user; $this->savuser=$user;
$this->savlangs=$langs; $this->savlangs=$langs;
$this->savdb=$db; $this->savdb=$db;
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
// Set the WebService URL // Set the WebService URL
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
$this->soapclient = new nusoap_client($WS_DOL_URL); $this->soapclient = new nusoap_client($WS_DOL_URL);
if ($this->soapclient) if ($this->soapclient)
@ -84,7 +84,28 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$this->soapclient->decodeUTF8(false); $this->soapclient->decodeUTF8(false);
} }
// create third_parties, needed to test an invoice print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db;
print "\n";
}
public static function setUpBeforeClass()
{
global $conf,$user,$langs,$db;
// create a third_party, needed to create an invoice
//
// The third party is created in setUpBeforeClass() and not in the
// constructor to avoid creating several objects (the constructor is
// called for each test).
//
// The third party must be created before beginning the DB transaction
// because there is a foreign key constraint between invoices and third
// parties (tables: lx_facture and llx_societe) and with MySQL,
// constraints are checked immediately, they are not deferred to
// transaction commit. So if the invoice is created in the same
// transaction than the third party, the FK constraint fails.
// See this post for more detail: http://stackoverflow.com/a/5014744/5187108
$societe=new Societe($db); $societe=new Societe($db);
$societe->ref=''; $societe->ref='';
$societe->name='name'; $societe->name='name';
@ -98,23 +119,14 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$societe->create($user); $societe->create($user);
$this->socid = $societe->id; self::$socid = $societe->id;
print __METHOD__." societe created id=".$societe->id."\n"; print __METHOD__." societe created id=".$societe->id."\n";
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db;
print "\n";
}
// Static methods
public static function setUpBeforeClass()
{
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
print __METHOD__."\n"; print __METHOD__."\n";
} }
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;
@ -137,7 +149,6 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$db=$this->savdb; $db=$this->savdb;
print __METHOD__."\n"; print __METHOD__."\n";
} }
/** /**
@ -166,17 +177,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
$WS_METHOD = 'createInvoice'; $WS_METHOD = 'createInvoice';
// load societe first
/*$societe=new Societe($db);
$societe->fetch('', '', 'ref-phpunit');
print __METHOD__." societe loaded id=".$societe->id."\n";
*/
$body = array ( $body = array (
"id" => NULL, "id" => NULL,
"ref" => NULL, "ref" => NULL,
"ref_ext" => "ref-phpunit-2", "ref_ext" => "ref-phpunit-2",
"thirdparty_id" => $this->socid, "thirdparty_id" => self::$socid,
"fk_user_author" => NULL, "fk_user_author" => NULL,
"fk_user_valid" => NULL, "fk_user_valid" => NULL,
"date" => "2015-04-19 20:16:53", "date" => "2015-04-19 20:16:53",
@ -333,7 +338,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
"id" => NULL, "id" => NULL,
"ref" => NULL, "ref" => NULL,
"ref_ext" => "ref-phpunit-2", "ref_ext" => "ref-phpunit-2",
"thirdparty_id" => $this->socid, "thirdparty_id" => self::$socid,
"fk_user_author" => NULL, "fk_user_author" => NULL,
"fk_user_valid" => NULL, "fk_user_valid" => NULL,
"date" => "2015-04-19 20:16:53", "date" => "2015-04-19 20:16:53",