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

This commit is contained in:
Juanjo Menent 2016-12-10 09:16:20 +01:00
commit 0c1e754b91
270 changed files with 11684 additions and 1829 deletions

121
ChangeLog
View File

@ -15,7 +15,126 @@ make a Dolibarr upgrade.
***** ChangeLog for 5.0.0 compared to 4.0.* ***** ***** ChangeLog for 5.0.0 compared to 4.0.* *****
For users: For users:
... NEW: Add module mulicurrency.
NEW: Add module accoutancy expert (double party accountancy).
NEW: Better responsive design, above all on smartphone.
NEW: #5801 More complete change to allow to disable supplier invoice document generation.
NEW: #5830 Can choose a generic email or use remail in the mail from field.
NEW: #5896 More complete data on event sent by email (name in title, emails list in details)
NEW: Add a better icon to show when "run" in cron jobs is disabled.
NEW: Add account statement into fields of bank account transaction list.
NEW: Add a direct debit mandate PDF template.
NEW: add clone contract feature.
NEW: Add color regarding stock even on ajax autocompleter product selector.
NEW: Add date into list of print jobs for Google Print.
NEW: add field and filters on turnover by third party report.
NEW: Add last activation date as info in module list.
NEW: add option to limit stock product by warehouse.
NEW: Add missing unique key on table llx_links.
NEW: Add option "Hide images in Top menu".
NEW: Add option PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY to show thirdparty on page to submit time.
NEW: Add option "Stock can be negative". Off by default.
NEW: Add option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED.
NEW: Add hidden option to include parent products too in stats of orders (not supported in rest of app yet).
NEW: Add Panama datas.
NEW: Add ressource extrafields.
NEW: add restrictions on standard exports (agenda, order, deplacement, facture, fournisseur, societe, propal, expedition)
NEW: Add substitution keys __SHIPPINGTRACKNUM__, __SHIPPINGTRACKNUMURL__ into shipping email template.
NEW: Add status Done on interventions.
NEW: Add system tool "Files integrity checker" to detect modified files for packaged versions.
NEW: Add tooltip in payment term edition in dictionnary.
NEW: Add type "url" as possible extrafield.
NEW: Add workflow to calculated supplier order status on stock dispatch.
NEW: Add workflow to classifed propal bill on invoice validation.
NEW: allow to save a parent warehouse.
NEW: Better filtering of automatic/manually inserted events.
NEW: Bill orders from order list.
NEW: Can add event from the card listing events.
NEW: Can change thirdparty when cloning a project.
NEW: Can create expense report for someone else (advanced permission).
NEW: Can clone an expense report.
NEW: Can edit a label for each price segment when using several segment prices for products.
NEW: Can filter on fields on admin translation page.
NEW: Can filter on project/task ref/label on the "new time consumed" page.
NEW: Can filter on status on objects on the "statistics" pages.
NEW: Can filter on type of leave requests in list.
NEW: Can generate SEPA mandate for each bank account of your customers.
NEW: Can see/make bank conciliation from bank transaction list.
NEW: Can edit RUM number of a customer bank account.
NEW: Can link template invoice to other objects. Generated invoices will be linked to same objects (example: contracts).
NEW: Can renamed attached files on some documents tabs (like products and expense reports).
NEW: Can see/edit the customer ref of a shipment.
NEW: Can select fields/extrafields on contract list + Mass delete action.
NEW: Can select fields on expense report list. Can make mass delete.
NEW: Can select fields to show on list of bank transaction.
NEW: Can set to paid automatically social or fiscal taxes after a payment was recorded.
NEW: Can sort on status of recurring invoice in list of template invoices.
NEW: Can use native php and dolibarr object on pages of module website.
NEW: Checkbox 'close order to "Everything received" automatically if all products are received' is visible on supplier orders.
NEW: conf to allow payments on different thirdparties bills but same parent company.
NEW: Consumption view on thirdparty total line and total HT by element.
NEW: Display bookkeeping by accounting account - Bookkeeping ordered by accounting account - Link with customers and suppliers invoices - Sub Total by accounting account - Ability to display more than 25 lines and filter by customer/supplier, invoice and accounting account
NEW: Each user can select its landing page (on tab "user display setup").
NEW: Editing translation GUI become easier with tool to search existing translation.
NEW: Error code of each email sent is visible in list of email targets
NEW: Export thirdparty with payment terms and mode.
NEW: filter actiontype on thirdparty tab.
NEW: filter by supplier and fk_warehouse on replenishment page.
NEW: Filters can accept generic search key like __DAY__, __MONTH__, __YEAR__ replaced with current day, month year before making the search.
NEW: Function "crop" images available on project, product and holiday attachment tab.
NEW: function to display full path to current warehouse.
NEW: Generation of document is available on member card.
NEW: Introduce mass action "delete" on sales orders.
NEW: Introduce option MAIN_DEFAULT_PAYMENT_TERM_ID to set default payment term on company level.
NEW: introduce option PROJECT_DISABLE_PRIVATE_PROJECT and PROJECT_DISABLE_PUBLIC_PROJECT.
NEW: Link between objects can be done on both side and on all objects.
NEW: More filter on bank transaction list.
NEW: Mutualize mass action. So "Send by email" is also available on orders.
NEW: New set of icon for status easier to understand.
NEW: option "Current/Next" for limit payment date (in payment term dictionary setup) to use a specific day of current month or jump to same day of next month.
NEW: Option DOC_SHOW_FIRST_SALES_REP shows name of "user buyer or saler" on PDF.
NEW: Option MAIN_INFO_SOCIETE_MAIL_ALIASES to be able to use several identities into the "email from".
NEW: Pagination available on list of users.
NEW: Phone formatting for Canada. Add dol_print_phone into phpunit tests.
NEW: Reduce nb of picto visible after reference of an object into lists, merging preview and download.
NEW: Reduce space lost on EDM module.
NEW: Reopen a paid bill is a user advanced permission.
NEW: can set a default bank account on thirdparty card.
NEW: Show photo of contacts on thirdparty card.
NEW: Show subtotal into list of linked elements.
NEW: Show total line (planned workload and time spent) on list of tasks.
NEW: Start to introduce search filters on dictionnaries for vat list.
NEW: Support extrafields for expense reports.
NEW: Support extrafields on product lot.
NEW: Support free bottom text and watermark on expense report template.
NEW: Support mass actions for proposals
NEW: Table with list of lots/serial can be viewed (module product batch).
NEW: The autofill zip/town table option is on by default.
NEW: the count of linked files on card includes external links.
NEW: Usage of vat code seems ok everywhere.
NEW: User date of employment added.
NEW: Use small photo of user on all user links.
NEW: Use new archi to select fields into list of time spent.
NEW: Available substitution key (__INVOICE_MONTH__, __INVOICE_PREVIOUS_MONTH__, ...) to use into note text of recurring invoices.
For developers:
NEW: Add ORDER_MODIFY trigger on each order modification.
NEW: Trigger on delete stock
NEW: The getURLContent return more information on success and error.
NEW: Uniformize code and correct deal with triggers
NEW: REST API explorer. Can create invoice and orders with lines.
NEW: Add a lot of API REST: expense reports, orders, commercial proposals, projects, agenda events, users, invoices, ...
NEW: Default collation for mysql is now utf8_unicode_ci
NEW: Can use any filter on all REST API to list.
NEW: ckeditor accept a parameter to disable all html filtering.
NEW: Complete table llx_ecm_files with field generated_or_uploaded
NEW: Enhance function setValueFrom so we can use it for "edit in form" feature.
NEW: getNomUrl displays full path to warehouse
NEW: Hook formObjectOptions
NEW: hook in element overview
NEW: Hook on stock product card
NEW: param socid find_min_price_product_fournisseur() function
NEW: More phpunit tests
WARNING: WARNING:

View File

