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

This commit is contained in:
Laurent Destailleur 2015-01-22 23:14:40 +01:00
commit 4aa4f5f5e9
225 changed files with 14779 additions and 11432 deletions

View File

@ -18,6 +18,7 @@ php:
- "5.3"
- "5.4"
- "5.5"
- "5.6"
env:
- DB=mysql

View File

@ -236,6 +236,18 @@ source_file = htdocs/langs/en_US/paypal.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.printgcp]
file_filter = htdocs/langs/<lang>/printgcp.lang
source_file = htdocs/langs/en_US/printgcp.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.printing]
file_filter = htdocs/langs/<lang>/printing.lang
source_file = htdocs/langs/en_US/printing.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.printipp]
file_filter = htdocs/langs/<lang>/printipp.lang
source_file = htdocs/langs/en_US/printipp.lang

View File

@ -52,6 +52,9 @@ http://www.fsf.org/licensing/licenses/index_html
Copyright
---------
Copyright (C) 2015
- Marcos García <marcosgdf@gmail.com>
Copyright (C) 2014
- Laurent Destailleur <eldy@users.sourceforge.net>
- Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>

View File

@ -1,6 +1,9 @@
--------------------------------------------------------------
English Dolibarr ChangeLog
--------------------------------------------------------------
***** ChangeLog for 3.8 compared to 3.7.* *****
- New: Add Option to not change date on cloning project
- New: Add check list from table for extrafield type
***** ChangeLog for 3.8 compared to 3.7.* *****
@ -8,7 +11,11 @@ For users:
- New: Use new combobox.
- New: Add hidden option MAXTABS_IN_CARD.
- Fix / Improve : [ bug #1747 ] Remove creation of batch 'Undefined'
- Add Weighted average price as default price for buying price for margin calculation. Add option
MARGIN_PMP_AS_DEFAULT_BUY_PRICE to replace with first supplier price.
- Introduce option MAIN_HTML_TITLE to start to control format of html title content.
- Add extrafields on bank account cards.
- Added delay between mails in Newsletter module
For translators:
- Update language files.
@ -188,6 +195,20 @@ Dolibarr better:
***** ChangeLog for 3.6.3 compared to 3.6.2 *****
- Fix: ref_ext was not saved when recording a customer order from web service
- Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid.
- Fix: withdrawal create error if in the same month are deleted previus withdrawals.
- Fix: [ bug #1788 ] Duplicated doActions hook in product/fournisseurs.php
- Fix: withdrawal create error if in the same month are deleted previus withdrawals.
- Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules
- Fix: [ bug #1802 ] SQL error when updating a task with PostgreSQL database
- Fix: [ bug #1785 ] Start date is lost in Project > Linked objects
- Fix: [ bug #1804 ] SQL error when sending email without addresee
- Fix: [ bug #1803 ] AJAX company contact input is not aligned
- Fix: [ bug #1787 ] Incorrect behaviour of doActions hook
- Fix: [ bug #1796 ] Unable to use numeration modules from an external module
- Fix: [ bug #1783 ] SQL error when enabling 3rd party module with PostgreSQL and MySQL strict mode ON
- Fix: [ bug #1717 ] Sorting unpaid invoices by amount received brings due amount
- Fix: [ bug #1784 ] MOTD doesn't show up in Amarok theme
***** ChangeLog for 3.6.2 compared to 3.6.1 *****
- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.
@ -352,6 +373,8 @@ Fix: Paypal link were broken dur to SSL v3 closed.
Fix: [ bug #1769 ] Error when installing to a PostgreSQL DB that contains numbers
Fix: [ bug #1752 ] Date filter of margins module, filters since 12H instead of 00H
Fix: [ bug #1757 ] Sorting breaks product/service statistics
Fix: [ bug #1797 ] Tulip supplier invoice module takes creation date instead of invoice date
Fix: [ bug #1792 ] Users are not allowed to see margins module index page when no product view permission is enabled
***** ChangeLog for 3.5.6 compared to 3.5.5 *****
Fix: Avoid missing class error for fetch_thirdparty method #1973

View File

@ -11,7 +11,6 @@ beta version of Dolibarr, step by step.
- Update version/info in /ChangeLog
- Update version number with x.y.z-w in htdocs/filefunc.inc.php
- Update version number with x.y.z-w in build/debian/changelog
- Update version number with x.y.z-w in build/exe/doliwamp/doliwamp.iss
- Update version number with x.y.z-w in build/rpm/*.spec
- Commit all changes.
- Add a Tag (x.y.betaz_YYYYMMDD) and push it: git push --tags
@ -30,10 +29,9 @@ This files describe steps made by Dolibarr packaging team to make a
complete release of Dolibarr, step by step.
- Check all files are commited.
- Update version/info in ChangeLog
- Update version/info in ChangeLog. To generate a changelog, you can do "git log x.y.z..HEAD --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e '^Fix\|New\|Sec'"
- Update version number with x.y.z in htdocs/filefunc.inc.php
- Update version number with x.y.z in build/debian/changelog
- Update version number with x.y.z in build/exe/doliwamp/doliwamp.iss
- Update version number with x.y.z in build/rpm/*.spec
- Commit all changes.

View File

@ -253,14 +253,80 @@
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamName">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.Missing" />
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn" />
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired" />
<rule ref="PEAR.Commenting.FunctionComment.Missing" />
<!-- TODO Remove this and fix reported errors -->
<rule ref="PEAR.Commenting.ClassComment.Missing">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.Missing">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.Missing@authorTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.Missing@categoryTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.Missing@licenseTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.Missing@linkTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.Missing@packageTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.MissingAuthorTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.MissingCategoryTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.MissingLicenseTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.MissingLinkTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.ClassComment.MissingPackageTag">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamType">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamName">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamType">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParamName">
<severity>0</severity>
</rule>
<!-- TODO Remove this and fix reported errors -->
<rule ref="PEAR.Commenting.ClassComment.Missing">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.MissingReturn">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.ReturnNotRequired">
<severity>0</severity>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.Missing">
<severity>0</severity>
</rule>
>>>>>>> refs/remotes/origin/3.7
<!--
<rule ref="PEAR.Commenting.FileComment" />
<rule ref="PEAR.Commenting.FileComment.WrongStyle">

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
# ldapadd_sample1.txt
# ldapadd is into package ldap-utils on debian.
#
# Use this sample to add a dc "my-domain".
# This is the first thing to create

View File

@ -1,4 +1,5 @@
# ldapadd_sample2.txt
# ldapadd is into package ldap-utils on debian.
#
# Use this sample to add a ou "contacts"
# This is the second thing to create after creating the root my-domain

View File

@ -1,4 +1,5 @@
# ldapadd_sample3.txt
# ldapadd is into package ldap-utils on debian.
#
# Use this sample to add cn records
# This is the step to create records inside tree ou=contacts,dc=my-domain,dc=com

View File

@ -1,4 +1,5 @@
# ldapdelete_sample1.txt
# ldapdelete is into package ldap-utils on debian.
#
# Use this sample to delete a dc "my-domain"
# This delete the first level of LDAP tree.

View File

@ -1,4 +1,5 @@
# ldapdelete_sample3.txt
# ldapdelete is into package ldap-utils on debian.
#
# Use this sample to delete cn records
# This is the step to delete a cn record stored inside tree ou=contacts,dc=my-domain,dc=com

View File

@ -1,4 +1,5 @@
# ldapmodify_sample1.txt
# ldapmodify is into package ldap-utils on debian.
#
# Use this sample to modify a dc "my-domain"
#

View File

@ -0,0 +1,9 @@
# ldapsearch_sample1.txt
# ldapsearch is into package ldap-utils on debian.
#
# Use this sample to search into a ldap
#
# ldapsearch -h hostname -x
# ldapsearch -h hostname -x -b "ou=people,dc=teclib,dc=infra"
# ldapsearch -h hostname -x -z 0 -b "o=somecompany.com" -D "cn=manager,o=somecompany.com" -W "(objectclass=*)"
# ldapsearch -h hostname -x -b "o=somecompany.com" -D "cn=manager,o=somecompany.com" -W "(objectclass=*)"

View File

@ -27,7 +27,7 @@
/**
* Class to manage accounting accounts
*/
class AccountingAccount
class AccountingAccount extends CommonObject
{
var $db;
var $error;
@ -126,6 +126,7 @@ class AccountingAccount
{
global $conf, $langs;
$error = 0;
$now = dol_now();
$now=dol_now();
@ -447,4 +448,4 @@ class AccountingAccount
return - 1;
}
}
}
}

View File

@ -221,7 +221,7 @@ class BookKeeping extends CommonObject
* Insert line into bookkeeping
*
* @param User $user User who inserted operation
* @return $result Result
* @return int <0 KO >0 OK
*/
function create($user='')
{
@ -276,8 +276,9 @@ class BookKeeping extends CommonObject
}
$now = dol_now();
if (empty($this->date_create))
$this->date_create = $now();
if (empty($this->date_create)) {
$this->date_create = $now;
}
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, ";
$sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,";
@ -330,23 +331,19 @@ class BookKeeping extends CommonObject
$sql .= " WHERE import_key = '" . $importkey . "'";
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
// Commit or rollback
if ($error) {
if (! $resql) {
$this->errors[] = "Error " . $this->db->lasterror();
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
return - 1;
}
$this->db->commit();
return 1;
}
/**
@ -595,16 +592,13 @@ class BookKeeping extends CommonObject
$this->db->begin();
if (! $error)
{
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
}
// if (! $notrigger)
// {
// // Call trigger
// $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user);
// if ($result < 0) $error++;
// // End call triggers
// }
if (! $error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
@ -712,4 +706,4 @@ class BookKeepingLine
var $fk_user_author;
var $code_journal;
var $piece_num;
}
}

View File

@ -235,4 +235,4 @@ if ($result) {
}
$db->close();
llxFooter();
llxFooter();

View File

@ -143,9 +143,9 @@ if ($result) {
$obj = $db->fetch_object($result);
$tabcompany[$obj->rowid] = array(
'id' => $obj->socid,
'name' => $obj->name,
'code_client' => $obj->code_compta
'id' => $obj->socid,
'name' => $obj->name,
'code_client' => $obj->code_compta
);
// Controls
@ -169,84 +169,130 @@ if ($result) {
}
$links = $object->get_url($obj->rowid);
foreach ( $links as $key => $val )
// get_url may return -1 which is not traversable
if (is_array($links))
{
$tabtype[$obj->rowid] = $links[$key]['type'];
foreach ($links as $key => $val)
{
$tabtype[$obj->rowid] = $links[$key]['type'];
if ($links[$key]['type'] == 'payment')
{
$paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
}
else if ($links[$key]['type'] == 'payment_supplier')
{
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
}
else if ($links[$key]['type'] == 'company')
{
$societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
}
else if ($links[$key]['type'] == 'sc')
{
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
$chargestatic->lib = $langs->trans($reg[1]);
}
else
if ($links[$key]['type'] == 'payment')
{
$chargestatic->lib = $links[$key]['label'];
$paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
}
$chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid)
else if ($links[$key]['type'] == 'payment_supplier')
{
$objmid = $db->fetch_object($resultmid);
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
}
else if ($links[$key]['type'] == 'company')
{
$societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
}
else if ($links[$key]['type'] == 'sc')
{
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
$chargestatic->lib = $langs->trans($reg[1]);
}
else if ($links[$key]['type'] == 'company')
{
$societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
}
else if ($links[$key]['type'] == 'sc')
{
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
$chargestatic->lib = $langs->trans($reg[1]);
}
else
{
$chargestatic->lib = $links[$key]['label'];
}
$chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid)
{
$objmid = $db->fetch_object($resultmid);
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
}
}
else if ($links[$key]['type'] == 'payment_vat')
{
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
else if ($links[$key]['type'] == 'payment_salary')
{
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
$tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount;
}
else if ($links[$key]['type'] == 'banktransfert')
{
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
/*else {
$tabtp [$obj->rowid] [$accountancy_account_salary] += $obj->amount;
}*/
}
else if ($links[$key]['type'] == 'payment_vat')
{
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
else if ($links[$key]['type'] == 'payment_salary')
{
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
$tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount;
}
else if ($links[$key]['type'] == 'banktransfert')
{
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
/*else {
$tabtp [$obj->rowid] [$accountancy_account_salary] += $obj->amount;
}*/
}
else if ($links[$key]['type'] == 'payment_vat')
{
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
else if ($links[$key]['type'] == 'payment_salary')
{
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
$tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount;
}
else if ($links[$key]['type'] == 'banktransfert')
{
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
/*else {
$tabtp [$obj->rowid] [$accountancy_account_salary] += $obj->amount;
}*/
}
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
@ -265,10 +311,10 @@ if ($result) {
if ($action == 'writeBookKeeping')
{
$error = 0;
foreach ( $tabpay as $key => $val )
foreach ($tabpay as $key => $val)
{
// Bank
foreach ( $tabbq[$key] as $k => $mt )
foreach ($tabbq[$key] as $k => $mt)
{
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
@ -320,7 +366,7 @@ if ($action == 'writeBookKeeping')
}
}
// Third party
foreach ( $tabtp[$key] as $k => $mt )
foreach ($tabtp[$key] as $k => $mt)
{
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];

View File

@ -131,7 +131,8 @@ if ($result) {
$tabtype = array ();
$i = 0;
while ( $i < $num ) {
while ($i < $num)
{
$obj = $db->fetch_object($result);
// controls
@ -155,65 +156,61 @@ if ($result) {
}
$links = $object->get_url($obj->rowid);
foreach ( $links as $key => $val ) {
// get_url may return -1 which is not traversable
if (is_array($links))
{
foreach ( $links as $key => $val )
{
$tabtype[$obj->rowid] = $links[$key]['type'];
$tabtype[$obj->rowid] = $links[$key]['type'];
if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'company') {
if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
} else if ($links[$key]['type'] == 'sc') {
$societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
} else if ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
$chargestatic->lib = $langs->trans($reg[1]);
} else {
$chargestatic->lib = $links[$key]['label'];
}
$chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
$chargestatic->lib = $langs->trans($reg[1]);
} else {
$chargestatic->lib = $links[$key]['label'];
$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
}
/*else {
$tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
}*/
}
$chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountancy/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
}
} else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
} else if ($links[$key]['type'] == 'banktransfert') {
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
/*else {
$tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
}*/
}
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
@ -229,11 +226,14 @@ if ($result) {
*/
// write bookkeeping
if ($action == 'writeBookKeeping') {
if ($action == 'writeBookKeeping')
{
$error = 0;
foreach ( $tabpay as $key => $val ) {
foreach ( $tabpay as $key => $val )
{
// cash
foreach ( $tabbq[$key] as $k => $mt ) {
foreach ( $tabbq[$key] as $k => $mt )
{
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@ -249,8 +249,8 @@ if ($action == 'writeBookKeeping') {
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
$bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL;
if ($tabtype[$key] == 'payment') {
if ($tabtype[$key] == 'payment')
{
$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
@ -528,4 +528,4 @@ if ($action == 'export_csv') {
// End of page
llxFooter();
}
$db->close();
$db->close();

View File

@ -241,7 +241,7 @@ if ($action == 'writebookkeeping') {
* View
*/
$companystatic = new Societe($db);
$companystatic = new Fournisseur($db);
// export csv
if ($action == 'export_csv')
@ -406,7 +406,6 @@ if ($action == 'export_csv')
$r = '';
$invoicestatic = new FactureFournisseur($db);
$companystatic = new Fournisseur($db);
foreach ( $tabfac as $key => $val ) {
$invoicestatic->id = $key;
@ -469,4 +468,4 @@ if ($action == 'export_csv')
// End of page
llxFooter();
}
$db->close();
$db->close();

View File

@ -7,6 +7,7 @@
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -100,9 +101,9 @@ if (! empty($conf->multicompany->enabled)) {
}
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2)";
$sql .= " AND f.type IN (0,1,2,5)";
else
$sql .= " AND f.type IN (0,1,2,3)";
$sql .= " AND f.type IN (0,1,2,3,5)";
$sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
@ -136,6 +137,16 @@ if ($result) {
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_ACCOUNT : $langs->trans("CodeNotDef");
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
// Situation invoices handling
$line = new FactureLigne($db);
$line->fetch($obj->id);
$prev_progress = $line->get_prev_progress();
if ($obj->situation_percent == 0) { // Avoid divide by 0
$situation_ratio = 0;
} else {
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
}
// Invoice lines
$tabfac[$obj->rowid]["date"] = $obj->df;
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
@ -148,9 +159,9 @@ if ($result) {
$tabht[$obj->rowid][$compta_prod] = 0;
if (! isset($tabtva[$obj->rowid][$compta_tva]))
$tabtva[$obj->rowid][$compta_tva] = 0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
@ -471,4 +482,4 @@ if ($action == 'export_csv') {
// End of page
llxFooter();
}
$db->close();
$db->close();

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,10 @@ class Adherent extends CommonObject
var $mesgs;
var $id;
var $ref;
public $ref_ext;
var $civility_id;
var $firstname;
var $lastname;
@ -107,6 +110,7 @@ class Adherent extends CommonObject
var $oldcopy; // To contains a clone of this when we need to save old properties of object
public $entity;
/**
* Constructor
@ -1237,7 +1241,7 @@ class Adherent extends CommonObject
/**
* Insert subscription into database and eventually add links to banks, mailman, etc...
*
* @param timestamp $date Date of effect of subscription
* @param int $date Date of effect of subscription
* @param double $montant Amount of subscription (0 accepted for some members)
* @param int $accountid Id bank account
* @param string $operation Type operation (if Id bank account provided)
@ -1245,7 +1249,7 @@ class Adherent extends CommonObject
* @param string $num_chq Numero cheque (if Id bank account provided)
* @param string $emetteur_nom Name of cheque writer
* @param string $emetteur_banque Name of bank of cheque
* @param timestamp $datesubend Date end subscription
* @param int $datesubend Date end subscription
* @return int rowid of record added, <0 if KO
*/
function cotisation($date, $montant, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0)
@ -1559,25 +1563,26 @@ class Adherent extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowMember").': '.$this->ref;
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
if ($option == 'card')
{
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id.$linkclose;
$lienfin='</a>';
}
if ($option == 'subscription')
{
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/card_subscriptions.php?rowid='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/card_subscriptions.php?rowid='.$this->id.$linkclose;
$lienfin='</a>';
}
if ($option == 'category')
{
$lien = '<a href="'.DOL_URL_ROOT.'/categories/categorie.php?id='.$this->id.'&type=3">';
$lien = '<a href="'.DOL_URL_ROOT.'/categories/categorie.php?id='.$this->id.'&type=3'.$linkclose;
$lienfin='</a>';
}
$picto='user';
$label=$langs->trans("ShowMember");
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
@ -1601,7 +1606,7 @@ class Adherent extends CommonObject
*
* @param int $statut Id statut
* @param int $need_subscription 1 si type adherent avec cotisation, 0 sinon
* @param timestamp $date_end_subscription Date fin adhesion
* @param int $date_end_subscription Date fin adhesion
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label
*/

View File

@ -60,7 +60,7 @@ class AdherentType extends CommonObject
* Fonction qui permet de creer le status de l'adherent
*
* @param User $user User making creation
* @return >0 if OK, < 0 if KO
* @return int >0 if OK, < 0 if KO
*/
function create($user)
{
@ -248,13 +248,13 @@ class AdherentType extends CommonObject
$i++;
}
}
return $projets;
}
else
{
print $this->db->error();
}
return $projets;
}
@ -270,12 +270,12 @@ class AdherentType extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowTypeCard",$this->libelle);
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='group';
$label=$langs->trans("ShowTypeCard",$this->libelle);
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
@ -287,7 +287,7 @@ class AdherentType extends CommonObject
/**
* getMailOnValid
*
* @return Return mail model
* @return string Return mail model
*/
function getMailOnValid()
{
@ -306,7 +306,7 @@ class AdherentType extends CommonObject
/**
* getMailOnSubscription
*
* @return Return mail model
* @return string Return mail model
*/
function getMailOnSubscription()
{
@ -325,7 +325,7 @@ class AdherentType extends CommonObject
/**
* getMailOnResiliate
*
* @return Return mail model
* @return string Return mail model
*/
function getMailOnResiliate()
{

View File

@ -264,12 +264,12 @@ class Cotisation extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowSubscription").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='payment';
$label=$langs->trans("ShowSubscription");
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -171,7 +171,7 @@ $message.='<br>';
print $message;
$message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'<br>';
//$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login);

View File

@ -26,6 +26,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$langs->load("admin");
@ -86,11 +87,15 @@ $form=new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("BankSetupModule"),$linkback,'setup');
print '<br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_BANK_CHEQUERECEIPT_FREE_TEXT">';
$head = bank_admin_prepare_head(null);
dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), 0, 'account');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td>';
@ -183,7 +188,11 @@ while ($i < $nbofbank)
}
print '</table>'."\n";
dol_fiche_end();
print '</form>';
$db->close();
llxFooter();
$db->close();

View File

@ -0,0 +1,154 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/bank_extrafields.php
* \ingroup bank
* \brief Page to setup extra fields of bank
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("banks");
$langs->load("admin");
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='bank_account'; //Must be the $element of the class that manage extrafield
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
llxHeader('',$langs->trans("BankSetupModule"),$help_url);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("BankSetupModule"),$linkback,'setup');
$head = bank_admin_prepare_head(null);
dol_fiche_head($head, 'attributes', $langs->trans("BankSetupModule"), 0, 'account');
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
print '<br>';
// Load attribute_label
$extrafields->fetch_name_optionals_label($elementtype);
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td align="center">'.$langs->trans("Position").'</td>';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Unique").'</td>';
print '<td align="center">'.$langs->trans("Required").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=True;
foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td>".$extrafields->attribute_pos[$key]."</td>\n";
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
print "</tr>";
// $i++;
}
print "</table>";
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation d'un champ optionnel
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();

View File

@ -348,18 +348,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$commande->type=0;
$nextval=$module->getNextValue($mysoc,$commande);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);

View File

@ -299,18 +299,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$contract);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);

View File

@ -324,18 +324,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$expedition);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);

View File

@ -393,61 +393,53 @@ foreach ($dirmodels as $reldir)
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=$langs->trans("NextValueForInvoices").': ';
if ($nextval)
{
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
}
else
{
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
// Example for remplacement
$facture->type=1;
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=$langs->trans("NextValueForReplacements").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=$langs->trans("NextValueForReplacements").': ';
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
// Example for credit invoice
$facture->type=2;
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=$langs->trans("NextValueForCreditNotes").': ';
if ($nextval)
{
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
}
else
{
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
// Example for deposit invoice
$facture->type=3;
$nextval=$module->getNextValue($mysoc,$facture);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=$langs->trans("NextValueForDeposit").': ';
if ($nextval)
{
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval;
}
else
{
} else {
$htmltooltip.=$langs->trans($module->error);
}
}

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 Philippe Grand <philippe.grand@atoo-net.com>
*
@ -328,10 +328,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$ficheinter);
if ($nextval != $langs->trans("NotAvailable"))
{
$htmltooltip.=''.$langs->trans("NextValue").': '.$nextval;
}
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>';

View File

@ -309,15 +309,13 @@ foreach ($dirmodels as $reldir)
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$livraison);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
}
else
{
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}

View File

@ -48,11 +48,14 @@ if ($action == 'setvalue')
$mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha');
$checkread = GETPOST('value','alpha');
$checkread_key = GETPOST('MAILING_EMAIL_UNSUBSCRIBE_KEY','alpha');
$mailingdelay = GETPOST('MAILING_DELAY', 'int');
$res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res=dolibarr_set_const($db, "MAILING_DELAY",$mailingdelay,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
// Create temporary encryption key if nedded
$res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY",$checkread_key,'chaine',0,'',$conf->entity);
@ -124,6 +127,12 @@ print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf
if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail"));
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("MailingDelay").'</td><td>';
print '<input size="32" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
print '</td></tr>';
// Constant to add salt into the unsubscribe and check read tag.
// It is also used as a security key parameter.
$var=!$var;

View File

@ -65,12 +65,12 @@ if ($action == 'update' && empty($_POST["cancel"]))
{
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity);
// Send mode parameters
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',0);
if (isset($_POST["MAIN_MAIL_SMTP_PORT"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',0);
if (isset($_POST["MAIN_MAIL_SMTP_SERVER"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',0);
if (isset($_POST["MAIN_MAIL_SMTPS_ID"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',0);
if (isset($_POST["MAIN_MAIL_SMTPS_PW"])) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',0);
if (isset($_POST["MAIN_MAIL_EMAIL_TLS"])) dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',0);
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',$conf->entity);
// Content parameters
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity);

View File

@ -344,18 +344,16 @@ foreach ($dirmodels as $reldir)
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$propal->type=0;
$nextval=$module->getNextValue($mysoc,$propal);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);

View File

@ -278,15 +278,13 @@ foreach ($dirmodels as $reldir)
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$invoice);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
}
else
{
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}

View File

@ -279,15 +279,13 @@ foreach ($dirmodels as $reldir)
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$commande);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
}
else
{
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}

View File

@ -278,7 +278,7 @@ if ($socid)
// Address
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3">';
print dol_print_address($soc->address,'gmap','thirdparty',$object->id);
print dol_print_address($soc->address,'gmap','thirdparty',$soc->id);
print '</td></tr>';
// Zip / Town

View File

@ -1274,9 +1274,9 @@ class Categorie extends CommonObject
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'">';
$label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label);
$lien = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='category';

View File

@ -118,6 +118,13 @@ class ActionComm extends CommonObject
$error=0;
$now=dol_now();
// Check parameters
if (empty($this->userownerid))
{
$this->errors[]='ErrorPropertyUserowneridNotDefined';
return -1;
}
// Clean parameters
$this->label=dol_trunc(trim($this->label),128);
$this->location=dol_trunc(trim($this->location),128);
@ -138,9 +145,20 @@ class ActionComm extends CommonObject
if ($this->elementtype=='commande') $this->elementtype='order';
if ($this->elementtype=='contrat') $this->elementtype='contract';
if (! is_array($this->userassigned)) // For backward compatibility
{
$tmpid=$this->userassigned;
$this->userassigned=array();
$this->userassigned[$tmpid]=array('id'=>$tmpid);
}
$userownerid=$this->userownerid;
$userdoneid=$this->userdoneid;
// Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...).
if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned))
$this->userassigned = array($userownerid=>array('id'=>$userownerid));
if (! $this->type_id || ! $this->type_code)
{
$key=empty($this->type_id)?$this->type_code:$this->type_id;
@ -226,6 +244,12 @@ class ActionComm extends CommonObject
{
foreach($this->userassigned as $key => $val)
{
if (! is_array($val)) // For backward compatibility when val=id
{
$tmpid=$val;
$val=array('id'=>$val);
}
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
$sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".($val['mandatory']?$val['mandatory']:'0').", ".($val['transparency']?$val['transparency']:'0').", ".($val['answer_status']?$val['answer_status']:'0').")";
@ -873,11 +897,12 @@ class ActionComm extends CommonObject
global $conf,$langs;
$result='';
if ($option=='birthday') $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.'">';
else $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id.'">';
$lienfin='</a>';
$label=$this->label;
if (empty($label)) $label=$this->libelle; // For backward compatibility
if (empty($label)) $label=$this->libelle; // For backward compatibility
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
if ($option=='birthday') $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.$linkclose;
else $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id.$linkclose;
$lienfin='</a>';
//print 'rrr'.$this->libelle.'-'.$withpicto;
if ($withpicto == 2)
@ -973,7 +998,7 @@ class ActionComm extends CommonObject
$sql.= " a.label, a.code, a.note, a.fk_action as type_id,";
$sql.= " a.fk_soc,";
$sql.= " a.fk_user_author, a.fk_user_mod,";
$sql.= " a.fk_user_action, a.fk_user_done,";
$sql.= " a.fk_user_action,";
$sql.= " a.fk_contact, a.percent as percentage,";
$sql.= " a.fk_element, a.elementtype,";
$sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,";
@ -981,9 +1006,11 @@ class ActionComm extends CommonObject
$sql.= " s.nom as socname,";
$sql.= " c.id as type_id, c.code as type_code, c.libelle";
$sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
$sql.= " WHERE a.fk_action=c.id";
// We must filter on assignement table
if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
$sql.= " WHERE a.fk_action=c.id";
$sql.= " AND a.entity = ".$conf->entity;
foreach ($filters as $key => $value)
{
@ -993,17 +1020,8 @@ class ActionComm extends CommonObject
if ($key == 'idfrom') $sql.=" AND a.id >= ".(is_numeric($value)?$value:0);
if ($key == 'idto') $sql.=" AND a.id <= ".(is_numeric($value)?$value:0);
if ($key == 'project') $sql.=" AND a.fk_project=".(is_numeric($value)?$value:0);
if ($key == 'login')
{
$login=$value;
$userforfilter=new User($this->db);
$result=$userforfilter->fetch('',$value);
$sql.= " AND (";
$sql.= " a.fk_user_author = ".$userforfilter->id;
$sql.= " OR a.fk_user_action = ".$userforfilter->id;
$sql.= " OR a.fk_user_done = ".$userforfilter->id;
$sql.= ")";
}
// We must filter on assignement table
if ($key == 'logint' || $key == 'login') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($key == 'logina')
{
$logina=$value;
@ -1011,19 +1029,12 @@ class ActionComm extends CommonObject
$result=$userforfilter->fetch('',$value);
$sql.= " AND a.fk_user_author = ".$userforfilter->id;
}
if ($key == 'logint')
if ($key == 'logint' || $key == 'login')
{
$logint=$value;
$userforfilter=new User($this->db);
$result=$userforfilter->fetch('',$value);
$sql.= " AND a.fk_user_action = ".$userforfilter->id;
}
if ($key == 'logind')
{
$logind=$value;
$userforfilter=new User($this->db);
$result=$userforfilter->fetch('',$value);
$sql.= " AND a.fk_user_done = ".$userforfilter->id;
$sql.= " AND ar.fk_element = ".$userforfilter->id;
}
}
$sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import

View File

@ -40,9 +40,7 @@ if (! empty($conf->projet->enabled)) {
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
$filter=GETPOST("filter",'',3);
$filtera = GETPOST("userasked","int",3)?GETPOST("userasked","int",3):GETPOST("filtera","int",3);
$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3);
$filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filterd","int",3);
$usergroup = GETPOST("usergroup","int",3);
$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
@ -72,9 +70,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden();
if (! $user->rights->agenda->allactions->read) $canedit=0;
if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me
{
$filtera=$user->id;
$filtert=$user->id;
$filterd=$user->id;
}
$action=GETPOST('action','alpha');
@ -283,9 +279,7 @@ $param='';
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
if ($filter) $param.="&filter=".$filter;
if ($filtera) $param.="&filtera=".$filtera;
if ($filtert) $param.="&filtert=".$filtert;
if ($filterd) $param.="&filterd=".$filterd;
if ($socid) $param.="&socid=".$socid;
if ($showbirthday) $param.="&showbirthday=1";
if ($pid) $param.="&projectid=".$pid;
@ -340,7 +334,7 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
$head = calendars_prepare_head($paramnoaction);
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup);
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,$listofextcals,$actioncode,$usergroup);
dol_fiche_end();
$showextcals=$listofextcals;
@ -405,27 +399,29 @@ print_fiche_titre($s,$link.' &nbsp; &nbsp; '.$nav, '');
// Get event in an array
$eventarray=array();
$sql = 'SELECT a.id,a.label,';
$sql = 'SELECT ';
if ($usergroup > 0) $sql.=" DISTINCT";
$sql.= ' a.id, a.label,';
$sql.= ' a.datep,';
$sql.= ' a.datep2,';
$sql.= ' a.datea,';
$sql.= ' a.datea2,';
$sql.= ' a.percent,';
$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,';
$sql.= ' a.fk_user_author,a.fk_user_action,';
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql.= ' a.fk_soc, a.fk_contact,';
$sql.= ' ca.code as type_code, ca.libelle as type_label';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql.= ' WHERE a.fk_action = ca.id';
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
if ($actioncode) $sql.=" AND ca.code='".$db->escape($actioncode)."'";
if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid;
// FIXME: We must filter on assignement table
if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($action == 'show_day')
{
$sql.= " AND (";
@ -459,14 +455,12 @@ if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
// FIXME: We must filter on assignement table
if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0)
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0)
{
$sql.= " AND (";
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert;
if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
$sql.= ")";
}
// Sort on date
@ -1000,7 +994,7 @@ elseif ($action == 'show_week') // View by week
{
// Show days of the current week
$curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd');
$tmparray = dol_getdate($curtime,'fast');
$tmparray = dol_getdate($curtime, true);
$tmpday = $tmparray['mday'];
$tmpmonth = $tmparray['mon'];
$tmpyear = $tmparray['year'];
@ -1094,7 +1088,7 @@ $db->close();
function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60)
{
global $user, $conf, $langs;
global $action, $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form
global $action, $filter, $filtert, $status, $actioncode; // Filters used into search form
global $theme_datacolor;
global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
@ -1383,7 +1377,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
{
print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action='.$action.'&maxprint=0&month='.$monthshown.'&year='.$year;
print ($status?'&status='.$status:'').($filter?'&filter='.$filter:'');
print ($filtera?'&filtera='.$filtera:'').($filtert?'&filtert='.$filtert:'').($filterd?'&filterd='.$filterd:'');
print ($filtert?'&filtert='.$filtert:'');
print ($actioncode!=''?'&actioncode='.$actioncode:'');
print '">'.img_picto("all","1downarrow_selected.png").' ...';
print ' +'.(count($eventarray[$daykey])-$maxprint);

View File

@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
$langs->load("users");
$langs->load("companies");
$langs->load("agenda");
$langs->load("commercial");
@ -52,9 +53,7 @@ if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $s
if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW);
$filter=GETPOST("filter",'',3);
$filtera = GETPOST("userasked","int",3)?GETPOST("userasked","int",3):GETPOST("filtera","int",3);
$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3);
$filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filterd","int",3);
$usergroup = GETPOST("usergroup","int",3);
$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
@ -94,9 +93,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden();
if (! $user->rights->agenda->allactions->read) $canedit=0;
if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permission to see all, we show only affected to me
{
$filtera=$user->id;
$filtert=$user->id;
$filterd=$user->id;
}
// Purge search criteria
@ -133,15 +130,14 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
*/
$form=new Form($db);
$userstatic=new User($db);
$nav='';
$nav.=' &nbsp; <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
if ($status || isset($_GET['status']) || isset($_POST['status'])) $nav.='<input type="hidden" name="status" value="'.$status.'">';
if ($filter) $nav.='<input type="hidden" name="filter" value="'.$filter.'">';
if ($filtera) $nav.='<input type="hidden" name="filtera" value="'.$filtera.'">';
if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
if ($filterd) $nav.='<input type="hidden" name="filterd" value="'.$filterd.'">';
if ($socid) $nav.='<input type="hidden" name="socid" value="'.$socid.'">';
if ($showbirthday) $nav.='<input type="hidden" name="showbirthday" value="1">';
if ($pid) $nav.='<input type="hidden" name="projectid" value="'.$pid.'">';
@ -163,65 +159,57 @@ $param='';
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
if ($filter) $param.="&filter=".$filter;
if ($filtera) $param.="&filtera=".$filtera;
if ($filtert) $param.="&filtert=".$filtert;
if ($filterd) $param.="&filterd=".$filterd;
if ($socid) $param.="&socid=".$socid;
if ($showbirthday) $param.="&showbirthday=1";
if ($pid) $param.="&projectid=".$pid;
if ($type) $param.="&type=".$type;
if ($usergroup) $param.="&usergroup=".$usergroup;
$sql = "SELECT s.nom as societe, s.rowid as socid, s.client,";
$sql.= " a.id, a.datep as dp, a.datep2 as dp2,";
$sql.= " a.fk_contact, a.note, a.label, a.percent as percent,";
$sql = "SELECT";
if ($usergroup > 0) $sql.=" DISTINCT";
$sql.= " s.nom as societe, s.rowid as socid, s.client,";
$sql.= " a.id, a.label, a.datep as dp, a.datep2 as dp2,";
$sql.= ' a.fk_user_author,a.fk_user_action,';
$sql.= " a.fk_contact, a.note, a.percent as percent,";
$sql.= " c.code as type_code, c.libelle as type_label,";
$sql.= " ua.login as loginauthor, ua.rowid as useridauthor,";
$sql.= " ut.login as logintodo, ut.rowid as useridtodo,";
//$sql.= " ud.login as logindone, ud.rowid as useriddone,";
$sql.= " sp.lastname, sp.firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c,";
$sql.= " ".MAIN_DB_PREFIX.'user as u,';
$sql.= " ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON a.fk_user_author = ua.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ut ON a.fk_user_action = ut.rowid";
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ud ON a.fk_user_done = ud.rowid";
if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql.= " WHERE c.id = a.fk_action";
$sql.= ' AND a.fk_user_author = u.rowid';
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
if ($actioncode) $sql.=" AND c.code='".$db->escape($actioncode)."'";
if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
// FIXME: We must filter on assignement table
if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($type) $sql.= " AND c.id = ".$type;
if ($status == '0') { $sql.= " AND a.percent = 0"; }
if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
// FIXME: We must filter on assignement table
if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0)
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0)
{
$sql.= " AND (";
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert;
if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
$sql.= ")";
}
// The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
if ($dateselect > 0) $sql.= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect-3600)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."'))";
if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'";
if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'";
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1, $offset);
//print $sql;
dol_syslog("comm/action/listactions.php", LOG_DEBUG);
@ -246,7 +234,7 @@ if ($resql)
$head = calendars_prepare_head($param);
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$action,-1,$actioncode,$usergroup);
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,0,$filtert,0,$pid,$socid,$action,-1,$actioncode,$usergroup);
dol_fiche_end();
// Add link to show birthdays
@ -275,14 +263,11 @@ if ($resql)
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
//print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder);
//print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"ut.login",$param,"","",$sortfield,$sortorder);
//print_liste_field_titre($langs->trans("DoneBy"),$_SERVER["PHP_SELF"],"ud.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ActionsOwnedBy"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@ -375,46 +360,16 @@ if ($resql)
}
print '</td>';
// User author
/*
print '<td align="left">';
if ($obj->useridauthor)
{
$userstatic=new User($db);
$userstatic->id=$obj->useridauthor;
$userstatic->login=$obj->loginauthor;
print $userstatic->getLoginUrl(1);
}
else print '&nbsp;';
print '</td>';
*/
// User to do
print '<td align="left">';
if ($obj->useridtodo)
if ($obj->fk_user_action > 0)
{
$userstatic=new User($db);
$userstatic->id=$obj->useridtodo;
$userstatic->login=$obj->logintodo;
$userstatic->fetch($obj->fk_user_action);
print $userstatic->getLoginUrl(1);
}
else print '&nbsp;';
print '</td>';
// User did
/*
print '<td align="left">';
if ($obj->useriddone)
{
$userstatic=new User($db);
$userstatic->id=$obj->useriddone;
$userstatic->login=$obj->logindone;
print $userstatic->getLoginUrl(1);
}
else print '&nbsp;';
print '</td>';
*/
// Status/Percent
print '<td align="right" class="nowrap">'.$actionstatic->LibStatut($obj->percent,6).'</td>';
@ -434,6 +389,6 @@ else
}
$db->close();
llxFooter();
$db->close();

View File

@ -39,9 +39,7 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
$filter=GETPOST("filter",'',3);
$filtera = GETPOST("userasked","int",3)?GETPOST("userasked","int",3):GETPOST("filtera","int",3);
$filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3);
$filterd = GETPOST("userdone","int",3)?GETPOST("userdone","int",3):GETPOST("filterd","int",3);
$usergroup = GETPOST("usergroup","int",3);
//if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id;
//$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
@ -73,9 +71,7 @@ if (! $user->rights->agenda->myactions->read) accessforbidden();
if (! $user->rights->agenda->allactions->read) $canedit=0;
if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no permission to see all, we show only affected to me
{
$filtera=$user->id;
$filtert=$user->id;
$filterd=$user->id;
}
//$action=GETPOST('action','alpha');
@ -130,6 +126,7 @@ if (GETPOST('viewday') || $action == 'show_day') {
} // View by day
$langs->load("users");
$langs->load("agenda");
$langs->load("other");
$langs->load("commercial");
@ -198,9 +195,7 @@ $param='';
if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param.="&actioncode=".$actioncode;
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
if ($filter) $param.="&filter=".$filter;
if ($filtera) $param.="&filtera=".$filtera;
if ($filtert) $param.="&filtert=".$filtert;
if ($filterd) $param.="&filterd=".$filterd;
if ($usergroup) $param.="&usergroup=".$usergroup;
if ($socid) $param.="&socid=".$socid;
if ($showbirthday) $param.="&showbirthday=1";
@ -280,7 +275,7 @@ $paramnoaction=preg_replace('/action=[a-z_]+/','',$param);
$head = calendars_prepare_head($paramnoaction);
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup);
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup);
dol_fiche_end();
$showextcals=$listofextcals;
@ -332,27 +327,29 @@ print_fiche_titre($s,$link.' &nbsp; &nbsp; '.$nav, '');
// Get event in an array
$eventarray=array();
$sql = 'SELECT a.id,a.label,';
$sql = 'SELECT';
if ($usergroup > 0) $sql.=" DISTINCT";
$sql.= ' a.id, a.label,';
$sql.= ' a.datep,';
$sql.= ' a.datep2,';
$sql.= ' a.datea,';
$sql.= ' a.datea2,';
$sql.= ' a.percent,';
$sql.= ' a.fk_user_author,a.fk_user_action,a.fk_user_done,';
$sql.= ' a.fk_user_author,a.fk_user_action,';
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,';
$sql.= ' ca.code, ca.color';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
if ($usergroup > 0) $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ugu";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
$sql.= ' WHERE a.fk_action = ca.id';
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
if ($actioncode) $sql.=" AND ca.code='".$db->escape($actioncode)."'";
if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid);
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
if ($socid > 0) $sql.= ' AND a.fk_soc = '.$socid;
// FIXME: We must filter on assignement table
if ($usergroup > 0) $sql.= " AND ugu.fk_user = a.fk_user_action";
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($action == 'show_day')
{
$sql.= " AND (";
@ -386,14 +383,12 @@ if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable
if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started
if ($status == 'done' || $status == '100') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; }
if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; }
// FIXME: We must filter on assignement table
if ($filtera > 0 || $filtert > 0 || $filterd > 0 || $usergroup > 0)
// We must filter on assignement table
if ($filtert > 0 || $usergroup > 0)
{
$sql.= " AND (";
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
if ($usergroup > 0) $sql.= ($filtera>0||$filtert>0||$filterd>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
if ($filtert > 0) $sql.= "ar.fk_element = ".$filtert;
if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup;
$sql.= ")";
}
// Sort on date
@ -679,7 +674,7 @@ foreach ($usernames as $username)
{
$var = ! $var;
echo "<tr>";
echo '<td class="cal_current_month"'.($var?' style="background: #F8F8F8"':'').'>' . $username->getNomUrl(1). '</td>';
echo '<td class="cal_current_month cal_peruserviewname"'.($var?' style="background: #F8F8F8"':'').'>' . $username->getNomUrl(1). '</td>';
$tmpday = $sav;
// Lopp on each day of week
@ -809,7 +804,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
{
global $db;
global $user, $conf, $langs, $hookmanager, $action;
global $filter, $filtera, $filtert, $filterd, $status, $actioncode; // Filters used into search form
global $filter, $filtert, $status, $actioncode; // Filters used into search form
global $theme_datacolor; // Array with a list of different we can use (come from theme)
global $cachethirdparties, $cachecontacts, $colorindexused;
global $begin_h, $end_h;
@ -905,9 +900,9 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
$newcolor = ''; //init
if (empty($event->fulldayevent))
{
$a = dol_mktime((int) $h,0,0,$month,$day,$year,false,false);
$b = dol_mktime((int) $h,30,0,$month,$day,$year,false,false);
$c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,false);
$a = dol_mktime((int) $h,0,0,$month,$day,$year,false,0);
$b = dol_mktime((int) $h,30,0,$month,$day,$year,false,0);
$c = dol_mktime((int) $h+1,0,0,$month,$day,$year,false,0);
$dateendtouse=$event->date_end_in_calendar;
if ($dateendtouse==$event->date_start_in_calendar) $dateendtouse++;

View File

@ -66,6 +66,7 @@ $pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom";
$cancelbutton = GETPOST('cancel');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('commcard','globalcard'));
@ -80,12 +81,14 @@ $parameters = array('socid' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
//Some actions show a "cancel" input submit button with name="cancel"
$cancelbutton = GETPOST('cancel');
if ($action == 'setcustomeraccountancycode')
if (empty($reshook))
{
if (! $cancelbutton)
if ($cancelbutton)
{
$action="";
}
if ($action == 'setcustomeraccountancycode')
{
$result=$object->fetch($id);
$object->code_compta=$_POST["customeraccountancycode"];
@ -95,57 +98,52 @@ if ($action == 'setcustomeraccountancycode')
setEventMessage($object->errors, 'errors');
}
}
$action="";
}
// conditions de reglement
if ($action == 'setconditions' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// mode de reglement
if ($action == 'setmode' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// assujetissement a la TVA
if ($action == 'setassujtva' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->tva_assuj=$_POST['assujtva_value'];
// conditions de reglement
if ($action == 'setconditions' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// TODO move to DAO class
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$id."'";
$result = $db->query($sql);
if (! $result) dol_print_error($result);
}
// mode de reglement
if ($action == 'setmode' && $user->rights->societe->creer)
{
$object->fetch($id);
$result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
// set prospect level
if ($action == 'setprospectlevel' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->fk_prospectlevel=GETPOST('prospect_level_id','alpha');
$result=$object->set_prospect_level($user);
if ($result < 0) setEventMessage($object->error,'errors');
}
// assujetissement a la TVA
if ($action == 'setassujtva' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->tva_assuj=$_POST['assujtva_value'];
$result=$object->update($object->id);
if ($result < 0) dol_print_error($db,$object->error);
}
// Update communication level
if ($action == 'cstc')
{
$object->fetch($id);
$object->stcomm_id=GETPOST('stcomm','int');
$result=$object->set_commnucation_level($user);
if ($result < 0) setEventMessage($object->error,'errors');
}
// set prospect level
if ($action == 'setprospectlevel' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->fk_prospectlevel=GETPOST('prospect_level_id','alpha');
$result=$object->set_prospect_level($user);
if ($result < 0) setEventMessage($object->error,'errors');
}
// Update communication level
if ($action == 'setOutstandingBill')
{
if (!$cancelbutton)
// update prospect level
if ($action == 'cstc')
{
$object->fetch($id);
$object->stcomm_id=GETPOST('stcomm','int');
$result=$object->set_commnucation_level($user);
if ($result < 0) setEventMessage($object->error,'errors');
}
// update outstandng limit
if ($action == 'setOutstandingBill')
{
$object->fetch($id);
$object->outstanding_limit=GETPOST('OutstandingBill');
@ -159,14 +157,24 @@ if ($action == 'setOutstandingBill')
* View
*/
llxHeader('',$langs->trans('CustomerCard'));
$contactstatic = new Contact($db);
$userstatic=new User($db);
$form = new Form($db);
$formcompany=new FormCompany($db);
if ($id > 0 && empty($object->id))
{
// Load data of third party
$res=$object->fetch($id);
if ($object->id <= 0) dol_print_error($db,$object->error);
}
$title=$langs->trans("CustomerCard");
if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name;
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('',$title,$help_url);
if ($mode == 'search')
{
@ -196,14 +204,6 @@ if ($mode == 'search')
if ($id > 0)
{
// Load data of third party
$object->fetch($id);
if ($object->id <= 0)
{
dol_print_error($db,$object->error);
}
$head = societe_prepare_head($object);
dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"),0,'company');
@ -519,7 +519,7 @@ if ($id > 0)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id.'">'.$langs->trans("AllPropals").' ('.$num.')</a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id.'">'.$langs->trans("AllPropals").' <span class="badge">'.$num.'</span></a></td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';
@ -531,11 +531,13 @@ if ($id > 0)
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td class="nowrap"><a href="propal.php?id='.$objp->propalid.'">'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.'</a>'."\n";
if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 )
{
print " ".img_warning();
}
print '<td class="nowrap">';
$propal_static->id=$objp->propalid;
$propal_static->ref=$objp->ref;
print $propal_static->getNomUrl(1);
if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 ) {
print " ".img_warning();
}
print '</td><td align="right" width="80">'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
print '<td align="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
print '<td align="right" style="min-width: 60px" class="nowrap">'.$propal_static->LibStatut($objp->fk_statut,5).'</td></tr>';
@ -592,7 +594,7 @@ if ($id > 0)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' ('.$num.')</a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'">'.$langs->trans("AllOrders").' <span class="badge">'.$num.'</span></a></td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
//if($num2 > 0) print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').'</a></td>';
//else print '<td width="20px" align="right"><a href="#">'.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'</a></td>';
@ -606,7 +608,10 @@ if ($id > 0)
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$objp->cid.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$objp->ref."</a>\n";
print '<td class="nowrap">';
$commande_static->id=$objp->cid;
$commande_static->ref=$objp->ref;
print $commande_static->getNomUrl(1);
print '</td><td align="right" width="80">'.dol_print_date($db->jdate($objp->dc),'day')."</td>\n";
print '<td align="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
print '<td align="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut,$objp->facture,5).'</td></tr>';
@ -647,7 +652,7 @@ if ($id > 0)
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastContracts",($num<=$MAXLIST?"":$MAXLIST)).'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->id.'">'.$langs->trans("AllContracts").' ('.$num.')</a></td></tr></table></td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->id.'">'.$langs->trans("AllContracts").' <span class="badge">'.$num.'</span></a></td></tr></table></td>';
print '</tr>';
}
$i = 0;
@ -706,7 +711,7 @@ if ($id > 0)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'">'.$langs->trans("AllInterventions").' ('.$num.')</td></tr></table></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/fichinter/list.php?socid='.$object->id.'">'.$langs->trans("AllInterventions").' <span class="badge">'.$num.'</span></td></tr></table></td>';
print '</tr>';
$var=!$var;
}
@ -769,7 +774,7 @@ if ($id > 0)
$tableaushown=1;
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllBills").' ('.$num.')</a></td>';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllBills").' <span class="badge">'.$num.'</span></a></td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';

View File

@ -142,7 +142,7 @@ if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
*/
if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
{
$sql = "SELECT p.rowid, p.ref, p.total_ht, s.rowid as socid, s.nom as name, s.client, s.canvas";
$sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, s.rowid as socid, s.nom as name, s.client, s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -172,6 +172,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
print '<tr '.$bc[$var].'><td class="nowrap">';
$propalstatic->id=$obj->rowid;
$propalstatic->ref=$obj->ref;
$propalstatic->ref_client=$obj->ref_client;
print $propalstatic->getNomUrl(1);
print '</td>';
print '<td class="nowrap">';
@ -209,7 +210,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
{
$langs->load("orders");
$sql = "SELECT c.rowid, c.ref, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
$sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -239,6 +240,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
print '<tr '.$bc[$var].'><td class="nowrap">';
$orderstatic->id=$obj->rowid;
$orderstatic->ref=$obj->ref;
$orderstatic->ref_client=$obj->ref_client;
print $orderstatic->getNomUrl(1);
print '</td>';
print '<td class="nowrap">';
@ -467,7 +469,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
{
$langs->load("propal");
$sql = "SELECT s.nom as name, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql = "SELECT s.nom as name, s.rowid, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -503,6 +505,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
$propalstatic->id=$obj->propalid;
$propalstatic->ref=$obj->ref;
$propalstatic->ref_client=$obj->ref_client;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2550,21 +2550,18 @@ class Propal extends CommonObject
{
$mybool=false;
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file = $conf->global->PROPALE_ADDON.".php";
$classname = $conf->global->PROPALE_ADDON;
$file = $conf->global->PROPALE_ADDON.".php";
$classname = $conf->global->PROPALE_ADDON;
// Include file with class
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot.$reldir."/core/modules/propale/";
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
}
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/propale/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
if (! $mybool)
{
@ -2581,14 +2578,14 @@ class Propal extends CommonObject
return $numref;
}
else
{
{
$this->error=$obj->error;
//dol_print_error($db,"Propale::getNextNumRef ".$obj->error);
return "";
}
}
else
{
{
$langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
return "";
@ -2608,29 +2605,31 @@ class Propal extends CommonObject
global $langs;
$result='';
if ($option == '')
{
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$this->id. $get_params .'">';
$label=$langs->trans("ShowPropal").': '.$this->ref;
if (! empty($this->ref_client))
$label.= '<br>'.$langs->trans('RefCustomer').': '.$this->ref_client;
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
if ($option == '') {
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$this->id. $get_params .$linkclose;
}
if ($option == 'compta') // deprecated
{
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$this->id. $get_params .'">';
if ($option == 'compta') { // deprecated
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$this->id. $get_params .$linkclose;
}
if ($option == 'expedition')
{
$lien = '<a href="'.DOL_URL_ROOT.'/expedition/propal.php?id='.$this->id. $get_params .'">';
if ($option == 'expedition') {
$lien = '<a href="'.DOL_URL_ROOT.'/expedition/propal.php?id='.$this->id. $get_params .$linkclose;
}
if ($option == 'document')
{
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id. $get_params .'">';
if ($option == 'document') {
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id. $get_params .$linkclose;
}
$lienfin='</a>';
$picto='propal';
$label=$langs->trans("ShowPropal").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto)
$result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2)
$result.=' ';
$result.=$lien.$this->ref.$lienfin;
return $result;
}

View File

@ -313,7 +313,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1">('.$num.')</a></td></tr>';
print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>';
$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
while ($i < $nbofloop)
@ -399,7 +399,7 @@ if (! empty($conf->propal->enabled))
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("ProposalsToProcess").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1">('.$num.')</a></td></tr>';
print '<td colspan="3">'.$langs->trans("ProposalsToProcess").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>';
if ($num)
{
@ -471,7 +471,7 @@ if (! empty($conf->propal->enabled))
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("OnProcessOrders").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=2">('.$num.')</a></td></tr>';
print '<td colspan="3">'.$langs->trans("OnProcessOrders").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=2"><span class="badge">'.$num.'</span></a></td></tr>';
if ($num)
{

View File

@ -177,11 +177,13 @@ $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($action == 'cstc')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"];
$sql .= " WHERE rowid = ".$_GET["socid"];
$result=$db->query($sql);
if (empty($reshook)) {
if ($action == 'cstc')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"];
$sql .= " WHERE rowid = ".$_GET["socid"];
$result=$db->query($sql);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -140,26 +140,25 @@ class Commande extends CommonOrder
if (! empty($conf->global->COMMANDE_ADDON))
{
$mybool=false;
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file = $conf->global->COMMANDE_ADDON.".php";
$classname = $conf->global->COMMANDE_ADDON;
$mybool=false;
// Include file with class
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot.$reldir."/core/modules/commande/";
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
}
$file = $conf->global->COMMANDE_ADDON.".php";
$classname = $conf->global->COMMANDE_ADDON;
// Include file with class
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/commande/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
dol_print_error('',"Failed to include file ".$file);
return '';
}
$obj = new $classname();
@ -2885,11 +2884,13 @@ class Commande extends CommonOrder
if ($short) return $url;
$linkstart = '<a href="'.$url.'">';
$linkend='</a>';
$picto='order';
$label=$langs->trans("ShowOrder").': '.$this->ref;
if (! empty($this->ref_client))
$label.= '<br>'.$langs->trans('RefCustomer').': '.$this->ref_client;
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -303,7 +303,7 @@ if (! empty($conf->commande->enabled))
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("OrdersToProcess").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1">('.$num.')</a></td></tr>';
print '<td colspan="3">'.$langs->trans("OrdersToProcess").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>';
if ($num)
{
@ -374,7 +374,7 @@ if (! empty($conf->commande->enabled))
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("OnProcessOrders").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=2">('.$num.')</a></td></tr>';
print '<td colspan="3">'.$langs->trans("OnProcessOrders").' <a href="'.DOL_URL_ROOT.'/commande/list.php?viewstatut=2"><span class="badge">'.$num.'</span></a></td></tr>';
if ($num)
{

View File

@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$langs->load("banks");
$langs->load("categories");
@ -48,6 +49,10 @@ $fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'banque',$id,'bank_account&bank_account','','',$fieldid);
$account = new Account($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($account->table_element);
/*
* Actions
@ -100,6 +105,9 @@ if ($_POST["action"] == 'add')
$error++;
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$account);
if (! $error)
{
$id = $account->create($user);
@ -172,6 +180,9 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
$error++;
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$account);
if (! $error)
{
$result = $account->update($user);
@ -306,6 +317,15 @@ if ($action == 'create')
$doleditor=new DolEditor('account_comment',$account->comment,'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70);
$doleditor->Create();
print '</td></tr>';
// Other attributes
$parameters=array('colspan' => 3);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $account->showOptionals($extrafields,'edit',$parameters);
}
print '</table>';
@ -464,6 +484,14 @@ else
print '<tr><td valign="top">'.$langs->trans("Comment").'</td>';
print '<td colspan="3">'.$account->comment.'</td></tr>';
// Other attributes
$parameters=array('colspan' => 3);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $account->showOptionals($extrafields);
}
print '</table>';
print '<br>';
@ -621,6 +649,15 @@ else
$doleditor->Create();
print '</td></tr>';
// Other attributes
$parameters=array('colspan' => 3);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $account->showOptionals($extrafields,'edit');
}
print '</table>';
print '<br>';

View File

@ -164,10 +164,10 @@ class Account extends CommonObject
* TODO Move this into AccountLine
* Return array with links from llx_bank_url
*
* @param int $fk_bank To search using bank transaction id
* @param int $url_id To search using link to
* @param string $type To search using type
* @return array Array of links
* @param int $fk_bank To search using bank transaction id
* @param int $url_id To search using link to
* @param string $type To search using type
* @return array|-1 Array of links or -1 on error
*/
function get_url($fk_bank='', $url_id='', $type='')
{
@ -343,7 +343,7 @@ class Account extends CommonObject
*/
function create($user='')
{
global $langs,$conf;
global $langs,$conf, $hookmanager;
// Clean parameters
if (! $this->min_allowed) $this->min_allowed=0;
@ -441,6 +441,23 @@ class Account extends CommonObject
$this->error=$this->db->lasterror();
return -3;
}
// Actions on extra fields (by external module or standard code)
$hookmanager->initHooks(array('bankdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
return -4;
}
}
}
else if ($reshook < 0) return -5;
}
return $this->id;
}
@ -466,7 +483,7 @@ class Account extends CommonObject
*/
function update($user='')
{
global $langs,$conf;
global $langs,$conf, $hookmanager;
// Clean parameters
if (! $this->min_allowed) $this->min_allowed=0;
@ -517,6 +534,25 @@ class Account extends CommonObject
$result = $this->db->query($sql);
if ($result)
{
// Actions on extra fields (by external module or standard code)
$hookmanager->initHooks(array('bankdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
return -1;
}
}
}
else if ($reshook < 0) return -1;
return 1;
}
else
@ -662,6 +698,15 @@ class Account extends CommonObject
$this->min_allowed = $obj->min_allowed;
$this->min_desired = $obj->min_desired;
$this->comment = $obj->comment;
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
return 1;
}
else
@ -693,6 +738,18 @@ class Account extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
// Remove extrafields
if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields();
if ($result < 0)
{
return -1;
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
}
}
return 1;
}
else {
@ -878,15 +935,16 @@ class Account extends CommonObject
global $langs;
$result='';
$linkclose = '" title="'.dol_escape_htmltag($this->label, 1).'" class="classfortooltip">';
if (empty($mode))
{
$lien = '<a href="'.DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id.$linkclose;
$lienfin='</a>';
}
else if ($mode == 'transactions')
{
$lien = '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$this->id.$linkclose;
$lienfin='</a>';
}
@ -1426,11 +1484,11 @@ class AccountLine extends CommonObject
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$this->rowid.'">';
$label=$langs->trans("ShowTransaction").': '.$this->rowid;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$this->rowid.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowTransaction"), 'account', 'class="classfortooltip"').$lienfin.' ');
if ($withpicto) $result.=($lien.img_object($label, 'account', 'class="classfortooltip"').$lienfin.' ');
$result.=$lien.$this->rowid.$lienfin;
if ($option == 'showall' || $option == 'showconciliated') $result.=' (';

View File

@ -358,7 +358,7 @@ if ($result)
print '</a>';
}
else if ($links[$key]['type']=='user') {
print '<a href="'.DOL_URL_ROOT.'/user/fiche?id='.$links[$key]['url_id'].'">';
print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowUser'),'user').' ';
print $langs->trans("User");
print '</a>';

View File

@ -357,13 +357,13 @@ class Deplacement extends CommonObject
global $langs;
$result='';
$label=$langs->trans("Show").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='trip';
$label=$langs->trans("Show").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -711,13 +711,13 @@ class Don extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowDonation").': '.$this->id;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/dons/card.php?rowid='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/dons/card.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='generic';
$label=$langs->trans("ShowDonation").': '.$this->id;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';

File diff suppressed because it is too large Load Diff

View File

@ -558,13 +558,13 @@ class FactureRec extends Facture
global $langs;
$result='';
$label=$langs->trans("ShowInvoice").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/facture/fiche-rec.php?facid='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/facture/fiche-rec.php?facid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='bill';
$label=$langs->trans("ShowInvoice").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -10,6 +10,8 @@
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2014 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012-2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
@ -122,6 +124,21 @@ class Facture extends CommonInvoice
var $fac_rec;
/**
* @var int Situation cycle reference number
*/
public $situation_cycle_ref;
/**
* @var int Situation counter inside the cycle
*/
public $situation_counter;
/**
* @var bool Final situation flag
*/
public $situation_final;
/**
* Standard invoice
*/
@ -147,6 +164,11 @@ class Facture extends CommonInvoice
*/
const TYPE_PROFORMA = 4;
/**
* Situation invoice
*/
const TYPE_SITUATION = 5;
/**
* Constructor
*
@ -248,6 +270,7 @@ class Facture extends CommonInvoice
$sql.= ", fk_account";
$sql.= ", fk_facture_source, fk_user_author, fk_projet";
$sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf";
$sql.= ", situation_cycle_ref, situation_counter, situation_final";
$sql.= ")";
$sql.= " VALUES (";
$sql.= "'(PROV)'";
@ -256,20 +279,24 @@ class Facture extends CommonInvoice
$sql.= ", '".$this->type."'";
$sql.= ", '".$socid."'";
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL');
$sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL');
$sql.= ", ".($this->remise_absolue>0?$this->remise_absolue:'NULL');
$sql.= ", ".($this->remise_percent>0?$this->remise_percent:'NULL');
$sql.= ", '".$this->db->idate($this->date)."'";
$sql.= ",".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ",".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ",".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null");
$sql.= ",".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
$sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null");
$sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
$sql.= ",".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null");
$sql.= ",".($user->id > 0 ? "'".$user->id."'":"null");
$sql.= ",".($this->fk_project?$this->fk_project:"null");
$sql.= ','.$this->cond_reglement_id;
$sql.= ",".$this->mode_reglement_id;
$sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."')";
$sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null");
$sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null");
$sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".$this->cond_reglement_id;
$sql.= ", ".$this->mode_reglement_id;
$sql.= ", '".$this->db->idate($datelim)."', '".$this->modelpdf."'";
$sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null");
$sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null");
$sql.= ", ".($this->situation_final?$this->situation_final:0);
$sql.=")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
@ -399,7 +426,9 @@ class Facture extends CommonInvoice
$this->lines[$i]->fk_fournprice,
$this->lines[$i]->pa_ht,
$this->lines[$i]->label,
$this->lines[$i]->array_options
$this->lines[$i]->array_options,
$this->lines[$i]->situation_percent,
$this->lines[$i]->fk_prev_id
);
if ($result < 0)
{
@ -451,7 +480,9 @@ class Facture extends CommonInvoice
0,
null,
0,
$_facrec->lines[$i]->label
$_facrec->lines[$i]->label,
null,
$_facrec->lines[$i]->situation_percent
);
if ( $result_insert < 0)
@ -556,10 +587,14 @@ class Facture extends CommonInvoice
$facture->lines = $this->lines; // Tableau des lignes de factures
$facture->products = $this->lines; // Tant que products encore utilise
$facture->situation_counter = $this->situation_counter;
$facture->situation_cycle_ref=$this->situation_cycle_ref;
$facture->situation_final = $this->situation_final;
// Loop on each line of new invoice
foreach($facture->lines as $i => $line)
{
$facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid;
if ($invertdetail)
{
$facture->lines[$i]->subprice = -$facture->lines[$i]->subprice;
@ -827,9 +862,10 @@ class Facture extends CommonInvoice
if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref;
if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref;
if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref;
if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref;
if ($moretitle) $label.=' - '.$moretitle;
$linkstart='<a href="'.$url.'">';
$linkstart='<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
if ($withpicto) $result.=($linkstart.img_object(($max?dol_trunc($label,$max):$label), $picto, 'class="classfortooltip"').$linkend);
@ -863,6 +899,7 @@ class Facture extends CommonInvoice
$sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf';
$sql.= ', f.fk_facture_source';
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams';
$sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final';
$sql.= ', f.fk_account';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
@ -923,7 +960,9 @@ class Facture extends CommonInvoice
$this->user_author = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid;
$this->modelpdf = $obj->model_pdf;
$this->situation_cycle_ref = $obj->situation_cycle_ref;
$this->situation_counter = $obj->situation_counter;
$this->situation_final = $obj->situation_final;
$this->extraparams = (array) json_decode($obj->extraparams, true);
if ($this->statut == 0) $this->brouillon = 1;
@ -974,6 +1013,7 @@ class Facture extends CommonInvoice
$this->lines=array();
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, ';
$sql .= ' l.situation_percent, l.fk_prev_id,';
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
$sql.= ' l.rang, l.special_code,';
$sql.= ' l.date_start as date_start, l.date_end as date_end,';
@ -1033,6 +1073,8 @@ class Facture extends CommonInvoice
$line->rang = $objp->rang;
$line->special_code = $objp->special_code;
$line->fk_parent_line = $objp->fk_parent_line;
$line->situation_percent= $objp->situation_percent;
$line->fk_prev_id = $objp->fk_prev_id;
$this->lines[$i] = $line;
@ -1073,6 +1115,17 @@ class Facture extends CommonInvoice
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
if (isset($this->import_key)) $this->import_key=trim($this->import_key);
if (empty($this->situation_cycle_ref)) {
$this->situation_cycle_ref = 'null';
}
if (empty($this->situation_counter)) {
$this->situation_counter = 'null';
}
if (empty($this->situation_final)) {
$this->situation_final = '0';
}
// Check parameters
// Put here code to add control on parameters values
@ -1110,7 +1163,10 @@ class Facture extends CommonInvoice
$sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").",";
$sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").",";
$sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").",";
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null")."";
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
$sql.= ", situation_cycle_ref=".$this->situation_cycle_ref;
$sql.= ", situation_counter=".$this->situation_counter;
$sql.= ", situation_final=".$this->situation_final;
$sql.= " WHERE rowid=".$this->id;
@ -1808,6 +1864,15 @@ class Facture extends CommonInvoice
$this->statut=1;
$this->brouillon=0;
$this->date_validation=$now;
$i = 0;
$final = True;
while ($i < count($this->lines) && $final == True) {
$final = ($this->lines[$i]->situation_percent == 100);
$i++;
}
if ($final) {
$this->setFinal();
}
}
}
else
@ -1947,9 +2012,11 @@ class Facture extends CommonInvoice
* @param int $pa_ht Buying price of line (to calculate margin) or ''
* @param string $label Label of the line (deprecated, do not use)
* @param array $array_option extrafields array
* @param int $situation_percent Situation advance percentage
* @param int $fk_prev_id Previous situation line id reference
* @return int <0 if KO, Id of line if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_option=0, $situation_percent=100, $fk_prev_id='')
{
global $mysoc, $conf, $langs;
@ -1966,6 +2033,8 @@ class Facture extends CommonInvoice
if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
if (empty($fk_prev_id)) $fk_prev_id = 'null';
if (is_null($situation_percent) || $situation_percent > 100) $situation_percent = 100;
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
@ -1999,7 +2068,7 @@ class Facture extends CommonInvoice
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
@ -2060,6 +2129,8 @@ class Facture extends CommonInvoice
$this->line->fk_parent_line=$fk_parent_line;
$this->line->origin=$origin;
$this->line->origin_id=$origin_id;
$this->line->situation_percent = $situation_percent;
$this->line->fk_prev_id = $fk_prev_id;
// infos marge
$this->line->fk_fournprice = $fk_fournprice;
@ -2121,9 +2192,10 @@ class Facture extends CommonInvoice
* @param string $label Label of the line (deprecated, do not use)
* @param int $special_code Special code (also used by externals modules!)
* @param array $array_option extrafields array
* @param int $situation_percent Situation advance percentage
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0, $situation_percent=0)
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -2139,6 +2211,8 @@ class Facture extends CommonInvoice
if (empty($qty)) $qty=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
if (empty($special_code) || $special_code == 3) $special_code=0;
if ($situation_percent > 100 || is_null($situation_percent) || $situation_percent == "") $situation_percent = 100;
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
@ -2157,7 +2231,7 @@ class Facture extends CommonInvoice
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type,'',$localtaxes_type);
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type,'',$localtaxes_type, $situation_percent);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
@ -2205,6 +2279,8 @@ class Facture extends CommonInvoice
$this->line->product_type = $type;
$this->line->fk_parent_line = $fk_parent_line;
$this->line->skip_update_total = $skip_update_total;
$this->line->situation_percent = $situation_percent;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
@ -2247,6 +2323,31 @@ class Facture extends CommonInvoice
}
}
/**
* Update invoice line with percentage
*
* @param FactureLigne $line Invoice line
* @param int $percent Percentage
* @return void
*/
function update_percent($line, $percent)
{
include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php');
// Cap percentages to 100
if ($percent > 100) $percent = 100;
$line->situation_percent = $percent;
$tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->product_type, 'HT', 0, 0, '', '', $percent);
$line->total_ht = $tabprice[0];
$line->total_tva = $tabprice[1];
$line->total_ttc = $tabprice[2];
$line->total_localtax1 = $tabprice[9];
$line->total_localtax2 = $tabprice[10];
$line->update();
$this->update_price(1);
$this->db->commit();
}
/**
* Delete line in database
*
@ -2497,52 +2598,64 @@ class Facture extends CommonInvoice
else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre';
else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure';
$mybool=false;
$file = $conf->global->FACTURE_ADDON.".php";
$classname = $conf->global->FACTURE_ADDON;
// Include file with class
foreach ($conf->file->dol_document_root as $dirroot)
if (! empty($conf->global->FACTURE_ADDON))
{
$dir = $dirroot."/core/modules/facture/";
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
$mybool=false;
$file = $conf->global->FACTURE_ADDON.".php";
$classname = $conf->global->FACTURE_ADDON;
// For compatibility
if (! $mybool)
{
$file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php";
$classname = "mod_facture_".$conf->global->FACTURE_ADDON;
$classname = preg_replace('/\-.*$/','',$classname);
// Include file with class
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot."/core/modules/facture/";
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/facture/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
}
//print "xx".$mybool.$dir.$file."-".$classname;
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
// For compatibility
if (! $mybool)
{
$file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php";
$classname = "mod_facture_".$conf->global->FACTURE_ADDON;
$classname = preg_replace('/\-.*$/','',$classname);
// Include file with class
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot."/core/modules/facture/";
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
}
$obj = new $classname();
$numref = "";
$numref = $obj->getNumRef($soc,$this,$mode);
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
if ($numref != "")
{
return $numref;
$obj = new $classname();
$numref = "";
$numref = $obj->getNextValue($soc,$this,$mode);
if ($numref != "")
{
return $numref;
}
else
{
dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
return "";
}
}
else
{
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
return false;
$langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
return "";
}
}
@ -2647,6 +2760,10 @@ class Facture extends CommonInvoice
if ($maxfacnumber == '' && $ventilExportCompta == 0) return 1;
// If invoice to delete is last one and not already dispatched, we can delete
if ($maxfacnumber == $this->ref && $ventilExportCompta == 0) return 1;
if ($this->situation_cycle_ref) {
$last = $this->is_last_in_cycle();
return $last;
}
}
else if ($this->statut == 0 && $facref == 'PROV') // Si facture brouillon et provisoire
{
@ -3206,6 +3323,7 @@ class Facture extends CommonInvoice
{
$sql = 'SELECT l.rowid, l.label as custom_label, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,';
$sql.= ' l.fk_remise_except, l.localtax1_tx, l.localtax2_tx,';
$sql .= ' l.situation_percent, l.fk_prev_id,';
$sql.= ' l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
$sql.= ' l.date_start, l.date_end,';
@ -3247,6 +3365,8 @@ class Facture extends CommonInvoice
$this->lines[$i]->total_tva = $obj->total_tva;
$this->lines[$i]->total_ttc = $obj->total_ttc;
$this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
$this->lines[$i]->situation_percent = $obj->situation_percent;
$this->lines[$i]->fk_prev_id = $obj->fk_prev_id;
$this->lines[$i]->special_code = $obj->special_code;
$this->lines[$i]->rang = $obj->rang;
$this->lines[$i]->date_start = $this->db->jdate($obj->date_start);
@ -3304,12 +3424,120 @@ class Facture extends CommonInvoice
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
/**
* Gets the smallest reference available for a new cycle
*
* @return int >= 1 if OK, -1 if error
*
*
*/
function newCycle()
{
$sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture';
$resql = $this->db->query($sql);
if ($resql) {
if ($resql->num_rows > 0) {
$res = $this->db->fetch_array($resql);
$ref = $res['max(situation_cycle_ref)'];
$ref++;
} else {
$ref = 1;
}
$this->db->free($resql);
return $ref;
} else {
$this->error = $this->db->error();
dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR);
return -1;
}
}
/**
* Checks if the invoice is the first of a cycle
*
* @return boolean
*/
function is_first()
{
return ($this->situation_counter == 1);
}
/**
* Returns an array containing the previous situations as Facture objects
*
* @return mixed -1 if error, array of previous situations
*/
function get_prev_sits()
{
$sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture';
$sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref;
$sql .= ' and situation_counter < ' . $this->situation_counter;
$resql = $this->db->query($sql);
$res = array();
if ($resql && $resql->num_rows > 0) {
while ($row = $this->db->fetch_object($resql)) {
$id = $row->rowid;
$situation = new Facture($this->db);
$situation->fetch($id);
$res[] = $situation;
}
} else {
$this->error = $this->db->error();
dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR);
return -1;
}
return $res;
}
/**
* Sets the invoice as a final situation
*
* @return int 1 if ok, -1 if error
*/
function setFinal()
{
global $conf, $langs, $user;
$this->situation_final = 1;
$sql = 'update ' . MAIN_DB_PREFIX . 'facture set situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id;
$resql = $this->db->query($sql);
if ($resql) {
// FIXME: call triggers?
$this->db->commit();
return 1;
} else {
$this->error = $this->db->error();
dol_syslog(get_class($this) . "::update Error setFinal " . $sql, LOG_ERR);
$this->db->rollback();
return -1;
}
}
/**
* Checks if the invoice is the last in its cycle
*
* @return int 0 or 1 if OK, -1 if error
*
*/
function is_last_in_cycle()
{
$sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref;
$resql = $this->db->query($sql);
if ($resql && $resql->num_rows > 0) {
$res = $this->db->fetch_array($resql);
$last = $res['max(situation_counter)'];
return ($last == $this->situation_counter);
} else {
$this->error = $this->db->error();
dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
}
/**
* Class to manage invoice lines.
* Saved into database table llx_facturedet
@ -3391,6 +3619,16 @@ class FactureLigne extends CommonInvoiceLine
var $skip_update_total; // Skip update price total for special lines
/**
* @var int Situation advance percentage
*/
public $situation_percent;
/**
* @var int Previous situation line id reference
*/
public $fk_prev_id;
/**
* Constructor
*
@ -3414,6 +3652,7 @@ class FactureLigne extends CommonInvoiceLine
$sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,';
$sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,';
$sql.= ' fd.fk_code_ventilation,';
$sql.= ' fd.situation_percent, fd.fk_prev_id,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid';
@ -3461,6 +3700,9 @@ class FactureLigne extends CommonInvoiceLine
$this->product_label = $objp->product_libelle;
$this->product_desc = $objp->product_desc;
$this->situation_percent = $objp->situation_percent;
$this->fk_prev_id = $objp->fk_prev_id;
$this->db->free($result);
}
else
@ -3498,6 +3740,8 @@ class FactureLigne extends CommonInvoiceLine
if (empty($this->subprice)) $this->subprice=0;
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->fk_prev_id)) $this->fk_prev_id = 'null';
if (empty($this->situation_percent)) $this->situation_percent = 0;
if (empty($this->pa_ht)) $this->pa_ht=0;
@ -3541,7 +3785,8 @@ class FactureLigne extends CommonInvoiceLine
$sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,';
$sql.= ' date_start, date_end, fk_code_ventilation, ';
$sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,';
$sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2)';
$sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,';
$sql.= ' situation_percent, fk_prev_id)';
$sql.= " VALUES (".$this->fk_facture.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
@ -3570,6 +3815,8 @@ class FactureLigne extends CommonInvoiceLine
$sql.= " ".price2num($this->total_ttc).",";
$sql.= " ".price2num($this->total_localtax1).",";
$sql.= " ".price2num($this->total_localtax2);
$sql .= ", " . $this->situation_percent;
$sql .= ", " . $this->fk_prev_id;
$sql.= ')';
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
@ -3687,6 +3934,7 @@ class FactureLigne extends CommonInvoiceLine
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->product_type)) $this->product_type=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (is_null($this->situation_percent)) $this->situation_percent=100;
// Check parameters
if ($this->product_type < 0) return -1;
@ -3732,6 +3980,7 @@ class FactureLigne extends CommonInvoiceLine
$sql.= " , buy_price_ht='".price2num($this->pa_ht)."'";
$sql.= ",fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
$sql .= ", situation_percent=" . $this->situation_percent;
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -3846,5 +4095,28 @@ class FactureLigne extends CommonInvoiceLine
return -2;
}
}
}
/**
* Returns situation_percent of the previous line
*
* @return int >= 0
*/
function get_prev_progress()
{
if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") {
return 0;
} else {
$sql = 'SELECT situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet WHERE rowid=' . $this->fk_prev_id;
$resql = $this->db->query($sql);
if ($resql && $resql->num_rows > 0) {
$res = $this->db->fetch_array($resql);
return $res['situation_percent'];
} else {
$this->error = $this->db->error();
dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
}
}

View File

@ -3,6 +3,8 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -408,7 +410,7 @@ $sql.= ",".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.type IN (0,1,3) AND f.fk_statut = 1";
$sql.= " AND f.type IN (0,1,3,5) AND f.fk_statut = 1";
$sql.= " AND f.paye = 0";
if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -551,7 +553,7 @@ if ($resql)
print_liste_field_titre($langs->trans("Taxes"),$_SERVER["PHP_SELF"],"f.tva","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder);
if (empty($mode))
{

View File

@ -4,7 +4,9 @@
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -101,7 +103,7 @@ $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0];
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client,";
$sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,";
$sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2, fd.rowid as id, fd.situation_percent,";
$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,";
$sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,";
$sql.= " ct.accountancy_code_sell as account_tva, ct.recuperableonly";
@ -112,8 +114,8 @@ $sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
else $sql.= " AND f.type IN (0,1,2,3,5)";
$sql.= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " ORDER BY f.rowid";
@ -157,6 +159,16 @@ if ($result)
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $obj->thirdparty, $mysoc);
$compta_localtax2= (! empty($account_localtax2[3])?$account_localtax2[3]:$langs->trans("CodeNotDef"));
// Situation invoices handling
$line = new FactureLigne($db);
$line->fetch($obj->id);
$prev_progress = $line->get_prev_progress();
if ($obj->situation_percent == 0) { // Avoid divide by 0
$situation_ratio = 0;
} else {
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
}
//la ligne facture
$tabfac[$obj->rowid]["date"] = $obj->datef;
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
@ -166,9 +178,9 @@ if ($result)
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva]=0;
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1]=0;
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2]=0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
if($obj->recuperableonly != 1) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
if($obj->recuperableonly != 1) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
$tabcompany[$obj->rowid]=array('id'=>$obj->socid, 'name'=>$obj->name, 'client'=>$obj->client);

View File

@ -585,12 +585,12 @@ class Localtax extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowVatPayment").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/localtax/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/localtax/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='payment';
$label=$langs->trans("ShowVatPayment").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -4,6 +4,8 @@
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
*
* This program is free software; you can redistribute it and/or modify
@ -69,185 +71,188 @@ if ($facid > 0)
// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('paiementcard','globalcard'));
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/*
* Actions
*/
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
$error = 0;
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes'))
{
$error = 0;
$datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$paiement_id = 0;
$totalpayment = 0;
$atleastonepaymentnotnull = 0;
$datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$paiement_id = 0;
$totalpayment = 0;
$atleastonepaymentnotnull = 0;
// Generate payment array and check if there is payment higher than invoice and payment date before invoice date
$tmpinvoice=new Facture($db);
foreach ($_POST as $key => $value)
{
if (substr($key,0,7) == 'amount_')
{
$cursorfacid = substr($key,7);
$amounts[$cursorfacid] = price2num(trim(GETPOST($key)));
$totalpayment = $totalpayment + $amounts[$cursorfacid];
if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++;
$result=$tmpinvoice->fetch($cursorfacid);
if ($result <= 0) dol_print_error($db);
$amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
if ($amounts[$cursorfacid])
{
// Check amount
if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid])))
{
$addwarning=1;
$formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
}
// Check date
if ($datepaye && ($datepaye < $tmpinvoice->date))
{
$langs->load("errors");
//$error++;
setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings');
}
}
$formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]);
}
}
// Check parameters
if (! GETPOST('paiementcode'))
{
setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors');
$error++;
}
if (! empty($conf->banque->enabled))
{
// If bank module is on, account is required to enter a payment
if (GETPOST('accountid') <= 0)
{
setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors');
$error++;
}
}
if (empty($totalpayment) && empty($atleastonepaymentnotnull))
{
setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors');
$error++;
}
if (empty($datepaye))
{
setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors');
$error++;
}
}
/*
* Action add_paiement
*/
if ($action == 'add_paiement')
{
if ($error)
{
$action = 'create';
}
// Le reste propre a cette action s'affiche en bas de page.
}
/*
* Action confirm_paiement
*/
if ($action == 'confirm_paiement' && $confirm == 'yes')
{
$error=0;
$datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$db->begin();
// Clean parameters amount if payment is for a credit note
if (GETPOST('type') == 2)
{
foreach ($amounts as $key => $value) // How payment is dispatch
// Generate payment array and check if there is payment higher than invoice and payment date before invoice date
$tmpinvoice=new Facture($db);
foreach ($_POST as $key => $value)
{
$newvalue = price2num($value,'MT');
$amounts[$key] = -$newvalue;
if (substr($key,0,7) == 'amount_')
{
$cursorfacid = substr($key,7);
$amounts[$cursorfacid] = price2num(trim(GETPOST($key)));
$totalpayment = $totalpayment + $amounts[$cursorfacid];
if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++;
$result=$tmpinvoice->fetch($cursorfacid);
if ($result <= 0) dol_print_error($db);
$amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
if ($amounts[$cursorfacid])
{
// Check amount
if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid])))
{
$addwarning=1;
$formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
}
// Check date
if ($datepaye && ($datepaye < $tmpinvoice->date))
{
$langs->load("errors");
//$error++;
setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings');
}
}
$formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]);
}
}
}
if (! empty($conf->banque->enabled))
{
// Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement
if (GETPOST('accountid') <= 0)
{
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors');
$error++;
}
}
// Check parameters
if (! GETPOST('paiementcode'))
{
setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors');
$error++;
}
// Creation of payment line
$paiement = new Paiement($db);
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Array with all payments dispatching
$paiement->paiementid = dol_getIdFromCode($db,$_POST['paiementcode'],'c_paiement');
$paiement->num_paiement = $_POST['num_paiement'];
$paiement->note = $_POST['comment'];
if (! empty($conf->banque->enabled))
{
// If bank module is on, account is required to enter a payment
if (GETPOST('accountid') <= 0)
{
setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors');
$error++;
}
}
if (! $error)
{
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0));
if ($paiement_id < 0)
{
setEventMessage($paiement->error, 'errors');
$error++;
}
}
if (empty($totalpayment) && empty($atleastonepaymentnotnull))
{
setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors');
$error++;
}
if (! $error)
{
$label='(CustomerInvoicePayment)';
if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)';
$result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),GETPOST('chqemetteur'),GETPOST('chqbank'));
if ($result < 0)
{
setEventMessage($paiement->error, 'errors');
$error++;
}
}
if (empty($datepaye))
{
setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors');
$error++;
}
}
if (! $error)
{
$db->commit();
/*
* Action add_paiement
*/
if ($action == 'add_paiement')
{
if ($error)
{
$action = 'create';
}
// Le reste propre a cette action s'affiche en bas de page.
}
// If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card
$invoiceid=0;
foreach ($paiement->amounts as $key => $amount)
{
$facid = $key;
if (is_numeric($amount) && $amount <> 0)
{
if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment
else $invoiceid=$facid;
}
}
if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture.php?facid='.$invoiceid;
else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id;
header('Location: '.$loc);
exit;
}
else
{
$db->rollback();
}
/*
* Action confirm_paiement
*/
if ($action == 'confirm_paiement' && $confirm == 'yes')
{
$error=0;
$datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$db->begin();
// Clean parameters amount if payment is for a credit note
if (GETPOST('type') == 2)
{
foreach ($amounts as $key => $value) // How payment is dispatch
{
$newvalue = price2num($value,'MT');
$amounts[$key] = -$newvalue;
}
}
if (! empty($conf->banque->enabled))
{
// Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement
if (GETPOST('accountid') <= 0)
{
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors');
$error++;
}
}
// Creation of payment line
$paiement = new Paiement($db);
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Array with all payments dispatching
$paiement->paiementid = dol_getIdFromCode($db,$_POST['paiementcode'],'c_paiement');
$paiement->num_paiement = $_POST['num_paiement'];
$paiement->note = $_POST['comment'];
if (! $error)
{
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0));
if ($paiement_id < 0)
{
setEventMessage($paiement->error, 'errors');
$error++;
}
}
if (! $error)
{
$label='(CustomerInvoicePayment)';
if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)';
$result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),GETPOST('chqemetteur'),GETPOST('chqbank'));
if ($result < 0)
{
setEventMessage($paiement->error, 'errors');
$error++;
}
}
if (! $error)
{
$db->commit();
// If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card
$invoiceid=0;
foreach ($paiement->amounts as $key => $amount)
{
$facid = $key;
if (is_numeric($amount) && $amount <> 0)
{
if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment
else $invoiceid=$facid;
}
}
if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture.php?facid='.$invoiceid;
else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id;
header('Location: '.$loc);
exit;
}
else
{
$db->rollback();
}
}
}
@ -469,7 +474,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
if ($facture->type != 2)
{
$sql .= ' AND type IN (0,1,3)'; // Standard invoice, replacement, deposit
$sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
}
else
{

View File

@ -769,11 +769,12 @@ class RemiseCheque extends CommonObject
global $langs;
$result='';
$label = $langs->trans("ShowCheckReceipt").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCheckReceipt"), 'payment', 'class="classfortooltip"').$lienfin);
if ($withpicto) $result.=($lien.img_object($label, 'payment', 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;

View File

@ -2,6 +2,8 @@
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
@ -212,13 +214,14 @@ class Paiement extends CommonObject
//Invoice types that are eligible for changing status to paid
$affected_types = array(
0,
1,
2,
3
Facture::TYPE_STANDARD,
Facture::TYPE_REPLACEMENT,
Facture::TYPE_CREDIT_NOTE,
Facture::TYPE_DEPOSIT,
Facture::TYPE_SITUATION
);
if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice. We do nothing more.");
if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more.");
else if ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more.");
else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more.");
else
@ -745,8 +748,9 @@ class Paiement extends CommonObject
global $langs;
$result='';
$label = $langs->trans("ShowPayment").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment"), 'payment', 'class="classfortooltip"').$lienfin);

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
*
@ -737,7 +737,7 @@ class BonPrelevement extends CommonObject
{
global $conf,$langs;
dol_syslog(get_class($this)."::Create banque=$banque agence=$agence");
dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence, LOG_DEBUG);
require_once (DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once (DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
@ -781,7 +781,8 @@ class BonPrelevement extends CommonObject
//if ($banque) $sql.= " AND sr.code_banque = '".$conf->global->PRELEVEMENT_CODE_BANQUE."'";
//if ($agence) $sql.= " AND sr.code_guichet = '".$conf->global->PRELEVEMENT_CODE_GUICHET."'";
dol_syslog(get_class($this)."::Create", LOG_DEBUG);
dol_syslog(__METHOD__."::Read invoices, sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -795,13 +796,12 @@ class BonPrelevement extends CommonObject
$i++;
}
$this->db->free($resql);
dol_syslog($i." invoices to withdraw");
dol_syslog(__METHOD__."::Read invoices, ".$i." invoices to withdraw", LOG_DEBUG);
}
else
{
$error = 1;
dol_syslog("Erreur -1");
dol_syslog($this->db->error());
$error++;
dol_syslog(__METHOD__."::Read invoices error ".$this->db->error(), LOG_ERR);
}
}
@ -812,7 +812,7 @@ class BonPrelevement extends CommonObject
// Check RIB
$i = 0;
dol_syslog("Start RIB check");
dol_syslog(__METHOD__."::Check RIB", LOG_DEBUG);
if (count($factures) > 0)
{
@ -836,24 +836,24 @@ class BonPrelevement extends CommonObject
}
else
{
dol_syslog("Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR);
dol_syslog(__METHOD__."::Check RIB Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR);
$this->invoice_in_error[$fac[0]]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty (reported by function verif) ".$soc->name;
}
}
else
{
dol_syslog("Failed to read company", LOG_ERR);
dol_syslog(__METHOD__."::Check RIB Failed to read company", LOG_ERR);
}
}
else
{
dol_syslog("Failed to read invoice", LOG_ERR);
dol_syslog(__METHOD__."::Check RIB Failed to read invoice", LOG_ERR);
}
}
}
else
{
dol_syslog("No invoice to process");
dol_syslog(__METHOD__."::Check RIB No invoice to process", LOG_ERR);
}
}
@ -893,58 +893,56 @@ class BonPrelevement extends CommonObject
*/
if (!$error)
{
$ref = "T".substr($year,-2).$month;
$ref = substr($year,-2).$month;
$sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons";
$sql.= " WHERE ref LIKE '".$ref."%'";
$sql.= " AND entity = ".$conf->entity;
$sql = "SELECT substring(ref from char_length(ref) - 1)";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons";
$sql.= " WHERE ref LIKE '%".$ref."%'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " ORDER BY ref DESC LIMIT 1";
dol_syslog(get_class($this)."::Create", LOG_DEBUG);
$resql = $this->db->query($sql);
dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$row = $this->db->fetch_row($resql);
}
else
{
$error++;
dol_syslog("Erreur recherche reference");
}
if ($resql)
{
$row = $this->db->fetch_row($resql);
$ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT);
$ref = $ref . substr("00".($row[0]+1), -2);
$filebonprev = $ref;
$filebonprev = $ref;
// Create withdraw receipt in database
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (";
$sql.= " ref, entity, datec";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($ref)."'";
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ")";
// Create withdraw receipt in database
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (";
$sql.= " ref, entity, datec";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($ref)."'";
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ")";
$resql = $this->db->query($sql);
if ($resql)
{
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
dol_syslog(get_class($this)."::Create", LOG_DEBUG);
$resql = $this->db->query($sql);
$dir=$conf->prelevement->dir_output.'/receipts';
$file=$filebonprev;
if (! is_dir($dir)) dol_mkdir($dir);
if ($resql)
{
$prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
$dir=$conf->prelevement->dir_output.'/receipts';
$file=$filebonprev;
if (! is_dir($dir)) dol_mkdir($dir);
$bonprev = new BonPrelevement($this->db, $dir."/".$file);
$bonprev->id = $prev_id;
}
else
{
$error++;
dol_syslog("Erreur creation du bon de prelevement");
}
$bonprev = new BonPrelevement($this->db, $dir."/".$file);
$bonprev->id = $prev_id;
}
else
{
$error++;
dol_syslog(__METHOD__."::Create withdraw receipt ".$this->db->error(), LOG_ERR);
}
}
else
{
$error++;
dol_syslog(__METHOD__."::Get last withdraw receipt ".$this->db->error(), LOG_ERR);
}
}
/*
@ -987,13 +985,12 @@ class BonPrelevement extends CommonObject
$sql.= ", fk_prelevement_bons = ".$prev_id;
$sql.= " WHERE rowid = ".$fac[1];
dol_syslog(get_class($this)."::Create", LOG_DEBUG);
dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
dol_syslog("Erreur mise a jour des demandes");
dol_syslog($this->db->error());
dol_syslog(__METHOD__."::Update Orders::Error=".$this->db->error(), LOG_ERR);
}
}
@ -1008,7 +1005,7 @@ class BonPrelevement extends CommonObject
* Withdraw receipt
*/
dol_syslog("Debut prelevement - Nombre de factures ".count($factures_prev));
dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG);
if (count($factures_prev) > 0)
{
@ -1031,8 +1028,7 @@ class BonPrelevement extends CommonObject
//Build file
$bonprev->generate();
}
dol_syslog($filebonprev);
dol_syslog("Fin prelevement");
dol_syslog(__METHOD__."::End withdraw receipt, file ".$filebonprev, LOG_DEBUG);
}
/*
@ -1044,12 +1040,11 @@ class BonPrelevement extends CommonObject
$sql.= " WHERE rowid = ".$prev_id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog(get_class($this)."::Create", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql)
{
$error++;
dol_syslog("Erreur mise a jour du total - $sql");
dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR);
}
/*
@ -1062,7 +1057,6 @@ class BonPrelevement extends CommonObject
else
{
$this->db->rollback();
dol_syslog("Error",LOG_ERR);
}
return count($factures_prev);
@ -1124,17 +1118,18 @@ class BonPrelevement extends CommonObject
global $langs;
$result='';
$label = $langs->trans("ShowWithdraw").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
if ($option == 'xxx')
{
$lien = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
}
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowWithdraw"), 'payment', 'class="classfortooltip"').$lienfin.' ');
if ($withpicto) $result.=($lien.img_object($label, 'payment', 'class="classfortooltip"').$lienfin.' ');
$result.=$lien.$this->ref.$lienfin;
return $result;
}

View File

@ -2,6 +2,8 @@
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Dourseanud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
@ -166,9 +168,9 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2)";
$sql.= " AND f.type IN (0,1,2,5)";
else
$sql.= " AND f.type IN (0,1,2,3)";
$sql.= " AND f.type IN (0,1,2,3,5)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
@ -693,9 +695,9 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2)";
$sql.= " AND f.type IN (0,1,2,5)";
else
$sql.= " AND f.type IN (0,1,2,3)";
$sql.= " AND f.type IN (0,1,2,3,5)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity = ".$conf->entity;

View File

@ -103,8 +103,8 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
else $sql.= " AND f.type IN (0,1,2,3,5)";
}
else
{
@ -246,8 +246,8 @@ if ($modecompta == 'CREANCES-DETTES')
$sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
else $sql.= " AND f.type IN (0,1,2,3,5)";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY dm";

View File

@ -486,12 +486,12 @@ class PaymentSalary extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowSalaryPayment").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='payment';
$label=$langs->trans("ShowSalaryPayment").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -420,11 +420,12 @@ class ChargeSociales extends CommonObject
$result='';
if (empty($this->ref)) $this->ref=$this->lib;
$label = $langs->trans("ShowSocialContribution").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowSocialContribution").': '.$this->lib, 'bill', 'class="classfortooltip"').$lienfin.' ');
if ($withpicto) $result.=($lien.img_object($label, 'bill', 'class="classfortooltip"').$lienfin.' ');
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin;
return $result;

View File

@ -585,13 +585,14 @@ class PaymentSocialContribution extends CommonObject
$result='';
if (empty($this->ref)) $this->ref=$this->lib;
$label = $langs->trans("ShowPayment").': '.$this->ref;
if (!empty($this->id))
{
$lien = '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowPayment").': '.$this->ref, 'payment', 'class="classfortooltip"').$lienfin.' ');
if ($withpicto) $result.=($lien.img_object($label, 'payment', 'class="classfortooltip"').$lienfin.' ');
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin;
}

View File

@ -193,9 +193,9 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND l.fk_facture = f.rowid";
$sql.= " AND f.fk_statut in (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql.= " AND f.type IN (0,1,2)";
$sql.= " AND f.type IN (0,1,2,5)";
} else {
$sql.= " AND f.type IN (0,1,2,3)";
$sql.= " AND f.type IN (0,1,2,3,5)";
}
if ($date_start && $date_end) {
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";

View File

@ -178,9 +178,9 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid";
$sql.= " WHERE f.fk_statut in (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql.= " AND f.type IN (0,1,2)";
$sql.= " AND f.type IN (0,1,2,5)";
} else {
$sql.= " AND f.type IN (0,1,2,3)";
$sql.= " AND f.type IN (0,1,2,3,5)";
}
if ($date_start && $date_end) {
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";

View File

@ -191,9 +191,9 @@ if ($modecompta == 'CREANCES-DETTES') {
}
$sql.= " WHERE f.fk_statut in (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql.= " AND f.type IN (0,1,2)";
$sql.= " AND f.type IN (0,1,2,5)";
} else {
$sql.= " AND f.type IN (0,1,2,3)";
$sql.= " AND f.type IN (0,1,2,3,5)";
}
$sql.= " AND f.fk_soc = s.rowid";
if ($date_start && $date_end) {

View File

@ -91,8 +91,8 @@ if ($modecompta == 'CREANCES-DETTES')
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_statut in (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
else $sql.= " AND f.type IN (0,1,2,3,5)";
}
else
{

View File

@ -638,12 +638,12 @@ class Tva extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowVatPayment").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='payment';
$label=$langs->trans("ShowVatPayment").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -887,17 +887,18 @@ class Contact extends CommonObject
global $langs;
$result='';
$label = $langs->trans("ShowContact").': '.$this->getFullName($langs);
$lien = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
if ($option == 'xxx')
{
$lien = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$this->id.$moreparam.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
}
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowContact").': '.$this->getFullName($langs), 'contact', 'class="classfortooltip"').$lienfin.' ');
if ($withpicto) $result.=($lien.img_object($label, 'contact', 'class="classfortooltip"').$lienfin.' ');
$result.=$lien.($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)).$lienfin;
return $result;
}

View File

@ -211,23 +211,31 @@ class Contrat extends CommonObject
global $db, $langs, $conf;
$langs->load("contracts");
$dir = DOL_DOCUMENT_ROOT . "/core/modules/contract";
if (empty($conf->global->CONTRACT_ADDON))
if (!empty($conf->global->CONTRACT_ADDON))
{
$conf->global->CONTRACT_ADDON='mod_contract_serpis';
}
$mybool = false;
$file = $conf->global->CONTRACT_ADDON.".php";
$file = $conf->global->CONTRACT_ADDON.".php";
$classname = $conf->global->CONTRACT_ADDON;
// Chargement de la classe de numerotation
$classname = $conf->global->CONTRACT_ADDON;
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/contract/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
$result=include_once $dir.'/'.$file;
if ($result)
{
$obj = new $classname();
$numref = "";
$numref = $obj->getNextValue($soc,$this);
@ -237,15 +245,17 @@ class Contrat extends CommonObject
}
else
{
$this->error = $obj->error;
dol_print_error($db,get_class($this)."::getNextValue ".$obj->error);
return "";
}
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_CONTRACT_ADDON_NotDefined");
$langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
return "";
}
}
}
/**
@ -1672,13 +1682,13 @@ class Contrat extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowContract").': '.$this->ref;
$lien = '<a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$this->id.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='contract';
$label=$langs->trans("ShowContract").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
@ -2201,13 +2211,13 @@ class ContratLigne extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowContractOfService").': '.$this->label;
$lien = '<a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$this->fk_contrat.'">';
$lien = '<a href="'.DOL_URL_ROOT.'/contrat/card.php?id='.$this->fk_contrat.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$lienfin='</a>';
$picto='contract';
$label=$langs->trans("ShowContractOfService").': '.$this->label;
if ($withpicto) $result.=($lien.img_object($label, $picto, 'class="classfortooltip"').$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
@ -2487,45 +2497,4 @@ class ContratLigne extends CommonObject
}
}
/**
* Load elements linked to contract (only intervention for the moment)
*
* @param string $type Object type
* @return array $elements array of linked elements
*/
function get_element_list($type)
{
$elements = array();
$sql = '';
if ($type == 'intervention')
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "fichinter WHERE fk_contrat=" . $this->id;
if (! $sql) return -1;
//print $sql;
dol_syslog(get_class($this)."::get_element_list", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$nump = $this->db->num_rows($result);
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($result);
$elements[$i] = $obj->rowid;
$i++;
}
$this->db->free($result);
/* Return array */
return $elements;
}
}
else
{
dol_print_error($this->db);
}
}
}

