diff --git a/ChangeLog b/ChangeLog index 13346d43763..229fd1bac85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,22 @@ Upgrading to any other version or any other database system is abolutely require make a Dolibarr upgrade. +***** ChangeLog for 4.0 compared to 3.9.* ***** +For users: + +For developers: + + +WARNING: + +Dolibarr 4.0 should be compatible with PHP 7 but more feedbacks are still expected to confirm that. + +Following changes may create regression for some external modules, but were necessary to make +Dolibarr better: +- Method select_type_comptes_financiers() has been renamed into selectTypeOfBankAccount() + + + ***** ChangeLog for 3.9.0 compared to 3.8.* ***** For users: NEW: A new and more modern look for "eldy" theme. @@ -171,6 +187,109 @@ This is list of hooks modified: +***** ChangeLog for 3.8.4 compared to 3.8.3 ***** +FIX: #3694 +FIX: #3798 #2519 Cron jobs would never be executed +FIX: #4155 Search Categories error +FIX: #4239 +FIX: #4272 Error when trying to print the page "Linked objects" of a Thirdparty +FIX: #4291 Correctly filter bank card GETPOSTs +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: #4341 +FIX: #4394 Untranslated label in list of expense reports +FIX: #4414 Supplier invoices use FAC_FORCE_DATE_VALIDATION client invoices property +FIX: #4418 +FIX: #4425 Missing "VAT" translation in supplier order popup +FIX: #4434 Weird behaviour when enabling multiprices +FIX: #4440 Wrong price is filled by Product::fetch into multiprices arrays +FIX: #4453 SEPA Direct Debit generated XML shows a trailing comma in RmtInf field +FIX: #4528 +FIX: #4556 desiredstock and seuil_stock_alerte cleared on modify product card +FIX: #4580 +FIX: #4583 Incorrect call of Categories::containing throws a DoliDB error +FIX: #4649 Wrong parameters order +FIX: #4768 +FIX: #4785 +FIX: Add a test to show bugged module with a bad declaration of dictionaries to avoid to see clean module to be breaked. +FIX: add Croatia into list of country in EEC +FIX: add missing global def for ttc column +FIX: ajax error with multicompany module +FIX: Avoid errors when batch stock is negative +FIX: bad field in select +FIX: bad path +FIX: bad transaction level due to code of situation invoices +FIX: best sql request +FIX: bookmark's user change after update if the user hasn't superadmin right +FIX: call trigger LINEBILL_SUPPLIER_CREATE +FIX: Can not disabled an opened service line in a contract +FIX: can't clone event +FIX: can't send mail to thirdparty contact if no mail defined on thirdparty card +FIX: Check stock of batch on shippment +FIX: code corrupting database +FIX: compatibility with multicompany transversal mode +FIX: compatibility with multicompany transversal mode and more security issue +FIX: Contrat card don't consider user permissions to show active/unactive service button +FIX: CVE CVE-2015-8685 +FIX: Deadlock situation. Can't edit anymore contract. FIX: List of automatic events was not visible. +FIX: disable main.inc.php hooks +FIX: do not show warning if account defined +FIX: don't see the sales representative of anothers entities +FIX: duration format +FIX: Correct problem of rights beetween tax and salaries module +FIX: Email templates not compatible with Multicompany +FIX: $fileparams is not defined +FIX: filter by socid if from customer card +FIX: for avoid conflict with "global $m" in memory.lib.php +FIX: for avoid division by 0 +FIX: hover css +FIX: If option to hide automatic ECM is on, dont show menu. +FIX: if we dont use SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE the hour is displayed on pdf +FIX: Introduce hidden option to disable feature than hangs when too much data +FIX: ISSUE #4506 : make working the PROPAL_CLONE_ON_CREATE_PAGE hidden constant +FIX: issue when bank module is disabled FIX: missing entity filter for lines of payment +FIX: list of leave request was not showing label correctly. +FIX: MAIN_THIRDPARTY_CREATION_INDIVIDUAL syntax error in name +FIX: markRate can be 100 +FIX: minor css error (pixel size must have "px"). Compatibility with old behaviour. +FIX: missing field "label" +FIX: missing signature and uniformize code between card and script +FIX: missing traduction +FIX: missing translation +FIX: missing translation key +FIX: nblignes not calculated after hook and hook can't modify this value. Usefull for modules +FIX: no database structure change is allowed into minor versions +FIX: no transaction in this place +FIX: Noway to validate a leave request for some uer even if they have permission for. +FIX: Option to disable meteo was not set correctly in edit mode +FIX: $outputlangs is not defined (dolibarr 3.7, 3.8, 3.9) +FIX: path to copyrighted files +FIX: php unit to work both with old and new setup +FIX: Purge of temp files was broken +FIX: Relative discount decimals are not saved +FIX: Removed a bugged list. Fixed another one to not count data of previous year. +FIX: retrieve correct pu_ttc (set by printObjectLine function) like in 3.7 +FIX: search product in customer product prices doesn't work +FIX: Some filters are lost when paging +FIX: sql injection #4341 +FIX: sql injection even when code is on several lines +FIX: sql request and total for time spen for current month +FIX: Sql syntax error in doc_generic_task_odt +FIX: Status filter don't work +FIX: Strict Standards: Only variables should be passed by reference +FIX: The part added with hidden option MAIN_DOC_USE_TIMING was included with a . instead of -. This make os think it is part of extension instead of file name. +FIX: The third dashboard don't consider user permissions +FIX: the view my task must show only task you are assigned to +FIX: to allow phpunit of migration process for 3.4 to 3.5 +FIX: to allow phpunit of migration process for 3.5 to 3.6 +FIX: userlocaltax +FIX: view of product image when using old path +FIX: size of image uploaded on user. +FIX: We must ue the "small" size of imge to show on card pages. +FIX: When we make a direct assignement on a task to a user, we must check he is also assigned to project (and if not assign it) +FIX: wrong fk_parent_line in credit note with invoiceAvoirWithLines option +FIX: wrong modelpdf var name +FIX: wrong object name + ***** ChangeLog for 3.8.3 compared to 3.8.2 ***** FIX: #3805 FIX: #3231 [Members] Public subscription page displays GeoIP error diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index db61a84d133..58f1514b632 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -1108,6 +1108,14 @@ if ($nboftargetok) { "$DESTI/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM', "$DESTI/standard/$FILENAMETGZ.zip"=>'Dolibarr ERP-CRM' ); + %filestoscanstableasso=( + "$DESTI/package_rpm_generic/$FILENAMERPM"=>'package_rpm_generic', + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'package_debian-ubuntu', + "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows', + "$DESTI/standard/$FILENAMETGZ.tgz"=>'standard', + "$DESTI/standard/$FILENAMETGZ.zip"=>'standard' + ); + use POSIX qw/strftime/; foreach my $file (sort keys %filestoscansf) { @@ -1150,8 +1158,10 @@ if ($nboftargetok) { if ($target eq 'SF') { $destFolder="$NEWPUBLISH/$filestoscan{$file}/".$MAJOR.'.'.$MINOR.'.'.$BUILD; - print "Publish file ".$file." to $NEWPUBLISH/".$filestoscan{$file}."/".$MAJOR.'.'.$MINOR.'.'.$BUILD."\n"; } + elsif ($target eq 'ASSO' && $NEWPUBLISH =~ /stable/) { + $destFolder="$NEWPUBLISH/$filestoscanstableasso{$file}"; + } else { $dirnameonly=$file; @@ -1159,8 +1169,8 @@ if ($nboftargetok) { $filenameonly=$file; $filenameonly =~ s/.*\/[^\/]+\/([^\/])+$/$1/; $destFolder="$NEWPUBLISH/$dirnameonly"; - print "Publish file ".$file." to $NEWPUBLISH/".$dirnameonly."\n"; } + print "Publish file ".$file." to ".$destFolder."\n"; # mkdir #my $ssh = Net::SSH::Perl->new("frs.sourceforge.net"); diff --git a/dev/initdata/generate-invoice.php b/dev/initdata/generate-invoice.php index 11d827e0dcf..e7c274040de 100755 --- a/dev/initdata/generate-invoice.php +++ b/dev/initdata/generate-invoice.php @@ -90,7 +90,7 @@ $result=0; while ($i < GEN_NUMBER_FACTURE && $result >= 0) { $i++; - $socid = rand(1, $num_socs); + $socid = mt_rand(1, $num_socs); print "Invoice ".$i." for socid ".$socid; @@ -105,14 +105,14 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0) $result=$facture->validate($user); if ($result) { - $nbp = rand(2, 5); + $nbp = mt_rand(2, 5); $xnbp = 0; while ($xnbp < $nbp) { - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $product=new Product($db); $result=$product->fetch($prodids[$prodid]); - $result=$facture->addline($product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); + $result=$facture->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); if ($result < 0) { dol_print_error($db,$propal->error); diff --git a/dev/initdata/generate-order.php b/dev/initdata/generate-order.php index 082d5428c97..9e96bbd781b 100755 --- a/dev/initdata/generate-order.php +++ b/dev/initdata/generate-order.php @@ -165,7 +165,7 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++) $com = new Commande($db); $com->socid = 4; - $com->date_commande = $dates[rand(1, count($dates)-1)]; + $com->date_commande = $dates[mt_rand(1, count($dates)-1)]; $com->note = 'A comment'; $com->source = 1; $com->fk_project = 0; @@ -179,14 +179,14 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++) $result=$com->valid($user); if ($result > 0) { - $nbp = rand(2, 5); + $nbp = mt_rand(2, 5); $xnbp = 0; while ($xnbp < $nbp) { - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $product=new Product($db); $result=$product->fetch($prodids[$prodid]); - $result=$com->addline($product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type); + $result=$com->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type); if ($result < 0) { dol_print_error($db,$propal->error); diff --git a/dev/initdata/generate-product.php b/dev/initdata/generate-product.php index 975fc1ba33d..fbdde96f95a 100755 --- a/dev/initdata/generate-product.php +++ b/dev/initdata/generate-product.php @@ -85,12 +85,12 @@ for ($s = 0 ; $s < GEN_NUMBER_PRODUIT ; $s++) { print "Product ".$s; $produit = new Product($db); - $produit->type = rand(0,1); + $produit->type = mt_rand(0,1); $produit->status = 1; $produit->ref = ($produit->type?'S':'P').time().$s; $produit->label = 'Label '.time().$s; $produit->description = 'Description '.time().$s; - $produit->price = rand(1,1000); + $produit->price = mt_rand(1,1000); $produit->tva_tx = "19.6"; $ret=$produit->create($user); if ($ret < 0) print "Error $ret - ".$produit->error."\n"; diff --git a/dev/initdata/generate-proposal.php b/dev/initdata/generate-proposal.php index 8d413a518c1..071efc0298f 100755 --- a/dev/initdata/generate-proposal.php +++ b/dev/initdata/generate-proposal.php @@ -117,7 +117,7 @@ $result=0; while ($i < GEN_NUMBER_PROPAL && $result >= 0) { $i++; - $socid = rand(1, $num_socs); + $socid = mt_rand(1, $num_socs); print "Proposal ".$i." for socid ".$socid; $soc = new Societe($db); @@ -140,14 +140,14 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0) $result=$propal->create($user); if ($result >= 0) { - $nbp = rand(2, 5); + $nbp = mt_rand(2, 5); $xnbp = 0; while ($xnbp < $nbp) { - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $product=new Product($db); $result=$product->fetch($prodids[$prodid]); - $result=$propal->addline($product->description, $product->price, rand(1,5), 0, 0, 0, $prodids[$prodid], 0); + $result=$propal->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0); if ($result < 0) { dol_print_error($db,$propal->error); diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php index d6e9d4c9393..8c3a6e3e86e 100755 --- a/dev/initdata/generate-thirdparty.php +++ b/dev/initdata/generate-thirdparty.php @@ -90,30 +90,30 @@ for ($s = 0 ; $s < GEN_NUMBER_SOCIETE ; $s++) print "Company $s\n"; $soc = new Societe($db); $soc->name = "Company num ".time()."$s"; - $soc->town = $listoftown[rand(0, count($listoftown)-1)]; - $soc->client = rand(1,2); // Une societe sur 2 est prospect, l'autre client - $soc->fournisseur = rand(0,1); // Une societe sur 2 est fournisseur + $soc->town = $listoftown[mt_rand(0, count($listoftown)-1)]; + $soc->client = mt_rand(1,2); // Une societe sur 2 est prospect, l'autre client + $soc->fournisseur = mt_rand(0,1); // Une societe sur 2 est fournisseur $soc->code_client='CU'.time()."$s"; $soc->code_fournisseur='SU'.time()."$s"; $soc->tva_assuj=1; $soc->country_id=1; $soc->country_code='FR'; // Un client sur 3 a une remise de 5% - $user_remise=rand(1,3); if ($user_remise==3) $soc->remise_percent=5; + $user_remise=mt_rand(1,3); if ($user_remise==3) $soc->remise_percent=5; print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_percent."\n"; $soc->note_private = 'Company created by the script generate-societe.php'; $socid = $soc->create(); if ($socid >= 0) { - $rand = rand(1,4); + $rand = mt_rand(1,4); print "> Generates $rand contact(s)\n"; for ($c = 0 ; $c < $rand ; $c++) { $contact = new Contact($db); $contact->socid = $soc->id; $contact->lastname = "Lastname".$c; - $contact->firstname = $listoflastname[rand(0, count($listoflastname)-1)]; + $contact->firstname = $listoflastname[mt_rand(0, count($listoflastname)-1)]; if ( $contact->create($user) ) { diff --git a/dev/initdemo/initdemo.sh b/dev/initdemo/initdemo.sh index e8ea47c71b2..10dc671e09d 100755 --- a/dev/initdemo/initdemo.sh +++ b/dev/initdemo/initdemo.sh @@ -171,6 +171,8 @@ then fi #echo "mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile" #mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile +#echo "drop old table" +echo "drop table llx_accounting_account;" | mysql -P$port -u$admin $passwd $base echo "mysql -P$port -u$admin -p***** $base < $mydir/$dumpfile" mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile export res=$? diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 28333b3edee..3c47498c52e 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -322,10 +322,22 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) print ''; - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + print ''; + } + print ''; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 0dc1798ef57..0b43e99b1d8 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -198,7 +198,8 @@ if (! $conf->use_javascript_ajax) { $listmodelcsv = array ( '1' => $langs->trans("Modelcsv_normal"), '2' => $langs->trans("Modelcsv_CEGID"), - '3' => $langs->trans("Modelcsv_COALA") + '3' => $langs->trans("Modelcsv_COALA"), + '4' => $langs->trans("Modelcsv_bob50") ); print $form->selectarray("modelcsv", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0); diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 16027a42af4..3e4b69d6624 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * * 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 @@ -106,81 +106,38 @@ if (! empty($search_accountancy_code_end)) { if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = 'bookkepping'; - + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - - $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); + + $result = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + foreach ( $object->lines as $line ) { - + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; - // Model Cegid Expert Export - $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $date . $sep; - print $line->code_journal . $sep; - print length_accountg($line->numero_compte) . $sep; - print ' ' . $sep; - print $line->sens . $sep; - print price($line->montant) . $sep; - print dol_trunc($line->label_compte, 32) . $sep; - print $line->doc_ref . $sep; - - /*print $line->piece_num . $sep; - print length_accounta($line->code_tiers) . $sep; - print . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep;*/ - - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - - // Std export - $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); - print $date . $sep; - print $line->doc_ref . $sep; - print length_accounta($line->numero_compte) . $sep; - print length_accountg($line->code_tiers) . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - - /*print $line->piece_num . $sep; - print $line->label_compte . $sep; - print price($line->montant) . $sep; - print $line->sens . $sep;*/ - print $line->code_journal . $sep; - print "\n"; - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { - - // Coala export - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $sep; - print $line->code_journal . $sep; - print length_accounta($line->numero_compte) . $sep; - print $line->piece_num . $sep; - print $line->doc_ref . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep; - print 'E' . $sep; - print length_accountg($line->code_tiers) . $sep; - print "\n"; } + print length_accountg($line->numero_compte) . $sep; + print $line->debit . $sep; + print $line->credit . $sep; + print $line->debit . $sep; + print $line->credit - $line->debit . $sep; + print "\n"; } -} +} else { - + $title_page = $langs->trans("AccountBalance") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); - + llxHeader('', $title_page); - + /* * List */ - + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); @@ -188,27 +145,27 @@ else { setEventMessages($object->error, $object->errors, 'errors'); } } - + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); - + print '
'; print '
' . "\n"; print '
'; - + print '
'; - + print '
'; print $langs->trans('DateStart') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print $langs->trans('DateEnd') . ': '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print '
'; - + print ''; print ''; print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); @@ -217,7 +174,7 @@ else { print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; - + print ''; print ''; - + print ''; print ''; print ''; - + print ''; - + print ''; - + $var = True; - + $total_debit = 0; $total_credit = 0; - + foreach ( $object->lines as $line ) { $var = ! $var; - + $total_debit += $line->debit; $total_credit += $line->credit; - + print ""; - + print ''; print ''; print ''; @@ -260,7 +217,7 @@ else { print ''; print "\n"; } - + print ''; print ''; print ''; print ''; print ''; - + print "
'; print $langs->trans('From'); @@ -226,32 +183,32 @@ else { print $langs->trans('To'); print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print '   '; print ''; print ' '; print ''; print '
' . length_accountg($line->numero_compte) . '' . price($line->debit) . '' . price($line->credit) . '
'; @@ -272,10 +229,10 @@ else { print '' . price($total_credit - $total_debit) . '
"; print '
'; - + llxFooter(); } $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 387df40122c..515736580f8 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * * 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 @@ -182,9 +182,9 @@ if (! empty($search_mvt_num)) { * Action */ if ($action == 'delbookkeeping') { - + $import_key = GETPOST('importkey', 'alpha'); - + if (! empty($import_key)) { $result = $object->deleteByImportkey($import_key); if ($result < 0) { @@ -194,9 +194,9 @@ if ($action == 'delbookkeeping') { exit(); } } elseif ($action == 'delbookkeepingyearconfirm') { - + $delyear = GETPOST('delyear', 'int'); - + if (! empty($delyear)) { $result = $object->deleteByYear($delyear); if ($result < 0) { @@ -206,34 +206,30 @@ if ($action == 'delbookkeeping') { exit(); } } elseif ($action == 'delmouvconfirm') { - + $mvt_num = GETPOST('mvt_num', 'int'); - + if (! empty($mvt_num)) { $result = $object->deleteMvtNum($mvt_num); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - // if (!empty($options)) { - // Header("Location: list.php?".urldecode($options)); - // } else { Header("Location: list.php"); - // } exit(); } } elseif ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = 'bookkepping'; - + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - + $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + foreach ( $object->lines as $line ) { - + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; // Model Cegid Expert Export @@ -246,16 +242,9 @@ if ($action == 'delbookkeeping') { print price($line->montant) . $sep; print dol_trunc($line->label_compte, 32) . $sep; print $line->doc_ref . $sep; - - /*print $line->piece_num . $sep; - print length_accounta($line->code_tiers) . $sep; - print . $sep; - print price($line->debit) . $sep; - print price($line->credit) . $sep;*/ - print "\n"; } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - + // Std export $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); print $date . $sep; @@ -264,15 +253,10 @@ if ($action == 'delbookkeeping') { print length_accounta($line->code_tiers) . $sep; print price($line->debit) . $sep; print price($line->credit) . $sep; - - /*print $line->piece_num . $sep; - print $line->label_compte . $sep; - print price($line->montant) . $sep; - print $line->sens . $sep;*/ print $line->code_journal . $sep; print "\n"; } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { - + // Coala export $date = dol_print_date($line->doc_date, '%d/%m/%Y'); print $date . $sep; @@ -285,23 +269,48 @@ if ($action == 'delbookkeeping') { print 'E' . $sep; print length_accountg($line->code_tiers) . $sep; print "\n"; + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 4) { + + // Bob50 + print $line->piece_num . $sep; + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $sep; + + if (empty($line->code_tiers)) { + print 'G' . $sep; + print length_accounta($line->numero_compte) . $sep; + } else { + if (substr($line->numero_compte,0,3)=='411') { + print 'C' . $sep; + } + if (substr($line->numero_compte,0,3)=='401') { + print 'F' . $sep; + } + print length_accountg($line->code_tiers) . $sep; + + } + + print price($line->debit) . $sep; + print price($line->credit) . $sep; + print dol_trunc($line->label_compte, 32) . $sep; + print "\n"; } } -} +} /* * View */ else { - + $title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); - + llxHeader('', $title_page); - + /* * List */ - + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); @@ -309,78 +318,48 @@ else { setEventMessages($object->error, $object->errors, 'errors'); } } - + $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); print $formconfirm; } if ($action == 'delbookkeepingyear') { - + $form_question = array (); $delyear = GETPOST('delyear'); - + if (empty($delyear)) { $delyear = dol_print_date(dol_now(), '%Y'); } $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - + $form_question['delyear'] = array ( 'name' => 'delyear', 'type' => 'select', 'label' => $langs->trans('DelYear'), 'values' => $year_array, - 'default' => $delyear + 'default' => $delyear ); - + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1); print $formconfirm; } - + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); - - /*print '
'; - print ''; - print ''; - - print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey')); - - print '
'; - - print '
';*/ - + print '
'; print '
' . "\n"; print '
'; print ''; - // print '' . $langs->trans("Export") . ''; print '
'; - + print '
'; - - /*print '
'; - print $langs->trans('DateStart') . ': '; - print $form->select_date($search_date_start, 'date_start', 0, 0, 1); - print $langs->trans('DateEnd') . ': '; - print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - print '
'; - print '
'; - print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; - print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; - print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); - print '
'; - print '
'; - print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; - print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); - print '
';*/ - + print ''; print ''; print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder); @@ -391,12 +370,10 @@ else { print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); - // print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); - // print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; - + print ''; print ''; print ''; @@ -404,61 +381,52 @@ else { print $langs->trans('From') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print '
'; - print $langs->trans('to') . ': '; + print $langs->trans('To') . ': '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); - // print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1); print ''; print ''; print ''; - // print ''; print ''; - // print ''; - + print ''; print ''; print ''; - // print ''; - // print ''; print ''; print ''; - + print ''; - + $var = True; - + $total_debit = 0; $total_credit = 0; - + foreach ( $object->lines as $line ) { $var = ! $var; - + $total_debit += $line->debit; $total_credit += $line->credit; - + print ""; - + print ''; print ''; print ''; @@ -467,8 +435,6 @@ else { print ''; print ''; print ''; - // print ''; - // print ''; print ''; print ''; print "\n"; } - + print ''; print ''; print ''; print ''; print ''; - + print "
'; - // print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; print $langs->trans('From'); print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); - // print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; print '
'; - print $langs->trans('to'); + print $langs->trans('To'); print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print '
'; - // print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $langs->trans('From'); print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); - // print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print '
'; - print $langs->trans('to'); + print $langs->trans('To'); print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); print '
'; print ''; print '    '; print ''; print ' '; print ''; print '
' . $line->piece_num . '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->montant) . '' . $line->sens . '' . $line->code_journal . ''; print '' . img_edit() . ' '; @@ -476,7 +442,7 @@ else { print '
'; @@ -487,10 +453,10 @@ else { print '
"; print '
'; - + llxFooter(); } diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index dfd52ec0f00..10640c1887a 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -74,7 +74,6 @@ if (empty($search_date_start)) { $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); } - if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") @@ -184,13 +183,13 @@ print ''; print '
'; print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; print $formventilation->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, ''); -print $langs->trans('to') . ' ' . $langs->trans('AccountAccounting') . ': '; +print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; print $formventilation->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, ''); print '
'; print '
'; print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $formventilation->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); -print $langs->trans('to') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; +print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; print $formventilation->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); print '
'; print ""; @@ -257,9 +256,10 @@ print ''; -print ''; print "\n"; @@ -268,7 +268,7 @@ $var = True; foreach ( $object->lines as $line ) { $var = ! $var; - + print ""; print '' . "\n"; print '' . "\n"; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0015dfbf9e9..f4b478b681e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015-*2016 Florian Henry + * Copyright (C) 2015-2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify @@ -1064,6 +1064,7 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); @@ -1118,7 +1119,7 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -1147,7 +1148,7 @@ class BookKeeping extends CommonObject } } else { $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::fetch_all_per_mvt " . $this->error, LOG_ERR); + dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); return - 1; } diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 7b4d597fc12..471a329e64c 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -48,6 +48,8 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_country = GETPOST('search_country', 'alpha'); +$search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Getpost Order and column and limit page $sortfield = GETPOST('sortfield', 'alpha'); @@ -68,7 +70,7 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $offset = $limit * $page; if (! $sortfield) - $sortfield = "f.datef, f.facnumber, l.rowid"; + $sortfield = "f.datef, f.facnumber, fd.rowid"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { @@ -94,6 +96,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_country = ''; + $search_tvaintra = ''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -150,14 +154,27 @@ print ''; + '; /* * Action */ - if ($action == 'ventil' && ! empty($btn_ventil)) { print '
' . $langs->trans("Processing") . '...
'; if (! empty($codeventil) && ! empty($mesCasesCochees)) { print '
' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '
'; $mesCodesVentilChoisis = $codeventil; $cpt = 0; - + foreach ( $mesCasesCochees as $maLigneCochee ) { $maLigneCourante = explode("_", $maLigneCochee); $monId = $maLigneCourante[0]; $monNumLigne = $maLigneCourante[1]; $monCompte = $mesCodesVentilChoisis[$monNumLigne]; - + $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql .= " SET fk_code_ventilation = " . $monCompte; $sql .= " WHERE rowid = " . $monId; - + + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); + dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG); if ($db->query($sql)) { - print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '
'; + print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
'; } else { - print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '
' . $sql . '
'; + print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
' . $sql . '
'; } - + $cpt ++; } } else { @@ -164,7 +166,6 @@ if ($action == 'ventil' && ! empty($btn_ventil)) { /* * Customer Invoice lines */ - if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { @@ -224,16 +225,13 @@ $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); $i = 0; - + print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); print '
' . $langs->trans("DescVentilTodoCustomer") . '
'; - print_liste_field_titre($langs->trans("Date"), $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder); - print '  '; - print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); - + print '
' . "\n"; print ''; - + print '
'; print ''; print ''; -$searchpitco=$form->showFilterAndCheckAddButtons(0); -print $searchpitco; +print ''; +print ''; +print ' '; +print ''; print '
' . $line->piece_num . '' . $line->doc_type . '
'; print ''; print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); @@ -247,40 +245,39 @@ if ($result) { print_liste_field_titre(''); print_liste_field_titre($langs->trans("Ventilate") . '
/', '', '', '', '', 'align="center"'); print ''; - + // We add search filter - print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; - + $facture_static = new Facture($db); $product_static = new Product($db); $form = new Form($db); - + $var = true; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; - + $objp->code_sell_l = ''; $objp->code_sell_p = ''; $objp->aarowid_suggest = ''; $code_sell_p_l_differ = ''; - + $code_sell_p_notset = ''; $objp->aarowid_suggest = $objp->aarowid; - + if (! empty($objp->code_sell)) { $objp->code_sell_p = $objp->code_sell; } else { @@ -304,9 +301,9 @@ if ($result) { } if ($objp->code_sell_l != $objp->code_sell_p) $code_sell_p_l_differ = 'color:red'; - + print ""; - + // Ref Invoice $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; @@ -316,14 +313,14 @@ if ($result) { $product_static->id = $objp->product_id; $product_static->type = $objp->type; print ''; - + print ''; $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; print ''; @@ -339,10 +336,10 @@ if ($result) { if ($objp->code_sell_l == $objp->code_sell_p) { print $objp->code_sell_l; } else { - print $langs->trans("Purchase") . ' = ' . $objp->code_sell_l . '
' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p; + print $langs->trans("Buy") . ' = ' . $objp->code_sell_l . '
' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p; } print ''; - + print ''; @@ -353,7 +350,7 @@ if ($result) { print ''; $i ++; } - + print '
%%'; print ''; print ' '; print ''; print '
'; - + if ($product_static->id) print $product_static->getNomUrl(1); else print ' '; - + print '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, $trunclength)) . ''; print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1); print '
'; print '
'; print ''; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 4529fe08278..f995b2684ee 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -71,7 +71,7 @@ $now = dol_now(); // Security check if ($user->societe_id > 0 && empty($id_bank_account)) accessforbidden(); - + /* * View */ @@ -122,7 +122,7 @@ $paymentsalstatic = new PaymentSalary($db); // Get code of finance journal $bank_code_journal = new Account($db); $result = $bank_code_journal->fetch($id_bank_account); -$journal = $bank_code_journal->ref; +$journal = $bank_code_journal->accountancy_journal; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); $result = $db->query($sql); @@ -148,7 +148,7 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_client' => $obj->code_compta + 'code_client' => $obj->code_compta ); // Controls @@ -251,7 +251,7 @@ if ($result) { $tabbq[$obj->rowid][$compta_bank] += $obj->amount; // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; - + $i ++; } } else { @@ -312,14 +312,13 @@ if ($action == 'writebookkeeping') { if ($resultmid) { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; - ; } } $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } // Third party @@ -388,7 +387,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } else { - + $bookkeeping->doc_ref = $k; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } @@ -396,7 +395,7 @@ if ($action == 'writebookkeeping') { $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } } @@ -414,7 +413,7 @@ if ($action == 'export_csv') { $companystatic = new Client($db); // Model Cegid Expert Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; @@ -436,7 +435,7 @@ if ($action == 'export_csv') { print ($mt < 0 ? 'C' : 'D') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; print $val["type_payment"] . $sep; - print $val["ref"] . $sep; + print utf8_decode($val["ref"]) . $sep; print "\n"; } @@ -455,7 +454,7 @@ if ($action == 'export_csv') { print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; print $val["type_payment"] . $sep; - print $val["ref"] . $sep; + print utf8_decode($val["ref"]) . $sep; print "\n"; } } @@ -468,7 +467,7 @@ if ($action == 'export_csv') { print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; print $val["type_payment"] . $sep; - print $val["ref"] . $sep; + print utf8_decode($val["ref"]) . $sep; print "\n"; } } @@ -486,7 +485,12 @@ if ($action == 'export_csv') { print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("Bank") . '"' . $sep; + if ($companystatic->name == '') { + print '"' . $langs->trans('Bank') . " - " . utf8_decode($val["ref"]) . '"' . $sep; + } else { + print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; + } + // print '"' . $langs->trans("Bank") . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; @@ -499,7 +503,12 @@ if ($action == 'export_csv') { print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $companystatic->name . '"' . $sep; + // print '"' . $companystatic->name . '"' . $sep; + if ($companystatic->name == '') { + print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($val["ref"]) . '"' . $sep; + } else { + print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep; + } print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; @@ -510,7 +519,12 @@ if ($action == 'export_csv') { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; - print '"' . $langs->trans("Bank") . '"' . $sep; + // print '"' . $langs->trans("Bank") . '"' . $sep; + if ($companystatic->name == '') { + print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($val["ref"]) . '"' . $sep; + } else { + print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; + } print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; @@ -523,7 +537,7 @@ else { $form = new Form($db); llxHeader('', $langs->trans("FinanceJournal")); - + $nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1); $builddate = time(); $description = $langs->trans("DescFinanceJournal") . '
'; @@ -531,7 +545,7 @@ else { $varlink = 'id_account=' . $id_bank_account; report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( - 'action' => '' + 'action' => '' ), '', $varlink); print ''; @@ -573,7 +587,7 @@ else { foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + if ($val["lib"] == '(SupplierInvoicePayment)') { $reflabel = $langs->trans('SupplierInvoicePayment'); } @@ -587,7 +601,12 @@ else { print "" . $date . ""; print "" . $reflabel . ""; print "" . length_accountg($k) . ""; - print "" . $langs->trans('Bank') . ""; + // print "" . $langs->trans('Bank') . ""; + if ($val['soclib'] == '') { + print "" . $langs->trans('Bank') . " - " . $val["ref"] . ""; + } else { + print "" . $langs->trans("Bank") . " - " . $val['soclib'] . ""; + } print "" . $val["type_payment"] . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; @@ -601,8 +620,18 @@ else { print ""; print "" . $date . ""; print "" . $val["soclib"] . ""; + // print "" . length_accounta($k) . ""; + if (length_accounta($k) == '') { + print "" . length_accounta($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) . ""; + } else { print "" . length_accounta($k) . ""; - print "" . $langs->trans('ThirdParty') . " (" . $val['soclib'] . ")"; + } + // print "" . $langs->trans('ThirdParty') . " (" . $val['soclib'] . ")"; + if ($val['soclib'] == '') { + print "" . $langs->trans('ThirdParty') . " - " . $val["ref"] . ""; + } else { + print "" . $langs->trans("ThirdParty") . ' - ' . $val['soclib'] . ""; + } print "" . $val["type_payment"] . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; @@ -615,7 +644,12 @@ else { print "" . $date . ""; print "" . $reflabel . ""; print "" . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . ""; - print "" . $langs->trans('ThirdParty') . ""; + // print "" . $langs->trans('ThirdParty') . ""; + if ($val['soclib'] == '') { + print "" . $langs->trans('ThirdParty') . " - " . $val["ref"] . ""; + } else { + print "" . $langs->trans("ThirdParty") . ' - ' . $val['soclib'] . ""; + } print " "; print "" . ($mt < 0 ? price(- $mt) : '') . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 7d9778f72b8..82811598188 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -112,14 +112,14 @@ if ($result) { $num = $db->num_rows($result); // les variables $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - + $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); + $tabfac = array (); $tabht = array (); $tabtva = array (); $tabttc = array (); $tabcompany = array (); - + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); @@ -133,9 +133,13 @@ if ($result) { $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); } $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - + $tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; + $tabfac[$obj->rowid]["refsologest"] = $obj->ref ; + $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier ; + + $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->description; $tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; @@ -145,9 +149,9 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_fournisseur' => $obj->code_compta_fournisseur + 'code_fournisseur' => $obj->code_compta_fournisseur ); - + $i ++; } } else { @@ -158,11 +162,11 @@ if ($result) { if ($action == 'writebookkeeping') { $now = dol_now(); $error = 0; - + foreach ( $tabfac as $key => $val ) { foreach ( $tabttc[$key] as $k => $mt ) { // get compte id and label - + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -179,14 +183,14 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { if ($mt) { @@ -209,16 +213,16 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } } } - + // VAT // var_dump($tabtva); foreach ( $tabtva[$key] as $k => $mt ) { @@ -240,16 +244,16 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } } } - + if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } @@ -265,23 +269,23 @@ $companystatic = new Fournisseur($db); if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; - + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - + // Model Cegid Expert Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; - + foreach ( $tabfac as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + if ($mt) { print $date . $sep; print $purchase_journal . $sep; @@ -294,7 +298,7 @@ if ($action == 'export_csv') { print "\n"; } } - + // VAT foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -309,7 +313,7 @@ if ($action == 'export_csv') { print "\n"; } } - + foreach ( $tabttc[$key] as $k => $mt ) { print $date . $sep; print $purchase_journal . $sep; @@ -325,12 +329,20 @@ if ($action == 'export_csv') { } else { // Model Classic Export foreach ( $tabfac as $key => $val ) { + + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $invoicestatic->ref = $val["refsologest"]; + $invoicestatic->refsupplier = $val["refsuppliersologest"]; + $invoicestatic->type = $val["type"]; + $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); @@ -339,7 +351,8 @@ if ($action == 'export_csv') { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; + //print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; @@ -351,19 +364,21 @@ if ($action == 'export_csv') { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("VAT") . '"' . $sep; + //print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; } } - + // Third party foreach ( $tabttc[$key] as $k => $mt ) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode($companystatic->name) . '"' . $sep; + //print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; } @@ -371,11 +386,11 @@ if ($action == 'export_csv') { } } } else { - + llxHeader('', $langs->trans("PurchasesJournal")); - + $form = new Form($db); - + $nom = $langs->trans("PurchasesJournal"); $nomlink = ''; $periodlink = ''; @@ -387,16 +402,16 @@ if ($action == 'export_csv') { } else { $description .= $langs->trans("DepositsAreIncluded"); } - + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( - 'action' => '' + 'action' => '' )); - + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -425,31 +440,39 @@ if ($action == 'export_csv') { print ""; print ""; print "\n"; - + $var = true; $r = ''; - + $invoicestatic = new FactureFournisseur($db); - + foreach ( $tabfac as $key => $val ) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; + + $invoicestatic->ref = $val["refsologest"]; + $invoicestatic->refsupplier = $val["refsuppliersologest"]; + + $invoicestatic->type = $val["type"]; $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print ""; print ""; print ""; print ""; - print ""; + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + print ""; + //print ""; print '"; print '"; print ""; @@ -461,34 +484,36 @@ if ($action == 'export_csv') { print ""; print ""; print ""; - print ""; + print "" ; + print ""; print '"; print '"; print ""; } } print ""; - + // Third party foreach ( $tabttc[$key] as $k => $mt ) { print ""; print ""; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print ""; + print ""; + print ""; + //print ""; print '"; print '"; } print ""; - + $var = ! $var; } - + print "
" . $langs->trans("Account") . "" . $langs->trans("Type") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $accountingaccount->label . "" . $companystatic->getNomUrl(0, 'supplier', 16). ' - ' .$invoicestatic->refsupplier .' - '. $accountingaccount->label . "" . $accountingaccount->label . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $langs->trans("VAT") . "" . length_accountg($k) . "" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("VAT") . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accounta($k); - print "" . $langs->trans("ThirdParty"); - print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; - print "" . length_accounta($k)."" . $companystatic->getNomUrl(0, 'supplier', 16). ' - '.$invoicestatic->refsupplier .' - '. $langs->trans("Code_tiers")."" . $langs->trans("ThirdParty"); + //print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; + //print "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 5166d503b06..8ffb4690dba 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -40,10 +40,10 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs -$langs->load("commercial"); $langs->load("compta"); $langs->load("bills"); $langs->load("other"); +$langs->load("main"); $langs->load("accountancy"); $date_startmonth = GETPOST('date_startmonth'); @@ -119,16 +119,16 @@ if ($result) { $tabtva = array (); $tabttc = array (); $tabcompany = array (); - + $num = $db->num_rows($result); $i = 0; - + while ( $i < $num ) { $obj = $db->fetch_object($result); // les variables $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; - + $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) @@ -138,22 +138,23 @@ if ($result) { } $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - + // Situation invoices handling $line = new FactureLigne($db); - $line->fetch($obj->rowid); - $prev_progress = $line->get_prev_progress(); + $line->fetch($obj->fdid); // id of line + $prev_progress = 0; if ($obj->type == Facture::TYPE_SITUATION) { - // Avoid divide by 0 + // Avoid divide by 0 if ($obj->situation_percent == 0) { $situation_ratio = 0; } else { - $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; + $prev_progress = $line->get_prev_progress($obj->rowid); // id of invoice + $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; } } else { $situation_ratio = 1; } - + // Invoice lines $tabfac[$obj->rowid]["date"] = $obj->df; $tabfac[$obj->rowid]["ref"] = $obj->facnumber; @@ -172,9 +173,9 @@ if ($result) { $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, - 'code_client' => $obj->code_compta + 'code_client' => $obj->code_compta ); - + $i ++; } } else { @@ -190,7 +191,7 @@ if ($result) { if ($action == 'writebookkeeping') { $now = dol_now(); $error = 0; - + foreach ( $tabfac as $key => $val ) { foreach ( $tabttc[$key] as $k => $mt ) { $bookkeeping = new BookKeeping($db); @@ -209,14 +210,14 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt < 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { if ($mt) { @@ -239,16 +240,16 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } } } - + // VAT // var_dump($tabtva); foreach ( $tabtva[$key] as $k => $mt ) { @@ -269,16 +270,16 @@ if ($action == 'writebookkeeping') { $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->fk_user_author = $user->id; - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } } } - + if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } @@ -288,23 +289,23 @@ if ($action == 'writebookkeeping') { if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; - + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - + $companystatic = new Client($db); - + // Model Cegid Expert Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; - + foreach ( $tabfac as $key => $val ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + foreach ( $tabttc[$key] as $k => $mt ) { print $date . $sep; print $sell_journal . $sep; @@ -316,7 +317,7 @@ if ($action == 'export_csv') { print $val["ref"]; print "\n"; } - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount_static = new AccountingAccount($db); @@ -332,7 +333,7 @@ if ($action == 'export_csv') { print "\n"; } } - + // TVA foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -354,42 +355,45 @@ if ($action == 'export_csv') { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + foreach ( $tabttc[$key] as $k => $mt ) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode($companystatic->name) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $companystatic->ref_client . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + //print '"' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; } - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - '. utf8_decode ( dol_trunc($accountingaccount->label, 32)) . '"' . $sep; + //print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; } } - + // VAT foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("VAT") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - '. $langs->trans("VAT") . '"' . $sep; + //print '"' . $langs->trans("VAT") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print "\n"; @@ -398,11 +402,11 @@ if ($action == 'export_csv') { } } } else { - + $form = new Form($db); - + llxHeader('', $langs->trans("SellsJournal")); - + $nom = $langs->trans("SellsJournal"); $nomlink = ''; $periodlink = ''; @@ -415,13 +419,13 @@ if ($action == 'export_csv') { $description .= $langs->trans("DepositsAreIncluded"); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( - 'action' => '' + 'action' => '' )); - + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -451,20 +455,20 @@ if ($action == 'export_csv') { print ""; print ""; print "\n"; - + $var = true; $r = ''; - + $invoicestatic = new Facture($db); $companystatic = new Client($db); - + foreach ( $tabfac as $key => $val ) { $invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; $invoicestatic->type = $val["type"]; - + $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Third party foreach ( $tabttc[$key] as $k => $mt ) { print ""; @@ -474,30 +478,32 @@ if ($action == 'export_csv') { $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; print ""; print ""; print ""; } print ""; - + // Product / Service foreach ( $tabht[$key] as $k => $mt ) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k); - + if ($mt) { print ""; print ""; print ""; print ""; - print ""; + //print ""; + print ""; print ""; print ""; print ""; } } - + // VAT foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -505,18 +511,19 @@ if ($action == 'export_csv') { print ""; print ""; print ""; - print ""; + print ""; + //print ""; print ""; print ""; print ""; } } - + $var = ! $var; } - + print "
" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . length_accounta($k); - print "" . $langs->trans("ThirdParty"); - print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; + //print "" . $langs->trans("ThirdParty"); + //print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; + print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref_client . ' - ' . $langs->trans("Code_tiers"). "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $accountingaccount->label . "" . $accountingaccount->label . "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref_client . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)) . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . length_accountg($k) . "" . $langs->trans("VAT") . "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref_client .' - '. $langs->trans("VAT") . "" . $langs->trans("VAT") . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 788eaa32e88..ade361fdd51 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -217,7 +217,7 @@ if ($result) { print ''; print ''; print ''; - print '%'; + print '%'; print ''; print ' '; print ''; @@ -233,7 +233,7 @@ if ($result) { while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; - $codeCompta = $objp->account_number . ' ' . $objp->label; + $codeCompta = $objp->account_number . ' - ' . $objp->label; print ""; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index e0f0c390a02..f1b82c9be21 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/accountancy/supplier/list.php - * \ingroup Accountancy - * \brief Ventilation page from suppliers invoices + * \file htdocs/accountancy/supplier/list.php + * \ingroup Advanced accountancy + * \brief Ventilation page from suppliers invoices */ require '../../main.inc.php'; @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; // Langs $langs->load("compta"); @@ -128,36 +129,39 @@ print ''; + '; + /* * Action */ - if ($action == 'ventil' && ! empty($btn_ventil)) { print '
' . $langs->trans("Processing") . '...
'; if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) { print '
' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '
'; $mesCodesVentilChoisis = $codeventil; $cpt = 0; - + foreach ( $mesCasesCochees as $maLigneCochee ) { // print '
id selectionnee : '.$monChoix."
"; $maLigneCourante = explode("_", $maLigneCochee); $monId = $maLigneCourante[0]; $monNumLigne = $maLigneCourante[1]; $monCompte = $mesCodesVentilChoisis[$monNumLigne]; - + $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " SET fk_code_ventilation = " . $monCompte; $sql .= " WHERE rowid = " . $monId; - + + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); + dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG); if ($db->query($sql)) { - print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '
'; + print '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
'; } else { - print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '
' . $sql . '
'; + print '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
' . $sql . '
'; } - + $cpt ++; } } else { @@ -169,7 +173,6 @@ if ($action == 'ventil' && ! empty($btn_ventil)) { /* * Supplier Invoice Lines */ - if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { @@ -226,15 +229,15 @@ $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); $i = 0; - + // TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list... print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - + print '
' . $langs->trans("DescVentilTodoCustomer") . '
'; - + print '
' . "\n"; print ''; - + print ''; print ''; print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); @@ -248,14 +251,14 @@ if ($result) { print_liste_field_titre(''); print_liste_field_titre($langs->trans("Ventilate") . '
/', '', '', '', '', 'align="center"'); print "\n"; - + print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; - + $facturefourn_static = new FactureFournisseur($db); $productfourn_static = new ProductFournisseur($db); $form = new Form($db); - + $var = True; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $var = ! $var; - + // product_type: 0 = service ? 1 = product // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! @@ -281,9 +284,9 @@ if ($result) { $objp->code_buy_p = ''; $objp->aarowid_suggest = ''; $code_buy_p_l_differ = ''; - + $code_buy_p_notset = ''; - + $objp->aarowid_suggest = $objp->aarowid; if (! empty($objp->code_buy)) { $objp->code_buy_p = $objp->code_buy; @@ -297,7 +300,7 @@ if ($result) { $objp->code_buy_p = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); } } - + if ($objp->type_l == 1) { $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); if ($objp->aarowid == '') @@ -307,17 +310,17 @@ if ($result) { if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_p; } - + if ($objp->code_buy_l != $objp->code_buy_p) $code_buy_p_l_differ = 'color:red'; print ""; - + // Ref Invoice $facturefourn_static->ref = $objp->ref; $facturefourn_static->id = $objp->facid; print ''; - + // Ref Supplier Invoice $productfourn_static->ref = $objp->product_ref; $productfourn_static->id = $objp->product_id; @@ -328,23 +331,23 @@ if ($result) { else print ' '; print ''; - + print ''; - + // TODO: we should set a user defined value to adjust user square / wide screen size $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; print ''; - + print ''; - + if ($objp->vat_tx_l != $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; print ''; - + print ''; - + // Colonne choix du compte print ''; - + print ""; $i ++; } - + print '
%%  '; @@ -264,16 +267,16 @@ if ($result) { print ''; print '
' . $facturefourn_static->getNomUrl(1) . '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, $trunclength)) . ''; print price($objp->price); print ''; print price($objp->tva_tx_line); print ''; // if not same kind of product_type stored in product & facturedt we display both account and let user choose if ($objp->code_buy_l == $objp->code_buy_p) { @@ -353,7 +356,7 @@ if ($result) { print 'lines=' . $objp->code_buy_l . '
product=' . $objp->code_buy_p; } print '
'; print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1); @@ -363,11 +366,11 @@ if ($result) { print ''; print 'aarowid ? "checked" : "") . '/>'; print '
'; print '
'; print '
'; diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 0ef1f4bd62b..8515dc1d2c8 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -141,7 +141,7 @@ if (count($listofsearchfields)) { if ($i == 0) print ''.$langs->trans("Search").''; print ''; - print ':'; + print ':'; if ($i == 0) print ''; print ''; $i++; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ce5abc27416..8ee8b791303 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -405,7 +405,7 @@ $tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[23] = array(); $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[25] = array('type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); +$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); $tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newByMonth'=>$langs->trans("NbAddedAutomatically")); @@ -493,7 +493,7 @@ if ($id == 11) } if ($id == 25) { - // We save list of template type Dolibarr can manage. This list can found by a grep into code on "->param['models']" + // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']" $elementList = array(); if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal'); if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder'); @@ -1017,8 +1017,18 @@ if ($id) } print ''; print ""; + + if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates') + { + print '* '.$langs->trans("AvailableVariables").": "; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail=new FormMail($db); + $tmp=$formmail->getAvailableSubstitKey('form'); + print join(', ', $tmp); + print ''; + } - $colspan=count($fieldlist)+2; + $colspan=count($fieldlist)+3; if ($id == 4) $colspan++; if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of * @@ -1583,7 +1593,9 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') if ($context != 'hide') { //print ''; - $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); + $okforextended=true; + if ($tabname == MAIN_DB_PREFIX.'c_email_templates' && empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended=false; + $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_5, '90%'); print $doleditor->Create(1); } else print ' '; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 727e9904fef..5265f73e595 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -102,7 +102,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $listofsearchfields['search_contract']=array('text'=>'Contrat'); } -// Search contract +// Search supplier proposal if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { $listofsearchfields['search_supplier_proposal']=array('text'=>'SupplierProposalShort'); @@ -118,8 +118,8 @@ if (count($listofsearchfields)) { if ($i == 0) print ''.$langs->trans("Search").''; print ''; - print ':'; - if ($i == 0) print ''; + print ':'; + if ($i == 0) print ''; print ''; $i++; } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b5f33b5f689..9a7d0349f41 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("mails"); @@ -55,27 +56,7 @@ $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $hookmanager->initHooks(array('mailingcard','globalcard')); // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) -$object->substitutionarray=array( - '__ID__' => 'IdRecord', - '__EMAIL__' => 'EMail', - '__LASTNAME__' => 'Lastname', - '__FIRSTNAME__' => 'Firstname', - '__MAILTOEMAIL__' => 'TagMailtoEmail', - '__OTHER1__' => 'Other1', - '__OTHER2__' => 'Other2', - '__OTHER3__' => 'Other3', - '__OTHER4__' => 'Other4', - '__OTHER5__' => 'Other5', - '__SIGNATURE__' => 'TagSignature', - '__CHECK_READ__' => 'TagCheckMail', - '__UNSUBSCRIBE__' => 'TagUnsubscribe' - //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet -); -if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) -{ - $object->substitutionarray['__SECUREKEYPAYPAL__']='SecureKeyPaypal'; - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $object->substitutionarray['__SECUREKEYPAYPAL_MEMBER__']='SecureKeyPaypalUniquePerMember'; -} +$object->substitutionarray=FormMail::getAvailableSubstitKey('emailing'); $object->substitutionarrayfortest=array( '__ID__' => 'TESTIdRecord', @@ -243,8 +224,18 @@ if (empty($reshook)) if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); + + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'order' . $obj->source_id, 2); + + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); + + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); } $substitutionisok=true; complete_substitutions_array($substitutionarray, $langs); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 7d85567f480..40a654fef0b 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1044,6 +1044,19 @@ if (empty($reshook)) unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { $db->rollback(); @@ -2432,13 +2445,8 @@ if ($action == 'create') $formmail->withcancel = 1; // Tableau des substitutions + $formmail->setSubstitFromObject($object); $formmail->substit['__PROPREF__'] = $object->ref; - $formmail->substit['__SIGNATURE__'] = $user->signature; - $formmail->substit['__REFCLIENT__'] = $object->ref_client; - $formmail->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name; - $formmail->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); - $formmail->substit['__PERSONALIZED__'] = ''; - $formmail->substit['__CONTACTCIVNAME__'] = ''; // Find the good contact adress $custcontact = ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7905af12030..4242a23823c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -182,7 +182,7 @@ class Propal extends CommonObject */ const STATUS_NOTSIGNED = 3; /** - * Billed quote + * Billed or processed quote */ const STATUS_BILLED = 4; @@ -2565,7 +2565,7 @@ class Propal extends CommonObject if ($mode == 'signed') { $delay_warning=$conf->propal->facturation->warning_delay; $statut = self::STATUS_SIGNED; - $label = $langs->trans("PropalsToBill"); + $label = $langs->trans("PropalsToBill"); // We set here bill but may be billed or ordered } $response = new WorkboardResponse(); @@ -2675,7 +2675,7 @@ class Propal extends CommonObject $line->remise_percent=00; } - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; $this->lines[$xnbp]=$line; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index e63e3b9a5dc..c37a9bb1b33 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -969,6 +969,19 @@ if (empty($reshook)) unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -1308,6 +1321,7 @@ if ($action == 'create' && $user->rights->commande->creer) $projectid = 0; $remise_absolue = 0; + $currency_code = $conf->currency; if (! empty($origin) && ! empty($originid)) { @@ -1320,7 +1334,7 @@ if ($action == 'create' && $user->rights->commande->creer) if ($element == 'project') { $projectid = $originid; - + if (!$cond_reglement_id) { $cond_reglement_id = $soc->cond_reglement_id; } @@ -1656,7 +1670,7 @@ if ($action == 'create' && $user->rights->commande->creer) default: $newclassname = $classname; } - + print '' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . ''; print '' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . ''; print '' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . ""; @@ -1918,7 +1932,7 @@ if ($action == 'create' && $user->rights->commande->creer) /* * Commande - */ + */ $nbrow = 9; if (! empty($conf->projet->enabled)) $nbrow ++; @@ -2037,6 +2051,9 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print $object->date ? dol_print_date($object->date, 'daytext') : ' '; + if ($object->hasDelay() && empty($object->date_livraison)) { + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + } } print ''; print ''; @@ -2059,6 +2076,9 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : ' '; + if ($object->hasDelay() && ! empty($object->date_livraison)) { + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + } } print ''; print ''; @@ -2586,6 +2606,7 @@ if ($action == 'create' && $user->rights->commande->creer) $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; // Define output language @@ -2654,13 +2675,8 @@ if ($action == 'create' && $user->rights->commande->creer) $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; // Tableau des substitutions + $formmail->setSubstitFromObject($object); $formmail->substit ['__ORDERREF__'] = $object->ref; - $formmail->substit ['__SIGNATURE__'] = $user->signature; - $formmail->substit ['__REFCLIENT__'] = $object->ref_client; - $formmail->substit ['__THIRDPARTY_NAME__'] = $object->thirdparty->name; - $formmail->substit ['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); - $formmail->substit ['__PERSONALIZED__'] = ''; - $formmail->substit ['__CONTACTCIVNAME__'] = ''; $custcontact = ''; $contactarr = array(); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 8f8edcf15a3..9eb31ebd608 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -140,10 +140,6 @@ class Commande extends CommonOrder */ var $lines = array(); - // Pour board - var $nbtodo; - var $nbtodolate; - // Multicurrency var $fk_multicurrency; var $multicurrency_code; @@ -3224,7 +3220,7 @@ class Commande extends CommonOrder $line->total_tva=19.6; $line->remise_percent=0; } - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; $this->lines[$xnbp]=$line; @@ -3436,6 +3432,22 @@ class Commande extends CommonOrder return max($this->date_commande, $this->date_livraison) < ($now - $conf->commande->client->warning_delay); } + + /** + * Show the customer delayed info + * + * @return string Show delayed information + */ + public function showDelay() + { + global $conf, $langs; + + if (empty($this->date_livraison)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day'); + else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day'); + $text.=' '.($conf->commande->client->warning_delay>0?'+':'-').' '.round(abs($conf->commande->client->warning_delay)/3600/24,1).' '.$langs->trans("days").' < '.$langs->trans("Today"); + + return $text; + } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e5f8a62acb5..91a602c31a6 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -554,7 +554,7 @@ if ($resql) // Warning late icon print ''; if ($generic_commande->hasDelay()) { - print img_picto($langs->trans("Late"), "warning"); + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); } if(!empty($objp->note_private)) { diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index aeafb1ee67b..ebb9bedca2c 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -622,8 +622,10 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) //SEARCH BUTTON print ''; print ''; - + print ''; + //ALL/NONE + print ''; if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; print ''; @@ -697,7 +699,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) /* * Boutons actions */ - print '
'.$langs->trans("CloseProcessedOrdersAutomatically"); + print '
global->INVOICE_CLOSE_ORDERS_OFF_BY_DEFAULT_FORMASSINVOICE)?' checked="checked"':'').' name="autocloseorders"> '.$langs->trans("CloseProcessedOrdersAutomatically"); print '
'; print ''; print ''; diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 0973ece78d3..b1bf6cd4270 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2012-2014 Marcos García + * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2011-2015 Alexandre Spangaro * Copyright (C) 2015 Florian Henry * @@ -209,29 +209,13 @@ if ($id > 0 || ! empty($ref)) $result=$object->fetch($id, $ref); - // Chargement des categories bancaires dans $options - $nbcategories=0; + // Load bank groups + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; + $bankcateg = new BankCateg($db); + $options = array(); - $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " ORDER BY label"; - - $result = $db->query($sql); - if ($result) - { - $var=True; - $num = $db->num_rows($result); - $i = 0; - $options = ''; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $options.= ''."\n"; - $nbcategories++; - $i++; - } - $db->free($result); + foreach ($bankcateg->fetchAll() as $bankcategory) { + $options[$bankcategory->id] = $bankcategory->label; } // Definition de sql_rech et param @@ -397,15 +381,11 @@ if ($id > 0 || ! empty($ref)) } } - if ($object->type != 2 && $object->rappro) - { + if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate - if ($user->rights->banque->consolidate) - { - print ''.$langs->trans("Conciliate").''; - } - else - { + if ($user->rights->banque->consolidate) { + print ''.$langs->trans("Conciliate").''; + } else { print ''.$langs->trans("Conciliate").''; } } @@ -489,14 +469,14 @@ if ($id > 0 || ! empty($ref)) $form->select_date($dateop,'op',0,0,0,'transaction'); print ''; print ''; - $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == 2 ? 'LIQ' : '')),'operation','1,2',2,1); + $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); print ''; print ''; print ''; print ''; - if ($nbcategories) - { - print '
'.$langs->trans("Rubrique").': '; + if ($options) { + print '
'.$langs->trans("Rubrique").': '; + print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); } print ''; print ''; @@ -529,8 +509,11 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("Credit").''; print ''.$langs->trans("BankBalance").''; print ''; - if ($object->type != 2 && $object->rappro) print $langs->trans("AccountStatementShort"); - else print ' '; + if ($object->canBeConciliated() > 0) { + print $langs->trans("AccountStatementShort"); + } else { + print ' '; + } print ''; print '
'; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index cccf16f0467..b33b0438552 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -286,13 +286,13 @@ if ($action == 'create') // Type print ''.$langs->trans("AccountType").''; print ''; - $formbank->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type"); + $formbank->selectTypeOfBankAccount(isset($_POST["type"])?$_POST["type"]:1,"type"); print ''; // Currency print ''.$langs->trans("Currency").''; print ''; - $selectedcode=$account->account_currency_code; + $selectedcode=$account->currency_code; if (! $selectedcode) $selectedcode=$conf->currency; print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); @@ -302,7 +302,7 @@ if ($action == 'create') // Status print ''.$langs->trans("Status").''; print ''; - print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); + print $form->selectarray("clos", $account->status,(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print ''; // Country @@ -369,10 +369,10 @@ if ($action == 'create') print ''; print ''.$langs->trans("BalanceMinimalAllowed").''; - print 'account_min_allowed).'">'; + print 'min_allowed).'">'; print ''.$langs->trans("BalanceMinimalDesired").''; - print 'account_min_desired).'">'; + print 'min_desired).'">'; print ''; print '
'; @@ -583,7 +583,7 @@ else // Currency print ''.$langs->trans("Currency").''; print ''; - $selectedcode=$account->account_currency_code; + $selectedcode=$account->currency_code; if (! $selectedcode) $selectedcode=$conf->currency; print $langs->trans("Currency".$selectedcode); print ''; @@ -643,7 +643,7 @@ else print '
'; - if ($account->type == 0 || $account->type == 1) + if ($account->type == Account::TYPE_SAVINGS || $account->type == Account::TYPE_CURRENT) { print ''; @@ -843,7 +843,7 @@ else // Type print ''; print ''; // Currency @@ -851,7 +851,7 @@ else print ''; print ''; print ''; print ''; // Country @@ -895,7 +895,7 @@ else $conciliate=$account->canBeConciliated(); if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')'; - else print 'rappro?'':' checked').'"> '.$langs->trans("DisableConciliation"); + else print ' 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation"); print ''; // Balance diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 1d9da7f9f59..48e8e738fef 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Charles-Fr BENKE * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García * * 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 @@ -27,6 +28,7 @@ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -36,70 +38,39 @@ $action=GETPOST('action'); if (!$user->rights->banque->configurer) accessforbidden(); - +$bankcateg = new BankCateg($db); +$categid = GETPOST('categid'); +$label = GETPOST("label"); /* * Add category */ if (GETPOST('add')) { - if (GETPOST("label")) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; - $sql.= "label"; - $sql.= ", entity"; - $sql.= ") VALUES ("; - $sql.= "'".$db->escape(GETPOST("label"))."'"; - $sql.= ", ".$conf->entity; - $sql.= ")"; - - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + if ($label) { + $bankcateg = new BankCateg($db); + $bankcateg->label = GETPOST('label'); + $bankcateg->create($user); } } -/* - * Update category - */ -if (GETPOST('update')) -{ - if (GETPOST("label")) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ "; - $sql.= "set label='".$db->escape(GETPOST("label"))."'"; - $sql.= " WHERE rowid = '".GETPOST('categid')."'"; - $sql.= " AND entity = ".$conf->entity; +if ($categid) { + $bankcateg = new BankCateg($db); - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); + if ($bankcateg->fetch($categid) > 0) { + + //Update category + if (GETPOST('update') && $label) { + + $bankcateg->label = $label; + $bankcateg->update($user); + } + //Delete category + if ($action == 'delete') { + $bankcateg->delete($user); } } } -/* -* Action suppression catégorie -*/ -if ($action == 'delete') -{ - if (GETPOST('categid')) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE rowid = '".GETPOST('categid')."'"; - $sql.= " AND entity = ".$conf->entity; - - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } - } -} - - /* * View @@ -174,5 +145,3 @@ if ($action != 'edit') print '
'.$langs->trans("AccountType").''; - $formbank->select_type_comptes_financiers((isset($_POST["type"])?$_POST["type"]:$account->type),"type"); + $formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$account->type),"type"); print '
'; - $selectedcode=$account->account_currency_code; + $selectedcode=$account->currency_code; if (! $selectedcode) $selectedcode=$conf->currency; print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); @@ -861,7 +861,7 @@ else // Status print '
'.$langs->trans("Status").''; - print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); + print $form->selectarray("clos", $account->status,(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print '
'; llxFooter(); - -$db->close(); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index a5e108a2c96..bad817d7a21 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -139,7 +139,19 @@ class Account extends CommonObject public $state_code; public $state; - public $type_lib=array(); + /** + * Variable containing all account types with their respective translated label. + * Defined in __construct + * @var array + */ + public $type_lib = array(); + + /** + * Variable containing all account statuses with their respective translated label. + * Defined in __construct + * @var array + */ + public $status = array(); /** * Accountancy code @@ -154,6 +166,13 @@ class Account extends CommonObject */ public $currency_code; + /** + * Currency code + * @var string + * @deprecated Use currency_code instead + */ + public $account_currency_code; + /** * Authorized minimum balance * @var float @@ -205,7 +224,6 @@ class Account extends CommonObject $this->db = $db; - $this->clos = 0; $this->solde = 0; $this->type_lib = array( @@ -231,7 +249,7 @@ class Account extends CommonObject global $conf; if (empty($this->rappro)) return -1; - if ($this->courant == 2 && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) return -2; + if ($this->courant == Account::TYPE_CASH && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) return -2; if ($this->clos) return -3; return 1; } @@ -347,7 +365,7 @@ class Account extends CommonObject * @param string $banque Bank of cheque writer * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, $user, $emetteur='',$banque='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='') { // Deprecatîon warning if (is_numeric($oper)) { @@ -388,7 +406,7 @@ class Account extends CommonObject $this->error="this->rowid not defined"; return -2; } - if ($this->courant == 2 && $oper != 'LIQ') + if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ') { $this->error="ErrorCashAccountAcceptsOnlyCashMoney"; return -3; @@ -398,63 +416,55 @@ class Account extends CommonObject $datev = $date; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank ("; - $sql.= "datec"; - $sql.= ", dateo"; - $sql.= ", datev"; - $sql.= ", label"; - $sql.= ", amount"; - $sql.= ", fk_user_author"; - $sql.= ", num_chq"; - $sql.= ", fk_account"; - $sql.= ", fk_type"; - $sql.= ",emetteur,banque"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", '".$this->db->idate($date)."'"; - $sql.= ", '".$this->db->idate($datev)."'"; - $sql.= ", '".$this->db->escape($label)."'"; - $sql.= ", ".price2num($amount); - $sql.= ", '".$user->id."'"; - $sql.= ", ".($num_chq?"'".$num_chq."'":"null"); - $sql.= ", '".$this->rowid."'"; - $sql.= ", '".$oper."'"; - $sql.= ", ".($emetteur?"'".$this->db->escape($emetteur)."'":"null"); - $sql.= ", ".($banque?"'".$this->db->escape($banque)."'":"null"); - $sql.= ")"; + $accline = new AccountLine($this->db); + $accline->datec = $now; + $accline->dateo = $date; + $accline->datev = $datev; + $accline->label = $label; + $accline->amount = $amount; + $accline->fk_user_author = $user->id; + $accline->fk_account = $this->rowid; + $accline->fk_type = $oper; - dol_syslog(get_class($this)."::addline", LOG_DEBUG); - if ($this->db->query($sql)) - { - $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank"); - if ($categorie) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; - $sql.= "lineid"; - $sql.= ", fk_categ"; - $sql.= ") VALUES ("; - $sql.= "'".$rowid."'"; - $sql.= ", '".$categorie."'"; - $sql.= ")"; + if ($num_chq) { + $accline->num_chq = $num_chq; + } - $result = $this->db->query($sql); - if (! $result) - { - $this->db->rollback(); - $this->error=$this->db->error(); - return -3; - } - } - $this->db->commit(); - return $rowid; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -2; - } - } + if ($emetteur) { + $accline->emetteur = $emetteur; + } + + if ($banque) { + $accline->bank_chq = $banque; + } + + if ($accline->insert() > 0) { + + if ($categorie) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; + $sql .= "lineid"; + $sql .= ", fk_categ"; + $sql .= ") VALUES ("; + $sql .= "'".$accline->id."'"; + $sql .= ", '".$categorie."'"; + $sql .= ")"; + + $result = $this->db->query($sql); + if (!$result) { + $this->db->rollback(); + $this->error = $this->db->error(); + return -3; + } + } + + $this->db->commit(); + return $accline->id; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -2; + } + } /** * Create bank account into database @@ -462,7 +472,7 @@ class Account extends CommonObject * @param User $user Object user making creation * @return int < 0 if KO, > 0 if OK */ - function create($user='') + function create(User $user = null) { global $langs,$conf, $hookmanager; @@ -556,32 +566,18 @@ class Account extends CommonObject $result=$this->update(); if ($result > 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank ("; - $sql.= "datec"; - $sql.= ", label"; - $sql.= ", amount"; - $sql.= ", fk_account"; - $sql.= ", datev"; - $sql.= ", dateo"; - $sql.= ", fk_type"; - $sql.= ", rappro"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", '(".$langs->trans("InitialBankBalance").")'"; - $sql.= ", ".price2num($this->solde); - $sql.= ", '".$this->id."'"; - $sql.= ", '".$this->db->idate($this->date_solde)."'"; - $sql.= ", '".$this->db->idate($this->date_solde)."'"; - $sql.= ", 'SOLD'"; - $sql.= ", 0"; // Not conciliated by default - $sql.= ")"; + $accline = new AccountLine($this->db); + $accline->datec = $this->db->idate($now); + $accline->label = '('.$langs->trans("InitialBankBalance").')'; + $accline->amount = price2num($this->solde); + $accline->fk_account = $this->id; + $accline->datev = $this->db->idate($this->date_solde); + $accline->dateo = $this->db->idate($this->date_solde); + $accline->fk_type = 'SOLD'; - $resql=$this->db->query($sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - return -3; - } + if ($accline->insert() < 0) { + return -3; + } // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('bankdao')); @@ -622,7 +618,7 @@ class Account extends CommonObject * @param User $user Object user making action * @return int <0 si ko, >0 si ok */ - function update($user='') + function update(User $user = null) { global $langs,$conf, $hookmanager; @@ -720,7 +716,7 @@ class Account extends CommonObject * @param User $user Object user making update * @return int <0 if KO, >0 if OK */ - function update_bban($user='') + function update_bban(User $user = null) { global $conf,$langs; @@ -812,7 +808,7 @@ class Account extends CommonObject $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - $this->rowid = $obj->rowid; // deprecated + $this->rowid = $obj->rowid; $this->ref = $obj->ref; $this->label = $obj->label; $this->type = $obj->courant; @@ -878,7 +874,7 @@ class Account extends CommonObject * @param User $user User deleting * @return int <0 if KO, >0 if OK */ - function delete($user='') + function delete(User $user = null) { global $conf; @@ -928,42 +924,32 @@ class Account extends CommonObject * @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 Libelle du statut */ - function LibStatut($statut,$mode=0) - { - global $langs; - $langs->load('banks'); + function LibStatut($statut, $mode = 0) + { + global $langs; + $langs->load('banks'); - if ($mode == 0) - { - if ($statut==0) return $langs->trans("StatusAccountOpened"); - if ($statut==1) return $langs->trans("StatusAccountClosed"); - } - if ($mode == 1) - { - if ($statut==0) return $langs->trans("StatusAccountOpened"); - if ($statut==1) return $langs->trans("StatusAccountClosed"); - } - if ($mode == 2) - { - if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4').' '.$langs->trans("StatusAccountOpened"); - if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5').' '.$langs->trans("StatusAccountClosed"); - } - if ($mode == 3) - { - if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4'); - if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5'); - } - if ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans("StatusAccountOpened"),'statut4').' '.$langs->trans("StatusAccountOpened"); - if ($statut==1) return img_picto($langs->trans("StatusAccountClosed"),'statut5').' '.$langs->trans("StatusAccountClosed"); - } - if ($mode == 5) - { - if ($statut==0) return $langs->trans("StatusAccountOpened").' '.img_picto($langs->trans("StatusAccountOpened"),'statut4'); - if ($statut==1) return $langs->trans("StatusAccountClosed").' '.img_picto($langs->trans("StatusAccountClosed"),'statut5'); - } - } + if ($statut == self::STATUS_OPEN) { + $label = $langs->trans("StatusAccountOpened"); + $picto = img_picto($label, 'statut4'); + } else { + $label = $langs->trans("StatusAccountClosed"); + $picto = img_picto($label, 'statut5'); + } + + if ($mode == 2) { + return $picto.' '.$label; + } elseif ($mode == 3) { + return $picto; + } elseif ($mode == 4) { + return $picto.' '.$label; + } elseif ($mode == 5) { + return $label.' '.$picto; + } + + //There is no short mode for this label + return $label; + } /** @@ -1034,7 +1020,7 @@ class Account extends CommonObject * @param int $filteraccountid To get info for a particular account id * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user,$filteraccountid=0) + function load_board(User $user, $filteraccountid = 0) { global $conf, $langs; @@ -1082,6 +1068,34 @@ class Account extends CommonObject } + /** + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @return int Nb of account we can reconciliate + */ + public static function countAccountToReconcile() + { + global $db, $conf, $langs; + + if ($user->societe_id) return 0; // protection pour eviter appel par utilisateur externe + + $nb=0; + + $sql = "SELECT COUNT(ba.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; + $sql.= " WHERE ba.rappro > 0 and ba.clos = 0"; + if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $nb = $obj->nb; + } + else dol_print_error($db); + + return $nb; + } + /** * Return clicable name (with picto eventually) * @@ -1229,8 +1243,8 @@ class Account extends CommonObject $this->ref = 'MBA'; $this->label = 'My Bank account'; $this->bank = 'MyBank'; - $this->courant = 1; - $this->clos = 0; + $this->courant = Account::TYPE_CURRENT; + $this->clos = Account::STATUS_OPEN; $this->code_banque = '123'; $this->code_guichet = '456'; $this->number = 'ABC12345'; @@ -1280,13 +1294,14 @@ class AccountLine extends CommonObject var $fk_account; // Id of bank account var $bank_account_label; // Label of bank account + public $emetteur; /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + function __construct(DoliDB $db) { $this->db = $db; } @@ -1348,7 +1363,7 @@ class AccountLine extends CommonObject $this->num_releve = $obj->num_releve; $this->num_chq = $obj->num_chq; - $this->bank_chq = $obj->bank_chq; + $this->bank_chq = $obj->banque; $this->fk_bordereau = $obj->fk_bordereau; $this->fk_account = $obj->fk_account; @@ -1366,6 +1381,52 @@ class AccountLine extends CommonObject } } + /** + * Inserts a transaction to a bank account + * + * @return int <0 if KO, rowid of the line if OK + */ + public function insert() + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank ("; + $sql .= "datec"; + $sql .= ", dateo"; + $sql .= ", datev"; + $sql .= ", label"; + $sql .= ", amount"; + $sql .= ", fk_user_author"; + $sql .= ", num_chq"; + $sql .= ", fk_account"; + $sql .= ", fk_type"; + $sql .= ",emetteur,banque"; + $sql .= ", rappro"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($this->datec)."'"; + $sql .= ", '".$this->db->idate($this->dateo)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", ".price2num($this->amount); + $sql .= ", '".$this->fk_user_author."'"; + $sql .= ", ".($this->num_chq ? "'".$this->num_chq."'" : "null"); + $sql .= ", '".$this->fk_account."'"; + $sql .= ", '".$this->db->escape($this->fk_type)."'"; + $sql .= ", ".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null"); + $sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null"); + $sql .= ", ".(int) $this->rappro; + $sql .= ")"; + + dol_syslog(get_class($this)."::insert", LOG_DEBUG); + $resql = $this->db->query($sql); + + if (!$resql) { + $this->error = $this->db->lasterror(); + return -1; + } + + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'bank'); + + return $this->id; + } /** * Delete transaction bank line record @@ -1373,7 +1434,7 @@ class AccountLine extends CommonObject * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - function delete($user=null) + function delete(User $user = null) { $nbko=0; @@ -1422,7 +1483,7 @@ class AccountLine extends CommonObject * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - function delete_urls($user=null) + function delete_urls(User $user = null) { $nbko=0; @@ -1460,7 +1521,7 @@ class AccountLine extends CommonObject * @param int $notrigger 0=Disable all triggers * @return int <0 if KO, >0 if OK */ - function update($user,$notrigger=0) + function update(User $user, $notrigger = 0) { $this->db->begin(); @@ -1493,7 +1554,7 @@ class AccountLine extends CommonObject * @param int $cat Category id * @return int <0 if KO, >0 if OK */ - function update_conciliation($user,$cat) + function update_conciliation(User $user, $cat) { $this->db->begin(); diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 5004d13caf1..7487e4a9f48 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2009 Regis Houssin + * Copyright (C) 2016 Marcos García * * 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,346 +18,294 @@ */ /** - * \file compta/bank/class/bankcateg.class.php - * \ingroup banque - * \brief This file is CRUD class file (Create/Read/Update/Delete) for bank categories - * \author Laurent Destailleur + * \file compta/bank/class/bankcateg.class.php + * \ingroup bank + * \brief This file is CRUD class file (Create/Read/Update/Delete) for bank categories */ -// Put here all includes required by your class file -//require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - - /** - * Class to manage bank categories + * Class to manage bank categories */ class BankCateg // extends CommonObject { - //public $element='bank_categ'; //!< Id that identify managed objects - //public $table_element='bank_categ'; //!< Name of table without prefix where object is stored + //public $element='bank_categ'; //!< Id that identify managed objects + //public $table_element='bank_categ'; //!< Name of table without prefix where object is stored - var $id; - var $label; + public $id; + public $label; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } - /** - * Create in database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - function create($user, $notrigger=0) - { - global $conf, $langs; - $error=0; + /** + * Create in database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = 0) + { + global $conf; - // Clean parameters - if (isset($this->label)) $this->label=trim($this->label); + $error = 0; - // Check parameters - // Put here code to add control on parameters values + // Clean parameters + if (isset($this->label)) { + $this->label = trim($this->label); + } - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; - $sql.= "label"; - $sql.= ", entity"; - $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").""; - $sql.= ", ".$conf->entity; - $sql.= ")"; + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; + $sql .= "label"; + $sql .= ", entity"; + $sql .= ") VALUES ("; + $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").""; + $sql .= ", ".$conf->entity; + $sql .= ")"; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } - if (! $error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_categ"); + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_categ"); + } - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @return int <0 if KO, >0 if OK - */ - function fetch($id) - { - global $langs,$conf; + /** + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + public function fetch($id) + { + global $conf; - $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as t"; - $sql.= " WHERE t.rowid = ".$id; - $sql.= " AND t.entity = ".$conf->entity; + $sql = "SELECT"; + $sql .= " t.rowid,"; + $sql .= " t.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as t"; + $sql .= " WHERE t.rowid = ".$id; + $sql .= " AND t.entity = ".$conf->entity; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->label = $obj->label; - } - $this->db->free($resql); + $this->id = $obj->rowid; + $this->label = $obj->label; + } + $this->db->free($resql); - return 1; - } - else - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user = null, $notrigger = 0) + { + global $conf; + $error = 0; - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function update($user=null, $notrigger=0) - { - global $conf, $langs; - $error=0; + // Clean parameters + if (isset($this->label)) { + $this->label = trim($this->label); + } - // Clean parameters - if (isset($this->label)) $this->label=trim($this->label); + // Check parameters + // Put here code to add control on parameters values - // Check parameters - // Put here code to add control on parameters values + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ SET"; + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").""; + $sql .= " WHERE rowid=".$this->id; + $sql .= " AND entity = ".$conf->entity; - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ SET"; - $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").""; - $sql.= " WHERE rowid=".$this->id; - $sql.= " AND entity = ".$conf->entity; + $this->db->begin(); - $this->db->begin(); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = 0) + { + global $conf; + $error = 0; - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; + $sql .= " WHERE rowid=".$this->id; + $sql .= " AND entity = ".$conf->entity; - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } + $this->db->begin(); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } - /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - function delete($user, $notrigger=0) - { - global $conf, $langs; - $error=0; + // Commit or rollback + if ($error) { + 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; + } + } - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE rowid=".$this->id; - $sql.= " AND entity = ".$conf->entity; + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromClone($fromid) + { + global $user; - $this->db->begin(); + $error = 0; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - - if (! $error) - { - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } - } - - // Commit or rollback - if ($error) - { - 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; - } - } - - - - /** - * Load an object from its id and create a new one in database - * - * @param int $fromid Id of object to clone - * @return int New id of clone - */ - function createFromClone($fromid) - { - global $user,$langs; - - $error=0; - - $object=new BankCateg($this->db); + $object = new BankCateg($this->db); $object->context['createfromclone'] = 'createfromclone'; $this->db->begin(); - // Load source object - $object->fetch($fromid); - $object->id=0; - $object->statut=0; + // Load source object + $object->fetch($fromid); + $object->id = 0; + $object->statut = 0; - // Clear fields - // ... + // Create clone + $result = $object->create($user); - // Create clone - $result=$object->create($user); + // Other options + if ($result < 0) { + $this->error = $object->error; + $error++; + } - // Other options - if ($result < 0) - { - $this->error=$object->error; - $error++; - } + unset($object->context['createfromclone']); - if (! $error) - { + // End + if (!$error) { + $this->db->commit(); + return $object->id; + } else { + $this->db->rollback(); + return -1; + } + } + /** + * Returns all bank categories + * + * @return BankCateg[] + */ + public function fetchAll() + { + global $conf; + $return = array(); - } + $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ WHERE entity = ".$conf->entity." ORDER BY label"; + $resql = $this->db->query($sql); - unset($object->context['createfromclone']); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $tmp = new BankCateg($this->db); + $tmp->id = $obj->rowid; + $tmp->label = $obj->label; - // End - if (! $error) - { - $this->db->commit(); - return $object->id; - } - else - { - $this->db->rollback(); - return -1; - } - } + $return[] = $tmp; + } + } + return $return; + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - function initAsSpecimen() - { - $this->id=0; - - $this->label=''; - } + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + $this->label = ''; + } } diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 13b65f0baf1..a17614238be 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -6,6 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García * * 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 @@ -102,7 +103,7 @@ if ($user->rights->banque->modifier && $action == "update") $ac = new Account($db); $ac->fetch($id); - if ($ac->courant == 2 && $_POST['value'] != 'LIQ') + if ($ac->courant == Account::TYPE_CASH && $_POST['value'] != 'LIQ') { setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors'); $error++; @@ -205,24 +206,13 @@ $form = new Form($db); llxHeader(); -// The list of categories is initialized -$sql = "SELECT rowid, label"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; -$sql.= " ORDER BY label"; -$result = $db->query($sql); -if ($result) -{ - $var=True; - $num = $db->num_rows($result); - $i = 0; - $options = ""; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $options .= "\n"; - $i++; - } - $db->free($result); +// Load bank groups +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; +$bankcateg = new BankCateg($db); +$options = array(); + +foreach ($bankcateg->fetchAll() as $bankcategory) { + $options[$bankcategory->id] = $bankcategory->label; } $var=false; @@ -620,7 +610,7 @@ print ''; print ''; } print ''; diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 11cd92cdbbc..ec9420b4587 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García * * 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 @@ -111,28 +112,13 @@ if ($action == 'del') } } +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; +$bankcateg = new BankCateg($db); +$options = array(); -// Load bank groups -$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label"; -$resql = $db->query($sql); -$options=""; -if ($resql) -{ - $var=True; - $num = $db->num_rows($resql); - if ($num > 0) $options .= ''; - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $options .= ''."\n"; - $i++; - } - $db->free($resql); - //print $options; +foreach ($bankcateg->fetchAll() as $bankcategory) { + $options[$bankcategory->id] = $bankcategory->label; } -else dol_print_error($db); - /* * View @@ -236,10 +222,11 @@ if ($resql) print ''.$langs->trans("InputReceiptNumber").': '; print ''; // The only default value is value we just entered print '
'; - if ($options) - { - print $langs->trans("EventualyAddCategory").':
'; - } + if ($options) { + print $langs->trans("EventualyAddCategory").': '; + print Form::selectarray('cat', $options, GETPOST('cat'), 1); + print '
'; + } print '
'.$langs->trans("ThenCheckLinesAndConciliate").' "'.$langs->trans("Conciliate").'"
'; print '
'; @@ -440,14 +427,6 @@ if ($resql) print '
"; } else diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 43587cfa6a0..8ef53f26203 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -143,16 +143,12 @@ if (empty($num)) dol_fiche_end(); print '
'; - - if ($object->type != 2 && $object->rappro) - { + + if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate - if ($user->rights->banque->consolidate) - { - print ''.$langs->trans("Conciliate").''; - } - else - { + if ($user->rights->banque->consolidate) { + print ''.$langs->trans("Conciliate").''; + } else { print ''.$langs->trans("Conciliate").''; } } diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php index 1a3294a2f15..146ed4759c4 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/virement.php @@ -93,7 +93,7 @@ if ($action == 'add') // By default, electronic transfert from bank to bank $typefrom='PRE'; $typeto='VIR'; - if ($accountto->courant == 2 || $accountfrom->courant == 2) + if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { // This is transfert of change $typefrom='LIQ'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 2fcdfb7f6a0..7298eb18135 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -783,10 +783,17 @@ if (empty($reshook)) $facture_source = new Facture($db); // fetch origin object if ($facture_source->fetch($object->fk_facture_source)>0) { + $fk_parent_line = 0; foreach($facture_source->lines as $line) { + // Reset fk_parent_line for no child products and special product + if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { + $fk_parent_line = 0; + } + $line->fk_facture = $object->id; + $line->fk_parent_line = $fk_parent_line; $line->subprice =-$line->subprice; // invert price for object $line->pa_ht = -$line->pa_ht; @@ -796,9 +803,14 @@ if (empty($reshook)) $line->total_localtax1=-$line->total_localtax1; $line->total_localtax2=-$line->total_localtax2; - $line->insert(); + $result = $line->insert(); $object->lines[] = $line; // insert new line in current object + + // Defined the new fk_parent_line + if ($result > 0 && $line->product_type == 9) { + $fk_parent_line = $result; + } } $object->update_price(1); @@ -1594,7 +1606,7 @@ if (empty($reshook)) $line = new FactureLigne($db); $line->fetch(GETPOST('lineid')); - $percent = $line->get_prev_progress(); + $percent = $line->get_prev_progress($object->id); if (GETPOST('progress') < $percent) { @@ -1712,7 +1724,7 @@ if (empty($reshook)) { foreach ($object->lines as $line) { - $percent = $line->get_prev_progress(); + $percent = $line->get_prev_progress($object->id); if (GETPOST('all_progress') < $percent) { $mesg = '
' . $langs->trans("CantBeLessThanMinPercent") . '
'; $result = -1; @@ -1911,7 +1923,7 @@ if ($action == 'create') if ($element == 'project') { $projectid = $originid; - + if (!$cond_reglement_id) { $cond_reglement_id = $soc->cond_reglement_id; } @@ -1924,7 +1936,7 @@ if ($action == 'create') if (!$dateinvoice) { // Do not set 0 here (0 for a date is 1970) $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); - } + } } else { // For compatibility if ($element == 'order' || $element == 'commande') { @@ -2667,7 +2679,7 @@ else if ($id > 0 || ! empty($ref)) $qualified_for_stock_change = $object->hasProductsOrServices(1); } - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change && $object->statut >= 1) + if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change && $object->statut >= 1) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; @@ -2858,7 +2870,7 @@ else if ($id > 0 || ! empty($ref)) } // Clone confirmation - if ($action == 'clone') + if ($action == 'clone') { // Create an array for form $formquestion = array( @@ -2869,7 +2881,7 @@ else if ($id > 0 || ! empty($ref)) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('CloneInvoice'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - if (! $formconfirm) + if (! $formconfirm) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -3818,14 +3830,14 @@ else if ($id > 0 || ! empty($ref)) // modified by hook if (empty($reshook)) { // Editer une facture deja validee, sans paiement effectue et pas exporte en compta - if ($object->statut == 1) + if ($object->statut == 1) { // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees $ventilExportCompta = $object->getVentilExportCompta(); - if ($resteapayer == $object->total_ttc && empty($object->paye) && $ventilExportCompta == 0) + if ($resteapayer == $object->total_ttc && empty($object->paye) && $ventilExportCompta == 0) { - if (! $objectidnext) + if (! $objectidnext && $object->is_last_in_cycle()) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))) @@ -4150,14 +4162,8 @@ else if ($id > 0 || ! empty($ref)) $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; // Tableau des substitutions - $formmail->substit['__REF__'] = $object->ref; - $formmail->substit['__SIGNATURE__'] = $user->signature; - $formmail->substit['__REFCLIENT__'] = $object->ref_client; - $formmail->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name; - $formmail->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); - $formmail->substit['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:''); - $formmail->substit['__PERSONALIZED__'] = ''; - $formmail->substit['__CONTACTCIVNAME__'] = ''; + $formmail->setSubstitFromObject($object); + $formmail->substit['__INVREF__'] = $object->ref; // Find the good contact adress $custcontact = ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 95356149622..f5aadddeaf9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3566,7 +3566,7 @@ class Facture extends CommonInvoice $line->remise_percent=0; if ($xnbp == 1) // Qty is negative (product line) { - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; $line->qty=-1; $line->total_ht=-100; @@ -3583,7 +3583,7 @@ class Facture extends CommonInvoice } else if ($xnbp == 3) // Discount is 50% (product line) { - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; $line->total_ht=50; $line->total_ttc=59.8; @@ -3592,7 +3592,7 @@ class Facture extends CommonInvoice } else // (product line) { - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; $line->total_ht=100; $line->total_ttc=119.6; @@ -3621,7 +3621,7 @@ class Facture extends CommonInvoice $line->total_ht=0; $line->total_ttc=0; // 90 * 1.196 $line->total_tva=0; - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; $this->lines[$xnbp]=$line; @@ -4533,15 +4533,22 @@ class FactureLigne extends CommonInvoiceLine } /** - * Returns situation_percent of the previous line + * Returns situation_percent of the previous line. + * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. * - * @return int >= 0 + * @param int $invoiceid Invoice id + * @return int >= 0 */ - function get_prev_progress() + function get_prev_progress($invoiceid) { if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { return 0; } else { + // If invoice is a not a situation invoice, this->fk_prev_id is used for something else + $tmpinvoice=new Facture($this->db); + $tmpinvoice->fetch($invoiceid); + if ($tmpinvoice->type != Facture::TYPE_SITUATION) return 0; + $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) { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 81eeed8a5b9..e833c0629b3 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1027,7 +1027,7 @@ else print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecord,'title_accountancy.png',0,'','',$limit); - print $langs->trans("ToCreateAPredefinedInvoice").'