@ -12,6 +12,7 @@ beta version of Dolibarr, step by step.
To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
- To know number of lines changes: git diff --shortstat A B
- Update version number with x.y.z-w in htdocs/filefunc.inc.php - Update version number with x.y.z-w in htdocs/filefunc.inc.php
- Commit all changes. - Commit all changes.
@ -35,6 +36,7 @@ complete release of Dolibarr, step by step.
To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a major new version x.y.0 (from develop repo), you can do "cd ~/git/dolibarr; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent develop) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a major new version x.y.0 (from x.y repo), you can do "cd ~/git/dolibarr_x.y; git log `diff -u <(git rev-list --first-parent x.(y-1).0) <(git rev-list --first-parent x.y.0) | sed -ne 's/^ //p' | head -1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa" To generate a changelog of a maintenance version x.y.z, you can do "cd ~/git/dolibarr_x.y; git log x.y.z-1.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^FIX\|NEW' | sort -u | sed 's/FIXED:/FIX:/g' | sed 's/FIXED :/FIX:/g' | sed 's/FIX :/FIX:/g' | sed 's/FIX /FIX: /g' | sed 's/NEW :/NEW:/g' | sed 's/NEW /NEW: /g' > /tmp/aaa"
- To know number of lines changes: git diff --shortstat A B
- Update version number with x.y.z in htdocs/filefunc.inc.php - Update version number with x.y.z in htdocs/filefunc.inc.php
- Commit all changes. - Commit all changes.

View File

@ -64,7 +64,7 @@ class modMyModule extends DolibarrModules
$this->description = "Description of module MyModule"; $this->description = "Description of module MyModule";
$this->descriptionlong = "A very long description. Can be a full HTML content"; $this->descriptionlong = "A very long description. Can be a full HTML content";
$this->editor_name = 'Editor name'; $this->editor_name = 'Editor name';
$this->editor_url = 'http://www.dolibarr.org'; $this->editor_url = 'https://www.dolibarr.org';
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = '1.0'; $this->version = '1.0';

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Jean-François Ferry <jfefe@aternatik.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

View File

@ -190,14 +190,14 @@ class BookKeeping extends CommonObject
if ($resql) { if ($resql) {
$row = $this->db->fetch_object($resql); $row = $this->db->fetch_object($resql);
if ($row->nb == 0) { if ($row->nb == 0)
{
// Determine piece_num // Determine piece_num
$sqlnum = "SELECT piece_num"; $sqlnum = "SELECT piece_num";
$sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; // For example doc_type = 'bank'
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ...
$sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; // ref of source object
$sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
@ -276,13 +276,13 @@ class BookKeeping extends CommonObject
$this->id = $id; $this->id = $id;
$result = 0; $result = 0;
} else { } else {
$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__ . ' ' . join(',', $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__ . ' ' . join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
@ -290,11 +290,11 @@ class BookKeeping extends CommonObject
} else { // Already exists } else { // Already exists
$result = -3; $result = -3;
$error++; $error++;
$this->errors[] = 'Error Transaction for ('.$this->doc_type.', '.$this->doc_ref.', '.$this->fk_docdet.') were already recorded'; $this->error='BookkeepingRecordAlreadyExists';
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_WARNING); dol_syslog(__METHOD__ . ' ' . $this->error, LOG_WARNING);
} }
} else { } else {
$result = - 5; $result = -5;
$error ++; $error ++;
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
@ -316,11 +316,9 @@ class BookKeeping extends CommonObject
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
$this->db->rollback(); $this->db->rollback();
return -1 * $error;
return - 1 * $error;
} else { } else {
$this->db->commit(); $this->db->commit();
return $result; return $result;
} }
} }

View File

@ -153,7 +153,8 @@ if ($result) {
// one line for bank jounral = tabbq // one line for bank jounral = tabbq
// one line for thirdparty journal = tabtp // one line for thirdparty journal = tabtp
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num )
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// Set accountancy code (for bank and thirdparty) // Set accountancy code (for bank and thirdparty)
@ -314,7 +315,8 @@ if (! $error && $action == 'writebookkeeping') {
if (! $errorforline) if (! $errorforline)
{ {
// Line into bank account // Line into bank account
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt )
{
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -363,12 +365,21 @@ if (! $error && $action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{
$error++;
$errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
} }
} }
} }
}
// Third party // Third party
if (! $errorforline) if (! $errorforline)
@ -463,16 +474,6 @@ if (! $error && $action == 'writebookkeeping') {
$action = ''; $action = '';
} }
/*
* View
*/
$form = new Form($db);
// Export // Export
if ($action == 'export_csv') { if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
@ -633,6 +634,15 @@ if ($action == 'export_csv') {
} }
} }
/*
* View
*/
$form = new Form($db);
if (empty($action) || $action == 'view') { if (empty($action) || $action == 'view') {
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
$invoicesupplierstatic = new FactureFournisseur($db); $invoicesupplierstatic = new FactureFournisseur($db);
@ -689,7 +699,8 @@ if (empty($action) || $action == 'view') {
print "<td>" . $langs->trans("AccountAccounting") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("Type") . "</td>"; print "<td>" . $langs->trans("Type") . "</td>";
print "<td>" . $langs->trans("PaymentMode") . "</td>"; print "<td>" . $langs->trans("PaymentMode") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td>";
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n"; print "</tr>\n";
$var = true; $var = true;
@ -721,7 +732,7 @@ if (empty($action) || $action == 'view') {
$sqlmid = 'SELECT payfac.fk_facture as id'; $sqlmid = 'SELECT payfac.fk_facture as id';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac";
$sqlmid .= " WHERE payfac.fk_paiement=" . $val["paymentid"]; $sqlmid .= " WHERE payfac.fk_paiement=" . $val["paymentid"];
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
@ -735,7 +746,7 @@ if (empty($action) || $action == 'view') {
$sqlmid = 'SELECT payfac.fk_facturefourn as id'; $sqlmid = 'SELECT payfac.fk_facturefourn as id';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac";
$sqlmid .= " WHERE payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; $sqlmid .= " WHERE payfac.fk_paiementfourn=" . $val["paymentsupplierid"];
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
@ -750,8 +761,8 @@ if (empty($action) || $action == 'view') {
$invoicestatic->ref = $val["ref"]; $invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];*/ $invoicestatic->type = $val["type"];*/
// Bank // Bank
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt )
{
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";
print "<td><!-- Bank bank.rowid=".$key."--></td>"; print "<td><!-- Bank bank.rowid=".$key."--></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
@ -809,7 +820,7 @@ if (empty($action) || $action == 'view') {
{ {
print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
} }
else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE);
print "</td>"; print "</td>";
print "<td>" . $reflabel . "</td>"; print "<td>" . $reflabel . "</td>";
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";

View File

@ -83,6 +83,9 @@ class Adherent extends CommonObject
var $datevalid; var $datevalid;
var $birth; var $birth;
var $note_public;
var $note_private;
var $typeid; // Id type adherent var $typeid; // Id type adherent
var $type; // Libelle type adherent var $type; // Libelle type adherent
var $need_subscription; var $need_subscription;
@ -411,6 +414,8 @@ class Adherent extends CommonObject
$this->state_id=($this->state_id > 0?$this->state_id:$this->state_id); $this->state_id=($this->state_id > 0?$this->state_id:$this->state_id);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname)); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname));
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname)); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname));
$this->note_public=($this->note_public?$this->note_public:$this->note_public);
$this->note_private=($this->note_private?$this->note_private:$this->note_private);
// Check parameters // Check parameters
if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email))
@ -440,7 +445,7 @@ class Adherent extends CommonObject
$sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
$sql.= ", phone_mobile=" .($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null"); $sql.= ", phone_mobile=" .($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null");
$sql.= ", note_private=" .($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", note_private=" .($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", note_public=" .($this->note_private?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", note_public=" .($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", photo=" .($this->photo?"'".$this->photo."'":"null"); $sql.= ", photo=" .($this->photo?"'".$this->photo."'":"null");
$sql.= ", public='".$this->public."'"; $sql.= ", public='".$this->public."'";
$sql.= ", statut=" .$this->statut; $sql.= ", statut=" .$this->statut;

View File

@ -143,7 +143,7 @@ class Members extends DolibarrApi
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve member list : '.$member->error); throw new RestException(503, 'Error when retrieve member list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No member found'); throw new RestException(404, 'No member found');
@ -289,9 +289,6 @@ class Members extends DolibarrApi
* *
* @param object $object Object to clean * @param object $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
*
* @todo use an array for properties to clean
*
*/ */
function _cleanObjectDatas($object) { function _cleanObjectDatas($object) {

View File

@ -135,7 +135,7 @@ class Subscriptions extends DolibarrApi
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve subscription list : '.$subscription->error); throw new RestException(503, 'Error when retrieve subscription list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No Subscription found'); throw new RestException(404, 'No Subscription found');

View File

@ -306,12 +306,12 @@ if ($action == 'edit' || $action == 'updateedit')
$var=true; $var=true;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th width="35%">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n"; print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
// Name // Name
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>'; print '<tr '.$bc[$var].'><td class="fieldrequired"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" size="30" value="'. ($conf->global->MAIN_INFO_SOCIETE_NOM?$conf->global->MAIN_INFO_SOCIETE_NOM:$_POST["nom"]) . '" autofocus="autofocus"></td></tr>'."\n"; print '<input name="nom" id="name" class="minwidth200" value="'. ($conf->global->MAIN_INFO_SOCIETE_NOM?$conf->global->MAIN_INFO_SOCIETE_NOM:$_POST["nom"]) . '" autofocus="autofocus"></td></tr>'."\n";
// Addresse // Addresse
$var=!$var; $var=!$var;
@ -320,11 +320,11 @@ if ($action == 'edit' || $action == 'updateedit')
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><label for="zipcode">'.$langs->trans("CompanyZip").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="zipcode">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input name="zipcode" id="zipcode" value="'. ($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP:$_POST["zipcode"]) . '" size="10"></td></tr>'."\n"; print '<input class="minwidth100" name="zipcode" id="zipcode" value="'. ($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP:$_POST["zipcode"]) . '"></td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><label for="town">'.$langs->trans("CompanyTown").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="town">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="town" id="town" size="30" value="'. ($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN:$_POST["town"]) . '"></td></tr>'."\n"; print '<input name="town" class="minwidth100" id="town" value="'. ($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN:$_POST["town"]) . '"></td></tr>'."\n";
// Country // Country
$var=!$var; $var=!$var;
@ -356,20 +356,20 @@ if ($action == 'edit' || $action == 'updateedit')
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><label for="email">'.$langs->trans("EMail").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
print '<input name="mail" id="email" size="60" value="'. $conf->global->MAIN_INFO_SOCIETE_MAIL . '"></td></tr>'; print '<input name="mail" id="email" class="minwidth200" value="'. $conf->global->MAIN_INFO_SOCIETE_MAIL . '"></td></tr>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
// Web // Web
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><label for="web">'.$langs->trans("Web").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
print '<input name="web" id="web" size="60" value="'. $conf->global->MAIN_INFO_SOCIETE_WEB . '"></td></tr>'; print '<input name="web" id="web" class="minwidth300" value="'. $conf->global->MAIN_INFO_SOCIETE_WEB . '"></td></tr>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
// Barcode // Barcode
if (! empty($conf->barcode->enabled)) { if (! empty($conf->barcode->enabled)) {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td><label for="barcode">'.$langs->trans("Gencod").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
print '<input name="barcode" id="barcode" size="40" value="'. $conf->global->MAIN_INFO_SOCIETE_GENCOD . '"></td></tr>'; print '<input name="barcode" id="barcode" class="minwidth150" value="'. $conf->global->MAIN_INFO_SOCIETE_GENCOD . '"></td></tr>';
print '</td></tr>'; print '</td></tr>';
} }
@ -377,7 +377,7 @@ if ($action == 'edit' || $action == 'updateedit')
$var=!$var; $var=!$var;
print '<tr'.dol_bc($var,'hideonsmartphone').'><td><label for="logo">'.$langs->trans("Logo").' (png,jpg)</label></td><td>'; print '<tr'.dol_bc($var,'hideonsmartphone').'><td><label for="logo">'.$langs->trans("Logo").' (png,jpg)</label></td><td>';
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
print '<input type="file" class="flat" name="logo" id="logo" size="50">'; print '<input type="file" class="flat class=minwidth200" name="logo" id="logo">';
print '</td><td class="nocellnopadd" valign="middle" align="right">'; print '</td><td class="nocellnopadd" valign="middle" align="right">';
if (! empty($mysoc->logo_mini)) { if (! empty($mysoc->logo_mini)) {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete")).'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete")).'</a>';
@ -393,7 +393,7 @@ if ($action == 'edit' || $action == 'updateedit')
// Note // Note
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td valign="top"><label for="note">'.$langs->trans("Note").'</label></td><td>'; print '<tr '.$bc[$var].'><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? $conf->global->MAIN_INFO_SOCIETE_NOTE : '').'</textarea></td></tr>'; print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? $conf->global->MAIN_INFO_SOCIETE_NOTE : '').'</textarea></td></tr>';
print '</td></tr>'; print '</td></tr>';
@ -410,13 +410,13 @@ if ($action == 'edit' || $action == 'updateedit')
// Managing Director(s) // Managing Director(s)
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" size="80" value="' . $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '"></td></tr>'; print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth200" value="' . $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '"></td></tr>';
// Capital // Capital
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="capital">'.$langs->trans("Capital").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
print '<input name="capital" id="capital" size="20" value="' . $conf->global->MAIN_INFO_CAPITAL . '"></td></tr>'; print '<input name="capital" id="capital" class="minwidth100" value="' . $conf->global->MAIN_INFO_CAPITAL . '"></td></tr>';
// Juridical Status // Juridical Status
$var=!$var; $var=!$var;
@ -432,10 +432,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="profid1">'.$langs->transcountry("ProfId1",$mysoc->country_code).'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="profid1">'.$langs->transcountry("ProfId1",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="siren" id="profid1" size="20" value="' . (! empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '') . '">'; print '<input name="siren" id="profid1" class="minwidth200" value="' . (! empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '') . '">';
} }
else else
{ {
@ -448,10 +448,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="profid2">'.$langs->transcountry("ProfId2",$mysoc->country_code).'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="profid2">'.$langs->transcountry("ProfId2",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="siret" id="profid2" size="20" value="' . (! empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '' ) . '">'; print '<input name="siret" id="profid2" class="minwidth200" value="' . (! empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '' ) . '">';
} }
else else
{ {
@ -464,10 +464,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="profid3">'.$langs->transcountry("ProfId3",$mysoc->country_code).'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="profid3">'.$langs->transcountry("ProfId3",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="ape" id="profid3" size="20" value="' . (! empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '') . '">'; print '<input name="ape" id="profid3" class="minwidth200" value="' . (! empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '') . '">';
} }
else else
{ {
@ -480,10 +480,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="profid4">'.$langs->transcountry("ProfId4",$mysoc->country_code).'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="profid4">'.$langs->transcountry("ProfId4",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="rcs" id="profid4" size="20" value="' . (! empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '') . '">'; print '<input name="rcs" id="profid4" class="minwidth200" value="' . (! empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '') . '">';
} }
else else
{ {
@ -496,10 +496,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="profid5">'.$langs->transcountry("ProfId5",$mysoc->country_code).'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="profid5">'.$langs->transcountry("ProfId5",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="MAIN_INFO_PROFID5" id="profid5" size="20" value="' . (! empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '') . '">'; print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="' . (! empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '') . '">';
} }
else else
{ {
@ -512,10 +512,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="profid6">'.$langs->transcountry("ProfId6",$mysoc->country_code).'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="profid6">'.$langs->transcountry("ProfId6",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="MAIN_INFO_PROFID6" id="profid6" size="20" value="' . (! empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '') . '">'; print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="' . (! empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '') . '">';
} }
else else
{ {
@ -526,13 +526,13 @@ if ($action == 'edit' || $action == 'updateedit')
// TVA Intra // TVA Intra
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
print '<input name="tva" id="intra_vat" size="20" value="' . (! empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '') . '">'; print '<input name="tva" id="intra_vat" class="minwidth200" value="' . (! empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '') . '">';
print '</td></tr>'; print '</td></tr>';
// Object of the company // Object of the company
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="object">'.$langs->trans("CompanyObject").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="object">'.$langs->trans("CompanyObject").'</label></td><td>';
print '<textarea class="flat quatrevingtpercent" name="object" id="object" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>'; print '<textarea class="flat quatrevingtpercent" name="object" id="object" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
print '</td></tr>'; print '</td></tr>';
@ -543,12 +543,12 @@ if ($action == 'edit' || $action == 'updateedit')
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>'; print '<td class="titlefield">'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=true; $var=true;
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%"><label for="fiscalmonthstart">'.$langs->trans("FiscalMonthStart").'</label></td><td>'; print '<tr '.$bc[$var].'><td><label for="fiscalmonthstart">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',0,1) . '</td></tr>'; print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',0,1) . '</td></tr>';
print "</table>"; print "</table>";
@ -558,7 +558,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>'; print '<td class="titlefield">'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>';
print '<td align="right">&nbsp;</td>'; print '<td align="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
$var=true; $var=true;
@ -699,19 +699,19 @@ else
$var=true; $var=true;
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyName").'</td><td>'; print '<tr '.$bc[$var].'><td class="titlefield">'.$langs->trans("CompanyName").'</td><td>';
if (! empty($conf->global->MAIN_INFO_SOCIETE_NOM)) print $conf->global->MAIN_INFO_SOCIETE_NOM; if (! empty($conf->global->MAIN_INFO_SOCIETE_NOM)) print $conf->global->MAIN_INFO_SOCIETE_NOM;
else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyName")).'</font>'; else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyName")).'</font>';
print '</td></tr>'; print '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyAddress").'</td><td>' . nl2br(empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS) . '</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyAddress").'</td><td>' . nl2br(empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS) . '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyZip").'</td><td>' . (empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP) . '</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyZip").'</td><td>' . (empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP) . '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyTown").'</td><td>' . (empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN) . '</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyTown").'</td><td>' . (empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN) . '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCountry").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCountry").'</td><td>';
@ -731,7 +731,7 @@ else
print '</td></tr>'; print '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyCurrency").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCurrency").'</td><td>';
print currency_name($conf->currency,1); print currency_name($conf->currency,1);
print ' ('.$conf->currency; print ' ('.$conf->currency;
print ($conf->currency != $langs->getCurrencySymbol($conf->currency) ? ' - '.$langs->getCurrencySymbol($conf->currency) : ''); print ($conf->currency != $langs->getCurrencySymbol($conf->currency) ? ' - '.$langs->getCurrencySymbol($conf->currency) : '');
@ -739,52 +739,54 @@ else
print '</td></tr>'; print '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Phone").'</td><td>' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_TEL,$mysoc->country_code) . '</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("Phone").'</td><td>' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_TEL,$mysoc->country_code) . '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Fax").'</td><td>' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_FAX,$mysoc->country_code) . '</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("Fax").'</td><td>' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_FAX,$mysoc->country_code) . '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Mail").'</td><td>' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL,0,0,0,80) . '</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("Mail").'</td><td>' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL,0,0,0,80) . '</td></tr>';
// Web // Web
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Web").'</td><td>' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB,'_blank',80) . '</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("Web").'</td><td>' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB,'_blank',80) . '</td></tr>';
// Barcode // Barcode
if (! empty($conf->barcode->enabled)) if (! empty($conf->barcode->enabled))
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Gencod").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("Gencod").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '</td></tr>';
} }
// Logo // Logo
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Logo").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("Logo").'</td><td>';
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; $tagtd='tagtd ';
if ($conf->browser->layout == 'phone') $tagtd='';
print '<div class="tagtable centpercent"><div class="tagtr inline-block centpercent valignmiddle"><div class="'.$tagtd.'inline-block valignmiddle left">';
print $mysoc->logo; print $mysoc->logo;
print '</td><td class="nocellnopadd" valign="center" align="right">'; print '</div><div class="'.$tagtd.'inline-block valignmiddle left">';
// It offers the generation of the thumbnail if it does not exist // It offers the generation of the thumbnail if it does not exist
if (!is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini) && preg_match('/(\.jpg|\.jpeg|\.png)$/i',$mysoc->logo)) if (!is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini) && preg_match('/(\.jpg|\.jpeg|\.png)$/i',$mysoc->logo))
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=addthumb&amp;file='.urlencode($mysoc->logo).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'</a>&nbsp;&nbsp;'; print '<a class="img_logo" href="'.$_SERVER["PHP_SELF"].'?action=addthumb&amp;file='.urlencode($mysoc->logo).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'</a>&nbsp;&nbsp;';
} }
else if ($mysoc->logo_mini && is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) else if ($mysoc->logo_mini && is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
{ {
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&amp;file='.urlencode('/thumbs/'.$mysoc->logo_mini).'">'; print '<img class="img_logo" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&amp;file='.urlencode('/thumbs/'.$mysoc->logo_mini).'">';
} }
else else
{ {
print '<img height="30" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">'; print '<img class="img_logo" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
} }
print '</td></tr></table>'; print '</div></div></div>';
print '</td></tr>'; print '</td></tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%" valign="top">'.$langs->trans("Note").'</td><td>' . (! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) : '') . '</td></tr>'; print '<tr '.$bc[$var].'><td valign="top">'.$langs->trans("Note").'</td><td>' . (! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) : '') . '</td></tr>';
print '</table>'; print '</table>';
@ -796,22 +798,22 @@ else
print '<form name="formsoc" method="post">'; print '<form name="formsoc" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
$var=true; $var=true;
// Managing Director(s) // Managing Director(s)
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ManagingDirectors").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("ManagingDirectors").'</td><td>';
print $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '</td></tr>'; print $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '</td></tr>';
// Capital // Capital
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Capital").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("Capital").'</td><td>';
print $conf->global->MAIN_INFO_CAPITAL . '</td></tr>'; print $conf->global->MAIN_INFO_CAPITAL . '</td></tr>';
// Juridical Status // Juridical Status
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("JuridicalStatus").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("JuridicalStatus").'</td><td>';
print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE); print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE);
print '</td></tr>'; print '</td></tr>';
@ -819,7 +821,7 @@ else
if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId1",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->transcountry("ProfId1",$mysoc->country_code).'</td><td>';
if (! empty($conf->global->MAIN_INFO_SIREN)) if (! empty($conf->global->MAIN_INFO_SIREN))
{ {
print $conf->global->MAIN_INFO_SIREN; print $conf->global->MAIN_INFO_SIREN;
@ -835,7 +837,7 @@ else
if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId2",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->transcountry("ProfId2",$mysoc->country_code).'</td><td>';
if (! empty($conf->global->MAIN_INFO_SIRET)) if (! empty($conf->global->MAIN_INFO_SIRET))
{ {
print $conf->global->MAIN_INFO_SIRET; print $conf->global->MAIN_INFO_SIRET;
@ -851,7 +853,7 @@ else
if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId3",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->transcountry("ProfId3",$mysoc->country_code).'</td><td>';
if (! empty($conf->global->MAIN_INFO_APE)) if (! empty($conf->global->MAIN_INFO_APE))
{ {
print $conf->global->MAIN_INFO_APE; print $conf->global->MAIN_INFO_APE;
@ -867,7 +869,7 @@ else
if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId4",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->transcountry("ProfId4",$mysoc->country_code).'</td><td>';
if (! empty($conf->global->MAIN_INFO_RCS)) if (! empty($conf->global->MAIN_INFO_RCS))
{ {
print $conf->global->MAIN_INFO_RCS; print $conf->global->MAIN_INFO_RCS;
@ -883,7 +885,7 @@ else
if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId5",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->transcountry("ProfId5",$mysoc->country_code).'</td><td>';
if (! empty($conf->global->MAIN_INFO_PROFID5)) if (! empty($conf->global->MAIN_INFO_PROFID5))
{ {
print $conf->global->MAIN_INFO_PROFID5; print $conf->global->MAIN_INFO_PROFID5;
@ -899,7 +901,7 @@ else
if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId6",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->transcountry("ProfId6",$mysoc->country_code).'</td><td>';
if (! empty($conf->global->MAIN_INFO_PROFID6)) if (! empty($conf->global->MAIN_INFO_PROFID6))
{ {
print $conf->global->MAIN_INFO_PROFID6; print $conf->global->MAIN_INFO_PROFID6;
@ -950,7 +952,7 @@ else
print '</tr>'; print '</tr>';
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%" valign="top">'.$langs->trans("CompanyObject").'</td><td>' . (! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? nl2br($conf->global->MAIN_INFO_SOCIETE_OBJECT) : '') . '</td></tr>'; print '<tr '.$bc[$var].'><td valign="top">'.$langs->trans("CompanyObject").'</td><td>' . (! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? nl2br($conf->global->MAIN_INFO_SOCIETE_OBJECT) : '') . '</td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
@ -961,12 +963,12 @@ else
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>'; print '<td class="titlefield">'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=true; $var=true;
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FiscalMonthStart").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("FiscalMonthStart").'</td><td>';
$monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1; $monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1;
print dol_print_date(dol_mktime(12,0,0,$monthstart,1,2000,1),'%B','gm') . '</td></tr>'; print dol_print_date(dol_mktime(12,0,0,$monthstart,1,2000,1),'%B','gm') . '</td></tr>';

View File

@ -39,6 +39,7 @@ $langs->load("products");
$langs->load("members"); $langs->load("members");
$langs->load("projects"); $langs->load("projects");
$langs->load("hrm"); $langs->load("hrm");
$langs->load("agenda");
if (! $user->admin) accessforbidden(); if (! $user->admin) accessforbidden();

View File

@ -81,9 +81,6 @@ class DolibarrApi
* *
* @param object $object Object to clean * @param object $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
*
* @todo use an array for properties to clean
*
*/ */
function _cleanObjectDatas($object) { function _cleanObjectDatas($object) {

View File

@ -54,7 +54,7 @@ class DictionnaryCountries extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param string $filter To filter the countries by name * @param string $filter To filter the countries by name
* @param string $lang Code of the language the label of the countries must be translated to * @param string $lang Code of the language the label of the countries must be translated to
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of countries * @return List of countries
* *
* @throws RestException * @throws RestException

View File

@ -47,7 +47,7 @@ class DictionnaryTowns extends DolibarrApi
* @param int $page Page number (starting from zero) * @param int $page Page number (starting from zero)
* @param string $zipcode To filter on zipcode * @param string $zipcode To filter on zipcode
* @param string $town To filter on city name * @param string $town To filter on city name
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of towns * @return List of towns
* *
* @throws RestException * @throws RestException

View File

@ -115,6 +115,10 @@ foreach ($modulesdir as $dir)
elseif ($module == 'stock') { elseif ($module == 'stock') {
$moduledirforclass = 'product/stock'; $moduledirforclass = 'product/stock';
} }
elseif ($module == 'fournisseur') {
$moduledirforclass = 'fourn';
}
//dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass);
// Defined if module is enabled // Defined if module is enabled
$enabled=true; $enabled=true;
@ -137,6 +141,8 @@ foreach ($modulesdir as $dir)
{ {
while (($file_searched = readdir($handle_part))!==false) while (($file_searched = readdir($handle_part))!==false)
{ {
if ($file_searched == 'api_access.class.php') continue;
// Support of the deprecated API. // Support of the deprecated API.
if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg)) if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg))
{ {
@ -144,19 +150,28 @@ foreach ($modulesdir as $dir)
require_once $dir_part.$file_searched; require_once $dir_part.$file_searched;
if (class_exists($classname)) if (class_exists($classname))
{ {
dol_syslog("Found deprecated API by index.php: classname=".$classname." into ".$dir." - ".$dir_part.$file_searched); //dol_syslog("Found deprecated API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
$api->r->addAPIClass($classname, '/'); $api->r->addAPIClass($classname, '/');
} }
else
{
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
}
} }
elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$reg)) elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$reg))
{ {
$classname = ucwords($reg[1]); $classname = ucwords($reg[1]);
$classname = str_replace('_', '', $classname);
require_once $dir_part.$file_searched; require_once $dir_part.$file_searched;
if (class_exists($classname)) if (class_exists($classname))
{ {
dol_syslog("Found API by index.php: classname=".$classname." into ".$dir." - ".$dir_part.$file_searched); //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
$listofapis[] = $classname; $listofapis[] = $classname;
} }
else
{
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
}
} }
} }
} }

View File

@ -157,7 +157,7 @@ class Categories extends DolibarrApi
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve category list : '.$category_static->error); throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No category found'); throw new RestException(404, 'No category found');
@ -243,7 +243,7 @@ class Categories extends DolibarrApi
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve category list : '.$category_static->error); throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No category found'); throw new RestException(404, 'No category found');
@ -346,9 +346,6 @@ class Categories extends DolibarrApi
* *
* @param Categorie $object Object to clean * @param Categorie $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
*
* @todo use an array for properties to clean
*
*/ */
function _cleanObjectDatas($object) { function _cleanObjectDatas($object) {

View File

@ -152,13 +152,13 @@ class CategoryApi extends DolibarrApi
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$category_static = new Categorie($db); $category_static = new Categorie($db);
if($category_static->fetch($obj->rowid)) { if($category_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($category_static); $obj_ret[] = $this->_cleanObjectDatas($category_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve category list : '.$category_static->error); throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No category found'); throw new RestException(404, 'No category found');
@ -233,13 +233,13 @@ class CategoryApi extends DolibarrApi
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$category_static = new Categorie($db); $category_static = new Categorie($db);
if($category_static->fetch($obj->rowid)) { if($category_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($category_static); $obj_ret[] = $this->_cleanObjectDatas($category_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve category list : '.$category_static->error); throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No category found'); throw new RestException(404, 'No category found');

View File

@ -102,13 +102,19 @@ class AgendaEvents extends DolibarrApi
$obj_ret = array(); $obj_ret = array();
// case of external user, $societe param is ignored and replaced by user's socid // case of external user
//$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; $socid = 0;
if (! empty(DolibarrApiAccess::$user->societe_id)) $socid = DolibarrApiAccess::$user->societe_id;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.id as rowid"; $sql = "SELECT t.id as rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
$sql.= ' WHERE t.entity IN ('.getEntity('agenda', 1).')'; $sql.= ' WHERE t.entity IN ('.getEntity('agenda', 1).')';
if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")";
if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid;
// Insert sale filter // Insert sale filter
if ($search_sale > 0) if ($search_sale > 0)
{ {
@ -146,13 +152,13 @@ class AgendaEvents extends DolibarrApi
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$actioncomm_static = new ActionComm($db); $actioncomm_static = new ActionComm($db);
if($actioncomm_static->fetch($obj->rowid)) { if($actioncomm_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($actioncomm_static); $obj_ret[] = $this->_cleanObjectDatas($actioncomm_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve Agenda Event list'); throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No Agenda Event found'); throw new RestException(404, 'No Agenda Event found');

View File

@ -385,7 +385,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cf.fk_soc = s.rowid"; $sql.= " WHERE cf.fk_soc = s.rowid";
$sql.= " AND cf.fk_statut = 0"; $sql.= " AND cf.fk_statut = 0";
$sql.= " AND cf.entity IN (".getEntity('commande_fournisseur', 1).")"; $sql.= " AND cf.entity IN (".getEntity('supplier_order', 1).")";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND cf.fk_soc = ".$socid; if ($socid) $sql.= " AND cf.fk_soc = ".$socid;

View File

@ -90,17 +90,19 @@ class Proposals extends DolibarrApi
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter commercial proposal of. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} * @param string $thirdparty_ids Thirdparty ids to filter commercial proposal of. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of order objects * @return array Array of order objects
*/ */
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
// case of external user, $thirdpartyid param is ignored and replaced by user's socid
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
@ -150,13 +152,13 @@ class Proposals extends DolibarrApi
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$propal_static = new Propal($db); $propal_static = new Propal($db);
if($propal_static->fetch($obj->rowid)) { if($propal_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($propal_static); $obj_ret[] = $this->_cleanObjectDatas($propal_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve propal list'); throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No order found'); throw new RestException(404, 'No order found');

View File

@ -670,6 +670,7 @@ class Propal extends CommonObject
//Fetch current line from the database and then clone the object and set it in $oldline property //Fetch current line from the database and then clone the object and set it in $oldline property
$line = new PropaleLigne($this->db); $line = new PropaleLigne($this->db);
$line->fetch($rowid); $line->fetch($rowid);
$line->fetch_optionals(); // Fetch extrafields for oldcopy
$staticline = clone $line; $staticline = clone $line;

View File

@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$langs->load("facture"); $langs->load("facture");
$langs->load("orders"); $langs->load("orders");

View File

@ -32,12 +32,21 @@ $langs->load('propal');
$langs->load('compta'); $langs->load('compta');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
// Security check // Security check
if (! empty($user->societe_id)) $socid=$user->societe_id; if (! empty($user->societe_id)) $socid=$user->societe_id;
$result = restrictedArea($user, 'propal', $id); $result = restrictedArea($user, 'propal', $id);
$object = new Propal($db);
if (! $object->fetch($id, $ref) > 0)
{
dol_print_error($db);
exit;
}
/* /*
* View * View
@ -47,8 +56,6 @@ $form = new Form($db);
llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
$object = new Propal($db);
$object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$head = propal_prepare_head($object); $head = propal_prepare_head($object);
@ -112,7 +119,6 @@ print '<br>';
dol_print_object_info($object); dol_print_object_info($object);
print '</div>';
print '</div>'; print '</div>';
dol_fiche_end(); dol_fiche_end();

View File

@ -289,7 +289,7 @@ if ($sall) {
} }
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
if ($viewstatut <> '') if ($viewstatut != '' && $viewstatut != '-1')
{ {
$sql.= ' AND p.fk_statut IN ('.$viewstatut.')'; $sql.= ' AND p.fk_statut IN ('.$viewstatut.')';
} }
@ -538,7 +538,7 @@ if ($resql)
$moreforfilter.='<div class="divsearchfield">'; $moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
$moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
$moreforfilter.='</div>'; $moreforfilter.='</div>';
} }
$parameters=array(); $parameters=array();

View File

@ -1629,7 +1629,7 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
// Template to use by default // Template to use by default
print '<tr><td>' . $langs->trans('Model') . '</td>'; print '<tr><td>' . $langs->trans('DefaultModel') . '</td>';
print '<td colspan="2">'; print '<td colspan="2">';
include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php'; include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php';
$liste = ModelePDFCommandes::liste_modeles($db); $liste = ModelePDFCommandes::liste_modeles($db);

View File

@ -115,6 +115,7 @@ class CommandeApi extends DolibarrApi
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT s.rowid"; $sql = "SELECT s.rowid";
@ -167,13 +168,13 @@ class CommandeApi extends DolibarrApi
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$commande_static = new Commande($db); $commande_static = new Commande($db);
if($commande_static->fetch($obj->rowid)) { if($commande_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($commande_static); $obj_ret[] = $this->_cleanObjectDatas($commande_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve commande list'); throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No commande found'); throw new RestException(404, 'No commande found');

View File

@ -94,15 +94,19 @@ class Orders extends DolibarrApi
* @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} * @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of order objects * @return array Array of order objects
*
* @throws RestException
*/ */
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
// case of external user, $thirdpartyid param is ignored and replaced by user's socid
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
@ -153,13 +157,13 @@ class Orders extends DolibarrApi
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$commande_static = new Commande($db); $commande_static = new Commande($db);
if($commande_static->fetch($obj->rowid)) { if($commande_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($commande_static); $obj_ret[] = $this->_cleanObjectDatas($commande_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve commande list'); throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No order found'); throw new RestException(404, 'No order found');

View File

@ -81,7 +81,8 @@ class CommandeStats extends Stats
$this->where.= " c.fk_statut > 2"; // Only approved & ordered $this->where.= " c.fk_statut > 2"; // Only approved & ordered
} }
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where.= " AND c.entity = ".$conf->entity; $this->where.= ' AND c.entity IN ('.getEntity('commande', 1).')';
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($this->socid) if ($this->socid)
{ {

View File

@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$langs->load("orders"); $langs->load("orders");
$langs->load("sendings"); $langs->load("sendings");
@ -139,69 +140,61 @@ if ($id > 0 || ! empty($ref))
if ($object->fetch($id, $ref) > 0) if ($object->fetch($id, $ref) > 0)
{ {
$soc = new Societe($db); $object->fetch_thirdparty();
$soc->fetch($object->socid);
$head = commande_prepare_head($object); $head = commande_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), 0, 'order'); dol_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), 0, 'order');
/* // Order card
* Facture synthese pour rappel
*/
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print "</td></tr>";
// Ref commande client $morehtmlref='<div class="refidno">';
print '<tr><td>'; // Ref customer
print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">'; $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
print $langs->trans('RefCustomer').'</td><td align="left">'; $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
print '</td>'; // Thirdparty
print '</tr></table>'; $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
print '</td><td colspan="3">'; // Project
print $object->ref_client; if (! empty($conf->projet->enabled))
print '</td>';
print '</tr>';
// Customer
if (is_null($object->thirdparty)) $object->fetch_thirdparty();
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
// Delivery address
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
{ {
print '<tr><td>'; $langs->load("projects");
print '<table class="nobordernopadding" width="100%"><tr><td>'; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
print $langs->trans('DeliveryAddress'); if ($user->rights->commande->creer)
print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdelivery_address')
{ {
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id); if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
} }
else } else {
{ if (! empty($object->fk_project)) {
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id); $proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
} }
print '</td></tr>';
} }
}
$morehtmlref.='</div>';
print "</table>"; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
print '</div>'; dol_fiche_end();
print '<br>'; print '<br>';
@ -215,7 +208,7 @@ if ($id > 0 || ! empty($ref))
} }
else else
{ {
// Contrat non trouve // Contact not found
print "ErrorRecordNotFound"; print "ErrorRecordNotFound";
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
@ -94,7 +94,6 @@ if ($id > 0 || ! empty($ref))
$head = commande_prepare_head($object); $head = commande_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), 0, 'order'); dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), 0, 'order');
// Construit liste des fichiers // Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0; $totalsize=0;
@ -103,22 +102,72 @@ if ($id > 0 || ! empty($ref))
$totalsize+=$file['size']; $totalsize+=$file['size'];
} }
// Order card
$linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
// Order card
$linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
// Ref
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print '</td></tr>';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print "</table>\n"; print "</table>\n";
print "</div>\n"; print "</div>\n";
print dol_fiche_end();
$modulepart = 'commande'; $modulepart = 'commande';
$permission = $user->rights->commande->creer; $permission = $user->rights->commande->creer;
$permtoedit = $user->rights->commande->creer; $permtoedit = $user->rights->commande->creer;

View File

@ -32,12 +32,21 @@ if (!$user->rights->commande->lire) accessforbidden();
$langs->load("orders"); $langs->load("orders");
$langs->load("sendings"); $langs->load("sendings");
// Security check
$socid=0; $socid=0;
$comid = GETPOST("id",'int'); $comid = GETPOST("id",'int');
$id = GETPOST("id",'int');
$ref=GETPOST('ref','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'commande',$comid,''); $result=restrictedArea($user,'commande',$comid,'');
$object = new Commande($db);
if (! $object->fetch($id, $ref) > 0)
{
dol_print_error($db);
exit;
}
/* /*
@ -46,21 +55,76 @@ $result=restrictedArea($user,'commande',$comid,'');
llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
$commande = new Commande($db); $object->fetch_thirdparty();
$commande->fetch($comid); $object->info($object->id);
$commande->info($comid);
$soc = new Societe($db);
$soc->fetch($commande->socid);
$head = commande_prepare_head($commande); $soc = new Societe($db);
$soc->fetch($object->thirdparty->id);
$head = commande_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("CustomerOrder"), 0, 'order'); dol_fiche_head($head, 'info', $langs->trans("CustomerOrder"), 0, 'order');
// Order card
$linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';
dol_print_object_info($commande); dol_print_object_info($object);
print '</td></tr></table>'; print '</td></tr></table>';
print '</div>'; print '</div>';
dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* *
@ -48,6 +48,7 @@ $object = new Commande($db);
if (! $object->fetch($id, $ref) > 0) if (! $object->fetch($id, $ref) > 0)
{ {
dol_print_error($db); dol_print_error($db);
exit;
} }
$permissionnote=$user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php $permissionnote=$user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php
@ -77,38 +78,66 @@ if ($id > 0 || ! empty($ref))
dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), 0, 'order'); dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), 0, 'order');
print '<table class="border" width="100%">'; // Order card
$linkback = '<a href="'.DOL_URL_ROOT.'/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print "</td></tr>";
// Ref commande client $morehtmlref='<div class="refidno">';
print '<tr><td>'; // Ref customer
print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">'; $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
print $langs->trans('RefCustomer').'</td><td align="left">'; $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
print '</td>'; // Thirdparty
print '</tr></table>'; $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
print '</td><td colspan="3">'; // Project
print $object->ref_client; if (! empty($conf->projet->enabled))
print '</td>'; {
print '</tr>'; $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
// Customer
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$soc->getNomUrl(1).'</td></tr>';
print "</table>"; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
$cssclass="titlefield"; $cssclass="titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>'; print '</div>';
dol_fiche_end();
} }

View File

@ -898,7 +898,7 @@ if (empty($reshook))
} }
} }
// Standard or deposit or proforma invoice // Standard or deposit or proforma invoice, not from a Predefined template invoice
if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT || $_POST['type'] == Facture::TYPE_PROFORMA || ($_POST['type'] == Facture::TYPE_SITUATION && empty($_POST['situations']))) && GETPOST('fac_rec') <= 0) if (($_POST['type'] == Facture::TYPE_STANDARD || $_POST['type'] == Facture::TYPE_DEPOSIT || $_POST['type'] == Facture::TYPE_PROFORMA || ($_POST['type'] == Facture::TYPE_SITUATION && empty($_POST['situations']))) && GETPOST('fac_rec') <= 0)
{ {
if (GETPOST('socid', 'int') < 1) if (GETPOST('socid', 'int') < 1)
@ -2075,6 +2075,8 @@ if ($action == 'create')
} }
print '</tr>' . "\n"; print '</tr>' . "\n";
$exampletemplateinvoice=new FactureRec($db);
// Overwrite value if creation of invoice is from a predefined invoice // Overwrite value if creation of invoice is from a predefined invoice
if (empty($origin) && empty($originid) && GETPOST('fac_rec','int') > 0) if (empty($origin) && empty($originid) && GETPOST('fac_rec','int') > 0)
{ {
@ -2109,7 +2111,10 @@ if ($action == 'create')
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
print '<option value="' . $objp->rowid . '"'; print '<option value="' . $objp->rowid . '"';
if (GETPOST('fac_rec') == $objp->rowid) if (GETPOST('fac_rec') == $objp->rowid)
{
print ' selected'; print ' selected';
$exampletemplateinvoice->fetch(GETPOST('fac_rec'));
}
print '>' . $objp->titre . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')</option>'; print '>' . $objp->titre . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')</option>';
$i ++; $i ++;
} }
@ -2387,9 +2392,10 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
} }
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
// Date invoice // Date invoice
print '<tr><td class="fieldrequired">' . $langs->trans('DateInvoice') . '</td><td colspan="2">'; print '<tr><td class="fieldrequired">' . $langs->trans('DateInvoice') . '</td><td colspan="2">';
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
print $form->select_date($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1, 1); print $form->select_date($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1, 1);
print '</td></tr>'; print '</td></tr>';
@ -2474,9 +2480,39 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
} }
// Help of substitution key
$htmltext='';
if (GETPOST('fac_rec','int') > 0)
{
$dateexample=($datefacture ? $datefacture : $dateinvoice);
if (empty($dateexample)) $dateexample=dol_now();
$substitutionarray=array(
'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($exampletemplateinvoice->total_ht).')',
'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($exampletemplateinvoice->total_ttc).')',
'__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')',
'__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')',
'__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')',
'__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')',
'__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')',
'__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')',
'__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')',
'__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')',
'__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')'
);
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($substitutionarray as $key => $val)
{
$htmltext.=$key.' = '.$langs->trans($val).'<br>';
}
$htmltext.='</i>';
}
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>'; print '<td class="border tdtop">';
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext);
print '</td>';
print '<td valign="top" colspan="2">'; print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
@ -2485,7 +2521,9 @@ if ($action == 'create')
if (empty($user->societe_id)) if (empty($user->societe_id))
{ {
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>'; print '<td class="border tdtop">';
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext);
print '</td>';
print '<td valign="top" colspan="2">'; print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);

View File

@ -111,6 +111,7 @@ class InvoiceApi extends DolibarrApi
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $socid; $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $socid;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT s.rowid"; $sql = "SELECT s.rowid";
@ -165,13 +166,13 @@ class InvoiceApi extends DolibarrApi
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$invoice_static = new Facture($db); $invoice_static = new Facture($db);
if($invoice_static->fetch($obj->rowid)) { if($invoice_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($invoice_static); $obj_ret[] = $this->_cleanObjectDatas($invoice_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve invoice list'); throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No invoice found'); throw new RestException(404, 'No invoice found');

View File

@ -87,32 +87,35 @@ class Invoices extends DolibarrApi
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @param int $socid Filter list with thirdparty ID * @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i}
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of invoice objects * @return array Array of invoice objects
* *
* @throws RestException * @throws RestException
*/ */
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $socid=0, $status='', $sqlfilters = '') { function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $socid; // case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; $search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."facture as t"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('facture', 1).')'; $sql.= ' WHERE t.entity IN ('.getEntity('facture', 1).')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socid) $sql.= " AND t.fk_soc = ".$socid; if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Filter by status // Filter by status
@ -150,19 +153,20 @@ class Invoices extends DolibarrApi
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$i=0;
$num = $db->num_rows($result); $num = $db->num_rows($result);
while ($i < min($num, ($limit <= 0 ? $num : $limit))) while ($i < min($num, ($limit <= 0 ? $num : $limit)))
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$invoice_static = new Facture($db); $invoice_static = new Facture($db);
if($invoice_static->fetch($obj->rowid)) { if($invoice_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($invoice_static); $obj_ret[] = $this->_cleanObjectDatas($invoice_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve invoice list'); throw new RestException(503, 'Error when retrieve invoice list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No invoice found'); throw new RestException(404, 'No invoice found');
@ -255,7 +259,7 @@ class Invoices extends DolibarrApi
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
if( ! DolibarrApi::_checkAccessToResource('facture',$this->facture->id)) { if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@ -267,7 +271,7 @@ class Invoices extends DolibarrApi
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'Facture deleted' 'message' => 'Invoice deleted'
) )
); );
} }
@ -275,7 +279,7 @@ class Invoices extends DolibarrApi
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *
* @param array $data Datas to validate * @param array|null $data Datas to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException
@ -290,4 +294,5 @@ class Invoices extends DolibarrApi
} }
return $invoice; return $invoice;
} }
} }

View File

@ -296,6 +296,10 @@ class Facture extends CommonInvoice
$this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id; $this->mode_reglement_id = GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $_facrec->mode_reglement_id;
$this->fk_account = GETPOST('fk_account') > 0 ? GETPOST('fk_account') : $_facrec->fk_account; $this->fk_account = GETPOST('fk_account') > 0 ? GETPOST('fk_account') : $_facrec->fk_account;
// Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result
$this->total_ht = $_facrec->total_ht;
$this->total_ttc = $_facrec->total_ttc;
// Fields always coming from template // Fields always coming from template
$this->remise_absolue = $_facrec->remise_absolue; $this->remise_absolue = $_facrec->remise_absolue;
$this->remise_percent = $_facrec->remise_percent; $this->remise_percent = $_facrec->remise_percent;
@ -327,6 +331,39 @@ class Facture extends CommonInvoice
//$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1.
$result = $_facrec->setNextDate($next_date,1); $result = $_facrec->setNextDate($next_date,1);
} }
// Define lang of customer
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) $newlang=$this->thirdparty->default_lang; // for proposal, order, invoice, ...
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) $newlang=$this->default_lang; // for thirdparty
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$substitutionarray=array(
'__TOTAL_HT__' => price($this->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency_code),
'__TOTAL_TTC__' => price($this->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code),
'__INVOICE_PREVIOUS_MONTH__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'),
'__INVOICE_MONTH__' => dol_print_date($this->date, '%m'),
'__INVOICE_NEXT_MONTH__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'),
'__INVOICE_PREVIOUS_MONTH_TEXT__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'),
'__INVOICE_MONTH_TEXT__' => dol_print_date($this->date, '%B'),
'__INVOICE_NEXT_MONTH_TEXT__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'),
'__INVOICE_PREVIOUS_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'),
'__INVOICE_YEAR__' => dol_print_date($this->date, '%Y'),
'__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'),
);
$substitutionisok=true;
complete_substitutions_array($substitutionarray, $outputlangs);
$this->note_public=make_substitutions($this->note_public,$substitutionarray);
$this->note_private=make_substitutions($this->note_private,$substitutionarray);
} }
// Define due date if not already defined // Define due date if not already defined

View File

@ -37,6 +37,7 @@ if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
} }
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
$langs->load('bills'); $langs->load('bills');
$langs->load('compta'); $langs->load('compta');
@ -915,15 +916,53 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>';
print '</tr>'; print '</tr>';
// Note public $note_public=GETPOST('note_public')?GETPOST('note_public'):$object->note_public;
print '<tr><td>'.$langs->trans("NotePublic").'</td><td valign="top">'; $note_private=GETPOST('note_private')?GETPOST('note_private'):$object->note_private;
print '<textarea class="flat centpercent" name="note_public" wrap="soft" rows="'.ROWS_4.'"></textarea>';
print '</td></tr>';
// Note private // Help of substitution key
print '<tr><td>'.$langs->trans("NotePrivate").'</td><td valign="top">'; $substitutionarray=array(
print '<textarea class="flat centpercent" name="note_private" wrap="soft" rows="'.ROWS_4.'"></textarea>'; '__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')',
'__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')',
'__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')',
'__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')',
'__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')',
'__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')',
'__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')',
'__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')',
'__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')'
);
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($substitutionarray as $key => $val)
{
$htmltext.=$key.' = '.$langs->trans($val).'<br>';
}
$htmltext.='</i>';
// Public note
print '<tr>';
print '<td class="border tdtop">';
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext);
print '</td>';
print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
if (empty($user->societe_id))
{
print '<tr>';
print '<td class="border tdtop">';
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext);
print '</td>';
print '<td valign="top" colspan="2">';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
print '</td></tr>'; print '</td></tr>';
}
// Author // Author
print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>"; print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>";
@ -941,7 +980,7 @@ if ($action == 'create')
// Project // Project
if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0)
{ {
$projectid = $object->fk_project; $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project;
$langs->load('projects'); $langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td>'; print '<tr><td>' . $langs->trans('Project') . '</td><td>';
$numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0);
@ -970,7 +1009,7 @@ if ($action == 'create')
// Frequency // Frequency
print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>"; print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='5' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m'));
print "</td></tr>"; print "</td></tr>";
// First date of execution for cron // First date of execution for cron
@ -1131,21 +1170,6 @@ else
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref
/*
print '<tr><td class="titlefield">';
//print $langs->trans('Ref');
print $form->editfieldkey($langs->trans("Ref"), 'ref', $object->ref, $object, $user->rights->facture->creer);
print '</td>';
print '<td colspan="3">';
$morehtmlref = $form->editfieldval($langs->trans("Ref"), 'ref', $object->ref, $object, $user->rights->facture->creer, 'string');
print $form->showrefnav($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Customer").'</td>';
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1,'customer').'</td></tr>';
*/
print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td colspan="3">'.$author->getFullName($langs)."</td></tr>"; print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td colspan="3">'.$author->getFullName($langs)."</td></tr>";
print '<tr><td>'.$langs->trans("AmountHT").'</td>'; print '<tr><td>'.$langs->trans("AmountHT").'</td>';
@ -1200,9 +1224,33 @@ else
} }
print '</td></tr>'; print '</td></tr>';
// Help of substitution key
$dateexample=dol_now();
if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when;
$substitutionarray=array(
'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')',
'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')',
'__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')',
'__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')',
'__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')',
'__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')',
'__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')',
'__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')',
'__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')',
'__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')',
'__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')'
);
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($substitutionarray as $key => $val)
{
$htmltext.=$key.' = '.$langs->trans($val).'<br>';
}
$htmltext.='</i>';
// Note public // Note public
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer); print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext), 'note_public', $object->note_public, $object, $user->rights->facture->creer);
print '</td><td colspan="5">'; print '</td><td colspan="5">';
print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60'); print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60');
print '</td>'; print '</td>';
@ -1210,40 +1258,12 @@ else
// Note private // Note private
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer); print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext), 'note_private', $object->note_private, $object, $user->rights->facture->creer);
print '</td><td colspan="5">'; print '</td><td colspan="5">';
print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60'); print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Project
/*
if (! empty($conf->projet->enabled))
{
$langs->load('projects');
print '<tr>';
print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Project');
print '</td>';
if ($action != 'classify') {
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=classify&amp;facid=' . $object->id . '">';
print img_edit($langs->trans('SetProject'), 1);
print '</a></td>';
}
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'classify') {
$form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1);
} else {
$form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
}
print '</td>';
print '</tr>';
}*/
// Bank Account // Bank Account
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

@ -133,7 +133,7 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search
$fieldstosearchall = array( $fieldstosearchall = array(
'f.facnumber'=>'Ref', 'f.facnumber'=>'Ref',
'f.ref_client'=>'RefCustomer', 'f.ref_client'=>'RefCustomer',
'fd.description'=>'Description', 'pd.description'=>'Description',
's.nom'=>"ThirdParty", 's.nom'=>"ThirdParty",
'f.note_public'=>'NotePublic', 'f.note_public'=>'NotePublic',
); );
@ -156,7 +156,7 @@ $arrayfields=array(
'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
'am'=>array('label'=>$langs->trans("Received"), 'checked'=>0), 'dynamount_payed'=>array('label'=>$langs->trans("Received"), 'checked'=>0),
'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0),
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
@ -253,7 +253,9 @@ $sql.= ' f.datec as date_creation, f.tms as date_update,';
$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
$sql.= " typent.code as typent_code,"; $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name"; $sql.= " state.code_departement as state_code, state.nom as state_name";
if (! $sall) $sql.= ', SUM(pf.amount) as am'; // To be able to sort on status // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed';
// Add fields from extrafields // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks // Add fields from hooks
@ -267,7 +269,6 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s
$sql.= ', '.MAIN_DB_PREFIX.'facture as f'; $sql.= ', '.MAIN_DB_PREFIX.'facture as f';
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields as ef on (f.rowid = ef.fk_object)"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields as ef on (f.rowid = ef.fk_object)";
if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
else $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as fd ON fd.fk_facture = f.rowid';
if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture';
if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product';
// We'll need this table joined to the select in order to filter by sale // We'll need this table joined to the select in order to filter by sale
@ -655,8 +656,8 @@ if ($resql)
if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'],$_SERVER['PHP_SELF'],'f.total','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'],$_SERVER['PHP_SELF'],'f.total','',$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'],$_SERVER['PHP_SELF'],'f.tva','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'],$_SERVER['PHP_SELF'],'f.tva','',$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['am']['checked'])) print_liste_field_titre($arrayfields['am']['label'],$_SERVER['PHP_SELF'],'am','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'rtp','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder);
// Extra fields // Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{ {
@ -675,7 +676,7 @@ if ($resql)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'],$_SERVER["PHP_SELF"],"fk_statut,paye,type,dynamount_payed","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
@ -786,7 +787,7 @@ if ($resql)
print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.$search_montant_ttc.'">'; print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.$search_montant_ttc.'">';
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['am']['checked'])) if (! empty($arrayfields['dynamount_payed']['checked']))
{ {
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
print '</td>'; print '</td>';
@ -1025,9 +1026,9 @@ if ($resql)
$totalarray['totalttc'] += $obj->total_ttc; $totalarray['totalttc'] += $obj->total_ttc;
} }
if (! empty($arrayfields['am']['checked'])) if (! empty($arrayfields['dynamount_payed']['checked']))
{ {
print '<td align="right">'.(! empty($paiement)?price($paiement,0,$langs):'&nbsp;').'</td>'; print '<td align="right">'.(! empty($paiement)?price($paiement,0,$langs):'&nbsp;').'</td>'; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalamfield']=$totalarray['nbfield']; if (! $i) $totalarray['totalamfield']=$totalarray['nbfield'];
$totalarray['totalam'] += $paiement; $totalarray['totalam'] += $paiement;
@ -1035,7 +1036,7 @@ if ($resql)
if (! empty($arrayfields['rtp']['checked'])) if (! empty($arrayfields['rtp']['checked']))
{ {
print '<td align="right">'.(! empty($remaintopay)?price($remaintopay,0,$langs):'&nbsp;').'</td>'; print '<td align="right">'.(! empty($remaintopay)?price($remaintopay,0,$langs):'&nbsp;').'</td>'; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield'];
$totalarray['totalrtp'] += $remaintopay; $totalarray['totalrtp'] += $remaintopay;

View File

@ -171,7 +171,7 @@ if ($resql)
print '</td>'; print '</td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="6" name="search_amount" value="'.$search_amount.'">'; print '<input class="flat maxwidth50" type="text" name="search_amount" value="'.$search_amount.'">';
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
@ -190,7 +190,7 @@ if ($resql)
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
// Num ref cheque // Num ref cheque
print '<td width="80">'; print '<td>';
$checkdepositstatic->id=$objp->rowid; $checkdepositstatic->id=$objp->rowid;
$checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid); $checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid);
$checkdepositstatic->statut=$objp->statut; $checkdepositstatic->statut=$objp->statut;

View File

@ -52,6 +52,17 @@ if ($user->societe_id > 0) $socid = $user->societe_id;
if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat'); if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat');
if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield='s.nom, s.rowid';
if (! $sortorder) $sortorder='ASC';
// Date range // Date range
$year=GETPOST("year"); $year=GETPOST("year");
if (empty($year)) if (empty($year))
@ -155,12 +166,23 @@ if (! empty($conf->accounting->enabled))
} }
// Show report array // Show report array
$param='&modecompta='.$modecompta;
if ($date_startday) $param.='&date_startday='.$date_startday;
if ($date_startmonth) $param.='&date_startmonth='.$date_startmonth;
if ($date_startyear) $param.='&date_startyear='.$date_startyear;
if ($date_endday) $param.='&date_endday='.$date_endday;
if ($date_endmonth) $param.='&date_endmonth='.$date_endmonth;
if ($date_endyear) $param.='&date_endyear='.$date_startyear;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="10%">&nbsp;</td><td>&nbsp;</td>'; print_liste_field_titre('');
print_liste_field_titre($langs->trans("Name"), $_SERVER["PHP_SELF"],'s.nom, s.rowid','',$param,'',$sortfield,$sortorder);
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print "<td align=\"right\">".$langs->trans("AmountHT")."</td>"; {
print "<td align=\"right\">".$langs->trans("AmountTTC")."</td>"; print_liste_field_titre($langs->trans("AmountHT"), $_SERVER["PHP_SELF"],'amount_ht','',$param,'align="right"',$sortfield,$sortorder);
}
print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"],'amount_ttc','',$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
/* /*
@ -202,7 +224,7 @@ else
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid; if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql.= " GROUP BY s.nom, s.rowid"; $sql.= " GROUP BY s.nom, s.rowid";
$sql.= " ORDER BY s.nom, s.rowid"; $sql.= $db->order($sortfield, $sortorder);
dol_syslog("get customer invoices", LOG_DEBUG); dol_syslog("get customer invoices", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
@ -328,7 +350,7 @@ else
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid; if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql .= " GROUP BY s.nom, s.rowid"; $sql .= " GROUP BY s.nom, s.rowid";
$sql .= " ORDER BY s.nom, s.rowid"; $sql.= $db->order($sortfield, $sortorder);
print '<tr><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>'; print '<tr><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>';
@ -413,7 +435,11 @@ else
} }
$sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle, c.id"; $sql.= " GROUP BY c.libelle, c.id";
$sql.= " ORDER BY c.libelle, c.id"; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get social contributions deductible=0", LOG_DEBUG); dol_syslog("get social contributions deductible=0", LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);
@ -473,8 +499,6 @@ if ($modecompta == 'CREANCES-DETTES')
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle, c.id";
$sql.= " ORDER BY c.libelle, c.id";
} }
else else
{ {
@ -488,9 +512,13 @@ else
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle, c.id";
$sql.= " ORDER BY c.libelle, c.id";
} }
$sql.= " GROUP BY c.libelle, c.id";
$newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get social contributions deductible=1", LOG_DEBUG); dol_syslog("get social contributions deductible=1", LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);
@ -574,7 +602,11 @@ if (! empty($conf->salaries->enabled))
$sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm"; $sql.= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm";
$sql.= " ORDER BY u.firstname"; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'u.firstname, u.lastname';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get payment salaries"); dol_syslog("get payment salaries");
$result=$db->query($sql); $result=$db->query($sql);
@ -642,7 +674,7 @@ if (! empty($conf->expensereport->enabled))
$column='p.date_valid'; $column='p.date_valid';
} else { } else {
$sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht, sum(p.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
@ -656,10 +688,14 @@ if (! empty($conf->expensereport->enabled))
print '<tr><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>'; print '<tr><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>';
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
{
$sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
}
$sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm"; $sql.= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm";
$sql.= " ORDER BY p.ref"; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.ref';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get expense report outcome"); dol_syslog("get expense report outcome");
$result=$db->query($sql); $result=$db->query($sql);
@ -733,7 +769,11 @@ if (! empty($conf->don->enabled))
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'"; $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm"; $sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
$sql.= " ORDER BY p.societe, p.firstname, p.lastname, dm"; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get dunning"); dol_syslog("get dunning");
$result=$db->query($sql); $result=$db->query($sql);
@ -808,7 +848,11 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= " ORDER BY dm"; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get vat to pay", LOG_DEBUG); dol_syslog("get vat to pay", LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);
@ -853,7 +897,11 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= " ORDER BY dm"; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get vat received back", LOG_DEBUG); dol_syslog("get vat received back", LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);
@ -897,7 +945,11 @@ else
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'"; $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " AND t.entity = ".$conf->entity; $sql.= " AND t.entity = ".$conf->entity;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= " ORDER BY dm"; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get vat really paid", LOG_DEBUG); dol_syslog("get vat really paid", LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);
@ -938,7 +990,11 @@ else
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'"; $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " AND t.entity = ".$conf->entity; $sql.= " AND t.entity = ".$conf->entity;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= " ORDER BY dm"; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get vat really received back", LOG_DEBUG); dol_syslog("get vat really received back", LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);

View File

@ -1183,10 +1183,10 @@ else
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'; print '<tr><td>';
print $langs->trans("ExportCardToFormat").'</td><td colspan="3">'; print $langs->trans("VCard").'</td><td colspan="3">';
print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'">'; print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'">';
print img_picto($langs->trans("VCard"),'vcard.png').' '; print img_picto($langs->trans("Download"),'vcard.png').' ';
print $langs->trans("VCard"); print $langs->trans("Download");
print '</a>'; print '</a>';
print '</td></tr>'; print '</td></tr>';

View File

@ -991,6 +991,7 @@ if (empty($reshook))
} }
} }
/* /*
* View * View
*/ */
@ -999,6 +1000,7 @@ llxHeader('',$langs->trans("Contract"),"");
$form = new Form($db); $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db);
$objectlignestatic=new ContratLigne($db); $objectlignestatic=new ContratLigne($db);
@ -1086,34 +1088,36 @@ if ($action == 'create')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td>';
if (! empty($modCodeContract->code_auto)) { if (! empty($modCodeContract->code_auto)) {
$tmpcode=$langs->trans("Draft"); $tmpcode=$langs->trans("Draft");
} else { } else {
$tmpcode='<input name="ref" size="20" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">'; $tmpcode='<input name="ref" class="maxwidth100" maxlength="128" value="'.dol_escape_htmltag(GETPOST('ref')?GETPOST('ref'):$tmpcode).'">';
} }
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$tmpcode.'</td></tr>'; print $tmpcode;
print '</td></tr>';
// Ref customer // Ref customer
print '<tr><td>'.$langs->trans('RefCustomer').'</td>'; print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
print '<td colspan="2"><input type="text" size="5" name="ref_customer" id="ref_customer" value="'.GETPOST('ref_customer','alpha').'"></td></tr>'; print '<td><input type="text" class="maxwidth150" name="ref_customer" id="ref_customer" value="'.dol_escape_htmltag(GETPOST('ref_customer','alpha')).'"></td></tr>';
// Ref supplier // Ref supplier
print '<tr><td>'.$langs->trans('RefSupplier').'</td>'; print '<tr><td>'.$langs->trans('RefSupplier').'</td>';
print '<td colspan="2"><input type="text" size="5" name="ref_supplier" id="ref_supplier" value="'.GETPOST('ref_supplier','alpha').'"></td></tr>'; print '<td><input type="text" class="maxwidth150" name="ref_supplier" id="ref_supplier" value="'.dol_escape_htmltag(GETPOST('ref_supplier','alpha')).'"></td></tr>';
// Thirdparty // Thirdparty
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>'; print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
if ($socid>0) if ($socid>0)
{ {
print '<td colspan="2">'; print '<td>';
print $soc->getNomUrl(1); print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">'; print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>'; print '</td>';
} }
else else
{ {
print '<td colspan="2">'; print '<td>';
print $form->select_company('','socid','','SelectThirdParty',1); print $form->select_company('','socid','','SelectThirdParty',1);
print '</td>'; print '</td>';
} }
@ -1122,7 +1126,7 @@ if ($action == 'create')
if($socid>0) if($socid>0)
{ {
// Ligne info remises tiers // Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('Discounts').'</td><td>';
if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent); if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount"); else print $langs->trans("CompanyHasNoRelativeDiscount");
print '. '; print '. ';
@ -1158,11 +1162,9 @@ if ($action == 'create')
} }
print '<tr><td>'.$langs->trans("NotePublic").'</td><td valign="top">'; print '<tr><td>'.$langs->trans("NotePublic").'</td><td valign="top">';
$doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); $doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>';
if (empty($user->societe_id)) if (empty($user->societe_id))
{ {
@ -1293,47 +1295,75 @@ else
print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneContract'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
} }
print '<table class="border" width="100%">'; // Contract card
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref du contrat
$morehtmlref='';
if (! empty($modCodeContract->code_auto)) { if (! empty($modCodeContract->code_auto)) {
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">'; $morehtmlref.=$object->ref;
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print "</td></tr>";
} else { } else {
print '<tr>'; $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,$object,$user->rights->contrat->creer,'string','',0,3);
print '<td class="titlefieldcreate">'; $morehtmlref.=$form->editfieldval("",'ref',$object->ref,$object,$user->rights->contrat->creer,'string','',0,2);
print $form->editfieldkey("Ref",'ref',$object->ref,$object,$user->rights->contrat->creer);
print '</td><td>';
print $form->editfieldval("Ref",'ref',$object->ref,$object,$user->rights->contrat->creer);
print '</td>';
print '</tr>';
} }
print '<tr>'; $morehtmlref.='<div class="refidno">';
print '<td>'; // Ref customer
print $form->editfieldkey("RefCustomer",'ref_customer',$object->ref_customer,$object,$user->rights->contrat->creer); $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
print '</td><td>'; $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1);
print $form->editfieldval("RefCustomer",'ref_customer',$object->ref_customer,$object,$user->rights->contrat->creer); // Ref supplier
print '</td>'; $morehtmlref.='<br>';
print '</tr>'; $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->contrat->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
print '<tr>';
print '<td>';
print $form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,$user->rights->contrat->creer);
print '</td><td>';
print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,$user->rights->contrat->creer);
print '</td>';
print '</tr>';
// Customer dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Ligne info remises tiers // Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discount').'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent); if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount"); else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$object->thirdparty->getAvailableDiscounts(); $absolute_discount=$object->thirdparty->getAvailableDiscounts();
@ -1343,44 +1373,14 @@ else
print '.'; print '.';
print '</td></tr>'; print '</td></tr>';
// Statut contrat
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
if ($object->statut==0) print $object->getLibStatut(2);
else print $object->getLibStatut(4);
print "</td></tr>";
// Date // Date
print '<tr>'; print '<tr>';
print '<td>'; print '<td class="titlefield">';
print $form->editfieldkey("Date",'date_contrat',$object->date_contrat,$object,$user->rights->contrat->creer); print $form->editfieldkey("Date",'date_contrat',$object->date_contrat,$object,$user->rights->contrat->creer);
print '</td><td>'; print '</td><td>';
print $form->editfieldval("Date",'date_contrat',$object->date_contrat,$object,$user->rights->contrat->creer,'datehourpicker'); print $form->editfieldval("Date",'date_contrat',$object->date_contrat,$object,$user->rights->contrat->creer,'datehourpicker');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
/* print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="3">'.dol_print_date($object->date_contrat,"dayhour")."</td></tr>\n";*/
// Projet
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans("Project");
print '</td>';
if ($action != "classify" && $user->rights->projet->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->trans("SetProject")).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == "classify")
{
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, "projectid", 1, 0, 1);
}
else
{
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, "none", 0, 0);
}
print "</td></tr>";
}
// Other attributes // Other attributes
$cols = 3; $cols = 3;
@ -1388,6 +1388,8 @@ else
print "</table>"; print "</table>";
print '</div>';
if (! empty($object->brouillon) && $user->rights->contrat->creer) if (! empty($object->brouillon) && $user->rights->contrat->creer)
{ {
print '</form>'; print '</form>';
@ -1457,8 +1459,8 @@ else
print '<tr class="liste_titre'.($cursorline?' liste_titre_add':'').'">'; print '<tr class="liste_titre'.($cursorline?' liste_titre_add':'').'">';
print '<td>'.$langs->trans("ServiceNb",$cursorline).'</td>'; print '<td>'.$langs->trans("ServiceNb",$cursorline).'</td>';
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>'; print '<td width="80" align="center">'.$langs->trans("VAT").'</td>';
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>'; print '<td width="80" align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>'; print '<td width="30" align="center">'.$langs->trans("Qty").'</td>';
if ($conf->global->PRODUCT_USE_UNITS) print '<td width="30" align="left">'.$langs->trans("Unit").'</td>'; if ($conf->global->PRODUCT_USE_UNITS) print '<td width="30" align="left">'.$langs->trans("Unit").'</td>';
print '<td width="50" align="right">'.$langs->trans("ReductionShort").'</td>'; print '<td width="50" align="right">'.$langs->trans("ReductionShort").'</td>';
@ -1691,7 +1693,7 @@ else
if ($object->statut > 0) if ($object->statut > 0)
{ {
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td colspan="'.($conf->margin->enabled?7:6).'"><hr></td>'; print '<td colspan="'.($conf->margin->enabled?7:6).'"><hr class="opacitymedium"></td>';
print "</tr>\n"; print "</tr>\n";
} }
@ -1927,8 +1929,6 @@ else
<input type="hidden" name="id" value="'.$object->id.'"> <input type="hidden" name="id" value="'.$object->id.'">
'; ';
print '<br>';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Array with (n*2)+1 lines print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Array with (n*2)+1 lines

View File

@ -45,6 +45,7 @@ class Contrat extends CommonObject
public $table_element_line='contratdet'; public $table_element_line='contratdet';
public $fk_element='fk_contrat'; public $fk_element='fk_contrat';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='contract';
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -1150,6 +1151,16 @@ class Contrat extends CommonObject
} }
} }
// Removed extrafields
if (! $error) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}
if (! $error) if (! $error)
{ {
// We remove directory // We remove directory
@ -2050,7 +2061,7 @@ class Contrat extends CommonObject
$sql = "SELECT count(c.rowid) as nb"; $sql = "SELECT count(c.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
if (!$user->rights->contrat->activer && !$user->societe_id) if (!$user->rights->contrat->lire && !$user->societe_id)
{ {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id; $sql.= " WHERE sc.fk_user = " .$user->id;

View File

@ -46,9 +46,7 @@ $result=restrictedArea($user,'contrat',$id);
$object = new Contrat($db); $object = new Contrat($db);
/* // Add new contact
* Ajout d'un nouveau contact
*/
if ($action == 'addcontact' && $user->rights->contrat->creer) if ($action == 'addcontact' && $user->rights->contrat->creer)
{ {
@ -91,7 +89,7 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer)
} }
} }
// Efface un contact // Delete contact
if ($action == 'deletecontact' && $user->rights->contrat->creer) if ($action == 'deletecontact' && $user->rights->contrat->creer)
{ {
$object->fetch($id); $object->fetch($id);
@ -134,24 +132,76 @@ if ($id > 0 || ! empty($ref))
dol_fiche_head($head, $hselected, $langs->trans("Contract"), 0, 'contract'); dol_fiche_head($head, $hselected, $langs->trans("Contract"), 0, 'contract');
/* // Contract card
* Contrat
*/
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Reference du contrat
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print "</td></tr>";
// Customer $morehtmlref='';
print "<tr><td>".$langs->trans("Customer")."</td>"; //if (! empty($modCodeContract->code_auto)) {
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; $morehtmlref.=$object->ref;
/*} else {
$morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
$morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
}*/
$morehtmlref.='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
// Ref supplier
$morehtmlref.='<br>';
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->contrat->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Ligne info remises tiers // Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discount').'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent); if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount"); else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$object->thirdparty->getAvailableDiscounts(); $absolute_discount=$object->thirdparty->getAvailableDiscounts();
@ -161,10 +211,21 @@ if ($id > 0 || ! empty($ref))
print '.'; print '.';
print '</td></tr>'; print '</td></tr>';
// Date
print '<tr>';
print '<td class="titlefield">';
print $form->editfieldkey("Date",'date_contrat',$object->date_contrat,$object,0);
print '</td><td>';
print $form->editfieldval("Date",'date_contrat',$object->date_contrat,$object,0,'datehourpicker');
print '</td>';
print '</tr>';
print "</table>"; print "</table>";
print '</div>'; print '</div>';
dol_fiche_end();
print '<br>'; print '<br>';
// Contacts lines // Contacts lines

View File

@ -105,23 +105,81 @@ if ($object->id)
} }
print '<table class="border" width="100%">'; // Contract card
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Reference
print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td><td colspan="3">'.$form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '').'</td></tr>';
// Societe $morehtmlref='';
print '<tr><td>'.$langs->trans("Customer").'</td>'; //if (! empty($modCodeContract->code_auto)) {
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; $morehtmlref.=$object->ref;
/*} else {
$morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
$morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
}*/
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; $morehtmlref.='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
// Ref supplier
$morehtmlref.='<br>';
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->contrat->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_fiche_end();
$modulepart = 'contract'; $modulepart = 'contract';
$permission = $user->rights->contrat->creer; $permission = $user->rights->contrat->creer;
$permtoedit = $user->rights->contrat->creer; $permtoedit = $user->rights->contrat->creer;

View File

@ -40,20 +40,91 @@ $result = restrictedArea($user, 'contrat',$contratid,'');
llxHeader('',$langs->trans("Contract"),""); llxHeader('',$langs->trans("Contract"),"");
$contrat = new Contrat($db); $object = new Contrat($db);
$contrat->fetch($contratid); $object->fetch($contratid);
$contrat->info($contratid); $object->fetch_thirdparty();
$object->info($contratid);
$head = contract_prepare_head($contrat); $head = contract_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Contract"), 0, 'contract'); dol_fiche_head($head, 'info', $langs->trans("Contract"), 0, 'contract');
// Contract card
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='';
//if (! empty($modCodeContract->code_auto)) {
$morehtmlref.=$object->ref;
/*} else {
$morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
$morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
}*/
$morehtmlref.='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
// Ref supplier
$morehtmlref.='<br>';
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->contrat->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';
dol_print_object_info($contrat); dol_print_object_info($object);
print '</td></tr></table>'; print '</td></tr></table>';
print '</div>'; print '</div>';
dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.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
@ -72,31 +72,98 @@ if ($id > 0 || ! empty($ref))
dol_fiche_head($head, 'note', $langs->trans("Contract"), 0, 'contract'); dol_fiche_head($head, 'note', $langs->trans("Contract"), 0, 'contract');
// Contract card
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Reference
print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td><td colspan="5">'.$form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '').'</td></tr>';
// Societe $morehtmlref='';
print '<tr><td>'.$langs->trans("Customer").'</td>'; //if (! empty($modCodeContract->code_auto)) {
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; $morehtmlref.=$object->ref;
/*} else {
$morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
$morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
}*/
$morehtmlref.='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
// Ref supplier
$morehtmlref.='<br>';
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->contrat->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Ligne info remises tiers // Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discount').'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent); if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount"); else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$object->thirdparty->getAvailableDiscounts(); $absolute_discount=$object->thirdparty->getAvailableDiscounts();
print '. '; print '. ';
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->currency)); if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
else print $langs->trans("CompanyHasNoAbsoluteDiscount"); else print $langs->trans("CompanyHasNoAbsoluteDiscount");
print '.'; print '.';
print '</td></tr>'; print '</td></tr>';
// Date
print '<tr>';
print '<td class="titlefield">';
print $form->editfieldkey("Date",'date_contrat',$object->date_contrat,$object,0);
print '</td><td>';
print $form->editfieldval("Date",'date_contrat',$object->date_contrat,$object,0,'datehourpicker');
print '</td>';
print '</tr>';
print "</table>"; print "</table>";
print '</div>';
print '<br>'; print '<br>';
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';

View File

@ -3301,7 +3301,7 @@ abstract class CommonObject
} }
// VAT // VAT
print '<td class="linecolvat" align="right" width="50">'.$langs->trans('VAT').'</td>'; print '<td class="linecolvat" align="right" width="80">'.$langs->trans('VAT').'</td>';
// Price HT // Price HT
print '<td class="linecoluht" align="right" width="80">'.$langs->trans('PriceUHT').'</td>'; print '<td class="linecoluht" align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
@ -4470,10 +4470,10 @@ abstract class CommonObject
switch($mode) { switch($mode) {
case "view": case "view":
$out .= $extrafields->showOutputField($key,$value); $out .= $extrafields->showOutputField($key, $value);
break; break;
case "edit": case "edit":
$out .= $extrafields->showInputField($key,$value,'',$keyprefix,'',0,$this->id); $out .= $extrafields->showInputField($key, $value, '', $keyprefix, '', 0, $this->id);
break; break;
} }

View File

@ -660,7 +660,7 @@ class ExtraFields
* Return HTML string to put an input field into a page * Return HTML string to put an input field into a page
* *
* @param string $key Key of attribute * @param string $key Key of attribute
* @param string $value Value to show (for date type it must be in timestamp format) * @param string $value Preselected value to show (for date type it must be in timestamp format)
* @param string $moreparam To add more parametes on html input tag * @param string $moreparam To add more parametes on html input tag
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
* @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names)
@ -668,7 +668,7 @@ class ExtraFields
* @param int $objectid Current object id * @param int $objectid Current object id
* @return string * @return string
*/ */
function showInputField($key,$value,$moreparam='',$keyprefix='',$keysuffix='',$showsize=0, $objectid=0) function showInputField($key, $value, $moreparam='', $keyprefix='', $keysuffix='', $showsize=0, $objectid=0)
{ {
global $conf,$langs; global $conf,$langs;
@ -1162,11 +1162,18 @@ class ExtraFields
$InfoFieldList = explode(":", $param_list[0]); $InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]); dol_include_once($InfoFieldList[1]);
if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
{
$valuetoshow=$value;
if (!empty($value))
{ {
$object = new $InfoFieldList[0]($this->db); $object = new $InfoFieldList[0]($this->db);
if (!empty($value)) $object->fetch($value); $resfetch=$object->fetch($value);
if ($resfetch > 0)
{
$valuetoshow=$object->ref; $valuetoshow=$object->ref;
if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ref is id because name is not unique if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique)
}
}
$out.='<input type="text" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$valuetoshow.'" >'; $out.='<input type="text" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$valuetoshow.'" >';
} }
else else

View File

@ -78,9 +78,9 @@ class Form
* @param object $object Object * @param object $object Object
* @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field.
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...)
* @param string $moreparam More param to add on a href URL* * @param string $moreparam More param to add on a href URL.
* @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS.
* @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':' * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' '
* @return string HTML edit field * @return string HTML edit field
*/ */
function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='', $fieldrequired=0, $notabletag=0) function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='', $fieldrequired=0, $notabletag=0)
@ -119,6 +119,7 @@ class Form
if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='<td align="right">'; if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='<td align="right">';
if ($htmlname && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='<a href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&amp;id='.$object->id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).'</a>'; if ($htmlname && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='<a href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&amp;id='.$object->id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).'</a>';
if (! empty($notabletag) && $notabletag == 1) $ret.=' : '; if (! empty($notabletag) && $notabletag == 1) $ret.=' : ';
if (! empty($notabletag) && $notabletag == 3) $ret.=' ';
if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='</td>'; if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='</td>';
if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='</tr></table>'; if (empty($notabletag) && GETPOST('action') != 'edit'.$htmlname && $perm) $ret.='</tr></table>';
} }
@ -561,9 +562,16 @@ class Form
jQuery(".checkforselect").click(function() { jQuery(".checkforselect").click(function() {
initCheckForSelect(); initCheckForSelect();
}); });
/* Warning: if you set submit button to disabled, post using Enter will no more work
jQuery(".massactionselect").change(function() { jQuery(".massactionselect").change(function() {
console.log( $( this ).val() ); var massaction = $( this ).val();
var urlform = $( this ).closest("form").attr("action").replace("#show_files","");
if (massaction == "builddoc")
{
urlform = urlform + "#show_files";
}
$( this ).closest("form").attr("action", urlform);
console.log("we select a mass action "+massaction+" - "+urlform);
/* Warning: if you set submit button to disabled, post using Enter will no more work
if ($(this).val() != \'0\') if ($(this).val() != \'0\')
{ {
jQuery(".massactionconfirmed").prop(\'disabled\', false); jQuery(".massactionconfirmed").prop(\'disabled\', false);
@ -572,9 +580,9 @@ class Form
{ {
jQuery(".massactionconfirmed").prop(\'disabled\', true); jQuery(".massactionconfirmed").prop(\'disabled\', true);
} }
});
*/ */
}); });
});
</script> </script>
'; ';
} }
@ -1635,9 +1643,13 @@ class Form
* @param int $forcecombo Force to use combo box * @param int $forcecombo Force to use combo box
* @param string $morecss Add more css on select * @param string $morecss Add more css on select
* @param int $hidepriceinlabel 1=Hide prices in label * @param int $hidepriceinlabel 1=Hide prices in label
* @param string $warehouseStatus warehouse status filter, following comma separated filter options can be used
* 'warehouseopen' = select products from open warehouses,
* 'warehouseclosed' = select products from closed warehouses,
* 'warehouseinternal' = select products from warehouses for internal correct/transfer only
* @return void * @return void
*/ */
function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array(), $socid=0, $showempty='1', $forcecombo=0, $morecss='', $hidepriceinlabel=0) function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array(), $socid=0, $showempty='1', $forcecombo=0, $morecss='', $hidepriceinlabel=0, $warehouseStatus='')
{ {
global $langs,$conf; global $langs,$conf;
@ -1656,7 +1668,7 @@ class Form
unset($producttmpselect); unset($producttmpselect);
} }
// mode=1 means customers products // mode=1 means customers products
$urloption='htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished; $urloption='htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished.'&warehousestatus='.$warehouseStatus;
//Price by customer //Price by customer
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
$urloption.='&socid='.$socid; $urloption.='&socid='.$socid;
@ -1677,7 +1689,7 @@ class Form
} }
else else
{ {
print $this->select_produits_list($selected,$htmlname,$filtertype,$limit,$price_level,'',$status,$finished,0,$socid,$showempty,$forcecombo,$morecss,$hidepriceinlabel); print $this->select_produits_list($selected,$htmlname,$filtertype,$limit,$price_level,'',$status,$finished,0,$socid,$showempty,$forcecombo,$morecss,$hidepriceinlabel, $warehouseStatus);
} }
} }
@ -1698,28 +1710,54 @@ class Form
* @param int $forcecombo Force to use combo box * @param int $forcecombo Force to use combo box
* @param string $morecss Add more css on select * @param string $morecss Add more css on select
* @param int $hidepriceinlabel 1=Hide prices in label * @param int $hidepriceinlabel 1=Hide prices in label
* @param string $warehouseStatus warehouse status filter, following comma separated filter options can be used
* 'warehouseopen' = select products from open warehouses,
* 'warehouseclosed' = select products from closed warehouses,
* 'warehouseinternal' = select products from warehouses for internal correct/transfer only
* @return array Array of keys for json * @return array Array of keys for json
*/ */
function select_produits_list($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$outputmode=0,$socid=0,$showempty='1',$forcecombo=0,$morecss='',$hidepriceinlabel=0) function select_produits_list($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$outputmode=0,$socid=0,$showempty='1',$forcecombo=0,$morecss='',$hidepriceinlabel=0, $warehouseStatus='')
{ {
global $langs,$conf,$user,$db; global $langs,$conf,$user,$db;
$out=''; $out='';
$outarray=array(); $outarray=array();
$sql = "SELECT "; $warehouseStatusArray = array();
$sql.= " p.rowid, p.label, p.ref, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.stock, p.fk_price_expression"; if (! empty($warehouseStatus))
{
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
if (preg_match('/warehouseclosed/', $warehouseStatus))
{
$warehouseStatusArray[] = Entrepot::STATUS_CLOSED;
}
if (preg_match('/warehouseopen/', $warehouseStatus))
{
$warehouseStatusArray[] = Entrepot::STATUS_OPEN_ALL;
}
if (preg_match('/warehouseinternal/', $warehouseStatus))
{
$warehouseStatusArray[] = Entrepot::STATUS_OPEN_INTERNAL;
}
}
$selectFields = " p.rowid, p.label, p.ref, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression";
(count($warehouseStatusArray)) ? $selectFieldsGrouped = ", sum(ps.reel) as stock" : $selectFieldsGrouped = ", p.stock";
$sql = "SELECT ";
$sql.= $selectFields . $selectFieldsGrouped;
//Price by customer //Price by customer
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
$sql.=' ,pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,'; $sql.=' ,pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
$sql.=' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx'; $sql.=' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx';
$selectFields.= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx";
} }
// Multilang : we add translation // Multilang : we add translation
if (! empty($conf->global->MAIN_MULTILANGS)) if (! empty($conf->global->MAIN_MULTILANGS))
{ {
$sql.= ", pl.label as label_translated"; $sql.= ", pl.label as label_translated";
$selectFields.= ", label_translated";
} }
// Price by quantity // Price by quantity
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
@ -1732,8 +1770,15 @@ class Form
if ($price_level >= 1 && !empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND price_level=".$price_level; if ($price_level >= 1 && !empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND price_level=".$price_level;
$sql.= " ORDER BY date_price"; $sql.= " ORDER BY date_price";
$sql.= " DESC LIMIT 1) as price_by_qty"; $sql.= " DESC LIMIT 1) as price_by_qty";
$selectFields.= ", price_rowid, price_by_qty";
} }
$sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if (count($warehouseStatusArray))
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on ps.fk_entrepot = e.rowid";
}
//Price by customer //Price by customer
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid";
@ -1744,6 +1789,10 @@ class Form
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='". $langs->getDefaultLang() ."'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='". $langs->getDefaultLang() ."'";
} }
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
if (count($warehouseStatusArray))
{
$sql.= ' AND (p.fk_product_type = 1 OR e.statut IN ('.implode(',',$warehouseStatusArray).'))';
}
if ($finished == 0) if ($finished == 0)
{ {
$sql.= " AND p.finished = ".$finished; $sql.= " AND p.finished = ".$finished;
@ -1779,6 +1828,10 @@ class Form
if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$db->escape($prefix.$filterkey)."%'"; if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '".$db->escape($prefix.$filterkey)."%'";
$sql.=')'; $sql.=')';
} }
if (count($warehouseStatusArray))
{
$sql.= ' GROUP BY'.$selectFields;
}
$sql.= $db->order("p.ref"); $sql.= $db->order("p.ref");
$sql.= $db->plimit($limit); $sql.= $db->plimit($limit);
@ -4818,17 +4871,17 @@ class Form
if ($addjscombo && empty($conf->dol_use_jmobile) && $jsbeautify) if ($addjscombo && empty($conf->dol_use_jmobile) && $jsbeautify)
{ {
$minLengthToAutocomplete=0; $minLengthToAutocomplete=0;
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT')?constant('REQUIRE_JQUERY_MULTISELECT'):'select2':$conf->global->MAIN_USE_JQUERY_MULTISELECT; $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?(constant('REQUIRE_JQUERY_MULTISELECT')?constant('REQUIRE_JQUERY_MULTISELECT'):'select2'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out.='<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript"> // Enhance with select2
$(document).ready(function () { $nodatarole='';
$(\''.(preg_match('/^\./',$htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({ if ($conf->use_javascript_ajax)
dir: \'ltr\', {
width: \'resolve\', /* off or resolve */ include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
minimumInputLength: '.$minLengthToAutocomplete.' $comboenhancement = ajax_combobox($htmlname);
}); $out.=$comboenhancement;
}); $nodatarole=($comboenhancement?' data-role="none"':'');
</script>'; }
} }
$out.='<select id="'.preg_replace('/^\./','',$htmlname).'" '.($disabled?'disabled ':'').'class="flat '.(preg_replace('/^\./','',$htmlname)).($morecss?' '.$morecss:'').'" name="'.preg_replace('/^\./','',$htmlname).'" '.($moreparam?$moreparam:'').'>'; $out.='<select id="'.preg_replace('/^\./','',$htmlname).'" '.($disabled?'disabled ':'').'class="flat '.(preg_replace('/^\./','',$htmlname)).($morecss?' '.$morecss:'').'" name="'.preg_replace('/^\./','',$htmlname).'" '.($moreparam?$moreparam:'').'>';

View File

@ -140,10 +140,8 @@ class FormFile
if ($perm) if ($perm)
{ {
$langs->load('other'); $langs->load('other');
//$out .= ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb");
$out .= ' '; $out .= ' ';
$out.=info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1); $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
//$out .= ')';
} }
} }
else else

View File

@ -8,7 +8,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra))
} }
// Add extra fields // Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND entity IN (0, ".$conf->entity.')'; $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND type != 'separate' AND entity IN (0, ".$conf->entity.')';
//print $sql; //print $sql;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)

View File

@ -977,7 +977,7 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql
{ {
//var_dump($objMod->dictionaries['tabname']); //var_dump($objMod->dictionaries['tabname']);
$nbtabname=$nbtablib=$nbtabsql=$nbtabsqlsort=$nbtabfield=$nbtabfieldvalue=$nbtabfieldinsert=$nbtabrowid=$nbtabcond=$nbtabfieldcheck=$nbtabhelp=0; $nbtabname=$nbtablib=$nbtabsql=$nbtabsqlsort=$nbtabfield=$nbtabfieldvalue=$nbtabfieldinsert=$nbtabrowid=$nbtabcond=$nbtabfieldcheck=$nbtabhelp=0;
foreach($objMod->dictionaries['tabname'] as $val) { $nbtabname++; $taborder[] = count($tabname)+1; $tabname[] = $val; } foreach($objMod->dictionaries['tabname'] as $val) { $nbtabname++; $taborder[] = max($taborder)+1; $tabname[] = $val; }
foreach($objMod->dictionaries['tablib'] as $val) { $nbtablib++; $tablib[] = $val; } foreach($objMod->dictionaries['tablib'] as $val) { $nbtablib++; $tablib[] = $val; }
foreach($objMod->dictionaries['tabsql'] as $val) { $nbtabsql++; $tabsql[] = $val; } foreach($objMod->dictionaries['tabsql'] as $val) { $nbtabsql++; $tabsql[] = $val; }
foreach($objMod->dictionaries['tabsqlsort'] as $val) { $nbtabsqlsort++; $tabsqlsort[] = $val; } foreach($objMod->dictionaries['tabsqlsort'] as $val) { $nbtabsqlsort++; $tabsqlsort[] = $val; }

View File

@ -1390,7 +1390,7 @@ function show_subsidiaries($conf,$langs,$db,$object)
{ {
$socstatic = new Societe($db); $socstatic = new Societe($db);
print load_fiche_titre($langs->trans("Subsidiaries")); print load_fiche_titre($langs->trans("Subsidiaries"), '', '');
print "\n".'<table class="noborder" width="100%">'."\n"; print "\n".'<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td>'.$langs->trans("Company").'</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Company").'</td>';

View File

@ -72,8 +72,22 @@ function fichinter_prepare_head($object)
// Tab to link resources // Tab to link resources
if ($conf->resource->enabled) if ($conf->resource->enabled)
{ {
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
$nbResource = 0;
$objectres=new Dolresource($db);
foreach ($objectres->available_resources as $modresources => $resources)
{
$resources=(array) $resources; // To be sure $resources is an array
foreach($resources as $resource_obj)
{
$linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj);
}
}
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
$head[$h][1] = $langs->trans("Resources"); $head[$h][1] = $langs->trans("Resources");
if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
$head[$h][2] = 'resource'; $head[$h][2] = 'resource';
$h++; $h++;
} }

View File

@ -1061,9 +1061,10 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
$morehtmlstatus.=$tmptxt; $morehtmlstatus.=$tmptxt;
} }
elseif ($object->element == 'facturerec') elseif ($object->element == 'contrat')
{ {
$morehtmlstatus.='<!-- No status for recurring invoice -->'; if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2);
else $morehtmlstatus.=$object->getLibStatut(4);
} }
else { // Generic case else { // Generic case
$tmptxt=$object->getLibStatut(6); $tmptxt=$object->getLibStatut(6);
@ -1215,6 +1216,7 @@ function dol_strftime($fmt, $ts=false, $is_gmt=false)
* "%d %b %Y", * "%d %b %Y",
* "%d/%m/%Y %H:%M", * "%d/%m/%Y %H:%M",
* "%d/%m/%Y %H:%M:%S", * "%d/%m/%Y %H:%M:%S",
* "%B"=Long text of month, "%A"=Long text of day, "%b"=Short text of month, "%a"=Short text of day
* "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...reduceformat" * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...reduceformat"
* @param string $tzoutput true or 'gmt' => string is for Greenwich location * @param string $tzoutput true or 'gmt' => string is for Greenwich location
* false or 'tzserver' => output string is for local PHP server TZ usage * false or 'tzserver' => output string is for local PHP server TZ usage

View File

@ -228,14 +228,14 @@ function dol_print_object_info($object, $usetable=0)
else print ': '; else print ': ';
if (is_object($object->user_creation)) if (is_object($object->user_creation))
{ {
if ($object->user_creation->id) print $object->user_creation->getNomUrl(1); if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation);
if ($userstatic->id) print $userstatic->getNomUrl(1); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
@ -264,14 +264,14 @@ function dol_print_object_info($object, $usetable=0)
else print ': '; else print ': ';
if (is_object($object->user_modification)) if (is_object($object->user_modification))
{ {
if ($object->user_modification->id) print $object->user_modification->getNomUrl(1); if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification);
if ($userstatic->id) print $userstatic->getNomUrl(1); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
@ -300,14 +300,14 @@ function dol_print_object_info($object, $usetable=0)
else print ': '; else print ': ';
if (is_object($object->user_validation)) if (is_object($object->user_validation))
{ {
if ($object->user_validation->id) print $object->user_validation->getNomUrl(1); if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation);
if ($userstatic->id) print $userstatic->getNomUrl(1); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
@ -336,14 +336,14 @@ function dol_print_object_info($object, $usetable=0)
else print ': '; else print ': ';
if (is_object($object->user_approve)) if (is_object($object->user_approve))
{ {
if ($object->user_approve->id) print $object->user_approve->getNomUrl(1); if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve);
if ($userstatic->id) print $userstatic->getNomUrl(1); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
@ -372,7 +372,7 @@ function dol_print_object_info($object, $usetable=0)
else print ': '; else print ': ';
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->fetch($object->user_approve_id2); $userstatic->fetch($object->user_approve_id2);
if ($userstatic->id) print $userstatic->getNomUrl(1); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
else print '<br>'; else print '<br>';
@ -400,14 +400,14 @@ function dol_print_object_info($object, $usetable=0)
else print ': '; else print ': ';
if (is_object($object->user_cloture)) if (is_object($object->user_cloture))
{ {
if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1); if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->fetch($object->user_cloture); $userstatic->fetch($object->user_cloture);
if ($userstatic->id) print $userstatic->getNomUrl(1); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';
@ -436,14 +436,14 @@ function dol_print_object_info($object, $usetable=0)
else print ': '; else print ': ';
if (is_object($object->user_rappro)) if (is_object($object->user_rappro))
{ {
if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1); if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
else else
{ {
$userstatic=new User($db); $userstatic=new User($db);
$userstatic->fetch($object->user_rappro); $userstatic->fetch($object->user_rappro);
if ($userstatic->id) print $userstatic->getNomUrl(1); if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
else print $langs->trans("Unknown"); else print $langs->trans("Unknown");
} }
if ($usetable) print '</td></tr>'; if ($usetable) print '</td></tr>';

View File

@ -941,6 +941,20 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
$line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
} }
// Prof Id 5
if ($fromcompany->idprof5)
{
$field=$outputlangs->transcountrynoentities("ProfId5",$fromcompany->country_code);
if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
$line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5);
}
// Prof Id 6
if ($fromcompany->idprof6)
{
$field=$outputlangs->transcountrynoentities("ProfId6",$fromcompany->country_code);
if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
$line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6);
}
// IntraCommunautary VAT // IntraCommunautary VAT
if ($fromcompany->tva_intra != '') if ($fromcompany->tva_intra != '')
{ {

View File

@ -372,7 +372,7 @@ class ImportCsv extends ModeleImports
if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor
{ {
$file=$objimport->array_import_convertvalue[0][$val]['classfile']; $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']);
$class=$objimport->array_import_convertvalue[0][$val]['class']; $class=$objimport->array_import_convertvalue[0][$val]['class'];
$method=$objimport->array_import_convertvalue[0][$val]['method']; $method=$objimport->array_import_convertvalue[0][$val]['method'];
if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '')

View File

@ -285,19 +285,11 @@ class modAdherent extends DolibarrModules
$this->export_label[$r]='MembersAndSubscriptions'; $this->export_label[$r]='MembersAndSubscriptions';
$this->export_permission[$r]=array(array("adherent","export")); $this->export_permission[$r]=array(array("adherent","export"));
$this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount'); $this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount');
$this->export_TypeFields_array[$r]=array('a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.dateadh'=>'Date','c.subscription'=>'Numeric'); $this->export_TypeFields_array[$r]=array('a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric');
$this->export_entities_array[$r]=array('a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription'); $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription');
// Add extra fields // Add extra fields
$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity = ".$conf->entity; $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra';
$resql=$this->db->query($sql); include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_entities_array[$r][$fieldname]='member';
}
// End add axtra fields // End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)'; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)';

View File

@ -380,7 +380,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
$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('facture_fournisseur',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; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
$r++; $r++;
@ -443,7 +443,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.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] .=' 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('facture_fournisseur',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; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
// Order // Order
@ -552,7 +552,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
$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('commande_fournisseur',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; if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
} }

View File

@ -215,101 +215,32 @@ class modProjet extends DolibarrModules
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r]=array(array("projet","export")); $this->export_permission[$r]=array(array("projet","export"));
$this->export_dependencies_array[$r]=array('task_time'=>'ptt.rowid'); $this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.description'=>"Text", 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.description'=>"Text",
'pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text", 'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
'ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text"); 'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company', $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', 's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',
'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'p.description'=>"project"); 'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'cls.code'=>"project",'p.opp_percent'=>'project','p.description'=>"project");
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country', $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'Status','p.description'=>"Description"); 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.description'=>"Description");
// Add fields for project // Add fields for project
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array()); $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array());
// Add extra fields $keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra';
$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet'"; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$tmp='';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='project';
}
}
// End add extra fields
// Add fields for tasks // Add fields for tasks
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.label'=>'LabelTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription")); $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.label'=>'LabelTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription"));
$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask")); $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask"));
// Add extra fields // Add extra fields
$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task'"; $keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2';
$resql=$this->db->query($sql); include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extra2.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$tmp='';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='projecttask';
}
}
// End add extra fields // End add extra fields
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote")); $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"));
$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time")); $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"));
@ -317,6 +248,7 @@ class modProjet 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.'projet as p'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'projet as p';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";

View File

@ -72,13 +72,13 @@ else $typeofdata='textarea:12:95%';
<div class="tagtable border table-border centpercent"> <div class="tagtable border table-border centpercent">
<?php if ($module != 'product') { // No public note yet on products ?> <?php if ($module != 'product') { // No public note yet on products ?>
<div class="tagtr table-border-row"> <div class="tagtr table-border-row">
<div class="tagtd table-key-border-col<?php echo (empty($cssclass)?'':' '.$cssclass); ?>"<?php echo ($colwidth ? ' style="width: '.$colwidth.'%"' : ''); ?>><?php echo $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); ?></div> <div class="tagtd tdtop table-key-border-col<?php echo (empty($cssclass)?'':' '.$cssclass); ?>"<?php echo ($colwidth ? ' style="width: '.$colwidth.'%"' : ''); ?>><?php echo $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); ?></div>
<div class="tagtd table-val-border-col"><?php echo $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); ?></div> <div class="tagtd table-val-border-col"><?php echo $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); ?></div>
</div> </div>
<?php } ?> <?php } ?>
<?php if (empty($user->societe_id)) { ?> <?php if (empty($user->societe_id)) { ?>
<div class="tagtr table-border-row"> <div class="tagtr table-border-row">
<div class="tagtd table-key-border-col<?php echo (empty($cssclass)?'':' '.$cssclass); ?>"<?php echo ($colwidth ? ' style="width: '.$colwidth.'%"' : ''); ?>><?php echo $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); ?></div> <div class="tagtd tdtop table-key-border-col<?php echo (empty($cssclass)?'':' '.$cssclass); ?>"<?php echo ($colwidth ? ' style="width: '.$colwidth.'%"' : ''); ?>><?php echo $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); ?></div>
<div class="tagtd table-val-border-col"><?php echo $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); ?></div> <div class="tagtd table-val-border-col"><?php echo $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); ?></div>
</div> </div>
<?php } ?> <?php } ?>

View File

@ -107,7 +107,7 @@ if ($nolinesbefore) {
<?php <?php
} }
?> ?>
<tr class="pair nodrag nodrop nohoverpair<?php echo $nolinesbefore?'':' liste_titre_add'; ?>"> <tr class="pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element=='contrat')?'':' liste_titre_add'; ?>">
<?php <?php
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay=2; } $coldisplay=2; }
@ -183,9 +183,17 @@ else {
if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
if (empty($senderissupplier)) if (empty($senderissupplier))
{
if ($conf->global->ENTREPOT_EXTRA_STATUS)
{
// hide products in closed warehouse, but show products for internal transfer
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id, '1', 0, '', 0, 'warehouseopen,warehouseinternal');
}
else
{ {
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id);
} }
}
else else
{ {
if ($senderissupplier != 2) if ($senderissupplier != 2)

View File

@ -88,9 +88,20 @@ print "</tr>";
print '<tr class="impair">'; print '<tr class="impair">';
print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>'; print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>';
print '<td><input type="text" class="flat" id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '" size="40">'; $disabled='';
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->global->CRON_DISABLE_KEY_CHANGE)) $disabled=' disabled="disabled"';
print '<td>';
if (empty($conf->global->CRON_DISABLE_KEY_CHANGE))
{
print '<input type="text" class="flat minwidth200"'.$disabled.' id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '">';
if (! empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
}
else
{
print (! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'');
print '<input type="hidden" id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '">';
}
print '</td>'; print '</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';

View File

@ -767,7 +767,7 @@ if ($action == 'create')
$liste = ModelePdfExpedition::liste_modeles($db); $liste = ModelePdfExpedition::liste_modeles($db);
if (count($liste) > 1) if (count($liste) > 1)
{ {
print "<tr><td>".$langs->trans("Model")."</td>"; print "<tr><td>".$langs->trans("DefaultModel")."</td>";
print '<td colspan="3">'; print '<td colspan="3">';
print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF); print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF);
print "</td></tr>\n"; print "</td></tr>\n";
@ -862,7 +862,7 @@ if ($action == 'create')
if ($line->fk_product > 0) // If predefined product if ($line->fk_product > 0) // If predefined product
{ {
$product->fetch($line->fk_product); $product->fetch($line->fk_product);
$product->load_stock(); $product->load_stock('warehouseopen');
print '<td>'; print '<td>';
print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne

View File

@ -892,7 +892,7 @@ class Expedition extends CommonObject
$result=$product->fetch($fk_product); $result=$product->fetch($fk_product);
if ($entrepot_id > 0) { if ($entrepot_id > 0) {
$product->load_stock(); $product->load_stock('warehouseopen');
$product_stock = $product->stock_warehouse[$entrepot_id]->real; $product_stock = $product->stock_warehouse[$entrepot_id]->real;
} }
else else

View File

@ -31,7 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@ -53,107 +56,164 @@ $socid=0;
if (! empty($user->societe_id)) $socid=$user->societe_id; if (! empty($user->societe_id)) $socid=$user->societe_id;
$result=restrictedArea($user,'commande',$id); $result=restrictedArea($user,'commande',$id);
$object = new Commande($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
/* /*
* Actions * Actions
*/ */
// Categorisation dans projet $parameters = array('socid' => $socid);
if ($action == 'classin') $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
{ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
$commande = new Commande($db);
$commande->fetch($id);
$commande->setProject(GETPOST('projectid','int'));
}
if ($action == 'confirm_cloture' && GETPOST('confirm','alpha') == 'yes') if (empty($reshook))
{ {
$commande = new Commande($db); // Categorisation dans projet
$commande->fetch($id); if ($action == 'classin')
$result = $commande->cloture($user); {
} $object = new Commande($db);
$object->fetch($id);
$object->setProject(GETPOST('projectid','int'));
}
// Positionne ref commande client if ($action == 'confirm_cloture' && GETPOST('confirm','alpha') == 'yes')
if ($action == 'setrefcustomer' && $user->rights->commande->creer) {
{ $object = new Commande($db);
$commande = new Commande($db); $object->fetch($id);
$commande->fetch($id); $result = $object->cloture($user);
$commande->set_ref_client($user,GETPOST('ref_customer','alpha')); }
}
if ($action == 'setdatedelivery' && $user->rights->commande->creer) // Positionne ref commande client
{ else if ($action == 'setref_client' && $user->rights->commande->creer) {
$result = $object->set_ref_client($user, GETPOST('ref_client'));
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
if ($action == 'setdatedelivery' && $user->rights->commande->creer)
{
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$datelivraison=dol_mktime(0, 0, 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int')); $datelivraison=dol_mktime(0, 0, 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int'));
$commande = new Commande($db); $object = new Commande($db);
$commande->fetch($id); $object->fetch($id);
$result=$commande->set_date_livraison($user,$datelivraison); $result=$object->set_date_livraison($user,$datelivraison);
if ($result < 0) if ($result < 0)
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) if ($action == 'setdeliveryaddress' && $user->rights->commande->creer)
{ {
$commande = new Commande($db); $object = new Commande($db);
$commande->fetch($id); $object->fetch($id);
$commande->setDeliveryAddress(GETPOST('delivery_address_id','int')); $object->setDeliveryAddress(GETPOST('delivery_address_id','int'));
if ($result < 0) if ($result < 0)
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
if ($action == 'setmode' && $user->rights->commande->creer) if ($action == 'setmode' && $user->rights->commande->creer)
{ {
$commande = new Commande($db); $object = new Commande($db);
$commande->fetch($id); $object->fetch($id);
$result = $commande->setPaymentMethods(GETPOST('mode_reglement_id','int')); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) if ($result < 0)
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
if ($action == 'setavailability' && $user->rights->commande->creer) { if ($action == 'setavailability' && $user->rights->commande->creer) {
$commande = new Commande($db); $object = new Commande($db);
$commande->fetch($id); $object->fetch($id);
$result=$commande->availability(GETPOST('availability_id')); $result=$object->availability(GETPOST('availability_id'));
if ($result < 0) if ($result < 0)
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
if ($action == 'setdemandreason' && $user->rights->commande->creer) { if ($action == 'setdemandreason' && $user->rights->commande->creer) {
$commande = new Commande($db); $object = new Commande($db);
$commande->fetch($id); $object->fetch($id);
$result=$commande->demand_reason(GETPOST('demand_reason_id')); $result=$object->demand_reason(GETPOST('demand_reason_id'));
if ($result < 0) if ($result < 0)
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
if ($action == 'setconditions' && $user->rights->commande->creer) if ($action == 'setconditions' && $user->rights->commande->creer)
{ {
$commande = new Commande($db); $object = new Commande($db);
$commande->fetch($id); $object->fetch($id);
$result=$commande->setPaymentTerms(GETPOST('cond_reglement_id','int')); $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) if ($result < 0)
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
// shipping method // shipping method
if ($action == 'setshippingmethod' && $user->rights->commande->creer) { if ($action == 'setshippingmethod' && $user->rights->commande->creer) {
$commande = new Commande($db); $object = new Commande($db);
$commande->fetch($id); $object->fetch($id);
$result=$commande->setShippingMethod(GETPOST('shipping_method_id', 'int')); $result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
if ($result < 0) if ($result < 0)
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
// warehouse // warehouse
if ($action == 'setwarehouse' && $user->rights->commande->creer) { if ($action == 'setwarehouse' && $user->rights->commande->creer) {
$commande = new Commande($db); $object = new Commande($db);
$commande->fetch($id); $object->fetch($id);
$result = $commande->setWarehouse(GETPOST('warehouse_id', 'int')); $result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
if ($result < 0) if ($result < 0)
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
if ($action == 'update_extras')
{
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0) $error++;
if (! $error)
{
// Actions on extra fields (by external module or standard code)
$hookmanager->initHooks(array('orderdao'));
$parameters = array('id' => $object->id);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
// some hooks
if (empty($reshook)) {
$result = $object->insertExtraFields();
if ($result < 0) {
$error++;
}
} else if ($reshook < 0)
$error++;
}
if ($error)
$action = 'edit_extras';
}
if ($action == 'set_thirdparty' && $user->rights->commande->creer)
{
$object->fetch($id);
$object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY');
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit();
}
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
}
/* /*
* View * View
@ -162,81 +222,109 @@ if ($action == 'setwarehouse' && $user->rights->commande->creer) {
$form = new Form($db); $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$formproduct = new FormProduct($db); $formproduct = new FormProduct($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
llxHeader('',$langs->trans('OrderCard'),''); llxHeader('',$langs->trans('OrderCard'),'');
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$commande = new Commande($db); $object = new Commande($db);
if ( $commande->fetch($id,$ref) > 0) if ( $object->fetch($id,$ref) > 0)
{ {
$commande->loadExpeditions(1); $object->loadExpeditions(1);
$product_static=new Product($db); $product_static=new Product($db);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($object->socid);
$author = new User($db); $author = new User($db);
$author->fetch($commande->user_author_id); $author->fetch($object->user_author_id);
$head = commande_prepare_head($commande); $res = $object->fetch_optionals($object->id, $extralabels);
$head = commande_prepare_head($object);
dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), 0, 'order'); dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), 0, 'order');
/*
* Confirmation de la validation $formconfirm = '';
*/
// Confirm validation
if ($action == 'cloture') if ($action == 'cloture')
{ {
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id,$langs->trans("CloseShipment"),$langs->trans("ConfirmCloseShipment"),"confirm_cloture"); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id,$langs->trans("CloseShipment"),$langs->trans("ConfirmCloseShipment"),"confirm_cloture");
} }
// Onglet commande if (! $formconfirm) {
//$nbrow=8; $parameters = array();
//if (! empty($conf->projet->enabled)) $nbrow++; $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
}
// Print form confirm
print $formconfirm;
// Order card
$linkback = '<a href="' . DOL_URL_ROOT . '/commande/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref
print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">';
print $form->showrefnav($commande,'ref','',1,'ref','ref');
print '</td>';
print '</tr>';
// Ref commande client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
if ($action != 'RefCustomerOrder' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=RefCustomerOrder&amp;id='.$commande->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($user->rights->commande->creer && $action == 'RefCustomerOrder')
{
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setrefcustomer">';
print '<input type="text" class="flat" size="20" name="ref_customer" value="'.$commande->ref_client.'">';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $commande->ref_client;
}
print '</td>';
print '</tr>';
// Third party
print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
print '</tr>';
// Discounts for third party // Discounts for third party
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td colspan="3">';
if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent); if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount"); else print $langs->trans("CompanyHasNoRelativeDiscount");
print '. '; print '. ';
@ -246,7 +334,7 @@ if ($id > 0 || ! empty($ref))
$absolute_creditnote=price2num($absolute_creditnote,'MT'); $absolute_creditnote=price2num($absolute_creditnote,'MT');
if ($absolute_discount) if ($absolute_discount)
{ {
if ($commande->statut > Commande::STATUS_DRAFT) if ($object->statut > Commande::STATUS_DRAFT)
{ {
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency));
} }
@ -255,7 +343,7 @@ if ($id > 0 || ! empty($ref))
// Remise dispo de type non avoir // Remise dispo de type non avoir
$filter='fk_facture_source IS NULL'; $filter='fk_facture_source IS NULL';
print '<br>'; print '<br>';
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$commande->id,0,'remise_id',$soc->id,$absolute_discount,$filter, 0, '', 1); $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter, 0, '', 1);
} }
} }
if ($absolute_creditnote) if ($absolute_creditnote)
@ -268,9 +356,9 @@ if ($id > 0 || ! empty($ref))
// Date // Date
print '<tr><td>'.$langs->trans('Date').'</td>'; print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print dol_print_date($commande->date,'daytext'); print dol_print_date($object->date,'daytext');
if ($commande->hasDelay() && empty($commande->date_livraison)) { if ($object->hasDelay() && empty($object->date_livraison)) {
print ' '.img_picto($langs->trans("Late").' : '.$commande->showDelay(), "warning"); print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning");
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -281,29 +369,29 @@ if ($id > 0 || ! empty($ref))
print $langs->trans('DateDeliveryPlanned'); print $langs->trans('DateDeliveryPlanned');
print '</td>'; print '</td>';
if ($action != 'editdate_livraison') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>'; if ($action != 'editdate_livraison') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($action == 'editdate_livraison') if ($action == 'editdate_livraison')
{ {
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'" method="post">'; print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdatedelivery">'; print '<input type="hidden" name="action" value="setdatedelivery">';
$form->select_date($commande->date_livraison>0?$commande->date_livraison:-1,'liv_','','','',"setdatedelivery"); $form->select_date($object->date_livraison>0?$object->date_livraison:-1,'liv_','','','',"setdatedelivery");
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>'; print '</form>';
} }
else else
{ {
print dol_print_date($commande->date_livraison,'daytext'); print dol_print_date($object->date_livraison,'daytext');
if ($commande->hasDelay() && ! empty($commande->date_livraison)) { if ($object->hasDelay() && ! empty($object->date_livraison)) {
print ' '.img_picto($langs->trans("Late").' : '.$commande->showDelay(), "warning"); print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning");
} }
} }
print '</td>'; print '</td>';
// Note on several rows // Note on several rows
//print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>'; //print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
//print nl2br($commande->note_public); //print nl2br($object->note_public);
//print '</td>'; //print '</td>';
print '</tr>'; print '</tr>';
@ -313,13 +401,13 @@ if ($id > 0 || ! empty($ref))
print $langs->trans('SendingMethod'); print $langs->trans('SendingMethod');
print '</td>'; print '</td>';
if ($action != 'editshippingmethod' && $user->rights->expedition->creer) if ($action != 'editshippingmethod' && $user->rights->expedition->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&amp;id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($action == 'editshippingmethod') { if ($action == 'editshippingmethod') {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->shipping_method_id, 'shipping_method_id', 1); $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else { } else {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->shipping_method_id, 'none'); $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -333,34 +421,35 @@ if ($id > 0 || ! empty($ref))
print $langs->trans('Warehouse'); print $langs->trans('Warehouse');
print '</td>'; print '</td>';
if ($action != 'editwarehouse' && $user->rights->commande->creer) if ($action != 'editwarehouse' && $user->rights->commande->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editwarehouse&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetWarehouse'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editwarehouse&amp;id='.$object->id.'">'.img_edit($langs->trans('SetWarehouse'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($action == 'editwarehouse') { if ($action == 'editwarehouse') {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->warehouse_id, 'warehouse_id', 1); $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
} else { } else {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->warehouse_id, 'none'); $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none');
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Terms of payment // Terms of payment
/*
print '<tr><td height="10">'; print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort'); print $langs->trans('PaymentConditionsShort');
print '</td>'; print '</td>';
if ($action != 'editconditions' && ! empty($commande->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; if ($action != 'editconditions' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($action == 'editconditions') if ($action == 'editconditions')
{ {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'cond_reglement_id'); $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
} }
else else
{ {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'none'); $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none');
} }
print '</td></tr>'; print '</td></tr>';
@ -369,18 +458,18 @@ if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode'); print $langs->trans('PaymentMode');
print '</td>'; print '</td>';
if ($action != 'editmode' && ! empty($commande->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>'; if ($action != 'editmode' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($action == 'editmode') if ($action == 'editmode')
{ {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'mode_reglement_id'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
} }
else else
{ {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none'); $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none');
} }
print '</td></tr>'; print '</td></tr>';*/
// Availability // Availability
print '<tr><td height="10">'; print '<tr><td height="10">';
@ -388,13 +477,13 @@ if ($id > 0 || ! empty($ref))
print $langs->trans('AvailabilityPeriod'); print $langs->trans('AvailabilityPeriod');
print '</td>'; print '</td>';
if ($action != 'editavailability') if ($action != 'editavailability')
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editavailability&amp;id=' . $commande->id . '">' . img_edit($langs->trans('SetAvailability'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editavailability&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetAvailability'), 1) . '</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editavailability') { if ($action == 'editavailability') {
$form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $commande->id, $commande->availability_id, 'availability_id', 1); $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1);
} else { } else {
$form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $commande->id, $commande->availability_id, 'none', 1); $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1);
} }
print '</td></tr>'; print '</td></tr>';
@ -404,63 +493,124 @@ if ($id > 0 || ! empty($ref))
print $langs->trans('Source'); print $langs->trans('Source');
print '</td>'; print '</td>';
if ($action != 'editdemandreason') if ($action != 'editdemandreason')
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editdemandreason&amp;id=' . $commande->id . '">' . img_edit($langs->trans('SetDemandReason'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editdemandreason&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetDemandReason'), 1) . '</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editdemandreason') { if ($action == 'editdemandreason') {
$form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $commande->id, $commande->demand_reason_id, 'demand_reason_id', 1); $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1);
} else { } else {
$form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $commande->id, $commande->demand_reason_id, 'none'); $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none');
} }
// Project $tmparray=$object->getTotalWeightVolume();
if (! empty($conf->projet->enabled)) $totalWeight=$tmparray['weight'];
$totalVolume=$tmparray['volume'];
if ($totalWeight || $totalVolume)
{
print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>';
print '<td>';
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
print '</td></tr>';
print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>';
print '<td>';
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
print '</td></tr>';
}
// TODO How record was recorded OrderMode (llx_c_input_method)
// Incoterms
if (!empty($conf->incoterm->enabled))
{ {
$langs->load('projects');
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('Project'); print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->commande->creer) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>'; print '</td>';
if ($action != 'classify') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>'; print '<td colspan="3">';
print '</tr></table>'; if ($action != 'editincoterm')
print '</td><td colspan="2">';
if ($action == 'classify')
{ {
$form->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'projectid', 0, 0, 1); print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
} }
else else
{ {
$form->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->fk_project, 'none', 0, 0); print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
} }
print '</td></tr>'; print '</td></tr>';
} }
// Lignes de 3 colonnes // Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Total HT // Total HT
print '<tr><td>'.$langs->trans('AmountHT').'</td>'; print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>';
print '<td>'.price($commande->total_ht, 0, '', 1, -1, -1, $conf->currency).'</td>'; print '<td>'.price($object->total_ht, 0, '', 1, -1, -1, $conf->currency).'</td>';
print '</tr>'; print '</tr>';
// Total TVA // Total VAT
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($commande->total_tva, 0, '', 1, -1, -1, $conf->currency).'</td>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva, 0, '', 1, -1, -1, $conf->currency).'</td>';
print '</tr>'; print '</tr>';
// Amount Local Taxes
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1
{
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
print '<td>' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
}
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF
{
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
print '<td>' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
}
// Total TTC // Total TTC
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($commande->total_ttc, 0, '', 1, -1, -1, $conf->currency).'</td>'; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc, 0, '', 1, -1, -1, $conf->currency).'</td>';
print '</tr>'; print '</tr>';
// Statut print '</table>';
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$commande->getLibStatut(4).'</td>'; print '</div>';
print '</tr>'; print '</div>';
print '</div>';
print '<div class="clearboth"></div><br>';
print '</table><br>';
/** /**
* Lines or orders with quantity shipped and remain to ship * Lines or orders with quantity shipped and remain to ship
* Note: Qty shipped are already available into $commande->expeditions[fk_product] * Note: Qty shipped are already available into $object->expeditions[fk_product]
*/ */
print '<table class="noborder noshadow" width="100%">'; print '<table class="noborder noshadow" width="100%">';
@ -472,7 +622,7 @@ if ($id > 0 || ! empty($ref))
$sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc'; $sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc';
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE cd.fk_commande = ".$commande->id; $sql.= " WHERE cd.fk_commande = ".$object->id;
$sql.= " ORDER BY cd.rang, cd.rowid"; $sql.= " ORDER BY cd.rang, cd.rowid";
//print $sql; //print $sql;
@ -522,7 +672,7 @@ if ($id > 0 || ! empty($ref))
// Define output language // Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{ {
$commande->fetch_thirdparty(); $object->fetch_thirdparty();
$prod = new Product($db); $prod = new Product($db);
$prod->id = $objp->fk_product; $prod->id = $objp->fk_product;
@ -532,7 +682,7 @@ if ($id > 0 || ! empty($ref))
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if (empty($newlang)) $newlang=$commande->thirdparty->default_lang; if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
if (! empty($newlang)) if (! empty($newlang))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
@ -594,7 +744,7 @@ if ($id > 0 || ! empty($ref))
$qtyProdCom=$objp->qty; $qtyProdCom=$objp->qty;
print '<td align="center">'; print '<td align="center">';
// Nb of sending products for this line of order // Nb of sending products for this line of order
$qtyAlreadyShipped = (! empty($commande->expeditions[$objp->rowid])?$commande->expeditions[$objp->rowid]:0); $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
print $qtyAlreadyShipped; print $qtyAlreadyShipped;
print '</td>'; print '</td>';
@ -616,7 +766,7 @@ if ($id > 0 || ! empty($ref))
{ {
$product = new Product($db); $product = new Product($db);
$product->fetch($objp->fk_product); $product->fetch($objp->fk_product);
$product->load_stock(); $product->load_stock('warehouseopen');
} }
if ($objp->fk_product > 0 && $type == 0 && ! empty($conf->stock->enabled)) if ($objp->fk_product > 0 && $type == 0 && ! empty($conf->stock->enabled))
@ -691,7 +841,7 @@ if ($id > 0 || ! empty($ref))
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// Bouton expedier sans gestion des stocks // Bouton expedier sans gestion des stocks
if (empty($conf->stock->enabled) && ($commande->statut > Commande::STATUS_DRAFT && $commande->statut < Commande::STATUS_CLOSED)) if (empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED))
{ {
if ($user->rights->expedition->creer) if ($user->rights->expedition->creer)
{ {
@ -712,12 +862,12 @@ if ($id > 0 || ! empty($ref))
// Bouton expedier avec gestion des stocks // Bouton expedier avec gestion des stocks
if (! empty($conf->stock->enabled) && $commande->statut == Commande::STATUS_DRAFT) if (! empty($conf->stock->enabled) && $object->statut == Commande::STATUS_DRAFT)
{ {
print $langs->trans("ValidateOrderFirstBeforeShipment"); print $langs->trans("ValidateOrderFirstBeforeShipment");
} }
if (! empty($conf->stock->enabled) && ($commande->statut > Commande::STATUS_DRAFT && $commande->statut < Commande::STATUS_CLOSED)) if (! empty($conf->stock->enabled) && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED))
{ {
if ($user->rights->expedition->creer) if ($user->rights->expedition->creer)
{ {
@ -726,10 +876,10 @@ if ($id > 0 || ! empty($ref))
print '<form method="GET" action="'.DOL_URL_ROOT.'/expedition/card.php">'; print '<form method="GET" action="'.DOL_URL_ROOT.'/expedition/card.php">';
print '<input type="hidden" name="action" value="create">'; print '<input type="hidden" name="action" value="create">';
//print '<input type="hidden" name="id" value="'.$commande->id.'">'; //print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="shipping_method_id" value="'.$commande->shipping_method_id.'">'; print '<input type="hidden" name="shipping_method_id" value="'.$object->shipping_method_id.'">';
print '<input type="hidden" name="origin" value="commande">'; print '<input type="hidden" name="origin" value="commande">';
print '<input type="hidden" name="origin_id" value="'.$commande->id.'">'; print '<input type="hidden" name="origin_id" value="'.$object->id.'">';
//print '<table class="border" width="100%">'; //print '<table class="border" width="100%">';
$langs->load("stocks"); $langs->load("stocks");
@ -742,7 +892,7 @@ if ($id > 0 || ! empty($ref))
print $langs->trans("WarehouseSource"); print $langs->trans("WarehouseSource");
//print '</td>'; //print '</td>';
//print '<td>'; //print '<td>';
print $formproduct->selectWarehouses(! empty($commande->warehouse_id)?$commande->warehouse_id:-1, 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200'); print $formproduct->selectWarehouses(! empty($object->warehouse_id)?$object->warehouse_id:-1, 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200');
if (count($formproduct->cache_warehouses) <= 0) if (count($formproduct->cache_warehouses) <= 0)
{ {
print ' &nbsp; '.$langs->trans("WarehouseSourceNotDefined").' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create">'.$langs->trans("AddOne").'</a>'; print ' &nbsp; '.$langs->trans("WarehouseSourceNotDefined").' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create">'.$langs->trans("AddOne").'</a>';
@ -773,7 +923,7 @@ if ($id > 0 || ! empty($ref))
} }
} }
show_list_sending_receive('commande',$commande->id); show_list_sending_receive('commande',$object->id);
} }
else else
{ {

View File

@ -1240,11 +1240,15 @@ if ($action == 'create')
print '<td>'; print '<td>';
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$include_users = $object->fetch_users_approver_expensereport(); $include_users = $object->fetch_users_approver_expensereport();
if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateExpenseReport");
else
{
$defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users
if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver
if (GETPOST('fk_user_validator') > 0) $defaultselectuser=GETPOST('fk_user_validator'); if (GETPOST('fk_user_validator') > 0) $defaultselectuser=GETPOST('fk_user_validator');
$s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", 0, $include_users); $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", 0, $include_users);
print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -2225,7 +2229,8 @@ if ($action != 'create' && $action != 'edit')
// If bank module is not used // If bank module is not used
if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5) if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5)
{ {
if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0)
if ($object->paid == 0)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>"; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
} }

View File

@ -107,11 +107,6 @@ class ExpenseReports extends DolibarrApi
$sql.= ' WHERE t.entity IN ('.getEntity('expensereport', 1).')'; $sql.= ' WHERE t.entity IN ('.getEntity('expensereport', 1).')';
if ($user_ids) $sql.=" AND t.fk_user_author IN (".$user_ids.")"; if ($user_ids) $sql.=" AND t.fk_user_author IN (".$user_ids.")";
// Insert sale filter
if ($search_sale > 0)
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
@ -144,13 +139,13 @@ class ExpenseReports extends DolibarrApi
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$expensereport_static = new ExpenseReport($db); $expensereport_static = new ExpenseReport($db);
if($expensereport_static->fetch($obj->rowid)) { if($expensereport_static->fetch($obj->rowid)) {
$obj_ret[] = parent::_cleanObjectDatas($expensereport_static); $obj_ret[] = $this->_cleanObjectDatas($expensereport_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieve Expense Report list'); throw new RestException(503, 'Error when retrieve Expense Report list : '.$db->lasterror());
} }
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No Expense Report found'); throw new RestException(404, 'No Expense Report found');

View File

@ -1519,7 +1519,8 @@ class ExpenseReport extends CommonObject
/** /**
* Return list of people with permission to validate trips and expenses * Return list of people with permission to validate expense reports.
* Search for permission "approve expense report"
* *
* @return array Array of user ids * @return array Array of user ids
*/ */
@ -1527,9 +1528,14 @@ class ExpenseReport extends CommonObject
{ {
$users_validator=array(); $users_validator=array();
$sql = "SELECT fk_user"; $sql = "SELECT DISTINCT ur.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd";
$sql.= " WHERE ur.fk_id = rd.id and module = 'expensereport' AND perms = 'approve'"; // Permission 'Approve'; $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve';
$sql.= "UNION";
$sql.= " SELECT DISTINCT ugu.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd";
$sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve';
//print $sql;
dol_syslog(get_class($this)."::fetch_users_approver_expensereport sql=".$sql); dol_syslog(get_class($this)."::fetch_users_approver_expensereport sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);

View File

@ -56,14 +56,17 @@ class ExpenseReportStats extends Stats
$this->userid = $userid; $this->userid = $userid;
$object=new ExpenseReport($this->db); $object=new ExpenseReport($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element; $this->from = MAIN_DB_PREFIX.$object->table_element." as e";
$this->field='total_ht'; $this->field='total_ht';
$this->where = " fk_statut > 0 and date_valid > '2000-01-01'"; $this->where = " e.fk_statut > 0";
//$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have.
$this->where.= ' AND e.entity IN ('.getEntity('expensereport', 1).')';
//$this->where.= " AND entity = ".$conf->entity; //$this->where.= " AND entity = ".$conf->entity;
if ($this->socid) if ($this->socid)
{ {
$this->where.=" AND fk_soc = ".$this->socid; $this->where.=" AND e.fk_soc = ".$this->socid;
} }
// Only me and subordinates // Only me and subordinates
@ -71,10 +74,10 @@ class ExpenseReportStats extends Stats
{ {
$childids = $user->getAllChildIds(); $childids = $user->getAllChildIds();
$childids[]=$user->id; $childids[]=$user->id;
$this->where.=" AND fk_user_author IN (".(join(',',$childids)).")"; $this->where.=" AND e.fk_user_author IN (".(join(',',$childids)).")";
} }
if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; if ($this->userid > 0) $this->where.=' AND e.fk_user_author = '.$this->userid;
} }
@ -102,9 +105,9 @@ class ExpenseReportStats extends Stats
*/ */
function getNbByMonth($year) function getNbByMonth($year)
{ {
$sql = "SELECT MONTH(date_valid) as dm, count(*)"; $sql = "SELECT MONTH(e.date_valid) as dm, count(*)";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE YEAR(date_valid) = ".$year; $sql.= " WHERE YEAR(e.date_valid) = ".$year;
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -123,9 +126,9 @@ class ExpenseReportStats extends Stats
*/ */
function getAmountByMonth($year) function getAmountByMonth($year)
{ {
$sql = "SELECT date_format(date_valid,'%m') as dm, sum(".$this->field.")"; $sql = "SELECT date_format(e.date_valid,'%m') as dm, sum(".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE date_format(date_valid,'%Y') = '".$year."'"; $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -143,9 +146,9 @@ class ExpenseReportStats extends Stats
*/ */
function getAverageByMonth($year) function getAverageByMonth($year)
{ {
$sql = "SELECT date_format(date_valid,'%m') as dm, avg(".$this->field.")"; $sql = "SELECT date_format(e.date_valid,'%m') as dm, avg(".$this->field.")";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE date_format(date_valid,'%Y') = '".$year."'"; $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'";
$sql.= " AND ".$this->where; $sql.= " AND ".$this->where;
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= $this->db->order('dm','DESC'); $sql.= $this->db->order('dm','DESC');
@ -160,7 +163,7 @@ class ExpenseReportStats extends Stats
*/ */
function getAllByYear() function getAllByYear()
{ {
$sql = "SELECT date_format(date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql = "SELECT date_format(e.date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE ".$this->where; $sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year"; $sql.= " GROUP BY year";

View File

@ -128,6 +128,7 @@ if (isset($_POST['action']))
$sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc"; $sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')';
$sql.= " ORDER BY d.rowid"; $sql.= " ORDER BY d.rowid";
$result = $db->query($sql); $result = $db->query($sql);

View File

@ -147,7 +147,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u"
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE u.rowid = d.fk_user_author"; $sql.= " WHERE u.rowid = d.fk_user_author";
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND d.fk_user_author IN ('.join(',',$childids).')'; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND d.fk_user_author IN ('.join(',',$childids).')';
//$sql.= " AND d.entity = ".$conf->entity; $sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')';
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND d.fk_user_author = ".$socid; if ($socid) $sql.= " AND d.fk_user_author = ".$socid;
$sql.= $db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);

View File

@ -203,7 +203,7 @@ $sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_extrafields as ef on (d.rowid = ef.fk_object)"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_extrafields as ef on (d.rowid = ef.fk_object)";
$sql.= ", ".MAIN_DB_PREFIX."user as u"; $sql.= ", ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE d.fk_user_author = u.rowid AND d.entity = ".$conf->entity; $sql.= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport', 1).")";
// Search all // Search all
if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall); if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall);
// Ref // Ref

View File

@ -199,7 +199,7 @@ $disable_delete = 0;
$sql = 'SELECT er.rowid as did, er.paid, er.total_ttc, per.amount'; $sql = 'SELECT er.rowid as did, er.paid, er.total_ttc, per.amount';
$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er';
$sql.= ' WHERE per.fk_expensereport = er.rowid'; $sql.= ' WHERE per.fk_expensereport = er.rowid';
$sql.= ' AND er.entity = '.$conf->entity; $sql.= ' AND er.entity IN ('.getEntity('expensereport', 1).')';
$sql.= ' AND per.rowid = '.$id; $sql.= ' AND per.rowid = '.$id;
dol_syslog("expensereport/payment/card.php", LOG_DEBUG); dol_syslog("expensereport/payment/card.php", LOG_DEBUG);

View File

@ -193,8 +193,9 @@ if (GETPOST("action") == 'create')
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">'.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>'; print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">'.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
$sql = "SELECT sum(p.amount) as total"; $sql = "SELECT sum(p.amount) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e";
$sql.= " WHERE p.fk_expensereport = ".$chid; $sql.= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$chid;
$sql.= ' AND e.entity IN ('.getEntity('expensereport', 1).')';
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -139,6 +139,7 @@ else:
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid";
$sql.= " WHERE d.fk_statut = 6"; $sql.= " WHERE d.fk_statut = 6";
$sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')';
$sql.= " ORDER BY d.date_valid DESC"; $sql.= " ORDER BY d.date_valid DESC";
$resql=$db->query($sql); $resql=$db->query($sql);

View File

@ -377,6 +377,9 @@ class Export
case 'Duree': case 'Duree':
case 'Numeric': case 'Numeric':
case 'Number': case 'Number':
// Must be a string text to allow to use comparison strings like "<= 999"
$szFilterField='<input type="text" size="6" name="'.$NameField.'" value="'.$ValueField.'">';
break;
case 'Status': case 'Status':
if (! empty($conf->global->MAIN_ACTIVATE_HTML5)) $szFilterField='<input type="number" size="6" name="'.$NameField.'" value="'.$ValueField.'">'; if (! empty($conf->global->MAIN_ACTIVATE_HTML5)) $szFilterField='<input type="number" size="6" name="'.$NameField.'" value="'.$ValueField.'">';
else $szFilterField='<input type="text" size="6" name="'.$NameField.'" value="'.$ValueField.'">'; else $szFilterField='<input type="text" size="6" name="'.$NameField.'" value="'.$ValueField.'">';

View File

@ -1194,10 +1194,10 @@ else if ($id > 0 || ! empty($ref))
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref customer // Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {

View File

@ -1348,7 +1348,7 @@ class FichinterLigne extends CommonObjectLine
// Mise a jour ligne en base // Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinterdet SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."fichinterdet SET";
$sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " description='".$this->db->escape($this->desc)."'";
$sql.= ",date=".$this->db->idate($this->datei); $sql.= ",date='".$this->db->idate($this->datei)."'";
$sql.= ",duree=".$this->duration; $sql.= ",duree=".$this->duration;
$sql.= ",rang='".$this->rang."'"; $sql.= ",rang='".$this->rang."'";
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;

View File

@ -112,43 +112,74 @@ llxHeader('',$langs->trans("Intervention"));
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$soc = new Societe($db); $object->fetch_thirdparty();
$soc->fetch($object->socid);
$head = fichinter_prepare_head($object); $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention'); dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention');
/* // Intervention card
* Fiche intervention synthese pour rappel
*/
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print "</td></tr>";
// Customer $morehtmlref='<div class="refidno">';
if ( is_null($object->thirdparty) ) // Ref customer
$object->fetch_thirdparty(); //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
print "<tr><td>".$langs->trans("Company")."</td>"; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print "</table>";
print '</div>'; dol_fiche_end();
print '<br>'; print '<br>';
if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1; if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser=1;
if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty=1; if (! empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty=1;
// Contacts lines // Contacts lines (modules that overwrite templates must declare this into descriptor)
include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break;
}
} }

View File

@ -101,24 +101,66 @@ if ($object->id)
} }
print '<table class="border" width="100%">'; // Intervention card
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print '</td></tr>';
// Societe $morehtmlref='<div class="refidno">';
print "<tr><td>".$langs->trans("Company")."</td><td>".$object->thirdparty->getNomUrl(1)."</td></tr>"; // Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
dol_fiche_end();
$modulepart = 'ficheinter'; $modulepart = 'ficheinter';
$permission = $user->rights->ficheinter->creer; $permission = $user->rights->ficheinter->creer;
$permtoedit = $user->rights->ficheinter->creer; $permtoedit = $user->rights->ficheinter->creer;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> /* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2009-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2009-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
$langs->load('companies'); $langs->load('companies');
$langs->load("interventions"); $langs->load("interventions");
$socid=0;
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref=GETPOST('ref','alpha');
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
@ -39,9 +41,10 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db); $object = new Fichinter($db);
if ($id > 0) if (! $object->fetch($id, $ref) > 0)
{ {
$object->fetch($id); dol_print_error($db);
exit;
} }
@ -51,13 +54,63 @@ if ($id > 0)
llxHeader('',$langs->trans("Intervention")); llxHeader('',$langs->trans("Intervention"));
$societe = new Societe($db); $object->fetch_thirdparty();
$societe->fetch($object->socid); $object->info($object->id);
$head = fichinter_prepare_head($object); $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans('InterventionCard'), 0, 'intervention'); dol_fiche_head($head, 'info', $langs->trans('InterventionCard'), 0, 'intervention');
$object->info($object->id); // Intervention card
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';
dol_print_object_info($object); dol_print_object_info($object);
@ -65,5 +118,7 @@ print '</td></tr></table>';
print '</div>'; print '</div>';
dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -60,31 +60,67 @@ $form = new Form($db);
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$societe = new Societe($db); $object->fetch_thirdparty();
if ($societe->fetch($object->socid))
{
$head = fichinter_prepare_head($object); $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention'); dol_fiche_head($head, 'note', $langs->trans('InterventionCard'), 0, 'intervention');
print '<table class="border" width="100%">'; // Intervention card
$linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td><td>';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print '</td></tr>';
// Company $morehtmlref='<div class="refidno">';
print '<tr><td>'.$langs->trans('Company').'</td><td>'.$societe->getNomUrl(1).'</td></tr>'; // Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
print "</table>"; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<br>'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass="titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
dol_fiche_end(); dol_fiche_end();
}
} }
llxFooter(); llxFooter();

View File

@ -0,0 +1,313 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
/**
* API class for supplier invoices
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class SupplierInvoices extends DolibarrApi
{
/**
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'socid'
);
/**
* @var FactureFournisseur $invoice {@type FactureFournisseur}
*/
public $invoice;
/**
* Constructor
*/
function __construct()
{
global $db, $conf;
$this->db = $db;
$this->invoice = new FactureFournisseur($this->db);
}
/**
* Get properties of a supplier invoice object
*
* Return an array with supplier invoice information
*
* @param int $id ID of supplier invoice
* @return array|mixed data without useless information
*
* @throws RestException
*/
function get($id)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Supplier invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
return $this->_cleanObjectDatas($this->invoice);
}
/**
* List invoices
*
* Get a list of supplier invoices
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter invoices of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i}
* @param string $status Filter by invoice status : draft | unpaid | paid | cancelled
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of invoice objects
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') {
global $db, $conf;
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice', 1).')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Filter by status
if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)";
if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)";
if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)";
if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (3)";
// Insert sale filter
if ($search_sale > 0)
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
if ($result)
{
$i = 0;
$num = $db->num_rows($result);
while ($i < min($num, ($limit <= 0 ? $num : $limit)))
{
$obj = $db->fetch_object($result);
$invoice_static = new FactureFournisseur($db);
if($invoice_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($invoice_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve supplier invoice list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No supplier invoice found');
}
return $obj_ret;
}
/**
* Create supplier invoice object
*
* @param array $request_data Request datas
* @return int ID of supplier invoice
*/
function post($request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach($request_data as $field => $value) {
$this->invoice->$field = $value;
}
if(! array_keys($request_data,'date')) {
$this->invoice->date = dol_now();
}
/* We keep lines as an array
if (isset($request_data["lines"])) {
$lines = array();
foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line);
}
$this->invoice->lines = $lines;
}*/
if ($this->invoice->create(DolibarrApiAccess::$user) <= 0) {
$errormsg = $this->invoice->error;
throw new RestException(500, $errormsg ? $errormsg : "Error while creating order");
}
return $this->invoice->id;
}
/**
* Update supplier invoice
*
* @param int $id Id of supplier invoice to update
* @param array $request_data Datas
* @return int
*/
function put($id, $request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Supplier invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
$this->invoice->$field = $value;
}
if($this->invoice->update($id, DolibarrApiAccess::$user))
return $this->get ($id);
return false;
}
/**
* Delete supplier invoice
*
* @param int $id Supplier invoice ID
* @return type
*/
function delete($id)
{
if(! DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) {
throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Supplier invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( $this->invoice->delete($id) < 0)
{
throw new RestException(500);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Supplier invoice deleted'
)
);
}
/**
* Clean sensible object datas
*
* @param Object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object);
unset($object->rowid);
return $object;
}
/**
* Validate fields before create or update object
*
* @param array $data Datas to validate
* @return array
*
* @throws RestException
*/
function _validate($data)
{
$invoice = array();
foreach (Invoices::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
$invoice[$field] = $data[$field];
}
return $invoice;
}
}

View File

@ -208,7 +208,7 @@ class FactureFournisseur extends CommonInvoice
* Create supplier invoice into database * Create supplier invoice into database
* *
* @param User $user object utilisateur qui cree * @param User $user object utilisateur qui cree
* @return int id facture si ok, < 0 si erreur * @return int Id invoice created if OK, < 0 if KO
*/ */
public function create($user) public function create($user)
{ {
@ -313,12 +313,14 @@ class FactureFournisseur extends CommonInvoice
} }
} }
if (count($this->lines) && is_object($this->lines[0])) // If this->lines is array of InvoiceLines (preferred mode)
{
dol_syslog("There is ".count($this->lines)." lines that are invoice lines objects");
foreach ($this->lines as $i => $val) foreach ($this->lines as $i => $val)
{ {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)';
$sql .= ' VALUES ('.$this->id.');'; $sql .= ' VALUES ('.$this->id.')';
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql_insert=$this->db->query($sql); $resql_insert=$this->db->query($sql);
if ($resql_insert) if ($resql_insert)
{ {
@ -338,7 +340,56 @@ class FactureFournisseur extends CommonInvoice
$this->lines[$i]->product_type $this->lines[$i]->product_type
); );
} }
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -5;
} }
}
}
else // If this->lines is an array of invoice line arrays
{
dol_syslog("There is ".count($this->lines)." lines that are array lines");
foreach ($this->lines as $i => $val)
{
$line = $this->lines[$i];
// Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
//if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object.
if (! is_object($line)) $line = (object) $line;
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)';
$sql .= ' VALUES ('.$this->id.')';
$resql_insert=$this->db->query($sql);
if ($resql_insert)
{
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
$this->updateline(
$idligne,
$line->description,
$line->pu_ht,
$line->tva_tx,
$line->localtax1_tx,
$line->localtax2_tx,
$line->qty,
$line->fk_product,
'HT',
(! empty($line->info_bits)?$line->info_bits:''),
$line->product_type
);
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -5;
}
}
}
// Update total price // Update total price
$result=$this->update_price(); $result=$this->update_price();
if ($result > 0) if ($result > 0)

View File

@ -1813,7 +1813,7 @@ elseif (! empty($object->id))
// Author // Author
print '<tr><td class="titlefield">'.$langs->trans("AuthorRequest").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("AuthorRequest").'</td>';
print '<td>'.$author->getNomUrl(1).'</td>'; print '<td>'.$author->getNomUrl(1, '', 0, 0, 0).'</td>';
print '</tr>'; print '</tr>';
// Conditions de reglement par defaut // Conditions de reglement par defaut
@ -2672,15 +2672,13 @@ elseif (! empty($object->id))
if ($user->rights->fournisseur->commande->commander && $object->statut == 2) if ($user->rights->fournisseur->commande->commander && $object->statut == 2)
{ {
/* // Set status to ordered (action=commande)
* Commander (action=commande)
*/
print '<!-- form to record supplier order -->'."\n"; print '<!-- form to record supplier order -->'."\n";
print '<form name="commande" action="card.php?id='.$object->id.'&amp;action=commande" method="post">'; print '<form name="commande" action="card.php?id='.$object->id.'&amp;action=commande" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="commande">'; print '<input type="hidden" name="action" value="commande">';
print load_fiche_titre($langs->trans("ToOrder"),'',''); print load_fiche_titre($langs->trans("ToOrder"),'','');
print '<table class="border" width="100%">'; print '<table class="noborder" width="100%">';
//print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ToOrder").'</td></tr>'; //print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ToOrder").'</td></tr>';
print '<tr><td>'.$langs->trans("OrderDate").'</td><td>'; print '<tr><td>'.$langs->trans("OrderDate").'</td><td>';
$date_com = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $date_com = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
@ -2700,15 +2698,14 @@ elseif (! empty($object->id))
if ($user->rights->fournisseur->commande->receptionner && ($object->statut == 3 || $object->statut == 4)) if ($user->rights->fournisseur->commande->receptionner && ($object->statut == 3 || $object->statut == 4))
{ {
/* // Set status to received (action=livraison)
* Receptionner (action=livraison)
*/
print '<!-- form to record supplier order received -->'."\n"; print '<!-- form to record supplier order received -->'."\n";
print '<form action="card.php?id='.$object->id.'" method="post">'; print '<form action="card.php?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="livraison">'; print '<input type="hidden" name="action" value="livraison">';
print load_fiche_titre($langs->trans("Receive"),'',''); print load_fiche_titre($langs->trans("Receive"),'','');
print '<table class="border" width="100%">';
print '<table class="noborder" width="100%">';
//print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Receive").'</td></tr>'; //print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Receive").'</td></tr>';
print '<tr><td>'.$langs->trans("DeliveryDate").'</td><td>'; print '<tr><td>'.$langs->trans("DeliveryDate").'</td><td>';
print $form->select_date('','',1,1,'',"commande",1,0,1); print $form->select_date('','',1,1,'',"commande",1,0,1);

View File

@ -133,38 +133,60 @@ if ($id > 0 || ! empty($ref))
if ($object->fetch($id, $ref) > 0) if ($object->fetch($id, $ref) > 0)
{ {
$soc = new Societe($db); $object->fetch_thirdparty();
$soc->fetch($object->socid);
$head = ordersupplier_prepare_head($object); $head = ordersupplier_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("SupplierOrder"), 0, 'order'); dol_fiche_head($head, 'contact', $langs->trans("SupplierOrder"), 0, 'order');
// Supplier order card
/*
* Facture synthese pour rappel
*/
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref $morehtmlref='<div class="refidno">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>'; // Ref supplier
print '<td colspan="2">'; $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
print '</td>'; // Thirdparty
print '</tr>'; $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->fournisseur->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
// Supplier
print '<tr><td>'.$langs->trans("Supplier")."</td>";
print '<td colspan="2">'.$soc->getNomUrl(1,'supplier').'</td>';
print '</tr>';
print "</table>"; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '</div>'; dol_fiche_end();
print '<br>';
// Contacts lines // Contacts lines
include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
@ -65,16 +65,16 @@ $projectid = 0;
if ($_GET["projectid"]) if ($_GET["projectid"])
$projectid = GETPOST("projectid", 'int'); $projectid = GETPOST("projectid", 'int');
$commande = new CommandeFournisseur($db); $object = new CommandeFournisseur($db);
if ($id > 0 || ! empty($ref)) { if ($id > 0 || ! empty($ref)) {
$result = $commande->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$result = $commande->fetch_thirdparty(); $result = $object->fetch_thirdparty();
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -94,9 +94,9 @@ if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED
$error ++; $error ++;
$action = ''; $action = '';
} else { } else {
$result = $commande->calcAndSetStatusDispatch($user); $result = $object->calcAndSetStatusDispatch($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error ++; $error ++;
$action = ''; $action = '';
} }
@ -114,9 +114,9 @@ if ($action == 'uncheckdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANC
$error ++; $error ++;
$action = ''; $action = '';
} else { } else {
$result = $commande->calcAndSetStatusDispatch($user); $result = $object->calcAndSetStatusDispatch($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error ++; $error ++;
$action = ''; $action = '';
} }
@ -134,9 +134,9 @@ if ($action == 'denydispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_
$error ++; $error ++;
$action = ''; $action = '';
} else { } else {
$result = $commande->calcAndSetStatusDispatch($user); $result = $object->calcAndSetStatusDispatch($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error ++; $error ++;
$action = ''; $action = '';
} }
@ -174,9 +174,9 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
} }
if (! $error) { if (! $error) {
$result = $commande->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger); $result = $object->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger);
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error ++; $error ++;
} }
} }
@ -218,9 +218,9 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
} }
if (! $error) { if (! $error) {
$result = $commande->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger); $result = $object->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger);
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error ++; $error ++;
} }
} }
@ -229,9 +229,9 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
} }
if (! $error) { if (! $error) {
$result = $commande->calcAndSetStatusDispatch($user, GETPOST('closeopenorder')?1:0); $result = $object->calcAndSetStatusDispatch($user, GETPOST('closeopenorder')?1:0);
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error ++; $error ++;
} }
} }
@ -240,11 +240,11 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
global $conf, $langs, $user; global $conf, $langs, $user;
// Call trigger // Call trigger
$result = $commande->call_trigger('ORDER_SUPPLIER_DISPATCH', $user); $result = $object->call_trigger('ORDER_SUPPLIER_DISPATCH', $user);
// End call triggers // End call triggers
if ($result < 0) { if ($result < 0) {
setEventMessages($commande->error, $commande->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error ++; $error ++;
} }
} }
@ -275,25 +275,75 @@ llxHeader('', $langs->trans("Order"), $help_url, '', 0, 0, array('/fourn/js/lib_
if ($id > 0 || ! empty($ref)) { if ($id > 0 || ! empty($ref)) {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($object->socid);
$author = new User($db); $author = new User($db);
$author->fetch($commande->user_author_id); $author->fetch($object->user_author_id);
$head = ordersupplier_prepare_head($commande); $head = ordersupplier_prepare_head($object);
$title = $langs->trans("SupplierOrder"); $title = $langs->trans("SupplierOrder");
dol_fiche_head($head, 'dispatch', $title, 0, 'order'); dol_fiche_head($head, 'dispatch', $title, 0, 'order');
/*
* Commande
*/
print '<table class="border" width="100%">';
// Supplier order card
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->fournisseur->commande->creer)
{
if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
/*
// Ref // Ref
print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td>'; print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $form->showrefnav($commande, 'ref', '', 1, 'ref', 'ref'); print $form->showrefnav($object, 'ref', '', 1, 'ref', 'ref');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -306,29 +356,31 @@ if ($id > 0 || ! empty($ref)) {
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Status") . '</td>'; print '<td>' . $langs->trans("Status") . '</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $commande->getLibStatut(4); print $object->getLibStatut(4);
print "</td></tr>"; print "</td></tr>";
*/
// Date // Date
if ($commande->methode_commande_id > 0) { if ($object->methode_commande_id > 0) {
print '<tr><td>' . $langs->trans("Date") . '</td><td colspan="2">'; print '<tr><td class="titlefield">' . $langs->trans("Date") . '</td><td>';
if ($commande->date_commande) { if ($object->date_commande) {
print dol_print_date($commande->date_commande, "dayhourtext") . "\n"; print dol_print_date($object->date_commande, "dayhourtext") . "\n";
} }
print "</td></tr>"; print "</td></tr>";
if ($commande->methode_commande) { if ($object->methode_commande) {
print '<tr><td>' . $langs->trans("Method") . '</td><td colspan="2">' . $commande->methode_commande . '</td></tr>'; print '<tr><td>' . $langs->trans("Method") . '</td><td>' . $object->methode_commande . '</td></tr>';
} }
} }
// Auteur // Auteur
print '<tr><td>' . $langs->trans("AuthorRequest") . '</td>'; print '<tr><td>' . $langs->trans("AuthorRequest") . '</td>';
print '<td colspan="2">' . $author->getNomUrl(1) . '</td>'; print '<td>' . $author->getNomUrl(1, '', 0, 0, 0) . '</td>';
print '</tr>'; print '</tr>';
print "</table>"; print "</table>";
print '</div>';
// if ($mesg) print $mesg; // if ($mesg) print $mesg;
print '<br>'; print '<br>';
@ -336,20 +388,20 @@ if ($id > 0 || ! empty($ref)) {
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
$disabled = 0; $disabled = 0;
/* // Line of orders
* Lignes de commandes if ($object->statut <= 2 || $object->statut >= 6) {
*/
if ($commande->statut <= 2 || $commande->statut >= 6) {
print $langs->trans("OrderStatusNotReadyToDispatch"); print $langs->trans("OrderStatusNotReadyToDispatch");
} }
if ($commande->statut == 3 || $commande->statut == 4 || $commande->statut == 5) { if ($object->statut == 3 || $object->statut == 4 || $object->statut == 5) {
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
$listwarehouses = $entrepot->list_array(1); $listwarehouses = $entrepot->list_array(1);
print '<form method="POST" action="dispatch.php?id=' . $commande->id . '">'; print '<form method="POST" action="dispatch.php?id=' . $object->id . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="dispatch">'; print '<input type="hidden" name="action" value="dispatch">';
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
// Set $products_dispatched with qty dispatched for each product id // Set $products_dispatched with qty dispatched for each product id
@ -357,7 +409,7 @@ if ($id > 0 || ! empty($ref)) {
$sql = "SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty"; $sql = "SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as cfd"; $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as cfd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet";
$sql .= " WHERE cfd.fk_commande = " . $commande->id; $sql .= " WHERE cfd.fk_commande = " . $object->id;
$sql .= " GROUP BY l.rowid, cfd.fk_product"; $sql .= " GROUP BY l.rowid, cfd.fk_product";
$resql = $db->query($sql); $resql = $db->query($sql);
@ -369,7 +421,7 @@ if ($id > 0 || ! empty($ref)) {
while ( $i < $num ) { while ( $i < $num ) {
$objd = $db->fetch_object($resql); $objd = $db->fetch_object($resql);
$products_dispatched[$objd->rowid] = price2num($objd->qty, 5); $products_dispatched[$objd->rowid] = price2num($objd->qty, 5);
$i ++; $i++;
} }
} }
$db->free($resql); $db->free($resql);
@ -379,7 +431,7 @@ if ($id > 0 || ! empty($ref)) {
$sql .= " p.ref, p.label, p.tobatch"; $sql .= " p.ref, p.label, p.tobatch";
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l"; $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid";
$sql .= " WHERE l.fk_commande = " . $commande->id; $sql .= " WHERE l.fk_commande = " . $object->id;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
$sql .= " AND l.product_type = 0"; $sql .= " AND l.product_type = 0";
$sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product $sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
@ -414,8 +466,9 @@ if ($id > 0 || ! empty($ref)) {
} }
} }
$nbfreeproduct = 0; $nbfreeproduct = 0; // Nb of lins of free products/services
$nbproduct = 0; $nbproduct = 0; // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default)
// or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on.
$var = false; $var = false;
while ( $i < $num ) { while ( $i < $num ) {
@ -423,14 +476,14 @@ if ($id > 0 || ! empty($ref)) {
// On n'affiche pas les produits personnalises // On n'affiche pas les produits personnalises
if (! $objp->fk_product > 0) { if (! $objp->fk_product > 0) {
$nbfreeproduct ++; $nbfreeproduct++;
} else { } else {
$remaintodispatch = price2num($objp->qty - (( float ) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched $remaintodispatch = price2num($objp->qty - (( float ) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched
if ($remaintodispatch < 0) if ($remaintodispatch < 0)
$remaintodispatch = 0; $remaintodispatch = 0;
if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) { if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) {
$nbproduct ++; $nbproduct++;
$var = ! $var; $var = ! $var;
@ -538,7 +591,7 @@ if ($id > 0 || ! empty($ref)) {
print "</tr>\n"; print "</tr>\n";
} }
} }
$i ++; $i++;
} }
$db->free($resql); $db->free($resql);
} else { } else {
@ -546,30 +599,35 @@ if ($id > 0 || ! empty($ref)) {
} }
print "</table>\n"; print "</table>\n";
print "<br/>\n"; print '</div>';
print "<br>\n";
if ($nbproduct) if ($nbproduct)
{ {
$checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv($commande->statuts[5])); $checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv($object->statuts[5]));
print '<br><div class="center">'; print '<br><div class="center">';
print $langs->trans("Comment") . ' : '; print $langs->trans("Comment") . ' : ';
print '<input type="text" size="60" maxlength="128" name="comment" value="'; print '<input type="text" class="minwidth200" maxlength="128" name="comment" value="';
print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $commande->ref); print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
// print ' / '.$commande->ref_supplier; // Not yet available // print ' / '.$object->ref_supplier; // Not yet available
print '" class="flat"><br>'; print '" class="flat"><br>';
print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel; print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
// print '<div class="center">';
print '<br><input type="submit" class="button" value="' . $langs->trans("DispatchVerb") . '"'; print '<br><input type="submit" class="button" value="' . $langs->trans("DispatchVerb") . '"';
if (count($listwarehouses) <= 0) if (count($listwarehouses) <= 0)
print ' disabled'; print ' disabled';
print '>'; print '>';
// print '</div>'; print '</div>';
} }
if (! $nbproduct && $nbfreeproduct) {
print $langs->trans("NoPredefinedProductToDispatch"); // Message if nothing to dispatch
if (! $nbproduct) {
if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED))
print $langs->trans("NoPredefinedProductToDispatch"); // No predefined line at all
else
print $langs->trans("NoMorePredefinedProductToDispatch"); // No predefined line that remain to be dispatched.
} }
print '</form>'; print '</form>';
@ -577,6 +635,7 @@ if ($id > 0 || ! empty($ref)) {
dol_fiche_end(); dol_fiche_end();
// List of lines already dispatched // List of lines already dispatched
$sql = "SELECT p.ref, p.label,"; $sql = "SELECT p.ref, p.label,";
$sql .= " e.rowid as warehouse_id, e.label as entrepot,"; $sql .= " e.rowid as warehouse_id, e.label as entrepot,";
@ -584,7 +643,7 @@ if ($id > 0 || ! empty($ref)) {
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p,"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p,";
$sql .= " " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as cfd"; $sql .= " " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as cfd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entrepot as e ON cfd.fk_entrepot = e.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entrepot as e ON cfd.fk_entrepot = e.rowid";
$sql .= " WHERE cfd.fk_commande = " . $commande->id; $sql .= " WHERE cfd.fk_commande = " . $object->id;
$sql .= " AND cfd.fk_product = p.rowid"; $sql .= " AND cfd.fk_product = p.rowid";
$sql .= " ORDER BY cfd.rowid ASC"; $sql .= " ORDER BY cfd.rowid ASC";
@ -594,10 +653,11 @@ if ($id > 0 || ! empty($ref)) {
$i = 0; $i = 0;
if ($num > 0) { if ($num > 0) {
print "<br/>\n"; print "<br>\n";
print load_fiche_titre($langs->trans("ReceivingForSameOrder")); print load_fiche_titre($langs->trans("ReceivingForSameOrder"));
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -666,7 +726,7 @@ if ($id > 0 || ! empty($ref)) {
} }
} else { } else {
$disabled = ''; $disabled = '';
if ($commande->statut == 5) if ($object->statut == 5)
$disabled = 1; $disabled = 1;
if (empty($objp->status)) { if (empty($objp->status)) {
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=checkdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Approve") . '</a>'; print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=checkdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Approve") . '</a>';
@ -692,6 +752,7 @@ if ($id > 0 || ! empty($ref)) {
$db->free($resql); $db->free($resql);
print "</table>\n"; print "</table>\n";
print '</div>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
@ -74,6 +74,7 @@ if ($object->fetch($id,$ref) < 0)
$upload_dir = $conf->fournisseur->dir_output.'/commande/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->fournisseur->dir_output.'/commande/'.dol_sanitizeFileName($object->ref);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
/* /*
* Actions * Actions
*/ */
@ -92,6 +93,8 @@ if ($object->id > 0)
$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; $help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
llxHeader('',$langs->trans("Order"),$help_url); llxHeader('',$langs->trans("Order"),$help_url);
$object->fetch_thirdparty();
$author = new User($db); $author = new User($db);
$author->fetch($object->user_author_id); $author->fetch($object->user_author_id);
@ -108,57 +111,67 @@ if ($object->id > 0)
$totalsize+=$file['size']; $totalsize+=$file['size'];
} }
// Supplier order card
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref $morehtmlref='<div class="refidno">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>'; // Ref supplier
print '<td colspan="2">'; $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
print '</td>'; // Thirdparty
print '</tr>'; $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
// Fournisseur if (! empty($conf->projet->enabled))
print '<tr><td>'.$langs->trans("Supplier")."</td>";
print '<td colspan="2">'.$object->thirdparty->getNomUrl(1,'supplier').'</td>';
print '</tr>';
// Statut
print '<tr>';
print '<td>'.$langs->trans("Status").'</td>';
print '<td colspan="2">';
print $object->getLibStatut(4);
print "</td></tr>";
// Date
if ($object->methode_commande_id > 0)
{ {
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">'; $langs->load("projects");
if ($object->date_commande) $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->fournisseur->commande->creer)
{ {
print dol_print_date($object->date_commande,"dayhourtext")."\n"; if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
print "</td></tr>"; } else {
if (! empty($object->fk_project)) {
if ($object->methode_commande) $proj = new Project($db);
{ $proj->fetch($object->fk_project);
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->getInputMethod().'</td></tr>'; $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
} }
} }
}
$morehtmlref.='</div>';
// Auteur dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<tr><td>'.$langs->trans("AuthorRequest").'</td>';
print '<td colspan="2">'.$author->getNomUrl(1).'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print "</table>\n"; print "</table>\n";
print "</div>\n"; print "</div>\n";
dol_fiche_end();
$modulepart = 'commande_fournisseur'; $modulepart = 'commande_fournisseur';
$permission = $user->rights->fournisseur->commande->creer; $permission = $user->rights->fournisseur->commande->creer;
$permtoedit = $user->rights->fournisseur->commande->creer; $permtoedit = $user->rights->fournisseur->commande->creer;
@ -169,6 +182,7 @@ if ($object->id > 0)
else else
{ {
header('Location: index.php'); header('Location: index.php');
exit;
} }

View File

@ -130,7 +130,7 @@ if (empty($user->socid)) $fieldstosearchall["cf.note_private"]="NotePrivate";
$checkedtypetiers=0; $checkedtypetiers=0;
$arrayfields=array( $arrayfields=array(
'cf.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'cf.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplier"), 'checked'=>1, 'enabled'=>1), 'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplierShort"), 'checked'=>1, 'enabled'=>1),
'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1), 'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1),
'u.login'=>array('label'=>$langs->trans("AuthorRequest"), 'checked'=>1), 'u.login'=>array('label'=>$langs->trans("AuthorRequest"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
@ -293,7 +293,7 @@ if ($search_user > 0)
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
} }
$sql.= ' WHERE cf.fk_soc = s.rowid'; $sql.= ' WHERE cf.fk_soc = s.rowid';
$sql.= ' AND cf.entity IN ('.getEntity('commande_fournisseur', 1).')'; $sql.= ' AND cf.entity IN ('.getEntity('supplier_order', 1).')';
if ($socid > 0) $sql.= " AND s.rowid = ".$socid; if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($search_ref) $sql .= natural_search('cf.ref', $search_ref); if ($search_ref) $sql .= natural_search('cf.ref', $search_ref);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* *
@ -74,8 +74,7 @@ if ($id > 0 || ! empty($ref))
{ {
if ($result >= 0) if ($result >= 0)
{ {
$soc = new Societe($db); $object->fetch_thirdparty();
$soc->fetch($object->socid);
$author = new User($db); $author = new User($db);
$author->fetch($object->user_author_id); $author->fetch($object->user_author_id);
@ -85,61 +84,63 @@ if ($id > 0 || ! empty($ref))
$title=$langs->trans("SupplierOrder"); $title=$langs->trans("SupplierOrder");
dol_fiche_head($head, 'note', $title, 0, 'order'); dol_fiche_head($head, 'note', $title, 0, 'order');
// Supplier order card
/*
* Commande
*/
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref $morehtmlref='<div class="refidno">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>'; // Ref supplier
print '<td colspan="2">'; $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
print '</td>'; // Thirdparty
print '</tr>'; $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
// Fournisseur if (! empty($conf->projet->enabled))
print '<tr><td>'.$langs->trans("Supplier")."</td>";
print '<td colspan="2">'.$soc->getNomUrl(1,'supplier').'</td>';
print '</tr>';
// Statut
print '<tr>';
print '<td>'.$langs->trans("Status").'</td>';
print '<td colspan="2">';
print $object->getLibStatut(4);
print "</td></tr>";
// Date
if ($object->methode_commande_id > 0)
{ {
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">'; $langs->load("projects");
if ($object->date_commande) $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->fournisseur->commande->creer)
{ {
print dol_print_date($object->date_commande,"dayhourtext")."\n"; if ($action != 'classify')
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
print "</td></tr>"; } else {
if (! empty($object->fk_project)) {
if ($object->methode_commande) $proj = new Project($db);
{ $proj->fetch($object->fk_project);
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->getInputMethod().'</td></tr>'; $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
} }
} }
}
$morehtmlref.='</div>';
// Author dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<tr><td>'.$langs->trans("AuthorRequest").'</td>';
print '<td colspan="2">'.$author->getNomUrl(1).'</td>';
print '</tr>';
print "</table>";
print '<br>'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$colwidth=20;
$cssclass="titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
dol_fiche_end(); dol_fiche_end();
} }
else else

View File

@ -2342,7 +2342,7 @@ else
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';
$paymentstatic->id=$objp->rowid; $paymentstatic->id=$objp->rowid;
$paymentstatic->datepaye=$db->jdate($objp->dp); $paymentstatic->datepaye=$db->jdate($objp->dp);
$paymentstatic->ref=$objp->ref; $paymentstatic->ref=($objp->ref ? $objp->ref : $objp->rowid);;
$paymentstatic->num_paiement=$objp->num_paiement; $paymentstatic->num_paiement=$objp->num_paiement;
$paymentstatic->payment_code=$objp->payment_code; $paymentstatic->payment_code=$objp->payment_code;
print $paymentstatic->getNomUrl(1); print $paymentstatic->getNomUrl(1);

View File

@ -247,9 +247,9 @@ llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:Factur
$sql = "SELECT"; $sql = "SELECT";
if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT'; if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite,"; $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,";
$sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label,"; $sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,";
$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,";
$sql.= " typent.code as typent_code,"; $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= " p.rowid as project_id, p.ref as project_ref"; $sql.= " p.rowid as project_id, p.ref as project_ref";

View File

@ -530,6 +530,14 @@ if ($step == 3 && $datatoimport)
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">'; print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
print '<input type="hidden" value="'.$step.'" name="step">';
print '<input type="hidden" value="'.$format.'" name="format">';
print '<input type="hidden" value="'.$excludefirstline.'" name="excludefirstline">';
print '<input type="hidden" value="'.$endatlinenb.'" name="endatlinenb">';
print '<input type="hidden" value="'.$separator.'" name="separator">';
print '<input type="hidden" value="'.$enclosure.'" name="enclosure">';
print '<input type="hidden" value="'.$datatoimport.'" name="datatoimport">';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">'; print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
$filetoimport=''; $filetoimport='';
@ -543,14 +551,30 @@ if ($step == 3 && $datatoimport)
$var=false; $var=false;
print '<tr '.$bc[$var].'><td colspan="6">'; print '<tr '.$bc[$var].'><td colspan="6">';
print '<input type="file" name="userfile" size="20" maxlength="80"> &nbsp; &nbsp; '; print '<input type="file" name="userfile" size="20" maxlength="80"> &nbsp; &nbsp; ';
print '<input type="submit" class="button" value="'.$langs->trans("AddFile").'" name="sendit">'; $out = (empty($conf->global->MAIN_UPLOAD_DOC)?' disabled':'');
print '<input type="hidden" value="'.$step.'" name="step">'; print '<input type="submit" class="button" value="'.$langs->trans("AddFile").'"'.$out.' name="sendit">';
print '<input type="hidden" value="'.$format.'" name="format">'; $out='';
print '<input type="hidden" value="'.$excludefirstline.'" name="excludefirstline">'; if (! empty($conf->global->MAIN_UPLOAD_DOC))
print '<input type="hidden" value="'.$endatlinenb.'" name="endatlinenb">'; {
print '<input type="hidden" value="'.$separator.'" name="separator">'; $max=$conf->global->MAIN_UPLOAD_DOC; // En Kb
print '<input type="hidden" value="'.$enclosure.'" name="enclosure">'; $maxphp=@ini_get('upload_max_filesize'); // En inconnu
print '<input type="hidden" value="'.$datatoimport.'" name="datatoimport">'; if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp*1;
if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024;
if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024;
if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024;
// Now $max and $maxphp are in Kb
if ($maxphp > 0) $max=min($max,$maxphp);
$langs->load('other');
$out .= ' ';
$out.=info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
}
else
{
$out .= ' ('.$langs->trans("UploadDisabled").')';
}
print $out;
print '</td>';
print "</tr>\n"; print "</tr>\n";
// Search available imports // Search available imports
@ -867,12 +891,13 @@ if ($step == 4 && $datatoimport)
print '<tr '.$bc[$var].' height="'.$height.'">'; print '<tr '.$bc[$var].' height="'.$height.'">';
$i++; $i++;
$entity=(! empty($objimport->array_import_entities[0][$code])?$objimport->array_import_entities[0][$code]:$objimport->array_import_icon[0]); $entity=(! empty($objimport->array_import_entities[0][$code])?$objimport->array_import_entities[0][$code]:$objimport->array_import_icon[0]);
$tablealias=preg_replace('/(\..*)$/i','',$code); $tablealias=preg_replace('/(\..*)$/i','',$code);
$tablename=$objimport->array_import_tables[0][$tablealias]; $tablename=$objimport->array_import_tables[0][$tablealias];
$entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity;
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity; $entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ...
$entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ...
print '<td class="nowrap" style="font-weight: normal">=>'.img_object('',$entityicon).' '.$langs->trans($entitylang).'</td>'; print '<td class="nowrap" style="font-weight: normal">=>'.img_object('',$entityicon).' '.$langs->trans($entitylang).'</td>';
print '<td style="font-weight: normal">'; print '<td style="font-weight: normal">';

View File

@ -173,7 +173,7 @@ if (empty($user->societe_id))
! empty($conf->propal->enabled) && $user->rights->propale->lire, ! empty($conf->propal->enabled) && $user->rights->propale->lire,
! empty($conf->commande->enabled) && $user->rights->commande->lire, ! empty($conf->commande->enabled) && $user->rights->commande->lire,
! empty($conf->facture->enabled) && $user->rights->facture->lire, ! empty($conf->facture->enabled) && $user->rights->facture->lire,
! empty($conf->contrat->enabled) && $user->rights->contrat->activer, ! empty($conf->contrat->enabled) && $user->rights->contrat->lire,
! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire,
! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), ! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS),
! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), ! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS),

View File

@ -243,3 +243,6 @@ ALTER TABLE llx_expensereport ADD UNIQUE INDEX idx_expensereport_uk_ref (ref, en
UPDATE llx_projet_task SET ref = NULL WHERE ref = ''; UPDATE llx_projet_task SET ref = NULL WHERE ref = '';
ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity); ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity);
ALTER TABLE llx_contrat ADD COLUMN fk_user_modif integer;

View File

@ -21,6 +21,13 @@
-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
-- VMYSQL4.1 update llx_facture set date_pointoftax = NULL where DATE(STR_TO_DATE(date_pointoftax, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- VMYSQL4.1 update llx_facture set date_pointoftax = NULL where DATE(STR_TO_DATE(date_pointoftax, '%Y-%m-%d')) IS NULL;
-- Requests to clean corrupted database -- Requests to clean corrupted database
@ -294,3 +301,19 @@ DELETE FROM llx_c_shipment_mode where code IN (select code from tmp_c_shipment_m
drop table tmp_c_shipment_mode; drop table tmp_c_shipment_mode;
-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
-- VMYSQL4.1 update llx_expensereport set date_debut = date_create where DATE(STR_TO_DATE(date_debut, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- VMYSQL4.1 update llx_expensereport set date_debut = date_create where DATE(STR_TO_DATE(date_debut, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
-- VMYSQL4.1 update llx_expensereport set date_fin = date_debut where DATE(STR_TO_DATE(date_fin, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- VMYSQL4.1 update llx_expensereport set date_fin = date_debut where DATE(STR_TO_DATE(date_fin, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
-- VMYSQL4.1 update llx_expensereport set date_valid = date_fin where DATE(STR_TO_DATE(date_valid, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- VMYSQL4.1 update llx_expensereport set date_valid = date_fin where DATE(STR_TO_DATE(date_valid, '%Y-%m-%d')) IS NULL;

View File

@ -38,6 +38,7 @@ create table llx_contrat
fk_commercial_signature integer, -- obsolete fk_commercial_signature integer, -- obsolete
fk_commercial_suivi integer, -- obsolete fk_commercial_suivi integer, -- obsolete
fk_user_author integer NOT NULL default 0, fk_user_author integer NOT NULL default 0,
fk_user_modif integer,
fk_user_mise_en_service integer, fk_user_mise_en_service integer,
fk_user_cloture integer, fk_user_cloture integer,
note_private text, note_private text,

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