View File

@ -0,0 +1,64 @@
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/actions_printing.inc.php
* \brief Code for actions print_file to print file with calling trigger
*/
// $action must be defined
// $db, $user, $conf, $langs must be defined
// Filename to print must be provided into 'file' parameter
// Print file
if ($action == 'print_file' and $user->rights->printing->read)
{
$langs->load("printing");
require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php';
$objectprint = new PrintingDriver($db);
$list = $objectprint->listDrivers($db, 10);
if (! empty($list)) {
$errorprint=0;
$printed=0;
foreach ($list as $driver) {
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
$langs->load($driver);
$classname = 'printing_'.$driver;
$printer = new $classname($db);
//print '<pre>'.print_r($printer, true).'</pre>';
if (! empty($conf->global->{$printer->active})) {
$subdir=(GETPOST('printer', 'alpha')=='expedition'?'sending':'');
$errorprint = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'), $subdir);
//if ($errorprint < 0) {
// setEventMessage($interface->errors, 'errors');
//}
if ($errorprint=='') {
setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file'))).' '.$langs->trans("ViaModule").' '.$printer->name);
$printed++;
}
}
}
if ($printed==0) setEventMessage($langs->trans("NoActivePrintingModuleFound"));
} else {
setEventMessage($langs->trans("NoModuleFound"), 'warning');
}
$action = '';
}