'; + print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; $i = 0; print '
'.$langs->trans("Rubriques").''; if ($user->rights->banque->modifier) { - print ' '; + print Form::selectarray('cat1', $options, '', 1).' '; print '
'; print 'rowid])?' checked':'').'>'; -// print ''; -// print '   '; -// print "trans("Conciliate")."\">"; -// if ($options) -// { -// print "
"; -// } print "
'; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c7bc789c6f4..d227d127f69 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -61,6 +61,7 @@ $ref=GETPOST('ref','alpha'); $socid=GETPOST('socid','int'); $action=GETPOST('action','alpha'); $massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); $confirm=GETPOST('confirm','alpha'); $lineid=GETPOST('lineid','int'); $userid=GETPOST('userid','int'); @@ -131,7 +132,8 @@ if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } - +if (! GETPOST('confirmmassaction')) { $massaction=''; } + $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -533,8 +535,8 @@ if (empty($reshook)) $upload_dir = $diroutputpdf; $file = $upload_dir . '/' . GETPOST('file'); $ret=dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); $action=''; } @@ -714,6 +716,7 @@ if ($resql) if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; if ($search_status != '') $param.='&search_status='.$search_status; if ($search_paymentmode > 0) $param.='search_paymentmode='.$search_paymentmode; + if ($show_files) $param.='&show_files=' .$show_files; $param.=(! empty($option)?"&option=".$option:""); $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); @@ -1055,7 +1058,7 @@ if ($resql) print "\n"; $db->free($resql); - if ($massaction == 'builddoc' || $action == 'remove_file') + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { /* * Show list of available documents @@ -1067,10 +1070,16 @@ if ($resql) $genallowed=$user->rights->facture->lire; $delallowed=$user->rights->facture->lire; - print '
'; - // We disable multilang because we concat already existing pdf. - $formfile->show_documents('unpaid','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$langs->trans("PDFMerge"),''); - } + print '
'; + $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); + $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; + + $formfile->show_documents('massfilesarea','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
'.$langs->trans("ShowTempMassFilesArea").''; + } } else { diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php deleted file mode 100644 index 043a45a0861..00000000000 --- a/htdocs/compta/facture/mergepdftool.php +++ /dev/null @@ -1,1031 +0,0 @@ - - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2014 Raphaël Doursenaud - * - * 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 . - * - * Note: Page can be call with param mode=sendremind to bring feature to send - * remind by emails. - */ - -/** - * \file htdocs/compta/facture/mergepdftool.php - * \ingroup facture - * \brief Page to list and build doc of selected invoices - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - -$langs->load("mails"); -$langs->load("bills"); - -$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); -$action = GETPOST('action','alpha'); -$option = GETPOST('option'); -$mode=GETPOST('mode'); -$builddoc_generatebutton=GETPOST('builddoc_generatebutton'); -$month = GETPOST("month","int"); -$year = GETPOST("year","int"); -$filter = GETPOST("filtre"); -if (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x')) -{ - $filter=GETPOST('filtre',2); - //if ($filter != 'payed:0') $option=''; -} -if ($option == 'late') $filter = 'paye:0'; -if ($option == 'unpaidall') $filter = 'paye:0'; -if ($mode == 'sendmassremind' && $filter == '') $filter = 'paye:0'; -if ($filter == '') $filter = 'paye:0'; - -$search_user = GETPOST('search_user','int'); -$search_sale = GETPOST('search_sale','int'); - -// Security check -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user,'facture',$id,''); - -$diroutputpdf=$conf->facture->dir_output . '/unpaid/temp'; -if (! $user->rights->societe->client->voir || $socid) $diroutputpdf.='/private/'.$user->id; // If user has no permission to see all, output dir is specific to user - -$resultmasssend=''; -if (GETPOST('buttonsendremind')) -{ - $action='presend'; - $mode='sendmassremind'; -} - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test must be present to be compatible with all browsers -{ - $search_ref=""; - $search_ref_supplier=""; - $search_user = ""; - $search_sale = ""; - $search_label=""; - $search_company=""; - $search_amount_no_tax=""; - $search_amount_all_tax=""; - $year=""; - $month=""; - $filter=""; - $option=""; -} - - - -/* - * Action - */ - -// Send remind email -if ($action == 'presend' && GETPOST('cancel')) -{ - $action=''; - if (GETPOST('models')=='facture_relance') $mode='sendmassremind'; // If we made a cancel from submit email form, this means we must be into mode=sendmassremind -} - -if ($action == 'presend' && GETPOST('sendmail')) -{ - if (GETPOST('models')=='facture_relance') $mode='sendmassremind'; // If we made a cancel from submit email form, this means we must be into mode=sendmassremind - - if (!isset($user->email)) - { - $error++; - setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); - } - - $countToSend = count($_POST['toSend']); - if (empty($countToSend)) - { - $error++; - setEventMessages($langs->trans("InvoiceNotChecked"), null, 'warnings'); - } - - if (! $error) - { - $nbsent = 0; - $nbignored = 0; - - $arrayofinvoices=GETPOST('toSend','array'); - - $thirdparty=new Societe($db); - $invoicetmp=new Facture($db); - $listofinvoicesid=array(); - $listofinvoicesthirdparties=array(); - $listofinvoicesref=array(); - foreach($arrayofinvoices as $invoiceid) - { - $invoicetmp=new Facture($db); // must create new instance because instance is saved into $listofinvoicesref array for future use - $result=$invoicetmp->fetch($invoiceid); - if ($result > 0) - { - $listoinvoicesid[$invoiceid]=$invoiceid; - $thirdpartyid=$invoicetmp->fk_soc?$invoicetmp->fk_soc:$invoicetmp->socid; - $listofinvoicesthirdparties[$thirdpartyid]=$thirdpartyid; - $listofinvoicesref[$thirdpartyid][$invoiceid]=$invoicetmp; - } - } - //var_dump($listofinvoicesref);exit; - - foreach ($listofinvoicesthirdparties as $thirdpartyid) - { - $result = $thirdparty->fetch($thirdpartyid); - if ($result < 0) - { - dol_print_error($db); - exit; - } - - // Define recipient $sendto and $sendtocc - if (trim($_POST['sendto'])) - { - // Recipient is provided into free text - $sendto = trim($_POST['sendto']); - $sendtoid = 0; - } - elseif ($_POST['receiver'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $thirdparty->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $thirdparty->contact_get_property((int) $_POST['receiver'],'email'); - $sendtoid = $_POST['receiver']; - } - } - if (trim($_POST['sendtocc'])) - { - $sendtocc = trim($_POST['sendtocc']); - } - elseif ($_POST['receivercc'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receivercc'] == 'thirdparty') // Id of third party - { - $sendtocc = $thirdparty->email; - } - else // Id du contact - { - $sendtocc = $thirdparty->contact_get_property((int) $_POST['receivercc'],'email'); - } - } - - //var_dump($listofinvoicesref[$thirdpartyid]); - - $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); - $listofqualifiedinvoice=array(); - $listofqualifiedref=array(); - foreach($listofinvoicesref[$thirdpartyid] as $invoiceid => $invoice) - { - //var_dump($invoice); - $object = $invoice; - //$object = new Facture($db); - //$result = $object->fetch(); - //var_dump($thirdpartyid.' - '.$invoiceid.' - '.$object->statut); - - if ($object->statut != Facture::STATUS_VALIDATED) - { - $nbignored++; - continue; // Payment done or started or canceled - } - - // Read document - // TODO Use future field $object->fullpathdoc to know where is stored default file - // TODO If not defined, use $object->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc. - $filename=dol_sanitizeFileName($object->ref).'.pdf'; - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); - $file = $filedir . '/' . $filename; - $mime = 'application/pdf'; - - if (dol_is_file($file)) - { - if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) - { - $object->fetch_thirdparty(); - $sendto = $object->thirdparty->email; - } - - if (empty($sendto)) - { - $nbignored++; - continue; - } - - if (dol_strlen($sendto)) - { - // Create form object - $attachedfiles=array( - 'paths'=>array_merge($attachedfiles['paths'],array($file)), - 'names'=>array_merge($attachedfiles['names'],array($filename)), - 'mimes'=>array_merge($attachedfiles['mimes'],array($mime)) - ); - } - - $listofqualifiedinvoice[$invoiceid]=$invoice; - $listofqualifiedref[$invoiceid]=$invoice->ref; - } - else - { - $nbignored++; - $langs->load("other"); - $resultmasssend.='
'.$langs->trans('ErrorCantReadFile',$file).'
'; - dol_syslog('Failed to read file: '.$file, LOG_WARNING); - continue; - } - - //var_dump($listofqualifiedref); - } - - if (count($listofqualifiedinvoice) > 0) - { - $langs->load("commercial"); - $from = $user->getFullName($langs) . ' <' . $user->email .'>'; - $replyto = $from; - $subject = GETPOST('subject'); - $message = GETPOST('message'); - $sendtocc = GETPOST('sentocc'); - $sendtobcc = (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)?'':$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO); - - $substitutionarray=array( - '__ID__' => join(', ',array_keys($listofqualifiedinvoice)), - '__EMAIL__' => $thirdparty->email, - '__CHECK_READ__' => '', - //'__LASTNAME__' => $obj2->lastname, - //'__FIRSTNAME__' => $obj2->firstname, - '__FACREF__' => join(', ',$listofqualifiedref), // For backward compatibility - '__REF__' => join(', ',$listofqualifiedref), - '__REFCLIENT__' => $thirdparty->name - ); - - $subject=make_substitutions($subject, $substitutionarray); - $message=make_substitutions($message, $substitutionarray); - - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - //var_dump($filepath); - - // Send mail - require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'); - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1); - if ($mailfile->error) - { - $resultmasssend.='
'.$mailfile->error.'
'; - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - $resultmasssend.=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " - - $error=0; - - foreach($listofqualifiedinvoice as $invid => $object) - { - $actiontypecode='AC_FAC'; - $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; - if ($message) - { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg = dol_concatdesc($actionmsg, $message); - } - - // Initialisation donnees - $object->sendtoid = 0; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; // Long text - $object->actionmsg2 = $actionmsg2; // Short text - $object->fk_element = $invid; - $object->elementtype = $invoice->element; - - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - - if (! $error) - { - $resultmasssend.=$langs->trans("MailSent").': '.$sendto."
\n"; - } - else - { - dol_print_error($db); - } - $nbsent++; - } - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $resultmasssend.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $resultmasssend.='
'.$mailfile->error.'
'; - } - else - { - $resultmasssend.='
No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
'; - } - } - } - } - } - - if ($nbsent) - { - $action=''; // Do not show form post if there was at least one successfull sent - setEventMessages($nbsent. '/'.$countToSend.' '.$langs->trans("RemindSent"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("NoRemindSent"), null, 'warnings'); // May be object has no generated PDF file - } - } -} - - -if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_search') && !empty($builddoc_generatebutton)) -{ - if (is_array($_POST['toGenerate'])) - { - $arrayofinclusion=array(); - foreach($_POST['toGenerate'] as $tmppdf) $arrayofinclusion[]=preg_quote($tmppdf.'.pdf','/'); - $factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true); - - // liste les fichiers - $files = array(); - foreach($_POST['toGenerate'] as $basename) - { - foreach($factures as $facture) - { - if (strstr($facture["name"],$basename)) - { - $files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"]; - } - } - } - - // Define output language (Here it is not used because we do only merging existing PDF) - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - // Create empty PDF - $pdf=pdf_getInstance(); - if (class_exists('TCPDF')) - { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - - // Add all others - foreach($files as $file) - { - // Charge un document PDF depuis un fichier. - $pagecount = $pdf->setSourceFile($file); - for ($i = 1; $i <= $pagecount; $i++) - { - $tplidx = $pdf->importPage($i); - $s = $pdf->getTemplatesize($tplidx); - $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); - $pdf->useTemplate($tplidx); - } - } - - // Create output dir if not exists - dol_mkdir($diroutputpdf); - - // Save merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities("Invoices"))); - if ($filter=='paye:0') - { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); - } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; - if ($pagecount) - { - $now=dol_now(); - $file=$diroutputpdf.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf'; - $pdf->Output($file,'F'); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - - $langs->load("exports"); - setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); - } - } - else - { - setEventMessages($langs->trans('InvoiceNotChecked'), null, 'warnings'); - } -} - -// Remove file -if ($action == 'remove_file') -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $diroutputpdf; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $action=''; -} - - - -/* - * View - */ - -$form = new Form($db); -$formfile = new FormFile($db); -$formother = new FormOther($db); - -$title=$langs->trans("MergingPDFTool"); - -llxHeader('',$title); - -?> - -liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortfield) $sortfield="f.date_lim_reglement"; -if (! $sortorder) $sortorder="ASC"; - -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; - -$sql = "SELECT s.nom as name, s.rowid as socid, s.email"; -$sql.= ", f.rowid as facid, f.facnumber, f.ref_client, f.increment, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp"; -$sql.= ", f.datef as df, f.date_lim_reglement as datelimite"; -$sql.= ", f.paye as paye, f.fk_statut, f.type, f.fk_mode_reglement"; -$sql.= ", sum(pf.amount) as am"; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ",".MAIN_DB_PREFIX."facture as f"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; -// We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -if ($search_user > 0) -{ - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; -} -$sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= " AND f.entity = ".$conf->entity; -$sql.= " AND f.type IN (0,1,3,5)"; -if ($filter == 'paye:0') $sql.= " 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; -if (! empty($socid)) $sql .= " AND s.rowid = ".$socid; -if ($filter && $filter != -1) // GETPOST('filtre') may be a string -{ - $filtrearr = explode(",", $filter); - foreach ($filtrearr as $fil) - { - $filt = explode(":", $fil); - $sql .= " AND " . $filt[0] . " = " . $filt[1]; - } -} -if ($search_ref) $sql .= " AND f.facnumber LIKE '%".$db->escape($search_ref)."%'"; -if ($search_refcustomer) $sql .= " AND f.ref_client LIKE '%".$db->escape($search_refcustomer)."%'"; -if ($search_societe) $sql .= " AND s.nom LIKE '%".$db->escape($search_societe)."%'"; -if ($search_paymentmode) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; -if ($search_montant_ht) $sql .= " AND f.total = '".$db->escape($search_montant_ht)."'"; -if ($search_montant_ttc) $sql .= " AND f.total_ttc = '".$db->escape($search_montant_ttc)."'"; -if (GETPOST('sf_ref')) $sql .= " AND f.facnumber LIKE '%".$db->escape(GETPOST('sf_ref'))."%'"; -if ($month > 0) -{ - if ($year > 0) - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; - else - $sql.= " AND date_format(f.datef, '%m') = '$month'"; -} -else if ($year > 0) -{ - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; -} -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; -if ($search_user > 0) -{ - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; -} -$sql.= " GROUP BY s.nom, s.rowid, s.email, f.rowid, f.facnumber, f.ref_client, f.increment, f.total, f.tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp,"; -$sql.= " f.datef, f.date_lim_reglement, f.paye, f.fk_statut, f.type, f.fk_mode_reglement"; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; -$sql.= " ORDER BY "; -$listfield=explode(',',$sortfield); -foreach ($listfield as $key => $value) $sql.=$listfield[$key]." ".$sortorder.","; -$sql.= " f.facnumber DESC"; -//print $sql; -//$sql .= $db->plimit($limit+1,$offset); - -$resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - - if (! empty($socid)) - { - $soc = new Societe($db); - $soc->fetch($socid); - } - - $param=""; - $param.=(! empty($socid)?"&socid=".$socid:""); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_refcustomer) $param.='&search_ref='.urlencode($search_refcustomer); - if ($search_societe) $param.='&search_societe='.urlencode($search_societe); - if ($search_societe) $param.='&search_paymentmode='.urlencode($search_paymentmode); - if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_ttc) $param.='&search_montant_ttc='.urlencode($search_montant_ttc); - if ($late) $param.='&late='.urlencode($late); - if ($mode) $param.='&mode='.urlencode($mode); - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); - - //$titre=(! empty($socid)?$langs->trans("BillsCustomersUnpaidForCompany",$soc->name):$langs->trans("BillsCustomersUnpaid")); - $titre=(! empty($socid)?$langs->trans("BillsCustomersForCompany",$soc->name):$langs->trans("BillsCustomers")); - if ($option == 'late') $titre.=' ('.$langs->trans("Late").')'; - //else $titre.=' ('.$langs->trans("All").')'; - - $link=''; - //if (empty($option) || $option == 'late') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidAll").''; - //if (empty($option) || $option == 'unpaidall') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidLateOnly").''; - - $param.=(! empty($option)?"&option=".$option:""); - - print load_fiche_titre($titre,$link); - //print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',0); // We don't want pagination on this page - - $arrayofinvoices=GETPOST('toSend','array'); - if ($action == 'presend' && count($arrayofinvoices) == 0 && ! GETPOST('cancel')) - { - setEventMessages($langs->trans("InvoiceNotChecked"), null, 'errors'); - $action='list'; - $mode='sendmassremind'; - } - else - { - $invoicetmp=new Facture($db); - $listofinvoicesid=array(); - $listofinvoicesthirdparties=array(); - $listofinvoicesref=array(); - foreach($arrayofinvoices as $invoiceid) - { - $result=$invoicetmp->fetch($invoiceid); - if ($result > 0) - { - $listofinvoicesid[$invoiceid]=$invoiceid; - $thirdpartyid=$invoicetmp->fk_soc?$invoicetmp->fk_soc:$invoicetmp->socid; - $listofinvoicesthirdparties[$thirdpartyid]=$thirdpartyid; - $listofinvoicesref[$thirdpartyid][$invoiceid]=$invoicetmp->ref; - } - } - } - print '
'; - - if (GETPOST('modelselected')) { - $action = 'presend'; - } - if (! empty($mode) && $action == 'presend') - { - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - dol_fiche_head(null, '', $langs->trans("SendRemind")); - - $topicmail="MailTopicSendRemindUnpaidInvoices"; - $modelmail="facture_relance"; - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->withform=-1; - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set - { - $formmail->trackid='inv'.$object->id; - } - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'inv'.$object->id); - } - $formmail->withfrom=1; - $liste=$langs->trans("AllRecipientSelectedForRemind"); - if (count($listofinvoicesthirdparties) == 1) - { - $liste=array(); - $thirdpartyid=array_shift($listofinvoicesthirdparties); - $soc=new Societe($db); - $soc->fetch($thirdpartyid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $formmail->withtoreadonly=0; - } - else - { - $formmail->withtoreadonly=1; - } - $formmail->withto=$liste; - $formmail->withtofree=0; - $formmail->withtocc=1; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); - $formmail->withfile=$langs->trans("OnlyPDFattachmentSupported"); - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - //$formmail->substit['__REF__']=''; - $formmail->substit['__SIGNATURE__']=$user->signature; - //$formmail->substit['__REFCLIENT__']=''; - $formmail->substit['__PERSONALIZED__']=''; - $formmail->substit['__CONTACTCIVNAME__']=''; - - // Tableau des parametres complementaires du post - $formmail->param['action']=$action; - $formmail->param['models']=$modelmail; - $formmail->param['models_id']=GETPOST('modelmailselected','int'); - $formmail->param['facid']=join(',',$arrayofinvoices); - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - print $formmail->get_form(); - - dol_fiche_end(); - } - - print ''; - print ''; - if ($late) print ''; - - if ($resultmasssend) - { - print '
'.$langs->trans("ResultOfMassSending").':
'."\n"; - print $langs->trans("Selected").': '.$countToSend."\n
"; - print $langs->trans("Ignored").': '.$nbignored."\n
"; - print $langs->trans("Sent").': '.$nbsent."\n
"; - //print $resultmasssend; - print '
'; - } - - $i = 0; - - // If the user can view prospects other than his' - $moreforfilter=''; - if ($user->rights->societe->client->voir || $socid) - { - $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300'); - $moreforfilter.='
'; - } - // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) - { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - $moreforfilter.='
'; - } - if (! empty($moreforfilter)) - { - print '
'; - print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - print '
'; - - print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans('RefCustomer'),$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"f.datef","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"f.date_lim_reglement","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"f.fk_mode_reglement","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),$_SERVER["PHP_SELF"],"f.total","",$param,'align="right"',$sortfield,$sortorder); - 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"],"","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); - print "\n"; - - // Lignes des champs de filtre - print ''; - // Ref - print ''; - print ''; - print ''; - // Late - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - if ($num > 0) - { - $var=true; - $total_ht=0; - $total_tva=0; - $total_ttc=0; - $total_paid=0; - - $facturestatic=new Facture($db); - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $date_limit=$db->jdate($objp->datelimite); - - $var=!$var; - - print ""; - $classname = "impayee"; - - print '\n"; - - // Customer ref - print ''; - - print ''."\n"; - print ''."\n"; - - print ''; - - // Payment mode - print ''; - - - print ''; - print ''; - print ''; - print ''; - - // Remain to receive - print ''; - - // Status of invoice - print ''; - - if (empty($mode)) - { - // Checkbox to merge - print '' ; - } - else - { - // Checkbox to send remind - print '' ; - } - - print "\n"; - $total_ht+=$objp->total_ht; - $total_tva+=($objp->total_tva + $tx1 + $tx2 + $revenuestamp); - $total_ttc+=$objp->total_ttc; - $total_paid+=$objp->am + $cn + $dep; - - $i++; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - - print "
'; - print ''; - print ''; - print ''; - print ''; - $syear = $year; - $formother->select_year($syear?$syear:-1,'year',1, 20, 5); - print ''; - print ' '.$langs->trans("Late"); - print ''; - $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1); - print '   '; - $liststatus=array('paye:0'=>$langs->trans("Unpaid"), 'paye:1'=>$langs->trans("Paid")); - print $form->selectarray('filtre', $liststatus, $filter, 1); - print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(1, empty($mode)?'checkformerge':'checkforsend'); - print $searchpitco; - print '
'; - - $facturestatic->id=$objp->facid; - $facturestatic->ref=$objp->facnumber; - $facturestatic->type=$objp->type; - $facturestatic->statut=$objp->fk_statut; - $facturestatic->date_lim_reglement= $db->jdate($objp->datelimite); - - print ''; - - // Ref - print ''; - - // Warning picto - print ''; - - // PDF Picto - print ''; - - print '
'; - print $facturestatic->getNomUrl(1); - print ''; - if ($facturestatic->hasDelay()) { - print img_warning($langs->trans("Late")); - } - print ''; - $filename=dol_sanitizeFileName($objp->facnumber); - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->facnumber); - print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); - print '
'; - - print "
'; - print $objp->ref_client; - print ''.dol_print_date($db->jdate($objp->df),'day').''.dol_print_date($db->jdate($objp->datelimite),'day').''; - $thirdparty=new Societe($db); - $thirdparty->id=$objp->socid; - $thirdparty->name=$objp->name; - $thirdparty->client=$objp->client; - $thirdparty->code_client=$objp->code_client; - print $thirdparty->getNomUrl(1,'customer'); - print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $objp->fk_mode_reglement, 'none', '', -1); - print ''.price($objp->total_ht).''.price($objp->total_tva); - $tx1=price2num($objp->localtax1); - $tx2=price2num($objp->localtax2); - $revenuestamp=price2num($objp->revenuestamp); - if (! empty($tx1) || ! empty($tx2) || ! empty($revenuestamp)) print '+'.price($tx1 + $tx2 + $revenuestamp); - print ''.price($objp->total_ttc).''; - $cn=$facturestatic->getSumCreditNotesUsed(); - $dep=$facturestatic->getSumDepositsUsed(); - if (! empty($objp->am)) print price($objp->am); - if (! empty($objp->am) && ! empty($cn)) print '+'; - if (! empty($cn)) print price($cn); - if (! empty($dep)) print price(-$dep); - print ''.(((! empty($objp->total_ttc) || ! empty($objp->am) || ! empty($cn) || ! empty($dep)) && ($objp->total_ttc - $objp->am - $cn - $dep)) ? price($objp->total_ttc - $objp->am - $cn - $dep):' ').''; - print $facturestatic->LibStatut($objp->paye,$objp->fk_statut,5,$objp->am); - print ''; - if (! empty($formfile->infofiles['extensions']['pdf'])) - print ''; - print ''; - $selected=0; - if (in_array($objp->facid, $arrayofinvoices)) $selected=1; - if ($objp->email) print ''; - else print img_picto($langs->trans("NoEMail"), 'warning.png'); - print '
'.$langs->trans("Total").''.price($total_ht).''.price($total_tva).''.price($total_ttc).''.price($total_paid).''.price($total_ttc - $total_paid).'  
"; - - - if (empty($mode)) - { - /* - * Show list of available documents - */ - $filedir=$diroutputpdf; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->lire; - - print '
'; - // We disable multilang because we concat already existing pdf. - $formfile->show_documents('unpaid','',$filedir,$urlsource,$genallowed,$delallowed,'',1,1,0,48,1,$param,$langs->trans("PDFMerge"),$langs->trans("PDFMerge")); - } - else - { - if ($action != 'presend') - { - print '
'; - print ''; - print '
'; - print '
'; - } - } - - print ''; - - $db->free($resql); -} -else dol_print_error($db,''); - - -llxFooter(); -$db->close(); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 47abb50fb8b..00254b7440f 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -454,7 +454,7 @@ if ($object->id > 0) /* - * Withdrawal request + * Withdrawal opened requests */ $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande"; @@ -564,6 +564,8 @@ if ($object->id > 0) dol_print_error($db); } + // Closed requests + $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande,"; $sql.= " pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,"; $sql.= " pb.ref,"; diff --git a/htdocs/compta/hrm.php b/htdocs/compta/hrm.php index 08ca07b04c5..3f1b77a6697 100644 --- a/htdocs/compta/hrm.php +++ b/htdocs/compta/hrm.php @@ -97,7 +97,7 @@ if (count($listofsearchfields)) { if ($i == 0) print ''.$langs->trans("Search").''; print ''; - print ':'; + print ':'; if ($i == 0) print ''; print ''; $i++; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 855a04d2f39..4d5de55e384 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -116,7 +116,7 @@ if (count($listofsearchfields)) { if ($i == 0) print ''.$langs->trans("Search").''; print ''; - print ':'; + print ':'; if ($i == 0) print ''; print ''; $i++; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index cddbdcaa064..0cbd5068077 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -166,14 +166,15 @@ if ($result) // Situation invoices handling $line = new FactureLigne($db); - $line->fetch($obj->id); - $prev_progress = $line->get_prev_progress(); + $line->fetch($obj->id); // id of line + $prev_progress = 0; if ($obj->type==Facture::TYPE_SITUATION) { // Avoid divide by 0 if ($obj->situation_percent == 0) { $situation_ratio = 0; } else { - $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; + $prev_progress = $line->get_prev_progress($obj->rowid); // id on invoice + $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; } } else { $situation_ratio = 1; diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index aded1c6aa1f..566a2ff53cc 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -77,7 +77,7 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) else { $db->rollback(); - $mesg='
'.$localtax->error.'
'; + setEventMessages($localtax->error, $localtax->errors, 'errors'); $_GET["action"]="create"; } } @@ -112,18 +112,19 @@ if ($_GET["action"] == 'delete') { $localtax->error=$accountline->error; $db->rollback(); - $mesg='
'.$localtax->error.'
'; + setEventMessages($localtax->error, $localtax->errors, 'errors'); } } else { $db->rollback(); - $mesg='
'.$localtax->error.'
'; + setEventMessages($localtax->error, $localtax->errors, 'errors'); } } else { - $mesg='
Error try do delete a line linked to a conciliated bank transaction
'; + $mesg='Error try do delete a line linked to a conciliated bank transaction'; + setEventMessages($mesg, null, 'errors'); } } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 7fd5cb10483..c2607d5b83d 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -65,11 +65,13 @@ if ($action == 'create') $result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET); if ($result < 0) { - $mesg='
'.$bprev->error.'
'; + setEventMessages($bprev->error, $bprev->errors, 'errors'); } if ($result == 0) { - $mesg='
'.$langs->trans("NoInvoiceCouldBeWithdrawed").'
'; + $mesg=''; + $mesg=$langs->trans("NoInvoiceCouldBeWithdrawed"); + setEventMessages($mesg, null, 'errors'); foreach($bprev->invoice_in_error as $key => $val) { $mesg.=$val."
\n"; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9e8b1de5d07..395e484075d 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2147,7 +2147,7 @@ class Contrat extends CommonObject $line->total_ht=90; $line->total_ttc=107.64; // 90 * 1.196 $line->total_tva=17.64; - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; $this->lines[$xnbp]=$line; $xnbp++; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 39d28b55311..5fb15ef1ec1 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -103,8 +103,9 @@ class CMailFile * @param string $errors_to Email for errors-to * @param string $css Css option * @param string $trackid Tracking string + * @param string $moreinheader More in header (for phpmail only for the moment) */ - function __construct($subject,$to,$from,$msg,$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),$addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0,$errors_to='',$css='',$trackid='') + function __construct($subject,$to,$from,$msg,$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),$addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0,$errors_to='',$css='',$trackid='',$moreinheader='') { global $conf; @@ -199,7 +200,8 @@ class CMailFile $this->deliveryreceipt = $deliveryreceipt; $this->trackid = $trackid; $smtp_headers = $this->write_smtpheaders(); - + if (! empty($moreinheader)) $smtp_headers.=$moreinheader; + // Define mime_headers $mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list); @@ -259,7 +261,7 @@ class CMailFile $smtps->setFrom($this->getValidAddress($from,0,1)); $smtps->setTrackId($trackid); $smtps->setReplyTo($this->getValidAddress($from,0,1)); // Set property with this->smtps->setReplyTo after constructor if you want to use another value than the From - + if (! empty($this->html)) { if (!empty($css)) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index be3452f10dc..c5c2f334171 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4326,8 +4326,8 @@ class Form $syear = ''; $smonth = ''; $sday = ''; - $shour = ''; - $smin = ''; + $shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? '' : $conf->global->MAIN_DEFAULT_DATE_HOUR; + $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? '' : $conf->global->MAIN_DEFAULT_DATE_MIN; } $usecalendar='combo'; diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index ad74b465f27..450441cf54c 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -49,32 +49,11 @@ class FormBank * @param string $htmlname Nom champ formulaire * @return void */ - function select_type_comptes_financiers($selected=1,$htmlname='type') + public function selectTypeOfBankAccount($selected = Account::TYPE_CURRENT, $htmlname = 'type') { - global $langs; - $langs->load("banks"); + $account = new Account($this->db); - $type_available=array(0,1,2); - - print ''; + print Form::selectarray($htmlname, $account->type_lib, $selected); } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1226d3b35ba..339ba9c6b5e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -109,7 +109,10 @@ class FormFile $max=$conf->global->MAIN_UPLOAD_DOC; // En Kb $maxphp=@ini_get('upload_max_filesize'); // En inconnu + if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp*1; if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024; + if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024; + if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024; // Now $max and $maxphp are in Kb if ($maxphp > 0) $max=min($max,$maxphp); @@ -796,6 +799,7 @@ class FormFile // Show list of existing files if (empty($useinecm)) print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; + print ''."\n"; print ''; print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); @@ -829,10 +833,9 @@ class FormFile { $relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/'; } - $var=!$var; print ''; - print ''; - print ''; + print ''; + print ''; // Preview if (empty($useinecm)) { @@ -871,7 +875,7 @@ class FormFile } // Delete or view link // ($param must start with &) - print ''; - if ($modulo == ($nbcolsmod - 1)) print ''; + print '> '.$val->getName().'
'; + //print ''; + //if ($modulo == ($nbcolsmod - 1)) print ''; $j++; } } - print '
'; + print ''; //print "XX".$file['name']; //$file['name'] must be utf8 print '\n"; - print ''.dol_print_size($file['size'],1,1).''.dol_print_date($file['date'],"dayhour","tzuser").''.dol_print_size($file['size'],1,1).''.dol_print_date($file['date'],"dayhour","tzuser").''; + print ''; if ($useinecm) print ''.img_view().'   '; else { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 8e7064d1893..9d540a37bb6 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -657,9 +657,10 @@ class FormMail extends Form $langs->load('paypal'); + // Set the paypal message and url link into __PERSONALIZED__ key if ($this->param["models"]=='order_send') { - $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); + $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']?$this->substit['__ORDERREF__']:$this->substit['__REF__']); $this->substit['__PERSONALIZED__']=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url)); } if ($this->param["models"]=='facture_send') @@ -908,8 +909,94 @@ class FormMail extends Form return -1; } } + + + + /** + * Set substit array from object + * + * @param Object $object Object to use + * @return void + */ + function setSubstitFromObject($object) + { + $this->substit['__REF__'] = $object->ref; + $this->substit['__SIGNATURE__'] = $user->signature; + $this->substit['__REFCLIENT__'] = $object->ref_client; + $this->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name; + $this->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); + $this->substit['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:''); + $this->substit['__PERSONALIZED__'] = ''; + $this->substit['__CONTACTCIVNAME__'] = ''; // Will be replace just before sending + } + + /** + * Set substit array from object + * + * @param string $mode 'form' or 'emailing' + * @return void + */ + function getAvailableSubstitKey($mode='form') + { + global $conf; + + $vars=array(); + + if ($mode == 'form') + { + $vars=array( + '__REF__', + '__REFCLIENT__', + '__THIRDPARTY_NAME__', + '__PROJECT_REF__', + '__PROJECT_NAME__', + '__CONTACTCIVNAME__', + '__PERSONALIZED__', // Paypal link will be added here in form mode + '__SIGNATURE__', + ); + } + if ($mode == 'emailing') + { + // For mass emailing, we have different keys + $vars=array( + '__ID__' => 'IdRecord', + '__EMAIL__' => 'EMail', + '__LASTNAME__' => 'Lastname', + '__FIRSTNAME__' => 'Firstname', + '__MAILTOEMAIL__' => 'TagMailtoEmail', + '__OTHER1__' => 'Other1', + '__OTHER2__' => 'Other2', + '__OTHER3__' => 'Other3', + '__OTHER4__' => 'Other4', + '__OTHER5__' => 'Other5', + '__SIGNATURE__' => 'TagSignature', + '__CHECK_READ__' => 'TagCheckMail', + '__UNSUBSCRIBE__' => 'TagUnsubscribe' + //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing + ); + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + $vars['__SECUREKEYPAYPAL__']='SecureKeyPaypal'; + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + { + if ($conf->adherent->enabled) $vars['__SECUREKEYPAYPAL_MEMBER__']='SecureKeyPaypalUniquePerMember'; + if ($conf->facture->enabled) $vars['__SECUREKEYPAYPAL_INVOICE__']='SecureKeyPaypalUniquePerInvoice'; + if ($conf->commande->enabled) $vars['__SECUREKEYPAYPAL_ORDER__']='SecureKeyPaypalUniquePerOrder'; + if ($conf->contrat->enabled) $vars['__SECUREKEYPAYPAL_CONTRACTLINE__']='SecureKeyPaypalUniquePerContractLine'; + } + } + else + { + $vars['__SECUREKEYPAYPAL__']=''; + $vars['__SECUREKEYPAYPAL_MEMBER__']=''; + } + } + return $vars; + } + } + /** * ModelMail */ diff --git a/htdocs/core/class/html.formsupplier_proposal.class.php b/htdocs/core/class/html.formsupplier_proposal.class.php index d317778e1a0..ed8781731a0 100644 --- a/htdocs/core/class/html.formsupplier_proposal.class.php +++ b/htdocs/core/class/html.formsupplier_proposal.class.php @@ -84,7 +84,7 @@ class FormSupplierProposal } else { - $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Opened','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed'); + $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Opened','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Closed'); if (! empty($conv_to_new_code[$obj->code])) $key=$conv_to_new_code[$obj->code]; print ($langs->trans("PropalStatus".$key.($short?'Short':''))!="PropalStatus".$key.($short?'Short':''))?$langs->trans("PropalStatus".$key.($short?'Short':'')):$obj->label; } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 2661919722d..5c6b9613c17 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2012 J. Fernando Lagrange * Copyright (C) 2015 Raphaël Doursenaud * @@ -62,12 +62,16 @@ function versioncompare($versionarray1,$versionarray2) { $operande1=isset($versionarray1[$level])?$versionarray1[$level]:0; $operande2=isset($versionarray2[$level])?$versionarray2[$level]:0; - if (preg_match('/alpha|dev/i',$operande1)) $operande1=-3; - if (preg_match('/alpha|dev/i',$operande2)) $operande2=-3; - if (preg_match('/beta/i',$operande1)) $operande1=-2; - if (preg_match('/beta/i',$operande2)) $operande2=-2; - if (preg_match('/rc/i',$operande1)) $operande1=-1; - if (preg_match('/rc/i',$operande2)) $operande2=-1; + if (preg_match('/alpha|dev/i',$operande1)) $operande1=-5; + if (preg_match('/alpha|dev/i',$operande2)) $operande2=-5; + if (preg_match('/beta$/i',$operande1)) $operande1=-4; + if (preg_match('/beta$/i',$operande2)) $operande2=-4; + if (preg_match('/beta([0-9])+/i',$operande1)) $operande1=-3; + if (preg_match('/beta([0-9])+/i',$operande2)) $operande2=-3; + if (preg_match('/rc$/i',$operande1)) $operande1=-2; + if (preg_match('/rc$/i',$operande2)) $operande2=-2; + if (preg_match('/rc([0-9])+/i',$operande1)) $operande1=-1; + if (preg_match('/rc([0-9])+/i',$operande2)) $operande2=-1; $level++; //print 'level '.$level.' '.$operande1.'-'.$operande2.'
'; if ($operande1 < $operande2) { $ret = -$level; break; } @@ -591,7 +595,7 @@ function listOfSessions() $sessValues = file_get_contents($fullpath); // get raw session data // Example of possible value //$sessValues = 'newtoken|s:32:"1239f7a0c4b899200fe9ca5ea394f307";dol_loginmesg|s:0:"";newtoken|s:32:"1236457104f7ae0f328c2928973f3cb5";dol_loginmesg|s:0:"";token|s:32:"123615ad8d650c5cc4199b9a1a76783f";dol_login|s:5:"admin";dol_authmode|s:8:"dolibarr";dol_tz|s:1:"1";dol_tz_string|s:13:"Europe/Berlin";dol_dst|i:0;dol_dst_observed|s:1:"1";dol_dst_first|s:0:"";dol_dst_second|s:0:"";dol_screenwidth|s:4:"1920";dol_screenheight|s:3:"971";dol_company|s:12:"MyBigCompany";dol_entity|i:1;mainmenu|s:4:"home";leftmenuopened|s:10:"admintools";idmenu|s:0:"";leftmenu|s:10:"admintools";'; - + if (preg_match('/dol_login/i',$sessValues) && // limit to dolibarr session (preg_match('/dol_entity\|i:'.$conf->entity.';/i',$sessValues) || preg_match('/dol_entity\|s:([0-9]+):"'.$conf->entity.'"/i',$sessValues)) && // limit to current entity preg_match('/dol_company\|s:([0-9]+):"('.$conf->global->MAIN_INFO_SOCIETE_NOM.')"/i',$sessValues)) // limit to company name diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 3c5d57fdaf6..ceb8a87bb30 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -64,7 +64,7 @@ function bank_prepare_head(Account $object) $head[$h][2] = 'graph'; $h++; - if ($object->courant != 2) + if ($object->courant != Account::TYPE_CASH) { $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; $head[$h][1] = $langs->trans("AccountStatements"); diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index dea00188689..2d328ea7097 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -42,8 +42,10 @@ function contract_prepare_head(Contrat $object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; $head[$h][1] = $langs->trans("ContactsAddresses"); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; $head[$h][2] = 'contact'; $h++; } diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index a6f68800dc4..162aca37c8a 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -45,8 +45,10 @@ function fichinter_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('InterventionContact'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; $head[$h][2] = 'contact'; $h++; } diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 85b30064d0b..4b6f0b7e7d1 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -45,8 +45,10 @@ function facturefourn_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; $head[$h][2] = 'contact'; $h++; } @@ -119,8 +121,10 @@ function ordersupplier_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); + if ($nbContact > 0) $head[$h][1].= ' '.$nbContact.''; $head[$h][2] = 'contact'; $h++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3b5923536d7..ed39c6b45ef 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -630,14 +630,14 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' if ($level > $conf->global->SYSLOG_LEVEL) return; // If adding log inside HTML page is required - if (! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_LOGTOHTML)) + if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility { $conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; } - //TODO: Remove this. MAIN_ENABLE_LOG_HTML should be deprecated and use a log handler dedicated to HTML output + //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments - if (! empty($conf->global->MAIN_ENABLE_LOG_HTML) && ! empty($_GET["log"])) + if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"])) { print "\n\n'; + print ' '.$val->getName().'  '; - print ''; - print '
'; - print ''; + //print ''; + print '
'; print ''."\n"; - print ''; + print ''; } print ''; print ''."\n"; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 3924e8a9174..f71b04b7730 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -46,16 +46,14 @@ class CompanyBankAccount extends Account * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; $this->socid = 0; - $this->clos = 0; $this->solde = 0; $this->error_number = 0; $this->default_rib = 0; - return 1; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index cb966901a44..13d6d7dcde8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Florian Henry @@ -867,7 +867,7 @@ class Societe extends CommonObject } $sql .= ", fk_user_modif = ".(! empty($user->id)?"'".$user->id."'":"null"); $sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency; - $sql .= ', multicurrency_code = "'.$this->db->escape($this->multicurrency_code).'"'; + $sql .= ', multicurrency_code = \''.$this->db->escape($this->multicurrency_code)."'"; $sql .= " WHERE rowid = '" . $id ."'"; @@ -1662,10 +1662,19 @@ class Societe extends CommonObject $reparray=array(); - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.email, u.statut, u.entity"; + $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.email, u.statut, u.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.rowid = sc.fk_user AND sc.fk_soc =".$this->id; - $sql.= " AND entity in (0, ".$conf->entity.")"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + { + $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE ((ug.fk_user = sc.fk_user"; + $sql.= " AND ug.entity = ".$conf->entity.")"; + $sql.= " OR u.admin = 1)"; + } + else + $sql.= " WHERE entity in (0, ".$conf->entity.")"; + + $sql.= " AND u.rowid = sc.fk_user AND sc.fk_soc =".$this->id; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php index 152f655835e..b87bad6099d 100644 --- a/htdocs/societe/commerciaux.php +++ b/htdocs/societe/commerciaux.php @@ -33,7 +33,7 @@ $langs->load("suppliers"); $langs->load("banks"); // Security check -$socid = GETPOST("socid"); +$socid = GETPOST('socid', 'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); @@ -43,17 +43,14 @@ $hookmanager->initHooks(array('salesrepresentativescard','globalcard')); * Actions */ -if($_GET["socid"] && $_GET["commid"]) +if (! empty($socid) && $_GET["commid"]) { $action = 'add'; if ($user->rights->societe->creer) { - $object = new Societe($db); - $object->id = $_GET["socid"]; - $object->fetch($_GET["socid"]); - + $object->fetch($socid); $parameters=array('id'=>$_GET["commid"]); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -61,25 +58,24 @@ if($_GET["socid"] && $_GET["commid"]) if (empty($reshook)) $object->add_commercial($user, $_GET["commid"]); - header("Location: commerciaux.php?socid=".$object->id); + header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$object->id); exit; } else { - header("Location: commerciaux.php?socid=".$_GET["socid"]); + header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); exit; } } -if ($socid && $_GET["delcommid"]) +if (! empty($socid) && $_GET["delcommid"]) { $action = 'delete'; if ($user->rights->societe->creer) { $object = new Societe($db); - $object->id = $_GET["socid"]; - $object->fetch($_GET["socid"]); + $object->fetch($socid); $parameters=array('id'=>$_GET["delcommid"]); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -92,7 +88,7 @@ if ($socid && $_GET["delcommid"]) } else { - header("Location: commerciaux.php?socid=".$_GET["socid"]); + header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); exit; } } @@ -107,7 +103,7 @@ llxHeader('',$langs->trans("ThirdParty"),$help_url); $form = new Form($db); -if ($socid) +if (! empty($socid)) { $object = new Societe($db); $result=$object->fetch($socid); @@ -141,12 +137,26 @@ if ($socid) print ''.$langs->trans("SalesRepresentatives").''; print ''; - $sql = "SELECT u.rowid, u.login, u.fk_soc, u.lastname, u.firstname, u.statut, u.entity"; + $sql = "SELECT DISTINCT u.rowid, u.login, u.fk_soc, u.lastname, u.firstname, u.statut, u.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + { + $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + } $sql .= " WHERE sc.fk_soc =".$object->id; $sql .= " AND sc.fk_user = u.rowid"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + { + $sql.= " AND ((ug.fk_user = sc.fk_user"; + $sql.= " AND ug.entity = ".$conf->entity.")"; + $sql.= " OR u.admin = 1)"; + } + else + $sql.= " AND u.entity IN (0,".$conf->entity.")"; + $sql .= " ORDER BY u.lastname ASC "; + dol_syslog('societe/commerciaux.php::list salesman sql = '.$sql,LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -183,7 +193,7 @@ if ($socid) print ' '; if ($user->rights->societe->creer) { - print ''; + print ''; print img_delete(); print ''; } @@ -217,9 +227,17 @@ if ($socid) $langs->load("users"); $title=$langs->trans("ListOfUsers"); - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.login, u.statut"; + $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.login, u.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + { + $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE ((ug.fk_user = u.rowid"; + $sql.= " AND ug.entity = ".$conf->entity.")"; + $sql.= " OR u.admin = 1)"; + } + else + $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND u.statut<>0 "; $sql.= " ORDER BY u.lastname ASC "; @@ -251,10 +269,11 @@ if ($socid) print img_object($langs->trans("ShowUser"),"user").' '; print dolGetFirstLastname($obj->firstname, $obj->lastname)."\n"; print ''; + print ''; print ''.$obj->login.''; print ''.User::LibStatut($obj->statut,0).''; - print ''.$langs->trans("Add").''; + print ''.$langs->trans("Add").''; print ''."\n"; $i++; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 2ac6d3cbd7d..4228ba0319b 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -42,16 +42,16 @@ $object = new Societe($db); if ($socid > 0) $object->fetch($socid); // Sort & Order fields +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { - $page = 0; -} -$offset = $conf->liste_limit * $page; +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='dateprint'; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; // Search fields $sref=GETPOST("sref"); @@ -124,7 +124,7 @@ print '
'; print ''; // Alias names (commercial, trademark or alias names) -print ''; +print ''; print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field @@ -305,9 +305,19 @@ if ($month > 0) { $end = dol_time_plus_duree($start,1,'y') - 1; $sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'"; } -if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$sref."%'"; -if ($sprod_fulldescr) $sql.= " AND (d.description LIKE '%".$sprod_fulldescr."%' OR p.label LIKE '%".$sprod_fulldescr."%')"; +if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; +if ($sprod_fulldescr) +{ + $sql.= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; + $sql.=")"; +} $sql.= $db->order($sortfield,$sortorder); + +$resql=$db->query($sql); +$totalnboflines = $db->num_rows($resql); + $sql.= $db->plimit($limit + 1, $offset); //print $sql; @@ -316,49 +326,56 @@ $typeElementString = $form->selectarray("type_element", $elementTypeArray, GETPO $button = ''; $param="&sref=".$sref."&month=".$month."&year=".$year."&sprod_fulldescr=".$sprod_fulldescr."&socid=".$socid."&type_element=".$type_element; -print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); if ($sql_select) { $resql=$db->query($sql); if (!$resql) dol_print_error($db); -} -print '
'.$object->name_alias.'
'."\n"; -// Titles with sort buttons -print ''; -print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'dateprint','',$param,'align="center" width="150"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_status','',$param,'align="center"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder); -print "\n"; -// Filters -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -if ($sql_select) -{ $var=true; $num = $db->num_rows($resql); + + $param="&socid=".$socid."&type_element=".$type_element; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sprod_fulldescr) $param.= "&sprod_fulldescr=".urlencode($sprod_fulldescr); + if ($sref) $param.= "&sref=".urlencode($sref); + if ($month) $param.= "&month=".$month; + if ($year) $param.= "&year=".$year; + if ($optioncss != '') $param.='&optioncss='.$optioncss; + + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $totalnboflines, '', 0, '', '', $limit); + + print '
'; -print ''; -print ''; // date -print $formother->select_month($month?$month:-1,'month',1); -$formother->select_year($year?$year:-1,'year',1, 20, 1); -print ''; -print ''; -print ''; -print ''; -$searchpitco=$form->showFilterAndCheckAddButtons(0); -print $searchpitco; -print '
'."\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'dateprint','',$param,'align="center" width="150"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_status','',$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder); + print "\n"; + // Filters + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i = 0; - while (($objp = $db->fetch_object($resql)) && $i < $conf->liste_limit ) + while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) { $documentstatic->id=$objp->doc_id; $documentstatic->ref=$objp->doc_number; @@ -532,20 +549,42 @@ if ($sql_select) print "\n"; $i++; } - if ($num > $conf->liste_limit) { + + print "
'; + print ''; + print ''; // date + print $formother->select_month($month?$month:-1,'month',1); + $formother->select_year($year?$year:-1,'year',1, 20, 1); + print ''; + print ''; + print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print '
"; + + if ($num > $limit) { print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num); } $db->free($resql); } else if (empty($type_element) || $type_element == -1) { + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); + + print ''."\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'dateprint','',$param,'align="center" width="150"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_status','',$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder); + print "\n"; + print ''; + + print "
'.$langs->trans("SelectElementAndClickRefresh").'
"; } else { + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); + + print ''."\n"; + print ''; + + print "
'.$langs->trans("FeatureNotYetAvailable").'
"; } -print ""; print ""; llxFooter(); diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 615ee04cd44..98ee42afc57 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -79,7 +79,7 @@ if (count($listofsearchfields)) { if ($i == 0) print ''.$langs->trans("Search").''; print ''; - print ':'; + print ':'; if ($i == 0) print ''; print ''; $i++; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 0108ff1b55b..1b2a515695b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -778,9 +778,9 @@ if ($resql) { if (! empty($arrayfields["ef.".$key]['checked'])) { - $typeofextrafield=$extrafields->attribute_type[$key]; - if (in_array($typeofextrafield, array('int'))) print ''; - else print ''; + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; if (in_array($typeofextrafield, array('varchar', 'int', 'select'))) { $crit=$val; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 613348ed044..983205f60b9 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -2342,7 +2342,18 @@ else $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if (! empty($object->email)) + $at_least_one_email_contact = false; + $TContact = $object->contact_array_objects(); + foreach ($TContact as &$contact) + { + if (!empty($contact->email)) + { + $at_least_one_email_contact = true; + break; + } + } + + if (! empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); print ''; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a66c849bf3a..5411cee24b6 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -729,6 +729,18 @@ if (empty($reshook)) unset($_POST['dp_desc']); unset($_POST['idprod']); + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { $db->rollback(); @@ -836,6 +848,19 @@ if (empty($reshook)) unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { $db->rollback(); @@ -1076,7 +1101,7 @@ if ($action == 'create') print ''; } else { print ''; - print $form->select_company('', 'socid', 's.fournisseur = 1', 1); + print $form->select_company('', 'socid', 's.fournisseur = 1', 'SelectThirdParty'); print ''; } print '' . "\n"; @@ -1905,12 +1930,8 @@ if ($action == 'create') $formmail->withcancel = 1; // Tableau des substitutions - $formmail->substit['__ASKREF__'] = $object->ref; - $formmail->substit['__SIGNATURE__'] = $user->signature; - $formmail->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name; - $formmail->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); - $formmail->substit['__CONTACTCIVNAME__'] = ''; - $formmail->substit['__PERSONALIZED__'] = ''; + $formmail->setSubstitFromObject($object); + $formmail->substit['__SUPPLIERPROPREF__'] = $object->ref; // Tableau des parametres complementaires $formmail->param['action'] = 'send'; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b5319210fc7..df634da27ae 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -62,7 +62,7 @@ class SupplierProposal extends CommonObject */ var $author; var $ref_fourn; //Reference saisie lors de l'ajout d'une ligne à la demande - var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed) + var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (processed/billed) var $date; // Date of proposal var $date_livraison; @@ -139,6 +139,29 @@ class SupplierProposal extends CommonObject var $multicurrency_total_tva; var $multicurrency_total_ttc; + /** + * Draft status + */ + const STATUS_DRAFT = 0; + /** + * Validated status + */ + const STATUS_VALIDATED = 1; + /** + * Signed quote + */ + const STATUS_SIGNED = 2; + /** + * Not signed quote + */ + const STATUS_NOTSIGNED = 3; + /** + * Billed or processed quote + */ + const STATUS_BILLED = 4; + + + /** * Constructor * @@ -2087,7 +2110,7 @@ class SupplierProposal extends CommonObject */ function load_board($user,$mode) { - global $conf, $user; + global $conf, $user, $langs; $now=dol_now(); @@ -2110,29 +2133,43 @@ class SupplierProposal extends CommonObject $resql=$this->db->query($sql); if ($resql) { - if ($mode == 'opened') $delay_warning=$conf->supplier_proposal->cloture->warning_delay; - if ($mode == 'signed') $delay_warning=$conf->supplier_proposal->facturation->warning_delay; + if ($mode == 'opened') { + $delay_warning=$conf->supplier_proposal->cloture->warning_delay; + $statut = self::STATUS_VALIDATED; + $label = $langs->trans("SupplierProposalsToClose"); + } + if ($mode == 'signed') { + $delay_warning=$conf->supplier_proposal->facturation->warning_delay; + $statut = self::STATUS_SIGNED; + $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered + } + $response = new WorkboardResponse(); + $response->warning_delay = $delay_warning/60/60/24; + $response->label = $label; + $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; + $response->img = img_object($langs->trans("SupplierProposals"),"propal"); + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { - $this->nbtodo++; + $response->nbtodo++; if ($mode == 'opened') { $datelimit = $this->db->jdate($obj->datefin); if ($datelimit < ($now - $delay_warning)) { - $this->nbtodolate++; + $response->nbtodolate++; } } // TODO Definir regle des propales a facturer en retard // if ($mode == 'signed' && ! count($this->FactureListeArray($obj->rowid))) $this->nbtodolate++; } - return 1; + return $response; } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } } @@ -2207,7 +2244,7 @@ class SupplierProposal extends CommonObject $line->remise_percent=00; } - $prodid = rand(1, $num_prods); + $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; $this->lines[$xnbp]=$line; @@ -2257,7 +2294,7 @@ class SupplierProposal extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -1; } } diff --git a/htdocs/theme/eldy/img/warning.png b/htdocs/theme/eldy/img/warning.png index f1b93b8cc82..9ec45736b05 100644 Binary files a/htdocs/theme/eldy/img/warning.png and b/htdocs/theme/eldy/img/warning.png differ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ad72cd5f5ad..65c232c6737 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -209,6 +209,8 @@ print '$colortexttitlenotab='.$colortexttitlenotab."\n"; print '$colortexttitle='.$colortexttitle."\n"; print '$colortext='.$colortext."\n"; print '$colortextlink='.$colortextlink."\n"; +print '$colortextbackhmenu='.$colortextbackhmenu."\n"; +print '$colortextbackvmenu='.$colortextbackvmenu."\n"; print 'dol_hide_topmenu='.$dol_hide_topmenu."\n"; print 'dol_hide_leftmenu='.$dol_hide_leftmenu."\n"; print 'dol_optimize_smallscreen='.$dol_optimize_smallscreen."\n"; @@ -433,6 +435,9 @@ th .button { .centpercent { width: 100%; } +.quatrevingtpercent, .inputsearch { + width: 80%; +} textarea.centpercent { width: 96%; } @@ -529,6 +534,13 @@ div.myavailability { .strikefordisabled { text-decoration: line-through; } +.tdoverflow { + max-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + /* ============================================================================== */ /* Styles to hide objects */ @@ -2147,11 +2159,11 @@ table.liste, table.noborder, table.formdoc, div.noborder { margin: 0px 0px 5px 0px; - -moz-box-shadow: 2px 2px 4px #CCC; +/* -moz-box-shadow: 2px 2px 4px #CCC; -webkit-box-shadow: 2px 2px 4px #CCC; box-shadow: 2px 2px 4px #CCC; -/* -moz-border-radius: 0.2em; + -moz-border-radius: 0.2em; -webkit-border-radius: 0.2em; border-radius: 0.2em;*/ } @@ -2217,7 +2229,7 @@ div.refidpadding { } div.refid { font-weight: bold; - color: #766; + color: #866; font-size: 160%; } div.refidno { @@ -2628,9 +2640,9 @@ span.dashboardlineko { font-weight: bold; } .boxtable { - -moz-box-shadow: 3px 3px 4px #DDD; +/* -moz-box-shadow: 3px 3px 4px #DDD; -webkit-box-shadow: 3px 3px 4px #DDD; - box-shadow: 3px 3px 4px #DDD; + box-shadow: 3px 3px 4px #DDD; */ margin-bottom: 8px !important; } @@ -2638,7 +2650,7 @@ span.dashboardlineko { .box { padding-right: 0px; padding-left: 0px; - padding-bottom: 4px; + padding-bottom: 12px; } tr.box_titre { @@ -2688,9 +2700,13 @@ tr.box_pair { tr.box_pair td, tr.box_impair td { padding: 4px; +} +tr.box_pair:not(:last-child) td, tr.box_impair:not(:last-child) td { border-bottom: 1px solid #ddd; } - +.noborderbottom { + border-bottom: none !important; +} .formboxfilter { vertical-align: middle; margin-bottom: 6px; @@ -4023,6 +4039,12 @@ border-top-right-radius: 6px; +/* For demo pages */ +img.demothumb { + box-shadow: 2px 2px 8px #888; +} + + /* The theme for public pages */ .public_body { margin: 20px; @@ -4033,6 +4055,9 @@ border-top-right-radius: 6px; + + + /* CSS style used for small screen */ .imgopensurveywizard @@ -4050,25 +4075,53 @@ border-top-right-radius: 6px; } -@media only screen and (max-width: px) +/* nboftopmenuentries = , fontsize= */ +/* rule to reduce top menu - 1st reduction */ +@media only screen and (max-width: px) { + div.tmenucenter { + max-width: px; /* size of viewport */ + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #; + } .mainmenuaspan { - display: none; + /*display: none;*/ + font-size: 10px; } + .topmenuimage { + background-size: 26px auto; + margin-top: 0px; + } + li.tmenu, li.tmenusel { min-width: 32px; } div.mainmenu { min-width: auto; } - .topmenuimage { - background-size: 26px auto; - margin-top: 8px; - } div.tmenuleft { display: none; } } +/* rule to reduce top menu - 2nd reduction */ +@media only screen and (max-width: px) +{ + div.tmenucenter { + max-width: px; /* size of viewport */ + text-overflow: clip; + } + .mainmenuaspan { + /*display: none;*/ + font-size: 10px; + } + .topmenuimage { + background-size: 20px auto; + margin-top: 2px; + } +} +/* rule to reduce top menu - 3rd reduction */ @media only screen and (max-width: 570px) { /* Reduce login top right info */ @@ -4086,13 +4139,20 @@ border-top-right-radius: 6px; top: 4px; max-width: 82px; } + li.tmenu, li.tmenusel { + min-width: 30px; + } + div.tmenucenter { + text-overflow: clip; + } + .topmenuimage { + background-size: 20px auto; + margin-top: 2px !important; + } div.mainmenu { min-width: 20px; } - .topmenuimage { - background-size: 20px auto; - } #tooltip { position: absolute; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 1266f5799a2..8662a8c835e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -204,6 +204,8 @@ print '$colortexttitlenotab='.$colortexttitlenotab."\n"; print '$colortexttitle='.$colortexttitle."\n"; print '$colortext='.$colortext."\n"; print '$colortextlink='.$colortextlink."\n"; +print '$colortextbackhmenu='.$colortextbackhmenu."\n"; +print '$colortextbackvmenu='.$colortextbackvmenu."\n"; print 'dol_hide_topmenu='.$dol_hide_topmenu."\n"; print 'dol_hide_leftmenu='.$dol_hide_leftmenu."\n"; print 'dol_optimize_smallscreen='.$dol_optimize_smallscreen."\n"; @@ -420,6 +422,9 @@ th .button { .centpercent { width: 100%; } +.quatrevingtpercent, .inputsearch { + width: 80%; +} textarea.centpercent { width: 96%; } @@ -517,6 +522,12 @@ div.myavailability { .strikefordisabled { text-decoration: line-through; } +.tdoverflow { + max-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} /* ============================================================================== */ @@ -881,13 +892,14 @@ ul.tmenu { /* t r b l */ } ul.tmenu li { background: rgb(); - + /* background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -ms-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgba(255,255,255,.3)), color-stop(1, rgba(0,0,0,.3)) ); + */ } li.tmenu, li.tmenusel { @@ -3855,6 +3867,13 @@ border-top-right-radius: 6px; +/* For demo pages */ +img.demothumb { + box-shadow: 2px 2px 8px #888; + margin-bottom: 4px; +} + + /* The theme for public pages */ .public_body { margin: 20px; @@ -3897,25 +3916,53 @@ border-top-right-radius: 6px; } } + +/* nboftopmenuentries = , fontsize= */ +/* rule to reduce top menu - 1st reduction */ @media only screen and (max-width: px) { + div.tmenucenter { + max-width: px; /* size of viewport */ + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #; + } .mainmenuaspan { - display: none; + /*display: none;*/ + font-size: 10px; } + .topmenuimage { + background-size: 26px auto; + margin-top: 0px; + } li.tmenu, li.tmenusel { min-width: 32px; } div.mainmenu { min-width: auto; } - .topmenuimage { - background-size: 26px auto; - margin-top: 8px; - } div.tmenuleft { display: none; } } +/* rule to reduce top menu - 2nd reduction */ +@media only screen and (max-width: px) +{ + div.tmenucenter { + max-width: px; /* size of viewport */ + text-overflow: clip; + } + .mainmenuaspan { + /*display: none;*/ + font-size: 10px; + } + .topmenuimage { + background-size: 20px auto; + margin-top: 2px; + } +} +/* rule to reduce top menu - 3rd reduction */ @media only screen and (max-width: 570px) { /* Reduce login top right info */ @@ -3933,12 +3980,20 @@ border-top-right-radius: 6px; top: 9px; } + li.tmenu, li.tmenusel { + min-width: 30px; + } + + div.tmenucenter { + text-overflow: clip; + } + .topmenuimage { + background-size: 20px auto; + margin-top: 2px !important; + } div.mainmenu { min-width: 20px; } - .topmenuimage { - background-size: 20px auto; - } #tooltip { position: absolute; diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 30c795bbd72..a91d064c7f8 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -44,15 +44,13 @@ class UserBankAccount extends Account * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; $this->socid = 0; - $this->clos = 0; $this->solde = 0; $this->error_number = 0; - return 1; } diff --git a/htdocs/user/home.php b/htdocs/user/home.php index e9d9fb6c489..6bcd468f62e 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -68,20 +68,19 @@ print ''; print ''; print ''; print ''; +print $langs->trans("User").':'; // Search Group if ($canreadperms) { $var=false; print ''; + print $langs->trans("Group").':'; } print "
'.$langs->trans("Search").'
'; -print $langs->trans("User").':
'; - print $langs->trans("Group").':

\n"; print ''; -//print ''; print '
'; diff --git a/test/phpunit/BankAccountTest.php b/test/phpunit/BankAccountTest.php index 7c59571464c..a212ff0317a 100644 --- a/test/phpunit/BankAccountTest.php +++ b/test/phpunit/BankAccountTest.php @@ -214,7 +214,7 @@ class BankAccountTest extends PHPUnit_Framework_TestCase $localobject=new Account($this->savdb); $result=$localobject->fetch($id); - $result=$localobject->delete($id); + $result=$localobject->delete($user); print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0);