View File

@ -1,45 +0,0 @@
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/actions_printipp.inc.php
* \brief Code for actions print_file to print file using ipp
*/
// $action must be defined
// $db, $user, $conf, $langs must be defined
// Filename to print must be provided into 'file' parameter
// Print file
if ($action == 'print_file' and $user->rights->printipp->read)
{
$langs->load("printipp");
require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php';
$printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD);
$result = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'));
if ($result)
{
setEventMessage($result,'warnings');
}
else
{
setEventMessage($langs->trans("FileWasSentToPrinter", basename(GETPOST('file'))));
}
$action = '';
}

View File

@ -103,7 +103,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
else // Id du contact
{
$sendto = $thirdparty->contact_get_property($_POST['receiver'],'email');
$sendto = $thirdparty->contact_get_property((int) $_POST['receiver'],'email');
$sendtoid = $_POST['receiver'];
}
}
@ -120,7 +120,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
else // Id du contact
{
$sendtocc = $thirdparty->contact_get_property($_POST['receivercc'],'email');
$sendtocc = $thirdparty->contact_get_property((int) $_POST['receivercc'],'email');
}
}

View File

@ -60,8 +60,7 @@ class box_actions extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo",$max));
if ($user->rights->agenda->myactions->read)
{
if ($user->rights->agenda->myactions->read) {
$sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage,";
$sql.= " ta.code, ta.libelle as type_label,";
$sql.= " s.nom as name, s.rowid as socid";
@ -80,15 +79,13 @@ class box_actions extends ModeleBoxes
dol_syslog("Box_actions::loadBox", LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
if ($result) {
$now=dol_now();
$delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;
$num = $db->num_rows($result);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$late = '';
$objp = $db->fetch_object($result);
$datelimite=$db->jdate($objp->dp);
@ -98,48 +95,68 @@ class box_actions extends ModeleBoxes
//($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label)
$label=empty($objp->label)?$objp->type_label:$objp->label;
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => ("action"),
'url' => DOL_URL_ROOT."/comm/action/card.php?id=".$objp->id);
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => ("action"),
'tooltip' => $langs->trans('Action'.$objp->code).': '.$label,
'url' => DOL_URL_ROOT."/comm/action/card.php?id=".$objp->id,
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => dol_trunc($label,32),
'text2'=> $late,
'url' => DOL_URL_ROOT."/comm/action/card.php?id=".$objp->id);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => dol_trunc($label,32),
'text2'=> $late,
'tooltip' => $langs->trans('Action'.$objp->code).': '.$label,
'url' => DOL_URL_ROOT."/comm/action/card.php?id=".$objp->id,
);
$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
'logo' => ($objp->socid?'company':''),
'url' => ($objp->socid?DOL_URL_ROOT."/societe/soc.php?socid=".$objp->socid:''));
$this->info_box_contents[$i][2] = array(
'td' => 'align="left" width="16"',
'logo' => ($objp->socid?'company':''),
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => ($objp->socid?DOL_URL_ROOT."/societe/soc.php?socid=".$objp->socid:''),
);
$this->info_box_contents[$i][3] = array('td' => 'align="left"',
'text' => dol_trunc($objp->name,24),
'url' => DOL_URL_ROOT."/societe/soc.php?socid=".$objp->socid);
$this->info_box_contents[$i][3] = array(
'td' => 'align="left"',
'text' => dol_trunc($objp->name,24),
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => DOL_URL_ROOT."/societe/soc.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][4] = array('td' => 'align="left" class="nowrap"',
'text' => dol_print_date($datelimite, "dayhour"));
$this->info_box_contents[$i][4] = array(
'td' => 'align="left" class="nowrap"',
'text' => dol_print_date($datelimite, "dayhour"),
);
$this->info_box_contents[$i][5] = array('td' => 'align="right"',
'text' => ($objp->percentage>= 0?$objp->percentage.'%':''));
$this->info_box_contents[$i][5] = array(
'td' => 'align="right"',
'text' => ($objp->percentage>= 0?$objp->percentage.'%':''),
);
$this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"',
'text' => $actionstatic->LibStatut($objp->percentage,3));
$this->info_box_contents[$i][6] = array(
'td' => 'align="right" width="18"',
'text' => $actionstatic->LibStatut($objp->percentage,3),
);
$i++;
}
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoActionsToDo"));
$db->free($result);
}
else {
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql));
}
}
else {
$this->info_box_contents[0][0] = array('align' => 'left',
'text' => $langs->trans("ReadPermissionNotAllowed"));
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'align' => 'left',
'text' => $langs->trans("ReadPermissionNotAllowed"),
);
}
}

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2012 Charles-François BENKE <charles.fr@benke.fr>
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,9 +18,9 @@
*/
/**
* \file htdocs/core/boxes/box_activity.php
* \ingroup societes
* \brief Module to show box of bills, orders & propal of the current year
* \file htdocs/core/boxes/box_activity.php
* \ingroup societes
* \brief Module to show box of bills, orders & propal of the current year
*/
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
@ -29,275 +30,416 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/
class box_activity extends ModeleBoxes
{
var $boxcode="activity";
var $boximg="object_bill";
var $boxlabel='BoxGlobalActivity';
var $depends = array("facture");
var $boxcode="activity";
var $boximg="object_bill";
var $boxlabel='BoxGlobalActivity';
var $depends = array("facture");
var $db;
var $param;
var $enabled = 1;
var $db;
var $param;
var $enabled = 1;
var $info_box_head = array();
var $info_box_contents = array();
var $info_box_head = array();
var $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $conf;
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
function __construct($db,$param)
{
global $conf;
$this->db=$db;
// FIXME: Use a cache to save data because this slow down too much main home page. This box slow down too seriously software.
// FIXME: Removed number_format (not compatible with all languages)
// FIXME: Pb into some status
$this->enabled=$conf->global->MAIN_FEATURES_LEVEL; // Not enabled by default due to bugs (see previous comments)
}
$this->db=$db;
// FIXME: Pb into some status
$this->enabled=$conf->global->MAIN_FEATURES_LEVEL; // Not enabled by default due to bugs (see previous comments)
}
/**
* Charge les donnees en memoire pour affichage ulterieur
*
* @param int $max Maximum number of records to load
* @return void
*/
function loadBox($max=5)
{
global $conf, $user, $langs, $db;
/**
* Charge les donnees en memoire pour affichage ulterieur
*
* @param int $max Maximum number of records to load
* @return void
*/
function loadBox($max=5)
{
global $conf, $user, $langs, $db;
$totalMnt = 0;
$totalnb = 0;
$i = 0;
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$totalMnt = 0;
$totalnb = 0;
$i = 0;
$cachetime = 3600;
$fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache';
$now = dol_now();
$nbofyears=2;
$nbofyears=2;
if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofyears=$conf->global->MAIN_BOX_ACTIVITY_DURATION;
$textHead = $langs->trans("Activity").' ('.$nbofyears.' '.$langs->trans("DurationYears").')';
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofyears=$conf->global->MAIN_BOX_ACTIVITY_DURATION;
$textHead = $langs->trans("Activity").' <span class="badge">'.$nbofyears.' '.$langs->trans("DurationYears").'</span>';
$this->info_box_head = array(
'text' => $textHead,
'limit'=> dol_strlen($textHead),
);
// compute the year limit to show
$tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofyears, "y");
// compute the year limit to show
$tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofyears, "y");
// list the summary of the bills
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
{
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic=new Facture($db);
// list the summary of the bills
if (! empty($conf->facture->enabled) && $user->rights->facture->lire) {
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic=new Facture($db);
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ")";
$sql.= " WHERE f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1";
$sql.= " GROUP BY f.fk_statut";
$sql.= " ORDER BY f.fk_statut DESC";
$cachefile = DOL_DATA_ROOT.'/facture/temp/boxactivity-invoice'.$fileid;
$refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile);
$data = array();
if ($refresh) {
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ")";
$sql.= " WHERE f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1";
$sql.= " GROUP BY f.fk_statut";
$sql.= " ORDER BY f.fk_statut DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
while ($i < $num)
{
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill');
$objp = $db->fetch_object($result);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$j=0;
while ($j < $num) {
$data[$j]=$db->fetch_object($result);
$j++;
}
file_put_contents($cachefile,serialize($data),LOCK_EX);
$db->free($result);
} else {
dol_print_error($db);
}
} else {
$data = unserialize(file_get_contents($cachefile));
}
if (! empty($data)) {
$j=0;
while ($i < count($data)) {
$billurl="viewstatut=2&amp;paye=1&amp;year=".$data[$j]->annee;
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0),
'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
'logo' => 'bill',
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(1,$objp->fk_statut,0)." ".$objp->annee);
$billurl="viewstatut=2&paye=1&year=".$objp->annee;
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee,
);
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => $objp->nb, 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills"
);
$this->info_box_contents[$i][2] = array(
'td' => 'align="right"',
'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0),
'text' => $data[$j]->nb,
'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
);
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
'text' => price($objp->Mnttot,1,$langs,0,0,-1,$conf->currency)
);
$this->info_box_contents[$i][3] = array(
'td' => 'align="right"',
'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency)
);
// We add only for the current year
if ($objp->annee == date("Y"))
{
$totalnb += $objp->nb;
$totalMnt += $objp->Mnttot;
}
$this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1,$objp->fk_statut,3) );
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices"));
// We add only for the current year
if ($data[$j]->annee == date("Y")) {
$totalnb += $data[$j]->nb;
$totalMnt += $data[$j]->Mnttot;
}
$this->info_box_contents[$i][4] = array(
'td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3),
);
$i++;
$j++;
}
if (count($data)==0)
$this->info_box_contents[$i][0] = array(
'td' => 'align="center"',
'text'=>$langs->trans("NoRecordedInvoices"),
);
}
$db->free($result);
}
else dol_print_error($db);
$cachefile = DOL_DATA_ROOT.'/facture/temp/boxactivity-invoice2'.$fileid;
$refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile);
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND paye=0";
$sql.= " GROUP BY f.fk_statut";
$sql.= " ORDER BY f.fk_statut DESC";
if ($refresh) {
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND paye=0";
$sql.= " GROUP BY f.fk_statut";
$sql.= " ORDER BY f.fk_statut DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result) + $i;
$now=dol_now();
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result) + $i;
$j=0;
while ($j < $num) {
$data[$j]=$db->fetch_object($result);
$j++;
}
file_put_contents($cachefile,serialize($data),LOCK_EX);
$db->free($result);
} else {
dol_print_error($db);
}
} else {
$data = unserialize(file_get_contents($cachefile));
}
if (! empty($data)) {
$j=0;
while ($i < $num)
{
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => 'bill');
$objp = $db->fetch_object($result);
while ($i < count($data)) {
$billurl="viewstatut=".$data[$j]->fk_statut."&amp;paye=0";
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
'logo' => 'bill',
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(0,$objp->fk_statut,0));
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
);
$billurl="viewstatut=".$objp->fk_statut."&paye=0";
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => $objp->nb, 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills"
);
$totalnb += $objp->nb;
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
'text' => price($objp->Mnttot,1,$langs,0,0,-1,$conf->currency)
);
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut(0,$objp->fk_statut,3)
);
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices"));
} else {
$this->info_box_contents[0][0] = array( 'td' => 'align="left"', 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql));
}
}
$this->info_box_contents[$i][2] = array(
'td' => 'align="right"',
'text' => $data[$j]->nb,
'tooltip' => $langs->trans('Bills').'&nbsp;'.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0),
'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&amp;mainmenu=accountancy&amp;leftmenu=customers_bills",
);
$totalnb += $data[$j]->nb;
$this->info_box_contents[$i][3] = array(
'td' => 'align="right"',
'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
);
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$i][4] = array(
'td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3),
);
$i++;
$j++;
}
if ($num==0)
$this->info_box_contents[$i][0] = array(
'td' => 'align="center"',
'text'=>$langs->trans("NoRecordedInvoices"),
);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500, 'text' => ($db->error().' sql='.$sql),
);
}
}
// list the summary of the orders
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
{
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$commandestatic=new Commande($db);
// list the summary of the orders
if (! empty($conf->commande->enabled) && $user->rights->commande->lire) {
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$commandestatic=new Commande($db);
$sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ")";
$sql.= " WHERE c.entity = ".$conf->entity;
$sql.= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'";
$sql.= " AND c.facture=0";
$sql.= " GROUP BY c.fk_statut";
$sql.= " ORDER BY c.fk_statut DESC";
$cachefile = DOL_DATA_ROOT.'/commande/temp/boxactivity-order'.$fileid;
$refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile);
$data = array();
if ($refresh) {
$result = $db->query($sql);
$sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ")";
$sql.= " WHERE c.entity = ".$conf->entity;
$sql.= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " AND c.date_commande >= '".$db->idate($tmpdate)."'";
$sql.= " AND c.facture=0";
$sql.= " GROUP BY c.fk_statut";
$sql.= " ORDER BY c.fk_statut DESC";
if ($result)
{
$num = $db->num_rows($result) + $i;
while ($i < $num)
{
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_order');
$result = $db->query($sql);
$objp = $db->fetch_object($result);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' =>$langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($objp->fk_statut,0,0)
);
if ($result) {
$num = $db->num_rows($result) + $i;
$j=0;
while ($j < $num) {
$data[$j]=$db->fetch_object($result);
$j++;
}
file_put_contents($cachefile,serialize($data),LOCK_EX);
$db->free($result);
} else {
dol_print_error($db);
}
} else {
$data = unserialize(file_get_contents($cachefile));
}
if (! empty($data)) {
$j=0;
while ($i < count($data)) {
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;viewstatut=".$data[$j]->fk_statut,
'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut,0,0),
'logo' => 'object_order',
);
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => $objp->nb,
'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$objp->fk_statut
);
$totalnb += $objp->nb;
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' =>$langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut,0,0),
);
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
'text' => price($objp->Mnttot,1,$langs,0,0,-1,$conf->currency)
);
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut,0,3));
$this->info_box_contents[$i][2] = array(
'td' => 'align="right"',
'text' => $data[$j]->nb,
'tooltip' => $langs->trans("Orders")."&nbsp;".$commandestatic->LibStatut($data[$j]->fk_statut,0,0),
'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;viewstatut=".$data[$j]->fk_statut,
);
$totalnb += $data[$j]->nb;
$i++;
}
}
else dol_print_error($db);
}
$this->info_box_contents[$i][3] = array(
'td' => 'align="right"',
'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
);
$totalMnt += $data[$j]->Mnttot;
$this->info_box_contents[$i][4] = array(
'td' => 'align="right" width="18"',
'text' => $commandestatic->LibStatut($data[$j]->fk_statut,0,3),
);
// list the summary of the propals
if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
{
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$propalstatic=new Propal($db);
$i++;
$j++;
}
}
}
$sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ")";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND p.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " AND p.datep >= '".$db->idate($tmpdate)."'";
$sql.= " AND p.date_cloture IS NULL"; // just unclosed
$sql.= " GROUP BY p.fk_statut";
$sql.= " ORDER BY p.fk_statut DESC";
// list the summary of the propals
if (! empty($conf->propal->enabled) && $user->rights->propal->lire) {
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$propalstatic=new Propal($db);
$result = $db->query($sql);
$cachefile = DOL_DATA_ROOT.'/propale/temp/boxactivity-propal'.$fileid;
$refresh = !file_exists($cachefile) || ($now-$cachetime) > dol_filemtime($cachefile);
$data = array();
if ($refresh) {
$sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ")";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND p.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= " AND p.datep >= '".$db->idate($tmpdate)."'";
$sql.= " AND p.date_cloture IS NULL"; // just unclosed
$sql.= " GROUP BY p.fk_statut";
$sql.= " ORDER BY p.fk_statut DESC";
if ($result)
{
$num = $db->num_rows($result) + $i;
while ($i < $num)
{
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_propal');
$result = $db->query($sql);
$objp = $db->fetch_object($result);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' =>$langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($objp->fk_statut,0)
);
if ($result) {
$num = $db->num_rows($result) + $i;
$j=0;
while ($j < $num) {
$data[$j]=$db->fetch_object($result);
$j++;
}
file_put_contents($cachefile,serialize($data),LOCK_EX);
$db->free($result);
} else {
dol_print_error($db);
}
} else {
$data = unserialize(file_get_contents($cachefile));
}
if (! empty($data)) {
$j=0;
while ($i < count($data)) {
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=".$data[$j]->fk_statut,
'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
'logo' => 'object_propal'
);
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => $objp->nb,
'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$objp->fk_statut
);
$totalnb += $objp->nb;
$objp = $db->fetch_object($result);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
);
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
'text' => price($objp->Mnttot,1,$langs,0,0,-1,$conf->currency)
);
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut,3));
$this->info_box_contents[$i][2] = array(
'td' => 'align="right"',
'text' => $data[$j]->nb,
'tooltip' => $langs->trans("Proposals")."&nbsp;".$propalstatic->LibStatut($data[$j]->fk_statut,0),
'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=".$data[$j]->fk_statut,
);
$totalnb += $data[$j]->nb;
$i++;
}
}
else dol_print_error($db);
}
$this->info_box_contents[$i][3] = array(
'td' => 'align="right"',
'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency),
);
$totalMnt += $data[$j]->Mnttot;
$this->info_box_contents[$i][4] = array(
'td' => 'align="right" width="18"',
'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3),
);
// Add the sum in the bottom of the boxes
$this->info_box_contents[$i][1] = array('td' => 'align="left" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead);
$this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => $totalnb);
$this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => price($totalMnt,1,$langs,0,0,-1,$conf->currency));
$this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => "");
$this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => "");
}
$i++;
$j++;
}
}
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @return void
*/
function showBox($head = null, $contents = null)
{
parent::showBox($this->info_box_head, $this->info_box_contents);
}
// Add the sum in the bottom of the boxes
$this->info_box_contents[$i][1] = array(
'td' => 'align="left" ',
'text' => $langs->trans("Total")."&nbsp;".$textHead,
);
$this->info_box_contents[$i][2] = array(
'td' => 'align="right" ',
'text' => $totalnb,
);
$this->info_box_contents[$i][3] = array(
'td' => 'align="right" ',
'text' => price($totalMnt,1,$langs,0,0,-1,$conf->currency)
);
$this->info_box_contents[$i][4] = array(
'td' => 'align="right" ',
'text' => "",
);
$this->info_box_contents[$i][5] = array(
'td' => 'align="right"',
'text' => "",
);
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @return void
*/
function showBox($head = null, $contents = null)
{
parent::showBox($this->info_box_head, $this->info_box_contents);
}
}

View File

@ -52,10 +52,11 @@ class box_bookmarks extends ModeleBoxes
$this->max=$max;
$this->info_box_head = array('text' => $langs->trans("BoxMyLastBookmarks",$max),
'sublink' => DOL_URL_ROOT.'/bookmarks/list.php');
if ($user->rights->bookmark->creer)
{
$this->info_box_head = array(
'text' => $langs->trans("BoxMyLastBookmarks",$max),
'sublink' => DOL_URL_ROOT.'/bookmarks/list.php',
);
if ($user->rights->bookmark->creer) {
$this->info_box_head['subpicto']='object_bookmark';
$this->info_box_head['subtext']=$langs->trans("BookmarksManagement");
}
@ -81,43 +82,52 @@ class box_bookmarks extends ModeleBoxes
$i = 0;
while ($i < $num)
{
$objp = $db->fetch_object($result);
while ($i < $num) {
$objp = $db->fetch_object($result);
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => $objp->url,
'target' => $objp->target?'newtab':'');
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $objp->title,
'url' => $objp->url,
'target' => $objp->target?'newtab':'');
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => $objp->url,
'tooltip' => $objp->title,
'target' => $objp->target?'newtab':'',
);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $objp->title,
'url' => $objp->url,
'tooltip' => $objp->title,
'target' => $objp->target?'newtab':'',
);
$i++;
}
$i++;
}
if ($num==0)
{
$mytxt=$langs->trans("NoRecordedBookmarks");
if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd");
$this->info_box_contents[$i][0] = array('td' => 'align="center" colspan="2"', 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt);
}
if ($num==0) {
$mytxt=$langs->trans("NoRecordedBookmarks");
if ($user->rights->bookmark->creer) $mytxt.=' '.$langs->trans("ClickToAdd");
$this->info_box_contents[$i][0] = array(
'td' => 'align="center" colspan="2"',
'tooltip' => $mytxt,
'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt,
);
}
$db->free($result);
}
else
{
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql));
}
}
else {
$this->info_box_contents[0][0] = array('align' => 'left',
'text' => $langs->trans("ReadPermissionNotAllowed"));
}
}
$db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'align' => 'left',
'text' => $langs->trans("ReadPermissionNotAllowed"),
);
}
}
/**
* Method to show box

View File

@ -104,19 +104,28 @@ class box_clients extends ModeleBoxes
$datec=$db->jdate($objp->datec);
$datem=$db->jdate($objp->tms);
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => $url.$objp->socid);
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => $this->boximg,
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => $url.$objp->socid
);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $objp->name,
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => $url.$objp->socid
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $objp->name,
'url' => $url.$objp->socid);
$this->info_box_contents[$i][2] = array(
'td' => 'align="right"',
'text' => dol_print_date($datem, "day")
);
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => dol_print_date($datem, "day"));
$this->info_box_contents[$i][3] = array('td' => 'align="right" width="18"',
'text' => $thirdpartystatic->LibStatut($objp->status,3));
$this->info_box_contents[$i][3] = array(
'td' => 'align="right" width="18"',
'text' => $thirdpartystatic->LibStatut($objp->status,3)
);
$i++;
}

View File

@ -80,70 +80,85 @@ class box_commandes extends ModeleBoxes
$sql.= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$objp = $db->fetch_object($result);
$date=$db->jdate($objp->date_commande);
$datem=$db->jdate($objp->tms);
$datem=$db->jdate($objp->tms);
$this->info_box_contents[$i][] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid);
$this->info_box_contents[$i][] = array('td' => 'align="left"',
'text' => $objp->ref,
'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid);
$this->info_box_contents[$i][] = array('td' => 'align="left" width="16"',
'logo' => 'company',
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][] = array('td' => 'align="left"',
'text' => $objp->name,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][] = array('td' => 'align="right"',
'text' => price($objp->total_ht),
);
if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER))
{
if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid);
$this->info_box_contents[$i][] = array('td' => 'align="right"',
'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''),
'url' => (($objp->fk_user_valid > 0)?DOL_URL_ROOT.'/user/card.php?id='.$objp->fk_user_valid:'')
);
}
$this->info_box_contents[$i][] = array('td' => 'align="right"',
'text' => dol_print_date($date,'day'),
$this->info_box_contents[$i][] = array(
'td' => 'align="left" width="16"',
'logo' => $this->boximg,
'tooltip' => $langs->trans('Order').': '.$objp->ref,
'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid,
);
$this->info_box_contents[$i][] = array('td' => 'align="right" width="18"',
'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3));
$this->info_box_contents[$i][] = array(
'td' => 'align="left"',
'text' => $objp->ref,
'tooltip' => $langs->trans('Order').': '.$objp->ref,
'url' => DOL_URL_ROOT."/commande/card.php?id=".$objp->rowid,
);
$this->info_box_contents[$i][] = array(
'td' => 'align="left" width="16"',
'logo' => 'company',
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][] = array(
'td' => 'align="left"',
'text' => $objp->name,
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][] = array(
'td' => 'align="right"',
'text' => price($objp->total_ht),
);
if (! empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) {
if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid);
$this->info_box_contents[$i][] = array(
'td' => 'align="right"',
'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''),
'url' => (($objp->fk_user_valid > 0)?DOL_URL_ROOT.'/user/card.php?id='.$objp->fk_user_valid:''),
);
}
$this->info_box_contents[$i][] = array(
'td' => 'align="right"',
'text' => dol_print_date($date,'day'),
);
$this->info_box_contents[$i][] = array(
'td' => 'align="right" width="18"',
'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3),
);
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedOrders"));
$db->free($result);
$db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
else {
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql));
}
}
else {
$this->info_box_contents[0][0] = array('align' => 'left',
'text' => $langs->trans("ReadPermissionNotAllowed"));
} else {
$this->info_box_contents[0][0] = array(
'align' => 'left',
'text' => $langs->trans("ReadPermissionNotAllowed"),
);
}
}

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2005 Christophe
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -76,8 +76,7 @@ class box_comptes extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts"));
if ($user->rights->banque->lire)
{
if ($user->rights->banque->lire) {
$sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,";
$sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix as iban,";
$sql.= " domiciliation, proprio, owner_address,";
@ -90,76 +89,87 @@ class box_comptes extends ModeleBoxes
$sql.= " ORDER BY label";
$sql.= $db->plimit($max, 0);
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
$solde_total = 0;
$i = 0;
$solde_total = array();
$listofcurrencies=array();
$account_static = new Account($db);
while ($i < $num)
{
$objp = $db->fetch_object($result);
$account_static = new Account($db);
while ($i < $num) {
$objp = $db->fetch_object($result);
$account_static->id = $objp->rowid;
$solde=$account_static->solde(0);
$account_static->id = $objp->rowid;
$solde=$account_static->solde(0);
$solde_total += $solde;
$solde_total[$objp->currency_code] += $solde;
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid);
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => $this->boximg,
'tooltip' => $langs->trans('Account').': '.$objp->label,
'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid,
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $objp->label,
'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $objp->label,
'tooltip' => $langs->trans('Account').': '.$objp->label,
'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid,
);
$this->info_box_contents[$i][2] = array('td' => 'align="left"',
'text' => $objp->number
);
$this->info_box_contents[$i][2] = array(
'td' => 'align="left"',
'text' => $objp->number,
);
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
'text' => price($solde, 0, $langs, 0, 0, -1, $objp->currency_code)
);
$this->info_box_contents[$i][3] = array(
'td' => 'align="right"',
'text' => price($solde, 0, $langs, 0, 0, -1, $objp->currency_code)
);
$listofcurrencies[$objp->currency_code]=1;
$i++;
}
$i++;
}
// Total
if (count($listofcurrencies) <= 1)
{
$this->info_box_contents[$i][0] = array('tr' => 'class="liste_total"', 'td' => 'align="right" class="liste_total"',
'text' => $langs->trans('Total')
);
$this->info_box_contents[$i][1] = array('td' => 'align="right" class="liste_total"',
'text' => '&nbsp;'
);
$this->info_box_contents[$i][2] = array('td' => 'align="right" class="liste_total"',
'text' => '&nbsp;'
);
$totalamount=price($solde_total,0,$langs,0,0,-1,$conf->currency);
$this->info_box_contents[$i][3] = array('td' => 'align="right" class="liste_total"',
'text' => $totalamount
);
}
// Total
foreach ($solde_total as $key=>$solde) {
$this->info_box_contents[$i][0] = array(
'tr' => 'class="liste_total"',
'td' => 'align="right" class="liste_total"',
'text' => '&nbsp;',
);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left" class="liste_total"',
'text' => $langs->trans('Total').' '.$key,
);
$this->info_box_contents[$i][2] = array(
'td' => 'align="right" class="liste_total"',
'text' => '&nbsp;'
);
$totalamount=price($solde,0,$langs,0,0,-1,$key);
$this->info_box_contents[$i][3] = array(
'td' => 'align="right" class="liste_total"',
'text' => $totalamount
);
$i++;
}
$db->free($result);
}
else {
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql));
}
}
else {
$this->info_box_contents[0][0] = array('td' => 'align="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"));
}
$db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"),
);
}
}

View File

@ -73,65 +73,83 @@ class box_contacts extends ModeleBoxes
$sql.= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
$contactstatic=new Contact($db);
$societestatic=new Societe($db);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$objp = $db->fetch_object($result);
$datec=$db->jdate($objp->datec);
$datem=$db->jdate($objp->tms);
$contactstatic->lastname=$objp->lastname;
$contactstatic->lastname=$objp->lastname;
$contactstatic->firstname=$objp->firstname;
$contactstatic->civility_id=$objp->civility_id;
$societestatic->id=$objp->fk_soc;
$societestatic->name=$objp->socname;
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/contact/card.php?id=".$objp->rowid);
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => $this->boximg,
'tooltip' => $langs->trans('Contact').': '.$contactstatic->getFullName($langs,0),
'url' => DOL_URL_ROOT."/contact/card.php?id=".$objp->rowid,
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $contactstatic->getFullName($langs,0),
'url' => DOL_URL_ROOT."/contact/card.php?id=".$objp->rowid);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $contactstatic->getFullName($langs,0),
'tooltip' => $langs->trans('Contact').': '.$contactstatic->getFullName($langs,0),
'url' => DOL_URL_ROOT."/contact/card.php?id=".$objp->rowid,
);
$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
'logo' => ($objp->fk_soc > 0?'company':''),
'url' => ($objp->fk_soc > 0?DOL_URL_ROOT."/societe/soc.php?socid=".$objp->fk_soc:''));
$this->info_box_contents[$i][2] = array(
'td' => 'align="left" width="16"',
'logo' => ($objp->fk_soc > 0?'company':''),
'tooltip' => $societestatic->name,
'url' => ($objp->fk_soc > 0?DOL_URL_ROOT."/societe/soc.php?socid=".$objp->fk_soc:''),
);
$this->info_box_contents[$i][3] = array('td' => 'align="left"',
'text' => $societestatic->name,
'url' => DOL_URL_ROOT."/societe/soc.php?socid=".$objp->fk_soc);
$this->info_box_contents[$i][3] = array(
'td' => 'align="left"',
'text' => $societestatic->name,
'tooltip' => $societestatic->name,
'url' => DOL_URL_ROOT."/societe/soc.php?socid=".$objp->fk_soc,
);
$this->info_box_contents[$i][4] = array('td' => 'align="right"',
'text' => dol_print_date($datem, "day"));
$this->info_box_contents[$i][4] = array(
'td' => 'align="right"',
'text' => dol_print_date($datem, "day"),
);
$i++;
}
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedContacts"));
if ($num==0)
$this->info_box_contents[$i][0] = array(
'td' => 'align="center"',
'text'=>$langs->trans("NoRecordedContacts"),
);
$db->free($result);
}
else {
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql));
}
}
else {
$this->info_box_contents[0][0] = array('align' => 'left',
'text' => $langs->trans("ReadPermissionNotAllowed"));
}
$db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'align' => 'left',
'text' => $langs->trans("ReadPermissionNotAllowed"),
);
}
}
}
/**
* Method to show box

View File

@ -79,8 +79,7 @@ class box_contracts extends ModeleBoxes
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$objp = $db->fetch_object($resql);
$datec=$db->jdate($objp->datec);
$dateterm=$db->jdate($objp->fin_validite);
@ -94,50 +93,69 @@ class box_contracts extends ModeleBoxes
// fin_validite is no more on contract but on services
// if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); }
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid);
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => $this->boximg,
'tooltip' => $langs->trans('Contract').': '.($objp->ref?$objp->ref:$objp->rowid),
'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid,
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some contracts have no ref
'text2'=> $late,
'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => ($objp->ref?$objp->ref:$objp->rowid), // Some contracts have no ref
'tooltip' => $langs->trans('Contract').': '.($objp->ref?$objp->ref:$objp->rowid),
'text2'=> $late,
'url' => DOL_URL_ROOT."/contrat/card.php?id=".$objp->rowid,
);
$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
'logo' => 'company',
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][2] = array(
'td' => 'align="left" width="16"',
'logo' => 'company',
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][3] = array('td' => 'align="left"',
'text' => dol_trunc($objp->name,40),
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][3] = array(
'td' => 'align="left"',
'text' => dol_trunc($objp->name,40),
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][4] = array('td' => 'align="right"',
'text' => dol_print_date($datec,'day'));
$this->info_box_contents[$i][4] = array(
'td' => 'align="right"',
'text' => dol_print_date($datec,'day'),
);
$this->info_box_contents[$i][5] = array('td' => 'align="right" class="nowrap"',
'text' => $contractstatic->getLibStatut(6),
'asis'=>1
);
$this->info_box_contents[$i][5] = array(
'td' => 'align="right" class="nowrap"',
'text' => $contractstatic->getLibStatut(6),
'asis'=>1,
);
$i++;
}
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedContracts"));
if ($num==0)
$this->info_box_contents[$i][0] = array(
'td' => 'align="center"',
'text'=>$langs->trans("NoRecordedContracts"),
);
$db->free($resql);
}
else
{
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql));
}
}
else
{
$this->info_box_contents[0][0] = array('td' => 'align="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"));
}
$db->free($resql);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"),
);
}
}
/**

View File

@ -98,8 +98,12 @@ class box_external_rss extends ModeleBoxes
}
else
{
$this->info_box_head = array('text' => $title,
'sublink' => $link, 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")), 'subpicto'=>'object_bookmark');
$this->info_box_head = array(
'text' => $title,
'sublink' => $link,
'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")),
'subpicto'=>'object_bookmark',
);
}
// INFO on items
@ -112,8 +116,8 @@ class box_external_rss extends ModeleBoxes
// Feed common fields
$href = $item['link'];
$title = urldecode($item['title']);
$date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed
if ($rssparser->getFormat() == 'rss') // If RSS
$date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed
if ($rssparser->getFormat() == 'rss') // If RSS
{
if (! $date && isset($item['pubdate'])) $date=$item['pubdate'];
if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date'];
@ -138,19 +142,27 @@ class box_external_rss extends ModeleBoxes
$title=preg_replace("/^\s+/","",$title); // Supprime espaces de debut
$this->info_box_contents["$href"]="$title";
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => $href,
'target' => 'newrss');
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => $href,
'tooltip' => $title,
'target' => 'newrss',
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $title,
'url' => $href,
'maxlength' => 64,
'target' => 'newrss');
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $title,
'url' => $href,
'tooltip' => $title,
'maxlength' => 64,
'target' => 'newrss',
);
$this->info_box_contents[$i][2] = array('td' => 'align="right" nowrap="1"',
'text' => $date);
$this->info_box_contents[$i][2] = array(
'td' => 'align="right" nowrap="1"',
'text' => $date,
);
}
}

View File

@ -101,55 +101,76 @@ class box_factures extends ModeleBoxes
$late = '';
if ($objp->paye == 0 && ($objp->fk_statut != 2 && $objp->fk_statut != 3) && $datelimite < ($now - $conf->facture->client->warning_delay)) { $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));}
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $picto,
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => $picto,
'tooltip' => $langs->trans('CustomerInvoice').': '.$objp->facnumber,
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid,
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $objp->facnumber,
'text2'=> $late,
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => $objp->facnumber,
'text2'=> $late,
'tooltip' => $langs->trans('CustomerInvoice').': '.$objp->facnumber,
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid,
);
$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
'logo' => 'company',
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][2] = array(
'td' => 'align="left" width="16"',
'logo' => 'company',
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][3] = array('td' => 'align="left"',
'text' => $objp->name,
'maxlength'=>40,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][3] = array(
'td' => 'align="left"',
'text' => $objp->name,
'maxlength'=>40,
'tooltip' => $langs->trans('Customer').': '.$objp->name,
'url' => DOL_URL_ROOT."/comm/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][4] = array('td' => 'align="right"',
'text' => price($objp->total_ht),
);
$this->info_box_contents[$i][4] = array(
'td' => 'align="right"',
'text' => price($objp->total_ht),
);
$this->info_box_contents[$i][5] = array('td' => 'align="right"',
'text' => dol_print_date($date,'day'),
);
$this->info_box_contents[$i][5] = array(
'td' => 'align="right"',
'text' => dol_print_date($date,'day'),
);
$this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3));
$this->info_box_contents[$i][6] = array(
'td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3),
);
$i++;
}
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices"));
if ($num==0)
$this->info_box_contents[$i][0] = array(
'td' => 'align="center"',
'text'=>$langs->trans("NoRecordedInvoices"),
);
$db->free($result);
}
else
{
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql));
}
$db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
}
else {
$this->info_box_contents[0][0] = array('td' => 'align="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"));
}
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'text' => $langs->trans("ReadPermissionNotAllowed"),
);
}
}
/**
* Method to show box

View File

@ -18,9 +18,9 @@
*/
/**
* \file htdocs/core/boxes/box_factures_fourn.php
* \file htdocs/core/boxes/box_factures_fourn.php
* \ingroup supplier
* \brief Fichier de gestion d'une box des factures fournisseurs
* \brief Fichier de gestion d'une box des factures fournisseurs
*/
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
@ -89,8 +89,7 @@ class box_factures_fourn extends ModeleBoxes
$i = 0;
$l_due_date = $langs->trans('Late').' ('.$langs->trans('DateEcheance').': %s)';
while ($i < $num)
{
while ($i < $num) {
$objp = $db->fetch_object($result);
$datelimite=$db->jdate($objp->datelimite);
$date=$db->jdate($objp->df);
@ -99,54 +98,79 @@ class box_factures_fourn extends ModeleBoxes
$late = '';
if ($objp->paye == 0 && $datelimite && $datelimite < ($now - $conf->facture->fournisseur->warning_delay)) $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day')));
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
'logo' => $this->boximg,
'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid);
$this->info_box_contents[$i][0] = array(
'td' => 'align="left" width="16"',
'logo' => $this->boximg,
'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier,
'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid,
);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => ($objp->ref?$objp->ref:$objp->facid),
'text2'=> $late,
'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid);
$this->info_box_contents[$i][1] = array(
'td' => 'align="left"',
'text' => ($objp->ref?$objp->ref:$objp->facid),
'text2'=> $late,
'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier,
'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid,
);
$this->info_box_contents[$i][2] = array('td' => 'align="left"',
'text' => $objp->ref_supplier,
'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid);
$this->info_box_contents[$i][2] = array(
'td' => 'align="left"',
'text' => $objp->ref_supplier,
'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier,
'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid,
);
$this->info_box_contents[$i][3] = array('td' => 'align="left" width="16"',
'logo' => 'company',
'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][3] = array(
'td' => 'align="left" width="16"',
'logo' => 'company',
'tooltip' => $langs->trans('Supplier').': '.$objp->name,
'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][4] = array('td' => 'align="left"',
'text' => $objp->name,
'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid);
$this->info_box_contents[$i][4] = array(
'td' => 'align="left"',
'text' => $objp->name,
'tooltip' => $langs->trans('Supplier').': '.$objp->name,
'url' => DOL_URL_ROOT."/fourn/card.php?socid=".$objp->socid,
);
$this->info_box_contents[$i][5] = array('td' => 'align="right"',
'text' => dol_print_date($date,'day'));
$this->info_box_contents[$i][5] = array(
'td' => 'align="right"',
'text' => dol_print_date($date,'day'),
);
$fac = new FactureFournisseur($db);
$fac->fetch($objp->facid);
$alreadypaid=$fac->getSommePaiement();
$this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type));
$fac = new FactureFournisseur($db);
$fac->fetch($objp->facid);
$alreadypaid=$fac->getSommePaiement();
$this->info_box_contents[$i][6] = array(
'td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type),
);
$i++;
}
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoModifiedSupplierBills"));
if ($num==0)
$this->info_box_contents[$i][0] = array(
'td' => 'align="center"',
'text'=>$langs->trans("NoModifiedSupplierBills"),
);
$db->free($result);
}
else {
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql));
}
}
else {
$this->info_box_contents[0][0] = array('td' => 'align="left"',
'text' => $langs->transnoentities("ReadPermissionNotAllowed"));
}
}
$db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left"',
'text' => $langs->transnoentities("ReadPermissionNotAllowed"),
);
}
}
/**
* Method to show box

View File

@ -257,8 +257,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
// Loop on each TD
$nbcolthisline=count($contents[$i]);
for ($j=0; $j < $nbcolthisline; $j++)
{
for ($j=0; $j < $nbcolthisline; $j++) {
// Define tdparam
$tdparam='';
if (isset($contents[$i][$j]['td'])) $tdparam.=' '.$contents[$i][$j]['td'];
@ -270,13 +269,15 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
$text2withnotags=preg_replace('/<([^>]+)>/i','',$text2);
$textnoformat=isset($contents[$i][$j]['textnoformat'])?$contents[$i][$j]['textnoformat']:'';
//print "xxx $textwithnotags y";
if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip']="";
$tooltip=isset($contents[$i][$j]['tooltip'])?$contents[$i][$j]['tooltip']:'';
print '<td'.$tdparam.'>';
print '<td'.$tdparam.'>'."\n";
// Url
if (! empty($contents[$i][$j]['url']))
if (! empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo']))
{
print '<a href="'.$contents[$i][$j]['url'].'" title="'.$textwithnotags.'"';
print '<a href="'.$contents[$i][$j]['url'].'" title="'.dol_escape_htmltag($langs->trans("Show").' '.$tooltip, 1).'" class="classfortooltip"';
//print ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "<a href>"
print isset($contents[$i][$j]['target'])?' target="'.$contents[$i][$j]['target'].'"':'';
print '>';
@ -286,7 +287,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
if (! empty($contents[$i][$j]['logo']))
{
$logo=preg_replace("/^object_/i","",$contents[$i][$j]['logo']);
print img_object($langs->trans("Show"),$logo);
print '<a href="'.$contents[$i][$j]['url'].'">';
print img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"');
}
$maxlength=$MAXLENGTHBOX;
@ -304,7 +306,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
if (! empty($textnoformat)) print "\n".$textnoformat."\n";
print "</td>";
print "</td>\n";
}
print "</tr>\n";

View File

@ -404,7 +404,7 @@ abstract class CommonDocGenerator
{
global $conf;
return array(
$resarray= array(
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
'line_product_ref'=>$line->product_ref,
'line_product_label'=>$line->product_label,
@ -425,6 +425,18 @@ abstract class CommonDocGenerator
'line_date_end'=>$line->date_end,
'line_date_end_rfc'=>dol_print_date($line->date_end,'rfc')
);
// Retrieve extrafields
$extrafieldkey=$line->element;
$array_key="line";
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
$line->fetch_optionals($line->rowid,$extralabels);
$resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs);
return $resarray;
}
/**

View File

@ -1,5 +1,7 @@
<?php
/* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,6 +30,36 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
abstract class CommonInvoice extends CommonObject
{
/**
* Standard invoice
*/
const TYPE_STANDARD = 0;
/**
* Replacement invoice
*/
const TYPE_REPLACEMENT = 1;
/**
* Credit note invoice
*/
const TYPE_CREDIT_NOTE = 2;
/**
* Deposit invoice
*/
const TYPE_DEPOSIT = 3;
/**
* Proforma invoice
*/
const TYPE_PROFORMA = 4;
/**
* Situation invoice
*/
const TYPE_SITUATION = 5;
/**
* Return amount of payments already done
*
@ -143,11 +175,12 @@ abstract class CommonInvoice extends CommonObject
function getLibType()
{
global $langs;
if ($this->type == 0) return $langs->trans("InvoiceStandard");
if ($this->type == 1) return $langs->trans("InvoiceReplacement");
if ($this->type == 2) return $langs->trans("InvoiceAvoir");
if ($this->type == 3) return $langs->trans("InvoiceDeposit");
if ($this->type == 4) return $langs->trans("InvoiceProForma");
if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard");
if ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement");
if ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir");
if ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit");
if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma");
if ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation");
return $langs->trans("Unknown");
}

View File

@ -7,6 +7,7 @@
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2011-2014 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1743,6 +1744,19 @@ abstract class CommonObject
// Add revenue stamp to total
$this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0;
// Situations totals
if ($this->situation_cycle_ref && $this->situation_counter > 1) {
$prev_sits = $this->get_prev_sits();
foreach ($prev_sits as $sit) {
$this->total_ht -= $sit->total_ht;
$this->total_tva -= $sit->total_tva;
$this->total_localtax1 -= $sit->total_localtax1;
$this->total_localtax2 -= $sit->total_localtax2;
$this->total_ttc -= $sit->total_ttc;
}
}
$this->db->free($resql);
// Now update global field total_ht, total_ttc and tva
@ -2191,7 +2205,6 @@ abstract class CommonObject
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$this->id = $obj->rowid;
$this->canvas = $obj->canvas;
return 1;
}
@ -2547,7 +2560,7 @@ abstract class CommonObject
*/
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
{
global $conf,$langs,$user,$object,$hookmanager;
global $conf, $hookmanager, $inputalsopricewithtax, $langs, $user;
print '<tr class="liste_titre nodrag nodrop">';
@ -2570,6 +2583,10 @@ abstract class CommonObject
// Reduction short
print '<td align="right" width="50"><label for="remise_percent">'.$langs->trans('ReductionShort').'</label></td>';
if ($this->situation_cycle_ref) {
print '<td align="right" width="50"><label for="progress">' . $langs->trans('Progress') . '</label></td>';
}
if (! empty($conf->margin->enabled) && empty($user->societe_id))
{
if ($conf->global->MARGIN_TYPE == "1")

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