diff --git a/.travis.yml b/.travis.yml index 8e1aa2aa10b..718356e8075 100644 --- a/.travis.yml +++ b/.travis.yml @@ -257,7 +257,7 @@ script: # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/codesniffer/ruleset.xml --encoding=utf-8 . + phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . set +e echo diff --git a/ChangeLog b/ChangeLog index 68ccd4e50df..a7a643e9d05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,69 +24,96 @@ Dolibarr better: - Function delete of class Facture (invoice) need the object $user as first parameter. Also you must check you make a fetch on object before calling the delete. - The old driver of "mysql" has been removed. Dolibarr use the new one (mysqli) by default. +- Remove not used function calculate_byte(). Use dol_print_size() instead. +- Function pdf_getTotalQty is now deprecated. Not used by Dolibarr core. +- Method expensereport->delete(id, user) has been replaced with ->delete(user) + Method warehouse->delete(id) has been replace with ->delete(user) + This is to follow good practice to make a fetch on object before deleting it. +- The form to add a product to a draft proposal/order/invoice from the product card is hidden by default. + It was not commonly used and usage generates some problems (cost price for margin calculation not entered, vat setting). + Set constant PRODUCT_ADD_FORM_ADD_TO to retrieve it. +***** ChangeLog for 4.0.1 compared to 4.0.0 ***** +FIX #2853 +FIX #2991 +FIX #3128 +FIX: #5699 +FIX #5734 +FIX : #5776 +FIX alignement of intervention status +FIX Clean of search fields +FIX Creation of donation should go back on card after creation +FIX Date visible on project overview +FIX Execute a dedicated job from its id may results of launching other jobs too. +FIX: Failed to export contact categories with contact extra fields +FIX inversion customer/supplier price +FIX link "back to list" was not visible. +FIX Lost filter on opportunities +FIX Mandatory field payment term was not css highlighted. +FIX Menu users not visible on dolidroid. +FIX SEC for HTB23302 +FIX The email test sender in email setup was broken +FIX Translation of "Name" is not a good choice for floow-up. +FIX Update of maxnbrun on job list failed. +FIX Value of payment term and project are not set on correct default value when invoice generated from template. +FIX: vat dictionary should allow enter and edit multiple values for localtaxes, separated by: (ex -19:-15) + ***** ChangeLog for 4.0.0 compared to 3.9.* ***** For users: -NEW: Add reccuring invoice feature and automatic generation of invoices. +NEW: Add recurring invoice feature and automatic generation of invoices. NEW: Add module "Loan" as stable. -NEW: Add module "Supplier commercial proposal" (price request) is set to stable status. -NEW: Experimental module Accountancy Expert -NEW: Experimental module Multicurency -NEW: Show into badge on tab head the number of dedicated contacts for all objects. +NEW: Add module "Supplier commercial proposal" (price request) with stable status. +NEW: Can select dynamicaly number of lines to show on page on product, shipment, contact, orders, thirdparties. +NEW: Can select fields to show on list also for list of customer orders, supplier orders, shipments, proposals and invoices. +NEW: Show into badge on tab head, the number of dedicated contacts for all objects. NEW: Add a checkbox to select/unselect all lines on page that support mass actions (like invoice list page) -NEW: Add a new method for margin calculation. Added margin on "cost price" to margin on WAP price and margin on "best supplier price". +NEW: Add a new method for margin calculation. Added margin on "cost price" in addition to margin on WAP price and margin on "best supplier price". NEW: Add an explanation message on shipment page to explain you can't make shipment if order is not validated NEW: Add date_rum into table of thirdparty bank account. NEW: The probability of lead/opportunity can be defined per lead. NEW: Added Malta VAT into migration script -NEW: #4972 Translated Charges sociales (type 0) and Charges sociales (type 1) in reports page NEW: Add Expense report into accountancy report NEW: Add Expense report to approve into workboard -NEW: Selection of boxes is move on top of home page -NEW: Add filter on a keyword, status and nature into list of modules +NEW: Selection of boxes is moved on top of home page +NEW: Add filter on a keyword, status and nature into list of modules. NEW: Add hidden option BANK_DISABLE_CHECK_DEPOSIT to disable check deposit feature. -NEW: Add option MAIN_PUBLIC_NOTE_IN_ADDRESS -NEW: add html id/class to locate value in the DOM html +NEW: Add hidden option MAIN_PUBLIC_NOTE_IN_ADDRESS NEW: Add index on invoice status -NEW: Add constant MAIN_LOGTOHTML to 0 into other setup by default to save time when we need to make debug on hosted instance. +NEW: Add constant MAIN_LOGTOHTML to 0 into setup by default to save time when we need to make debug on hosted instance. NEW: Add list of billed NEW: Add minimum stock and desired stock into import/export profiles. -NEW: Add state into thirdparty export fields +NEW: Add state into thirdparty export fields. NEW: Add more trackable events (create, submit and receive supplier order). -NEW: Add option MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN +NEW: Add hidden option MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN NEW: Add picto on module list to show warning and if module is an external module. -NEW: add product type filter on turnover report +NEW: Add product type filter on turnover report NEW: Add state into list of fields available for personalized fields of thirdparties NEW: Add statistics for interventions module NEW: Add statistics on number of projets on home page -NEW: Add stats and late records into dashboard for supplier proposals. +NEW: Add statistics and late records into dashboard for supplier proposals. NEW: Add the admin info on combo of type of contact -NEW: Add the event BILL_PAYED to list of supported events for module notification. -NEW: Add total weight and volume on PDF +NEW: Add the event BILL_PAYED to the list of supported events for module notification. +NEW: Add total weight and volume on PDF. NEW: Add hidden option to hide column qty ordered on shipments. -NEW: Add view of virtual stock into product list (when appropriate) -NEW: Add warning on tasks when they are late (add also the warning tolerance parameter) -NEW: Add weight/volume for one product into shipment export +NEW: Add view of virtual stock into product list (when appropriate). +NEW: Add warning on tasks when they are late (add also the warning tolerance parameter). +NEW: Add weight/volume for one product into shipment export. NEW: Add width and height on product card -NEW: allow a document to be linked to project from another customer on config -NEW: allow project to be shared across entities (for multicompany module) +NEW: allow a document to be linked to project of another customer by config setup. +NEW: allow project to be shared across entities (for multicompany module). NEW: All variant of ckeditor config can be tested into the setup page of module. NEW: Can change dynamically number of records visible into lists. -NEW: Can change type of extrafields for some combinations. -NEW: Can define number of first and last line into import wizard. +NEW: Can change type of extrafields (for some combinations only). +NEW: Can define number of first and last line to import into import wizard. NEW: Can edit next execution date of a cron job. NEW: Can edit value date of a vat payment after recording it. -NEW: Can filter modules on publisher -NEW: Can filter on employee status when building emailing from users -NEW: Can reopen an closed shipment -NEW: Can search on shipments into the quick search box -NEW: Can select dynamicaly number of lines to show on page on product, shipment, contact, orders, thirdparties -NEW: Can select fields to show on supplier orders list. -NEW: Can select fields to show on list also for list of customer orders, shipments and invoices. -NEW: Can select fields to show on proposal lists. -NEW: Can select language from combo list on page to overwrite a translation +NEW: Can filter modules on publisher. +NEW: Can filter on employee status when building emailing from users. +NEW: Can reopen an closed shipment. +NEW: Can search on shipments into the quick search box. +NEW: Can select language from a combo list on page to overwrite a translation. NEW: Can select number of lines on page list for projects and tasks. NEW: Can use ^ and $ (to say start with or end with like regex syntax) into search fields when search field is text. Bonus: ^$ can filter all lines with field not defined. NEW: Clean and enhance code for cron engine @@ -108,32 +135,35 @@ NEW: Into GED module, filename is truncated only if there is not enough space in NEW: Introduce a predefined job to run database backup NEW: Introduce option MAIN_WEIGHT_DEFAULT_UNIT and MAIN_VOLUME_DEFAULT_UNIT to force output unit for weight and volume. NEW: Introduce position of records into dictionnary of type of contacts -NEW: Link on user in leave context reach to leave tab. -NEW: List of user in agenda view per user show photo thumb +NEW: Link on a user in leave page reach to leave tab of user. +NEW: List of user in agenda view per user show photo thumb. NEW: Margins module - Check/update buying price on invoice lines NEW: Merge all admin tools (system and module admin tools) into same entry "Admin tools", so now things are clear: All features restricted to an admin user is inside "setup" (for setup) or "admin tools" (for action tools) instead of 3 different entries. NEW: Merge all boxes "related objects" into one. This save a lot of room on most card and avoid often horizontal scoll. NEW: Moved code that deals with bank categories to BankCateg. Created BankCateg::fetchAll function -NEW: Move Expense report menu from module to menu files -NEW: Move HRM dictionary from module to core dictionaries +NEW: Move HRM dictionary from module to core dictionaries. NEW: Mutualize code to manage email substitution variables. Show available variables into page to edit email templates. NEW: Mutualize code: Use one call of function "addThumbs", when possible, to generate thumbs files instead of several call of "vignette" function. NEW: On translation admin page, admin can overwrite a translation value. -NEW: Option MAIN_LIST_FILTER_ON_DAY is supported on proposal list -NEW: Add reputation field for price supplier -NEW: Rest API token is no more reset at each call. We can reset it with param reset=1 on login call. +NEW: Option MAIN_LIST_FILTER_ON_DAY is supported on proposal list. +NEW: Add reputation field for price supplier. NEW: Selection of fields is available on member list. NEW: Show a badge with number of withdraw requests done on the withdraw tab of invoice. -NEW: Add option to show detail per warehouse into reassort -NEW: Show total number of modules into the module list +NEW: Add option to show detail per warehouse into reassort. +NEW: Show total number of modules into the module list. NEW: Survey system has now a status like other objects. You can close or reopen a survey. -NEW: The note on time spent can be entered when using the view per day. -NEW: Use ellipsis truncation on too large left menu text +NEW: The note on time spent can be entered when using the "view per day". +NEW: Use ellipsis truncation on too large left menu text. NEW: When a new field to show into lists is selected, the form is automatically submited and field added. NEW: When creating a template invoice from a draft invoice, if there is link to contract on draft invoice, link is kept on template invoice. NEW: When emailing is not sent completely, show progression. +NEW: Experimental module Accountancy Expert. +NEW: Experimental module Multicurency For developers: +NEW: Add entity field in llx_societe_remise_except and llx_societe_remise. +NEW: Rest API token is no more reset at each call. We can reset it with param reset=1 on login call. +NEW: Add html id/class to locate value in the DOM html NEW: Add a css class style called 'reposition', so when clicking on a link with this class will move scrollbarr to be placed at same page location. NEW: TimeZone can be supplied to mktime NEW: hook in shipment card @@ -153,8 +183,9 @@ NEW: Removed deprecated CommonObject::client property. Please use CommonObject:: NEW: Removed unused FormOrder::selectSourcesCommande function NEW: Renamed ActionComm::add function to ActionComm::create NEW: Rename Form::select_date to Form::selectDate and Form::form_date to Form::formDate -NEW: Rename path for generiN +NEW: Rename path for generic media files NEW: More phpunit tests. Include some REST API into automatic tests. +NEW: Move Expense report menu from module to menu files. WARNING: diff --git a/README-FR.md b/README-FR.md index 55065d5d15f..41edb8ba50e 100644 --- a/README-FR.md +++ b/README-FR.md @@ -25,7 +25,7 @@ OpenSuse, Mandriva ou Mageia). Vous pouvez les télécharger depuis la rubrique *download* du portail officiel: https://www.dolibarr.org/ -Si vous avez déjà installé un serveur Web avec PHP et une base de donnée (Mysql), +Si vous avez déjà installé un serveur Web avec PHP et une base de donnée (MariaDb/MySql/PostgreSql), vous pouvez installer Dolibarr avec cette version de la manière suivante: - Copier le répertoire "dolibarr" et son contenu dans la racine de votre serveur @@ -117,8 +117,8 @@ Voir fichier ChangeLog. - Application simple à utiliser. - Plusieurs thèmes visuels. - Code simple et facilement personnalisable. -- Requiert PHP et Mysql ou Postgresql (Voir versions exactes sur http://wiki.dolibarr.org/index.php/Prérequis). -- Compatible avec toutes les offres Cloud du marché respectant les prérequis MySQL et PHP ou Postgresql. +- Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur http://wiki.dolibarr.org/index.php/Prérequis). +- Compatible avec toutes les offres Cloud du marché respectant les prérequis de base de données et PHP. - Export PDF de tous les éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) diff --git a/README.md b/README.md index 3eb0941568a..64579486985 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ If you have low technical skills and you're looking to install Dolibarr ERP/CRM ### Advanced setup -You can use a Web server and a supported database (MySQL recommended) to install the standard version. +You can use a Web server and a supported database (MariaDb, MySql or Postgresql) to install the standard version. - Uncompress the downloaded archive - Copy directory "dolibarr" and all its files inside your web server root, or copy directory anywhere and set up your web server to use "dolibarr/htdocs" as root for a new web server virtual host (second choice need to be server administrator) @@ -119,7 +119,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Can manage several currencies by adding external module multi-currency. - Very user friendly and easy to use - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) -- Works with PHP 5.3+ and MySQL 4.1+ or PostgreSQL 8.1. (See requirements on the [Wiki](http://wiki.dolibarr.org/index.php/Prerequisite)) +- Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](http://wiki.dolibarr.org/index.php/Prerequisite)) - Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. - An easy to understand, maintain and code interfaces with your own information system (PHP with no heavy framework; trigger and hook architecture) - Support for country specific features: diff --git a/build/README-FR b/build/README-FR deleted file mode 100644 index b677e545595..00000000000 --- a/build/README-FR +++ /dev/null @@ -1,78 +0,0 @@ -README (French) -################################ -Building packages -################################ - -Les sous repertoires du repertoire "build" contiennent tous les fichiers -requis pour packager Dolibarr de maniere automatisee. -On trouve plusieurs outils: - -- Pour construire un package Dolibarr complet, il suffit de -> Editer la version dans le fichier makepack-dolibarr.pl -> Lancer la commande perl makepack-dolibarr.pl - -- Pour construire un package d'une traduction, il suffit de lancer le script -> perl makepack-dolibarrlang.pl - -- Pour construire un package d'un theme, il suffit de lancer le script -> perl makepack-dolibarrtheme.pl - -- Pour construire un package d'un module, il suffit de lancer le script -> perl makepack-dolibarrmodule.pl - -- Pour construire un package DoliWamp autoexe: -> Installer InnoSetup (http://www.jrsoftware.org) -> Installer WampServer dans "C:\Program Files\Wamp" (http://www.wampserver.com) -> Installer les addon WampServer afin d'y mettre les versions: - Apache2.2.6, Mysql5.0.45, Php5.2.5 -> Modifier dans le fichier build/exe/doliwamp.iss la variable SourceDir - afin d'y mettre le repository Dolibarr. -> Modifier AppVerName et OutputBaseFilename. -> Lancer innosetup, ouvrir le fichier build/exe/doliwamp.iss et cliquer sur - le bouton "Compile". Le fichier .exe sera fabrique dans le repertoire build. - -- Pour generer la documentation developpeur, lancer le script -> perl dolybarr-doxygen-build.pl - - -Note: - -Le repertoire build et tout ce qu'il contient n'est absolument pas requis -pour faire fonctionner Dolibarr. Ils ne servent qu'a la generation des -packages. Certains packages, une fois construit, n'incluent par le repertoire -"build". - -On trouve dans le repertoire "build", les sous-repertoires utilises par -l'outil makepack-dolibarr.pl: - -* deb: -Fichier de config pour construire un package Debian. - -* rpm: -Fichier de config pour construire un package Redhat ou Mandrake. - -* tgz: -Fichier de config pour construire un package tgz. - -* exe: -Fichier de config pour construire un package exe pour Windows des sources -ou pour construire l'assistant d'installation complet DoliWamp. - -* zip: -Fichier de config pour construire un package zip. - -* live: -Fichier pour fabriquer un live CD de demo de Dolibarr. - -* patch: -Fichier exemple de generation de fichier patch pour diffusion d'une -modification de Dolibarr. - -* doap: -Fichier descriptif DOAP pour promouvoir/decrire la version de Dolibarr. - -* pad: -Fichier descriptif PAD pour promouvoir/decrire la version de Dolibarr. - -* dmg: -Fichier de config pour construire un package dmg DoliMamp pour Mac OS X diff --git a/build/debian/control b/build/debian/control index 9a76856505a..d5c4a913713 100755 --- a/build/debian/control +++ b/build/debian/control @@ -26,11 +26,11 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | # Misc dependencies # fonts-dejavu-core | ttf-dejavu-core, xdg-utils, - mysql-server, - mysql-client, + virtual-mysql-client, ${misc:Depends}, ${perl:Depends} -Recommends: apache2 | lighttpd | httpd +Recommends: apache2 | lighttpd | httpd, + virtual-mysql-server Suggests: www-browser, php5-geoip Description: Web based software to manage a company or foundation Dolibarr ERP & CRM is an easy to use open source/free software package for diff --git a/build/generate_filecheck_xml.php b/build/generate_filelist_xml.php similarity index 85% rename from build/generate_filecheck_xml.php rename to build/generate_filelist_xml.php index 665bb3a65d1..1bc0e2b6620 100644 --- a/build/generate_filecheck_xml.php +++ b/build/generate_filelist_xml.php @@ -32,11 +32,33 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit; } +require_once($path."../htdocs/master.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); -// Main + +/* + * Main + */ + +if (empty($argv[1])) +{ + print "Usage: ".$script_file." release=x.y.z\n"; + exit -1; +} parse_str($argv[1]); + +if ($release != DOL_VERSION) +{ + print 'Error: release is not version declared into filefunc.in.php.'."\n"; + exit -1; +} + //$outputfile=dirname(__FILE__).'/../htdocs/install/filelist-'.$release.'.xml'; -$outputfile=dirname(__FILE__).'/../htdocs/install/filelist.xml'; +$outputdir=dirname(__FILE__).'/../htdocs/install'; +print 'Delete current files '.$outputdir.'/filelist*.xml'."\n"; +dol_delete_file($outputdir.'/filelist*.xml',0,1,1); + +$outputfile=$outputdir.'/filelist-'.$release.'.xml'; $fp = fopen($outputfile,'w'); fputs($fp, ''."\n"); fputs($fp, ''."\n"); diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 809f279756c..1883f1814da 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -317,8 +317,13 @@ print "\n"; if ($CHOOSEDTARGET{'-CHKSUM'}) { print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filecheck_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n"; - $ret=`php $SOURCE/build/generate_filecheck_xml.php release=$MAJOR.$MINOR.$BUILD`; + $ret=`php $SOURCE/build/generate_filelist_xml.php release=$MAJOR.$MINOR.$BUILD`; print $ret."\n"; + # Copy to final dir + $NEWDESTI=$DESTI; + print "Copy \"$SOURCE/htdocs/install/filelist-$MAJOR.$MINOR.$BUILD.xml\" to $NEWDESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml\n"; + use File::Copy qw(copy); + copy "$SOURCE/htdocs/install/filelist-$MAJOR.$MINOR.$BUILD.xml", "$NEWDESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"; } @@ -603,7 +608,7 @@ if ($nboftargetok) { if ($target eq 'TGZ') { $NEWDESTI=$DESTI; - if ($NEWPUBLISH =~ /stable/) + if ($NEWDESTI =~ /stable/) { mkdir($DESTI.'/standard'); if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } @@ -635,7 +640,7 @@ if ($nboftargetok) { if ($target eq 'XZ') { $NEWDESTI=$DESTI; - if ($NEWPUBLISH =~ /stable/) + if ($NEWDESTI =~ /stable/) { mkdir($DESTI.'/standard'); if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } @@ -672,7 +677,7 @@ if ($nboftargetok) { if ($target eq 'ZIP') { $NEWDESTI=$DESTI; - if ($NEWPUBLISH =~ /stable/) + if ($NEWDESTI =~ /stable/) { mkdir($DESTI.'/standard'); if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } @@ -713,7 +718,7 @@ if ($nboftargetok) { if ($target =~ /FEDO/i) { $subdir="package_rpm_redhat-fedora"; } if ($target =~ /MAND/i) { $subdir="package_rpm_mandriva"; } if ($target =~ /OPEN/i) { $subdir="package_rpm_opensuse"; } - if ($NEWPUBLISH =~ /stable/) + if ($NEWDESTI =~ /stable/) { mkdir($DESTI.'/'.$subdir); if (-d $DESTI.'/'.$subdir) { $NEWDESTI=$DESTI.'/'.$subdir; } @@ -799,7 +804,7 @@ if ($nboftargetok) { if ($target eq 'DEB') { $NEWDESTI=$DESTI; - if ($NEWPUBLISH =~ /stable/) + if ($NEWDESTI =~ /stable/) { mkdir($DESTI.'/package_debian-ubuntu'); if (-d $DESTI.'/package_debian-ubuntu') { $NEWDESTI=$DESTI.'/package_debian-ubuntu'; } @@ -1002,7 +1007,7 @@ if ($nboftargetok) { if ($target eq 'APS') { $NEWDESTI=$DESTI; - if ($NEWPUBLISH =~ /stable/) + if ($NEWDESTI =~ /stable/) { mkdir($DESTI.'/package_aps'); if (-d $DESTI.'/package_aps') { $NEWDESTI=$DESTI.'/package_aps'; } @@ -1088,7 +1093,7 @@ if ($nboftargetok) { if ($target eq 'EXEDOLIWAMP') { $NEWDESTI=$DESTI; - if ($NEWPUBLISH =~ /stable/) + if ($NEWDESTI =~ /stable/) { mkdir($DESTI.'/package_windows'); if (-d $DESTI.'/package_windows') { $NEWDESTI=$DESTI.'/package_windows'; } @@ -1132,6 +1137,7 @@ if ($nboftargetok) { print "\nList of files to publish (BUILD=$BUILD)\n"; %filestoscansf=( + "$DESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"=>'signatures', "$DESTI/package_rpm_generic/$FILENAMERPM"=>'Dolibarr installer for Fedora-Redhat-Mandriva-Opensuse (DoliRpm)', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'Dolibarr installer for Debian-Ubuntu (DoliDeb)', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'none', @@ -1140,6 +1146,7 @@ if ($nboftargetok) { "$DESTI/standard/$FILENAMETGZ.zip"=>'Dolibarr ERP-CRM' ); %filestoscanstableasso=( + "$DESTI/signatures/filelist-$MAJOR.$MINOR.$BUILD.xml"=>'signatures', "$DESTI/package_rpm_generic/$FILENAMERPM"=>'package_rpm_generic', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', diff --git a/composer.json b/composer.json index 87f9822f376..2aa9dd216d6 100644 --- a/composer.json +++ b/composer.json @@ -2,14 +2,22 @@ "name": "dolibarr/dolibarr", "type": "project", "description": "Dolibarr ERP & CRM is a modern and easy to use web software to manage your business", - "keywords": ["erp","crm","invoice","sme","proposal","order","stock"], - "homepage": "http://www.dolibarr.org", + "keywords": [ + "erp", + "crm", + "invoice", + "sme", + "proposal", + "order", + "stock", + "agenda" + ], + "homepage": "https://www.dolibarr.org", "license": "GPL-3.0+", "support": { "issues": "https://github.com/Dolibarr/dolibarr/issues", - "forum": "http://www.dolibarr.org/forum", - "wiki": "http://wiki.dolibarr.org", - "irc": "irc://chat.freenode.net/dolibarr", + "forum": "https://www.dolibarr.org/forum", + "wiki": "https://wiki.dolibarr.org", "source": "https://github.com/Dolibarr/dolibarr" }, "config": { @@ -47,7 +55,6 @@ "ext-soap": "Native SOAP", "ext-zip": "ODT and Excel support", "ext-xml": "Excel support", - "firephp/firephp-core": "Logging to Firebug console support", - "raven/raven": "Sentry logging server support" + "firephp/firephp-core": "Logging to Firebug console support" } } diff --git a/dev/README b/dev/README index 88011d07509..337928507fc 100644 --- a/dev/README +++ b/dev/README @@ -7,7 +7,7 @@ provided with a standard release. There is also some documentation on Dolibarr Wiki: -http://wiki.dolibarr.org/ +https://wiki.dolibarr.org/ and -http://www.dolibarr.org/html_doxygen/index.html +https://doxygen.dolibarr.org/ diff --git a/dev/examples/README b/dev/examples/code/README similarity index 100% rename from dev/examples/README rename to dev/examples/code/README diff --git a/dev/examples/create_invoice.php b/dev/examples/code/create_invoice.php similarity index 100% rename from dev/examples/create_invoice.php rename to dev/examples/code/create_invoice.php diff --git a/dev/examples/create_order.php b/dev/examples/code/create_order.php similarity index 100% rename from dev/examples/create_order.php rename to dev/examples/code/create_order.php diff --git a/dev/examples/create_product.php b/dev/examples/code/create_product.php similarity index 100% rename from dev/examples/create_product.php rename to dev/examples/code/create_product.php diff --git a/dev/examples/create_user.php b/dev/examples/code/create_user.php similarity index 100% rename from dev/examples/create_user.php rename to dev/examples/code/create_user.php diff --git a/dev/examples/get_contracts.php b/dev/examples/code/get_contracts.php similarity index 100% rename from dev/examples/get_contracts.php rename to dev/examples/code/get_contracts.php diff --git a/dev/ical/event_recu.txt b/dev/examples/ical/event_recu.txt similarity index 100% rename from dev/ical/event_recu.txt rename to dev/examples/ical/event_recu.txt diff --git a/dev/ldap/README b/dev/examples/ldap/README similarity index 100% rename from dev/ldap/README rename to dev/examples/ldap/README diff --git a/dev/ldap/ldapadd_sample1.txt b/dev/examples/ldap/ldapadd_sample1.txt similarity index 100% rename from dev/ldap/ldapadd_sample1.txt rename to dev/examples/ldap/ldapadd_sample1.txt diff --git a/dev/ldap/ldapadd_sample2.txt b/dev/examples/ldap/ldapadd_sample2.txt similarity index 100% rename from dev/ldap/ldapadd_sample2.txt rename to dev/examples/ldap/ldapadd_sample2.txt diff --git a/dev/ldap/ldapadd_sample3.txt b/dev/examples/ldap/ldapadd_sample3.txt similarity index 100% rename from dev/ldap/ldapadd_sample3.txt rename to dev/examples/ldap/ldapadd_sample3.txt diff --git a/dev/ldap/ldapdelete_sample1.txt b/dev/examples/ldap/ldapdelete_sample1.txt similarity index 100% rename from dev/ldap/ldapdelete_sample1.txt rename to dev/examples/ldap/ldapdelete_sample1.txt diff --git a/dev/ldap/ldapdelete_sample3.txt b/dev/examples/ldap/ldapdelete_sample3.txt similarity index 100% rename from dev/ldap/ldapdelete_sample3.txt rename to dev/examples/ldap/ldapdelete_sample3.txt diff --git a/dev/ldap/ldapmodify_sample1.txt b/dev/examples/ldap/ldapmodify_sample1.txt similarity index 100% rename from dev/ldap/ldapmodify_sample1.txt rename to dev/examples/ldap/ldapmodify_sample1.txt diff --git a/dev/ldap/ldapsearch_sample1.txt b/dev/examples/ldap/ldapsearch_sample1.txt similarity index 100% rename from dev/ldap/ldapsearch_sample1.txt rename to dev/examples/ldap/ldapsearch_sample1.txt diff --git a/dev/ldap/setup_example_activedirectory.jpg b/dev/examples/ldap/setup_example_activedirectory.jpg similarity index 100% rename from dev/ldap/setup_example_activedirectory.jpg rename to dev/examples/ldap/setup_example_activedirectory.jpg diff --git a/dev/mail/README b/dev/examples/mail/README similarity index 100% rename from dev/mail/README rename to dev/examples/mail/README diff --git a/dev/mail/dolibarr_mail_attachement.txt b/dev/examples/mail/dolibarr_mail_attachement.txt similarity index 100% rename from dev/mail/dolibarr_mail_attachement.txt rename to dev/examples/mail/dolibarr_mail_attachement.txt diff --git a/dev/mail/dolibarr_mail_attachementHTML.txt b/dev/examples/mail/dolibarr_mail_attachementHTML.txt similarity index 100% rename from dev/mail/dolibarr_mail_attachementHTML.txt rename to dev/examples/mail/dolibarr_mail_attachementHTML.txt diff --git a/dev/mail/dolibarr_mail_attachementwithimageHTML.txt b/dev/examples/mail/dolibarr_mail_attachementwithimageHTML.txt similarity index 100% rename from dev/mail/dolibarr_mail_attachementwithimageHTML.txt rename to dev/examples/mail/dolibarr_mail_attachementwithimageHTML.txt diff --git a/dev/mail/dolibarr_mail_simple.txt b/dev/examples/mail/dolibarr_mail_simple.txt similarity index 100% rename from dev/mail/dolibarr_mail_simple.txt rename to dev/examples/mail/dolibarr_mail_simple.txt diff --git a/dev/mail/dolibarr_mail_simpleHTML.txt b/dev/examples/mail/dolibarr_mail_simpleHTML.txt similarity index 100% rename from dev/mail/dolibarr_mail_simpleHTML.txt rename to dev/examples/mail/dolibarr_mail_simpleHTML.txt diff --git a/dev/mail/dolibarr_mail_universal.txt b/dev/examples/mail/dolibarr_mail_universal.txt similarity index 100% rename from dev/mail/dolibarr_mail_universal.txt rename to dev/examples/mail/dolibarr_mail_universal.txt diff --git a/dev/mail/dolibarr_mail_withimageHTML.txt b/dev/examples/mail/dolibarr_mail_withimageHTML.txt similarity index 100% rename from dev/mail/dolibarr_mail_withimageHTML.txt rename to dev/examples/mail/dolibarr_mail_withimageHTML.txt diff --git a/dev/mail/source_email_from_thirdparty.txt b/dev/examples/mail/source_email_from_thirdparty.txt similarity index 100% rename from dev/mail/source_email_from_thirdparty.txt rename to dev/examples/mail/source_email_from_thirdparty.txt diff --git a/dev/initdemo/removedemo.sh b/dev/initdemo/removeconfdemo.sh similarity index 100% rename from dev/initdemo/removedemo.sh rename to dev/initdemo/removeconfdemo.sh diff --git a/dev/cliparts/commons.svg b/dev/resources/cliparts/commons.svg similarity index 100% rename from dev/cliparts/commons.svg rename to dev/resources/cliparts/commons.svg diff --git a/dev/dbmodel/dolibarr.uml b/dev/resources/dbmodel/dolibarr.uml similarity index 100% rename from dev/dbmodel/dolibarr.uml rename to dev/resources/dbmodel/dolibarr.uml diff --git a/dev/dbmodel/dolibarr.umldi b/dev/resources/dbmodel/dolibarr.umldi similarity index 100% rename from dev/dbmodel/dolibarr.umldi rename to dev/resources/dbmodel/dolibarr.umldi diff --git a/dev/dbmodel/dolibarr_schema.mwb b/dev/resources/dbmodel/dolibarr_schema.mwb similarity index 100% rename from dev/dbmodel/dolibarr_schema.mwb rename to dev/resources/dbmodel/dolibarr_schema.mwb diff --git a/dev/iso-normes/GURULABS-RPM-GUIDE-v1.0.PDF b/dev/resources/iso-normes/GURULABS-RPM-GUIDE-v1.0.PDF similarity index 100% rename from dev/iso-normes/GURULABS-RPM-GUIDE-v1.0.PDF rename to dev/resources/iso-normes/GURULABS-RPM-GUIDE-v1.0.PDF diff --git a/dev/iso-normes/address_format.txt b/dev/resources/iso-normes/address_format.txt similarity index 100% rename from dev/iso-normes/address_format.txt rename to dev/resources/iso-normes/address_format.txt diff --git a/dev/iso-normes/banknumber_format.txt b/dev/resources/iso-normes/banknumber_format.txt similarity index 100% rename from dev/iso-normes/banknumber_format.txt rename to dev/resources/iso-normes/banknumber_format.txt diff --git a/dev/iso-normes/barcode_EAN13.txt b/dev/resources/iso-normes/barcode_EAN13.txt similarity index 100% rename from dev/iso-normes/barcode_EAN13.txt rename to dev/resources/iso-normes/barcode_EAN13.txt diff --git a/dev/iso-normes/countries_iso-3166_en.txt b/dev/resources/iso-normes/countries_iso-3166_en.txt similarity index 100% rename from dev/iso-normes/countries_iso-3166_en.txt rename to dev/resources/iso-normes/countries_iso-3166_en.txt diff --git a/dev/iso-normes/countries_iso-3166_fr.txt b/dev/resources/iso-normes/countries_iso-3166_fr.txt similarity index 100% rename from dev/iso-normes/countries_iso-3166_fr.txt rename to dev/resources/iso-normes/countries_iso-3166_fr.txt diff --git a/dev/iso-normes/currencies_iso-4217.txt b/dev/resources/iso-normes/currencies_iso-4217.txt similarity index 100% rename from dev/iso-normes/currencies_iso-4217.txt rename to dev/resources/iso-normes/currencies_iso-4217.txt diff --git a/dev/iso-normes/fichier_norme_AFB-CFONB.pdf b/dev/resources/iso-normes/fichier_norme_AFB-CFONB.pdf similarity index 100% rename from dev/iso-normes/fichier_norme_AFB-CFONB.pdf rename to dev/resources/iso-normes/fichier_norme_AFB-CFONB.pdf diff --git a/dev/iso-normes/format_FEC-Lien_outil_de_test_agréé.pdf b/dev/resources/iso-normes/format_FEC-Lien_outil_de_test_agréé.pdf similarity index 100% rename from dev/iso-normes/format_FEC-Lien_outil_de_test_agréé.pdf rename to dev/resources/iso-normes/format_FEC-Lien_outil_de_test_agréé.pdf diff --git a/dev/iso-normes/format_FEC.pdf b/dev/resources/iso-normes/format_FEC.pdf similarity index 100% rename from dev/iso-normes/format_FEC.pdf rename to dev/resources/iso-normes/format_FEC.pdf diff --git a/dev/iso-normes/iban_iso-13616.txt b/dev/resources/iso-normes/iban_iso-13616.txt similarity index 100% rename from dev/iso-normes/iban_iso-13616.txt rename to dev/resources/iso-normes/iban_iso-13616.txt diff --git a/dev/iso-normes/languages_iso-639.txt b/dev/resources/iso-normes/languages_iso-639.txt similarity index 100% rename from dev/iso-normes/languages_iso-639.txt rename to dev/resources/iso-normes/languages_iso-639.txt diff --git a/dev/iso-normes/locales.txt b/dev/resources/iso-normes/locales.txt similarity index 100% rename from dev/iso-normes/locales.txt rename to dev/resources/iso-normes/locales.txt diff --git a/dev/iso-normes/vat_number_names.txt b/dev/resources/iso-normes/vat_number_names.txt similarity index 100% rename from dev/iso-normes/vat_number_names.txt rename to dev/resources/iso-normes/vat_number_names.txt diff --git a/dev/iso-normes/world_tax_rates.txt b/dev/resources/iso-normes/world_tax_rates.txt similarity index 100% rename from dev/iso-normes/world_tax_rates.txt rename to dev/resources/iso-normes/world_tax_rates.txt diff --git a/dev/iso-normes/xmlexport.txt b/dev/resources/iso-normes/xmlexport.txt similarity index 100% rename from dev/iso-normes/xmlexport.txt rename to dev/resources/iso-normes/xmlexport.txt diff --git a/dev/licence/Links on GPL.txt b/dev/resources/licence/Links on GPL.txt similarity index 100% rename from dev/licence/Links on GPL.txt rename to dev/resources/licence/Links on GPL.txt diff --git a/dev/licence/quick-guide-gplv3-compatibility.png b/dev/resources/licence/quick-guide-gplv3-compatibility.png similarity index 100% rename from dev/licence/quick-guide-gplv3-compatibility.png rename to dev/resources/licence/quick-guide-gplv3-compatibility.png diff --git a/dev/codesniffer/README b/dev/setup/codesniffer/README similarity index 100% rename from dev/codesniffer/README rename to dev/setup/codesniffer/README diff --git a/dev/codesniffer/php.ini b/dev/setup/codesniffer/php.ini similarity index 100% rename from dev/codesniffer/php.ini rename to dev/setup/codesniffer/php.ini diff --git a/dev/codesniffer/ruleset.dtd b/dev/setup/codesniffer/ruleset.dtd similarity index 100% rename from dev/codesniffer/ruleset.dtd rename to dev/setup/codesniffer/ruleset.dtd diff --git a/dev/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml similarity index 100% rename from dev/codesniffer/ruleset.xml rename to dev/setup/codesniffer/ruleset.xml diff --git a/dev/codetemplates/README b/dev/setup/codetemplates/README similarity index 100% rename from dev/codetemplates/README rename to dev/setup/codetemplates/README diff --git a/dev/codetemplates/codetemplates.dtd b/dev/setup/codetemplates/codetemplates.dtd similarity index 100% rename from dev/codetemplates/codetemplates.dtd rename to dev/setup/codetemplates/codetemplates.dtd diff --git a/dev/codetemplates/codetemplates.xml b/dev/setup/codetemplates/codetemplates.xml similarity index 100% rename from dev/codetemplates/codetemplates.xml rename to dev/setup/codetemplates/codetemplates.xml diff --git a/dev/multitail/.multitailrc b/dev/setup/multitail/.multitailrc similarity index 100% rename from dev/multitail/.multitailrc rename to dev/setup/multitail/.multitailrc diff --git a/dev/phpunit/README b/dev/setup/phpunit/README similarity index 100% rename from dev/phpunit/README rename to dev/setup/phpunit/README diff --git a/dev/phpunit/eclipse_setup_for_pti_phpunit.png b/dev/setup/phpunit/eclipse_setup_for_pti_phpunit.png similarity index 100% rename from dev/phpunit/eclipse_setup_for_pti_phpunit.png rename to dev/setup/phpunit/eclipse_setup_for_pti_phpunit.png diff --git a/dev/security/README b/dev/setup/security/README similarity index 100% rename from dev/security/README rename to dev/setup/security/README diff --git a/dev/security/htaccess.txt b/dev/setup/security/htaccess.txt similarity index 100% rename from dev/security/htaccess.txt rename to dev/setup/security/htaccess.txt diff --git a/dev/xdebug/README b/dev/setup/xdebug/README similarity index 100% rename from dev/xdebug/README rename to dev/setup/xdebug/README diff --git a/dev/xdebug/eclipse_setup_for_xdebug.jpg b/dev/setup/xdebug/eclipse_setup_for_xdebug.jpg similarity index 100% rename from dev/xdebug/eclipse_setup_for_xdebug.jpg rename to dev/setup/xdebug/eclipse_setup_for_xdebug.jpg diff --git a/dev/skeletons/README b/dev/skeletons/README index 02a760a53dc..5b5b992d91e 100644 --- a/dev/skeletons/README +++ b/dev/skeletons/README @@ -2,24 +2,32 @@ README (English) -------------------------------- This directory contains PHP script samples that can be used to start a development on Dolibarr. -build_class_from_table.php: + +*** build_class_from_table.php: + This is the script to use to generate PHP code of a PHP POJO class object, a PHP script that use this POJO. This script use the files skeleton_*.php to build its generated code. -modMyModule.class.php: +*** modMyModule.class.php: + Is a sample of module descriptor that you can use if you want to build a new module/plugin for Dolibarr. -skeleton_script.php: +*** skeleton_script.php: + Is a sample you can use as an example if you need to build a script to run on command line -skeleton_page.php: + +*** skeleton_page.php: + Is a sample you can use as an example if you need to build an HTML page to include in Dolibarr GUI. -skeleton_class.class.php: + +*** skeleton_class.class.php: + Is a sample you can use as an example if you need to build a class file to access a new table required by a Dolibarr development. However it is better to run the build_class_from_table.php script that accepts a table name as a parameter and will uses the description table within database and the skeleton_class.class.php file to generate full code for your class file. After running this script, the class to access your table (insert a record, update, delete and select) is directly finished and can be used by your module's code. diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 22432433334..64890b9d9cf 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -62,7 +62,7 @@ class modMyModule extends DolibarrModules $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "Description of module MyModule"; - $this->descriptionlong = "A very lon description. Can be a full HTML content"; + $this->descriptionlong = "A very long description. Can be a full HTML content"; $this->editor_name = 'Editor name'; $this->editor_url = 'http://www.dolibarr.org'; @@ -105,9 +105,9 @@ class modMyModule extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("mylangfile@mymodule"); diff --git a/dev/skeletons/skeleton_card.php b/dev/skeletons/skeleton_card.php index 53cacc2b10f..9adcdba87de 100644 --- a/dev/skeletons/skeleton_card.php +++ b/dev/skeletons/skeleton_card.php @@ -59,25 +59,27 @@ $myparam = GETPOST('myparam','alpha'); $search_field1=GETPOST("search_field1"); $search_field2=GETPOST("search_field2"); +if (empty($action) && empty($id) && empty($ref)) $action='view'; + // Protection if external user if ($user->societe_id > 0) { //accessforbidden(); } +//$result = restrictedArea($user, 'mymodule', $id); -if (empty($action) && empty($id) && empty($ref)) $action='list'; -// Load object if id or ref is provided as parameter -$object=new Skeleton_Class($db); -if (($id > 0 || ! empty($ref)) && $action != 'add') -{ - $result=$object->fetch($id,$ref); - if ($result < 0) dol_print_error($db); -} +$object = new Skeleton_Class($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('skeleton')); -$extrafields = new ExtraFields($db); @@ -281,8 +283,13 @@ if (($id || $ref) && $action == 'edit') // Part to show record -if ($id && (empty($action) || $action == 'view' || $action == 'delete')) +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $res = $object->fetch_optionals($object->id, $extralabels); + + $head = commande_prepare_head($object); + dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); + print load_fiche_titre($langs->trans("MyModule")); dol_fiche_head(); @@ -293,7 +300,7 @@ if ($id && (empty($action) || $action == 'view' || $action == 'delete')) } print ''."\n"; - // print ''; + // print ''; // LIST_OF_TD_LABEL_FIELDS_VIEW print '
'.$langs->trans("Label").'
'.$langs->trans("Label").''.$object->label.'
'; diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 3e4c2701896..86603642362 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -181,6 +181,16 @@ class Skeleton_Class extends CommonObject $this->prop2 = $obj->field2; //... } + + // Retrieve all extrafields for invoice + // fetch optionals attributes and labels + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + + // $this->fetch_lines(); + $this->db->free($resql); if ($numrows) { @@ -355,6 +365,8 @@ class Skeleton_Class extends CommonObject } } + // If you need to delete child tables to, you can insert them here + if (!$error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; $sql .= ' WHERE rowid=' . $this->id; @@ -427,8 +439,7 @@ class Skeleton_Class extends CommonObject } /** - * Return a link to the user card (with optionaly the picto) - * Use this->id,this->lastname, this->firstname + * Return a link to the object card (with optionaly the picto) * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param string $option On what the link point to @@ -451,7 +462,7 @@ class Skeleton_Class extends CommonObject $label.= '
'; $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; - $link = 'table_name.'_card.php?id='.$this->id.'"'; $link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"'); $link.= '>'; $linkend=''; @@ -477,13 +488,13 @@ class Skeleton_Class extends CommonObject } /** - * Renvoi le libelle d'un status donne + * Return the status * * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($status,$mode=0) + static function LibStatut($status,$mode=0) { global $langs; diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 1facee1306e..0ca6962bbef 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -256,11 +256,11 @@ if ($resql) $arrayofselected=is_array($toselect)?$toselect:array(); - $params=''; + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_field1 != '') $params.= '&search_field1='.urlencode($search_field1); - if ($search_field2 != '') $params.= '&search_field2='.urlencode($search_field2); + if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1); + if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2); if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields foreach ($search_array_options as $key => $val) @@ -286,7 +286,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); if ($sall) { @@ -319,8 +319,8 @@ if ($resql) // Fields title print ''; // LIST_OF_TD_TITLE_FIELDS - //if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$params,'',$sortfield,$sortorder); - //if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$params,'',$sortfield,$sortorder); + //if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder); + //if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { diff --git a/dev/detectnotabfiles.sh b/dev/tools/detectnotabfiles.sh similarity index 100% rename from dev/detectnotabfiles.sh rename to dev/tools/detectnotabfiles.sh diff --git a/dev/fixaltlanguages.sh b/dev/tools/fixaltlanguages.sh similarity index 100% rename from dev/fixaltlanguages.sh rename to dev/tools/fixaltlanguages.sh diff --git a/dev/fixdosfiles.sh b/dev/tools/fixdosfiles.sh similarity index 100% rename from dev/fixdosfiles.sh rename to dev/tools/fixdosfiles.sh diff --git a/dev/fixduplicatelangkey.sh b/dev/tools/fixduplicatelangkey.sh similarity index 100% rename from dev/fixduplicatelangkey.sh rename to dev/tools/fixduplicatelangkey.sh diff --git a/dev/fixduplicatelines.sh b/dev/tools/fixduplicatelines.sh similarity index 100% rename from dev/fixduplicatelines.sh rename to dev/tools/fixduplicatelines.sh diff --git a/dev/fixperms.sh b/dev/tools/fixperms.sh similarity index 100% rename from dev/fixperms.sh rename to dev/tools/fixperms.sh diff --git a/dev/fixutf8bomfiles.sh b/dev/tools/fixutf8bomfiles.sh similarity index 100% rename from dev/fixutf8bomfiles.sh rename to dev/tools/fixutf8bomfiles.sh diff --git a/dev/optimize_images.sh b/dev/tools/optimize_images.sh similarity index 100% rename from dev/optimize_images.sh rename to dev/tools/optimize_images.sh diff --git a/dev/resize_window.sh b/dev/tools/resize_window.sh similarity index 100% rename from dev/resize_window.sh rename to dev/tools/resize_window.sh diff --git a/dev/rmphpclosingtag.sh b/dev/tools/rmphpclosingtag.sh similarity index 100% rename from dev/rmphpclosingtag.sh rename to dev/tools/rmphpclosingtag.sh diff --git a/dev/test/testdiv.php b/dev/tools/test/testdiv.php similarity index 100% rename from dev/test/testdiv.php rename to dev/tools/test/testdiv.php diff --git a/dev/test/testtcpdf.php b/dev/tools/test/testtcpdf.php similarity index 100% rename from dev/test/testtcpdf.php rename to dev/tools/test/testtcpdf.php diff --git a/dev/test/testutf.php b/dev/tools/test/testutf.php similarity index 100% rename from dev/test/testutf.php rename to dev/tools/test/testutf.php diff --git a/doc/images/dolibarr_screenshot1_1280x800.jpg b/doc/images/dolibarr_screenshot1_1280x800.jpg new file mode 100644 index 00000000000..c6d5776d1fc Binary files /dev/null and b/doc/images/dolibarr_screenshot1_1280x800.jpg differ diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 2f7228eb9d4..63f99184884 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -19,7 +19,7 @@ /** * \file htdocs/accountancy/admin/account.php - * \ingroup Advanced accountancy + * \ingroup Advanced accountancy * \brief List accounting account */ require '../../main.inc.php'; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 1dcb2a533de..934e5f1f081 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -19,7 +19,7 @@ /** * \file htdocs/accountancy/admin/card.php - * \ingroup Advanced accountancy + * \ingroup Advanced accountancy * \brief Card of accounting account */ require '../../main.inc.php'; @@ -43,13 +43,13 @@ $rowid = GETPOST('rowid', 'int'); $cancel = GETPOST('cancel'); // Security check -if (! $user->admin) - accessforbidden(); + $object = new AccountingAccount($db); // Action -if ($action == 'add') { +if ($action == 'add' && $user->rights->accounting->chartofaccount) +{ if (! $cancel) { $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; @@ -69,10 +69,10 @@ if ($action == 'add') { $account_number = clean_account(GETPOST('account_number')); } - if (GETPOST('account_category') <= 0) { - $account_parent = ''; + if (GETPOST('account_parent') <= 0) { + $account_parent = 0; } else { - $account_parent = GETPOST('account_category','int'); + $account_parent = GETPOST('account_parent','int'); } $object->fk_pcg_version = $obj->pcg_version; @@ -97,8 +97,8 @@ if ($action == 'add') { } header("Location: account.php"); exit; -} else if ($action == 'edit') { - if (! GETPOST('cancel', 'alpha')) { +} else if ($action == 'edit' && $user->rights->accounting->chartofaccount) { + if (! $cancel) { $result = $object->fetch($id); $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; @@ -119,10 +119,10 @@ if ($action == 'add') { $account_number = clean_account(GETPOST('account_number')); } - if (GETPOST('account_category') <= 0) { - $account_parent = ''; + if (GETPOST('account_parent') <= 0) { + $account_parent = 0; } else { - $account_parent = GETPOST('account_category','int'); + $account_parent = GETPOST('account_parent','int'); } $object->fk_pcg_version = $obj->pcg_version; @@ -145,7 +145,7 @@ if ($action == 'add') { header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit(); } -} else if ($action == 'delete') { +} else if ($action == 'delete' && $user->rights->accounting->chartofaccount) { $result = $object->fetch($id); if (! empty($object->id)) { @@ -165,7 +165,9 @@ if ($action == 'add') { /* * View */ -llxheader('', $langs->trans('AccountAccounting')); +$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card'); +$helpurl = ''; +llxheader('', $title, $helpurl); $form = new Form($db); $htmlacc = new FormVentilation($db); @@ -184,7 +186,7 @@ if ($action == 'create') { print ''; // Account number - print ''; + print ''; print ''; // Label @@ -247,7 +249,7 @@ if ($action == 'create') { print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("AccountNumber") . '
'; // Account number - print ''; + print ''; print ''; // Label @@ -299,7 +301,7 @@ if ($action == 'create') { print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("AccountNumber") . '
'; // Account number - print ''; + print ''; print ''; print ''; @@ -327,14 +329,14 @@ if ($action == 'create') { print ''; // Active - print ''; + print ''; print ''; @@ -348,13 +350,13 @@ if ($action == 'create') { print '
'; - if ($user->admin) { + if (! empty($user->rights->accounting->chartofaccount)) { print '' . $langs->trans('Modify') . ''; } else { print '' . $langs->trans('Modify') . ''; } - if ($user->admin) { + if (! empty($user->rights->accounting->chartofaccount)) { print '' . $langs->trans('Delete') . ''; } else { print '' . $langs->trans('Delete') . ''; diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 14d91d85581..3cb9f407ce6 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -81,6 +81,9 @@ if ($action == 'update') { if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) { $error ++; } + if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) { + dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity); + } } else { $error ++; } diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 638e9794fe8..5b767208987 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -16,12 +16,12 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear.php - * \ingroup fiscal year - * \brief Setup page to configure fiscal year + * \file htdocs/accountancy/admin/fiscalyear.php + * \ingroup Advanced accountancy + * \brief Setup page to configure fiscal year */ -require '../../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; @@ -45,9 +45,9 @@ $langs->load("compta"); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear) - accessforbidden(); - +if (! $user->rights->mouvements->lire) // If we can read accounting records, we shoul be able to see fiscal year. + accessforbidden(); + $error = 0; // List of status @@ -65,6 +65,7 @@ $errors = array (); $object = new Fiscalyear($db); + /* * Actions */ @@ -80,8 +81,8 @@ $max = 100; $form = new Form($db); $title = $langs->trans('FiscalYears'); - -llxHeader('', $title, LOG_ERR); +$helpurl = ""; +llxHeader('', $title, $helpurl); $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f"; @@ -94,7 +95,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); -} +} $sql.= $db->plimit($limit+1, $offset); @@ -102,12 +103,12 @@ $result = $db->query($sql); if ($result) { $var = false; $num = $db->num_rows($result); - + $i = 0; $title = $langs->trans('FiscalYears'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit, 1); - + // Load attribute_label print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("AccountNumber") . '' . $object->account_number . '' . $linkback . '
' . $object->pcg_subtype . '
' . $langs->trans("Activated") . '
' . $langs->trans("Status") . ''; - - if (empty($object->active)) { + print $object->getLibStatut(4); + /*if (empty($object->active)) { print img_picto($langs->trans("Disabled"), 'switch_off'); } else { print img_picto($langs->trans("Activated"), 'switch_on'); - } + }*/ print '
'; print ''; @@ -117,10 +118,10 @@ if ($result) { print ''; print ''; print ''; - + if ($num) { $fiscalyearstatic = new Fiscalyear($db); - + while ( $i < $num && $i < $max ) { $obj = $db->fetch_object($result); $fiscalyearstatic->id = $obj->rowid; @@ -137,7 +138,6 @@ if ($result) { } else { print ''; } - print '
' . $langs->trans("DateEnd") . '' . $langs->trans("Statut") . '
' . $langs->trans("None") . '
'; } else { dol_print_error($db); @@ -147,7 +147,14 @@ dol_fiche_end(); // Buttons print '
'; -print '' . $langs->trans("NewFiscalYear") . ''; +if (! empty($user->rights->accounting->fiscalyear)) +{ + print '' . $langs->trans("NewFiscalYear") . ''; +} +else +{ + print '' . $langs->trans("NewFiscalYear") . ''; +} print '
'; llxFooter(); diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index c45700ce4f5..7c5c6d08c73 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -16,8 +16,9 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear_card.php - * \brief Page to show a fiscal year + * \file htdocs/accountancy/admin/fiscalyear_card.php + * \ingroup Advanced accountancy + * \brief Page to show a fiscal year */ require '../../main.inc.php'; @@ -28,7 +29,9 @@ $langs->load("admin"); $langs->load("compta"); // Security check -if (! $user->admin) +if ($user->societe_id > 0) + accessforbidden(); +if (empty($user->rights->accounting->fiscalyear)) accessforbidden(); $error = 0; @@ -71,13 +74,13 @@ if ($action == 'confirm_delete' && $confirm == "yes") { else if ($action == 'add') { if (! GETPOST('cancel', 'alpha')) { $error = 0; - + $object->date_start = $date_start; $object->date_end = $date_end; $object->label = GETPOST('label', 'alpha'); $object->statut = GETPOST('statut', 'int'); $object->datec = dol_now(); - + if (empty($object->date_start) && empty($object->date_end)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $error ++; @@ -86,20 +89,20 @@ else if ($action == 'add') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); $error ++; } - + if (! $error) { $db->begin(); - + $id = $object->create($user); - + if ($id > 0) { $db->commit(); - + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit(); } else { $db->rollback(); - + setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; } @@ -116,12 +119,12 @@ else if ($action == 'add') { else if ($action == 'update') { if (! GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); - + $object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start; $object->date_end = empty($_POST["fiscalyearend"]) ? '' : $date_end; $object->label = GETPOST('label', 'alpha'); $object->statut = GETPOST('statut', 'int'); - + $result = $object->update($user); if ($result > 0) { @@ -136,108 +139,112 @@ else if ($action == 'update') { } } + + /* * View */ -llxHeader(); +$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card"); +$helpurl = ""; +llxHeader("",$title,$helpurl); $form = new Form($db); if ($action == 'create') { print load_fiche_titre($langs->trans("NewFiscalYear")); - + print '
'; print ''; print ''; - + dol_fiche_head(); - + print ''; - + // Label - print ''; - + print ''; + // Date start print ''; - + // Date end print ''; - + // Statut print ''; print ''; print ''; - + print '
' . $langs->trans("Label") . '
' . $langs->trans("Label") . '
' . $langs->trans("DateStart") . ''; print $form->select_date(($date_start ? $date_start : ''), 'fiscalyear'); print '
' . $langs->trans("DateEnd") . ''; print $form->select_date(($date_end ? $date_end : - 1), 'fiscalyearend'); print '
' . $langs->trans("Status") . ''; print $form->selectarray('statut', $statut2label, GETPOST('statut')); print '
'; - + dol_fiche_end(); - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; } else if ($id) { $result = $object->fetch($id); if ($result > 0) { $head = fiscalyear_prepare_head($object); - + if ($action == 'edit') { - dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); - + dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); + print '
' . "\n"; print ''; print ''; print ''; - + print ''; - + // Ref print ""; - print ''; - + // Label print ''; - + // Date start print ''; - + // Date end print ''; - + // Statut print ''; - + print '
' . $langs->trans("Ref") . ''; + print '' . $langs->trans("Ref") . ''; print $object->ref; print '
' . $langs->trans("Label") . ''; print ''; print '
' . $langs->trans("DateStart") . ''; print $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear'); print '
' . $langs->trans("DateEnd") . ''; print $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend'); print '
' . $langs->trans("Statut") . ''; print $form->selectarray('statut', $statut2label, $object->statut); print '
'; - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; - + dol_fiche_end(); } else { /* @@ -246,59 +253,61 @@ if ($action == 'create') if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete"); } - - dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); - + + dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron'); + print ''; - + $linkback = '' . $langs->trans("BackToList") . ''; - + // Ref - print ''; - + // Label print '"; - + // Date start print ''; - + // Date end print ''; - + // Statut print ''; - + print "
' . $langs->trans("Ref") . ''; + print '
' . $langs->trans("Ref") . ''; print $object->ref; - print ''; + print ''; print $linkback; print '
'; print $form->editfieldkey("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); print ''; print $form->editfieldval("Label", 'label', $object->label, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'alpha:32'); print "
'; print $form->editfieldkey("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print ''; print $form->editfieldval("DateStart", 'date_start', $object->date_start, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print '
'; print $form->editfieldkey("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print ''; print $form->editfieldval("DateEnd", 'date_end', $object->date_end, $object, $conf->global->MAIN_EDIT_ALSO_INLINE, 'datepicker'); print '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
"; - + dol_fiche_end(); + + if (! empty($user->rights->accounting->fiscalyear)) + { + /* + * Barre d'actions + */ + print '
'; + + print '' . $langs->trans('Modify') . ''; + + print '' . $langs->trans('Delete') . ''; - /* - * Barre d'actions - */ - - print '
'; - - print '' . $langs->trans('Modify') . ''; - - print '' . $langs->trans('Delete') . ''; - - print '
'; + print '
'; + } } } else { dol_print_error($db); diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php index f1f61a1f8d5..3596d73d751 100644 --- a/htdocs/accountancy/admin/fiscalyear_info.php +++ b/htdocs/accountancy/admin/fiscalyear_info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-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 @@ -16,11 +16,12 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear_card.php - * \brief Page to show info of a fiscal year + * \file htdocs/accountancy/admin/fiscalyear_info.php + * \ingroup Advanced accountancy + * \brief Page to show info of a fiscal year */ -require '../../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php'; @@ -29,27 +30,31 @@ $langs->load("admin"); $langs->load("compta"); // Security check -if (! $user->admin) +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->fiscalyear) accessforbidden(); $id = GETPOST('id', 'int'); // View -llxHeader(); +$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Info"); +$helpurl = ""; +llxHeader("",$title,$helpurl); if ($id) { $object = new Fiscalyear($db); $object->fetch($id); $object->info($id); - + $head = fiscalyear_prepare_head($object); - - dol_fiche_head($head, 'info', $langs->trans("FiscalYearCard"), 0, 'cron'); - + + dol_fiche_head($head, 'info', $langs->trans("Fiscalyear"), 0, 'cron'); + print '
'; dol_print_object_info($object); print '
'; - + print '
'; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index b019872da6e..0173ac931cc 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -168,6 +168,18 @@ if ($action == 'setmanagezero') { } } +if ($action == 'setdisabledirectinput') { + $setdisabledirectinput = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity); + if (! $res > 0) + $error ++; + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View */ @@ -342,6 +354,20 @@ if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { } print ''; +$var = ! $var; +print ""; +print '' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . ''; +if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + print "\n"; dol_fiche_end(); diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 736581e9248..7fef6dfa8fb 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -65,7 +65,7 @@ $formventilation = new FormVentilation($db); $formother = new FormOther($db); $form = new Form($db); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 5eafa920973..17bbe55158c 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 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * 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 @@ -19,8 +19,8 @@ */ /** - * \file htdocs/accountancy/bookkeeping/list.php - * \ingroup Advanced accountancy + * \file htdocs/accountancy/bookkeeping/list.php + * \ingroup Advanced accountancy * \brief List operation of book keeping */ require '../../main.inc.php'; @@ -276,7 +276,7 @@ if ($result < 0) { } if ($action == 'delmouv') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1); print $formconfirm; } if ($action == 'delbookkeepingyear') { diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 6211f5752b1..ff7f764ea31 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -47,8 +47,6 @@ class AccountancyCategory */ public function __construct($db) { $this->db = $db; - - return 1; } /** diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index ddc80e00571..d40d8147ef0 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1,10 +1,11 @@ - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Florian Henry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Pierre-Henry Favre + * Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Pierre-Henry Favre + * Copyright (C) 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 @@ -21,7 +22,9 @@ */ /** - * \file htdocs/accountancy/class/accountancyexport.class.php + * \file htdocs/accountancy/class/accountancyexport.class.php + * \ingroup Advanced accountancy + * \brief Class accountancy export */ /** @@ -157,7 +160,7 @@ class AccountancyExport */ public function exportNormal($objectLines) { global $conf; - + foreach ( $objectLines as $line ) { // Std export $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); @@ -182,15 +185,16 @@ class AccountancyExport public function exportCegid($objectLines) { foreach ( $objectLines as $line ) { $date = dol_print_date($line->doc_date, '%d%m%Y'); + $separator = ";"; - print $date . $this->separator; - print $line->code_journal . $this->separator; - print length_accountg($line->numero_compte) . $this->separator; - print ' ' . $this->separator; - print $line->sens . $this->separator; - print price($line->montant) . $this->separator; - print dol_trunc($line->label_compte, 32) . $this->separator; - print $line->doc_ref . $this->separator; + print $date . $separator; + print $line->code_journal . $separator; + print length_accountg($line->numero_compte) . $separator; + print length_accounta($line->code_tiers) . $separator; + print $line->sens . $separator; + print price($line->montant) . $separator; + print $line->label_compte . $separator; + print $line->doc_ref; print $this->end_line; } } @@ -295,6 +299,8 @@ class AccountancyExport public function exportCiel(&$TData) { global $conf; + $this->end_line ="\r\n"; + $i = 1; $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd foreach ( $TData as $data ) { @@ -333,6 +339,8 @@ class AccountancyExport public function exportQuadratus(&$TData) { global $conf; + $this->end_line ="\r\n"; + $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy foreach ( $TData as $data ) { $code_compta = $data->numero_compte; diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 690f3785df1..00a16a227e3 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -45,7 +45,8 @@ class AccountingAccount extends CommonObject var $label; var $fk_user_author; var $fk_user_modif; - var $active; + var $active; // duplicate with status + var $status; /** * Constructor @@ -103,6 +104,7 @@ class AccountingAccount extends CommonObject $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; $this->active = $obj->active; + $this->status = $obj->active; return $this->id; } else { @@ -465,4 +467,61 @@ class AccountingAccount extends CommonObject return - 1; } } + + + /** + * Retourne le libelle du statut d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function LibStatut($statut,$mode=0) + { + global $langs; + $langs->load('users'); + + if ($mode == 0) + { + $prefix=''; + if ($statut == 1) return $langs->trans('Enabled'); + if ($statut == 0) return $langs->trans('Disabled'); + } + if ($mode == 1) + { + if ($statut == 1) return $langs->trans('Enabled'); + if ($statut == 0) return $langs->trans('Disabled'); + } + if ($mode == 2) + { + if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 3) + { + if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4'); + if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5'); + } + if ($mode == 4) + { + if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 5) + { + if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } + } } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 5832d44cd52..7b8aa12dca2 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -55,12 +55,17 @@ class BookKeeping extends CommonObject */ public $table_element = 'accounting_bookkeeping'; + + public $entity = 1; + + /** * * @var BookKeepingLine[] Lines */ public $lines = array (); + /** * * @var int ID @@ -95,7 +100,6 @@ class BookKeeping extends CommonObject */ public function __construct(DoliDB $db) { $this->db = $db; - return 1; } /** @@ -213,7 +217,6 @@ class BookKeeping extends CommonObject } $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; - $sql .= "doc_date"; $sql .= ", doc_type"; $sql .= ", doc_ref"; @@ -230,9 +233,8 @@ class BookKeeping extends CommonObject $sql .= ", import_key"; $sql .= ", code_journal"; $sql .= ", piece_num"; - + $sql .= ', entity'; $sql .= ") VALUES ("; - $sql .= "'" . $this->doc_date . "'"; $sql .= ",'" . $this->doc_type . "'"; $sql .= ",'" . $this->doc_ref . "'"; @@ -249,7 +251,7 @@ class BookKeeping extends CommonObject $sql .= ",'" . $this->date_create . "'"; $sql .= ",'" . $this->code_journal . "'"; $sql .= "," . $this->piece_num; - + $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ")"; dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); @@ -392,10 +394,9 @@ class BookKeeping extends CommonObject $sql .= 'fk_user_author,'; $sql .= 'import_key,'; $sql .= 'code_journal,'; - $sql .= 'piece_num'; - + $sql .= 'piece_num,'; + $sql .= 'entity'; $sql .= ') VALUES ('; - $sql .= ' ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'" . $this->db->idate($this->doc_date) . "'") . ','; $sql .= ' ' . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ','; $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; @@ -411,8 +412,8 @@ class BookKeeping extends CommonObject $sql .= ' ' . $user->id . ','; $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; $sql .= ' ' . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; - $sql .= ' ' . (! isset($this->piece_num) ? 'NULL' : $this->piece_num); - + $sql .= ' ' . (! isset($this->piece_num) ? 'NULL' : $this->piece_num).','; + $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ')'; $this->db->begin(); @@ -482,10 +483,14 @@ class BookKeeping extends CommonObject $sql .= " t.piece_num"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql .= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } if (null !== $ref) { - $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; } else { - $sql .= ' WHERE t.rowid = ' . $id; + $sql .= ' AND t.rowid = ' . $id; } $resql = $this->db->query($sql); @@ -587,13 +592,17 @@ class BookKeeping extends CommonObject } } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql.= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; } - // Affichage par compte comptable - $sql .= ' ORDER BY t.numero_compte ASC'; + if (count($sqlwhere) > 0) { + $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + } + // Affichage par compte comptable + $sql .= ' ORDER BY t.numero_compte ASC'; if (! empty($sortfield)) { - $sql .= ', ' . $sortfield . ' ' .$sortorder; + $sql .= ', ' . $sortfield . ' ' .$sortorder; } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); @@ -697,8 +706,12 @@ class BookKeeping extends CommonObject } } + $sql.= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } if (! empty($sortfield)) { diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index 9294cf7f6a8..237c0def27f 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -41,6 +41,9 @@ class FormVentilation extends Form $options = array(); $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } $sql .= ' ORDER BY import_key DESC'; dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG); @@ -62,17 +65,16 @@ class FormVentilation extends Form /** * Return list of accounts with label by chart of accounts * - * @param string $selectid Preselected chart of accounts - * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field - * @param array $event Event options - * @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1) - * @param int $select_out set value returned by select 0=rowid (default), 1=account_number - * @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number - * + * @param string $selectid Preselected chart of accounts + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param array $event Event options + * @param int $select_in selectid value is a aa.rowid (0 default) or aa.account_number (1) + * @param int $select_out set value returned by select 0=rowid (default), 1=account_number + * @param string $morecss More css non HTML object * @return string String with HTML select */ - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { + function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone') { global $conf; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -123,7 +125,7 @@ class FormVentilation extends Form $options[$select_value_out] = $label; } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss); $this->db->free($resql); return $out; } @@ -227,6 +229,9 @@ class FormVentilation extends Form // Auxiliary customer account $sql = "SELECT DISTINCT code_compta, nom "; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; + } $sql .= " ORDER BY code_compta"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); @@ -246,6 +251,9 @@ class FormVentilation extends Form // Auxiliary supplier account $sql = "SELECT DISTINCT code_compta_fournisseur, nom "; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")"; + } $sql .= " ORDER BY code_compta_fournisseur"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); @@ -280,10 +288,15 @@ class FormVentilation extends Form */ function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html') { + global $conf; + $out_array = array(); $sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } $sql .= " ORDER BY date_format(doc_date,'%Y')"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -308,18 +321,23 @@ class FormVentilation extends Form /** * Return HTML combo list of years existing into book keepping * - * @param string $selected Preselected value - * @param string $htmlname Name of HTML select object - * @param int $useempty Affiche valeur vide dans liste - * @param string $output_format (html/opton (for option html only)/array (to return options arrays + * @param string $selected Preselected value + * @param string $htmlname Name of HTML select object + * @param int $useempty Affiche valeur vide dans liste + * @param string $output_format Html/option (for option html only)/array (to return options arrays * @return string/array */ function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html') { + global $conf,$langs; + $out_array = array(); $sql = "SELECT DISTINCT code_journal"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } $sql .= " ORDER BY code_journal"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -330,7 +348,7 @@ class FormVentilation extends Form return -1; } while ($obj = $this->db->fetch_object($resql)) { - $out_array[$obj->code_journal] = $obj->code_journal; + $out_array[$obj->code_journal] = $obj->code_journal?$obj->code_journal:$langs->trans("NotDefined"); // TODO Not defined is accepted ? We should avoid this, shouldn't we ? } $this->db->free($resql); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index fce70e56051..be23efb56ea 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -43,7 +43,7 @@ if ($user->societe_id > 0) accessforbidden(); if (! $user->rights->accounting->ventilation->read) accessforbidden(); - + // Filter $year = $_GET["year"]; if ($year == 0) { @@ -57,17 +57,17 @@ if ($year == 0) { // Validate History $action = GETPOST('action'); if ($action == 'validatehistory') { - + $error = 0; $db->begin(); - + if ($db->type == 'pgsql') { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; + $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; + $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; - $sql1 .= " AND fd.fk_code_ventilation = 0"; + $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; } else { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; @@ -75,9 +75,9 @@ if ($action == 'validatehistory') { $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; } - + dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); - + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; @@ -85,12 +85,12 @@ if ($action == 'validatehistory') { setEventMessages($db->lasterror(), null, 'errors'); } else { $db->commit(); - setEventMessages($langs->trans('Dispatched'), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } } elseif ($action == 'fixaccountancycode') { $error = 0; $db->begin(); - + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; $sql1 .= " SET fd.fk_code_ventilation = 0"; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; @@ -98,9 +98,9 @@ if ($action == 'validatehistory') { $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; - + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); - + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; @@ -113,15 +113,15 @@ if ($action == 'validatehistory') { } elseif ($action == 'cleanaccountancycode') { $error = 0; $db->begin(); - + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; $sql1 .= " SET fd.fk_code_ventilation = 0"; $sql1 .= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; $sql1 .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; $sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')"; - + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); - + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; @@ -133,9 +133,11 @@ if ($action == 'validatehistory') { } } + /* * View */ + llxHeader('', $langs->trans("CustomersVentilation")); $textprevyear = '' . img_previous() . ''; @@ -143,11 +145,14 @@ $textnextyear = ' ' . $langs->trans("DescVentilCustomer") . ''; +print $langs->trans("DescVentilCustomer") . '
'; +print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToDispatch")) . '
'; +print '
'; print '
'; $sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd"; @@ -171,9 +176,9 @@ print ''; print ''; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } -print ''; +print ''; $sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; @@ -196,11 +201,10 @@ $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $i = 0; $num = $db->num_rows($resql); - - while ( $i < $num ) { - $row = $db->fetch_row($resql); + + while ( $row = $db->fetch_row($resql)) { + $var = ! $var; print ''; print ''; @@ -210,7 +214,6 @@ if ($resql) { print ''; print ''; print ''; - $i ++; } $db->free($resql); } else { @@ -222,9 +225,9 @@ print "
\n"; print '
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[13]) . '' . price($row[14]) . '
'; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } -print ''; +print ''; $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; for($i = 1; $i <= 12; $i ++) { @@ -245,10 +248,8 @@ $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); - - while ( $i < $num ) { - $row = $db->fetch_row($resql); - + + while ($row = $db->fetch_row($resql)) { print ''; for($i = 1; $i <= 12; $i ++) { print ''; @@ -268,40 +269,37 @@ if (! empty($conf->margin->enabled)) { print '
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '
'; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } - print ''; - - $sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Marge',"; + print ''; + + $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; for($i = 1; $i <= 12; $i ++) { $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } - $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as 'Total'"; + $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - + if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")"; } - + dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { - $i = 0; $num = $db->num_rows($resql); - - while ( $i < $num ) { - $row = $db->fetch_row($resql); - + + while ($row = $db->fetch_row($resql)) { + print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } - print ''; + print ''; print ''; - $i ++; } $db->free($resql); } else { diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 3549651cbd6..a579daf1a9d 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014-2016 Florian Henry - * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Juanjo Menent * * 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 @@ -87,6 +87,11 @@ if (! $user->rights->accounting->ventilation->dispatch) $formventilation = new FormVentilation($db); + +/* + * Actions + */ + // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { @@ -103,13 +108,13 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - + $db->begin(); - + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; $sql1 .= " SET l.fk_code_ventilation=" . $account_parent; $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; - + dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); $resql1 = $db->query($sql1); if (! $resql1) { @@ -148,10 +153,6 @@ print ''; -/* - * Action - */ - /* * Customer Invoice lines */ @@ -223,7 +224,7 @@ $result = $db->query($sql); if ($result) { $num_lines = $db->num_rows($result); $i = 0; - + $param = ""; if ($search_invoice) $param .= "&search_invoice=" . $search_invoice; @@ -242,17 +243,17 @@ if ($result) { if ($search_tvaintra) $param .= "&search_tvaintra=" . $search_tvaintra; - + print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords); print ''; - + print ''; print '
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price(price2num($row[$i])) . '' . price($row[13]) . '' . price(price2num($row[13])) . '
' . $langs->trans("DescVentilDoneCustomer") . '
'; - + print '
' . $langs->trans("ChangeAccount") . '
'; print $formventilation->select_account($account_parent, 'account_parent', 1); - print '
'; - + print ''; + print ''; print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); @@ -262,50 +263,50 @@ if ($result) { print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Country"), $_SERVER["PHP_SELF"], "co.label", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("IntracommunityVATNumber"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Ventilate") . '
/', '', '', '', '', 'align="center"'); print "\n"; - + print ''; print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print '\n"; - + $facture_static = new Facture($db); $product_static = new Product($db); - + $var = True; while ( $objp = $db->fetch_object($result) ) { $var = ! $var; $codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label_compte; - + print ''; - + // Ref Invoice $facture_static->ref = $objp->facnumber; - $facture_static->id = $objp->facid; + $facture_static->id = $objp->rowid; print ''; - + // Ref Product $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; - $product_static->type = $objp->type; + $product_static->type = $objp->product_type; print ''; - + print ''; print ''; print ''; @@ -316,7 +317,7 @@ if ($result) { print ''; print ''; print ''; - + print ""; $i ++; } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 167f558d830..7d2326b05e5 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -103,9 +103,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { $search_vat = ''; } + + /* * View */ + llxHeader('', $langs->trans("Ventilation")); print ''; - - $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); - print '
%%'; print ''; print "
' . $facture_static->getNomUrl(1) . ''; if ($product_static->id) print $product_static->getNomUrl(1); else print ' '; print '' . dol_trunc($objp->product_label, 24) . '' . nl2br(dol_trunc($objp->description, 32)) . '' . price($objp->total_ht) . '' . $objp->country .'' . $objp->tva_intra . '
'; - if (($origin == 'propal') || ($origin == 'commande')) - { - print ''; - print '
'; - print $desc; - print ''; - $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); - print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); - print '' . $langs->trans('Value') . ':'; - } - print '
'; - - print ''; + if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) + { + print '
'; + $tmp=' '; + print ''; + + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); + print ''; + if (($origin == 'propal') || ($origin == 'commande')) + { + print ''; + print '
'; + print $desc; + print ''; + $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); + print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); + print '' . $langs->trans('Value') . ':'; + } + print '
'; + + print '
'; + } } if ($socid > 0) @@ -2212,32 +2248,36 @@ if ($action == 'create') } // Replacement - print '
'; - $tmp=' - jQuery(document).ready(function() { - jQuery("#fac_replacement").change(function() { - jQuery("#radio_replacement").prop("checked", true); - }); - }); - '; - $text = $tmp.$langs->trans("InvoiceReplacementAsk") . ' '; - $text .= ' + jQuery(document).ready(function() { + jQuery("#fac_replacement").change(function() { + jQuery("#radio_replacement").prop("checked", true); + }); + }); + '; + $text = $tmp.$langs->trans("InvoiceReplacementAsk") . ' '; + $text .= ''; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; } - $text .= ''; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); - print $desc; - print ''; } else { @@ -2254,48 +2294,51 @@ if ($action == 'create') { if ($socid > 0) { - // Credit note - print '
'; - $tmp=' - jQuery(document).ready(function() { - if (! jQuery("#radio_creditnote").is(":checked")) - { - jQuery("#credit_note_options").hide(); - } - jQuery("#radio_creditnote").click(function() { - jQuery("#credit_note_options").show(); - }); - jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() { - jQuery("#credit_note_options").hide(); - }); - }); - '; - $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' '; - // $text.=''; - $text .= ''; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); - print $desc; - - print '
'; - print '    0 ? 'checked':'').' /> "; - print '
    0 ? 'checked':'').' /> "; - print '
'; - - print '
'; + // Credit note + if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) + { + print '
'; + $tmp=' + jQuery(document).ready(function() { + if (! jQuery("#radio_creditnote").is(":checked")) + { + jQuery("#credit_note_options").hide(); + } + jQuery("#radio_creditnote").click(function() { + jQuery("#credit_note_options").show(); + }); + jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() { + jQuery("#credit_note_options").hide(); + }); + }); + '; + $text = $tmp.$langs->transnoentities("InvoiceAvoirAsk") . ' '; + // $text.=''; + $text .= ''; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); + print $desc; + + print '
'; + print '    0 ? 'checked':'').' /> "; + print '
    0 ? 'checked':'').' /> "; + print '
'; + + print '
'; + } } else { @@ -2317,7 +2360,7 @@ if ($action == 'create') $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3); print $desc; print ''; - + print ''; print ''; @@ -2343,7 +2386,7 @@ if ($action == 'create') } // Date invoice - print '' . $langs->trans('Date') . ''; + print '' . $langs->trans('DateInvoice') . ''; $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); print $form->select_date($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1, 1); print ''; @@ -2356,9 +2399,9 @@ if ($action == 'create') print $form->select_date($date_pointoftax?$date_pointoftax:-1, 'date_pointoftax', '', '', '', "add", 1, 1, 1); print ''; } - + // Payment term - print '' . $langs->trans('PaymentConditionsShort') . ''; + print '' . $langs->trans('PaymentConditionsShort') . ''; $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print ''; @@ -2392,7 +2435,14 @@ if ($action == 'create') print ''; print ''; print ''; - print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:'')); + $incoterm_id = GETPOST('incoterm_id'); + $incoterm_location = GETPOST('location_incoterms'); + if (empty($incoterm_id)) + { + $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms); + $incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms); + } + print $form->select_incoterms($incoterm_id, $incoterm_location); print ''; } @@ -2421,12 +2471,11 @@ if ($action == 'create') print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print ''; } - + // Public note print ''; print '' . $langs->trans('NotePublic') . ''; print ''; - $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null)); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -2436,7 +2485,6 @@ if ($action == 'create') print ''; print '' . $langs->trans('NotePrivate') . ''; print ''; - $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null)); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ' @@ -2504,7 +2552,7 @@ if ($action == 'create') print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . ""; } print '' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . ""; - + if (!empty($conf->multicurrency->enabled)) { print '' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; @@ -2842,11 +2890,60 @@ else if ($id > 0 || ! empty($ref)) // Invoice content - print ''; - $linkback = '' . $langs->trans("BackToList") . ''; + $morehtmlref='
'; + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->facture->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; + + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + dol_banner_tab($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + print '
'; + print '
'; + print '
'; + + print '
'; + // Ref + /* print ''; print ''; + print '';*/ // Type - print ''; - // List of payments - - $sign = 1; - if ($object->type == Facture::TYPE_CREDIT_NOTE) - $sign = - 1; - - $nbrows = 8; - $nbcols = 3; - if (! empty($conf->projet->enabled)) - $nbrows ++; - if (! empty($conf->banque->enabled)) { - $nbrows ++; $nbcols++; - } - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) - $nbrows ++; - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) - $nbrows ++; - if ($selleruserevenustamp) - $nbrows ++; - if (! empty($conf->multicurrency->enabled)) $nbrows+=5; - if (! empty($conf->incoterm->enabled)) $nbrows+=1; - - print ''; - if (! empty($conf->global->INVOICE_POINTOFTAX_DATE)) { // Date invoice @@ -3378,14 +3156,14 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print '
' . $langs->trans('Ref') . ''; $morehtmlright = ''; @@ -2910,10 +3007,10 @@ else if ($id > 0 || ! empty($ref)) } print ')'; } - print '
' . $langs->trans('Type') . ''; + print '
' . $langs->trans('Type') . ''; print $object->getLibType(); if ($object->type == Facture::TYPE_REPLACEMENT) { $facreplaced = new Facture($db); @@ -2954,7 +3051,7 @@ else if ($id > 0 || ! empty($ref)) $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; print '
' . $langs->trans('Discounts'); - print ''; + print ''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); else @@ -3030,345 +3127,26 @@ else if ($id > 0 || ! empty($ref)) // Date invoice print '
'; print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) print ''; print '
'; - print $langs->trans('Date'); + print $langs->trans('DateInvoice'); print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
'; - print '
'; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editinvoicedate') { $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date, 'invoicedate'); } else { - print dol_print_date($object->date, 'daytext'); + print dol_print_date($object->date, 'day'); } } else { - print dol_print_date($object->date, 'daytext'); + print dol_print_date($object->date, 'day'); } print ''; - - if ($object->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) - { - if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print ''; - - if (count($object->tab_previous_situation_invoice) > 0) - { - //List of previous invoices - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; - print ''; - print ''; - - $total_prev_ht = $total_prev_ttc = 0; - $var = true; - foreach ($object->tab_previous_situation_invoice as $prev_invoice) - { - $totalpaye = $prev_invoice->getSommePaiement(); - $total_prev_ht += $prev_invoice->total_ht; - $total_prev_ttc += $prev_invoice->total_ttc; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; - print ''; - print ''; - - $var = !$var; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - if (count($object->tab_next_situation_invoice) > 0) - { - //List of next invoices - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; - print ''; - print ''; - - $total_next_ht = $total_next_ttc = 0; - - $var = true; - foreach ($object->tab_next_situation_invoice as $next_invoice) - { - $totalpaye = $next_invoice->getSommePaiement(); - $total_next_ht += $next_invoice->total_ht; - $total_next_ttc += $next_invoice->total_ttc; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; - print ''; - print ''; - - $var = !$var; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print '
' . $langs->trans('ListOfPreviousSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
'.$prev_invoice->getNomUrl(1).'' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . ''.$prev_invoice->getLibStatut(3, $totalpaye).'
' . price($total_prev_ht) . '' . price($total_prev_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
'.$next_invoice->getNomUrl(1).'' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . ''.$next_invoice->getLibStatut(3, $totalpaye).'
' . price($total_next_ht) . '' . price($total_next_ttc) . ' 
'; - } - - print ''; - - // List of payments already done - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - print ''; - print ''; - print ''; print ''; - $var = true; - - // Payments already done (from payment on this invoice) - $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; - $sql .= ' c.code as payment_code, c.libelle as payment_label,'; - $sql .= ' pf.amount,'; - $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_paiement as c, ' . MAIN_DB_PREFIX . 'paiement_facture as pf, ' . MAIN_DB_PREFIX . 'paiement as p'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; - $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; - $sql .= ' ORDER BY p.datep, p.tms'; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - - // if ($object->type != 2) - // { - if ($num > 0) - { - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; - $label = ($langs->trans("PaymentType" . $objp->payment_code) != ("PaymentType" . $objp->payment_code)) ? $langs->trans("PaymentType" . $objp->payment_code) : $objp->payment_label; - print ''; - if (! empty($conf->banque->enabled)) - { - $bankaccountstatic->id = $objp->baid; - $bankaccountstatic->ref = $objp->baref; - $bankaccountstatic->label = $objp->baref; - print ''; - } - print ''; - print ''; - print ''; - $i ++; - } - } else { - print ''; - } - // } - $db->free($result); - } else { - dol_print_error($db); - } - - if ($object->type != Facture::TYPE_CREDIT_NOTE) - { - // Total already paid - print ''; - - $resteapayeraffiche = $resteapayer; - - // Loop on each credit note or deposit amount applied - $creditnoteamount = 0; - $depositamount = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_facture = " . $object->id; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - $invoice = new Facture($db); - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $invoice->fetch($obj->fk_facture_source); - print ''; - print ''; - print ''; - $i ++; - if ($invoice->type == Facture::TYPE_CREDIT_NOTE) - $creditnoteamount += $obj->amount_ttc; - if ($invoice->type == Facture::TYPE_DEPOSIT) - $depositamount += $obj->amount_ttc; - } - } else { - dol_print_error($db); - } - - // Paye partiellement 'escompte' - if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat') { - print ''; - $resteapayeraffiche = 0; - } - // Paye partiellement ou Abandon 'badcustomer' - if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer') { - print ''; - // $resteapayeraffiche=0; - } - // Paye partiellement ou Abandon 'product_returned' - if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned') { - print ''; - $resteapayeraffiche = 0; - } - // Paye partiellement ou Abandon 'abandon' - if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon') { - print ''; - $resteapayeraffiche = 0; - } - - // Billed - print ''; - - // Remainder to pay - print ''; - print ''; - print ''; - } - else // Credit note - { - // Total already paid back - print ''; - - // Billed - print ''; - - // Remainder to pay back - print ''; - print ''; - print ''; - - // Sold credit note - // print ''; - // print ''; - } - - print '
' . ($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . '' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . '' . $langs->trans('Amount') . ' 
'; - $paymentstatic->id=$objp->rowid; - $paymentstatic->datepaye=$db->jdate($objp->dp); - $paymentstatic->ref=$objp->ref; - $paymentstatic->num_paiement=$objp->num_paiement; - $paymentstatic->payment_code=$objp->payment_code; - print $paymentstatic->getNomUrl(1); - print ''.dol_print_date($db->jdate($objp->dp), 'day') . '' . $label . ' ' . $objp->num_paiement . ''; - if ($bankaccountstatic->id) - print $bankaccountstatic->getNomUrl(1, 'transactions'); - print '' . price($sign * $objp->amount) . ' 
' . $langs->trans("None") . '
'; - if ($object->type != Facture::TYPE_DEPOSIT) - print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); - else - print $langs->trans('AlreadyPaid'); - print ' :' . price($totalpaye) . ' 
'; - if ($invoice->type == Facture::TYPE_CREDIT_NOTE) - print $langs->trans("CreditNote") . ' '; - if ($invoice->type == Facture::TYPE_DEPOSIT) - print $langs->trans("Deposit") . ' '; - print $invoice->getNomUrl(0); - print ' :' . price($obj->amount_ttc) . ''; - print 'rowid . '">' . img_delete() . ''; - print '
'; - print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; - print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; - print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1); - print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; - $text = $langs->trans("HelpAbandonOther"); - if ($object->close_note) - $text .= '

' . $langs->trans("Reason") . ':' . $object->close_note; - print $form->textwithpicto($langs->trans("Abandoned") . ':', $text, - 1); - print '
' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
'; - if ($resteapayeraffiche >= 0) - print $langs->trans('RemainderToPay'); - else - print $langs->trans('ExcessReceived'); - print ' :' . price($resteapayeraffiche) . ' 
'; - print $langs->trans('AlreadyPaidBack'); - print ' :' . price($sign * $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' 
'; - if ($resteapayeraffiche <= 0) - print $langs->trans('RemainderToPayBack'); - else - print $langs->trans('ExcessPaydBack'); - print ' :' . price($sign * $resteapayeraffiche) . ' 
'.$langs->trans('TotalTTC').' :'.price($sign * - // $object->total_ttc).' 
'; - - // Margin Infos - if (! empty($conf->margin->enabled)) - { - print '
'; - $formmargin->displayMarginInfos($object, $object->statut > 0); - } - - print '
id . '">' . img_edit($langs->trans('SetDate'), 1) . '
'; - print ''; + print ''; if ($action == 'editdate_pointoftax') { $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_pointoftax, 'date_pointoftax'); } else { - print dol_print_date($object->date_pointoftax, 'daytext'); + print dol_print_date($object->date_pointoftax, 'day'); } print ''; - } + } // Conditions de reglement print ''; @@ -3395,7 +3173,7 @@ else if ($id > 0 || ! empty($ref)) if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . ''; print ''; - print ''; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editconditions') { @@ -3416,13 +3194,13 @@ else if ($id > 0 || ! empty($ref)) if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . ''; print ''; - print ''; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editpaymentterm') { $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_lim_reglement, 'paymentterm'); } else { - print dol_print_date($object->date_lim_reglement, 'daytext'); + print dol_print_date($object->date_lim_reglement, 'day'); if ($object->hasDelay()) { print img_warning($langs->trans('Late')); } @@ -3440,7 +3218,7 @@ else if ($id > 0 || ! empty($ref)) if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . ''; print ''; - print ''; + print ''; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); @@ -3463,14 +3241,14 @@ else if ($id > 0 || ! empty($ref)) if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; print ''; - print ''; + print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); } else { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); } print ''; - + // Multicurrency rate print ''; print ''; @@ -3480,7 +3258,7 @@ else if ($id > 0 || ! empty($ref)) if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; print ''; - print ''; + print ''; if ($action == 'editmulticurrencyrate') { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { @@ -3497,7 +3275,7 @@ else if ($id > 0 || ! empty($ref)) if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).''; print ''; - print ''; + print ''; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); @@ -3530,7 +3308,7 @@ else if ($id > 0 || ! empty($ref)) print $object->situation_counter; print ''; - print ''; + print ''; $prevsits_total_amount = 0; foreach ($prevsits as $situation) { @@ -3551,7 +3329,7 @@ else if ($id > 0 || ! empty($ref)) print $prevsits[$i]->situation_counter; print ''; - print ''; + print ''; print '- ' . price($prevsits[$i]->total_ht); print ''; print '' . $langs->trans('Currency' . $conf->currency) . ''; @@ -3559,71 +3337,8 @@ else if ($id > 0 || ! empty($ref)) } } - // Amount - print '' . $langs->trans('AmountHT') . ''; - print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ''; - print '' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . ''; - print ''; - - // Amount Local Taxes - if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 - { - print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; - print '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . ''; - } - if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 - { - print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . ''; - } - - // Revenue stamp - if ($selleruserevenustamp) // Test company use revenue stamp - { - print ''; - print ''; - if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $user->rights->facture->creer) - print ''; - print '
'; - print $langs->trans('RevenueStamp'); - print 'id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . '
'; - print ''; - if ($action == 'editrevenuestamp') { - print '
'; - print ''; - print ''; - print $formother->select_revenue_stamp(GETPOST('revenuestamp'), 'revenuestamp', $mysoc->country_code); - // print ''; - print ' '; - print '
'; - } else { - print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); - } - print ''; - } - - // Total with tax - print '' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . ''; - - if (!empty($conf->multicurrency->enabled)) - { - // Multicurrency Amount HT - print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; - print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; - - // Multicurrency Amount VAT - print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; - print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; - - // Multicurrency Amount TTC - print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; - print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; - } - // Statut + /* print '' . $langs->trans('Status') . ''; print '' . ($object->getLibStatut(4, $totalpaye)) . ''; @@ -3651,7 +3366,7 @@ else if ($id > 0 || ! empty($ref)) } print ''; print ''; - } + }*/ // Incoterms if (!empty($conf->incoterm->enabled)) @@ -3664,7 +3379,7 @@ else if ($id > 0 || ! empty($ref)) else print ' '; print ''; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); @@ -3677,11 +3392,401 @@ else if ($id > 0 || ! empty($ref)) } // Other attributes - $cols = 5; + $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - print '
'; + print ''; + + print ''; + print '
'; + print '
'; + print '
'; + + print ''; + + // Amount + print ''; + print ''; + print ''; + print ''; + + // Amount Local Taxes + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 + { + print ''; + print ''; + } + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 + { + print ''; + print ''; + } + + // Revenue stamp + if ($selleruserevenustamp) // Test company use revenue stamp + { + print ''; + } + + // Total with tax + print ''; + + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency Amount HT + print ''; + print ''; + print ''; + + // Multicurrency Amount VAT + print ''; + print ''; + print ''; + + // Multicurrency Amount TTC + print ''; + print ''; + print ''; + } + + print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '
'; + print ''; + if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $user->rights->facture->creer) + { + print ''; + } + print '
'; + print $langs->trans('RevenueStamp'); + print 'id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . '
'; + print '
'; + if ($action == 'editrevenuestamp') { + print '
'; + print ''; + print ''; + print $formother->select_revenue_stamp(GETPOST('revenuestamp'), 'revenuestamp', $mysoc->country_code); + // print ''; + print ' '; + print '
'; + } else { + print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency); + } + print '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'; + + // List of payments + + $sign = 1; + if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = - 1; + $nbrows = 8; + $nbcols = 3; + if (! empty($conf->projet->enabled)) + $nbrows ++; + if (! empty($conf->banque->enabled)) { + $nbrows ++; + $nbcols ++; + } + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) + $nbrows ++; + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) + $nbrows ++; + if ($selleruserevenustamp) + $nbrows ++; + if (! empty($conf->multicurrency->enabled)) + $nbrows += 5; + if (! empty($conf->incoterm->enabled)) + $nbrows += 1; + + if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) + { + if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) + print ''; + + if (count($object->tab_previous_situation_invoice) > 0) { + // List of previous invoices + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + print ''; + print ''; + print ''; + print ''; + print ''; + + $total_prev_ht = $total_prev_ttc = 0; + $var = true; + foreach ($object->tab_previous_situation_invoice as $prev_invoice) { + $totalpaye = $prev_invoice->getSommePaiement(); + $total_prev_ht += $prev_invoice->total_ht; + $total_prev_ttc += $prev_invoice->total_ttc; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = ! $var; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + if (count($object->tab_next_situation_invoice) > 0) { + // List of next invoices + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + print ''; + print ''; + print ''; + print ''; + print ''; + + $total_next_ht = $total_next_ttc = 0; + + $var = true; + foreach ($object->tab_next_situation_invoice as $next_invoice) { + $totalpaye = $next_invoice->getSommePaiement(); + $total_next_ht += $next_invoice->total_ht; + $total_next_ttc += $next_invoice->total_ttc; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + print ''; + print ''; + print ''; + print ''; + print ''; + + $var = ! $var; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) + print '
' . $langs->trans('ListOfPreviousSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $prev_invoice->getNomUrl(1) . '' . price($prev_invoice->total_ht) . '' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_prev_ht) . '' . price($total_prev_ttc) . ' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
' . $next_invoice->getNomUrl(1) . '' . price($next_invoice->total_ht) . '' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_next_ht) . '' . price($total_next_ttc) . ' 
'; + } + + print ''; + + // List of payments already done + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) { + print ''; + } + print ''; + print ''; + print ''; + + $var = true; + + // Payments already done (from payment on this invoice) + $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; + $sql .= ' c.code as payment_code, c.libelle as payment_label,'; + $sql .= ' pf.amount,'; + $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_paiement as c, ' . MAIN_DB_PREFIX . 'paiement_facture as pf, ' . MAIN_DB_PREFIX . 'paiement as p'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid'; + $sql .= ' ORDER BY p.datep, p.tms'; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + + // if ($object->type != 2) + // { + if ($num > 0) { + while ($i < $num) { + $objp = $db->fetch_object($result); + $var = ! $var; + print ''; + print ''; + $label = ($langs->trans("PaymentType" . $objp->payment_code) != ("PaymentType" . $objp->payment_code)) ? $langs->trans("PaymentType" . $objp->payment_code) : $objp->payment_label; + print ''; + if (! empty($conf->banque->enabled)) { + $bankaccountstatic->id = $objp->baid; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; + print ''; + } + print ''; + print ''; + print ''; + $i ++; + } + } else { + print ''; + } + // } + $db->free($result); + } else { + dol_print_error($db); + } + + if ($object->type != Facture::TYPE_CREDIT_NOTE) { + // Total already paid + print ''; + + $resteapayeraffiche = $resteapayer; + + // Loop on each credit note or deposit amount applied + $creditnoteamount = 0; + $depositamount = 0; + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; + $sql .= " WHERE fk_facture = " . $object->id; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $invoice = new Facture($db); + while ($i < $num) { + $obj = $db->fetch_object($resql); + $invoice->fetch($obj->fk_facture_source); + print ''; + print ''; + print ''; + $i ++; + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) + $creditnoteamount += $obj->amount_ttc; + if ($invoice->type == Facture::TYPE_DEPOSIT) + $depositamount += $obj->amount_ttc; + } + } else { + dol_print_error($db); + } + + // Paye partiellement 'escompte' + if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat') { + print ''; + $resteapayeraffiche = 0; + } + // Paye partiellement ou Abandon 'badcustomer' + if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer') { + print ''; + // $resteapayeraffiche=0; + } + // Paye partiellement ou Abandon 'product_returned' + if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned') { + print ''; + $resteapayeraffiche = 0; + } + // Paye partiellement ou Abandon 'abandon' + if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon') { + print ''; + $resteapayeraffiche = 0; + } + + // Billed + print ''; + + // Remainder to pay + print ''; + print ''; + print ''; + } + else // Credit note + { + // Total already paid back + print ''; + + // Billed + print ''; + + // Remainder to pay back + print ''; + print ''; + print ''; + + // Sold credit note + // print ''; + // print ''; + } + + print '
' . ($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . '' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . '' . $langs->trans('Amount') . ' 
'; + $paymentstatic->id = $objp->rowid; + $paymentstatic->datepaye = $db->jdate($objp->dp); + $paymentstatic->ref = $objp->ref; + $paymentstatic->num_paiement = $objp->num_paiement; + $paymentstatic->payment_code = $objp->payment_code; + print $paymentstatic->getNomUrl(1); + print '' . dol_print_date($db->jdate($objp->dp), 'day') . '' . $label . ' ' . $objp->num_paiement . ''; + if ($bankaccountstatic->id) + print $bankaccountstatic->getNomUrl(1, 'transactions'); + print '' . price($sign * $objp->amount) . ' 
' . $langs->trans("None") . '
'; + if ($object->type != Facture::TYPE_DEPOSIT) + print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); + else + print $langs->trans('AlreadyPaid'); + print ' : 0)?' class="amountalreadypaid"':'').'>' . price($totalpaye) . ' 
'; + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) + print $langs->trans("CreditNote") . ' '; + if ($invoice->type == Facture::TYPE_DEPOSIT) + print $langs->trans("Deposit") . ' '; + print $invoice->getNomUrl(0); + print ' :' . price($obj->amount_ttc) . ''; + print 'rowid . '">' . img_delete() . ''; + print '
'; + print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1); + print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1); + print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1); + print '' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
'; + $text = $langs->trans("HelpAbandonOther"); + if ($object->close_note) + $text .= '

' . $langs->trans("Reason") . ':' . $object->close_note; + print $form->textwithpicto($langs->trans("Abandoned") . ':', $text, - 1); + print '
' . price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
'; + if ($resteapayeraffiche >= 0) + print $langs->trans('RemainderToPay'); + else + print $langs->trans('ExcessReceived'); + print ' :' . price($resteapayeraffiche) . ' 
'; + print $langs->trans('AlreadyPaidBack'); + print ' :' . price($sign * $totalpaye) . ' 
' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' 
'; + if ($resteapayeraffiche <= 0) + print $langs->trans('RemainderToPayBack'); + else + print $langs->trans('ExcessPaydBack'); + print ' :' . price($sign * $resteapayeraffiche) . ' 
'.$langs->trans('TotalTTC').' :'.price($sign * + // $object->total_ttc).' 
'; + + // Margin Infos + if (! empty($conf->margin->enabled)) { + $formmargin->displayMarginInfos($object); + } + + print '
'; + print '
'; + print ''; + + print '

'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); @@ -3919,7 +4024,7 @@ else if ($id > 0 || ! empty($ref)) } // Classify 'closed not completely paid' (possible si validee et pas encore classee payee) - + if ($object->statut == 1 && $object->paye == 0 && $resteapayer > 0 && $user->rights->facture->paiement) { if ($totalpaye > 0 || $totalcreditnotes > 0) @@ -3931,11 +4036,11 @@ else if ($id > 0 || ! empty($ref)) { if ( empty($conf->global->INVOICE_CAN_NEVER_BE_CANCELED)) { - if ($objectidnext) + if ($objectidnext) { print '
' . $langs->trans('ClassifyCanceled') . '
'; } - else + else { print ''; } @@ -3963,7 +4068,7 @@ else if ($id > 0 || ! empty($ref)) { if (! $objectidnext) { - print ''; + print ''; } } diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php index 1172769e95a..8300545cb22 100644 --- a/htdocs/compta/facture/apercu.php +++ b/htdocs/compta/facture/apercu.php @@ -50,7 +50,9 @@ $result = restrictedArea($user, 'facture', $id); $now=dol_now(); -llxHeader('',$langs->trans("Bill"),'Facture'); +$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Preview'); +$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; +llxHeader('', $title, $helpurl); $form = new Form($db); @@ -83,7 +85,7 @@ if ($id > 0 || ! empty($ref)) $linkback = '' . $langs->trans("BackToList") . ''; // Ref - print '' . $langs->trans('Ref') . ''; + print '' . $langs->trans('Ref') . ''; $morehtmlref = ''; $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, $object->id); @@ -238,7 +240,7 @@ if ($id > 0 || ! empty($ref)) print ''; // Dates - print ''.$langs->trans("Date").''; + print ''.$langs->trans("DateInvoice").''; print ''.dol_print_date($object->date,"daytext").''; // Right part with $rowspan lines diff --git a/htdocs/compta/facture/class/api_deprecated_invoice.class.php b/htdocs/compta/facture/class/api_deprecated_invoice.class.php index 353a48b79ef..51e047e4412 100644 --- a/htdocs/compta/facture/class/api_deprecated_invoice.class.php +++ b/htdocs/compta/facture/class/api_deprecated_invoice.class.php @@ -89,12 +89,12 @@ class InvoiceApi extends DolibarrApi * * Get a list of invoices * - * @param int $socid Filter list with thirdparty ID - * @param string $mode Filter by invoice status : draft | unpaid | paid | cancelled * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $socid Filter list with thirdparty ID + * @param string $mode Filter by invoice status : draft | unpaid | paid | cancelled * * @return array Array of invoice objects * @@ -103,12 +103,12 @@ class InvoiceApi extends DolibarrApi * @url GET thirdparty/{socid}/invoice/list * @url GET thirdparty/{socid}/invoice/list/{mode} */ - function getList($socid=0, $mode='', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getList($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $socid=0, $mode='') { global $db, $conf; $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $socid; // If the internal user must only see his customers, force searching by him if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; @@ -160,7 +160,7 @@ class InvoiceApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $invoice_static = new Facture($db); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index e14ed12dce3..e3951b4dca7 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -83,23 +83,22 @@ class Invoices extends DolibarrApi * * Get a list of invoices * - * FIXME this parameter is overwritten in the code and thus ignored - * @param int $socid Filter list with thirdparty ID - * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $socid Filter list with thirdparty ID + * @param string $status Filter by invoice status : draft | unpaid | paid | cancelled * @return array Array of invoice objects * * @throws RestException */ - function index($socid=0, $status='', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $socid=0, $status='') { global $db, $conf; $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $socid; // If the internal user must only see his customers, force searching by him if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; @@ -151,7 +150,7 @@ class Invoices extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $invoice_static = new Facture($db); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1d75be61f6c..007c8040d0d 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -43,6 +43,7 @@ class FactureRec extends CommonInvoice public $table_element_line='facturedet_rec'; public $fk_element='fk_facture'; + var $entity; var $number; var $date; var $amount; @@ -241,7 +242,7 @@ class FactureRec extends CommonInvoice */ function fetch($rowid, $ref='', $ref_ext='', $ref_int='') { - $sql = 'SELECT f.rowid, f.titre, f.fk_soc, f.amount, f.tva, f.total, f.total_ttc, f.remise_percent, f.remise_absolue, f.remise'; + $sql = 'SELECT f.rowid, f.entity, f.titre, f.fk_soc, f.amount, f.tva, f.total, f.total_ttc, f.remise_percent, f.remise_absolue, f.remise'; $sql.= ', f.date_lim_reglement as dlr'; $sql.= ', f.note_private, f.note_public, f.fk_user_author'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet'; @@ -269,6 +270,7 @@ class FactureRec extends CommonInvoice $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->titre = $obj->titre; $this->ref = $obj->titre; $this->ref_client = $obj->ref_client; @@ -438,14 +440,14 @@ class FactureRec extends CommonInvoice /** * Delete template invoice * - * @param int $rowid Id of invoice to delete. If empty, we delete current instance of invoice + * @param User $user User that delete. * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function delete($rowid=0, $notrigger=0, $idwarehouse=-1) + function delete($user, $notrigger=0, $idwarehouse=-1) { - if (empty($rowid)) $rowid=$this->id; + $rowid=$this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); @@ -519,6 +521,7 @@ class FactureRec extends CommonInvoice { // Clean parameters $remise_percent=price2num($remise_percent); + if (empty($remise_percent)) $remise_percent=0; $qty=price2num($qty); if (! $qty) $qty=1; if (! $info_bits) $info_bits=0; @@ -579,12 +582,12 @@ class FactureRec extends CommonInvoice $sql.= ", ".price2num($txtva); $sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null"); $sql.= ", ".$product_type; - $sql.= ", '".price2num($remise_percent)."'"; - $sql.= ", '".price2num($pu_ht)."'"; + $sql.= ", ".price2num($remise_percent); + $sql.= ", ".price2num($pu_ht); $sql.= ", null"; - $sql.= ", '".price2num($total_ht)."'"; - $sql.= ", '".price2num($total_tva)."'"; - $sql.= ", '".price2num($total_ttc)."'"; + $sql.= ", ".price2num($total_ht); + $sql.= ", ".price2num($total_tva); + $sql.= ", ".price2num($total_ttc); $sql.= ", ".$rang; $sql.= ", ".$special_code; $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null").")"; @@ -721,14 +724,16 @@ class FactureRec extends CommonInvoice } /** - * Create all recurrents invoices. - * A result may also be provided into this->output + * Create all recurrents invoices (for all entities if multicompany is used). + * A result may also be provided into this->output. + * + * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. * * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ function createRecurringInvoices() { - global $langs, $db, $user; + global $conf, $langs, $db, $user; $langs->load("bills"); @@ -743,6 +748,7 @@ class FactureRec extends CommonInvoice $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency $sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; + $sql.= $db->order('entity', 'ASC'); //print $sql;exit; $resql = $db->query($sql); @@ -754,7 +760,9 @@ class FactureRec extends CommonInvoice if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); - while ($i < $num) + $saventity = $conf->entity; + + while ($i < $num) // Loop on each template invoice { $line = $db->fetch_object($resql); @@ -763,7 +771,10 @@ class FactureRec extends CommonInvoice $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); - dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); + // Set entity context + $conf->entity = $facturerec->entity; + + dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); $error=0; @@ -774,7 +785,7 @@ class FactureRec extends CommonInvoice $facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; - $invoiceidgenerated = $facture->create($user); // This will also update fields of recurring invoice + $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { $this->errors = $facture->errors; @@ -794,18 +805,20 @@ class FactureRec extends CommonInvoice if (! $error && $invoiceidgenerated >= 0) { - $db->commit(); + $db->commit("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); dol_syslog("createRecurringInvoices Process invoice template ".$facturerec->ref." is finished with a success generation"); $nb_create++; $this->output.=$langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; } else { - $db->rollback(); + $db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); } $i++; } + + $conf->entity = $saventity; // Restore entity context } else dol_print_error($db); @@ -1060,7 +1073,7 @@ class FactureRec extends CommonInvoice return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET date_when = "'.$this->db->idate($date).'"'; + $sql.= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); if ($increment_nb_gen_done>0) $sql.= ', nb_gen_done = nb_gen_done + 1'; $sql.= ' WHERE rowid = '.$this->id; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 001b9058b24..4f358074e59 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -53,7 +53,8 @@ class Facture extends CommonInvoice public $table_element_line = 'facturedet'; public $fk_element = 'fk_facture'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - + public $picto='bill'; + /** * {@inheritdoc} */ @@ -241,7 +242,8 @@ class Facture extends CommonInvoice if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; - + if (empty($this->entity)) $this->entity = $conf->entity; + // Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate) if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); @@ -281,8 +283,9 @@ class Facture extends CommonInvoice $_facrec = new FactureRec($this->db); $result=$_facrec->fetch($this->fac_rec); - $this->socid = $_facrec->socid; - + $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template + $this->entity = $_facrec->entity; // Invoice created in same entity than template + // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; $this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public; @@ -311,13 +314,15 @@ class Facture extends CommonInvoice $forceduedate = $this->calculate_date_lim_reglement(); - // For recurrn invoices, update date and number of last generation of recurring template invoice, before inserting new invoice + // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice if ($_facrec->frequency > 0) { + dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); + if (empty($_facrec->date_when)) $_facrec->date_when = $now; $next_date = $_facrec->getNextDate(); // Calculate next date - $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date'); + $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date', '', $user, ''); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. - $_facrec->setNextDate($next_date,1); + $result = $_facrec->setNextDate($next_date,1); } } @@ -352,7 +357,7 @@ class Facture extends CommonInvoice $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; - $sql.= ", ".$conf->entity; + $sql.= ", ".$this->entity; $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", '".$this->db->escape($this->type)."'"; $sql.= ", '".$socid."'"; @@ -415,7 +420,7 @@ class Facture extends CommonInvoice if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order { require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; - $exp = new Expedition($db); + $exp = new Expedition($this->db); $exp->fetch($origin_id); $exp->fetchObjectLinked(); if (count($exp->linkedObjectsIds['commande']) > 0) @@ -1506,11 +1511,13 @@ class Facture extends CommonInvoice * Set customer ref * * @param string $ref_client Customer ref - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ function set_ref_client($ref_client, $notrigger=0) { + global $user; + $error=0; $this->db->begin(); @@ -1738,7 +1745,7 @@ class Facture extends CommonInvoice * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) * @return int <0 if KO, >0 if OK */ - function set_paid($user,$close_code='',$close_note='') + function set_paid($user, $close_code='', $close_note='') { $error=0; @@ -1903,7 +1910,7 @@ class Facture extends CommonInvoice * @param User $user Object user that validate * @param string $force_number Reference to force on invoice * @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease) - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ function validate($user, $force_number='', $idwarehouse=0, $notrigger=0) @@ -2815,7 +2822,7 @@ class Facture extends CommonInvoice * * @param User $user User that set discount * @param double $remise Discount - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ function set_remise($user, $remise, $notrigger=0) @@ -2879,7 +2886,7 @@ class Facture extends CommonInvoice * * @param User $user User that set discount * @param double $remise Discount - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ function set_remise_absolue($user, $remise, $notrigger=0) @@ -3934,7 +3941,7 @@ class Facture extends CommonInvoice * Sets the invoice as a final situation * * @param User $user Object user - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ function setFinal(User $user, $notrigger=0) diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index a7fa51ff5ae..ebc90fca6c5 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -114,7 +114,9 @@ else if ($action == 'deletecontact' && $user->rights->facture->creer) * View */ -llxHeader('', $langs->trans("InvoiceCustomer")); +$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('ContactsAddresses'); +$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; +llxHeader('', $title, $helpurl); $form = new Form($db); $formcompany = new FormCompany($db); @@ -163,7 +165,7 @@ if ($id > 0 || ! empty($ref)) print ''; // Ref customer - print ''; + print ''; print $langs->trans('RefCustomer'); print ''; print ''; diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index b25d52c173b..9a15b7875d8 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -82,7 +82,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; * View */ -llxHeader('', $langs->trans("InvoiceCustomer")); +$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Documents'); +$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; +llxHeader('', $title, $helpurl); $form = new Form($db); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 4198640701e..fd9f9e0fc13 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1,12 +1,13 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Meziane Sof * * 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 @@ -128,6 +129,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once +if (GETPOST('cancel')) $action=''; + // Create predefined invoice if ($action == 'add') { @@ -183,19 +186,19 @@ if ($action == 'add') // Get first contract linked to invoice used to generate template if ($id > 0) { - $srcObject = new Facture($db); - $srcObject->fetch(GETPOST('facid','int')); - - $srcObject->fetchObjectLinked(); - - if (! empty($srcObject->linkedObjectsIds['contrat'])) - { - $contractidid = reset($srcObject->linkedObjectsIds['contrat']); + $srcObject = new Facture($db); + $srcObject->fetch(GETPOST('facid','int')); - $object->origin = 'contrat'; - $object->origin_id = $contractidid; - $object->linked_objects[$object->origin] = $object->origin_id; - } + $srcObject->fetchObjectLinked(); + + if (! empty($srcObject->linkedObjectsIds['contrat'])) + { + $contractidid = reset($srcObject->linkedObjectsIds['contrat']); + + $object->origin = 'contrat'; + $object->origin_id = $contractidid; + $object->linked_objects[$object->origin] = $object->origin_id; + } } $db->begin(); @@ -209,16 +212,16 @@ if ($action == 'add') $result=$oldinvoice->delete($user, 1); if ($result < 0) { - $error++; - setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors'); - $action = "create"; + $error++; + setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors'); + $action = "create"; } } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; } if (! $error) @@ -230,9 +233,9 @@ if ($action == 'add') } else { - $db->rollback(); - - $error++; + $db->rollback(); + + $error++; setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; } @@ -240,9 +243,9 @@ if ($action == 'add') } // Delete -if ($action == 'delete' && $user->rights->facture->supprimer) +if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) { - $object->delete($user); + $object->delete(); header("Location: " . $_SERVER['PHP_SELF'] ); exit; } @@ -266,9 +269,19 @@ elseif ($action == 'classin' && $user->rights->facture->creer) $object->setProject(GETPOST('projectid', 'int')); } // Set bank account +elseif ($action == 'setref' && $user->rights->facture->creer) +{ + $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); + if ($result > 0) + { + $object->titre = GETPOST('ref', 'alpha'); + $object->ref = $object->titre; + } +} +// Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); } // Set frequency and unit frequency elseif ($action == 'setfrequency' && $user->rights->facture->creer) @@ -295,344 +308,362 @@ elseif ($action == 'setauto_validate' && $user->rights->facture->creer) // Delete line if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); + $object->fetch($id); + $object->fetch_thirdparty(); - $db->begin(); - - $line=new FactureLigneRec($db); - - // For triggers - $line->id = $lineid; - - if ($line->delete() > 0) - { - $result=$object->update_price(1); - - if ($result > 0) - { - $db->commit(); - $object->fetch($object->id); // Reload lines - } - else - { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } - } - else - { - $db->rollback(); - setEventMessages($line->error, $line->errors, 'errors'); - } + $db->begin(); + + $line=new FactureLigneRec($db); + + // For triggers + $line->id = $lineid; + + if ($line->delete() > 0) + { + $result=$object->update_price(1); + + if ($result > 0) + { + $db->commit(); + $object->fetch($object->id); // Reload lines + } + else + { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + } + else + { + $db->rollback(); + setEventMessages($line->error, $line->errors, 'errors'); + } } // Add a new line if ($action == 'addline' && $user->rights->facture->creer) { - $langs->load('errors'); - $error = 0; + $langs->load('errors'); + $error = 0; - // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - if (GETPOST('prod_entry_mode') == 'free') - { - $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { - $idprod=GETPOST('idprod', 'int'); - $tva_tx = ''; - } + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key . $predef]); - } - } + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) + { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key . $predef]); + } + } - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { - setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); - $error ++; - } - if ($qty == '') { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); - $error ++; - } - if ($qty < 0) { - $langs->load("errors"); - setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); - $error ++; - } + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); + $error ++; + } + if ($qty == '') { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); + $error ++; + } + if ($qty < 0) { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); + $error ++; + } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - $ret = $object->fetch($id); - if ($ret < 0) { - dol_print_error($db, $object->error); - exit(); - } - $ret = $object->fetch_thirdparty(); + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) + { + $ret = $object->fetch($id); + if ($ret < 0) { + dol_print_error($db, $object->error); + exit(); + } + $ret = $object->fetch_thirdparty(); - // Clean parameters - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); + // Clean parameters + $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); - // Define special_code for special lines - $special_code = 0; - // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices + // Define special_code for special lines + $special_code = 0; + // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - // Ecrase $base_price_type par celui du produit - // Replaces $fk_unit with the product's - if (! empty($idprod)) + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + // Ecrase $base_price_type par celui du produit + // Replaces $fk_unit with the product's + if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); + $prod = new Product($db); + $prod->fetch($idprod); - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; - - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; + // Update if prices fields are defined + $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); + if (empty($tva_tx)) $tva_npr=0; - // We define price for product - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) - { - $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; - $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; - if (empty($tva_tx)) $tva_npr=0; - } - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; - $prodcustprice = new Productcustomerprice($db); + // We define price for product + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + { + $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; + $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (empty($tva_tx)) $tva_npr=0; + } + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + $prodcustprice = new Productcustomerprice($db); - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result) { - if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; - } - } - } + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - // if price ht was forced (ie: from gui when calculated by margin rate and cost price) - if (! empty($price_ht)) - { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tva_tx != $prod->tva_tx) - { - if ($price_base_type != 'HT') - { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); - } - else - { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - } + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result) + { + if (count($prodcustprice->lines) > 0) + { + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; + } + } + } - $desc = ''; + // if price ht was forced (ie: from gui when calculated by margin rate and cost price) + if (! empty($price_ht)) + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + elseif ($tva_tx != $prod->tva_tx) + { + if ($price_base_type != 'HT') + { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); + } + else + { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); + } + } - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + $desc = ''; - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - $desc = dol_concatdesc($desc, $product_desc); + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } + $desc = dol_concatdesc($desc, $product_desc); - $type = $prod->type; - $fk_unit = $prod->fk_unit; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - if (empty($tva_tx)) $tva_npr=0; - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); - $fk_unit= GETPOST('units', 'alpha'); - } - - // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) + { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + + } - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); - - $info_bits = 0; - if ($tva_npr) - $info_bits |= 0x01; + $type = $prod->type; + $fk_unit = $prod->fk_unit; + + } + else + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + if (empty($tva_tx)) $tva_npr=0; + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + $fk_unit= GETPOST('units', 'alpha'); + } - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessages($mesg, null, 'errors'); - } else { - // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); + // Margin + $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value - if ($result > 0) - { - /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); - $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - }*/ - $object->fetch($object->id); // Reload lines - - unset($_POST['prod_entry_mode']); + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['multicurrency_price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - unset($_POST['np_marginRate']); - unset($_POST['np_markRate']); - unset($_POST['dp_desc']); - unset($_POST['idprod']); - unset($_POST['units']); + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) + { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessages($mesg, null, 'errors'); + } + else + { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); - 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']); + if ($result > 0) + { + /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records - unset($_POST['situations']); - unset($_POST['progress']); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + }*/ + $object->fetch($object->id); // Reload lines - $action = ''; - } + unset($_POST['prod_entry_mode']); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprod']); + unset($_POST['units']); + + 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']); + + unset($_POST['situations']); + unset($_POST['progress']); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + + $action = ''; + } } } elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) { - if (! $object->fetch($id) > 0) dol_print_error($db); - $object->fetch_thirdparty(); + if (! $object->fetch($id) > 0) dol_print_error($db); + $object->fetch_thirdparty(); - // Clean parameters - $date_start = ''; - $date_end = ''; - //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); - $pu_ht = GETPOST('price_ht'); - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - $qty = GETPOST('qty'); + // Clean parameters + $date_start = ''; + $date_end = ''; + //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); + $pu_ht = GETPOST('price_ht'); + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $qty = GETPOST('qty'); - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01; // Define vat_rate @@ -649,10 +680,12 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield - if (is_array($extralabelsline)) { + if (is_array($extralabelsline)) + { // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + foreach ($extralabelsline as $key => $value) + { + unset($_POST["options_" . $key]); } } @@ -676,13 +709,13 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' $productid = GETPOST('productid', 'int'); if (! empty($productid)) { - $product = new Product($db); - $product->fetch($productid); + $product = new Product($db); + $product->fetch($productid); - $type = $product->type; + $type = $product->type; - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min [$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); @@ -709,12 +742,29 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' } // Update line - if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, - $vat_rate, GETPOST('productid'), GETPOST('remise_percent'), 'HT', $info_bits, 0, 0, $type, - 0, $special_code, $label, GETPOST('units')); + if (! $error) + { + $result = $object->updateline( + GETPOST('lineid'), + $description, + $pu_ht, + $qty, + $vat_rate, + GETPOST('productid'), + GETPOST('remise_percent'), + 'HT', + $info_bits, + 0, + 0, + $type, + 0, + $special_code, + $label, + GETPOST('units') + ); - if ($result >= 0) { + if ($result >= 0) + { /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -732,47 +782,49 @@ elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST(' $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); }*/ - $object->fetch($object->id); // Reload lines - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['productid']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['multicurrency_price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - unset($_POST['np_marginRate']); - unset($_POST['np_markRate']); + $object->fetch($object->id); // Reload lines - unset($_POST['dp_desc']); - unset($_POST['idprod']); - unset($_POST['units']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); - 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']); + unset($_POST['dp_desc']); + unset($_POST['idprod']); + unset($_POST['units']); - unset($_POST['situations']); - unset($_POST['progress']); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + 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']); + + unset($_POST['situations']); + unset($_POST['progress']); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } // Do we click on purge search criteria ? @@ -825,7 +877,7 @@ if ($action == 'create') { $result = $object->getLinesArray(); - print '
'; + print ''; print ''; print ''; print ''; @@ -840,15 +892,15 @@ if ($action == 'create') $object->fetch_thirdparty(); + // Title + print ''.$langs->trans("Title").''; + print ''; + print ''; + // Third party print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').''; print ''; - // Title - print ''.$langs->trans("Title").''; - print ''; - print ''; - // Note public print ''.$langs->trans("NotePublic").''; print ''; @@ -873,15 +925,15 @@ if ($action == 'create') print ""; // Project - if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) - { - $projectid = $object->fk_project; - $langs->load('projects'); - print '' . $langs->trans('Project') . ''; - $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; - print ''; - } + if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) + { + $projectid = $object->fk_project; + $langs->load('projects'); + print '' . $langs->trans('Project') . ''; + $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); + print '   id).'">' . $langs->trans("AddProject") . ''; + print ''; + } // Bank account if ($object->fk_account > 0) @@ -920,8 +972,8 @@ if ($action == 'create') // Auto validate the invoice print "".$langs->trans("StatusOfGeneratedInvoices").""; - $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); - print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); + $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); + print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); print ""; print ""; @@ -950,176 +1002,7 @@ if ($action == 'create') } print "\n"; - - /* - print ''; - print ''; if ($flag_price_may_change) @@ -1156,11 +1039,16 @@ else $object->fetch_thirdparty(); // Confirmation de la suppression d'une ligne produit - if ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); - } - - print $formconfirm; + if ($action == 'ask_deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); + } + + // Confirm delete of repeatable invoice + if ($action == 'ask_deleteinvoice') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); + } + + print $formconfirm; $author = new User($db); $author->fetch($object->user_author); @@ -1178,20 +1066,13 @@ else $linkback = '' . $langs->trans("BackToList") . ''; // Ref - print ''; - print ''; + print ''; @@ -1220,9 +1101,12 @@ else print ''; // Project - if (! empty($conf->projet->enabled)) { + if (! empty($conf->projet->enabled)) + { $langs->load('projects'); print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -554,7 +554,7 @@ else } // Civility - print ''; @@ -783,10 +783,10 @@ else } // Lastname - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -890,7 +890,7 @@ else print $form->selectarray('priv',$selectarray,$object->priv,0); print ''; - // Note Public + // Note Public print ''; - // Statut + // Status print ''; print ''; // Civility - print ''; @@ -1122,7 +1122,7 @@ else // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { - print ''; + print ''; print ''; @@ -1141,7 +1141,7 @@ else if (! empty($conf->propal->enabled)) { - print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 8566b4e5585..4e045ccd449 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -554,8 +554,6 @@ class Contact extends CommonObject $this->db->rollback(); return -$error; } - - return $result; } @@ -1092,24 +1090,24 @@ class Contact extends CommonObject } elseif ($mode == 2) { - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); + elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); } elseif ($mode == 3) { - if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'),'statut5'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4'); + if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"'); + elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"'); } elseif ($mode == 4) { - if ($statut==0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($statut==0) return img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled'); + elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled'); } elseif ($mode == 5) { - if ($statut==0 || $statut==5) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); - elseif ($statut==1 || $statut==4) return ''.$langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($statut==0 || $statut==5) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5', 'class="pictostatus"'); + elseif ($statut==1 || $statut==4) return ''.$langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4', 'class="pictostatus"'); } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 5504d43671c..b8c96884e96 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -129,18 +129,18 @@ $fieldstosearchall = array( $arrayfields=array( 'p.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), 'p.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), - 'p.poste'=>array('label'=>$langs->trans("Post"), 'checked'=>1), + 'p.poste'=>array('label'=>$langs->trans("PostOrFunction"), 'checked'=>1), 'p.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0), 'p.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), - 'p.phone'=>array('label'=>$langs->trans("PhonePro"), 'checked'=>1), + 'p.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>1), 'p.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0), 'p.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>1), 'p.fax'=>array('label'=>$langs->trans("Fax"), 'checked'=>1), - 'p.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1), + 'p.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), 'p.skype'=>array('label'=>$langs->trans("Skype"), 'checked'=>1, 'enabled'=>(! empty($conf->skype->enabled))), 'p.thirdparty'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv'=>array('label'=>$langs->trans("ContactVisibility"), 'checked'=>1, 'position'=>200), - 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'p.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'p.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); @@ -380,6 +380,7 @@ if ($result) if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ); if (!empty($search_categ_thirdparty)) $param.='&search_categ_thirdparty='.urlencode($search_categ_thirdparty); if (!empty($search_categ_supplier)) $param.='&search_categ_supplier='.urlencode($search_categ_supplier); + if ($sall != '') $param.='&sall='.urlencode($sall); if ($search_lastname != '') $param.='&search_lastname='.urlencode($search_lastname); if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_firstname); if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); @@ -702,13 +703,12 @@ if ($result) print ''; } diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 761efcfa840..17c718cfb42 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -83,6 +83,10 @@ if ($id > 0) $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', ''); + $cssclass='titlefield'; + //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; + //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; + print '
'; print '
'; @@ -98,19 +102,19 @@ if ($id > 0) $objsoc = new Societe($db); $objsoc->fetch($object->socid); - print '
'; + print ''; } else { - print ''; } } // Civility - print ''; @@ -120,7 +124,7 @@ if ($id > 0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - print '"; + print '"; } print ""; print "
'; - - $sql = 'SELECT l.fk_product, l.product_type, l.label as custom_label, l.description, l.qty, l.rowid, l.tva_tx,'; - $sql.= ' l.fk_remise_except,'; - $sql.= ' l.remise_percent, l.subprice, l.info_bits,'; - $sql.= ' l.total_ht, l.total_tva as total_vat, l.total_ttc,'; - $sql.= ' l.date_start,'; - $sql.= ' l.date_end,'; - $sql.= ' l.product_type,'; - $sql.= ' l.fk_unit,'; - $sql.= ' p.ref, p.fk_product_type, p.label as product_label,'; - $sql.= ' p.description as product_desc'; - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as l"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; - $sql.= " WHERE l.fk_facture = ".$object->id; - $sql.= " ORDER BY l.rowid"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $total = 0; - - echo ''; - if ($num) - { - print ''; - print ''; - print ''; - print ''; - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print ''; - print "\n"; - } - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($result); - - if ($objp->fk_product > 0) - { - $product = New Product($db); - $product->fetch($objp->fk_product); - } - - $var=!$var; - print ""; - - // Show product and description - $type=(isset($objp->product_type)?$objp->product_type:$objp->fk_product_type); - $product_static->fk_unit=$objp->fk_unit; - - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print '\n"; - } - - // Vat rate - print ''; - - // Qty - print ''; - - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - - // Percent - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - - // Total HT - print '\n"; - - // Total VAT - print '\n"; - - // Total TTC - print '\n"; - - // Total Unit price - print '\n"; - - // Current price of product - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { - if ($objp->fk_product > 0) - { - $flag_price_may_change++; - $prodprice=$product_static->price; // price HT - print '\n"; - } - else - { - print ''; - } - } - - print ""; - - $i++; - } - - $db->free($result); - - } - else - { - print $db->error(); - } - print "
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$langs->trans("ReductionShort").''.$langs->trans("TotalHT").''.$langs->trans("TotalVAT").''.$langs->trans("TotalTTC").''.$langs->trans("PriceUHT").''.$langs->trans("CurrentProductPrice").'
'; - - print ''; // ancre pour retourner sur la ligne - - // Show product and description - $product_static->fetch($objp->fk_product); // We need all information later - $text=$product_static->getNomUrl(1); - $text.= ' - '.(! empty($objp->custom_label)?$objp->custom_label:$objp->product_label); - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end)); - - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - print (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; - - print '
'; - print ''; // ancre pour retourner sur la ligne - - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - - if (! empty($objp->custom_label)) { - - $text.= ' '.$objp->custom_label.''; - print $form->textwithtooltip($text,dol_htmlentitiesbr($objp->description),3,'','',$i); - - } else { - - print $text.' '.nl2br($objp->description); - } - - // Show range - print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end)); - - print "'.vatrate($objp->tva_tx).'%'.$objp->qty.''.$product_static->getLabelOfUnit().''.$objp->remise_percent." % '.price($objp->total_ht)."'.price($objp->total_vat)."'.price($objp->total_ttc)."'.price($objp->subprice)."'.price($prodprice)." 
"; - */ - + print '
' . $langs->trans('Ref') . ''; - $morehtmlref = ''; - /* - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; - $discount = new DiscountAbsolute($db); - $result = $discount->fetch(0, $object->id); - if ($result > 0) { - $morehtmlref = ' (' . $langs->trans("CreditNoteConvertedIntoDiscount", $discount->getNomUrl(1, 'discount')) . ')'; - } - if ($result < 0) { - dol_print_error('', $discount->error); - }*/ - print $form->showrefnav($object, 'ref', $linkback, 1, 'titre', 'titre', $morehtmlref); + print '
'; + //print $langs->trans('Ref'); + print $form->editfieldkey($langs->trans("Ref"), 'ref', $object->ref, $object, $user->rights->facture->creer); + print ''; + $morehtmlref = $form->editfieldval($langs->trans("Ref"), 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); + print $form->showrefnav($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref); print '
'; if ($object->type != Facture::TYPE_CREDIT_NOTE) { - if ($action == 'editconditions') { + if ($action == 'editconditions') + { $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); - } else { + } + else + { $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); } } else { @@ -1266,7 +1150,8 @@ else print '
'; @@ -1324,7 +1209,7 @@ else print ''; // if "frequency" is empty or = 0, the reccurence is disabled - print ''; @@ -1404,7 +1289,7 @@ else else print $langs->trans("StatusOfGeneratedInvoices"); print '\n"; print ''; @@ -172,8 +182,14 @@ if ($result) print ''; + // Account + if (! empty($conf->banque->enabled)) + { + print ''; + } print ''; - print '\n"; // Type print $type; + // Account + if (! empty($conf->banque->enabled)) + { + print ''; + } // Amount $total = $total + $obj->amount; print ""; - print ""; + print ""; print "\n"; $i++; } - print ''; + + $colspan=5; + if (! empty($conf->banque->enabled)) $colspan++; + print ''; print ""; print ""; diff --git a/htdocs/compta/ventilation/card.php b/htdocs/compta/ventilation/card.php deleted file mode 100644 index 59ed7fe9cde..00000000000 --- a/htdocs/compta/ventilation/card.php +++ /dev/null @@ -1,164 +0,0 @@ - - * Copyright (C) 2005-2006 Laurent Destailleur - * - * 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 . - * - */ - -/** - * \file htdocs/compta/ventilation/card.php - * \ingroup compta - * \brief Page fiche ventilation - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - -$langs->load("bills"); - -$mesg = ''; - -if (!$user->rights->compta->ventilation->creer) accessforbidden(); - - -/* - * Actions - */ - -if ($_POST["action"] == 'ventil' && $user->rights->compta->ventilation->creer) -{ - $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sql .= " SET fk_code_ventilation = ".$_POST["codeventil"]; - $sql .= " WHERE rowid = ".$_GET["id"]; - - $db->query($sql); -} - -llxHeader("","","Fiche ventilation"); - -if ($cancel == $langs->trans("Cancel")) -{ - $action = ''; -} -/* - * - * - */ - -$sql = "SELECT rowid, numero, intitule"; -$sql .= " FROM ".MAIN_DB_PREFIX."compta_compte_generaux"; -$sql .= " ORDER BY numero ASC"; - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - $i = 0; - - while ($i < $num) - { - $row = $db->fetch_row($result); - $cgs[$row[0]] = $row[1] . ' ' . $row[2]; - $i++; - } -} - -/* - * Cr�ation - * - */ -$form = new Form($db); -$facture_static=new Facture($db); - -if($_GET["id"]) -{ - $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,"; - $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,"; - $sql .= " l.date_start as date_start, l.date_end as date_end,"; - $sql .= " l.fk_code_ventilation "; - $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; - $sql .= " , ".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND l.rowid = ".$_GET["id"]; - - $result = $db->query($sql); - if ($result) - { - $num_lignes = $db->num_rows($result); - $i = 0; - - if ($num_lignes) - { - - $objp = $db->fetch_object($result); - - - if($objp->fk_code_ventilation == 0) - { - print '
'."\n"; - print ''; - print ''; - } - - - print load_fiche_titre("Ventilation"); - - print '
'; + print '
'; print ''; @@ -1335,25 +1220,25 @@ else if ($action == 'editfrequency') { print ''; - print ''; - print ''; - print '
'; print $langs->trans('Frequency'); print '
'; - print ''; - print ''; - print '
'; - print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); + print '
'; } else { - if ($object->frequency > 0) - { - print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); - } - else - { - print $langs->trans("NotARecurringInvoiceTemplate"); - } + if ($object->frequency > 0) + { + print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); + } + else + { + print $langs->trans("NotARecurringInvoiceTemplate"); + } } print '
'; - $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); + $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); if ($action == 'auto_validate' || $object->frequency > 0) { print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); @@ -1417,17 +1302,17 @@ else print '
'; // Frequencry/Recurring section - if ($object->frequency > 0) + if ($object->frequency > 0) + { + if (empty($conf->cron->enabled)) { - if (empty($conf->cron->enabled)) - { - print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name"))); - } + print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name"))); + } print ''; // Nb of generation already done - print ''; + print ''; print ''; @@ -1496,34 +1381,34 @@ else //if ($object->statut == Facture::STATUS_DRAFT) // there is no draft status on templates. //{ - if ($user->rights->facture->creer) - { - if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) - { - print ''; - } - else - { - if (empty($object->frequency) || $object->date_when <= $today) - { - print ''; - } - else - { - print ''; - } - } - } - else - { - print ''; - } + if ($user->rights->facture->creer) + { + if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) + { + print ''; + } + else + { + if (empty($object->frequency) || $object->date_when <= $today) + { + print ''; + } + else + { + print ''; + } + } + } + else + { + print ''; + } //} //if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer) if ($user->rights->facture->supprimer) { - print ''; + print ''; } print ''; @@ -1539,7 +1424,7 @@ else $somethingshown = $form->showLinkedObjectBlock($object, ''); - print ''; + print ''; } else @@ -1558,6 +1443,9 @@ else if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); + if ($search_frequency == '1') $sql.= ' AND f.frequency > 0'; + if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)'; + if ($month > 0) { if ($year > 0 && empty($day)) @@ -1577,8 +1465,8 @@ else $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'"; else if ($year_date_when > 0 && ! empty($day_date_when)) $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'"; - else - $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'"; + else + $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'"; } else if ($year_date_when > 0) { @@ -1586,14 +1474,14 @@ else } $nbtotalofrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - } + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($limit+1,$offset); + $sql.= $db->order($sortfield, $sortorder); + $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); if ($resql) @@ -1601,7 +1489,7 @@ else $num = $db->num_rows($resql); $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($day) $param.='&day='.$day; if ($month) $param.='&month='.$month; @@ -1692,8 +1580,8 @@ else if (! empty($arrayfields['f.frequency']['checked'])) { // Amount - print ''; } // Date invoice @@ -1807,7 +1695,7 @@ else $i++; } } - else print ''; + else print ''; print "
'.$langs->trans("NbOfGenerationDone").'
'.$langs->trans("NbOfGenerationDone").''; print $object->nb_gen_done?$object->nb_gen_done:'0'; print ''; - //print ''; + print ''; + print $form->selectyesno('search_frequency', $search_frequency, 1, false, 1); print '
'.$langs->trans("NoneF").'
'.$langs->trans("NoneF").'
"; $db->free($resql); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 250848319f3..419cacf4cff 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +$langs->load("companies"); $langs->load("bills"); @@ -35,7 +36,9 @@ $langs->load("bills"); * View */ -llxHeader('', $langs->trans("InvoiceCustomer")); +$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info'); +$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; +llxHeader('', $title, $helpurl); $fac = new Facture($db); $fac->fetch($_GET["facid"]); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index bab9ab00769..70e4cc03974 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -70,6 +70,7 @@ $userid=GETPOST('userid','int'); $search_product_category=GETPOST('search_product_category','int'); $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); $search_refcustomer=GETPOST('search_refcustomer','alpha'); +$search_type=GETPOST('search_type','int'); $search_societe=GETPOST('search_societe','alpha'); $search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_montant_vat=GETPOST('search_montant_vat','alpha'); @@ -142,6 +143,7 @@ $checkedtypetiers=0; $arrayfields=array( 'f.facnumber'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'f.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), + 'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0), 'f.date'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1), 'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), @@ -191,6 +193,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOS $search_product_category=''; $search_ref=''; $search_refcustomer=''; + $search_type=''; $search_project=''; $search_societe=''; $search_montant_ht=''; @@ -295,6 +298,15 @@ if ($filtre) } if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref); if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer); +if ($search_type != '' && $search_type >= 0) +{ + if ($search_type == '0') $sql.=" AND f.type = 0"; // standard + if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement + if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note + if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit + if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma + if ($search_type == '5') $sql.=" AND f.type = 5"; // situation +} if ($search_project) $sql .= natural_search('p.ref', $search_project); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_town) $sql.= natural_search('s.town', $search_town); @@ -310,7 +322,7 @@ if ($search_status != '' && $search_status >= 0) { if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft if ($search_status == '1') $sql.=" AND f.fk_statut = 1"; // unpayed - if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some correupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) + if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned } if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; @@ -400,7 +412,7 @@ if ($resql) $num = $db->num_rows($resql); $arrayofselected=is_array($toselect)?$toselect:array(); - + if ($socid) { $soc = new Societe($db); @@ -410,6 +422,7 @@ if ($resql) $param='&socid='.$socid; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall) $param.='&sall='.$sall; if ($day) $param.='&day='.urlencode($day); if ($month) $param.='&month='.urlencode($month); if ($year) $param.='&year=' .urlencode($year); @@ -418,6 +431,7 @@ if ($resql) if ($year_lim) $param.='&year_lim=' .urlencode($year_lim); if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); if ($search_refcustomer) $param.='&search_refcustomer=' .urlencode($search_refcustomer); + if ($search_type != '') $param.='&search_type='.urlencode($search_type); if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale); if ($search_user > 0) $param.='&search_user=' .urlencode($search_user); @@ -437,7 +451,7 @@ if ($resql) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + $arrayofmassactions=array( 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge") @@ -456,7 +470,7 @@ if ($resql) } if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + $i = 0; print '
'."\n"; if ($optioncss != '') print ''; @@ -466,7 +480,7 @@ if ($resql) print ''; print ''; print ''; - + print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); if ($massaction == 'presend') @@ -495,7 +509,7 @@ if ($resql) print ''; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); + $formmail = new FormMail($db); dol_fiche_head(null, '', ''); @@ -614,12 +628,13 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print ''."\n"; - + print ''; if (! empty($arrayfields['f.facnumber']['checked'])) print_liste_field_titre($arrayfields['f.facnumber']['label'],$_SERVER['PHP_SELF'],'f.facnumber','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'],$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'],$_SERVER["PHP_SELF"],'f.type','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'],$_SERVER['PHP_SELF'],'f.datef','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'],$_SERVER['PHP_SELF'],"f.date_lim_reglement",'',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],'s.nom','',$param,'',$sortfield,$sortorder); @@ -672,6 +687,20 @@ if ($resql) print ''; print ''; } + // Type + if (! empty($arrayfields['f.type']['checked'])) + { + print ''; + } // Date invoice if (! empty($arrayfields['f.date']['checked'])) { @@ -718,7 +747,7 @@ if ($resql) if (! empty($arrayfields['typent.code']['checked'])) { print ''; } // Payment mode @@ -829,6 +858,7 @@ if ($resql) $facturestatic->type=$obj->type; $facturestatic->statut=$obj->fk_statut; $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); + $facturestatic->type=$obj->type; print ''; if (! empty($arrayfields['f.facnumber']['checked'])) @@ -864,7 +894,7 @@ if ($resql) print "\n"; if (! $i) $totalarray['nbfield']++; } - + // Customer ref if (! empty($arrayfields['f.ref_client']['checked'])) { @@ -873,7 +903,16 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + + // Type + if (! empty($arrayfields['f.type']['checked'])) + { + print '"; + if (! $i) $totalarray['nbfield']++; + } + // Date if (! empty($arrayfields['f.date']['checked'])) { @@ -882,7 +921,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Date limit if (! empty($arrayfields['f.date_lim_reglement']['checked'])) { @@ -894,7 +933,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Third party if (! empty($arrayfields['s.nom']['checked'])) { @@ -948,7 +987,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Payment mode if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) { @@ -957,7 +996,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Amount HT if (! empty($arrayfields['f.total_ht']['checked'])) { @@ -998,7 +1037,7 @@ if ($resql) if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; $totalarray['totalrtp'] += $remaintopay; } - + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 77d3817d911..4b4b68a7cf4 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -60,7 +60,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, * View */ -llxHeader('', $langs->trans("InvoiceCustomer")); +$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Notes'); +$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; +llxHeader('', $title, $helpurl); $form = new Form($db); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 74a41dee31c..87a27166ae8 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -106,7 +106,9 @@ if ($action == "delete") $now=dol_now(); -llxHeader('', $langs->trans("InvoiceCustomer")); +$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('StandingOrders'); +$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; +llxHeader('', $title, $helpurl); $form = new Form($db); @@ -290,7 +292,7 @@ if ($object->id > 0) // Date invoice print ''; print ''; - print ''; + print ''; if ($i == 0) print ''; print ''; $i++; diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index b8a5779c708..f0b520bb11e 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -230,7 +230,7 @@ foreach ($tabfac as $key => $val) if (isset($line['nomtcheck']) || $mt) { print ""; - print ""; + print ""; print ""; print ""; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 0cbd5068077..670d89fd2cb 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -263,7 +263,7 @@ foreach ($tabfac as $key => $val) if (isset($line['nomtcheck']) || $mt) { print ""; - print ""; + print ""; print ""; print ""; diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index d7b6b897ec3..642c37b9d65 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -277,7 +277,8 @@ $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'"; $sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'"; $sql.= " AND localtaxtype=".$localTaxType; -$sql.= " GROUP BY dm ASC ORDER BY dm ASC"; +$sql.= " GROUP BY dm"; +$sql.= " ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index c11b2c815bc..4b0039c0a21 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -394,7 +394,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie json["invoice_type"] = $("#invoice_type").val(); json["amountPayment"] = $("#amountpayment").attr("value"); json["amounts"] = _elemToJson(form.find("input.amount")); - json["remains"] = _elemToJson(form.find("input.remain]")); + json["remains"] = _elemToJson(form.find("input.remain")); if (imgId != null) { json["imgClicked"] = imgId; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 0ffaf49b955..8d43e573696 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -3,8 +3,8 @@ * Copyright (C) 2007-2011 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2011-2016 Juanjo Menent - * Copyright (C) 2013 Philippe Grand - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2015-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 @@ -21,9 +21,9 @@ */ /** - * \file htdocs/compta/paiement/cheque/card.php - * \ingroup bank, invoice - * \brief Page for cheque deposits + * \file htdocs/compta/paiement/cheque/card.php + * \ingroup bank, invoice + * \brief Page for cheque deposits */ require '../../../main.inc.php'; @@ -95,7 +95,7 @@ if ($action == 'setrefext' && $user->rights->banque->cheque) { $ref_ext = GETPOST('ref_ext'); - $result=$object->setValueFrom('ref_ext', $ref_ext); + $result=$object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -298,7 +298,9 @@ if (GETPOST('removefilter')) $filteraccountid=0; } -llxHeader(); +$title=$langs->trans("Cheques") . " - " . $langs->trans("Card"); +$helpurl=""; +llxHeader("",$title,$helpurl); $form = new Form($db); $formfile = new FormFile($db); @@ -386,7 +388,7 @@ if ($action == 'new') print '
'; + $listtype=array( + Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), + Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), + Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), + Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + ); + //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. + print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); + print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100'); print '
'; + print $facturestatic->getLibType(); + print "
'; print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer) print ''; print '
'; - print $langs->trans('Date'); + print $langs->trans('DateInvoice'); print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 35a56e5afb3..1dd1c46299a 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -117,7 +117,7 @@ if (count($listofsearchfields)) { if ($i == 0) print '
'.$langs->trans("Search").'
:
".dol_print_date($val["date"])."".dol_print_date($db->jdate($val["date"]))."".$invoicestatic->getNomUrl(1)."".$k."".$line['label']."
".dol_print_date($val["date"])."".dol_print_date($db->jdate($val["date"]))."".$invoicestatic->getNomUrl(1)."".$k."".$line['label']."
'; //print ''; // Filter - print ''; print '\n"; print '\n"; print ''; - + // Link to payment print ''; - + print '' ; @@ -563,7 +565,7 @@ else $accountstatic->label=$object->account_label; print '
'.$langs->trans('Date').''.dol_print_date($now,'day').'
'.$langs->trans("DateChequeReceived").''; + print '
'.$langs->trans("DateChequeReceived").''; print $form->select_date($filterdate,'fd',0,0,1,'',1,1,1); print '
'.$langs->trans("BankAccount").''; @@ -502,7 +504,7 @@ if ($action == 'new') print ''.$value["emetteur"]."'.$value["banque"]."'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; $paymentstatic->id=$value["paymentid"]; @@ -528,7 +530,7 @@ if ($action == 'new') print ' '; } print ''; print ''; print '
'; - print ''; -print '
'; + print '
'; print ''; - print ''; + if (! empty($conf->banque->enabled)) + { + print ''; + } print ''; @@ -309,16 +315,21 @@ if ($resql) // Payment number print ''; - - print ''; + + // Account + if (! empty($conf->banque->enabled)) + { + print ''; + } + // Amount print ''; if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 06a32c3865f..3822f9f91f5 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -29,8 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); -$chid=GETPOST("id"); -$action=GETPOST('action'); +$chid=GETPOST("id", 'int'); +$action=GETPOST('action', 'alpha'); $amounts = array(); // Security check @@ -45,13 +45,13 @@ if ($user->societe_id > 0) * Actions */ -if ($action == 'add_payment') +if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes')) { $error=0; if ($_POST["cancel"]) { - $loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid; + $loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid; header("Location: ".$loc); exit; } @@ -109,7 +109,7 @@ if ($action == 'add_payment') if (! $error) { - $paymentid = $paiement->create($user); + $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib')=='on'?1:0)); if ($paymentid < 0) { $errmsg=$paiement->error; @@ -130,7 +130,7 @@ if ($action == 'add_payment') if (! $error) { $db->commit(); - $loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid; + $loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid; header('Location: '.$loc); exit; } @@ -155,7 +155,7 @@ $form=new Form($db); // Formulaire de creation d'un paiement de charge -if ($_GET["action"] == 'create') +if ($action == 'create') { $charge = new ChargeSociales($db); @@ -185,7 +185,7 @@ if ($_GET["action"] == 'create') print ""; - print ''; + print ''; print '\n"; print '\n"; print '\n"; @@ -317,8 +317,9 @@ if ($_GET["action"] == 'create') print "
'; print $langs->trans('Ref'); @@ -760,7 +762,7 @@ else dol_print_error($db); } - dol_fiche_end(); + dol_fiche_end(); } diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index e230d91e6ae..17882e76a6a 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -229,7 +229,10 @@ if ($resql) print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"c.libelle","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"p.num_paiement","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); + if (! empty($conf->banque->enabled)) + { + print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); + } print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"p.amount","",$param,'align="right"',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("Invoices"),"","","",$param,'align="left"',$sortfield,$sortorder); @@ -260,9 +263,12 @@ if ($resql) print ''; print ''; print ''; - $form->select_comptes($search_account,'search_account',0,'',1); - print ''; + $form->select_comptes($search_account,'search_account',0,'',1); + print ''; print ''; print ''.$objp->num_paiement.''; - if ($objp->bid) - { - $accountstatic->id=$objp->bid; - $accountstatic->label=$objp->label; - print $accountstatic->getNomUrl(1); - } - else print ' '; - print ''; + if ($objp->bid) + { + $accountstatic->id=$objp->bid; + $accountstatic->label=$objp->label; + print $accountstatic->getNomUrl(1); + } + else print ' '; + print ''.price($objp->amount).'
".$langs->trans("SocialContribution")."
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Type")."".$charge->type_libelle."
'.$langs->trans("Period")."".dol_print_date($charge->periode,'day')."
'.$langs->trans("Label").''.$charge->lib."
"; - print '
'; - print ''; + // Bouton Save payment + print '
'.$langs->trans("ClosePaidContributionsAutomatically"); + print '
'; print '     '; print ''; print '
'; diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index ad59687b43c..0ea48d9075c 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -65,7 +65,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char if ($result > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT."/compta/charges/index.php?mode=sconly"); + header("Location: ".DOL_URL_ROOT."/compta/sociales/payments.php?mode=sconly"); exit; } else @@ -162,25 +162,25 @@ if ($action == 'valide') print ''; // Ref -print ''; +print ''; print ''; // Date -print ''; +print ''; // Mode -print ''; +print ''; // Numero -print ''; +print ''; // Montant -print ''; +print ''; // Note -print ''; +print ''; // Bank account if (! empty($conf->banque->enabled)) @@ -278,7 +278,7 @@ else dol_print_error($db); } -print ''; +dol_fiche_end(); /* diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 800cd8492c9..5bc09419666 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -22,11 +22,12 @@ /** * \file htdocs/compta/prelevement/class/bonprelevement.class.php * \ingroup prelevement - * \brief Fichier de la classe des bons de prelevements + * \brief File of withdrawal receipts class */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -103,11 +104,11 @@ class BonPrelevement extends CommonObject } /** - * Add facture to withdrawal + * Add invoice to withdrawal * * @param int $facture_id id invoice to add * @param int $client_id id invoice customer - * @param string $client_nom name of cliente + * @param string $client_nom customer name * @param int $amount amount of invoice * @param string $code_banque code of bank withdrawal * @param string $code_guichet code of bank's office @@ -165,7 +166,7 @@ class BonPrelevement extends CommonObject * * @param int $line_id id line to add * @param int $client_id id invoice customer - * @param string $client_nom name of cliente + * @param string $client_nom customer name * @param int $amount amount of invoice * @param string $code_banque code of bank withdrawal * @param string $code_guichet code of bank's office @@ -181,7 +182,7 @@ class BonPrelevement extends CommonObject if ($concat == 1) { /* - * On aggrege les lignes + * We aggregate the lines */ $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes"; @@ -204,7 +205,7 @@ class BonPrelevement extends CommonObject else { /* - * Pas de d'agregation + * No aggregate */ $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_lignes ("; $sql.= "fk_prelevement_bons"; @@ -375,7 +376,7 @@ class BonPrelevement extends CommonObject } /* - * Fin de la procedure + * End of procedure */ if ($error == 0) { @@ -477,7 +478,7 @@ class BonPrelevement extends CommonObject $error++; } } - // Update prelevement line + // Update withdrawal line // TODO: Translate to ligneprelevement.class.php $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; $sql.= " SET statut = 2"; @@ -604,8 +605,8 @@ class BonPrelevement extends CommonObject $arr = array(); /* - * Renvoie toutes les factures presente - * dans un bon de prelevement + * Returns all invoices presented + * within a withdrawal receipt */ $sql = "SELECT fk_facture"; if ($amounts) $sql .= ", SUM(pl.amount)"; @@ -1015,15 +1016,21 @@ class BonPrelevement extends CommonObject $this->date_echeance = $datetimeprev; $this->reference_remise = $ref; - $this->raison_sociale = $conf->global->PRELEVEMENT_RAISON_SOCIALE; + $id=$conf->global->PRELEVEMENT_ID_BANKACCOUNT; + $account = new Account($this->db); + if ($account->fetch($id)>0) + { + $this->emetteur_code_banque = $account->code_banque; + $this->emetteur_code_guichet = $account->code_guichet; + $this->emetteur_numero_compte = $account->number; + $this->emetteur_number_key = $account->cle_rib; + $this->emetteur_iban = $account->iban; + $this->emetteur_bic = $account->bic; - $this->emetteur_code_banque = $conf->global->PRELEVEMENT_CODE_BANQUE; - $this->emetteur_code_guichet = $conf->global->PRELEVEMENT_CODE_GUICHET; - $this->emetteur_numero_compte = $conf->global->PRELEVEMENT_NUMERO_COMPTE; - $this->emetteur_number_key = $conf->global->PRELEVEMENT_NUMBER_KEY; - $this->emetteur_iban = $conf->global->PRELEVEMENT_IBAN; - $this->emetteur_bic = $conf->global->PRELEVEMENT_BIC; - $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; + $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; + + $this->raison_sociale = $account->proprio; + } $this->factures = $factures_prev_id; @@ -1518,7 +1525,8 @@ class BonPrelevement extends CommonObject */ static function buildRumNumber($row_code_client, $row_datec, $row_drum) { - $pre = ($row_datec > 1359673200) ? 'RUM-' : '++R'; + global $langs; + $pre = ($row_datec > 1359673200) ? $langs->trans('RUM').'-' : '++R'; return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } @@ -1558,7 +1566,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR =''; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.('AS-'.$row_facnumber.'-'.$Rowing).''.$CrLf; + $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.round($row_somme, 2).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1673,13 +1681,31 @@ class BonPrelevement extends CommonObject * @return string String with SEPA Sender */ function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n') - { // SEPA INITIALISATION - global $confs; + { + // SEPA INITIALISATION + global $conf; $dateTime_YMD = dol_print_date($ladate, '%Y%m%d'); $dateTime_ETAD = dol_print_date($ladate, '%Y-%m-%d'); $dateTime_YMDHMS = dol_print_date($ladate, '%Y-%m-%dT%H:%M:%S'); + // Get data of bank account + $id=$configuration->global->PRELEVEMENT_ID_BANKACCOUNT; + $account = new Account($this->db); + if ($account->fetch($id)>0) + { + $this->emetteur_code_banque = $account->code_banque; + $this->emetteur_code_guichet = $account->code_guichet; + $this->emetteur_numero_compte = $account->number; + $this->emetteur_number_key = $account->cle_rib; + $this->emetteur_iban = $account->iban; + $this->emetteur_bic = $account->bic; + + $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; + + $this->raison_sociale = $account->proprio; + } + // Récupération info demandeur $sql = "SELECT rowid, ref"; $sql.= " FROM"; @@ -1714,7 +1740,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($configuration->global->PRELEVEMENT_RAISON_SOCIALE)).''.$CrLf; + $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($configuration->global->MAIN_INFO_SOCIETE_ADDRESS)).''.$CrLf; @@ -1723,16 +1749,16 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.preg_replace('/\s/', '', $configuration->global->PRELEVEMENT_IBAN).''.$CrLf; + $XML_SEPA_INFO .= ' '.preg_replace('/\s/', '', $this->emetteur_iban).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$configuration->global->PRELEVEMENT_BIC.''.$CrLf; + $XML_SEPA_INFO .= ' '.$this->emetteur_bic.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$configuration->global->PRELEVEMENT_RAISON_SOCIALE.''.$CrLf; + $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; @@ -1744,7 +1770,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$configuration->global->PRELEVEMENT_ICS.''.$CrLf; + $XML_SEPA_INFO .= ' '.$this->emetteur_ics.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' SEPA'.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 3350f5c34a3..8be897990ed 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -122,7 +122,7 @@ if ($nb < 0 || $nb1 < 0 || $nb11 < 0) } print '
'.$langs->trans('Ref').'
'.$langs->trans('Ref').''; print $form->showrefnav($paiement,'id','',1,'rowid','id'); print '
'.$langs->trans('Date').''.dol_print_date($paiement->datep,'day').'
'.$langs->trans('Date').''.dol_print_date($paiement->datep,'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$paiement->type_code).'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$paiement->type_code).'
'.$langs->trans('Numero').''.$paiement->num_paiement.'
'.$langs->trans('Numero').''.$paiement->num_paiement.'
'.$langs->trans('Amount').''.price($paiement->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Amount').''.price($paiement->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($paiement->note).'
'.$langs->trans('Note').''.nl2br($paiement->note).'
'; -print ''; +print ''; print ''; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index f39fd0780ad..ea0070ef50b 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -415,7 +415,7 @@ if ($id) } else { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } print ""; } diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index f279e97b478..3e3fca22ffa 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2016 Laurent Destailleur - * Copyright (C) 2015 Jean-François Ferry +/* Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2015-2016 Laurent Destailleur + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -25,6 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("compta"); $langs->load("salaries"); @@ -40,6 +41,8 @@ $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); $search_label = GETPOST('search_label','alpha'); $search_amount = GETPOST('search_amount','alpha'); +$search_account = GETPOST('search_account','int'); + $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -68,11 +71,12 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; $search_amount=""; + $search_account=''; $typeid=""; } @@ -85,12 +89,16 @@ llxHeader(); $form = new Form($db); $salstatic = new PaymentSalary($db); $userstatic = new User($db); +$accountstatic = new Account($db); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc,"; -$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.datev as datev, s.fk_typepayment as type, s.num_payment,"; +$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; +$sql.= " ba.rowid as bid, ba.label as blabel,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE u.rowid = s.fk_user"; $sql.= " AND s.entity = ".$conf->entity; @@ -100,6 +108,7 @@ if ($search_ref) $sql.=" AND s.rowid=".$search_ref; if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email', 'u.note'), $search_user); if ($search_label) $sql.=natural_search(array('s.label'), $search_label); if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1); +if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; @@ -145,11 +154,11 @@ if ($result) print '
'.$langs->trans("NbOfInvoiceToWithdraw").'
'.$langs->trans("NbOfInvoiceToWithdraw").''; print $nb; print '
'; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.salary","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Employee"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); + if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -159,12 +168,10 @@ if ($result) print ''; - // People + // Employee print ''; - // Current salary - print ''; // Label print ''; // Date @@ -173,6 +180,13 @@ if ($result) print ''; + // Account + if (! empty($conf->banque->enabled)) + { + print ''; + } // Amount print ''; @@ -200,17 +214,29 @@ if ($result) $salstatic->ref=$obj->rowid; // Ref print "\n"; - // User name + // Employee print "\n"; - // Current salary - print "\n"; // Label payment print "\n"; // Date payment print '\n"; // Type print ''; - // Amount + // Account + if (! empty($conf->banque->enabled)) + { + print ''; + } + // Amount print ""; print ""; print "\n"; @@ -219,8 +245,10 @@ if ($result) $i++; } - - print ''; + + $colspan=5; + if (! empty($conf->banque->enabled)) $colspan++; + print ''; print '"; print ""; diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/card.php similarity index 96% rename from htdocs/compta/sociales/charges.php rename to htdocs/compta/sociales/card.php index f5a6cc2f6a9..8c21bf32ceb 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/card.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/compta/sociales/charges.php + * \file htdocs/compta/sociales/card.php * \ingroup tax * \brief Social contribution card page */ @@ -382,7 +382,7 @@ if ($id > 0) if ($action == 'edit') { - print "id&action=update\" method=\"post\">"; + print "id&action=update\" method=\"post\">"; print ''; } @@ -585,13 +585,13 @@ if ($id > 0) // Reopen if ($object->paye && $user->rights->tax->charges->creer) { - print "id&action=reopen\">".$langs->trans("ReOpen").""; + print "id&action=reopen\">".$langs->trans("ReOpen").""; } // Edit if ($object->paye == 0 && $user->rights->tax->charges->creer) { - print "id&action=edit\">".$langs->trans("Modify").""; + print "id&action=edit\">".$langs->trans("Modify").""; } // Emit payment @@ -603,19 +603,19 @@ if ($id > 0) // Classify 'paid' if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer) { - print "id&action=paid\">".$langs->trans("ClassifyPaid").""; + print "id&action=paid\">".$langs->trans("ClassifyPaid").""; } // Clone if ($user->rights->tax->charges->creer) { - print "id&action=clone\">".$langs->trans("ToClone").""; + print "id&action=clone\">".$langs->trans("ToClone").""; } // Delete if ($user->rights->tax->charges->supprimer) { - print "id&action=delete\">".$langs->trans("Delete").""; + print "id&action=delete\">".$langs->trans("Delete").""; } print ""; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index af3acbf4c7f..ca9af965758 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -449,7 +449,7 @@ class ChargeSociales extends CommonObject if (empty($this->ref)) $this->ref=$this->lib; $label = $langs->trans("ShowSocialContribution").': '.$this->ref; - $link = ''; + $link = ''; $linkend=''; if ($withpicto) $result.=($link.img_object($label, 'bill', 'class="classfortooltip"').$linkend.' '); diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index e3bf17b3418..1d553831f99 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -23,6 +23,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; /** @@ -64,10 +65,11 @@ class PaymentSocialContribution extends CommonObject * Create payment of social contribution into database. * Use this->amounts to have list of lines for the payment * - * @param User $user User making payment - * @return int <0 if KO, id of payment if OK + * @param User $user User making payment + * @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more + * @return int <0 if KO, id of payment if OK */ - function create($user) + function create($user, $closepaidcontrib=0) { global $conf, $langs; @@ -75,7 +77,9 @@ class PaymentSocialContribution extends CommonObject $now=dol_now(); - // Validate parametres + dol_syslog(get_class($this)."::create", LOG_DEBUG); + + // Validate parametres if (! $this->datepaye) { $this->error='ErrorBadValueForParameterCreatePaymentSocialContrib'; @@ -117,11 +121,40 @@ class PaymentSocialContribution extends CommonObject $sql.= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; $sql.= " 0)"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge"); + + // Insere tableau des montants / factures + foreach ($this->amounts as $key => $amount) + { + $contribid = $key; + if (is_numeric($amount) && $amount <> 0) + { + $amount = price2num($amount); + + // If we want to closed payed invoices + if ($closepaidcontrib) + { + + $contrib=new ChargeSociales($this->db); + $contrib->fetch($contribid); + $paiement = $contrib->getSommePaiement(); + //$creditnotes=$contrib->getSumCreditNotesUsed(); + $creditnotes=0; + //$deposits=$contrib->getSumDepositsUsed(); + $deposits=0; + $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); + $remaintopay=price2num($contrib->amount - $paiement - $creditnotes - $deposits,'MT'); + if ($remaintopay == 0) + { + $result=$contrib->set_paid($user, '', ''); + } + else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); + } + } + } } else { diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 15ca799c1c2..fc106de2ad1 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2016 Frédéric France * @@ -233,7 +233,7 @@ if ($resql) print ''; // Type - print ''; + print ''; // Date end period print ''; -print ''; print ''; @@ -338,6 +360,33 @@ print_liste_field_titre( "", $sortfield,$sortorder ); +print_liste_field_titre( + $langs->trans("Zip"), + $_SERVER["PHP_SELF"], + "zip", + "", + $paramslink, + "", + $sortfield,$sortorder + ); +print_liste_field_titre( + $langs->trans("Town"), + $_SERVER["PHP_SELF"], + "town", + "", + $paramslink, + "", + $sortfield,$sortorder + ); +print_liste_field_titre( + $langs->trans("Country"), + $_SERVER["PHP_SELF"], + "country", + "", + $paramslink, + "", + $sortfield,$sortorder + ); if ($modecompta == 'CREANCES-DETTES') { print_liste_field_titre( $langs->trans('AmountHT'), @@ -381,6 +430,27 @@ print_liste_field_titre( 'align="center" width="20%"' ); print "\n"; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + $var=true; if (count($amount)) { @@ -410,6 +480,30 @@ if (count($amount)) { arsort($amount); $arrayforsort=$amount; } + if ($sortfield == 'zip' && $sortorder == 'asc') { + asort($address_zip); + $arrayforsort=$address_zip; + } + if ($sortfield == 'zip' && $sortorder == 'desc') { + arsort($address_zip); + $arrayforsort=$address_zip; + } + if ($sortfield == 'town' && $sortorder == 'asc') { + asort($address_town); + $arrayforsort=$address_town; + } + if ($sortfield == 'town' && $sortorder == 'desc') { + arsort($address_town); + $arrayforsort=$address_town; + } + if ($sortfield == 'country' && $sortorder == 'asc') { + asort($address_pays); + $arrayforsort=$address_town; + } + if ($sortfield == 'country' && $sortorder == 'desc') { + arsort($address_pays); + $arrayforsort=$address_town; + } foreach($arrayforsort as $key=>$value) { $var=!$var; @@ -427,6 +521,18 @@ if (count($amount)) { } print "\n"; + print ''; + + print ''; + + print ''; + // Amount w/o VAT print ''; print ''; + print ''; + print ''; + print ''; if ($modecompta != 'CREANCES-DETTES') { print ''; } else { diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index eb887054151..17bcd80757c 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * @@ -266,19 +266,19 @@ if ($action == 'create') print ''; + } - // Type payment - print '\n"; - print ""; - - // Number - print ''."\n"; - } - + // Type payment + print '\n"; + print ""; + + // Number + print ''."\n"; + // Other attributes $parameters=array('colspan' => ' colspan="1"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -365,8 +365,8 @@ if ($id) /* - * Boutons d'actions - */ + * Action buttons + */ print "
\n"; if ($object->rappro == 0) { @@ -381,7 +381,7 @@ if ($id) } else { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } print "
"; } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index f6308a3790d..30d9655acc8 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -123,17 +123,9 @@ print $langs->trans("VATReportBuildWithOptionDefinedInModule").'
'; print '('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')
'; print '
'; -print '
'; print ''; print ''; print ''; print ' '; $form->select_types_paiements($typeid,'typeid','',0,0,1,16); print ''; + $form->select_comptes($search_account,'search_account',0,'',1); + print '".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".($obj->salary?price($obj->salary):'')."".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->datep),'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id=$obj->bid; + $accountstatic->label=$obj->blabel; + print $accountstatic->getNomUrl(1); + } + else print ' '; + print '".price($obj->amount)."
'.$langs->trans("Total").'
'.$langs->trans("Total").''.price($total)."
'.dol_trunc($obj->libelle,42).''.dol_trunc($obj->type_lib,16).''.$obj->type_lib.''; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php new file mode 100644 index 00000000000..017bcb7686e --- /dev/null +++ b/htdocs/compta/sociales/payments.php @@ -0,0 +1,490 @@ + + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * + * 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 . + */ + +/** + * \file htdocs/compta/sociales/payments.php + * \ingroup compta + * \brief Page to list payments of special expenses + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + +$langs->load("compta"); +$langs->load("bills"); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); + +$mode=GETPOST("mode",'alpha'); +$year=GETPOST("year",'int'); +$filtre=GETPOST("filtre",'alpha'); +if (! $year && $mode != 'sconly') { $year=date("Y", time()); } + +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield="pc.datep"; +if (! $sortorder) $sortorder="DESC"; + + +/* + * View + */ + +$tva_static = new Tva($db); +$socialcontrib=new ChargeSociales($db); +$payment_sc_static=new PaymentSocialContribution($db); +$sal_static = new PaymentSalary($db); + +llxHeader('',$langs->trans("SpecialExpensesArea")); + +$title=$langs->trans("SpecialExpensesArea"); +if ($mode == 'sconly') $title=$langs->trans("SocialContributionsPayments"); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($mode == 'sconly') $param='&mode=sconly'; +if ($sortfield) $param.='&sortfield='.$sortfield; +if ($sortorder) $param.='&sortorder='.$sortorder; + + +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +if ($mode != 'sconly') +{ + $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); + print_barre_liste($title,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$center,$num,$totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); +} +else +{ + print_barre_liste($title,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$center,$num,$totalnboflines, 'title_accountancy', 0, '', '', $limit); +} + +if ($year) $param.='&year='.$year; + +if ($mode != 'sconly') +{ + print $langs->trans("DescTaxAndDividendsArea").'
'; + print "
"; +} + +if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +{ + // Social contributions only + if ($mode != 'sconly') + { + print load_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + } + + print ''; + print ''; + print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pc.rowid","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"pc.datep","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"pct.code","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("LabelContrib"),$_SERVER["PHP_SELF"],"c.libelle","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("TypeContrib"),$_SERVER["PHP_SELF"],"cs.fk_type","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="140px"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"pc.amount","",$param,'align="right"',$sortfield,$sortorder); + print "\n"; + + $sql = "SELECT c.id, c.libelle as lib,"; + $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; + $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,"; + $sql.= " pct.code as payment_code"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; + $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs,"; + $sql.= " ".MAIN_DB_PREFIX."paiementcharge as pc"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; + $sql.= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid"; + $sql.= " AND cs.entity = ".$conf->entity; + if ($year > 0) + { + $sql .= " AND ("; + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; + $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; + $sql .= ")"; + } + if (preg_match('/^cs\./',$sortfield) || preg_match('/^c\./',$sortfield) || preg_match('/^pc\./',$sortfield) || preg_match('/^pct\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder); + //$sql.= $db->plimit($limit+1,$offset); + //print $sql; + + dol_syslog("compta/sociales/payments.php: select payment", LOG_DEBUG); + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $total = 0; + $totalnb = 0; + $totalpaye = 0; + $var=true; + + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + $var = !$var; + print ""; + // Ref payment + $payment_sc_static->id=$obj->pid; + $payment_sc_static->ref=$obj->pid; + print '\n"; + // Date payment + print ''; + // Type payment + print ''; + // Label + print ''; + // Type + print ''; + // Date + $date=$obj->periode; + if (empty($date)) $date=$obj->date_ech; + print ''; + // Expected to pay + print ''; + // Paid + print ''; + print ''; + + $total = $total + $obj->total; + $totalnb = $totalnb + $obj->nb; + $totalpaye = $totalpaye + $obj->totalpaye; + $i++; + } + print ''; + print ''; // A total here has no sense + print ''; + print ''; + print ''; + print '"; + print ""; + } + else + { + dol_print_error($db); + } + print '
'.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep),'day').''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; + $socialcontrib->id=$obj->rowid; + $socialcontrib->ref=$obj->libelle; + $socialcontrib->lib=$obj->libelle; + print $socialcontrib->getNomUrl(1,'20'); + print ''.$obj->lib.''.dol_print_date($date,'day').''.price($obj->total).''; + if ($obj->totalpaye) print price($obj->totalpaye); + print '
'.$langs->trans("Total").'   '.price($totalpaye)."
'; +} + +// VAT +if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +{ + if (! $mode || $mode != 'sconly') + { + print "
"; + + $tva = new Tva($db); + + print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm"; + $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; + $sql.= " WHERE pv.entity = ".$conf->entity; + if ($year > 0) + { + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } + if (preg_match('/^pv\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0 ; + print ''; + print ''; + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="140px"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); + print "\n"; + $var=1; + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + $var=!$var; + print ""; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $tva_static->id=$obj->rowid; + $tva_static->ref=$obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print ''; + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dm),'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm),'day')."'.price($obj->amount)."
'.$langs->trans("Total").''.price($total).'  '.price($total)."
"; + $db->free($result); + } + else + { + dol_print_error($db); + } + } +} + +// Localtax +if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") +{ + $j=1; + $numlt=3; +} +elseif($mysoc->localtax1_assuj=="1") +{ + $j=1; + $numlt=2; +} +elseif($mysoc->localtax2_assuj=="1") +{ + $j=2; + $numlt=3; +} +else +{ + $j=0; + $numlt=0; +} + +while($j<$numlt) +{ + if (! $mode || $mode != 'sconly') + { + print "
"; + + $tva = new Tva($db); + + print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"),$mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + + + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; + $sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv"; + $sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ; + if ($year > 0) + { + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } + if (preg_match('/^pv/',$sortfield)) $sql.= $db->order($sortfield,$sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0 ; + print ''; + print ''; + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"pv.datep","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); + print "\n"; + $var=1; + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + $var=!$var; + print ""; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $tva_static->id=$obj->rowid; + $tva_static->ref=$obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print '"; + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dm),'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp),'day')."'.price($obj->amount)."
'.$langs->trans("Total").''.price($total)."  '.price($total)."
"; + $db->free($result); + } + else + { + dol_print_error($db); + } + } + $j++; +} + + +// Payment Salary +if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) +{ + if (! $mode || $mode != 'sconly') + { + $sal = new PaymentSalary($db); + + print "
"; + + print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + + $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary"; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE s.entity IN (".getEntity('user',1).")"; + $sql.= " AND u.rowid = s.fk_user"; + if ($year > 0) + { + $sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."')"; + } + if (preg_match('/^s\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0 ; + print ''; + print ''; + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.dateep","",$param,'width="140px"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); + print "\n"; + $var=1; + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + $var=!$var; + print ""; + + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $sal_static->id=$obj->rowid; + $sal_static->ref=$obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print ''; // A total here has no sense + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dateep),'day').'".$obj->label."'.($obj->salary?price($obj->salary):'')."'.$sal_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep),'day')."'.price($obj->amount)."
'.$langs->trans("Total").'  '.price($total)."
"; + $db->free($result); + + print "
"; + } + else + { + dol_print_error($db); + } + } +} + +print ''; + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index dade07fd0e3..d00525796c0 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -27,13 +27,17 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $langs->load("companies"); $langs->load("categories"); +$langs->load("bills"); +$langs->load("compta"); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') $modecompta = $conf->global->ACCOUNTING_MODE; @@ -61,6 +65,10 @@ if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accountin // Date range $year=GETPOST("year"); $month=GETPOST("month"); +$search_societe = GETPOST("search_societe"); +$search_zip = GETPOST("search_zip"); +$search_town = GETPOST("search_town"); +$search_country = GETPOST("search_country"); $date_startyear = GETPOST("date_startyear"); $date_startmonth = GETPOST("date_startmonth"); $date_startday = GETPOST("date_startday"); @@ -128,6 +136,10 @@ $headerparams['q'] = $q; $tableparams = array(); $tableparams['search_categ'] = $selected_cat; +$tableparams['search_societe'] = $search_societe; +$tableparams['search_zip'] = $search_zip; +$tableparams['search_town'] = $search_town; +$tableparams['search_country'] = $search_country; $tableparams['subcat'] = ($subcat === true)?'yes':''; // Adding common parameters @@ -180,7 +192,7 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl // Show Array $catotal=0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name,"; + $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,"; $sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if ($selected_cat === -2) // Without any category @@ -216,7 +228,7 @@ if ($modecompta == 'CREANCES-DETTES') { * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) */ - $sql = "SELECT s.rowid as socid, s.nom as name, sum(pf.amount) as amount_ttc"; + $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; @@ -246,9 +258,13 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } } +if(!empty($search_societe)) $sql.= ' AND s.nom LIKE "%'.$search_societe.'%"'; +if(!empty($search_zip)) $sql.= ' AND s.zip LIKE "%'.$search_zip.'%"'; +if(!empty($search_town)) $sql.= ' AND s.town LIKE "%'.$search_town.'%"'; +if($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.''; $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; -$sql.= " GROUP BY s.rowid, s.nom"; +$sql.= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays"; $sql.= " ORDER BY s.rowid"; //echo $sql; @@ -262,6 +278,9 @@ if ($result) { $amount_ht[$obj->socid] = $obj->amount; $amount[$obj->socid] = $obj->amount_ttc; $name[$obj->socid] = $obj->name.' '.$obj->firstname; + $address_zip[$obj->socid] = $obj->zip; + $address_town[$obj->socid] = $obj->town; + $address_pays[$obj->socid] = getCountry($obj->fk_pays); $catotal_ht+=$obj->amount; $catotal+=$obj->amount_ttc; $i++; @@ -294,6 +313,9 @@ if ($modecompta != 'CREANCES-DETTES') { $obj = $db->fetch_object($result); $amount[$obj->rowid] += $obj->amount_ttc; $name[$obj->rowid] = $obj->name; + $address_zip[$obj->rowid] = $obj->zip; + $address_town[$obj->rowid] = $obj->town; + $address_pays[$obj->rowid] = getCountry($obj->fk_pays); $catotal+=$obj->amount_ttc; $i++; } @@ -323,7 +345,7 @@ if ($subcat) { print ' checked'; } print'>
'; +print ''; print ''; print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print $form->select_country($search_country, 'search_country'); +//print ''; +print '    
".$linkname."'; + print $address_zip[$key]; + print ''; + print $address_town[$key]; + print ''; + print $address_pays[$key]; + print ''; if ($modecompta != 'CREANCES-DETTES') { @@ -486,6 +592,9 @@ if (count($amount)) { // Total print '
'.$langs->trans("Total").'   
'.$langs->trans("Account").''; $form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant print '
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST("type_payment"), "type_payment"); - print "
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(GETPOST("type_payment"), "type_payment"); + print "
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'; -print ''; +print '
'; -print '
'; -print '
'; -print load_fiche_titre($langs->trans("VATSummary"), '', ''); -// The report mode is the one defined by defaut in tax module setup -//print $modetax; -//print '('.$langs->trans("SeeVATReportInInputOutputMode",'','').')'; -print ''; -print load_fiche_titre($langs->trans("VATPaid"), '', ''); -print '
'; +print load_fiche_titre($langs->trans("VATSummary"), '', ''); print ''; print ''; @@ -223,18 +215,12 @@ print '\n"; print ''; -/*} - else - { - print ''; - print ''; - }*/ - print '
'.$langs->trans("To print " 
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("FeatureIsSupportedInInOutModeOnly").'
'; -print '
'; +print '
'; + +print load_fiche_titre($langs->trans("VATPaid"), '', ''); /* * Payed @@ -250,10 +236,7 @@ $sql.= " GROUP BY dm ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); -print "
"; - -print '
'; +print ''; llxFooter(); $db->close(); diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 5484be65a32..d5bcbeeb06a 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -26,6 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -40,6 +41,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); $search_ref = GETPOST('search_ref','int'); $search_label = GETPOST('search_label','alpha'); $search_amount = GETPOST('search_amount','alpha'); +$search_account = GETPOST('search_account','int'); $month = GETPOST("month","int"); $year = GETPOST("year","int"); @@ -71,16 +73,18 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; $search_label=""; $search_amount=""; + $search_account=''; $year=""; $month=""; $typeid=""; } + /* * View */ @@ -90,14 +94,19 @@ llxHeader(); $form = new Form($db); $formother=new FormOther($db); $tva_static = new Tva($db); +$accountstatic = new Account($db); -$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, pst.code as payment_code"; +$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,"; +$sql.= " ba.rowid as bid, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql.= " WHERE t.entity = ".$conf->entity; if ($search_ref) $sql.=" AND t.rowid=".$search_ref; if ($search_label) $sql.=" AND t.label LIKE '%".$db->escape($search_label)."%'"; if ($search_amount) $sql.=" AND t.amount='".$db->escape(price2num(trim($search_amount)))."'"; +if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($month > 0) { if ($year > 0) @@ -155,8 +164,9 @@ if ($result) print_liste_field_titre($langs->trans("DateValue"),$_SERVER["PHP_SELF"],"dv","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"dp","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); + if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("Account"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"t.amount","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "
'; $form->select_types_paiements($typeid,'typeid','',0,0,1,16); print ''; + $form->select_comptes($search_account,'search_account',0,'',1); + print ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); print $searchpitco; @@ -204,15 +220,32 @@ if ($result) print ''.dol_print_date($db->jdate($obj->dp),'day')."'; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id=$obj->bid; + $accountstatic->label=$obj->blabel; + print $accountstatic->getNomUrl(1); + } + else print ' '; + print '".price($obj->amount)."  
'.$langs->trans("Total").'
'.$langs->trans("Total").'".price($total)." 
'; - - // Ref facture - print ''; - $facture_static->ref=$objp->facnumber; - $facture_static->id=$objp->facid; - print ''; - print ''; - - print ''; - print ''; - print ''; - - if($objp->fk_code_ventilation == 0) - { - print ''; - } - print '
'.$langs->trans("Invoice").''.$facture_static->getNomUrl(1).'
Ligne'.nl2br($objp->description).'
Ventiler dans le compte :'; - - if($objp->fk_code_ventilation == 0) - { - print $form->selectarray("codeventil",$cgs, $objp->fk_code_ventilation); - } - else - { - print $cgs[$objp->fk_code_ventilation]; - } - - print '
 
'; - print ''; - } - else - { - print "Error"; - } - } - else - { - print "Error"; - } -} -else -{ - print "Error ID incorrect"; -} - -llxFooter(); -$db->close(); diff --git a/htdocs/compta/ventilation/fournisseur/card.php b/htdocs/compta/ventilation/fournisseur/card.php deleted file mode 100644 index dc376de7c06..00000000000 --- a/htdocs/compta/ventilation/fournisseur/card.php +++ /dev/null @@ -1,148 +0,0 @@ - - * Copyright (C) 2005 Simon TOSSER - * - * 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 . - * - */ - -/** - * \file htdocs/compta/ventilation/fournisseur/card.php - * \ingroup compta - * \brief Page fiche ventilation - */ - -require '../../../main.inc.php'; - -$mesg = ''; - -if (!$user->rights->compta->ventilation->creer) accessforbidden(); - -if ($_POST["action"] == 'ventil' && $user->rights->compta->ventilation->creer) -{ - $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; - $sql .= " SET fk_code_ventilation = ".$_POST["codeventil"]; - $sql .= " WHERE rowid = ".$_GET["id"]; - - $db->query($sql); -} - -llxHeader("","","Fiche ventilation"); - -if ($cancel == $langs->trans("Cancel")) -{ - $action = ''; -} -/* - * - * - */ - -$sql = "SELECT rowid, numero, intitule"; -$sql .= " FROM ".MAIN_DB_PREFIX."compta_compte_generaux"; -$sql .= " ORDER BY numero ASC"; - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - $i = 0; - - while ($i < $num) - { - $row = $db->fetch_row($result); - $cgs[$row[0]] = $row[1] . ' ' . $row[2]; - $i++; - } -} - -/* - * Creation - * - */ -$form = new Form($db); - -if($_GET["id"]) -{ - $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ttc, l.qty, l.rowid, l.tva_tx, l.fk_code_ventilation "; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l"; - $sql .= " , ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql .= " WHERE f.rowid = l.fk_facture_fourn AND f.fk_statut = 1 AND l.rowid = ".$_GET["id"]; - - $result = $db->query($sql); - - if ($result) - { - $num_lignes = $db->num_rows($result); - $i = 0; - - if ($num_lignes) - { - - $objp = $db->fetch_object($result); - - - if($objp->fk_code_ventilation == 0) - { - print '
'."\n"; - print ''; - print ''; - } - - - print load_fiche_titre("Ventilation"); - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - - if($objp->fk_code_ventilation == 0) - { - print ''; - } - print '
Facture'.$objp->facnumber.'
Ligne'.stripslashes(nl2br($objp->description)).'
Ventiler dans le compte :'; - - if($objp->fk_code_ventilation == 0) - { - print $form->selectarray("codeventil",$cgs, $objp->fk_code_ventilation); - } - else - { - print $cgs[$objp->fk_code_ventilation]; - } - - print '
 
'; - print '
'; - } - else - { - print "Error"; - } - } - else - { - print "Error"; - } -} -else -{ - print "Error ID incorrect"; -} - -llxFooter(); -$db->close(); diff --git a/htdocs/compta/ventilation/fournisseur/list.php b/htdocs/compta/ventilation/fournisseur/list.php deleted file mode 100644 index 20ca396aa30..00000000000 --- a/htdocs/compta/ventilation/fournisseur/list.php +++ /dev/null @@ -1,105 +0,0 @@ - - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004 Laurent Destailleur - * - * 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 . - * - */ - - -/** - * \file htdocs/compta/ventilation/list.php - * \ingroup compta - * \brief Page de ventilation des lignes de facture - */ - -require '../../../main.inc.php'; - -$langs->load("bills"); - -if (!$user->rights->facture->lire) accessforbidden(); -if (!$user->rights->compta->ventilation->creer) accessforbidden(); -/* - * Securite acces client - */ -if ($user->societe_id > 0) accessforbidden(); - - -llxHeader('','Ventilation'); - -/* - * Lignes de factures - * - */ -$page = $_GET["page"]; -if ($page < 0) $page = 0; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$offset = $limit * $page ; - -$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ttc as price, l.rowid, l.fk_code_ventilation "; -$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l"; -$sql .= " , ".MAIN_DB_PREFIX."facture_fourn as f"; -$sql .= " WHERE f.rowid = l.fk_facture_fourn AND f.fk_statut = 1 AND fk_code_ventilation = 0"; -$sql .= " ORDER BY l.rowid DESC ".$db->plimit($limit+1,$offset); - -$result = $db->query($sql); -if ($result) -{ - $num_lignes = $db->num_rows($result); - $i = 0; - - print_barre_liste("Lignes de facture à ventiler",$page,"list.php","",$sortfield,$sortorder,'',$num_lignes); - - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < min($num_lignes, $limit)) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - - print ''; - print ''; - - print ''; - - print ''; - - print ""; - $i++; - } - -print "
Facture'.$langs->trans("Description").'  
'.$objp->facnumber.''.stripslashes(nl2br($objp->description)).''; - print price($objp->price); - print ''; - print img_edit(); - print '
"; - - - -} -else -{ - print $db->error(); -} - -llxFooter(); -$db->close(); diff --git a/htdocs/compta/ventilation/list.php b/htdocs/compta/ventilation/list.php deleted file mode 100644 index fc022cade0d..00000000000 --- a/htdocs/compta/ventilation/list.php +++ /dev/null @@ -1,129 +0,0 @@ - - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2006 Laurent Destailleur - * - * 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 . - * - */ - - -/** - * \file htdocs/compta/ventilation/list.php - * \ingroup compta - * \brief Page de ventilation des lignes de facture - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - -$langs->load("compta"); -$langs->load("bills"); - -if (!$user->rights->facture->lire) accessforbidden(); -if (!$user->rights->compta->ventilation->creer) accessforbidden(); - -// Securite acces client -if ($user->societe_id > 0) accessforbidden(); - - -llxHeader('','Ventilation'); - -/* - * Lignes de factures - */ - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, f.total as price, l.rowid, l.fk_code_ventilation,"; -$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type"; -$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; -$sql.= " , ".MAIN_DB_PREFIX."facturedet as l"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; -$sql.= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND fk_code_ventilation = 0"; -$sql.= " AND f.entity = ".$conf->entity; -$sql.= " ORDER BY l.rowid DESC ".$db->plimit($limit+1,$offset); - -$result = $db->query($sql); -if ($result) -{ - $num_lignes = $db->num_rows($result); - $i = 0; - - print_barre_liste($langs->trans("InvoiceLinesToDispatch"),$page,"list.php","",$sortfield,$sortorder,'',$num_lignes); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $facture_static=new Facture($db); - $product_static=new Product($db); - - $var=True; - while ($i < min($num_lignes, $limit)) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - - // Ref facture - $facture_static->ref=$objp->facnumber; - $facture_static->id=$objp->facid; - print ''; - - // Ref produit - $product_static->ref=$objp->product_ref; - $product_static->id=$objp->product_id; - $product_static->type=$objp->type; - print ''; - - print ''; - print ''; - - print ''; - - print ''; - - print ""; - $i++; - } - print "
'.$langs->trans("Invoice").''.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("Description").''.$langs->trans("Montant").' 
'.$facture_static->getNomUrl(1).''; - if ($product_static->id) print $product_static->getNomUrl(1); - else print ' '; - print ''.dol_trunc($objp->product_label,24).''.nl2br(dol_trunc($objp->description,32)).''; - print price($objp->price); - print ''; - print img_edit(); - print '
"; -} -else -{ - print $db->error(); -} - -llxFooter(); -$db->close(); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 512beec77ef..31eb96d633f 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * @@ -529,10 +529,10 @@ else // Name - print '
lastname).'" autofocus="autofocus">firstname).'">
lastname).'" autofocus="autofocus">firstname).'">
'; + print '
'; print $formcompany->select_civility(GETPOST("civility_id",'alpha')?GETPOST("civility_id",'alpha'):$object->civility_id); print '
lastname).'" autofocus="autofocus">firstname).'">
lastname).'" autofocus="autofocus">firstname).'">
'; $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); @@ -902,7 +902,7 @@ else print $doleditor->Create(1); print '
'.$langs->trans("Status").''; print $object->getLibStatut(4); @@ -1058,7 +1058,7 @@ else // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - print '
'.$langs->trans("ThirdParty").''; + print '
'.$langs->trans("ThirdParty").''; if ($object->socid > 0) { $objsoc->fetch($object->socid); @@ -1074,7 +1074,7 @@ else print '
'.$langs->trans("UserTitle").''; + print '
'.$langs->trans("UserTitle").''; print $object->getCivilityLabel(); print '
' . $langs->trans( "Categories" ) . '
' . $langs->trans("Categories") . ''; print $form->showCategories( $object->id, 'contact', 1 ); print '
'.$langs->trans("ContactForProposals").''; + print '
'.$langs->trans("ContactForProposals").''; print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); print '
'; if ($obj->socid) { - print ''; - print img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,20).''; + $objsoc = new Societe($db); + $objsoc->fetch($obj->socid); + print $objsoc->getNomUrl(1); } else - { print ' '; - } print '
'.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).'
'.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).'
'.$langs->trans("ThirdParty").''; + print '
'.$langs->trans("ThirdParty").''; print $langs->trans("ContactNotLinkedToCompany"); print '
'.$langs->trans("UserTitle").''; + print '
'.$langs->trans("UserTitle").''; print $object->getCivilityLabel(); print '
'.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); + print ''.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); print '   '; //var_dump($birthdatearray); @@ -138,17 +142,16 @@ if ($id > 0) } else { - print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown")."'.$langs->trans("DateToBirth").''.$langs->trans("Unknown")."
"; - print '
'; + //print '
'; - print '
'; + //print '
'; - $cssclass='titlefield'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 5feafcbb6b3..03e62523922 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -151,12 +151,12 @@ if ($action == 'edit') print ''; // Ref - print ''; // Photo - print ''; // Name - print ''; - print ''; + print ''; + print ''; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index ccb3d1d314c..347d77e84dd 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -214,7 +214,7 @@ if (empty($reshook)) if ($socid<1) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors'); $action='create'; $error++; } @@ -796,7 +796,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $result = $object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); + $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref_supplier'; @@ -821,7 +821,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $result = $object->setValueFrom('ref_customer',GETPOST('ref_customer','alpha')); + $result = $object->setValueFrom('ref_customer', GETPOST('ref_customer','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref_customer'; @@ -845,7 +845,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $result = $object->setValueFrom('ref',GETPOST('ref','alpha')); + $result = $object->setValueFrom('ref', GETPOST('ref','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref'; @@ -869,7 +869,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } $datacontrat=dol_mktime(GETPOST('date_contrathour'), GETPOST('date_contratmin'), 0, GETPOST('date_contratmonth'), GETPOST('date_contratday'), GETPOST('date_contratyear')); - $result = $object->setValueFrom('date_contrat',$datacontrat,'',null,'date'); + $result = $object->setValueFrom('date_contrat', $datacontrat, '', null, 'date', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'editdate_contrat'; @@ -1427,7 +1427,7 @@ else { $total = 0; - print ''; + print ''; print ''; print ''; print ''; @@ -1542,7 +1542,11 @@ else { print dol_print_date($db->jdate($objp->date_debut)); // Warning si date prevu passee et pas en service - if ($objp->statut == 0 && $db->jdate($objp->date_debut) < ($now - $conf->contrat->services->inactifs->warning_delay)) { print " ".img_warning($langs->trans("Late")); } + if ($objp->statut == 0 && $db->jdate($objp->date_debut) < ($now - $conf->contrat->services->inactifs->warning_delay)) { + $warning_delay=$conf->contrat->services->inactifs->warning_delay / 3600 / 24; + $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); + print " ".img_warning($textlate); + } } else print $langs->trans("Unknown"); print '  -  '; @@ -1550,7 +1554,11 @@ else if ($objp->date_fin) { print dol_print_date($db->jdate($objp->date_fin)); - if ($objp->statut == 4 && $db->jdate($objp->date_fin) < ($now - $conf->contrat->services->expires->warning_delay)) { print " ".img_warning($langs->trans("Late")); } + if ($objp->statut == 4 && $db->jdate($objp->date_fin) < ($now - $conf->contrat->services->expires->warning_delay)) { + $warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24; + $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); + print " ".img_warning($textlate); + } } else print $langs->trans("Unknown"); @@ -1950,6 +1958,13 @@ else else print ''; } + if (! empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) + { + $langs->load("bills"); + if ($user->rights->facture->creer) print ''; + else print ''; + } + if ($object->nbofservicesclosed < $nbofservices) { //if (! $numactive) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 578a1888ecb..d12fa566284 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García @@ -354,7 +354,7 @@ class Contrat extends CommonObject * * @param User $user Objet User * @param string $force_number Reference to force on contract (not implemented yet) - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ function validate($user, $force_number='', $notrigger=0) @@ -904,6 +904,7 @@ class Contrat extends CommonObject } if (! $paramsok) return -1; + $this->db->begin(); $now=dol_now(); @@ -1231,7 +1232,6 @@ class Contrat extends CommonObject $error=0; // Clean parameters - if (isset($this->ref)) $this->ref=trim($this->ref); if (isset($this->ref_customer)) $this->ref_customer=trim($this->ref_customer); if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); @@ -1249,14 +1249,11 @@ class Contrat extends CommonObject if (isset($this->import_key)) $this->import_key=trim($this->import_key); //if (isset($this->extraparams)) $this->extraparams=trim($this->extraparams); - - // Check parameters // Put here code to add a control on parameters values // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; - + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; $sql.= " ref_customer=".(isset($this->ref_customer)?"'".$this->db->escape($this->ref_customer)."'":"null").","; $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").","; @@ -1277,8 +1274,6 @@ class Contrat extends CommonObject $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").""; //$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").""; - - $sql.= " WHERE rowid=".$this->id; $this->db->begin(); @@ -1352,19 +1347,18 @@ class Contrat extends CommonObject $this->db->begin(); // Clean parameters - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - if (! $qty) $qty=1; - if (! $info_bits) $info_bits=0; - if (! $pu_ht) $pu_ht=0; - if (! $pu_ttc) $pu_ttc=0; - $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); $pa_ht=price2num($pa_ht); $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); + $remise_percent=price2num($remise_percent); + $qty=price2num($qty); + if (empty($qty)) $qty=1; + if (empty($info_bits)) $info_bits=0; + if (empty($pu_ht) || ! is_numeric($pu_ht)) $pu_ht=0; + if (empty($pu_ttc)) $pu_ttc=0; if ($price_base_type=='HT') { @@ -1432,15 +1426,17 @@ class Contrat extends CommonObject if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; } if ($date_end > 0) { $sql.= ",date_fin_validite"; } $sql.= ", fk_unit"; - $sql.= ") VALUES ($this->id, '', '" . $this->db->escape($desc) . "',"; + $sql.= ") VALUES ("; + $sql.= $this->id.", '', '" . $this->db->escape($desc) . "',"; $sql.= ($fk_product>0 ? $fk_product : "null").","; - $sql.= " '".$qty."',"; - $sql.= " '".$txtva."',"; - $sql.= " '".$txlocaltax1."',"; - $sql.= " '".$txlocaltax2."',"; + $sql.= " ".$qty.","; + $sql.= " ".$txtva.","; + $sql.= " ".$txlocaltax1.","; + $sql.= " ".$txlocaltax2.","; $sql.= " '".$localtax1_type."',"; $sql.= " '".$localtax2_type."',"; - $sql.= " ".price2num($remise_percent).",".price2num($pu_ht).","; + $sql.= " ".price2num($remise_percent).","; + $sql.= " ".price2num($pu_ht).","; $sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).","; $sql.= " '".$info_bits."',"; $sql.= " ".price2num($price).",".price2num($remise).","; @@ -2179,6 +2175,7 @@ class Contrat extends CommonObject $this->ref_supplier = 'SPECIMENSUPP'; $this->socid = 1; $this->statut= 0; + $this->date_creation = (dol_now() - 3600 * 24 * 7); $this->date_contrat = dol_now(); $this->commercial_signature_id = 1; $this->commercial_suivi_id = 1; @@ -2458,7 +2455,6 @@ class ContratLigne extends CommonObjectLine */ function fetch($id, $ref='') { - global $langs,$user; // Check parameters if (empty($id) && empty($ref)) return -1; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 86f7c00e566..2a2d2d35891 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -344,7 +344,7 @@ if ($result) $staticcompany->name=$obj->name; print $staticcompany->getNomUrl(1,'',20); print ''; - print ''; + print ''; //print ''; print ''; print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index cd0c934ead2..c003b638748 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -30,13 +31,26 @@ require ("../main.inc.php"); require_once (DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->load("contracts"); $langs->load("products"); $langs->load("companies"); $langs->load("compta"); +$action=GETPOST('action','alpha'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); + $search_name=GETPOST('search_name'); +$search_town=GETPOST('search_town','alpha'); +$search_zip=GETPOST('search_zip','alpha'); +$search_state=trim(GETPOST("search_state")); +$search_country=GETPOST("search_country",'int'); +$search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_contract=GETPOST('search_contract'); $search_ref_supplier=GETPOST('search_ref_supplier','alpha'); $sall=GETPOST('sall'); @@ -45,6 +59,9 @@ $socid=GETPOST('socid'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); $search_product_category=GETPOST('search_product_category','int'); +$day=GETPOST("day","int"); +$year=GETPOST("year","int"); +$month=GETPOST("month","int"); $optioncss = GETPOST('optioncss','alpha'); @@ -69,6 +86,7 @@ $staticcontratligne=new ContratLigne($db); if ($search_status == '') $search_status=1; +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $contextpage='contractlist'; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array @@ -76,9 +94,8 @@ $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('contract'); +$extralabels = $extrafields->fetch_name_optionals_label('contrat'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); - // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'c.ref'=>'Ref', @@ -90,25 +107,56 @@ $fieldstosearchall = array( ); if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; +$arrayfields=array( + 'c.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'c.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), + 'c.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), + 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0), + 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), + 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), + 'sale_representative'=>array('label'=>$langs->trans("SalesRepresentative"), 'checked'=>1), + 'c.date_contrat'=>array('label'=>$langs->trans("DateContract"), 'checked'=>1), + 'c.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'c.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} + /* * Action */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if (empty($reshook)) +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { - -} - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers -{ - $search_name=""; + $day=''; + $month=''; + $year=''; + $search_name=""; + $search_town=''; + $search_zip=""; + $search_state=""; + $search_type=''; + $search_country=''; $search_contract=""; $search_ref_supplier=""; $search_user=''; @@ -116,9 +164,20 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_product_category=''; $sall=""; $search_status=""; + $toselect=''; $search_array_options=array(); } +if (empty($reshook)) +{ + $objectclass='Contrat'; + $objectlabel='Contracts'; + $permtoread = $user->rights->contrat->lire; + $permtodelete = $user->rights->contrat->supprimer; + $uploaddir = $conf->contrat->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + /* * View @@ -132,16 +191,28 @@ $socstatic = new Societe($db); llxHeader(); $sql = 'SELECT'; -$sql.= " c.rowid as cid, c.ref, c.datec, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier,"; -$sql.= " s.nom as name, s.rowid as socid,"; +$sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier,"; +$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql.= " typent.code as typent_code,"; +$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= ' SUM('.$db->ifsql("cd.statut=0",1,0).') as nb_initial,'; $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')",1,0).') as nb_running,'; $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')",1,0).') as nb_expired,'; $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')",1,0).') as nb_late,'; $sql.= ' SUM('.$db->ifsql("cd.statut=5",1,0).') as nb_closed'; +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contrat_extrafields as ef on (c.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; if ($search_user > 0) @@ -154,32 +225,68 @@ $sql.= ' AND c.entity IN ('.getEntity('contract', 1).')'; if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; if ($socid) $sql.= " AND s.rowid = ".$db->escape($socid); if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - -if ($search_name) { - $sql .= natural_search('s.nom', $search_name); +if ($month > 0) +{ + if ($year > 0 && empty($day)) + $sql.= " AND c.date_contrat BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else if ($year > 0 && ! empty($day)) + $sql.= " AND c.date_contrat BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + else + $sql.= " AND date_format(c.date_contrat, '%m') = '".$month."'"; } -if ($search_contract) { - $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); -} -if (!empty($search_ref_supplier)) { - $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); +else if ($year > 0) +{ + $sql.= " AND c.date_contrat BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } +if ($search_name) $sql .= natural_search('s.nom', $search_name); +if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); +if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); if ($search_sale > 0) { $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; } -if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); -} +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; -$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier,"; +$sql.= ' s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql.= " typent.code,"; +$sql.= " state.code_departement, state.nom"; +// Add where from extra fields +foreach ($extrafields->attribute_label as $key => $val) +{ + $sql .= ', ef.'.$val; +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +$sql.= $db->order($sortfield,$sortorder); + $totalnboflines=0; $result=$db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); } -$sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -196,23 +303,44 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; + $arrayofselected=is_array($toselect)?$toselect:array(); + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - $param.='&search_contract='.$search_contract; - $param.='&search_name='.$search_name; - $param.='&search_ref_supplier='.$search_ref_supplier; - $param.='&search_sale=' .$search_sale; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($sall != '') $param.='&sall='.$sall; + if ($search_contract != '') $param.='&search_contract='.$search_contract; + if ($search_name != '') $param.='&search_name='.$search_name; + if ($search_ref_supplier != '') $param.='&search_ref_supplier='.$search_ref_supplier; + if ($search_sale != '') $param.='&search_sale=' .$search_sale; + if ($show_files) $param.='&show_files=' .$show_files; + if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Add $param from extra fields + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } + + // List of mass actions available + $arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + if ($user->rights->contrat->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); + if ($massaction == 'presend') $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); print '
'; if ($optioncss != '') print ''; print ''; + print ''; print ''; print ''; print ''; - print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num,$totalnboflines,'title_commercial.png', 0, '', '', $limit); + print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit); if ($sall) { @@ -220,8 +348,9 @@ if ($resql) print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - // If the user can view prospects other than his' $moreforfilter=''; + + // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); @@ -253,6 +382,7 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; + if (! empty($moreforfilter)) { print '
'; @@ -260,43 +390,164 @@ if ($resql) print '
'; } - print '
'.$langs->trans("Ref").''; + print '
'.$langs->trans("Ref").''; print $object->id; print ''; + print ''; print $form->showphoto('contact',$object)."\n"; if ($object->photo) print "
\n"; @@ -170,8 +170,8 @@ if ($action == 'edit') print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.'
'.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("ServiceNb",$cursorline).''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.dol_print_date($obj->tms,'dayhour').''.dol_print_date($db->jdate($obj->tms),'dayhour').''.$staticcontrat->LibStatut($obj->statut,2).''.($obj->nb_initial>0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0,3):'').''.($obj->nb_running>0 ? $obj->nb_running.$staticcontratligne->LibStatut(4,3,0):'').'
'; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'."\n"; print ''; - - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.ref","","$param",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RefCustomer"), $_SERVER["PHP_SELF"], "c.ref_customer","","$param",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RefSupplier"), $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"), $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("SalesRepresentative"), $_SERVER["PHP_SELF"], "","","$param",'',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("DateCreation"), $_SERVER["PHP_SELF"], "c.datec","","$param",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateContract"), $_SERVER["PHP_SELF"], "c.date_contrat","","$param",'align="center"',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "c.statut","","$param",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($staticcontratligne->LibStatut(0,3), '', '', '', '', 'width="16"'); - print_liste_field_titre($staticcontratligne->LibStatut(4,3,0), '', '', '', '', 'width="16"'); - print_liste_field_titre($staticcontratligne->LibStatut(4,3,1), '', '', '', '', 'width="16"'); - print_liste_field_titre($staticcontratligne->LibStatut(5,3), '', '', '', '', 'width="16"'); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref","","$param",'',$sortfield,$sortorder); + if (! empty($arrayfields['c.ref_customer']['checked'])) print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer","","$param",'',$sortfield,$sortorder); + if (! empty($arrayfields['c.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier","","$param",'',$sortfield,$sortorder); + if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom","","$param",'',$sortfield,$sortorder); + if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],'s.town','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],'s.zip','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "","","$param",'',$sortfield,$sortorder); + if (! empty($arrayfields['c.date_contrat']['checked'])) print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat","","$param",'align="center"',$sortfield,$sortorder); + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } + } + // Hook fields + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['status']['checked'])) + { + print_liste_field_titre($staticcontratligne->LibStatut(0,3), '', '', '', '', 'width="16"'); + print_liste_field_titre($staticcontratligne->LibStatut(4,3,0), '', '', '', '', 'width="16"'); + print_liste_field_titre($staticcontratligne->LibStatut(4,3,1), '', '', '', '', 'width="16"'); + print_liste_field_titre($staticcontratligne->LibStatut(5,3), '', '', '', '', 'width="16"'); + } + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + } + if (! empty($arrayfields['c.ref_customer']['checked'])) + { + print ''; + } + if (! empty($arrayfields['c.ref_supplier']['checked'])) + { + print ''; + } + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + // Town + if (! empty($arrayfields['s.town']['checked'])) print ''; + // Zip + if (! empty($arrayfields['s.zip']['checked'])) print ''; + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print ''; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + } + // Company type + if (! empty($arrayfields['typent.code']['checked'])) + { + print ''; + } + if (! empty($arrayfields['sale_representative']['checked'])) + { + print ''; + } + if (! empty($arrayfields['c.date_contrat']['checked'])) + { + // Date contract + print ''; + } + // 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'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['c.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['c.tms']['checked'])) + { + print ''; + } + // Status + if (! empty($arrayfields['status']['checked'])) + { + print ''; + } + print ''; print "\n"; @@ -306,65 +557,166 @@ if ($resql) $obj = $db->fetch_object($resql); $var=!$var; print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - - // Sales Rapresentatives - print ''; } - else + if (! empty($arrayfields['c.ref_customer']['checked'])) { - print ' '; + print ''; + } + if (! empty($arrayfields['c.ref_supplier']['checked'])) + { + print ''; + } + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + // Town + if (! empty($arrayfields['s.town']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Zip + if (! empty($arrayfields['s.zip']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Type ent + if (! empty($arrayfields['typent.code']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['sale_representative']['checked'])) + { + // Sales representatives + print ''; + } + // Date + if (! empty($arrayfields['c.date_contrat']['checked'])) + { + print ''; + } + // 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 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['c.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['c.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['status']['checked'])) + { + print ''; + print ''; + print ''; + print ''; + } + // Action column + print ''; - - - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if (! $i) $totalarray['nbfield']++; + print "\n"; $i++; } diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index d2de41391de..8e37e392603 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -361,7 +361,12 @@ if ($resql) if (($mode == "" || $mode == -1) || $mode < 5) { print ''; - $formconfirm.= ''; + $formconfirm.= ''; $formconfirm.= ''."\n"; $formconfirm.= '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ' '; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; + if (! empty($arrayfields['c.ref']['checked'])) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print ''; + //print $langs->trans('Month').': '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + //print ' '.$langs->trans('Year').': '; + $syear = $year; + $formother->select_year($syear,'year',1, 20, 5); + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + print $searchpitco; print '
'; - print img_object($langs->trans("ShowContract"),"contract").' '.(isset($obj->ref) ? $obj->ref : $obj->cid) .''; - if ($obj->nb_late) print img_warning($langs->trans("Late")); - print ''.$obj->ref_customer.''.$obj->ref_supplier.''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''.dol_print_date($obj->datec).''; - if($obj->socid) + if (! empty($arrayfields['c.ref']['checked'])) { - $result=$socstatic->fetch($obj->socid); - if ($result < 0) - { - dol_print_error($db); - exit; - } - $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) dol_print_error($db); - $nbofsalesrepresentative=count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 3) // We print only number - { - print ''; - print $nbofsalesrepresentative; - print ''; - } - else if ($nbofsalesrepresentative > 0) - { - $userstatic=new User($db); - $j=0; - foreach($listsalesrepresentatives as $val) - { - $userstatic->id=$val['id']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - print '
'.$userstatic->getNomUrl(1); - $j++; - if ($j < $nbofsalesrepresentative) print ', '; - print '
'; - } - } - //else print $langs->trans("NoSalesRepresentativeAffected"); + print '
'; + print img_object($langs->trans("ShowContract"),"contract").' '.(isset($obj->ref) ? $obj->ref : $obj->rowid) .''; + if ($obj->nb_late) print img_warning($langs->trans("Late")); + print ''.$obj->ref_customer.''.$obj->ref_supplier.''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; + if ($obj->socid > 0) + { + $result=$socstatic->fetch($obj->socid); + $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) dol_print_error($db); + $nbofsalesrepresentative=count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 3) // We print only number + { + print ''; + print $nbofsalesrepresentative; + print ''; + } + else if ($nbofsalesrepresentative > 0) + { + $userstatic=new User($db); + $j=0; + foreach($listsalesrepresentatives as $val) + { + $userstatic->id=$val['id']; + $userstatic->lastname=$val['lastname']; + $userstatic->firstname=$val['firstname']; + print '
'.$userstatic->getNomUrl(1); + $j++; + if ($j < $nbofsalesrepresentative) print ', '; + print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } + else + { + print ' '; + } + print '
'.dol_print_date($db->jdate($obj->date_contrat), 'day').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print ''.($obj->nb_initial>0?$obj->nb_initial:'').''.($obj->nb_running>0?$obj->nb_running:'').''.($obj->nb_expired>0?$obj->nb_expired:'').''.($obj->nb_closed>0 ?$obj->nb_closed:'').''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; } print ''.dol_print_date($db->jdate($obj->date_contrat)).''.$staticcontrat->LibStatut($obj->statut,3).''.($obj->nb_initial>0?$obj->nb_initial:'').''.($obj->nb_running>0?$obj->nb_running:'').''.($obj->nb_expired>0?$obj->nb_expired:'').''.($obj->nb_closed>0 ?$obj->nb_closed:'').'
'.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite)):' '); - if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) print img_warning($langs->trans("Late")); + if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) + { + $warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24; + $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); + print img_warning($textlate); + } else print '    '; } if (($mode == "" || $mode == -1) || $mode >= 5) print ''.dol_print_date($db->jdate($obj->date_cloture)); diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 8977938eb4a..6f2d4a2128f 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -140,4 +140,33 @@ elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'a //error fetching } } - +elseif ($action == 'renamefile' && GETPOST('renamefilesave')) +{ + if ($object->id) + { + // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. + //var_dump($upload_dir);exit; + if (! empty($upload_dir)) + { + $filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom')); + $filenameto=dol_sanitizeFileName(GETPOST('renamefileto')); + if ($filenamefrom && $filenameto) + { + $srcpath = $upload_dir.'/'.$filenamefrom; + $destpath = $upload_dir.'/'.$filenameto; + + $result = dol_move($srcpath, $destpath); + if ($result) + { + $object->addThumbs($destpath); + + // TODO Add revert function of addThumbs + //$object->delThumbs($srcpath); + + setEventMessages($langs->trans("FileRenamed"), null); + } + else setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); + } + } + } +} diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index a5e6a29b50a..dfc73105255 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -21,11 +21,13 @@ * \brief Code for actions on sending mails from object page */ - +// $mysoc must be defined // $id must be defined // $actiontypecode must be defined // $paramname must be defined // $mode must be defined +// $object and $uobject may be defined. + /* * Add file in email form @@ -86,11 +88,11 @@ if (GETPOST('removAll')) { $pathtodelete = $value; $filetodelete = $listofnames[$key]; - $result = dol_delete_file($pathtodelete,1); // Delete uploded Files - + $result = dol_delete_file($pathtodelete,1); // Delete uploded Files + $langs->load("other"); setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs'); - + $formmail->remove_attached_files($key); // Update Session } } @@ -107,51 +109,55 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $subject='';$actionmsg='';$actionmsg2=''; - $result=$object->fetch($id); - - $sendtosocid=0; - if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe') + if (is_object($object)) { - $result=$object->fetch_thirdparty(); - $thirdparty=$object->thirdparty; - $sendtosocid=$thirdparty->id; + $result=$object->fetch($id); + + $sendtosocid=0; + if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe') + { + $result=$object->fetch_thirdparty(); + $thirdparty=$object->thirdparty; + $sendtosocid=$thirdparty->id; + } + else if ($object->element == 'societe') + { + $thirdparty=$object; + if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; + elseif($conf->dolimail->enabled) + { + $dolimail = new Dolimail($db); + $possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1"); + $possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople + if (!$possibleaccounts && !$possibleuser) + { + setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors'); + } + elseif (count($possibleaccounts)>1) + { + $sendtosocid=$possibleaccounts[1]['id']; + $result=$object->fetch($sendtosocid); + + setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); + } + else + { + if($possibleaccounts){ + $sendtosocid=$possibleaccounts[1]['id']; + $result=$object->fetch($sendtosocid); + }elseif($possibleuser){ + $sendtosocid=$possibleuser[0]['id']; + + $result=$uobject->fetch($sendtosocid); + $object=$uobject; + } + + } + } + } + else dol_print_error('','Use actions_sendmails.in.php for a type that is not supported'); } - else if ($object->element == 'societe') - { - $thirdparty=$object; - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; - elseif($conf->dolimail->enabled) - { - $dolimail = new Dolimail($db); - $possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1"); - $possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople - if (!$possibleaccounts && !$possibleuser) - { - setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors'); - } - elseif (count($possibleaccounts)>1) - { - $sendtosocid=$possibleaccounts[1]['id']; - $result=$object->fetch($sendtosocid); - - setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); - } - else - { - if($possibleaccounts){ - $sendtosocid=$possibleaccounts[1]['id']; - $result=$object->fetch($sendtosocid); - }elseif($possibleuser){ - $sendtosocid=$possibleuser[0]['id']; - - $result=$uobject->fetch($sendtosocid); - $object=$uobject; - } - - } - } - } - else dol_print_error('','Use actions_sendmails.in.php for a type that is not supported'); + else $thirdparty = $mysoc; if ($result > 0) { @@ -247,35 +253,35 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $mailboxconfig = new IMAP($db); $mailboxconfig->fetch($mbid); if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref(); - + $mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox; $mailboxconfig->userfolder_fetch(); - + if ($mailboxconfig->mailbox_save_sent_mails == 1) { - + $folder=str_replace($ref, '', $mailboxconfig->folder_cache_key); if (!$folder) $folder = "Sent"; // Default Sent folder - + $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password); - if (FALSE === $mailboxconfig->mbox) + if (FALSE === $mailboxconfig->mbox) { $info = FALSE; $err = $langs->trans('Error3_Imap_Connection_Error'); setEventMessages($err,$mailboxconfig->element, null, 'errors'); - } - else + } + else { $mailboxconfig->mailboxid=$_POST['frommail']; $mailboxconfig->foldername=$folder; $from = $mailfromid[0] . $mailfromid[2]; $imap=1; } - - } + + } } } - + // 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,'','',$trackid); @@ -290,7 +296,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($result) { $error=0; - + // FIXME This must be moved into a trigger for action $trigger_name if (! empty($conf->dolimail->enabled)) { @@ -301,13 +307,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $dolimail=new DoliMail($db); $dolimail->id = $mid; $res=$dolimail->set_prop($user, 'answered',1); - } + } if ($imap==1) { // write mail to IMAP Server - $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); + $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs'); - else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); + else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); } } @@ -325,7 +331,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $interface=new Interfaces($db); $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); if ($result < 0) { - $error++; $this->errors=$interface->errors; + $error++; $errors=$interface->errors; } // End call of triggers @@ -339,8 +345,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val); - else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id); + if ($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val); + else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id); exit; } } diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index f9200810bdd..2e837fcbaae 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -22,16 +22,19 @@ */ -// This script is called with a POST method. -// Directory to scan (full path) is inside POST['dir']. +// This script is called with a POST method or as an include. -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! isset($usedbyinclude) || empty($usedbyinclude)) +{ + if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal + //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); + if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); + if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + + $res=@include '../../main.inc.php'; +} -$res=@include '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; //global $hookmanager; @@ -44,85 +47,85 @@ $arrayresult=array(); // Define $searchform if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) { - $arrayresult['searchintothirdparty']=array('text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintothirdparty']=array('img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) { - $arrayresult['searchintocontact']=array('text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintocontact']=array('img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php?sall='.urlencode($search_boxvalue)); } if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) { - $arrayresult['searchintoproduct']=array('text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoproduct']=array('img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue),'text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) { - $arrayresult['searchintoprojects']=array('text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php?search_all='.urlencode($search_boxvalue)); + $arrayresult['searchintoprojects']=array('img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php?search_all='.urlencode($search_boxvalue)); } if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) { - $arrayresult['searchintotasks']=array('text'=>img_picto('','object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php?search_all='.urlencode($search_boxvalue)); + $arrayresult['searchintotasks']=array('img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('','object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php?search_all='.urlencode($search_boxvalue)); } if (! empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) { - $arrayresult['searchintomember']=array('text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintomember']=array('img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { - $arrayresult['searchintouser']=array('text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/index.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintouser']=array('img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/index.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) { - $arrayresult['searchintopropal']=array('text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintopropal']=array('img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) { - $arrayresult['searchintoorder']=array('text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoorder']=array('img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) { - $arrayresult['searchintoinvoice']=array('text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoinvoice']=array('img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) { - $arrayresult['searchintoshipment']=array('text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoshipment']=array('img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) { - $arrayresult['searchintosupplierpropal']=array('text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintosupplierpropal']=array('img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire) { - $arrayresult['searchintosupplierorder']=array('text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue)); + $arrayresult['searchintosupplierorder']=array('img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue)); } if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire) { - $arrayresult['searchintosupplierinvoice']=array('text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintosupplierinvoice']=array('img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) { - $arrayresult['searchintocontract']=array('text'=>img_picto('','object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintocontract']=array('img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('','object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) { - $arrayresult['searchintointervention']=array('text'=>img_picto('','object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintointervention']=array('img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('','object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php?sall='.urlencode($search_boxvalue)); } // HR if (! empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) { - $arrayresult['searchintoexpensereport']=array('text'=>img_picto('','object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoexpensereport']=array('img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('','object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&sall='.urlencode($search_boxvalue)); } if (! empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) { - $arrayresult['searchintoleaves']=array('text'=>img_picto('','object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm&sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoleaves']=array('img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('','object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm&sall='.urlencode($search_boxvalue)); } @@ -144,6 +147,10 @@ if (empty($reshook)) else $arrayresult=$hookmanager->resArray; -print json_encode($arrayresult); +// Print output if called by ajax or do nothing (var $arrayresult will be used) if called by an include +if (! isset($usedbyinclude) || empty($usedbyinclude)) +{ + print json_encode($arrayresult); + if (is_object($db)) $db->close(); +} -if (is_object($db)) $db->close(); diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 40cc8885f90..fe864e1df16 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -1,6 +1,7 @@ - * Copyright (C) 2015 Frederic France +/* Copyright (C) 2010 Regis Houssin + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Laurent Destailleur * * 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 @@ -71,7 +72,8 @@ class box_contracts extends ModeleBoxes $sql.= " AND c.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; - $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY c.date_contrat DESC, c.ref DESC "; + else $sql.= " ORDER BY c.tms DESC, c.ref DESC "; $sql.= $db->plimit($max, 0); $resql = $db->query($sql); diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index d5d8f1243f5..afcbe8e68a6 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -84,7 +84,7 @@ class box_members extends ModeleBoxes { $sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; - $sql.= " t.cotisation"; + $sql.= " t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE a.entity = ".$conf->entity; $sql.= " AND a.fk_adherent_type = t.rowid"; @@ -135,7 +135,7 @@ class box_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', - 'text' => $memberstatic->LibStatut($objp->status,$objp->cotisation,$db->jdate($objp->date_end_subscription),3), + 'text' => $memberstatic->LibStatut($objp->status,$objp->subscription,$db->jdate($objp->date_end_subscription),3), ); $line++; diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 29db63054e5..f2bc86cdac5 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -68,6 +68,7 @@ class box_services_expired extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$db->idate($now)."'"; + $sql.= " AND c.entity = ".$conf->entity; $sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 877f40f6b79..0f754682925 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -251,6 +251,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" $out.= $s; } $out.= ' '; + $sublink=''; if (! empty($head['sublink'])) $sublink.= ''; if (! empty($head['subpicto'])) $sublink.= img_picto($head['subtext'], $head['subpicto'], 'class="'.(empty($head['subclass'])?'':$head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 563ec168d29..03f7e39bde8 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1105,12 +1105,12 @@ class CMailFile $_retVal = true; // Indicates if Object was created or not $server_response = ''; - while ( substr($server_response,3,1) != ' ' ) + while (substr($server_response,3,1) != ' ') { - if( !( $server_response = fgets($socket, 256) ) ) + if (! ($server_response = fgets($socket, 256)) ) { $this->error="Couldn't get mail server response codes"; - $_retVal = false; + return false; } } diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 59980cea7a9..d0e6dfe190a 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -143,7 +143,7 @@ class Ccountry // extends CommonObject * * @param int $id Id object * @param string $code Code - * @return int <0 if KO, >0 if OK + * @return int >0 if OK, 0 if not found, <0 if KO */ function fetch($id,$code='') { @@ -171,10 +171,13 @@ class Ccountry // extends CommonObject $this->code_iso = $obj->code_iso; $this->label = $obj->label; $this->active = $obj->active; - } - $this->db->free($resql); - return 1; + $this->db->free($resql); + return 1; + } + else { + return 0; + } } else { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 019c3102074..df65e73f679 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -35,8 +35,8 @@ abstract class CommonDocGenerator { var $error=''; protected $db; - - + + /** * Constructor * @@ -209,7 +209,7 @@ abstract class CommonDocGenerator { $object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); } - else if($extrafields->attribute_type[$key] == 'select') + else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') { $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; } @@ -280,7 +280,7 @@ abstract class CommonDocGenerator { $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); } - elseif($extrafields->attribute_type[$key] == 'select') + elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') { $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; } @@ -389,7 +389,7 @@ abstract class CommonDocGenerator // Add vat by rates foreach ($object->lines as $line) { - // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility + // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); @@ -576,12 +576,12 @@ abstract class CommonDocGenerator //Add value to store price with currency $array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } - else if($extrafields->attribute_type[$key] == 'select') + else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') { $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; } else if($extrafields->attribute_type[$key] == 'date') - { + { if (strlen($object->array_options['options_'.$key])>0) { $object->array_options['options_'.$key] = dol_print_date($object->array_options['options_'.$key],'day'); // using company output language diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 7c68a5ff978..c08d645cf53 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -198,9 +198,9 @@ abstract class CommonInvoice extends CommonObject } /** - * Retourne le libelle du type de facture + * Return label of type of invoice * - * @return string Libelle + * @return string Label of type of invoice */ function getLibType() { @@ -209,7 +209,7 @@ abstract class CommonInvoice extends CommonObject if ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); if ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); if ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); - if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); + if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. if ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); return $langs->trans("Unknown"); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 52f476e857e..1457d10726c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -433,7 +433,7 @@ abstract class CommonObject /** - * Return full address of contact + * Return full address for banner * * @param string $htmlkey HTML id to make banner content unique * @param Object $object Object (thirdparty, thirdparty of contact for contact, null for a member) @@ -476,7 +476,7 @@ abstract class CommonObject $out.=img_picto($langs->trans("Address"), 'object_address.png'); $out.=' '; } - $out.=dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1); $outdone++; + $out.=dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++; $outdone++; } @@ -601,13 +601,13 @@ abstract class CommonObject $datecreate = dol_now(); $this->db->begin(); - + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; $sql.= "'".$this->db->idate($datecreate)."'"; - $sql.= ", 4, '". $id_type_contact . "' "; + $sql.= ", 4, ". $id_type_contact; $sql.= ")"; $resql=$this->db->query($sql); @@ -1215,24 +1215,30 @@ abstract class CommonObject } /** - * Setter generic. Update a specific field into database + * Setter generic. Update a specific field into database. + * Warning: Trigger is run only if param trigkey is provided. * * @param string $field Field to update * @param mixed $value New value * @param string $table To force other table element or element line (should not be used) * @param int $id To force other object id (should not be used) * @param string $format Data format ('text', 'date'). 'text' is used if not defined - * @param string $id_field To force rowid field name. 'rowid' is used it not defined + * @param string $id_field To force rowid field name. 'rowid' is used if not defined * @param User|string $user Update last update fields also if user object provided + * @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY') * @return int <0 if KO, >0 if OK */ - function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $user='') + function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $user='', $trigkey='') { - if (empty($table)) $table=$this->table_element; - if (empty($id)) $id=$this->id; - if (empty($format)) $format='text'; - if (empty($id_field)) $id_field='rowid'; + global $user,$langs,$conf; + + if (empty($table)) $table=$this->table_element; + if (empty($id)) $id=$this->id; + if (empty($format)) $format='text'; + if (empty($id_field)) $id_field='rowid'; + $error=0; + $this->db->begin(); // Special case @@ -1240,7 +1246,8 @@ abstract class CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; - else if ($format == 'date') $sql.= $field." = '".$this->db->idate($value)."'"; + else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value); + else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); if (is_object($user)) $sql.=", fk_user_modif = ".$user->id; $sql.= " WHERE ".$id_field." = ".$id; @@ -1248,8 +1255,23 @@ abstract class CommonObject $resql = $this->db->query($sql); if ($resql) { - $this->db->commit(); - return 1; + if ($trigkey) + { + $result=$this->call_trigger($trigkey, $user); // This may set this->errors + if ($result < 0) $error++; + } + + if (! $error) + { + if (property_exists($this, $field)) $this->$field = $value; + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -2; + } } else { @@ -1267,7 +1289,7 @@ abstract class CommonObject * @param int $nodbprefix Do not include DB prefix to forge table name * @return int <0 if KO, >0 if OK */ - function load_previous_next_ref($filter,$fieldid,$nodbprefix=0) + function load_previous_next_ref($filter, $fieldid, $nodbprefix=0) { global $user; @@ -2584,7 +2606,7 @@ abstract class CommonObject $classfile = 'facture-rec'; $classname = 'FactureRec'; } else if ($objecttype == 'subscription') { - $classfile = 'cotisation'; $classname = 'Cotisation'; + $classfile = 'subscription'; $classname = 'Subscription'; } // Here $module, $classfile and $classname are set @@ -2758,6 +2780,7 @@ abstract class CommonObject $trigkey=''; if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; + if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE'; if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED'; if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED'; @@ -3057,6 +3080,7 @@ abstract class CommonObject /** * Return incoterms informations + * TODO Use a cache for label get * * @return string incoterms info */ @@ -3075,7 +3099,7 @@ abstract class CommonObject } } - $out .= ' - '.$this->location_incoterms; + $out .= (($res->code && $this->location_incoterms)?' - ':'').$this->location_incoterms; return $out; } @@ -4188,7 +4212,9 @@ abstract class CommonObject $object = new $InfoFieldList[0]($this->db); if ($value) { - $res=$object->fetch(0,$value); + if (is_numeric($value)) $res=$object->fetch($value); + else $res=$object->fetch('',$value); + if ($res > 0) $this->array_options[$key]=$object->id; else { @@ -4508,7 +4534,7 @@ abstract class CommonObject if (! $db->query($sql)) { - if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. + if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. //$this->errors = $db->lasterror(); return false; } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 3ac15c7a8c8..b388298cf08 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -51,7 +51,7 @@ class Conf public $standard_menu; public $modules = array(); // List of activated modules - public $modules_parts = array('css'=>array(),'js'=>array(),'tabs'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'sms'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'societe'=>array(),'hooks'=>array(),'dir'=>array()); + public $modules_parts = array('css'=>array(),'js'=>array(),'tabs'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'sms'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'societe'=>array(),'hooks'=>array(),'dir'=>array(), 'syslog' =>array()); var $logbuffer = array(); @@ -123,6 +123,8 @@ class Conf */ function setValues($db) { + global $conf; + dol_syslog(get_class($this)."::setValues"); /* @@ -203,7 +205,7 @@ class Conf $db->free($resql); } - + // Include other local consts.php files and fetch their values to the corresponding database constants if (! empty($this->global->LOCAL_CONSTS_FILES)) { $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); @@ -342,7 +344,7 @@ class Conf $this->fournisseur->facture=new stdClass(); $this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture"; $this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp"; - + // To prepare split of module fournisseur into fournisseur + supplier_order + supplier_invoice if (! empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, if module supplier is on, we set new properties { @@ -379,11 +381,13 @@ class Conf // Set some default values $this->global->MAIN_ACTIVATE_HTML5=1; - + // societe if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard"; if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum"; + if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint'; + // Security if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664'; // Default mask @@ -483,12 +487,12 @@ class Conf // By default, we propagate contacts if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) - + // By default, we use the zip town autofill if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=1; - + // Define list of limited modules - if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,supplier_proposal,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. + if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplier_proposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. // Enable select2 if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT='select2'; @@ -506,17 +510,17 @@ class Conf // Delay before warnings // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx if (isset($this->agenda)) { - $this->adherent->cotisation = new stdClass(); - $this->adherent->cotisation->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60; + $this->adherent->subscription = new stdClass(); + $this->adherent->subscription->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60; } if (isset($this->agenda)) $this->agenda->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60; - if (isset($this->projet)) + if (isset($this->projet)) { $this->projet->warning_delay=(isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE)?$this->global->MAIN_DELAY_PROJECT_TO_CLOSE:7)*24*60*60; $this->projet->task = new StdClass(); $this->projet->task->warning_delay=(isset($this->global->MAIN_DELAY_TASKS_TODO)?$this->global->MAIN_DELAY_TASKS_TODO:7)*24*60*60; } - + if (isset($this->commande)) { $this->commande->client = new stdClass(); $this->commande->fournisseur = new stdClass(); @@ -570,26 +574,40 @@ class Conf if (is_object($mc)) $mc->setValues($this); } - // We init log handlers - if (defined('SYSLOG_HANDLERS')) $handlers = json_decode(constant('SYSLOG_HANDLERS')); - else $handlers = array(); - foreach ($handlers as $handler) - { - $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; - if (!file_exists($file)) - { - throw new Exception('Missing log handler file '.$handler.'.php'); - } + // We init log handlers + if (defined('SYSLOG_HANDLERS')) { + $handlers = json_decode(constant('SYSLOG_HANDLERS')); + } else { + $handlers = array(); + } + foreach ($handlers as $handler) { + $handler_files = array(); + $dirsyslogs = array_merge(array('/core/modules/syslog/'), $conf->modules_parts['syslog']); + foreach ($dirsyslogs as $reldir) { + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); + if (is_dir($newdir)) { + $file = $newdir . $handler . '.php'; + if (file_exists($file)) { + $handler_files[] = $file; + } + } + } - require_once $file; - $loghandlerinstance = new $handler(); - if (!$loghandlerinstance instanceof LogHandlerInterface) - { - throw new Exception('Log handler does not extend LogHandlerInterface'); - } + if (empty($handler_files)) { + throw new Exception('Missing log handler file ' . $handler . '.php'); + } - if (empty($this->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance; - } + require_once $handler_files[0]; + $loghandlerinstance = new $handler(); + if (!$loghandlerinstance instanceof LogHandlerInterface) { + throw new Exception('Log handler does not extend LogHandlerInterface'); + } + + if (empty($this->loghandlers[$handler])) { + $this->loghandlers[$handler] = $loghandlerinstance; + } + } } } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index e256dbfb649..9a59801f720 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -66,6 +66,8 @@ class DiscountAbsolute */ function fetch($rowid,$fk_facture_source=0) { + global $conf; + // Check parameters if (! $rowid && ! $fk_facture_source) { @@ -81,9 +83,9 @@ class DiscountAbsolute $sql.= " f.facnumber as ref_facture_source"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; - $sql.= " WHERE"; - if ($rowid) $sql.= " sr.rowid=".$rowid; - if ($fk_facture_source) $sql.= " sr.fk_facture_source=".$fk_facture_source; + $sql.= " WHERE sr.entity = " . $conf->entity; + if ($rowid) $sql.= " AND sr.rowid=".$rowid; + if ($fk_facture_source) $sql.= " AND sr.fk_facture_source=".$fk_facture_source; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); @@ -150,11 +152,11 @@ class DiscountAbsolute // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; - $sql.= " (datec, fk_soc, fk_user, description,"; + $sql.= " (entity, datec, fk_soc, fk_user, description,"; $sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,"; $sql.= " fk_facture_source"; $sql.= ")"; - $sql.= " VALUES ('".$this->db->idate($this->datec!=''?$this->datec:dol_now())."', ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($this->description)."',"; + $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec!=''?$this->datec:dol_now())."', ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($this->description)."',"; $sql.= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.","; $sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null"); $sql.= ")"; @@ -343,10 +345,13 @@ class DiscountAbsolute */ function getAvailableDiscounts($company='', $user='',$filter='', $maxvalue=0) { + global $conf; + $sql = "SELECT SUM(rc.amount_ttc) as amount"; // $sql = "SELECT rc.amount_ttc as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql.= " WHERE (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available + $sql.= " WHERE rc.entity = " . $conf->entity; + $sql.= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id; if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id; if ($filter) $sql.=' AND ('.$filter.')'; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 3bfcf9b781e..5ad8b3aa646 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -140,21 +140,25 @@ class DolEditor * Output edit area inside the HTML stream. * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) * - * @param int $noprint 1=Return HTML string instead of printing it to output - * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });" + * @param int $noprint 1=Return HTML string instead of printing it to output + * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });" + * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. * @return void|string */ - function Create($noprint=0,$morejs='') + function Create($noprint=0,$morejs='',$disallowAnyContent=true) { global $conf,$langs; $fullpage=False; - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed - + if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) + { + $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed + } + $found=0; $out=''; - if ($this->tool == 'fckeditor') + if ($this->tool == 'fckeditor') // not used anymore { $found=1; $this->editor->Create(); @@ -179,6 +183,7 @@ class DolEditor $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; + $out.= ''."\n"; $out.= ''; $out.=$this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); - $out.=' '; + $out.=' '; } $assignedtouser=array(); if (!empty($_SESSION['assignedtouser'])) @@ -1572,6 +1580,7 @@ class Form $nbassignetouser=count($assignedtouser); if ($nbassignetouser && $action != 'view') $out.='
'; + if ($nbassignetouser) $out.='
'; $i=0; $ownerid=0; foreach($assignedtouser as $key => $value) { @@ -1585,7 +1594,8 @@ class Form $out.='
'; $i++; } - + if ($nbassignetouser) $out.='
'; + //$out.=''; return $out; } @@ -2065,9 +2075,10 @@ class Form * @param string $filtre For a SQL filter * @param array $ajaxoptions Options for ajax_autocompleter * @param int $hidelabel Hide label (0=no, 1=yes) + * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices * @return void */ - function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0) + function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0, $alsoproductwithnosupplierprice=0) { global $langs,$conf; global $price_level, $status, $finished; @@ -2089,7 +2100,7 @@ class Form print ''; } // mode=2 means suppliers products - $urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished; + $urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice; print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').''; } @@ -2100,7 +2111,7 @@ class Form print ''; print ''; } - print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0); + print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0,0,$alsoproductwithnosupplierprice); } } @@ -2116,9 +2127,10 @@ class Form * @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell (not used here, a filter on tobuy is already hard coded in request) * @param int $outputmode 0=HTML select string, 1=Array * @param int $limit Limit of line number + * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices * @return array Array of keys for json */ - function select_produits_fournisseurs_list($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$outputmode=0,$limit=100) + function select_produits_fournisseurs_list($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$outputmode=0,$limit=100,$alsoproductwithnosupplierprice=0) { global $langs,$conf,$db; @@ -2172,7 +2184,7 @@ class Form $num = $this->db->num_rows($result); //$out.=''; + $out.=''; if ($addempty) print ''; foreach($this->cache_conditions_paiements as $id => $arrayconditions) @@ -2945,12 +2969,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; $this->selectShippingMethod($selected, $htmlname, '', $addempty); - print '
'; + print ''; + print ''; } else { if ($selected) { $code=$langs->getLabelFromKey($db, $selected, 'c_shipment_mode', 'rowid', 'code'); @@ -3137,12 +3158,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; $this->select_comptes($selected, $htmlname, 0, '', $addempty); - print '
'; + print ''; + print ''; } else { if ($selected) { require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; @@ -3257,7 +3275,7 @@ class Form * @param int $width Force width of bow * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ - function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500) + function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=200, $width=500) { global $langs,$conf; global $useglobalvars; @@ -3499,7 +3517,7 @@ class Form $formconfirm.= '
'; $formconfirm.= $this->selectyesno("confirm",$newselectedchoice); $formconfirm.= '
'."\n"; @@ -3524,30 +3542,30 @@ class Form * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely except $selected,2=Disable) * @param int $maxlength Max length * @param int $forcefocus Force focus on field (works with javascript only) - * @return void + * @param int $nooutput No print is done. String is returned. + * @return string Return html content */ - function form_project($page, $socid, $selected='', $htmlname='projectid', $discard_closed=0, $maxlength=20, $forcefocus=0) + function form_project($page, $socid, $selected='', $htmlname='projectid', $discard_closed=0, $maxlength=20, $forcefocus=0, $nooutput=0) { global $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + $out=''; + $formproject=new FormProjets($this->db); $langs->load("project"); if ($htmlname != "none") { - print "\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus); - print '
'; + $out.="\n"; + $out.='
'; + $out.=''; + $out.=''; + $out.=$formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0, '', 1); + $out.=''; + $out.='
'; } else { @@ -3556,13 +3574,20 @@ class Form $projet = new Project($this->db); $projet->fetch($selected); //print ''.$projet->title.''; - print $projet->getNomUrl(0,'',1); + $out.=$projet->getNomUrl(0,'',1); } else { - print " "; + $out.=" "; } } + + if (empty($nooutput)) + { + print $out; + return ''; + } + return $out; } /** @@ -3582,12 +3607,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; $this->select_conditions_paiements($selected,$htmlname,-1,$addempty); - print '
'; + print ''; + print ''; } else { @@ -3618,12 +3640,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; $this->selectAvailabilityDelay($selected,$htmlname,-1,$addempty); - print '
'; + print ''; + print ''; } else { @@ -3655,12 +3674,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; $this->selectInputReason($selected,$htmlname,-1,$addempty); - print '
'; + print ''; + print ''; } else { @@ -3741,12 +3757,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; print $this->select_dolusers($selected,$htmlname,1,$exclude,0,$include); - print '
'; + print ''; + print ''; } else { @@ -3781,12 +3794,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; $this->select_types_paiements($selected,$htmlname,$filtertype,0,0,0,0,$active); - print '
'; + print ''; + print ''; } else { @@ -3816,12 +3826,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; print $this->selectMultiCurrency($selected, $htmlname, 0); - print '
'; + print ''; + print ''; } else { @@ -3848,12 +3855,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; print ''; - print '
'; + print ''; + print ''; } else { @@ -3956,7 +3960,6 @@ class Form if ($num==0) { $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); - print 'Cette societe n\'a pas de contact, veuillez en cr�er un avant de faire votre proposition commerciale
'; print ''.$addcontact.''; } print ''; @@ -3999,12 +4002,9 @@ class Form print '
'; print ''; print ''; - print ''; - print ''; - print ''; - print '
'; print $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); - print '
'; + print ''; + print ''; } else { @@ -5061,8 +5061,8 @@ class Form
'.img_picto('','list').' - +
@@ -5165,9 +5165,9 @@ class Form print '
'; print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, ''); - + print ''; - + print ''; print ''; print ''; @@ -5177,9 +5177,9 @@ class Form print ''; print ''; print ''; - + $numoutput=0; - + foreach($object->linkedObjects as $objecttype => $objects) { $tplpath = $element = $subelement = $objecttype; @@ -5239,7 +5239,7 @@ class Form foreach($dirtpls as $reldir) { $res=@include dol_buildpath($reldir.'/'.$tplname.'.tpl.php'); - if ($res) + if ($res) { $numoutput++; break; @@ -5251,7 +5251,7 @@ class Form { print ''; } - + print '
'.$langs->trans("Type").''.$langs->trans("Ref").''.$langs->trans("Status").'
'.$langs->trans("None").'
'; return $num; @@ -5260,7 +5260,7 @@ class Form /** * Show block with links to link to other objects. - * + * * @param CommonObject $object Object we want to show links to * @param array $restrictlinksto Restrict links to some elements, for exemple array('order') or array('supplier_order'). null or array() if no restriction. * @param array $excludelinksto Do not show links of this type, for exemple array('order') or array('supplier_order'). null or array() if no exclusion. @@ -5285,12 +5285,12 @@ class Form 'order_supplier'=>array('enabled'=>$conf->fournisseur->commande->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc = ".$object->thirdparty->id), 'invoice_supplier'=>array('enabled'=>$conf->fournisseur->facture->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc = ".$object->thirdparty->id) ); - + foreach($possiblelinks as $key => $possiblelink) { $num = 0; - + if (! empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || ! in_array($key, $excludelinksto))) { print '
global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>'; @@ -5300,7 +5300,7 @@ class Form { $num = $this->db->num_rows($resqllist); $i = 0; - + print '
'; print ''; print ''; @@ -5316,7 +5316,7 @@ class Form while ($i < $num) { $objp = $this->db->fetch_object($resqlorderlist); - + $var = ! $var; print ''; print ''; @@ -5330,8 +5330,8 @@ class Form $i++; } print ''; - print '
     
'; - + print '
     
'; + print '
'; $this->db->free($resqllist); } else { @@ -5340,8 +5340,8 @@ class Form print '
'; if ($num > 0) { - } - + } + //$linktoelem.=($linktoelem?'   ':''); if ($num > 0) $linktoelem.='
  • ' . $langs->trans($possiblelink['label']) .' ('.$num.')
  • '; //else $linktoelem.=$langs->trans($possiblelink['label']); @@ -5359,7 +5359,7 @@ class Form
    '; - + print ' '; - + return $linktoelem; } @@ -5474,15 +5474,15 @@ class Form * @param string $paramid Name of parameter to use to name the id into the URL next/previous link * @param string $morehtml More html content to output just before the nav bar * @param int $shownav Show Condition (navigation is shown if value is 1) - * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field) - * @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous + * @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field) + * @param string $fieldref Name of field ref of object (object->ref) to show or 'none' to not show ref. * @param string $morehtmlref More html to show after ref * @param string $moreparam More param to add in nav link url. * @param int $nodbprefix Do not include DB prefix to forge table name * @param string $morehtmlleft More html code to show before ref * @param string $morehtmlstatus More html code to show under navigation arrows (status place) * @param string $morehtmlright More html code to show after ref - * @return string Portion HTML avec ref + boutons nav + * @return string Portion HTML with ref + navigation buttons */ function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') { @@ -5507,7 +5507,7 @@ class Form $ret.='
    '; - // For thirdparty and contact, the ref is the id, so we show something else + // For thirdparty, contact, user, member, the ref is the id, so we show something else if ($object->element == 'societe') { $ret.=dol_htmlentities($object->name); @@ -5516,7 +5516,7 @@ class Form { $ret.=dol_htmlentities($object->getFullName($langs)); } - else $ret.=dol_htmlentities($object->$fieldref); + else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref); if ($morehtmlref) { $ret.=' '.$morehtmlref; @@ -5666,7 +5666,7 @@ class Form { if ($file && file_exists($dir."/".$file)) { - if ($addlinktofullsize) + if ($addlinktofullsize) { $urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile); if ($urladvanced) $ret.=''; @@ -5677,7 +5677,7 @@ class Form } else if ($altfile && file_exists($dir."/".$altfile)) { - if ($addlinktofullsize) + if ($addlinktofullsize) { $urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile); if ($urladvanced) $ret.=''; @@ -5722,7 +5722,7 @@ class Form } } - else dol_print_error('','Call of showphoto with wrong parameters'); + else dol_print_error('','Call of showphoto with wrong parameters modulepart='.$modulepart); return $ret; } diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 33393f1ef46..16a16719366 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -51,14 +51,14 @@ class FormAdmin * @param string $htmlname Name of HTML select * @param int $showauto Show 'auto' choice * @param array $filter Array of keys to exclude in list - * @param int $showempty Add empty value + * @param string $showempty 1=Add empty value or string to show * @param int $showwarning Show a warning if language is not complete * @param int $disabled Disable edit of select * @param string $morecss Add more css styles * @param int $showcode Add language code into label * @return string Return HTML select string with list of languages */ - function select_language($selected='',$htmlname='lang_id',$showauto=0,$filter=null,$showempty=0,$showwarning=0,$disabled=0,$morecss='',$showcode=0) + function select_language($selected='', $htmlname='lang_id', $showauto=0, $filter=null, $showempty='', $showwarning=0, $disabled=0, $morecss='', $showcode=0) { global $langs; @@ -71,7 +71,10 @@ class FormAdmin { $out.= ''; $num = $this->db->num_rows($result); $i = 0; @@ -743,7 +740,7 @@ class FormCompany $out.= ajax_multiautocompleter($htmlname,$fields,DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; $moreattrib.=' autocomplete="off"'; } - $out.= ''."\n"; + $out.= ''."\n"; return $out; } @@ -792,9 +789,8 @@ class FormCompany $maxlength=$formlength; if (empty($formlength)) { $formlength=24; $maxlength=128; } - $formlength=0; - $out = ''; + $out = ''; return $out; } diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 80b618b8804..ace00b77caa 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -157,12 +157,9 @@ class FormContract print '
    '; print ''; print ''; - print ''; - print ''; - print ''; - print '
    '; $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty); - print '
    '; + print ''; + print ''; } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 06eb8c0c5d2..b8fab63f906 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -268,9 +268,10 @@ class FormFile * @param string $buttonlabel Label on submit button * @param string $codelang Default language code to use on lang combo box if multilang is enabled * @param string $morepicto Add more HTML content into cell with picto + * @param Object $object Object when method is called from an object card. * @return string Output string with HTML array of documents (might be empty string) */ - function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='') + function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='',$object=null) { // Deprecation warning if (0 !== $iconPDF) { @@ -581,15 +582,25 @@ class FormFile } } + // Get list of files if (! empty($filedir)) { $file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview\.png)$','date',SORT_DESC); + $link_list = array(); + if (is_object($object)) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + $link = new Link($this->db); + $sortfield = $sortorder = null; + $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); + } + $out.= ''."\n"; // Show title of array if not already shown - if ((! empty($file_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) + if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) { $headershown=1; $out.= '
    '.$titletoshow.'
    '."\n"; @@ -621,7 +632,6 @@ class FormFile $out.= ' target="_blank">'; $out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]).' '.dol_trunc($file["name"],$maxfilenamelength); $out.= '
    '."\n"; - $out.= $this->showPreview($file,$modulepart,$relativepath); $out.= ''; @@ -673,13 +683,37 @@ class FormFile } } - if (count($file_list) == 0 && $headershown) - { - $out.=''.$langs->trans("None").''; - } - $this->numoffiles++; } + // Loop on each file found + if (is_array($link_list)) + { + $colspan=2; + + foreach($link_list as $file) + { + $var=!$var; + + $out.= ""; + $out.=''; + $out.=''; + $out.=$file->label; + $out.=''; + $out.=''; + $out.=''; + $out.=dol_print_date($file->datea,'dayhour'); + $out.=''; + if ($delallowed || $printer || $morepicto) $out.=''; + $out.=''; + } + $this->numoffiles++; + } + + if (count($file_list) == 0 && count($link_list) == 0 && $headershown) + { + $out.=''.$langs->trans("None").''; + } + } if ($headershown) @@ -697,7 +731,7 @@ class FormFile } /** - * Show only Document icon with link + * Show a Document icon with link(s) * * @param string $modulepart propal, facture, facture_fourn, ... * @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module. @@ -714,6 +748,8 @@ class FormFile $out=''; $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); + if (! empty($conf->dol_use_jmobile)) return ''; + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) // For ajax treatment @@ -721,7 +757,7 @@ class FormFile if (! empty($file_list)) { $out='
    '; + + print '
    '; + /* * Lines of products @@ -1719,11 +1797,12 @@ else if ($id || $ref) $var=!$var; } + + print "\n"; } - print "\n"; - print "\n
    \n"; + dol_fiche_end(); $object->fetchObjectLinked($object->id,$object->element); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index bb8cb9bcdda..34b6a6e20b9 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -37,7 +37,7 @@ if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propa if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; - + /** * Class to manage shipments */ @@ -48,7 +48,8 @@ class Expedition extends CommonObject public $table_element="expedition"; public $table_element_line="expeditiondet"; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - + public $picto = 'sending'; + var $socid; var $ref_customer; var $ref_int; @@ -93,13 +94,13 @@ class Expedition extends CommonObject var $meths; var $listmeths; // List of carriers - + const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; const STATUS_CLOSED = 2; - - - + + + /** * Constructor * @@ -179,7 +180,7 @@ class Expedition extends CommonObject * Create expedition en base * * @param User $user Objet du user qui cree - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si erreur, id expedition creee si ok */ function create($user, $notrigger=0) @@ -290,7 +291,7 @@ class Expedition extends CommonObject $error++; } } - + // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('expeditiondao')); @@ -364,13 +365,14 @@ class Expedition extends CommonObject * @param int $entrepot_id Id of warehouse * @param int $origin_line_id Id of source line * @param int $qty Quantity - * @param array $array_options extrafields array - * @return int <0 if KO, >0 if OK + * @param array $array_options extrafields array + * @return int <0 if KO, line_id if OK */ function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0) { global $conf; $error = 0; + $line_id = 0; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet ("; $sql.= "fk_expedition"; @@ -385,12 +387,17 @@ class Expedition extends CommonObject $sql.= ")"; dol_syslog(get_class($this)."::create_line", LOG_DEBUG); - if (! $this->db->query($sql)) + $resql = $this->db->query($sql); + if ($resql) + { + $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); + } + else { $error++; } - if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $expeditionline = new ExpeditionLigne($this->db); $expeditionline->array_options=$array_options; @@ -403,7 +410,7 @@ class Expedition extends CommonObject } } - if (! $error) return 1; + if (! $error) return $line_id; else return -1; } @@ -419,7 +426,7 @@ class Expedition extends CommonObject { $error = 0; $stockLocationQty = array(); // associated array with batch qty in stock location - + $tab=$line_ext->detail_batch; // create stockLocation Qty array foreach ($tab as $detbatch) @@ -432,14 +439,13 @@ class Expedition extends CommonObject // create shipment lines foreach ($stockLocationQty as $stockLocation => $qty) { - if ($this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options) < 0) + if (($line_id = $this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options)) < 0) { $error++; } else { // create shipment batch lines for stockLocation - $line_id= $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); foreach ($tab as $detbatch) { if ($detbatch->entrepot_id == $stockLocation){ @@ -447,7 +453,7 @@ class Expedition extends CommonObject { $error++; } - } + } } } } @@ -554,7 +560,7 @@ class Expedition extends CommonObject * Thirparty */ $result=$this->fetch_thirdparty(); - + // Retrieve all extrafields for expedition // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -591,7 +597,7 @@ class Expedition extends CommonObject * Validate object and update stock if option enabled * * @param User $user Object user that validate - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if OK, >0 if KO */ function valid($user, $notrigger=0) @@ -697,29 +703,29 @@ class Expedition extends CommonObject //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; - + if (empty($obj->edbrowid)) { // line without batch detail - + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref)); if ($result < 0) { - $error++; - $this->errors[]=$mouvS->error; + $error++; + $this->errors[]=$mouvS->error; break; } } else { // line with batch detail - + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch, $obj->fk_origin_stock); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { - $error++; - $this->errors[]=$mouvS->error; + $error++; + $this->errors[]=$mouvS->error; break; } } @@ -731,9 +737,7 @@ class Expedition extends CommonObject $this->error=$this->db->error(); return -2; } - - // FIXME Set status of order to "delivered" if check box "set order as delivered if remain to ship is 0" is on and if sum of all validated shipment = products or order to ship (because we are in case of stock movement on shipment validation) - + } // Change status of order to "shipment in process" @@ -742,7 +746,7 @@ class Expedition extends CommonObject { $error++; } - + if (! $error && ! $notrigger) { // Call trigger @@ -903,11 +907,11 @@ class Expedition extends CommonObject } } } - + // extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used $line->array_options = $array_options; - + $this->lines[$num] = $line; } @@ -960,7 +964,7 @@ class Expedition extends CommonObject return -1; } } - + //var_dump($linebatch); } } @@ -972,7 +976,7 @@ class Expedition extends CommonObject // extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used $line->array_options = $array_options; - + //var_dump($line); $this->lines[$num] = $line; return 1; @@ -1132,13 +1136,13 @@ class Expedition extends CommonObject { dol_syslog(get_class($this)."::delete movement index ".$i); $obj = $this->db->fetch_object($resql); - + $mouvS = new MouvementStock($this->db); // we do not log origin because it will be deleted $mouvS->origin = null; // get lot/serial $lotArray = null; - if ($conf->productbatch->enabled) + if ($conf->productbatch->enabled) { $lotArray = ExpeditionLineBatch::fetchAll($this->db,$obj->expeditiondet_id); if (! is_array($lotArray)) @@ -1157,7 +1161,7 @@ class Expedition extends CommonObject break; } } - else + else { // We increment stock of batches // We use warehouse selected for each line @@ -1171,7 +1175,7 @@ class Expedition extends CommonObject } } if ($error) break; // break for loop incase of error - } + } } } else @@ -1179,7 +1183,7 @@ class Expedition extends CommonObject $error++;$this->errors[]="Error ".$this->db->lasterror(); } } - + // delete batch expedition line if (! $error && $conf->productbatch->enabled) { @@ -1188,7 +1192,7 @@ class Expedition extends CommonObject $error++;$this->errors[]="Error ".$this->db->lasterror(); } } - + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; @@ -1227,7 +1231,7 @@ class Expedition extends CommonObject } } } - + if (! $error) { $this->db->commit(); @@ -1376,7 +1380,7 @@ class Expedition extends CommonObject $line->volume_units = $obj->volume_units; $line->pa_ht = $obj->pa_ht; - + // For invoicing $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc); // We force type to 0 $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) @@ -1398,8 +1402,8 @@ class Expedition extends CommonObject $this->total_ttc+= $tabprice[2]; $this->total_localtax1+= $tabprice[9]; $this->total_localtax2+= $tabprice[10]; - - if ($originline != $obj->fk_origin_line) + + if ($originline != $obj->fk_origin_line) { $line->detail_batch = array(); } @@ -1770,7 +1774,7 @@ class Expedition extends CommonObject } - + /** * Forge an set tracking url * @@ -1816,9 +1820,9 @@ class Expedition extends CommonObject global $conf,$langs,$user; $error=0; - + $this->db->begin(); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut='.self::STATUS_CLOSED; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -1830,9 +1834,9 @@ class Expedition extends CommonObject { $order = new Commande($this->db); $order->fetch($this->origin_id); - + $order->loadExpeditions(self::STATUS_CLOSED); // Fill $order->expeditions = array(orderlineid => qty) - + $shipments_match_order = 1; foreach($order->lines as $line) { @@ -1848,21 +1852,21 @@ class Expedition extends CommonObject } if ($shipments_match_order) { - dol_syslog("Qty for the ".count($order->lines)." lines of order have same value for shipments with status Expedition::STATUS_CLOSED=".self::STATUS_CLOSED.', so we close order'); + dol_syslog("Qty for the ".count($order->lines)." lines of order have same value for shipments with status Expedition::STATUS_CLOSED=".self::STATUS_CLOSED.', so we close order'); $order->cloture($user); } } - + $this->statut=self::STATUS_CLOSED; - + // If stock increment is done on closing if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; - + $langs->load("agenda"); - + // Loop on each product line to add a stock movement // TODO possibilite d'expedier a partir d'une propale ou autre origine ? $sql = "SELECT cd.fk_product, cd.subprice,"; @@ -1873,7 +1877,7 @@ class Expedition extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; $sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " AND cd.rowid = ed.fk_origin_line"; - + dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1892,14 +1896,14 @@ class Expedition extends CommonObject } if ($qty <= 0) continue; dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); - + $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; - + if (empty($obj->edbrowid)) { // line without batch detail - + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref)); if ($result < 0) { @@ -1911,9 +1915,9 @@ class Expedition extends CommonObject else { // line with batch detail - + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch, $obj->fk_origin_stock); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1928,7 +1932,7 @@ class Expedition extends CommonObject $error++; } } - + // Call trigger if (! $error) { @@ -1941,9 +1945,9 @@ class Expedition extends CommonObject else { dol_print_error($this->db); - $error++; + $error++; } - + if (! $error) { $this->db->commit(); @@ -1964,7 +1968,7 @@ class Expedition extends CommonObject function set_billed() { $error=0; - + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed @@ -1975,18 +1979,18 @@ class Expedition extends CommonObject { $this->statut=2; $this->billed=1; - + // Call trigger $result=$this->call_trigger('SHIPPING_BILLED',$user); - if ($result < 0) { + if ($result < 0) { $error++; } - + } else { $error++; $this->errors[]=$this->db->lasterror; } - + if (empty($error)) { $this->db->commit(); return 1; @@ -2008,9 +2012,9 @@ class Expedition extends CommonObject global $conf,$langs,$user; $error=0; - + $this->db->begin(); - + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; @@ -2019,14 +2023,14 @@ class Expedition extends CommonObject { $this->statut=1; $this->billed=0; - + // If stock increment is done on closing if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; - + $langs->load("agenda"); - + // Loop on each product line to add a stock movement // TODO possibilite d'expedier a partir d'une propale ou autre origine $sql = "SELECT cd.fk_product, cd.subprice,"; @@ -2037,7 +2041,7 @@ class Expedition extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid"; $sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " AND cd.rowid = ed.fk_origin_line"; - + dol_syslog(get_class($this)."::valid select details", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -2056,15 +2060,15 @@ class Expedition extends CommonObject } if ($qty <= 0) continue; dol_syslog(get_class($this)."::reopen expedition movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid); - + //var_dump($this->lines[$i]); $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; - + if (empty($obj->edbrowid)) { // line without batch detail - + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref)); if ($result < 0) { @@ -2076,9 +2080,9 @@ class Expedition extends CommonObject else { // line with batch detail - + // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record - $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref), '', $obj->eatby, $obj->sellby, $obj->batch, $obj->fk_origin_stock); + $result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -2093,7 +2097,7 @@ class Expedition extends CommonObject $error++; } } - + if (! $error) { // Call trigger @@ -2102,13 +2106,13 @@ class Expedition extends CommonObject $error++; } } - + } else { $error++; $this->errors[]=$this->db->lasterror(); } - - if (! $error) + + if (! $error) { $this->db->commit(); return 1; @@ -2119,7 +2123,7 @@ class Expedition extends CommonObject return -1; } } - + /** * Create a document onto disk according to template module. * @@ -2205,7 +2209,7 @@ class ExpeditionLigne extends CommonObjectLine public $element='expeditiondet'; public $table_element='expeditiondet'; - + public $fk_origin_line; // Deprecated diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 40e9c516ea8..38e4babc87d 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -82,7 +83,7 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'e.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate"; $checkedtypetiers=0; $arrayfields=array( @@ -258,6 +259,7 @@ if ($resql) $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall) $param.= "&sall=".$sall; if ($search_ref_exp) $param.= "&search_ref_exp=".$search_ref_exp; if ($search_ref_liv) $param.= "&search_ref_liv=".$search_ref_liv; if ($search_company) $param.= "&search_company=".$search_company; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 23943fd5282..c06044cb15a 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expenserep require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $langs->load("trips"); $langs->load("bills"); @@ -89,990 +90,1085 @@ $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty( $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$object=new ExpenseReport($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('expensereportcard','globalcard')); + +$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php +$permissionedit = $user->rights->expensereport->creer; // Used by the include of actions_lineupdown.inc.php + + + /* * Actions */ -if ($cancel) +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $action=''; - $fk_projet=''; - $date_start=''; - $date_end=''; - $date=''; - $comments=''; - $vatrate=''; - $value_unit=''; - $qty=1; - $fk_c_type_fees=-1; -} - -if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer) -{ - $object = new ExpenseReport($db); - $result=$object->delete($id, $user); - if ($result >= 0) - { - header("Location: index.php"); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -if ($action == 'add' && $user->rights->expensereport->creer) -{ - $object = new ExpenseReport($db); - - $object->date_debut = $date_start; - $object->date_fin = $date_end; - - $object->fk_statut = 1; - $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); - $object->fk_user_validator = GETPOST('fk_user_validator','int'); - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); - - if ($object->periode_existe($user,$object->date_debut,$object->date_fin)) - { - $error++; - setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); - $action='create'; - } - - if (! $error) - { - $db->begin(); - - $id = $object->create($user); - - if ($id > 0) - { - $db->commit(); - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - $action='create'; - } - } -} - -if ($action == 'update' && $user->rights->expensereport->creer) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - - $object->date_debut = $date_start; - $object->date_fin = $date_end; - - if($object->fk_statut < 3) - { - $object->fk_user_validator = GETPOST('fk_user_validator','int'); - } - - $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); - $object->fk_user_modif = $user->id; - - $result = $object->update($user); - if ($result > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST['id']); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - $result = $object->setValidate($user); - - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if ($result > 0 && $object->fk_user_validator > 0) - { - $langs->load("mails"); - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_validator); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; - - if ($emailTo && $emailFrom) - { - $filename=array(); $filedir=array(); $mimetype=array(); - - // SUBJECT - $subject = $langs->trans("ExpenseReportWaitingForApproval"); - - // CONTENT - $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); - - // Rebuild pdf - /* - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$id,'',"",$langs); - - if($resultPDF): - // ATTACHMENT - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref).".pdf"); - array_push($mimetype,"application/pdf"); - */ - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if ($mailfile) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); - setEventMessages($mesg, null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg=''; - $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); - $mesg.='
    '.$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - else - { - setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); - } - } - } - else - { - setEventMessages($mailfile->error,$mailfile->errors,'errors'); - $action=''; - } - } - else - { - setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); - $action=''; - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - $result = $object->set_save_from_refuse($user); - - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if ($result > 0) - { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition - { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_validator); - $emailTo = $destinataire->email; - - if ($emailTo) - { - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_author); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais à re-approuver"; - - // CONTENT - $dateRefusEx = explode(" ",$object->date_refuse); - - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n"; - $message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n"; - $message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Génération du pdf avant attachement - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF) - { - // ATTACHMENT - $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf"); - array_push($mimetype,"application/pdf"); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - - if (! $mailfile->error) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $mesg=$mailfile->error; - setEventMessages($mesg, null, 'errors'); - } - // END - Send mail - } - else - { - dol_print_error($db,$resultPDF); - exit; - } - } - } - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -// Approve -if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->approve) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - - $result = $object->setApproved($user); - - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if ($result > 0) - { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition - { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // CC - $emailCC = $conf->global->NDF_CC_EMAILS; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_valid); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais validée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être approuvé!\n"; - $message.= "- Approbateur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Génération du pdf avant attachement - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - if($resultPDF): - // ATTACHMENT - $filename=array(); $filedir=array(); $mimetype=array(); - array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); - array_push($filedir, $conf->expensereport->dir_output. - "/". - dol_sanitizeFileName($object->ref) . - "/". - dol_sanitizeFileName($object->ref). - ".pdf" - ); - array_push($mimetype,"application/pdf"); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename,$emailCC); - - if(!$mailfile->error): - - // SEND - $result=$mailfile->sendfile(); - if ($result): - setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs'); - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - else: - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - endif; - - else: - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - endif; - // END - Send mail - else : // if ($resultPDF) - dol_print_error($db,$resultPDF); - exit; - endif; - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->approve) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - - $result = $object->setDeny($user,GETPOST('detail_refuse')); - - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if ($result > 0) - { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition - { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_refuse); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais refusée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être refusée.\n"; - $message.= "- Refuseur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Motif de refus : {$_POST['detail_refuse']}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs'); - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); - } - // END - Send mail - } - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -//var_dump($user->id == $object->fk_user_validator);exit; -if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_cancel') && $id > 0 && $user->rights->expensereport->creer) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - - if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author) - { - $result = $object->set_cancel($user,GETPOST('detail_cancel')); - - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if ($result > 0) - { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition - { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_cancel); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "' ERP - Note de frais annulée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être annulée.\n"; - $message.= "- Annuleur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Motif d'annulation : {$_POST['detail_cancel']}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error) - { - // SEND - $result=$mailfile->sendfile(); - if ($result) - { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $mesg="Impossible d'envoyer l'email."; - setEventMessages($mesg, null, 'errors'); - } - // END - Send mail - } - else - { - setEventMessages($mail->error, $mail->errors, 'errors'); - } - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - else - { - setEventMessages($langs->transnoentitiesnoconv("OnlyOwnerCanCancel"), '', 'errors'); // Should not happened - } -} - -if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->creer) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) - { - $result = $object->setStatut(0); - - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if ($result > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - else - { - setEventMessages("NOT_AUTHOR", '', 'errors'); - } -} - -if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - - $result = $object->set_paid($id, $user); - - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - if ($result > 0) - { - if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition - { - // Send mail - - // TO - $destinataire = new User($db); - $destinataire->fetch($object->fk_user_author); - $emailTo = $destinataire->email; - - // FROM - $expediteur = new User($db); - $expediteur->fetch($user->id); - $emailFrom = $expediteur->email; - - // SUBJECT - $subject = "'ERP - Note de frais payée"; - - // CONTENT - $message = "Bonjour {$destinataire->firstname},\n\n"; - $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; - $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; - $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; - $message.= "Bien cordialement,\n' SI"; - - // Generate pdf before attachment - $object->setDocModel($user,""); - $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - - // PREPARE SEND - $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - - if(!$mailfile->error): - - // SEND - $result=$mailfile->sendfile(); - if ($result): - - // Retour - if($result): - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - else: - dol_print_error($db); - endif; - - else: - dol_print_error($db,$acct->error); - endif; - - else: - $mesg="Impossible d'envoyer l'email."; - setEventMessages($mesg, null, 'errors'); - endif; - // END - Send mail - } - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -if ($action == "addline" && $user->rights->expensereport->creer) -{ - $error = 0; - - $db->begin(); - - $object_ligne = new ExpenseReportLine($db); - - $vatrate = GETPOST('vatrate'); - $object_ligne->comments = GETPOST('comments'); - $qty = GETPOST('qty','int'); - if (empty($qty)) $qty=1; - $object_ligne->qty = $qty; - - $up=price2num(GETPOST('value_unit'),'MU'); - $object_ligne->value_unit = $up; - - $object_ligne->date = $date; - - $object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees'); - - // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. - if (empty($vatrate)) $vatrate = "0.000"; - - $object_ligne->vatrate = price2num($vatrate); - - $object_ligne->fk_projet = $fk_projet; - - - if (! GETPOST('fk_c_type_fees') > 0) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $action=''; - } - - if ($vatrate < 0 || $vatrate == '') - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors'); - $action=''; - } - - /* Projects are never required. To force them, check module forceproject - if ($conf->projet->enabled) - { - if (empty($object_ligne->fk_projet) || $object_ligne->fk_projet==-1) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors'); - } - }*/ - - // Si aucune date n'est rentrée - if (empty($object_ligne->date) || $object_ligne->date=="--") - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - } - // Si aucun prix n'est rentré - if($object_ligne->value_unit==0) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors'); - } - - // S'il y'a eu au moins une erreur - if (! $error) - { - $object_ligne->fk_expensereport = $_POST['fk_expensereport']; - - $type = 0; // TODO What if service ? - $seller = ''; // seller is unknown - $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); - - $object_ligne->vatrate = price2num($vatrate); - $object_ligne->total_ttc = $tmp[2]; - $object_ligne->total_ht = $tmp[0]; - $object_ligne->total_tva = $tmp[1]; - - $result = $object_ligne->insert(); - if ($result > 0) - { - $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - dol_print_error($db,$object->error); - $db->rollback(); - } - } - - $action=''; -} - -if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes" && $user->rights->expensereport->creer) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - - $object_ligne = new ExpenseReportLine($db); - $object_ligne->fetch(GETPOST("rowid")); - $total_ht = $object_ligne->total_ht; - $total_tva = $object_ligne->total_tva; - - $result=$object->deleteline(GETPOST("rowid"), $user); - if ($result >= 0) - { - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - $object->update_totaux_del($object_ligne->total_ht,$object_ligne->total_tva); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } -} - -if ($action == "updateligne" && $user->rights->expensereport->creer) -{ - $object = new ExpenseReport($db); - $object->fetch($id); - - $rowid = $_POST['rowid']; - $type_fees_id = GETPOST('fk_c_type_fees'); - $projet_id = $fk_projet; - $comments = GETPOST('comments'); - $qty = GETPOST('qty'); - $value_unit = GETPOST('value_unit'); - $vatrate = GETPOST('vatrate'); - - if (! GETPOST('fk_c_type_fees') > 0) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $action=''; - } - if (GETPOST('vatrate') < 0 || GETPOST('vatrate') == '') - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors'); - $action=''; - } - - if (! $error) - { - // TODO Use update method of ExpenseReportLine - $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id); - if ($result >= 0) - { - if ($result > 0) - { - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - - $result = $object->recalculer($id); - - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } -} - - -/* - * Generate or regenerate the PDF document - */ -if ($action == 'builddoc') // GET or POST -{ - $depl = new ExpenseReport($db, 0, $_GET['id']); - $depl->fetch($id); - - if ($_REQUEST['model']) - { - $depl->setDocModel($user, $_REQUEST['model']); - } - - $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - $result=expensereport_pdf_create($db, $depl, '', $depl->modelpdf, $outputlangs); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); + if ($cancel) + { $action=''; - } -} + $fk_projet=''; + $date_start=''; + $date_end=''; + $date=''; + $comments=''; + $vatrate=''; + $value_unit=''; + $qty=1; + $fk_c_type_fees=-1; + } -// Remove file in doc form -else if ($action == 'remove_file') -{ - $object = new ExpenseReport($db, 0, $_GET['id']); - if ($object->fetch($id)) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - $object->fetch_thirdparty(); + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - $langs->load("other"); - $upload_dir = $conf->expensereport->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $action=''; - } + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->expensereport->creer) + { + if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + { + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); + } + else + { + if ($object->id > 0) + { + // Because createFromClone modifies the object, we must clone it so that we can restore it later + $orig = clone $object; + + $result=$object->createFromClone($socid); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $object = $orig; + $action=''; + } + } + } + } + + if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer) + { + $object = new ExpenseReport($db); + $result = $object->fetch($id); + $result = $object->delete($user); + if ($result >= 0) + { + header("Location: index.php"); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($action == 'add' && $user->rights->expensereport->creer) + { + $object = new ExpenseReport($db); + + $object->date_debut = $date_start; + $object->date_fin = $date_end; + + $object->fk_statut = 1; + $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); + $object->fk_user_validator = GETPOST('fk_user_validator','int'); + $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private'); + // Fill array 'array_options' with data from add form + if (! $error) + { + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error++; + } + + if ($object->periode_existe($user,$object->date_debut,$object->date_fin)) + { + $error++; + setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); + $action='create'; + } + + if (! $error) + { + $db->begin(); + + $id = $object->create($user); + + if ($id > 0) + { + $db->commit(); + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + $action='create'; + } + } + } + + if ($action == 'update' && $user->rights->expensereport->creer) + { + $object = new ExpenseReport($db); + $object->fetch($id); + + $object->date_debut = $date_start; + $object->date_fin = $date_end; + + if($object->fk_statut < 3) + { + $object->fk_user_validator = GETPOST('fk_user_validator','int'); + } + + $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); + $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private'); + $object->fk_user_modif = $user->id; + + $result = $object->update($user); + if ($result > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST['id']); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($action == 'update_extras') + { + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) $error++; + + if (! $error) + { + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('expensereportdao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error++; + } + } else if ($reshook < 0) + $error++; + } + + if ($error) + $action = 'edit_extras'; + } + + if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer) + { + $object = new ExpenseReport($db); + $object->fetch($id); + $result = $object->setValidate($user); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + if ($result > 0 && $object->fk_user_validator > 0) + { + $langs->load("mails"); + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_validator); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_author); + $emailFrom = $expediteur->email; + + if ($emailTo && $emailFrom) + { + $filename=array(); $filedir=array(); $mimetype=array(); + + // SUBJECT + $subject = $langs->trans("ExpenseReportWaitingForApproval"); + + // CONTENT + $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; + $message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link); + + // Rebuild pdf + /* + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$id,'',"",$langs); + + if($resultPDF): + // ATTACHMENT + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref).".pdf"); + array_push($mimetype,"application/pdf"); + */ + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if ($mailfile) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); + setEventMessages($mesg, null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg=''; + $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); + $mesg.='
    '.$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + else + { + setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings'); + } + } + } + else + { + setEventMessages($mailfile->error,$mailfile->errors,'errors'); + $action=''; + } + } + else + { + setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings'); + $action=''; + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer) + { + $object = new ExpenseReport($db); + $object->fetch($id); + $result = $object->set_save_from_refuse($user); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + if ($result > 0) + { + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + { + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_validator); + $emailTo = $destinataire->email; + + if ($emailTo) + { + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_author); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = "' ERP - Note de frais à re-approuver"; + + // CONTENT + $dateRefusEx = explode(" ",$object->date_refuse); + + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n"; + $message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n"; + $message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // Génération du pdf avant attachement + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF) + { + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf"); + array_push($mimetype,"application/pdf"); + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); + + if (! $mailfile->error) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $mesg=$mailfile->error; + setEventMessages($mesg, null, 'errors'); + } + // END - Send mail + } + else + { + dol_print_error($db,$resultPDF); + exit; + } + } + } + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + // Approve + if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->approve) + { + $object = new ExpenseReport($db); + $object->fetch($id); + + $result = $object->setApproved($user); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + if ($result > 0) + { + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + { + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // CC + $emailCC = $conf->global->NDF_CC_EMAILS; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_valid); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = "' ERP - Note de frais validée"; + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être approuvé!\n"; + $message.= "- Approbateur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // Génération du pdf avant attachement + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + if($resultPDF): + // ATTACHMENT + $filename=array(); $filedir=array(); $mimetype=array(); + array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); + array_push($filedir, $conf->expensereport->dir_output. + "/". + dol_sanitizeFileName($object->ref) . + "/". + dol_sanitizeFileName($object->ref). + ".pdf" + ); + array_push($mimetype,"application/pdf"); + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename,$emailCC); + + if(!$mailfile->error): + + // SEND + $result=$mailfile->sendfile(); + if ($result): + setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs'); + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + else: + setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); + endif; + + else: + setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); + endif; + // END - Send mail + else : // if ($resultPDF) + dol_print_error($db,$resultPDF); + exit; + endif; + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->approve) + { + $object = new ExpenseReport($db); + $object->fetch($id); + + $result = $object->setDeny($user,GETPOST('detail_refuse')); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + if ($result > 0) + { + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + { + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_refuse); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = "' ERP - Note de frais refusée"; + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être refusée.\n"; + $message.= "- Refuseur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Motif de refus : {$_POST['detail_refuse']}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); + + if(!$mailfile->error) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs'); + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors'); + } + // END - Send mail + } + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + //var_dump($user->id == $object->fk_user_validator);exit; + if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_cancel') && $id > 0 && $user->rights->expensereport->creer) + { + $object = new ExpenseReport($db); + $object->fetch($id); + + if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author) + { + $result = $object->set_cancel($user,GETPOST('detail_cancel')); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + if ($result > 0) + { + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + { + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($object->fk_user_cancel); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = "' ERP - Note de frais annulée"; + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être annulée.\n"; + $message.= "- Annuleur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Motif d'annulation : {$_POST['detail_cancel']}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); + + if(!$mailfile->error) + { + // SEND + $result=$mailfile->sendfile(); + if ($result) + { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $mesg="Impossible d'envoyer l'email."; + setEventMessages($mesg, null, 'errors'); + } + // END - Send mail + } + else + { + setEventMessages($mail->error, $mail->errors, 'errors'); + } + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { + setEventMessages($langs->transnoentitiesnoconv("OnlyOwnerCanCancel"), '', 'errors'); // Should not happened + } + } + + if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->creer) + { + $object = new ExpenseReport($db); + $object->fetch($id); + if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) + { + $result = $object->setStatut(0); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + if ($result > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { + setEventMessages("NOT_AUTHOR", '', 'errors'); + } + } + + if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) + { + $object = new ExpenseReport($db); + $object->fetch($id); + + $result = $object->set_paid($id, $user); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + if ($result > 0) + { + if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) // TODO Translate this so we can remove condition + { + // Send mail + + // TO + $destinataire = new User($db); + $destinataire->fetch($object->fk_user_author); + $emailTo = $destinataire->email; + + // FROM + $expediteur = new User($db); + $expediteur->fetch($user->id); + $emailFrom = $expediteur->email; + + // SUBJECT + $subject = "'ERP - Note de frais payée"; + + // CONTENT + $message = "Bonjour {$destinataire->firstname},\n\n"; + $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; + $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; + $message.= "Bien cordialement,\n' SI"; + + // Generate pdf before attachment + $object->setDocModel($user,""); + $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); + + // PREPARE SEND + $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); + + if(!$mailfile->error): + + // SEND + $result=$mailfile->sendfile(); + if ($result): + + // Retour + if($result): + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + else: + dol_print_error($db); + endif; + + else: + dol_print_error($db,$acct->error); + endif; + + else: + $mesg="Impossible d'envoyer l'email."; + setEventMessages($mesg, null, 'errors'); + endif; + // END - Send mail + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($action == "addline" && $user->rights->expensereport->creer) + { + $error = 0; + + $db->begin(); + + $object_ligne = new ExpenseReportLine($db); + + $vatrate = GETPOST('vatrate'); + $object_ligne->comments = GETPOST('comments'); + $qty = GETPOST('qty','int'); + if (empty($qty)) $qty=1; + $object_ligne->qty = $qty; + + $up=price2num(GETPOST('value_unit'),'MU'); + $object_ligne->value_unit = $up; + + $object_ligne->date = $date; + + $object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees'); + + // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. + if (empty($vatrate)) $vatrate = "0.000"; + + $object_ligne->vatrate = price2num($vatrate); + + $object_ligne->fk_projet = $fk_projet; + + + if (! GETPOST('fk_c_type_fees') > 0) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); + $action=''; + } + + if ($vatrate < 0 || $vatrate == '') + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors'); + $action=''; + } + + /* Projects are never required. To force them, check module forceproject + if ($conf->projet->enabled) + { + if (empty($object_ligne->fk_projet) || $object_ligne->fk_projet==-1) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors'); + } + }*/ + + // Si aucune date n'est rentrée + if (empty($object_ligne->date) || $object_ligne->date=="--") + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); + } + // Si aucun prix n'est rentré + if($object_ligne->value_unit==0) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors'); + } + + // S'il y'a eu au moins une erreur + if (! $error) + { + $object_ligne->fk_expensereport = $_POST['fk_expensereport']; + + $type = 0; // TODO What if service ? + $seller = ''; // seller is unknown + $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); + + $object_ligne->vatrate = price2num($vatrate); + $object_ligne->total_ttc = $tmp[2]; + $object_ligne->total_ht = $tmp[0]; + $object_ligne->total_tva = $tmp[1]; + + $result = $object_ligne->insert(); + if ($result > 0) + { + $db->commit(); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + dol_print_error($db,$object->error); + $db->rollback(); + } + } + + $action=''; + } + + if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes" && $user->rights->expensereport->creer) + { + $object = new ExpenseReport($db); + $object->fetch($id); + + $object_ligne = new ExpenseReportLine($db); + $object_ligne->fetch(GETPOST("rowid")); + $total_ht = $object_ligne->total_ht; + $total_tva = $object_ligne->total_tva; + + $result=$object->deleteline(GETPOST("rowid"), $user); + if ($result >= 0) + { + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + $object->update_totaux_del($object_ligne->total_ht,$object_ligne->total_tva); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + if ($action == "updateligne" && $user->rights->expensereport->creer) + { + $object = new ExpenseReport($db); + $object->fetch($id); + + $rowid = $_POST['rowid']; + $type_fees_id = GETPOST('fk_c_type_fees'); + $projet_id = $fk_projet; + $comments = GETPOST('comments'); + $qty = GETPOST('qty'); + $value_unit = GETPOST('value_unit'); + $vatrate = GETPOST('vatrate'); + + if (! GETPOST('fk_c_type_fees') > 0) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); + $action=''; + } + if (GETPOST('vatrate') < 0 || GETPOST('vatrate') == '') + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors'); + $action=''; + } + + if (! $error) + { + // TODO Use update method of ExpenseReportLine + $result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id); + if ($result >= 0) + { + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + $result = $object->recalculer($id); + + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + + /* + * Generate or regenerate the PDF document + */ + if ($action == 'builddoc') // GET or POST + { + $depl = new ExpenseReport($db, 0, $_GET['id']); + $depl->fetch($id); + + if ($_REQUEST['model']) + { + $depl->setDocModel($user, $_REQUEST['model']); + } + + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + $result=expensereport_pdf_create($db, $depl, '', $depl->modelpdf, $outputlangs); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } + } + + // Remove file in doc form + else if ($action == 'remove_file') + { + $object = new ExpenseReport($db, 0, $_GET['id']); + if ($object->fetch($id)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $object->fetch_thirdparty(); + + $langs->load("other"); + $upload_dir = $conf->expensereport->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + $action=''; + } + } } @@ -1080,7 +1176,9 @@ else if ($action == 'remove_file') * View */ -llxHeader('', $langs->trans("ExpenseReport")); +$title=$langs->trans("ExpenseReport") . " - " . $langs->trans("Card"); +$helpurl="EN:Module_Expense_Reports"; +llxHeader("",$title,$helpurl); $form = new Form($db); $formfile = new FormFile($db); @@ -1137,7 +1235,7 @@ if ($action == 'create') // Public note print ''; print '' . $langs->trans('NotePublic') . ''; - print ''; + print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1147,19 +1245,27 @@ if ($action == 'create') if (empty($user->societe_id)) { print ''; print '' . $langs->trans('NotePrivate') . ''; - print ''; + print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; } + // Other attributes + $parameters = array('colspan' => ' colspan="3"'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by + // hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) { + print $object->showOptionals($extrafields, 'edit'); + } + print ''; print ''; dol_fiche_end(); - print '
    '; + print '
    '; print ''; print '     '; print '
    '; @@ -1170,9 +1276,10 @@ else { if($id > 0 || $ref) { - $object = new ExpenseReport($db); $result = $object->fetch($id, $ref); + $res = $object->fetch_optionals($object->id, $extralabels); + if ($result > 0) { if ($object->fk_user_author != $user->id) @@ -1200,7 +1307,7 @@ else print ''; print ''; - dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip'); + dol_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip'); if($object->fk_statut==99) { @@ -1216,7 +1323,7 @@ else $linkback = ''.$langs->trans("BackToList").''; // Ref - print ''.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print ''; @@ -1261,7 +1368,7 @@ else print ''; $userfee=new User($db); $userfee->fetch($object->fk_user_valid); - print $userfee->getNomUrl(1); + print $userfee->getNomUrl(-1); print ''; } @@ -1270,7 +1377,7 @@ else print ''; $userfee=new User($db); $userfee->fetch($object->fk_user_author); - print $userfee->getNomUrl(1); + print $userfee->getNomUrl(-1); print ''; if ($object->fk_statut==6) { @@ -1279,15 +1386,19 @@ else print ''; $userfee=new User($db); $userfee->fetch($user->id); - print $userfee->getNomUrl(1); + print $userfee->getNomUrl(-1); print ''; } + // Other attributes + //$cols = 3; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + // Public note print ''; print '' . $langs->trans('NotePublic') . ''; - print ''; + print ''; $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1297,7 +1408,7 @@ else if (empty($user->societe_id)) { print ''; print '' . $langs->trans('NotePrivate') . ''; - print ''; + print ''; $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1317,7 +1428,7 @@ else } else { - dol_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip'); + dol_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip'); if ($action == 'save') { @@ -1435,7 +1546,6 @@ else $sql.= " AND p.fk_typepayment = c.id"; $sql.= " ORDER BY dp"; - //print $sql; $resql = $db->query($sql); if ($resql) { @@ -1504,7 +1614,7 @@ else $userauthor=new User($db); $result=$userauthor->fetch($object->fk_user_author); if ($result < 0) dol_print_error('',$userauthor->error); - print $userauthor->getNomUrl(1); + print $userauthor->getNomUrl(-1); } print ''; @@ -1527,7 +1637,7 @@ else { $userfee=new User($db); $userfee->fetch($object->fk_user_validator); - print $userfee->getNomUrl(1); + print $userfee->getNomUrl(-1); if (empty($userfee->email) || ! isValidEmail($userfee->email)) { $langs->load("errors"); @@ -1545,7 +1655,7 @@ else { $userfee=new User($db); $userfee->fetch($object->fk_user_cancel); - print $userfee->getNomUrl(1); + print $userfee->getNomUrl(-1); } print ''; print ''; @@ -1566,7 +1676,7 @@ else { $userapp=new User($db); $userapp->fetch($object->fk_user_approve); - print $userapp->getNomUrl(1); + print $userapp->getNomUrl(-1); } print ''; print ''; @@ -1582,7 +1692,7 @@ else print ''; $userfee=new User($db); $userfee->fetch($object->fk_user_refuse); - print $userfee->getNomUrl(1); + print $userfee->getNomUrl(-1); print ''; print ''; print ''.$langs->trans("DATE_REFUS").''; @@ -1600,7 +1710,7 @@ else print ''; $userfee=new User($db); $userfee->fetch($object->fk_user_paid); - print $userfee->getNomUrl(1); + print $userfee->getNomUrl(-1); print ''; print ''; print ''.$langs->trans("DATE_PAIEMENT").''; @@ -1609,6 +1719,10 @@ else */ } + // Other attributes + $cols = 3; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + print ''; print '
    '; @@ -1702,17 +1816,19 @@ else } // Ajout des boutons de modification/suppression - print ''; if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer) { + print ''; + print 'rowid.'#'.$objp->rowid.'">'; print img_edit(); print '   '; print 'rowid.'">'; print img_delete(); print ''; + + print ''; } - print ''; print ''; } @@ -1904,12 +2020,12 @@ if ($action != 'create' && $action != 'edit') if ($object->fk_user_author == $user->id) { // Modify - print 'id.'">'.$langs->trans('Modify').''; + print ''; // Validate if (count($object->lines) > 0 || count($object->lignes) > 0) { - print 'id.'">'.$langs->trans('ValidateAndSubmit').''; + print ''; } } } @@ -1924,12 +2040,12 @@ if ($action != 'create' && $action != 'edit') if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { // Modify - print 'id.'">'.$langs->trans('Modify').''; + print ''; // Brouillonner (le statut refusée est identique à brouillon) //print ''.$langs->trans('BROUILLONNER').''; // Enregistrer depuis le statut "Refusée" - print 'id.'">'.$langs->trans('ValidateAndSubmit').''; + print ''; } } @@ -1938,7 +2054,7 @@ if ($action != 'create' && $action != 'edit') if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { // Brouillonner - print 'id.'">'.$langs->trans('SetToDraft').''; + print ''; } } @@ -1952,7 +2068,7 @@ if ($action != 'create' && $action != 'edit') if ($object->fk_user_author == $user->id) { // Brouillonner - print 'id.'">'.$langs->trans('SetToDraft').''; + print ''; } } @@ -1961,15 +2077,15 @@ if ($action != 'create' && $action != 'edit') //if($object->fk_user_validator==$user->id) //{ // Validate - print 'id.'">'.$langs->trans('Approve').''; + print ''; // Deny - print 'id.'">'.$langs->trans('Deny').''; + print ''; //} if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { // Cancel - print 'id.'">'.$langs->trans('Cancel').''; + print ''; } } @@ -1979,7 +2095,7 @@ if ($action != 'create' && $action != 'edit') if ($user->rights->expensereport->approve && $object->fk_statut == 5) { - print 'id.'">'.$langs->trans('Deny').''; + print ''; } // If bank module is used @@ -2008,14 +2124,14 @@ if ($action != 'create' && $action != 'edit') if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == 5) { // Cancel - print 'id.'">'.$langs->trans('Cancel').''; + print ''; } // TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled. if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == 6) { // Cancel - print 'id.'">'.$langs->trans('Cancel').''; + print ''; } @@ -2023,12 +2139,12 @@ if ($action != 'create' && $action != 'edit') if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut <= 4) { // Delete - print 'id.'">'.$langs->trans('Delete').''; + print ''; } else if($user->rights->expensereport->supprimer && $object->fk_statut != 6) { // Delete - print 'id.'">'.$langs->trans('Delete').''; + print ''; } } @@ -2044,7 +2160,8 @@ print '
    '; /* * Generate documents */ -if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit') + +if($user->rights->expensereport->export && $action != 'edit') { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); @@ -2072,10 +2189,12 @@ if ($action != 'create' && $action != 'edit' && ($id || $ref)) // Show links to link elements $linktoelements=array(); - if (! empty($conf->global->EXPENSES_LINK_TO_INTERVENTION)) $linktoelements[]='fichinter'; - $linktoelem = $form->showLinkToObjectBlock($object, $linktoelements, array('expensereport')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + if (! empty($conf->global->EXPENSES_LINK_TO_INTERVENTION)) + { + $linktoelements[]='fichinter'; + $linktoelem = $form->showLinkToObjectBlock($object, $linktoelements, array('expensereport')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + } } llxFooter(); diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php new file mode 100644 index 00000000000..298a178f00c --- /dev/null +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -0,0 +1,502 @@ + + * Copyright (C) 2016 Laurent Destailleur + * + * 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 . + */ + + use Luracast\Restler\RestException; + + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + +/** + * API class for Expense Reports + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class ExpenseReports extends DolibarrApi +{ + + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid' + ); + + /** + * @var ExpenseReport $expensereport {@type ExpenseReport} + */ + public $expensereport; + + + /** + * Constructor + */ + function __construct() + { + global $db, $conf; + $this->db = $db; + $this->expensereport = new ExpenseReport($this->db); + } + + /** + * Get properties of a Expense Report object + * + * Return an array with Expense Report informations + * + * @param int $id ID of Expense Report + * @return array|mixed Data without useless information + * + * @throws RestException + */ + function get($id) + { + if(! DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } + + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Expense report not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $this->expensereport->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->expensereport); + } + + /** + * List Expense Reports + * + * Get a list of Expense Reports + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} + * + * @return array Array of Expense Report objects + */ + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $user_ids = 0) { + global $db, $conf; + + $obj_ret = array(); + + // case of external user, $societe param is ignored and replaced by user's socid + //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; + + $sql = "SELECT t.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as t"; + $sql.= ' WHERE t.entity IN ('.getEntity('expensereport', 1).')'; + if ($user_ids) $sql.=" AND t.fk_user_author IN (".$user_ids.")"; + + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + + if ($result) + { + $num = $db->num_rows($result); + while ($i < min($num, ($limit <= 0 ? $num : $limit))) + { + $obj = $db->fetch_object($result); + $expensereport_static = new ExpenseReport($db); + if($expensereport_static->fetch($obj->rowid)) { + $obj_ret[] = parent::_cleanObjectDatas($expensereport_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve Expense Report list'); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No Expense Report found'); + } + return $obj_ret; + } + + /** + * Create Expense Report object + * + * @param array $request_data Request data + * @return int ID of Expense Report + */ + function post($request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401, "Insuffisant rights"); + } + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach($request_data as $field => $value) { + $this->expensereport->$field = $value; + } + /*if (isset($request_data["lines"])) { + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->expensereport->lines = $lines; + }*/ + if ($this->expensereport->create(DolibarrApiAccess::$user) <= 0) { + $errormsg = $this->expensereport->error; + throw new RestException(500, $errormsg ? $errormsg : "Error while creating expensereport"); + } + + return $this->expensereport->id; + } + + /** + * Get lines of an Expense Report + * + * @param int $id Id of Expense Report + * + * @url GET {id}/lines + * + * @return int + */ +/* + function getLines($id) { + if(! DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } + + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->expensereport->getLinesArray(); + $result = array(); + foreach ($this->expensereport->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } +*/ + + /** + * Add a line to given Expense Report + * + * @param int $id Id of Expense Report to update + * @param array $request_data Expense Report data + * + * @url POST {id}/lines + * + * @return int + */ +/* + function postLine($id, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } + + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $fk_parent_line, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->fk_unit, + $this->element, + $request_data->id + ); + + if ($updateRes > 0) { + return $this->get($id)->line->rowid; + + } + return false; + } +*/ + + /** + * Update a line to given Expense Report + * + * @param int $id Id of Expense Report to update + * @param int $lineid Id of line to update + * @param array $request_data Expense Report data + * + * @url PUT {id}/lines/{lineid} + * + * @return object + */ + /* + function putLine($id, $lineid, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } + + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->fk_unit + ); + + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; + } + */ + + /** + * Delete a line of given Expense Report + * + * @param int $id Id of Expense Report to update + * @param int $lineid Id of line to delete + * + * @url DELETE {id}/lines/{lineid} + * + * @return int + */ + /* + function delLine($id, $lineid) { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } + + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->deleteline($lineid); + if ($updateRes == 1) { + return $this->get($id); + } + return false; + } + */ + + /** + * Update Expense Report general fields (won't touch lines of expensereport) + * + * @param int $id Id of Expense Report to update + * @param array $request_data Datas + * + * @return int + */ + /* + function put($id, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } + + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + foreach($request_data as $field => $value) { + $this->expensereport->$field = $value; + } + + if($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update')) + return $this->get($id); + + return false; + } + */ + + /** + * Delete Expense Report + * + * @param int $id Expense Report ID + * + * @return array + */ + function delete($id) + { + if(! DolibarrApiAccess::$user->rights->expensereport->supprimer) { + throw new RestException(401); + } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Expense Report not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if( ! $this->expensereport->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when delete Expense Report : '.$this->expensereport->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Expense Report deleted' + ) + ); + + } + + /** + * Validate an Expense Report + * + * @param int $id Expense Report ID + * + * @url POST {id}/validate + * + * @return array + * FIXME An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "idwarehouse": 0 + * } + */ + /* + function validate($id, $idwarehouse=0) + { + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if( ! $this->expensereport->valid(DolibarrApiAccess::$user, $idwarehouse)) { + throw new RestException(500, 'Error when validate expensereport'); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'expensereport validated' + ) + ); + }*/ + + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + function _validate($data) + { + $expensereport = array(); + foreach (ExpenseReports::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $expensereport[$field] = $data[$field]; + + } + return $expensereport; + } +} diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index a05805c7f74..f460799346b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -36,12 +36,14 @@ class ExpenseReport extends CommonObject var $fk_element = 'fk_expensereport'; var $lignes=array(); - var $date_debut; - var $date_fin; + + public $date_debut; + + public $date_fin; var $fk_user_validator; var $status; - var $fk_statut; // -- 1=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + var $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied var $fk_c_paiement; var $paid; @@ -262,8 +264,8 @@ class ExpenseReport extends CommonObject /** * Load an object from database * - * @param int $id Id - * @param string $ref Ref + * @param int $id Id {@min 1} + * @param string $ref Ref {@name ref} * @return int <0 if KO, >0 if OK */ function fetch($id, $ref='') @@ -806,11 +808,10 @@ class ExpenseReport extends CommonObject /** * delete * - * @param int $rowid Id to delete (optional) * @param User $fuser User that delete * @return int <0 if KO, >0 if OK */ - function delete($rowid=0, User $fuser=null) + function delete(User $fuser=null) { global $user,$langs,$conf; diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index dd9a28a130c..9ff90982c3e 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -81,8 +81,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -llxHeader("",$langs->trans("ExpenseReport")); - +$title=$langs->trans("ExpenseReport") . " - " . $langs->trans("Documents"); +$helpurl="EN:Module_Expense_Reports"; +llxHeader("",$title,$helpurl); if ($object->id) { @@ -90,7 +91,7 @@ if ($object->id) $head=expensereport_prepare_head($object); - dol_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip'); + dol_fiche_head($head, 'documents', $langs->trans("ExpenseReport"), 0, 'trip'); // Construit liste des fichiers @@ -122,6 +123,7 @@ if ($object->id) $modulepart = 'expensereport'; $permission = $user->rights->expensereport->creer; + $permtoedit = $user->rights->expensereport->creer; $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 117ecc5e3c4..8d19a8e9f6d 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -142,7 +142,7 @@ $max=10; $langs->load("boxes"); -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.ref, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as fk_status"; +$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut, u.photo, d.rowid, d.ref, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as fk_status"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user_author"; @@ -183,9 +183,12 @@ if ($result) $userstatic->id=$obj->uid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->login=$obj->login; + $userstatic->statut=$obj->statut; + $userstatic->photo=$obj->photo; print ''; print ''.$expensereportstatic->getNomUrl(1).''; - print ''.$userstatic->getNomUrl(1).''; + print ''.$userstatic->getNomUrl(-1).''; print ''.price($obj->total_ht).''; print ''.price($obj->total_ttc).''; print ''.dol_print_date($db->jdate($obj->dm),'day').''; diff --git a/htdocs/expensereport/info.php b/htdocs/expensereport/info.php index a5a3c830975..b3ebbc153ef 100644 --- a/htdocs/expensereport/info.php +++ b/htdocs/expensereport/info.php @@ -39,8 +39,9 @@ $result = restrictedArea($user, 'expensereport', $id, ''); /* * View */ - -llxHeader('', $langs->trans("ExpenseReport")); +$title=$langs->trans("ExpenseReport") . " - " . $langs->trans("Info"); +$helpurl="EN:Module_Expense_Reports"; +llxHeader("",$title,$helpurl); if ($id) { @@ -50,7 +51,7 @@ if ($id) $head = expensereport_prepare_head($object); - dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip'); + dol_fiche_head($head, 'info', $langs->trans("ExpenseReport"), 0, 'trip'); print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalvatfield'] == $i) print ''; + elseif ($totalarray['totalttcfield'] == $i) print ''; + else print ''; + } + print ''; + } $db->free($resql); + + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print '
    '; dol_print_object_info($object); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index e09a74e20f3..722fb05767d 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -20,29 +20,51 @@ */ /** - * \file htdocs/expensereport/index.php + * \file htdocs/expensereport/list.php * \ingroup expensereport * \brief list of expense reports */ require "../main.inc.php"; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("companies"); $langs->load("users"); $langs->load("trips"); +$action=GETPOST('action','alpha'); +$massaction=GETPOST('massaction','alpha'); +$show_files=GETPOST('show_files','int'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); + // Security check $socid = $_GET["socid"]?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'expensereport','',''); +$diroutputmassaction=$conf->expensereport->dir_output . '/temp/massgeneration/'.$user->id; + +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='c.ref'; +if (! $sortorder) $sortorder='DESC'; + $sall = GETPOST('sall'); $search_ref = GETPOST('search_ref'); $search_user = GETPOST('search_user','int'); $search_amount_ht = GETPOST('search_amount_ht','alpha'); +$search_amount_vat = GETPOST('search_amount_vat','alpha'); $search_amount_ttc = GETPOST('search_amount_ttc','alpha'); $search_status = (GETPOST('search_status','alpha')!=''?GETPOST('search_status','alpha'):GETPOST('statut','alpha')); $month_start = GETPOST("month_start","int"); @@ -69,9 +91,33 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'd.ref'=>'Ref', + 'd.note_public'=>"NotePublic", 'u.lastname'=>'Lastname', 'u.firstname'=>"Firstname", + 'u.login'=>"Login", ); +if (empty($user->socid)) $fieldstosearchall["d.note_private"]="NotePrivate"; + +$arrayfields=array( + 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'user'=>array('label'=>$langs->trans("Person"), 'checked'=>1), + 'd.date_debut'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1), + 'd.date_fin'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1), + 'd.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), + 'd.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), + 'd.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), + 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'd.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} @@ -79,26 +125,42 @@ $fieldstosearchall = array( * Actions */ +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +// Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test must be present to be compatible with all browsers { $search_ref=""; $search_user=""; $search_amount_ht=""; + $search_amount_vat=""; $search_amount_ttc=""; $search_status=""; $month_start=""; $year_start=""; $month_end=""; $year_end=""; + $toselect=''; $search_array_options=array(); } +if (empty($reshook)) +{ + $objectclass='ExpenseReport'; + $objectlabel='ExpenseReport'; + $permtoread = $user->rights->expensereport->lire; + $permtodelete = $user->rights->expensereport->supprimer; + $uploaddir = $conf->expensereport->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + /* @@ -107,6 +169,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $form = new Form($db); $formother = new FormOther($db); +$formfile = new FormFile($db); llxHeader('', $langs->trans("ListOfTrips")); @@ -130,19 +193,21 @@ $pagenext = $page + 1; $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,"; $sql.= " d.date_debut, d.date_fin, d.date_valid,"; -$sql.= " u.rowid as id_user, u.firstname, u.lastname"; +$sql.= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.statut, u.photo"; +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; -$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; -$sql.= " WHERE d.entity = ".$conf->entity; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_extrafields as ef on (d.rowid = ef.fk_object)"; +$sql.= ", ".MAIN_DB_PREFIX."user as u"; +$sql.= " WHERE d.fk_user_author = u.rowid AND d.entity = ".$conf->entity; // Search all -if (!empty($sall)) -{ - $sql.= natural_search(array_keys($fieldstosearchall), $sall); -} +if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall); // Ref -if(!empty($search_ref)){ - $sql.= " AND d.ref LIKE '%".$db->escape($search_ref)."%'"; -} +if (!empty($search_ref)) $sql.= natural_search('d.ref', $search_ref); // Date Start if ($month_start > 0) { @@ -172,26 +237,16 @@ else if ($year_end > 0) $sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,1,false))."' AND '".$db->idate(dol_get_last_day($year_end,12,false))."'"; } // Amount -if ($search_amount_ht != '') -{ - $sql.= natural_search('d.total_ht', $search_amount_ht, 1); -} -if ($search_amount_ttc != '') -{ - $sql.= natural_search('d.total_ttc', $search_amount_ttc, 1); -} +if ($search_amount_ht != '') $sql.= natural_search('d.total_ht', $search_amount_ht, 1); +if ($search_amount_ttc != '') $sql.= natural_search('d.total_ttc', $search_amount_ttc, 1); // User -if ($search_user != '' && $search_user >= 0) -{ - $sql.= " AND u.rowid = '".$db->escape($search_user)."'"; -} +if ($search_user != '' && $search_user >= 0) $sql.= " AND u.rowid = '".$db->escape($search_user)."'"; // Status if ($search_status != '' && $search_status >= 0) { if (strstr($search_status, ',')) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; else $sql.=" AND d.fk_statut = ".$search_status; } - // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) { @@ -199,8 +254,26 @@ if (empty($user->rights->expensereport->readall) && empty($user->rights->expense $childids[]=$user->id; $sql.= " AND d.fk_user_author IN (".join(',',$childids).")\n"; } +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); + $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -214,11 +287,13 @@ $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i = 0; + $arrayofselected=is_array($toselect)?$toselect:array(); + $param=""; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall) $param.="&sall=".$sall; if ($search_ref) $param.="&search_ref=".$search_ref; if ($search_user) $param.="&search_user=".$search_user; if ($search_amount_ht) $param.="&search_amount_ht=".$search_amount_ht; @@ -233,78 +308,182 @@ if ($resql) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - print_barre_liste($langs->trans("ListTripsAndExpenses"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); + // List of mass actions available + $arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + if ($user->rights->expensereport->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); + if ($massaction == 'presend') $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + print '
    '."\n"; if ($optioncss != '') print ''; print ''; + print ''; print ''; print ''; print ''; - if ($sall) + $title = $langs->trans("ListTripsAndExpenses"); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - print ''; + $moreforfilter=''; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (! empty($moreforfilter)) + { + print '
    '; + print $moreforfilter; + print '
    '; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
    '."\n"; print ""; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"d.date_debut","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"d.date_fin","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.lastname","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("TotalHT"),$_SERVER["PHP_SELF"],"d.total_ht","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("TotalVAT"),$_SERVER["PHP_SELF"],"d.total_tva","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("TotalTTC"),$_SERVER["PHP_SELF"],"d.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.ref","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['user']['checked'])) print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.lastname","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['d.date_debut']['checked'])) print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"d.date_debut","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['d.date_fin']['checked'])) print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"d.date_fin","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['d.total_ht']['checked'])) print_liste_field_titre($langs->trans("TotalHT"),$_SERVER["PHP_SELF"],"d.total_ht","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['d.total_vat']['checked'])) print_liste_field_titre($langs->trans("TotalVAT"),$_SERVER["PHP_SELF"],"d.total_tva","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['d.total_ttc']['checked'])) print_liste_field_titre($langs->trans("TotalTTC"),$_SERVER["PHP_SELF"],"d.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + // 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'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } + } + // Hook fields + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'],$_SERVER["PHP_SELF"],"d.fk_statut","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Filters print ''; - print ''; - - // Date end - print ''; - - // User - if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) + if (! empty($arrayfields['d.ref']['checked'])) { - print ''; - } else { - print ''; + print ''; } - + // User + if (! empty($arrayfields['user']['checked'])) + { + if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) + { + print ''; + } else { + print ''; + } + } + // Date start + if (! empty($arrayfields['d.date_debut']['checked'])) + { + print ''; + } + // Date end + if (! empty($arrayfields['d.date_fin']['checked'])) + { + print ''; + } // Amount with no tax - print ''; - - print ''; - + if (! empty($arrayfields['d.total_ht']['checked'])) + { + print ''; + } + if (! empty($arrayfields['d.total_vat']['checked'])) + { + print ''; + } // Amount with all taxes - print ''; - + if (! empty($arrayfields['d.total_ttc']['checked'])) + { + print ''; + } + // 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'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['d.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['d.tms']['checked'])) + { + print ''; + } // Status - print ''; + } + // Action column + print ''; - print ''; - print "\n"; $var=true; @@ -314,74 +493,201 @@ if ($resql) $total_total_tva = 0; $expensereportstatic=new ExpenseReport($db); - + $usertmp = new User($db); + if ($num > 0) { - while ($i < min($num,$limit)) + $i=0; + $var=true; + $totalarray=array(); + while ($i < min($num,$limit)) { - $objp = $db->fetch_object($resql); - - $expensereportstatic->id=$objp->rowid; - $expensereportstatic->ref=$objp->ref; - $expensereportstatic->status=$objp->status; - $expensereportstatic->valid=$objp->date_valid; - $expensereportstatic->date_debut=$objp->date_debut; - $expensereportstatic->date_fin=$objp->date_fin; + $obj = $db->fetch_object($resql); + + $expensereportstatic->id=$obj->rowid; + $expensereportstatic->ref=$obj->ref; + $expensereportstatic->status=$obj->status; + $expensereportstatic->valid=$obj->date_valid; + $expensereportstatic->date_debut=$obj->date_debut; + $expensereportstatic->date_fin=$obj->date_fin; $var=!$var; print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; + if (! empty($arrayfields['d.ref']['checked'])) { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['user']['checked'])) { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['d.date_debut']['checked'])) { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['d.date_fin']['checked'])) { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Amount HT + if (! empty($arrayfields['d.total_ht']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; + $totalarray['totalht'] += $obj->total_ht; + } + // Amount VAT + if (! empty($arrayfields['d.total_vat']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; + $totalarray['totalvat'] += $obj->total_tva; + } + // Amount TTC + if (! empty($arrayfields['d.total_ttc']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; + $totalarray['totalttc'] += $obj->total_ttc; + } + + // 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 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['d.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['d.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['d.fk_statut']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; print "\n"; - $total_total_ht = $total_total_ht + $objp->total_ht; - $total_total_tva = $total_total_tva + $objp->total_tva; - $total_total_ttc = $total_total_ttc + $objp->total_ttc; + $total_total_ht = $total_total_ht + $obj->total_ht; + $total_total_tva = $total_total_tva + $obj->total_tva; + $total_total_ttc = $total_total_ttc + $obj->total_ttc; $i++; } - - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - } + } else { print ''.''; } - print "
    '; - print ''; - - // Date start - print ''; - print ''; - $formother->select_year($year_start,'year_start',1, $min_year, $max_year); - print ''; - print ''; - $formother->select_year($year_end,'year_end',1, $min_year, $max_year); - print ''; - print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print ' '; + print ''; + print ''; + print $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print ' '; + print ''; + $formother->select_year($year_start,'year_start',1, $min_year, $max_year); + print ''; + print ''; + $formother->select_year($year_end,'year_end',1, $min_year, $max_year); + print ' '; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; - select_expensereport_statut($search_status,'search_status',1,1); + if (! empty($arrayfields['d.fk_statut']['checked'])) + { + print ''; + select_expensereport_statut($search_status,'search_status',1,1); + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + print $searchpitco; print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
    '; - print $expensereportstatic->getNomUrl(1); - if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) print img_warning($langs->trans("Late")); - if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) print img_warning($langs->trans("Late")); - print ''.($objp->date_debut > 0 ? dol_print_date($objp->date_debut, 'day') : '').''.($objp->date_fin > 0 ? dol_print_date($objp->date_fin, 'day') : '').''.img_object($langs->trans("ShowUser"),"user").' '.dolGetFirstLastname($objp->firstname, $objp->lastname).''.price($objp->total_ht).''.price($objp->total_tva).''.price($objp->total_ttc).''; - print $expensereportstatic->getLibStatut(5); - print ''; + print $expensereportstatic->getNomUrl(1); + if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) print img_warning($langs->trans("Late")); + if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) print img_warning($langs->trans("Late")); + print ''; + $usertmp->id=$obj->id_user; + $usertmp->lastname=$obj->lastname; + $usertmp->firstname=$obj->firstname; + $usertmp->login=$obj->login; + $usertmp->statut=$obj->statut; + $usertmp->photo=$obj->photo; + print $usertmp->getNomUrl(-1); + print ''.($obj->date_debut > 0 ? dol_print_date($obj->date_debut, 'day') : '').''.($obj->date_fin > 0 ? dol_print_date($obj->date_fin, 'day') : '').''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print ''.$expensereportstatic->getLibStatut(5).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
    '.$langs->trans("Total").''.price($total_total_ht).''.price($total_total_tva).''.price($total_total_ttc).'
    '.$langs->trans("NoRecordFound").'
    "; - print "
    "; - - /* - print '
    '; - print ''.$langs->trans("NewTrip").''; - print '
    '; - */ + // Show total line + if (isset($totalarray['totalhtfield'])) + { + print '
    '.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
    '."\n"; + + print ''."\n"; + + /* + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) + { + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->expensereport->lire; + $delallowed=$user->rights->expensereport->lire; + + print '
    '; + $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); + $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; + + print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
    '.$langs->trans("ShowTempMassFilesArea").''; + } + */ } else { diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index eac3c735d66..b2c7a779d32 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -34,13 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } - if ($conf->contrat->enabled) { require_once DOL_DOCUMENT_ROOT."/core/class/html.formcontract.class.php"; @@ -140,7 +138,7 @@ if (empty($reshook)) } } } - + if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) { $result = $object->setValid($user); @@ -612,6 +610,21 @@ if (empty($reshook)) } } + // Classify Billed + else if ($action == 'classifydone' && $user->rights->ficheinter->creer) + { + $result=$object->setStatut(3); + if ($result > 0) + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + /* * Mise a jour d'une ligne d'intervention */ @@ -747,14 +760,14 @@ if (empty($reshook)) /* * Send mail */ - + // Actions to send emails $actiontypecode='AC_OTH_AUTO'; $trigger_name='FICHINTER_SENTBYMAIL'; $paramname='id'; $mode='emailfromintervention'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - + if ($action == 'update_extras') { @@ -842,8 +855,8 @@ if (empty($reshook)) $form = new Form($db); $formfile = new FormFile($db); -if ($conf->contrat->enabled) - $formcontract = new FormContract($db); +if ($conf->contrat->enabled) $formcontract = new FormContract($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } llxHeader('',$langs->trans("Intervention")); @@ -969,7 +982,7 @@ if ($action == 'create') else $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid'); */ - $numprojet=$formproject->select_projects($soc->id,GETPOST('projectid','int'),'projectid'); + $numprojet=$formproject->select_projects($soc->id,$projectid,'projectid'); if ($numprojet==0) { print '   '.$langs->trans("AddProject").''; @@ -1041,6 +1054,8 @@ if ($action == 'create') { print ''; print ''; + } elseif ($origin == 'project' && !empty($projectid)) { + print ''; } dol_fiche_end(); @@ -1058,6 +1073,13 @@ if ($action == 'create') dol_fiche_head(''); print '
    '; + if (is_object($objectsrc)) + { + print ''; + print ''; + } elseif ($origin == 'project' && !empty($projectid)) { + print ''; + } print ''; print ''; + //print ''; // Other attributes - $cols = 3; + $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + print '
    '.$langs->trans("ThirdParty").''; print $form->select_company('','socid','','SelectThirdParty',1); @@ -1081,7 +1103,7 @@ else if ($id > 0 || ! empty($ref)) { /* * Affichage en mode visu - */ + */ $object->fetch($id, $ref); $object->fetch_thirdparty(); @@ -1151,7 +1173,7 @@ else if ($id > 0 || ! empty($ref)) // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneIntervention'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - + if (!$formconfirm) { $parameters=array('lineid'=>$lineid); @@ -1163,59 +1185,104 @@ else if ($id > 0 || ! empty($ref)) // Print form confirm print $formconfirm; - print ''; - + + // Intervention card $linkback = ''.$langs->trans("BackToList").''; - + + + $morehtmlref='
    '; + // Ref customer + //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); + //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
    '.$langs->trans('Project') . ' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
    '; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + // Ref + /* print ''; // Third party print ""; - - if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) - { - // Duration - print ''; - print ''; - print ''; - } - + */ + if (! empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES)) { // Date Start - print ''; - print ''; + print ''; print ''; - + // Date End print ''; - print ''; print ''; - + // Date Terminate/close print ''; - print ''; print ''; } // Description (must be a textarea and not html must be allowed (used in list view) - print ''; print ''; // Project + /* if (! empty($conf->projet->enabled)) { $langs->load('projects'); @@ -1243,7 +1310,7 @@ else if ($id > 0 || ! empty($ref)) } print ''; print ''; - } + }*/ // Contrat if ($conf->contrat->enabled) @@ -1262,7 +1329,7 @@ else if ($id > 0 || ! empty($ref)) print ''; } print '
    '.$langs->trans("Ref").''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); print '
    ".$langs->trans("Company").''.$object->thirdparty->getNomUrl(1)."
    '.$langs->trans("TotalDuration").''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'
    '.$langs->trans("Dateo").''; + print '
    '.$langs->trans("Dateo").''; print $object->dateo ? dol_print_date($object->dateo, 'daytext') : ' '; print '
    '.$langs->trans("Datee").''; + print ''; print $object->datee ? dol_print_date($object->datee, 'daytext') : ' '; print '
    '.$langs->trans("Datet").''; + print ''; print $object->datet ? dol_print_date($object->datet, 'daytext') : ' '; print '
    '; + print '
    '; print $form->editfieldkey("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea'); - print ''; + print ''; print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea:8:80'); print '
    '; - print '
    '; + print ''; if ($action == 'contrat') { $formcontract= new Formcontract($db); @@ -1287,13 +1354,37 @@ else if ($id > 0 || ! empty($ref)) } // Statut - print '
    '.$langs->trans("Status").''.$object->getLibStatut(4).'
    '.$langs->trans("Status").''.$object->getLibStatut(4).'
    '; + + print '
    '; + print '
    '; + print '
    '; + print '
    '; + + print ''; + + if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) + { + // Duration + print ''; + print ''; + print ''; + } + print "
    '.$langs->trans("TotalDuration").''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'
    "; + + print '
    '; + print '
    '; + print '
    '; + + print '

    '; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { @@ -1442,7 +1533,7 @@ else if ($id > 0 || ! empty($ref)) print ''; $form->select_date($db->jdate($objp->date_intervention),'di',1,1,0,"date_intervention"); print ''; - + // Duration print ''; if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) { @@ -1626,7 +1717,7 @@ else if ($id > 0 || ! empty($ref)) else print ''; } - if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) + if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 { if ($object->statut != 2) { @@ -1639,11 +1730,17 @@ else if ($id > 0 || ! empty($ref)) } } + // Done + if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > 0 && $object->statut < 3) + { + print ''; + } + // Clone if ($user->rights->ficheinter->creer) { print ''; } - + // Delete if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer) { @@ -1754,7 +1851,7 @@ else if ($id > 0 || ! empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'int'.$object->id); - } + } $formmail->withfrom=1; $liste=array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 54d5dc05c33..f1ae7af5309 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -38,7 +38,8 @@ class Fichinter extends CommonObject public $table_element='fichinter'; public $fk_element='fk_fichinter'; public $table_element_line='fichinterdet'; - + public $picto = 'intervention'; + /** * {@inheritdoc} */ @@ -78,15 +79,15 @@ class Fichinter extends CommonObject $this->statuts[0]='Draft'; $this->statuts[1]='Validated'; $this->statuts[2]='StatusInterInvoiced'; - $this->statuts[3]='Close'; + $this->statuts[3]='Done'; $this->statuts_short[0]='Draft'; $this->statuts_short[1]='Validated'; $this->statuts_short[2]='StatusInterInvoiced'; - $this->statuts_short[3]='Close'; + $this->statuts_short[3]='Done'; $this->statuts_logo[0]='statut0'; $this->statuts_logo[1]='statut1'; $this->statuts_logo[2]='statut6'; - $this->statuts_logo[3]='statut4'; + $this->statuts_logo[3]='statut6'; } /** @@ -426,7 +427,7 @@ class Fichinter extends CommonObject * Validate a intervention * * @param User $user User that validate - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ function setValid($user, $notrigger=0) @@ -552,7 +553,7 @@ class Fichinter extends CommonObject * Returns the label of a statut * * @param int $statut id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ function LibStatut($statut,$mode=0) @@ -561,22 +562,20 @@ class Fichinter extends CommonObject if ($mode == 0) return $langs->trans($this->statuts[$statut]); - if ($mode == 1) return $langs->trans($this->statuts_short[$statut]); - if ($mode == 2) return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]).' '.$langs->trans($this->statuts_short[$statut]); - if ($mode == 3) return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]); - if ($mode == 4) return img_picto($langs->trans($this->statuts_short[$statut]),$this->statuts_logo[$statut]).' '.$langs->trans($this->statuts[$statut]); - if ($mode == 5) - return ''.$langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),$this->statuts_logo[$statut]); - + return ''.$langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); + if ($mode == 6) + return ''.$langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); + + return ''; } /** diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 5d88dd78977..86d9902954c 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -27,6 +27,7 @@ */ require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -134,13 +135,14 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP */ $form = new Form($db); -$interventionstatic=new Fichinter($db); +$formfile = new FormFile($db); +$objectstatic=new Fichinter($db); llxHeader('', $langs->trans("Intervention")); $sql = "SELECT"; -$sql.= " f.ref, f.rowid as fichid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update,"; +$sql.= " f.ref, f.rowid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update, f.note_private,"; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sql.= " fd.description as descriptiondetail, fd.date as dp, fd.duree,"; $sql.= " s.nom as name, s.rowid as socid, s.client"; // Add fields from extrafields @@ -213,6 +215,7 @@ if ($result) $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall) $urlparam.="&sall=".$sall; if ($socid) $param.="&socid=".$socid; if ($search_ref) $param.="&search_ref=".urlencode($search_ref); if ($search_company) $param.="&search_company=".urlencode($search_company); @@ -274,7 +277,7 @@ if ($result) print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -352,7 +355,8 @@ if ($result) if (! empty($arrayfields['f.fk_statut']['checked'])) { print ''; - $liststatus=$interventionstatic->statuts_short; + $liststatus=$objectstatic->statuts_short; + if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1); print ''; } @@ -372,16 +376,45 @@ if ($result) { $obj = $db->fetch_object($result); - $interventionstatic->id=$obj->fichid; - $interventionstatic->ref=$obj->ref; - $interventionstatic->statut=$obj->fk_statut; + $objectstatic->id=$obj->rowid; + $objectstatic->ref=$obj->ref; + $objectstatic->statut=$obj->fk_statut; $var=!$var; print ""; if (! empty($arrayfields['f.ref']['checked'])) { print ""; - print $interventionstatic->getNomUrl(1); + + print ''; + // Picto + Ref + print ''; + // Warning + $warnornote=''; + //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); + if (! empty($obj->note_private)) + { + $warnornote.=($warnornote?' ':''); + $warnornote.= ''; + $warnornote.= ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; + $warnornote.= ''; + } + if ($warnornote) + { + print ''; + } + // Other picto tool + print '
    '; + print $objectstatic->getNomUrl(1); + print ''; + print $warnornote; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->fichinter->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print '
    '; + print "\n"; if (! $i) $totalarray['nbfield']++; } @@ -460,7 +493,7 @@ if ($result) // Status if (! empty($arrayfields['f.fk_statut']['checked'])) { - print ''.$interventionstatic->LibStatut($obj->fk_statut,5).''; + print ''.$objectstatic->LibStatut($obj->fk_statut,5).''; if (! $i) $totalarray['nbfield']++; } // Action column diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index c1d3cef9fd9..e7f407acfd2 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -92,7 +92,7 @@ if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not do $path=$_SERVER["CONTEXT_PREFIX"]; // example '/dolibarr/' when using an apache alias. if (! preg_match('/\/$/', $path)) $path.='/'; } - else if (preg_match('/index\.php', $_SERVER['PHP_SELF'])) + else if (preg_match('/index\.php/', $_SERVER['PHP_SELF'])) { // When we ask index.php, we MUST BE SURE that $path is '' at the end. This is required to make install process // when using apache alias like '/dolibarr/' that point to htdocs. @@ -113,11 +113,11 @@ if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not do if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') break; if ($TDir[$i] == 'dolibarr') break; if (substr($TDir[$i], -4, 4) == '.php') continue; - + $path .= '../'; } } - + header("Location: ".$path."install/index.php"); exit; } @@ -162,9 +162,12 @@ if (empty($multicompany_force_entity)) $multicompany_force_entity=0; // To force // Security: CSRF protection // This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST']) // when we post forms (we allow GET to allow direct link to access a particular page). -if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET' && ! empty($_SERVER['HTTP_HOST']) && ! empty($_SERVER['HTTP_REFERER']) && ! preg_match('/'.preg_quote($_SERVER['HTTP_HOST'],'/').'/i', $_SERVER['HTTP_REFERER'])) +// Note about $_SERVER[HTTP_HOST/SERVER_NAME]: http://shiflett.org/blog/2006/mar/server-name-versus-http-host +if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) + && ! empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET' && ! empty($_SERVER['HTTP_HOST']) + && (empty($_SERVER['HTTP_REFERER']) || ! preg_match('/'.preg_quote($_SERVER['HTTP_HOST'],'/').'/i', $_SERVER['HTTP_REFERER']))) { - //print 'HTTP_POST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER']; + //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_POST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER']; print "Access refused by CSRF protection in main.inc.php.\n"; print "If you access your server behind a proxy using url rewriting, you might add the line \$dolibarr_nocsrfcheck=1 into your conf.php file.\n"; die; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index d8bb890c0dd..cee2b806d5c 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -120,8 +120,8 @@ if ($id > 0 && empty($object->id)) if ($object->id > 0) { - $title=$langs->trans("ThirdParty")." - ".$langs->trans('SupplierCard'); - if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('SupplierCard'); + $title=$langs->trans("ThirdParty")." - ".$langs->trans('Supplier'); + if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Supplier'); $help_url=''; llxHeader('',$title, $help_url); @@ -132,7 +132,9 @@ if ($object->id > 0) dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"),0,'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; @@ -284,7 +286,7 @@ if ($object->id > 0) print ''; print ''; print ''; + print '
    '; - print '
    '.$langs->trans("Summary").''.$langs->trans("ShowSupplierPreview").'
    '.$langs->trans("ShowSupplierPreview").'
    '; print ''; print ''; print '
    '; @@ -298,22 +300,23 @@ if ($object->id > 0) $langs->load("products"); print ''; print ''; - print ''; //Query from product/liste.php - $sql = 'SELECT p.rowid, p.ref, p.label, pfp.tms,'; - $sql.= ' p.fk_product_type, p.entity'; + $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,'; + $sql.= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product"; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= ' AND pfp.fk_soc = '.$object->id; $sql .= $db->order('pfp.tms', 'desc'); $sql.= $db->plimit($MAXLIST); - + $query = $db->query($sql); - + if (! $query) dol_print_error($db); + $return = array(); if ($db->num_rows($query)) { @@ -334,10 +337,25 @@ if ($object->id > 0) print ''; - print ''; + print ''; - print ''; + //print ''; + print ''; print ''; } } @@ -373,7 +391,7 @@ if ($object->id > 0) print ''; print ''; @@ -452,7 +470,6 @@ if ($object->id > 0) $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; $sql.= " WHERE p.fk_soc =".$object->id; $sql.= " AND p.entity =".$conf->entity; - $sql.= " ORDER BY p.date_commande DESC"; $resql=$db->query($sql); if ($resql) { @@ -478,7 +495,7 @@ if ($object->id > 0) print ''; print ''; @@ -552,7 +569,7 @@ if ($object->id > 0) print ''; print ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 8a812c34f8b..da4910a1db0 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -44,7 +44,8 @@ class CommandeFournisseur extends CommonOrder public $table_element_line = 'commande_fournisseurdet'; public $fk_element = 'fk_commande'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - + public $picto='order'; + /** * {@inheritdoc} */ @@ -127,6 +128,7 @@ class CommandeFournisseur extends CommonOrder public $multicurrency_total_tva; public $multicurrency_total_ttc; + /** * Constructor * @@ -271,6 +273,8 @@ class CommandeFournisseur extends CommonOrder $this->fetchObjectLinked(); + $this->lines=array(); + $sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description,"; $sql.= " l.qty,"; $sql.= " l.tva_tx, l.remise_percent, l.subprice,"; @@ -370,7 +374,7 @@ class CommandeFournisseur extends CommonOrder * * @param User $user Validator User * @param int $idwarehouse Id of warehouse to use for stock decrease - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ public function valid($user,$idwarehouse=0,$notrigger=0) @@ -617,7 +621,7 @@ class CommandeFournisseur extends CommonOrder * Returns the following order reference not used depending on the numbering model activated * defined within COMMANDE_SUPPLIER_ADDON_NUMBER * - * @param Societe $soc company object + * @param Company $soc company object * @return string free reference for the invoice */ public function getNextNumRef($soc) @@ -1144,7 +1148,13 @@ class CommandeFournisseur extends CommonOrder $this->lines[$i]->remise_percent, 'HT', 0, - $this->lines[$i]->info_bits + $this->lines[$i]->product_type, + $this->lines[$i]->info_bits, + false, + $this->lines[$i]->date_start, + $this->lines[$i]->date_end, + 0, + $this->lines[$i]->fk_unit ); if ($result < 0) { @@ -1294,7 +1304,7 @@ class CommandeFournisseur extends CommonOrder * @param float $txtva Taux tva * @param float $txlocaltax1 Localtax1 tax * @param float $txlocaltax2 Localtax2 tax - * @param int $fk_product Id produit + * @param int $fk_product Id product * @param int $fk_prod_fourn_price Id supplier price * @param string $fourn_ref Supplier reference * @param float $remise_percent Remise @@ -1369,7 +1379,7 @@ class CommandeFournisseur extends CommonOrder { $label = $prod->libelle; $pu = $prod->fourn_pu; - $ref = $prod->ref_fourn; + $ref_supplier = $prod->ref_supplier; $product_type = $prod->type; } if ($result == 0 || $result == -1) @@ -1432,6 +1442,8 @@ class CommandeFournisseur extends CommonOrder $this->line->fk_commande=$this->id; $this->line->label=$label; + $this->line->ref_fourn = $ref_supplier; + $this->line->ref_supplier = $ref_supplier; $this->line->desc=$desc; $this->line->qty=$qty; $this->line->tva_tx=$txtva; @@ -1458,7 +1470,6 @@ class CommandeFournisseur extends CommonOrder $this->line->date_start=$date_start; $this->line->date_end=$date_end; - // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; @@ -1623,55 +1634,34 @@ class CommandeFournisseur extends CommonOrder * * @param int $idline Id of line to delete * @param int $notrigger 1=Disable call to triggers - * @return <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function deleteline($idline, $notrigger=0) { - global $user,$langs,$conf; - $error = 0; - - if ($this->statut != 0) + if ($this->statut == 0) { - return -1; - } + $line = new CommandeFournisseurLigne($this->db); - $this->db->begin(); + if ($line->fetch($idline) <= 0) + { + return 0; + } - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('LINEORDER_SUPPLIER_DELETE',$user); - if ($result < 0) $error++; - // End call triggers - } - - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idline; - $resql=$this->db->query($sql); - - dol_syslog(get_class($this)."::deleteline sql=".$sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - $error++; - } - } - - if (! $error) - { - $result=$this->update_price(); - } - - if (! $error) - { - $this->db->commit(); - return 1; + if ($line->delete($notrigger) > 0) + { + $this->update_price(); + return 1; + } + else + { + $this->error = $line->error; + $this->errors = $line->errors; + return -1; + } } else - { - $this->db->rollback(); - return -1; + { + return -2; } } @@ -1922,7 +1912,7 @@ class CommandeFournisseur extends CommonOrder } } - // TODO LDR01 Add option to accept only if ALL predefined products are received (same qty). + // TODO LDR01 Add a control test to accept only if ALL predefined products are received (same qty). if (! $error && ! ($statut == 4 or $statut == 5 or $statut == 7)) @@ -1987,28 +1977,58 @@ class CommandeFournisseur extends CommonOrder * * @param User $user Objet user making change * @param timestamp $date_livraison Planned delivery date + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_date_livraison($user, $date_livraison) + function set_date_livraison($user, $date_livraison, $notrigger=0) { if ($user->rights->fournisseur->commande->creer) { - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; + $error=0; + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null'); $sql.= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::set_date_livraison", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->date_livraison = $date_livraison; - return 1; - } - else - { - $this->error=$this->db->error(); - return -1; - } + dol_syslog(__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if (!$resql) + { + $this->errors[]=$this->db->error(); + $error++; + } + + if (! $error) + { + $this->oldcopy= clone $this; + $this->date_livraison = $date_livraison; + } + + if (! $notrigger && empty($error)) + { + // Call trigger + $result=$this->call_trigger('ORDER_SUPPLIER_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + foreach($this->errors as $errmsg) + { + dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } } else { @@ -2021,27 +2041,57 @@ class CommandeFournisseur extends CommonOrder * * @param User $user Objet utilisateur qui modifie * @param int $id_projet Date de livraison + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - function set_id_projet($user, $id_projet) + function set_id_projet($user, $id_projet, $notrigger=0) { if ($user->rights->fournisseur->commande->creer) { + $error=0; + + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " SET fk_projet = ".($id_projet > 0 ? (int) $id_projet : 'null'); $sql.= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::set_id_projet", LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) + if (!$resql) { - $this->fk_projet = $id_projet; - return 1; + $this->errors[]=$this->db->error(); + $error++; + } + + if (! $error) + { + $this->oldcopy= clone $this; + $this->fk_projet = $id_projet; + } + + if (! $notrigger && empty($error)) + { + // Call trigger + $result=$this->call_trigger('ORDER_SUPPLIER_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + + if (! $error) + { + $this->db->commit(); + return 1; } else { - $this->error=$this->db->error(); - return -1; + foreach($this->errors as $errmsg) + { + dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; } } else @@ -2687,13 +2737,16 @@ class CommandeFournisseur extends CommonOrder return $text; } + /** * Calc status regarding dispatch stock * - * @param User $user User action - * @return int <0 si ko, >0 si ok + * @param User $user User action + * @param int $closeopenorder Close if received + * @return int <0 if KO, 0 if not applicable, >0 if OK */ - public function calcAndSetStatusDispatch(User $user) { + public function calcAndSetStatusDispatch(User $user, $closeopenorder=1) + { global $conf; if (! empty($conf->commande->enabled) && ! empty($conf->fournisseur->enabled)) @@ -2705,15 +2758,19 @@ class CommandeFournisseur extends CommonOrder $supplierorderdispatch = new CommandeFournisseurDispatch($this->db); $filter=array('t.fk_commande'=>$this->id); - if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { + if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { $filter['t.status']=1; } $ret=$supplierorderdispatch->fetchAll('','',0,0,$filter); - if ($ret<0) { + if ($ret<0) + { $this->error=$supplierorderdispatch->error; $this->errors=$supplierorderdispatch->errors; return $ret; - } else { - if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) { + } + else + { + if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) + { //Build array with quantity deliverd by product foreach($supplierorderdispatch->lines as $line) { $qtydelivered[$line->fk_product]+=$line->qty; @@ -2723,25 +2780,41 @@ class CommandeFournisseur extends CommonOrder } //Compare array $diff_array=array_diff_assoc($qtydelivered,$qtywished); - if (count($diff_array)==0) { + if (count($diff_array)==0) + { //No diff => mean everythings is received - $ret=$this->setStatus($user,5); - if ($ret<0) { - $this->error=$object->error; $this->errors=$object->errors; + if ($closeopenorder) + { + $ret=$this->setStatus($user,5); + if ($ret<0) { + return -1; + } + return 5; } - } else { + else + { + //Diff => received partially + $ret=$this->setStatus($user,4); + if ($ret<0) { + return -1; + } + return 4; + } + } + else + { //Diff => received partially $ret=$this->setStatus($user,4); if ($ret<0) { - $this->error=$object->error; $this->errors=$object->errors; + return -1; } + return 4; } } + return 1; } - - - return 1; } + return 0; } } @@ -2816,7 +2889,7 @@ class CommandeFournisseurLigne extends CommonOrderLine public function fetch($rowid) { $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx,'; - $sql.= ' cd.localtax1_tx, cd.localtax2_tx,'; + $sql.= ' cd.localtax1_tx, cd.localtax2_tx, cd.ref,'; $sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; $sql.= ' cd.total_localtax1, cd.total_localtax2,'; @@ -2834,6 +2907,8 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->fk_commande = $objp->fk_commande; $this->desc = $objp->description; $this->qty = $objp->qty; + $this->ref_fourn = $objp->ref; + $this->ref_supplier = $objp->ref; $this->subprice = $objp->subprice; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; @@ -2965,14 +3040,14 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql.= ", '".$this->localtax1_type."',"; $sql.= " '".$this->localtax2_type."'"; - $sql.= ", ".$this->remise_percent.",'".price2num($this->subprice,'MU')."','".$this->product_ref."',"; + $sql.= ", ".$this->remise_percent.",'".price2num($this->subprice,'MU')."','".$this->ref_supplier."',"; $sql.= "'".price2num($this->total_ht)."',"; $sql.= "'".price2num($this->total_tva)."',"; $sql.= "'".price2num($this->total_localtax1)."',"; $sql.= "'".price2num($this->total_localtax2)."',"; $sql.= "'".price2num($this->total_ttc)."',"; $sql.= ($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'":"null"); - $sql.= ", ".$this->fk_multicurrency; + $sql.= ", ".($this->fk_multicurrency ? $this->fk_multicurrency : "null"); $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".price2num($this->pu_ht * $this->multicurrency_tx); $sql.= ", ".$this->multicurrency_total_ht; @@ -3000,7 +3075,7 @@ class CommandeFournisseurLigne extends CommonOrderLine if (! $error && ! $notrigger) { // Call trigger - $result=$this->call_trigger('LINEORDER_INSERT',$user); + $result=$this->call_trigger('LINEORDER_SUPPLIER_CREATE',$user); if ($result < 0) $error++; // End call triggers } @@ -3113,5 +3188,55 @@ class CommandeFournisseurLigne extends CommonOrderLine return -1; } } + + /** + * Delete line in database + * + * @param int $notrigger 1=Disable call to triggers + * @return int <0 if KO, >0 if OK + */ + function delete($notrigger) + { + global $user; + + $error=0; + + $this->db->begin(); + + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid='".$this->rowid."';"; + + dol_syslog(__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + + if (!$notrigger) + { + // Call trigger + $result=$this->call_trigger('LINEORDER_SUPPLIER_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } + + if (!$error) + { + $this->db->commit(); + return 1; + } + + 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->error=$this->db->lasterror(); + return -1; + } + } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index aab90ce4b49..865cc4336f0 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -6,10 +6,11 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2013 Philippe Grand - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2014-2016 Marcos García - * Copyright (C) 2015 Bahfir Abbes - * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2014-2016 Marcos García + * Copyright (C) 2015 Bahfir Abbes + * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 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 @@ -44,7 +45,8 @@ class FactureFournisseur extends CommonInvoice public $table_element_line='facture_fourn_det'; public $fk_element='fk_facture_fourn'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - + public $picto='bill'; + /** * {@inheritdoc} */ @@ -126,7 +128,55 @@ class FactureFournisseur extends CommonInvoice public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; - + + /** + * Standard invoice + */ + const TYPE_STANDARD = 0; + + /** + * Replacement invoice + */ + const TYPE_REPLACEMENT = 1; + + /** + * Credit note invoice + */ + const TYPE_CREDIT_NOTE = 2; + + /** + * Deposit invoice + */ + const TYPE_DEPOSIT = 3; + + /** + * Draft + */ + const STATUS_DRAFT = 0; + + /** + * Validated (need to be paid) + */ + const STATUS_VALIDATED = 1; + + /** + * Classified paid. + * If paid partially, $this->close_code can be: + * - CLOSECODE_DISCOUNTVAT + * - CLOSECODE_BADDEBT + * If paid completelly, this->close_code will be null + */ + const STATUS_CLOSED = 2; + + /** + * Classified abandoned and no payment done. + * $this->close_code can be: + * - CLOSECODE_BADDEBT + * - CLOSECODE_ABANDONED + * - CLOSECODE_REPLACED + */ + const STATUS_ABANDONED = 3; + /** * Constructor * @@ -164,6 +214,7 @@ class FactureFournisseur extends CommonInvoice // Clean parameters if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); + if (empty($this->type)) $this->type = self::TYPE_STANDARD; if (empty($this->date)) $this->date=$now; $socid = $this->socid; @@ -190,6 +241,7 @@ class FactureFournisseur extends CommonInvoice $sql.= "ref"; $sql.= ", ref_supplier"; $sql.= ", entity"; + $sql.= ", type"; $sql.= ", libelle"; $sql.= ", fk_soc"; $sql.= ", datec"; @@ -211,6 +263,7 @@ class FactureFournisseur extends CommonInvoice $sql.= "'(PROV)'"; $sql.= ", '".$this->db->escape($this->ref_supplier)."'"; $sql.= ", ".$conf->entity; + $sql.= ", '".$this->db->escape($this->type)."'"; $sql.= ", '".$this->db->escape($this->libelle)."'"; $sql.= ", ".$this->socid; $sql.= ", '".$this->db->idate($now)."'"; @@ -378,7 +431,7 @@ class FactureFournisseur extends CommonInvoice $sql.= " t.tva,"; $sql.= " t.localtax1,"; $sql.= " t.localtax2,"; - $sql.= " t.total,"; + //$sql.= " t.total,"; $sql.= " t.total_ht,"; $sql.= " t.total_tva,"; $sql.= " t.total_ttc,"; @@ -439,7 +492,7 @@ class FactureFournisseur extends CommonInvoice $this->tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; - $this->total = $obj->total; + //$this->total = $obj->total; $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_ttc = $obj->total_ttc; @@ -619,6 +672,7 @@ class FactureFournisseur extends CommonInvoice $error=0; // Clean parameters + if (empty($this->type)) $this->type= self::TYPE_STANDARD; if (isset($this->ref)) $this->ref=trim($this->ref); if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); if (isset($this->entity)) $this->entity=trim($this->entity); @@ -856,10 +910,12 @@ class FactureFournisseur extends CommonInvoice /** * Tag invoice as a payed invoice * - * @param User $user Object user - * @return int <0 si ko, >0 si ok + * @param User $user Object user + * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet. Not implementd yet. + * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet. Not implementd yet. + * @return int <0 si ko, >0 si ok */ - function set_paid($user) + function set_paid($user, $close_code='', $close_note='') { global $conf,$langs; $error=0; @@ -952,7 +1008,7 @@ class FactureFournisseur extends CommonInvoice * @param User $user Object user that validate * @param string $force_number Reference to force on invoice * @param int $idwarehouse Id of warehouse for stock change - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, =0 if nothing to do, >0 if OK */ public function validate($user, $force_number='', $idwarehouse=0, $notrigger=0) @@ -1524,6 +1580,101 @@ class FactureFournisseur extends CommonInvoice } } + /** + * Renvoi liste des factures remplacables + * Statut validee ou abandonnee pour raison autre + non payee + aucun paiement + pas deja remplacee + * + * @param int $socid Id societe + * @return array Tableau des factures ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) + */ + function list_replacable_supplier_invoices($socid=0) + { + global $conf; + + $return = array(); + + $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut,"; + $sql.= " ff.rowid as rowidnext"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON f.rowid = ff.fk_facture_source"; + $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; + $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.paye = 0"; // Pas classee payee completement + $sql.= " AND pf.fk_paiementfourn IS NULL"; // Aucun paiement deja fait + $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement + if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; + $sql.= " ORDER BY f.ref"; + + dol_syslog(get_class($this)."::list_replacable_supplier_invoices", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $return[$obj->rowid]=array( 'id' => $obj->rowid, + 'ref' => $obj->ref, + 'status' => $obj->fk_statut); + } + //print_r($return); + return $return; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + + /** + * Renvoi liste des factures qualifiables pour correction par avoir + * Les factures qui respectent les regles suivantes sont retournees: + * (validee + paiement en cours) ou classee (payee completement ou payee partiellement) + pas deja remplacee + pas deja avoir + * + * @param int $socid Id societe + * @return array Tableau des factures ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) + */ + function list_qualified_avoir_supplier_invoices($socid=0) + { + global $conf; + + $return = array(); + + $sql = "SELECT f.rowid as rowid, f.ref, f.fk_statut, f.type, f.paye, pf.fk_paiementfourn"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf ON f.rowid = pf.fk_facturefourn"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; + $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; + $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement + $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir + if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; + $sql.= " ORDER BY f.ref"; + + dol_syslog(get_class($this)."::list_qualified_avoir_supplier_invoices", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $qualified=0; + if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; + if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; + if ($qualified) + { + $paymentornot=($obj->fk_paiementfourn?1:0); + $return[$obj->rowid]=array('ref'=>$obj->ref,'status'=>$obj->fk_statut,'type'=>$obj->type,'paye'=>$obj->paye,'paymentornot'=>$paymentornot); + } + } + + return $return; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) @@ -1585,15 +1736,28 @@ class FactureFournisseur extends CommonInvoice * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option Sur quoi pointe le lien - * @param int $max Max length of shown ref - * @return string Chaine avec URL + * @param string $option Where point the link + * @param int $max Max length of shown ref + * @param int $short 1=Return just URL + * @param string $moretitle Add more text to title tooltip + * @return string String with URL */ - public function getNomUrl($withpicto=0,$option='',$max=0) + public function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='') { global $langs, $conf; $result=''; + + if ($option == 'document') $url = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$this->id; + else $url = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$this->id; + + if ($short) return $url; + + $picto='bill'; + if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice + if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note + if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice + $label = '' . $langs->trans("ShowSupplierInvoice") . ''; if (! empty($this->ref)) $label .= '
    ' . $langs->trans('Ref') . ': ' . $this->ref; @@ -1605,23 +1769,19 @@ class FactureFournisseur extends CommonInvoice $label.= '
    ' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_ttc)) $label.= '
    ' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - - if ($option == 'document') - { - $link = ''; - $linkend=''; - } - else - { - $link = ''; - $linkend=''; - } + if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; + if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; + if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; + if ($moretitle) $label.=' - '.$moretitle; $ref=$this->ref; if (empty($ref)) $ref=$this->id; - if ($withpicto) $result.=($link.img_object($label, 'bill', 'class="classfortooltip"').$linkend.' '); - $result.=$link.($max?dol_trunc($ref,$max):$ref).$linkend; + $linkstart=''; + $linkend=''; + + if ($withpicto) $result.=($linkstart.img_object($label, $picto, 'class="classfortooltip"').$linkend.' '); + $result.=$linkstart.($max?dol_trunc($ref,$max):$ref).$linkend; return $result; } @@ -1905,7 +2065,7 @@ class FactureFournisseur extends CommonInvoice * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @return int 0 if KO, 1 if OK + * @return int <0 if KO, 0 if nothing done, >0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { @@ -1914,7 +2074,7 @@ class FactureFournisseur extends CommonInvoice $langs->load("suppliers"); // Set the model on the model name to use - if (! dol_strlen($modele)) + if (empty($modele)) { if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) { @@ -1922,13 +2082,20 @@ class FactureFournisseur extends CommonInvoice } else { - $modele = 'canelle'; + $modele = ''; // No default value. For supplier invoice, we allow to disable all PDF generation } } + + if (empty($modele)) + { + return 0; + } + else + { + $modelpath = "core/modules/supplier_invoice/pdf/"; - $modelpath = "core/modules/supplier_invoice/pdf/"; - - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + } } /** diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 78bdab0f6c5..738c0eb716f 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -130,7 +130,7 @@ class PaiementFourn extends Paiement * @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more * @return int id of created payment, < 0 if error */ - function create($user,$closepaidinvoices=0) + function create($user, $closepaidinvoices=0) { global $langs,$conf; @@ -141,6 +141,8 @@ class PaiementFourn extends Paiement $totalamount = 0; $totalamount_converted = 0; + dol_syslog(get_class($this)."::create", LOG_DEBUG); + if ($way == 'dolibarr') { $amounts = &$this->amounts; @@ -188,7 +190,6 @@ class PaiementFourn extends Paiement $sql.= " VALUES ('".$this->db->escape($ref)."', ".$conf->entity.", '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.", 0)"; - dol_syslog("PaiementFourn::create", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -220,7 +221,7 @@ class PaiementFourn extends Paiement $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); if ($remaintopay == 0) { - $result=$invoice->set_paid($user,'',''); + $result=$invoice->set_paid($user, '', ''); } else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing."); } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index b323f58e0b8..41df1e4f311 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -140,9 +140,8 @@ if (empty($reshook)) if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { - $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); + $result=$object->setValueFrom('ref_supplier', GETPOST('ref_supplier','alpha'), '', null, 'text', '', $user, 'ORDER_SUPPLIER_MODIFY'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); - else $object->ref_supplier = GETPOST('ref_supplier','alpha'); // The setValueFrom does not set new property of object } // Set incoterm @@ -165,7 +164,7 @@ if (empty($reshook)) $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - + // Multicurrency Code else if ($action == 'setmulticurrencycode' && $user->rights->fournisseur->commande->creer) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); @@ -173,7 +172,7 @@ if (empty($reshook)) // Multicurrency rate else if ($action == 'setmulticurrencyrate' && $user->rights->fournisseur->commande->creer) { - $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int')); + $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); } // bank account @@ -218,13 +217,13 @@ if (empty($reshook)) //$newstatus=3; // Submited // TODO If there is at least one reception, we can set to Received->Received partially $newstatus=4; // Received partially - + } else if ($object->statut == 6) $newstatus=2; // Canceled->Approved else if ($object->statut == 7) $newstatus=3; // Canceled->Process running else if ($object->statut == 9) $newstatus=1; // Refused->Validated else $newstatus = 2; - + //print "old status = ".$object->statut.' new status = '.$newstatus; $db->begin(); @@ -237,7 +236,7 @@ if (empty($reshook)) $sql.= ' WHERE rowid = '.$object->id; $resql=$db->query($sql); - + if ($newstatus == 0) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; @@ -272,11 +271,11 @@ if (empty($reshook)) } } - /* - * Add a line into product - */ + // Add a product line if ($action == 'addline' && $user->rights->fournisseur->commande->creer) { + $db->begin(); + $langs->load('errors'); $error = 0; @@ -351,7 +350,7 @@ if (empty($reshook)) $idprod=0; if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) } - + if (GETPOST('idprodfournprice') > 0) { $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat. @@ -367,7 +366,7 @@ if (empty($reshook)) if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); $type = $productsupplier->type; - + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); if (empty($tva_tx)) $tva_npr=0; @@ -411,7 +410,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } } - else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) + else if ((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -426,8 +425,8 @@ if (empty($reshook)) $tva_tx = price2num($tva_tx); // When vat is text input field // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty); + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); if (GETPOST('price_ht')!=='') { @@ -448,6 +447,8 @@ if (empty($reshook)) //print "xx".$tva_tx; exit; if (! $error && $result > 0) { + $db->commit(); + $ret=$object->fetch($object->id); // Reload to get new records // Define output language @@ -501,8 +502,11 @@ if (empty($reshook)) } else { + $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } + + $action = ''; } /* @@ -763,7 +767,7 @@ if (empty($reshook)) $result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']); if ($result > 0) { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; @@ -831,7 +835,7 @@ if (empty($reshook)) { $date_liv = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear")); - $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); + $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can' if ($result > 0) { $langs->load("deliveries"); @@ -870,10 +874,10 @@ if (empty($reshook)) if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) // En get ou en post { // Build document - + // Save last template used to generate document if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - + $outputlangs = $langs; if (GETPOST('lang_id')) { @@ -899,7 +903,7 @@ if (empty($reshook)) if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } - + if ($action == 'update_extras') { // Fill array 'array_options' with data from add form @@ -972,7 +976,7 @@ if (empty($reshook)) $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->fk_project = GETPOST('projectid'); - + // Fill array 'array_options' with data from add form if (! $error) { @@ -994,7 +998,7 @@ if (empty($reshook)) $element = 'supplier_proposal'; $subelement = 'supplier_proposal'; } - + $object->origin = $origin; $object->origin_id = $originid; @@ -1031,7 +1035,7 @@ if (empty($reshook)) $num = count($lines); $productsupplier = new ProductFournisseur($db); - + for($i = 0; $i < $num; $i ++) { @@ -1041,12 +1045,12 @@ if (empty($reshook)) $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); - + // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { $fk_parent_line = 0; } - + // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if // trigger used @@ -1056,17 +1060,17 @@ if (empty($reshook)) } $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty); - if ($result>=0) + if ($result>=0) { $tva_tx = $lines[$i]->tva_tx; - + if ($origin=="commande") { $soc=new societe($db); $soc->fetch($socid); $tva_tx=get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $productsupplier->product_fourn_price_id); } - + $result = $object->addline( $desc, $lines[$i]->subprice, @@ -1089,7 +1093,7 @@ if (empty($reshook)) $lines[$i]->fk_unit ); } - + if ($result < 0) { $error++; break; @@ -1102,8 +1106,8 @@ if (empty($reshook)) } // Add link between elements - - + + // Hooks $parameters = array('objFrom' => $srcobject); $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been @@ -1149,14 +1153,14 @@ if (empty($reshook)) /* * Send mail */ - + // Actions to send emails $actiontypecode='AC_SUP_ORD'; $trigger_name='ORDER_SUPPLIER_SENTBYMAIL'; $paramname='id'; $mode='emailfromsupplierorder'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - + if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && ! GETPOST('cancel')) { @@ -1307,14 +1311,15 @@ if (empty($reshook)) /* * View */ -$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; -llxHeader('',$langs->trans("Order"),$help_url); $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $productstatic = new Product($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; +llxHeader('',$langs->trans("Order"),$help_url); /* *************************************************************************** */ /* */ @@ -1380,9 +1385,9 @@ if ($action=='create') if (!empty($conf->multicurrency->enabled)) { if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } - + $note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null)); $note_public = $object->getDefaultCreateValueFor('note_public', (! empty($objectsrc->note_public) ? $objectsrc->note_public : null)); @@ -1394,9 +1399,9 @@ if ($action=='create') { $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; - + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; - + $note_private = $object->getDefaultCreateValueFor('note_private'); $note_public = $object->getDefaultCreateValueFor('note_public'); } @@ -1409,7 +1414,7 @@ if ($action=='create') print ''; print ''; if (!empty($currency_tx)) print ''; - + dol_fiche_head(''); print '
    '.$langs->trans("ProductsAndServices").''; - print ''.$langs->trans("All").' '.$object->nbOfProductRefs().''; + print ''.$langs->trans("ProductsAndServices").''; + print ''.$langs->trans("All").' '.$object->nbOfProductRefs().''; print '
    '; print $productstatic->getNomUrl(1); print ''; + print ''; + print $objp->supplier_ref; + print ''; print dol_trunc(dol_htmlentities($objp->label), 30); print ''.dol_print_date($objp->tms).''.dol_print_date($objp->tms, 'day').''; + //print (isset($objp->unitprice) ? price($objp->unitprice) : ''); + if (isset($objp->price)) + { + print price($objp->price); + if ($objp->quantity > 1) + { + print ' / '; + print $objp->quantity; + } + } + print '
    '; print ''; - print ''; + print ''; print ''; print '
    '.$langs->trans("LastSupplierProposals",($num<$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPriceRequests").' '.$num.''.$langs->trans("AllPriceRequests").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
    '; print '
    '; print ''; - print ''; + print ''; print ''; print '
    '.$langs->trans("LastSupplierOrders",($num<$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''.$langs->trans("AllOrders").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
    '; print '
    '; - print ''; + print '
    '.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans('AllBills').' '.$num.'
    '; print ''; print '
    '.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans('AllBills').' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
    '; print '
    '; @@ -1497,7 +1502,7 @@ if ($action=='create') print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print ''; } - + print ''; print '"; - + if (!empty($conf->multicurrency->enabled)) { print ''; print ''; - print ''; + print ''; } } @@ -1571,7 +1576,7 @@ if ($action=='create') print "\n"; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); @@ -1631,7 +1636,7 @@ elseif (! empty($object->id)) $object->date_commande=dol_now(); // We check if number is temporary number - if (preg_match('/^[\(]?PROV/i',$object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life + if (preg_match('/^[\(]?PROV/i',$object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life { $newref = $object->getNextNumRef($object->thirdparty); } @@ -1742,50 +1747,96 @@ elseif (! empty($object->id)) // Print form confirm print $formconfirm; - /* - * Commande - */ - $nbrow=8; - if (! empty($conf->projet->enabled)) $nbrow++; - - //Local taxes - if($mysoc->localtax1_assuj=="1") $nbrow++; - if($mysoc->localtax2_assuj=="1") $nbrow++; - - print '
    '.$langs->trans('NotePublic').''; $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); @@ -1539,12 +1544,12 @@ if ($action=='create') } print '
    ' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
    ' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . '
    ' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . '
    ' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . '
    ' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . '
    '; + + // Supplier order card $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref='
    '; + // Ref supplier + $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
    '.$langs->trans('Project') . ' '; + if ($user->rights->fournisseur->commande->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
    '; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; // Ref + /* print ''; print ''; - print ''; + print '';*/ // Ref supplier + /* print ''; - + // Fournisseur print '"; print ''; print ''; - + */ + // Statut + /* print ''; print ''; print '"; + */ // Date if ($object->methode_commande_id > 0) { - print ''; + print ''; } } // Author - print ''; - print ''; + print ''; + print ''; print ''; // Conditions de reglement par defaut @@ -1811,7 +1862,7 @@ elseif (! empty($object->id)) print ''; print '
    '.$langs->trans("Ref").''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); print '
    '; print $form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,$user->rights->fournisseur->commande->creer); print ''; print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,$user->rights->fournisseur->commande->creer); print '
    '.$langs->trans("Supplier")."'.$object->thirdparty->getNomUrl(1,'supplier').'
    '.$langs->trans("Status").''; print $object->getLibStatut(4); print "
    '.$langs->trans("Date").''; + print '
    '.$langs->trans("Date").''; if ($object->date_commande) { print dol_print_date($object->date_commande,"dayhourtext")."\n"; @@ -1794,13 +1845,13 @@ elseif (! empty($object->id)) if ($object->methode_commande) { - print '
    '.$langs->trans("Method").''.$object->getInputMethod().'
    '.$langs->trans("Method").''.$object->getInputMethod().'
    '.$langs->trans("AuthorRequest").''.$author->getNomUrl(1).'
    '.$langs->trans("AuthorRequest").''.$author->getNomUrl(1).'
    '; if ($action != 'editconditions') print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
    '; - print ''; + print ''; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'cond_reglement_id'); @@ -1831,7 +1882,7 @@ elseif (! empty($object->id)) print ''; if ($action != 'editmode') print 'id.'">'.img_edit($langs->trans('SetMode'),1).''; print ''; - print ''; + print ''; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); @@ -1841,37 +1892,37 @@ elseif (! empty($object->id)) $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); } print ''; - + // Multicurrency if (! empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; - print ''; + print ''; print ''; if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) print ''; print '
    '; print fieldLabel('Currency','multicurrency_code'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
    '; - print ''; + print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); } else { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); } print ''; - + // Multicurrency rate print ''; - print ''; + print ''; print ''; if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) print ''; print '
    '; print fieldLabel('CurrencyRate','multicurrency_tx'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
    '; - print ''; + print ''; if ($action == 'editmulticurrencyrate') { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { @@ -1890,7 +1941,7 @@ elseif (! empty($object->id)) if ($action != 'editbankaccount' && $user->rights->fournisseur->commande->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).''; print ''; - print ''; + print ''; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { @@ -1907,7 +1958,7 @@ elseif (! empty($object->id)) print ''; if ($action != 'editdate_livraison') print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).''; print ''; - print ''; + print ''; if ($action == 'editdate_livraison') { print '
    '; @@ -1930,7 +1981,6 @@ elseif (! empty($object->id)) } print ''; - // Delivery delay (in days) print ''; print ''.$langs->trans('NbDaysToDelivery').' '.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').''; @@ -1938,6 +1988,7 @@ elseif (! empty($object->id)) print ''; // Project + /* if (! empty($conf->projet->enabled)) { $langs->load('projects'); @@ -1947,7 +1998,7 @@ elseif (! empty($object->id)) print ''; if ($action != 'classify') print ''.img_edit($langs->trans('SetProject')).''; print ''; - print ''; + print ''; //print "$object->id, $object->socid, $object->fk_project"; if ($action == 'classify') { @@ -1959,7 +2010,7 @@ elseif (! empty($object->id)) } print ''; print ''; - } + }*/ // Incoterms if (!empty($conf->incoterm->enabled)) @@ -1972,7 +2023,7 @@ elseif (! empty($object->id)) else print ' '; print ''; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); @@ -1985,56 +2036,77 @@ elseif (! empty($object->id)) } // Other attributes - $cols = 3; + $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + print ''; + + print '
    '; + print '
    '; + print '
    '; + print '
    '; + + print ''; + // Total - print ''; - print ''; + print ''; + print ''; print ''; // Total VAT - print ''; + print ''; print ''; // Amount Local Taxes if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1 { print ''; - print ''; + print ''; print ''; } if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2 { print ''; - print ''; + print ''; print ''; } // Total TTC - print ''; + print ''; print ''; if (!empty($conf->multicurrency->enabled)) { // Multicurrency Amount HT - print ''; - print ''; + print ''; + print ''; print ''; - + // Multicurrency Amount VAT - print ''; - print ''; + print ''; + print ''; print ''; - + // Multicurrency Amount TTC - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } - print "
    '.$langs->trans("AmountHT").''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'
    '.$langs->trans("AmountHT").''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'
    '.$langs->trans("AmountVAT").''.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'
    '.$langs->trans("AmountVAT").''.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'
    '.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1,'',$langs,1,-1,-1,$conf->currency).''.price($object->total_localtax1,'',$langs,1,-1,-1,$conf->currency).'
    '.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2,'',$langs,1,-1,-1,$conf->currency).''.price($object->total_localtax2,'',$langs,1,-1,-1,$conf->currency).'
    '.$langs->trans("AmountTTC").''.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'
    '.$langs->trans("AmountTTC").''.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'
    ' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '

    "; - + print ''; + + // Margin Infos + /*if (! empty($conf->margin->enabled)) { + $formmargin->displayMarginInfos($object); + }*/ + + + print '
    '; + print '
    '; + print '
    '; + + print '

    '; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; @@ -2080,184 +2152,6 @@ elseif (! empty($object->id)) $num = count($object->lines); -/* - $i = 0; $total = 0; - if ($num) - { - print ''; - print ''.$langs->trans('Label').''; - print ''.$langs->trans('VAT').''; - print ''.$langs->trans('PriceUHT').''; - print ''.$langs->trans('Qty').''; - print ''.$langs->trans('ReductionShort').''; - print ''.$langs->trans('TotalHTShort').''; - print ' '; - print "\n"; - } - $var=true; - while ($i < $num) - { - $line = $object->lines[$i]; - $var=!$var; - - // Show product and description - $type=(! empty($line->product_type)?$line->product_type:(! empty($line->fk_product_type)?$line->fk_product_type:0)); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - $date_start=''; - $date_end=''; - if (! empty($line->date_start)) - { - $date_start=$line->date_start; - $type=1; - } - if (! empty($line->date_end)) - { - $date_end=$line->date_end; - $type=1; - } - - // Edit line - if ($action != 'editline' || $_GET['rowid'] != $line->id) - { - print ''; - - // Show product and description - print ''; - if ($line->fk_product > 0) - { - print ''; // ancre pour retourner sur la ligne - - $product_static=new ProductFournisseur($db); - $product_static->fetch($line->fk_product); - $text=$product_static->getNomUrl(1,'supplier'); - $text.= ' - '.$product_static->libelle; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($date_start,$date_end); - - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) print ($line->description && $line->description!=$product_static->libelle)?'
    '.dol_htmlentitiesbr($line->description):''; - } - - // Description - Editor wysiwyg - if (! $line->fk_product) - { - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($line->description); - - // Show range - print_date_range($date_start,$date_end); - } - - print ''; - - print ''.vatrate($line->tva_tx).'%'; - - print ''.price($line->subprice)."\n"; - - print ''.$line->qty.''; - - if ($line->remise_percent > 0) - { - print ''.dol_print_reduction($line->remise_percent,$langs)."\n"; - } - else - { - print ' '; - } - - print ''.price($line->total_ht).''; - - if (is_object($hookmanager)) - { - $parameters=array('line'=>$line,'num'=>$num,'i'=>$i); - $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action); - } - - if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) - { - print 'id.'#'.$line->id.'">'; - print img_edit(); - print ''; - - $actiondelete='delete_product_line'; - print ''; - print img_delete(); - print ''; - } - else - { - print '  '; - } - print ""; - } - - // Edit line - if ($action == 'editline' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id)) - { - print "\n"; - print ''; - print ''; - - print ''; - - print ''; // ancre pour retourner sur la ligne - if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $line->fk_product > 0) - { - $product_static=new ProductFournisseur($db); - $product_static->fetch($line->fk_product); - $text=$product_static->getNomUrl(1,'supplier'); - $text.= ' - '.$product_static->libelle; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($date_start,$date_end); - print '
    '; - } - else - { - $forceall=1; // For suppliers, we always show all types - print $form->select_type_of_lines($line->product_type,'type',1,0,$forceall); - if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) - || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '
    '; - } - - if (is_object($hookmanager)) - { - $parameters=array('fk_parent_line'=>$line->fk_parent_line, 'line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i); - $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action); - } - - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); - $doleditor->Create(); - - print '
    '; - print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $form->select_date($date_start,'date_start'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'',1,0,1); - print ' '.$langs->trans('to').' '; - print $form->select_date($date_end,'date_end'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'',1,0,1); - - print ''; - print ''; - print $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc); - print ''; - print ''; - print ''; - print '%'; - print ''; - print '
    '; - print '' . "\n"; - } - $i++; - } -*/ // Form to add new line if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) { @@ -2339,7 +2233,7 @@ elseif (! empty($object->id)) { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'sor'.$object->id); - } + } $formmail->withfrom=1; $liste=array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; @@ -2615,7 +2509,7 @@ elseif (! empty($object->id)) /** * Boutons actions */ - + if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete') { print '
    '; @@ -2625,7 +2519,7 @@ elseif (! empty($object->id)) // modified by hook if (empty($reshook)) { - + // Validate if ($object->statut == 0 && $num > 0) { @@ -2771,7 +2665,7 @@ elseif (! empty($object->id)) { print ''.$langs->trans("CreateBill").''; } - + if ($user->rights->fournisseur->commande->creer && $object->statut >= 2 && !empty($object->linkedObjectsIds['invoice_supplier'])) { print ''.$langs->trans("ClassifyBilled").''; @@ -2808,7 +2702,7 @@ elseif (! empty($object->id)) } } - + print "
    "; } @@ -2831,12 +2725,10 @@ elseif (! empty($object->id)) print $formfile->showdocuments('commande_fournisseur',$comfournref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,0,0,'','','',$object->thirdparty->default_lang); $somethingshown=$formfile->numoffiles; - // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('order_supplier')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - print '
    '; @@ -2887,7 +2779,7 @@ elseif (! empty($object->id)) print "".$langs->trans("Delivery")."\n"; $liv = array(); $liv[''] = ' '; - $liv['tot'] = $langs->trans("TotalWoman"); + $liv['tot'] = $langs->trans("CompleteOrNoMoreReceptionExpected"); $liv['par'] = $langs->trans("PartialWoman"); $liv['nev'] = $langs->trans("NeverReceived"); $liv['can'] = $langs->trans("Canceled"); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 472c44d1031..5d3e0ebc47f 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -77,6 +77,8 @@ if ($id > 0 || ! empty($ref)) { setEventMessages($commande->error, $commande->errors, 'errors'); } } + + /* * Actions */ @@ -147,9 +149,11 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $db->begin(); $pos = 0; - foreach ( $_POST as $key => $value ) { + foreach ($_POST as $key => $value) + { // without batch module enabled - if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { + if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) + { $pos ++; // $numline=$reg[2] + 1; // line of product @@ -179,7 +183,8 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) } } // with batch module enabled - if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) { + if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) + { $pos ++; // eat-by date dispatch @@ -224,7 +229,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) } if (! $error) { - $result = $commande->calcAndSetStatusDispatch($user); + $result = $commande->calcAndSetStatusDispatch($user, GETPOST('closeopenorder')?1:0); if ($result < 0) { setEventMessages($commande->error, $commande->errors, 'errors'); $error ++; @@ -543,15 +548,21 @@ if ($id > 0 || ! empty($ref)) { print "\n"; print "
    \n"; - if ($nbproduct) { - print $langs->trans("Comment") . ' : '; + if ($nbproduct) + { + $checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv($commande->statuts[5])); + + print '
    '; + print $langs->trans("Comment") . ' : '; print 'trans("DispatchSupplierOrder", $commande->ref); // print ' / '.$commande->ref_supplier; // Not yet available - print '" class="flat">   '; + print '" class="flat">
    '; + print ' '.$checkboxlabel; + // print '
    '; - print ''; diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index a797bc19fdc..fe702b5838b 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -19,9 +19,9 @@ */ /** - * \file htdocs/fourn/commande/index.php - * \ingroup commande fournisseur - * \brief Home page of supplier's orders area + * \file htdocs/fourn/commande/index.php + * \ingroup commande fournisseur + * \brief Home page of supplier's orders area */ require '../../main.inc.php'; @@ -50,8 +50,7 @@ $formfile = new FormFile($db); print load_fiche_titre($langs->trans("SuppliersOrdersArea")); -print ''; -print '
    '; +print '
    '; /* @@ -84,72 +83,72 @@ $sql.= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $var=True; + $var=True; - $total=0; - $totalinprocess=0; - $dataseries=array(); - $vals=array(); - // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially - // -> 7=Canceled/Never received -> (reopen) 3=Process runing - // -> 6=Canceled -> (reopen) 2=Approved - while ($i < $num) - { - $row = $db->fetch_row($resql); - if ($row) - { - if ($row[1]!=7 && $row[1]!=6 && $row[1]!=5) - { - $vals[$row[1]]=$row[0]; - $totalinprocess+=$row[0]; - } - $total+=$row[0]; - } - $i++; - } - $db->free($resql); + $total=0; + $totalinprocess=0; + $dataseries=array(); + $vals=array(); + // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially + // -> 7=Canceled/Never received -> (reopen) 3=Process runing + // -> 6=Canceled -> (reopen) 2=Approved + while ($i < $num) + { + $row = $db->fetch_row($resql); + if ($row) + { + if ($row[1]!=7 && $row[1]!=6 && $row[1]!=5) + { + $vals[$row[1]]=$row[0]; + $totalinprocess+=$row[0]; + } + $total+=$row[0]; + } + $i++; + } + $db->free($resql); - print ''; - print ''; - print "\n"; - foreach (array(0,1,2,3,4,5,6) as $statut) - { - $dataseries[]=array('label'=>$commandestatic->LibStatut($statut,1),'data'=>(isset($vals[$statut])?(int) $vals[$statut]:0)); - if (! $conf->use_javascript_ajax) - { - $var=!$var; - print ""; - print ''; - print ''; - print "\n"; - } - } - if ($conf->use_javascript_ajax) - { - print ''; - } - //if ($totalinprocess != $total) - //print ''; - print ''; + print '
    '.$langs->trans("Statistics").' - '.$langs->trans("SuppliersOrders").'
    '.$commandestatic->LibStatut($statut,0).''.(isset($vals[$statut])?$vals[$statut]:0).'
    '; - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1,'',0); - print '
    '.$langs->trans("Total").' ('.$langs->trans("SuppliersOrdersRunning").')'.$totalinprocess.'
    '.$langs->trans("Total").''.$total.'
    '; + print ''; + print "\n"; + foreach (array(0,1,2,3,4,5,6) as $statut) + { + $dataseries[]=array('label'=>$commandestatic->LibStatut($statut,1),'data'=>(isset($vals[$statut])?(int) $vals[$statut]:0)); + if (! $conf->use_javascript_ajax) + { + $var=!$var; + print ""; + print ''; + print ''; + print "\n"; + } + } + if ($conf->use_javascript_ajax) + { + print ''; + } + //if ($totalinprocess != $total) + //print ''; + print ''; - print "
    '.$langs->trans("Statistics").' - '.$langs->trans("SuppliersOrders").'
    '.$commandestatic->LibStatut($statut,0).''.(isset($vals[$statut])?$vals[$statut]:0).'
    '; + $data=array('series'=>$dataseries); + dol_print_graph('stats',300,180,$data,1,'pie',1,'',0); + print '
    '.$langs->trans("Total").' ('.$langs->trans("SuppliersOrdersRunning").')'.$totalinprocess.'
    '.$langs->trans("Total").''.$total.'

    "; + print "

    "; } else { - dol_print_error($db); + dol_print_error($db); } /* * Legends / Status * - * Motivo: Mostrar todos os Status e dar a possibilidade de filtrar apenas um deles - * Reason: Show all Status and give the possibility to filter only one + * Motivo: Mostrar todos os Status e dar a possibilidade de filtrar apenas um deles + * Reason: Show all Status and give the possibility to filter only one */ $sql = "SELECT count(cf.rowid), fk_statut"; @@ -165,34 +164,34 @@ $sql.= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - print ''; + print '
    '; - print ''; - print ''; - print "\n"; - $var=True; + print ''; + print ''; + print "\n"; + $var=True; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $var=!$var; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $var=!$var; - print ""; - print ''; - print ''; + print ""; + print ''; + print ''; - print "\n"; - $i++; - } - print "
    '.$langs->trans("Status").''.$langs->trans("Nb").'
    '.$langs->trans("Status").''.$langs->trans("Nb").'
    '.$langs->trans($commandestatic->statuts[$row[1]]).''.$row[0].' '.$commandestatic->LibStatut($row[1],3).'
    '.$langs->trans($commandestatic->statuts[$row[1]]).''.$row[0].' '.$commandestatic->LibStatut($row[1],3).'

    "; - $db->free($resql); + print "\n"; + $i++; + } + print "
    "; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } @@ -202,41 +201,41 @@ else if (! empty($conf->fournisseur->enabled)) { - $sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " AND c.fk_statut = 0"; - if (! empty($socid)) $sql.= " AND c.fk_soc = ".$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 0"; + if (! empty($socid)) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $resql=$db->query($sql); - if ($resql) - { - print ''; - print ''; - print ''; - $langs->load("orders"); - $num = $db->num_rows($resql); - if ($num) - { - $i = 0; - $var = True; - while ($i < $num) - { - $var=!$var; - $obj = $db->fetch_object($resql); - print ""; - print '"; - print ''; - $i++; - } - } - print "
    '.$langs->trans("DraftOrders").'
    '; - print "rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).'

    "; - } + $resql=$db->query($sql); + if ($resql) + { + print ''; + print ''; + print ''; + $langs->load("orders"); + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + print '"; + print ''; + $i++; + } + } + print "
    '.$langs->trans("DraftOrders").'
    '; + print "rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).'

    "; + } } @@ -258,40 +257,40 @@ $sql.= " AND subperms = 'approuver'"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - print ''; - print ''; - print "\n"; - $var=True; + print '
    '.$langs->trans("UserWithApproveOrderGrant").'
    '; + print ''; + print "\n"; + $var=True; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $var=!$var; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $var=!$var; - print ""; - print ''; - print "\n"; - $i++; - } - print "
    '.$langs->trans("UserWithApproveOrderGrant").'
    '; - $userstatic->id=$obj->rowid; - $userstatic->lastname=$obj->lastname; - $userstatic->firstname=$obj->firstname; - $userstatic->email=$obj->email; - print $userstatic->getNomUrl(1); - print '

    "; - $db->free($resql); + print ""; + print ''; + $userstatic->id=$obj->rowid; + $userstatic->lastname=$obj->lastname; + $userstatic->firstname=$obj->firstname; + $userstatic->email=$obj->email; + print $userstatic->getNomUrl(1); + print ''; + print "\n"; + $i++; + } + print "
    "; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } -print ''; +print '
    '; /* @@ -314,52 +313,52 @@ $sql.= $db->plimit($max, 0); $resql=$db->query($sql); if ($resql) { - print ''; - print ''; - print ''; + print '
    '.$langs->trans("LastModifiedOrders",$max).'
    '; + print ''; + print ''; - $num = $db->num_rows($resql); - if ($num) - { - $i = 0; - $var = True; - while ($i < $num) - { - $var=!$var; - $obj = $db->fetch_object($resql); + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); - print ""; - print '"; + print '
    '.$langs->trans("LastModifiedOrders",$max).'
    '; + print "
    '; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id=$obj->rowid; + $commandestatic->ref=$obj->ref; - print ''; - print ''; + print '
    '; - print $commandestatic->getNomUrl(1); - print '
    '; + print ''; - print ''; + print ''; - print '
    '; + print $commandestatic->getNomUrl(1); + print ''; - print ' '; - print ''; + print ' '; + print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); - print '
    '; + print '
    '; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); + print '
    '; - print ''; + print ''; - print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''; - print ''.dol_print_date($db->jdate($obj->tms),'day').''; - print ''.$commandestatic->LibStatut($obj->fk_statut,5).''; - print ''; - $i++; - } - } - print "
    "; + print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''; + print ''.dol_print_date($db->jdate($obj->tms),'day').''; + print ''.$commandestatic->LibStatut($obj->fk_statut,5).''; + print ''; + $i++; + } + } + print "
    "; } else dol_print_error($db); @@ -433,7 +432,7 @@ print "
    "; } */ -print ''; +print '
    '; llxFooter(); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3b6c928619f..d184845cb76 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -129,8 +130,8 @@ if (empty($user->socid)) $fieldstosearchall["cf.note_private"]="NotePrivate"; $checkedtypetiers=0; $arrayfields=array( 'cf.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplier"), 'checked'=>1, 'enabled'=>$conf->global->SUPPLIER_ORDER_HIDE_REF_SUPPLIER), - 'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'enabled'=>$conf->global->PROJECT_SHOW_REF_INTO_LISTS), + 'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplier"), 'checked'=>1, 'enabled'=>1), + 'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1), 'u.login'=>array('label'=>$langs->trans("AuthorRequest"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), @@ -399,6 +400,7 @@ if ($resql) if ($socid > 0) $param.='&socid='.$socid; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall) $param.="&search_all=".$sall; if ($orderday) $param.='&orderday='.$orderday; if ($ordermonth) $param.='&ordermonth='.$ordermonth; if ($orderyear) $param.='&orderyear='.$orderyear; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 0eada7d918f..2e0ef64f96f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -85,7 +85,9 @@ $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); if ($id > 0 || ! empty($ref)) { $ret=$object->fetch($id, $ref); - $object->fetch_thirdparty(); + if ($ret < 0) dol_print_error($db,$object->error); + $ret=$object->fetch_thirdparty(); + if ($ret < 0) dol_print_error($db,$object->error); } $permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php @@ -118,7 +120,7 @@ if (empty($reshook)) $object->fetch_thirdparty(); $result = $object->add_object_linked('order_supplier', GETPOST('linkedOrder')); } - + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { @@ -248,10 +250,28 @@ if (empty($reshook)) if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); - + if ($object->update($user) < 0) { setEventMessages($object->error, $object->errors, 'errors'); } + else + { + // Define output language + $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->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } } // payments conditions @@ -265,7 +285,7 @@ if (empty($reshook)) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); } - + // Multicurrency Code else if ($action == 'setmulticurrencycode' && $user->rights->facture->creer) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); @@ -273,7 +293,7 @@ if (empty($reshook)) // Multicurrency rate else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) { - $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int')); + $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); } // bank account @@ -486,7 +506,7 @@ if (empty($reshook)) break; } } - + // Now reload line $object->fetch_lines(); } @@ -507,7 +527,7 @@ if (empty($reshook)) { $error++; } - + if (! $error) { // If some invoice's lines already known @@ -545,7 +565,7 @@ if (empty($reshook)) { $langs->load("errors"); $db->rollback(); - + setEventMessages($object->error, $object->errors, 'errors'); $action='create'; $_GET['socid']=$_POST['socid']; @@ -557,7 +577,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) + if ($result < 0) { dol_print_error($db,$object->error,$object->errors); exit; @@ -774,7 +794,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } } - else if( GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='' ) + else if (GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -939,14 +959,14 @@ if (empty($reshook)) /* * Send mail */ - + // Actions to send emails $actiontypecode='AC_SUP_INV'; $trigger_name='BILL_SUPPLIER_SENTBYMAIL'; $paramname='id'; $mode='emailfromsupplierinvoice'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - + // Build document if ($action == 'builddoc') @@ -967,7 +987,7 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action=''; @@ -1112,8 +1132,13 @@ $form = new Form($db); $formfile = new FormFile($db); $bankaccountstatic=new Account($db); $paymentstatic=new PaiementFourn($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -llxHeader('',$langs->trans('SupplierInvoice'),''); +$now = dol_now(); + +$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Card'); +$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; +llxHeader('', $title, $helpurl); // Mode creation if ($action == 'create') @@ -1126,7 +1151,7 @@ if ($action == 'create') dol_htmloutput_events(); $currency_code = $conf->currency; - + $societe=''; if (GETPOST('socid') > 0) { @@ -1134,7 +1159,7 @@ if ($action == 'create') $societe->fetch(GETPOST('socid','int')); if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code; } - + if (GETPOST('origin') && GETPOST('originid')) { // Parse element/subelement (ex: project_task) @@ -1182,9 +1207,9 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled)) { if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } - + $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); @@ -1200,7 +1225,7 @@ if ($action == 'create') $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); $datedue=($datetmp==''?-1:$datetmp); - + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } @@ -1211,9 +1236,9 @@ if ($action == 'create') print ''; print ''; if (!empty($currency_tx)) print ''; - + dol_fiche_head(); - + print ''; // Ref @@ -1238,9 +1263,9 @@ if ($action == 'create') print ''; print ''; + // Type print '
    '.$langs->trans('RefSupplier').'
    '.$langs->trans('Type').''; print ''."\n"; - // Standard invoice print ''."\n"; - /* - // Deposit + // Deposit print ''."\n"; - // Proforma if (! empty($conf->global->FACTURE_USE_PROFORMAT)) { @@ -1268,7 +1291,6 @@ if ($action == 'create') print $desc; print ''."\n"; } - // Replacement print ''; - // Credit note print '"; - + if (!empty($conf->multicurrency->enabled)) { print ''; print '"; - print '"; + print '"; } } - else - { - // TODO more bugs - if (1==2 && ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - for ($i = 1 ; $i < 9 ; $i++) - { - $value_qty = '1'; - $value_tauxtva = ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } - } // Other options $parameters=array('colspan' => ' colspan="6"'); @@ -1541,6 +1533,8 @@ else // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $alreadypaid=$object->getSommePaiement(); + /* * View card */ @@ -1638,7 +1632,8 @@ else $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 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 if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; @@ -1649,14 +1644,64 @@ else print $formconfirm; - /** - * Invoice - */ - print '
    '; print ''; @@ -1248,16 +1273,14 @@ if ($action == 'create') $desc=$form->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); print $desc; print '
    '; print ''; print ''; $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); print $desc; print '
    '; print 'textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); print $desc; print '
    '; print ''.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
    ' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . '
    ' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
    ' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
    ' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
     '.$langs->trans('Label').''.$langs->trans('PriceUHT').''.$langs->trans('VAT').''.$langs->trans('Qty').''.$langs->trans('PriceUTTC').'
    '.$i.''; - print $form->load_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc); - print '
    '; + // Supplier invoice card $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref='
    '; + // Ref supplier + $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
    '.$langs->trans('Project') . ' '; + if ($user->rights->fournisseur->commande->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
    '; + + $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + // Ref + /* print ''; @@ -1671,9 +1716,10 @@ else print ''; print ''; - + */ + // Type - print ''; - print ''; - - /* - * List of payments - */ - $nbrows=9; $nbcols=3; - if (! empty($conf->projet->enabled)) $nbrows++; - if (! empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } - if (! empty($conf->incoterm->enabled)) $nbrows++; - - // Local taxes - if ($societe->localtax1_assuj=="1") $nbrows++; - if ($societe->localtax2_assuj=="1") $nbrows++; - - print ''; - + print ''; print ''; $form_permission = $object->statutrights->fournisseur->facture->creer && $object->getSommePaiement() <= 0; // Date - print ''; @@ -1897,7 +1835,7 @@ else $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); } print ''; - + // Multicurrency rate print ''; print ''; // Status - $alreadypaid=$object->getSommePaiement(); - print ''; - - // Amount - print ''; - print ''; - - // Amount Local Taxes - //TODO: Place into a function to control showing by country or study better option - if ($societe->localtax1_assuj=="1") //Localtax1 - { - print ''; - print ''; - print ''; - } - if ($societe->localtax2_assuj=="1") //Localtax2 - { - print ''; - print ''; - print ''; - } - print ''; - - if (!empty($conf->multicurrency->enabled)) - { - // Multicurrency Amount HT - print ''; - print ''; - print ''; - - // Multicurrency Amount VAT - print ''; - print ''; - print ''; - - // Multicurrency Amount TTC - print ''; - print ''; - print ''; - } + //print ''; // Project + /* if (! empty($conf->projet->enabled)) { $langs->load('projects'); @@ -2015,7 +1905,8 @@ else print ''; print ''; } - + */ + // Incoterms if (!empty($conf->incoterm->enabled)) { @@ -2039,12 +1930,180 @@ else print ''; } - // Other attributes - $cols = 4; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
    '.$langs->trans("Ref").''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); print '
    '.$langs->trans('Supplier').''.$societe->getNomUrl(1,'supplier'); print '   ('.$langs->trans('OtherBills').')
    '.$langs->trans('Type').''; + print '
    '.$langs->trans('Type').''; print $object->getLibType(); if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { @@ -1713,121 +1759,13 @@ else // Label print '
    '.$form->editfieldkey("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).''.$form->editfieldval("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).''; - - $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; - $sql.= ' c.id as paiement_type,'; - $sql.= ' pf.amount,'; - $sql.= ' ba.rowid as baid, ba.ref as baref, ba.label'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; - $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; - $sql.= ' ORDER BY p.datep, p.tms'; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $totalpaye = 0; - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - - $var=true; - if ($num > 0) - { - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) - { - $bankaccountstatic->id=$objp->baid; - $bankaccountstatic->ref=$objp->baref; - $bankaccountstatic->label=$objp->baref; - print ''; - } - print ''; - print ''; - print ''; - $totalpaye += $objp->amount; - $i++; - } - } - else - { - print ''; - } - - if ($object->paye == 0) - { - print ''; - print ''; - - $resteapayer = $object->total_ttc - $totalpaye; - - print ''; - print ''; - } - print '
    '.$langs->trans('Payments').''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
    '; - $paymentstatic->id=$objp->rowid; - $paymentstatic->datepaye=$db->jdate($objp->dp); - $paymentstatic->ref=$objp->ref; - $paymentstatic->num_paiement=$objp->num_paiement; - $paymentstatic->payment_code=$objp->payment_code; - print $paymentstatic->getNomUrl(1); - print ''.dol_print_date($db->jdate($objp->dp), 'day') . ''; - print $form->form_modes_reglement(null, $objp->paiement_type,'none').' '.$objp->num_paiement; - print ''; - if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1,'transactions'); - print ''.price($objp->amount).''; - if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) - { - print 'rowid.'">'; - print img_delete(); - print ''; - } - print '
    '.$langs->trans("None").'
    '.$langs->trans('AlreadyPaid').' :'.price($totalpaye).'
    '.$langs->trans("Billed").' :'.price($object->total_ttc).'
    '.$langs->trans('RemainderToPay').' :'.price($resteapayer).'
    '; - $db->free($result); - } - else - { - dol_print_error($db); - } - print '
    '.$form->editfieldval("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).'
    '.$form->editfieldkey("Date",'datef',$object->datep,$object,$form_permission,'datepicker').''; + print '
    '.$form->editfieldkey("DateInvoice",'datef',$object->datep,$object,$form_permission,'datepicker').''; print $form->editfieldval("Date",'datef',$object->datep,$object,$form_permission,'datepicker'); print '
    '; @@ -1934,58 +1872,10 @@ else print '
    '.$langs->trans('Status').''.$object->getLibStatut(4,$alreadypaid).'
    '.$langs->trans('AmountHT').''.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'
    '.$langs->trans('AmountVAT').''.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).''; - if (GETPOST('calculationrule')) $calculationrule=GETPOST('calculationrule','alpha'); - else $calculationrule=(empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)?'totalofround':'roundoftotal'); - if ($calculationrule == 'totalofround') $calculationrulenum=1; - else $calculationrulenum=2; - $s=$langs->trans("ReCalculate").' '; - $s.=''.$langs->trans("Mode1").''; - $s.=' / '; - $s.=''.$langs->trans("Mode2").''; - print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc",$calculationrulenum).'
    '.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('','help')); - print '
    '.$langs->transcountry("AmountLT1",$societe->country_code).''.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'
    '.$langs->transcountry("AmountLT2",$societe->country_code).''.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'
    '.$langs->trans('AmountTTC').''.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'
    ' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    '.$langs->trans('Status').''.$object->getLibStatut(4,$alreadypaid).'

    '; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
    '; + + print '
    '; + print '
    '; + print '
    '; + print '
    '; + + print ''; + + // Amount + print ''; + print ''; + + // Amount Local Taxes + //TODO: Place into a function to control showing by country or study better option + if ($societe->localtax1_assuj=="1") //Localtax1 + { + print ''; + print ''; + print ''; + } + if ($societe->localtax2_assuj=="1") //Localtax2 + { + print ''; + print ''; + print ''; + } + print ''; + + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency Amount HT + print ''; + print ''; + print ''; + + // Multicurrency Amount VAT + print ''; + print ''; + print ''; + + // Multicurrency Amount TTC + print ''; + print ''; + print ''; + } + + print '
    '.$langs->trans('AmountHT').''.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'
    '.$langs->trans('AmountVAT').''.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'
            '; + if (GETPOST('calculationrule')) $calculationrule=GETPOST('calculationrule','alpha'); + else $calculationrule=(empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)?'totalofround':'roundoftotal'); + if ($calculationrule == 'totalofround') $calculationrulenum=1; + else $calculationrulenum=2; + $s=$langs->trans("ReCalculate").' '; + $s.=''.$langs->trans("Mode1").''; + $s.=' / '; + $s.=''.$langs->trans("Mode2").''; + print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc",$calculationrulenum).'
    '.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('','help')); + print '
    '.$langs->transcountry("AmountLT1",$societe->country_code).''.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'
    '.$langs->transcountry("AmountLT2",$societe->country_code).''.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'
    '.$langs->trans('AmountTTC').''.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'
    ' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    '; + + /* + * List of payments + */ + $nbrows=9; $nbcols=3; + if (! empty($conf->projet->enabled)) $nbrows++; + if (! empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } + if (! empty($conf->incoterm->enabled)) $nbrows++; + + // Local taxes + if ($societe->localtax1_assuj=="1") $nbrows++; + if ($societe->localtax2_assuj=="1") $nbrows++; + + $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; + $sql.= ' c.id as paiement_type,'; + $sql.= ' pf.amount,'; + $sql.= ' ba.rowid as baid, ba.ref as baref, ba.label'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; + $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; + $sql.= ' ORDER BY p.datep, p.tms'; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; $totalpaye = 0; + print ''; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + + $var=false; + if ($num > 0) + { + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) + { + $bankaccountstatic->id=$objp->baid; + $bankaccountstatic->ref=$objp->baref; + $bankaccountstatic->label=$objp->baref; + print ''; + } + print ''; + print ''; + print ''; + $totalpaye += $objp->amount; + $i++; + } + } + else + { + print ''; + } + + if ($object->paye == 0) + { + print ''; + print ''; + + $resteapayer = $object->total_ttc - $totalpaye; + + print ''; + print ''; + } + print '
    '.$langs->trans('Payments').''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
    '; + $paymentstatic->id=$objp->rowid; + $paymentstatic->datepaye=$db->jdate($objp->dp); + $paymentstatic->ref=$objp->ref; + $paymentstatic->num_paiement=$objp->num_paiement; + $paymentstatic->payment_code=$objp->payment_code; + print $paymentstatic->getNomUrl(1); + print ''.dol_print_date($db->jdate($objp->dp), 'day') . ''; + print $form->form_modes_reglement(null, $objp->paiement_type,'none').' '.$objp->num_paiement; + print ''; + if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1,'transactions'); + print ''.price($objp->amount).''; + if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) + { + print 'rowid.'">'; + print img_delete(); + print ''; + } + print '
    '.$langs->trans("None").'
    '.$langs->trans('AlreadyPaid').' :'.price($totalpaye).'
    '.$langs->trans("Billed").' :'.price($object->total_ttc).'
    '.$langs->trans('RemainderToPay').' :'.price($resteapayer).'
    '; + $db->free($result); + } + else + { + dol_print_error($db); + } + + print '
    '; + print '
    '; + print '
    '; + + print '

    '; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; @@ -2083,7 +2142,7 @@ else global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; $forceall=1; $senderissupplier=1; $dateSelector=0; $inputalsopricewithtax=1; - + // Show object lines if (! empty($object->lines)) $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); @@ -2124,15 +2183,15 @@ else $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook - if (empty($reshook)) + if (empty($reshook)) { - + // Modify a validated invoice with no payments if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer) { print ''.$langs->trans('Modify').''; } - + // Reopen a standard paid invoice if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT) && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely) { @@ -2145,7 +2204,7 @@ else print ''.$langs->trans('ReOpen').''; } } - + // Send by mail if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED)) { @@ -2155,23 +2214,23 @@ else } else print ''.$langs->trans('SendByMail').''; } - - + + // Make payments if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) { print ''.$langs->trans('DoPayment').''; // must use facid because id is for payment id not invoice } - + // Classify paid if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) { print ''.$langs->trans('ClassifyPaid').''; - + //print ''.$langs->trans('ClassifyPaid').''; } - + // Validate if ($action != 'edit' && $object->statut == FactureFournisseur::STATUS_DRAFT) { @@ -2190,19 +2249,19 @@ else } } } - + // Create event if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. { print ''; } - + // Clone if ($action != 'edit' && $user->rights->fournisseur->facture->creer) { print 'socid.'">'.$langs->trans('ToClone').''; } - + // Delete if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) { @@ -2214,17 +2273,14 @@ else } print ''; print '
    '; - + if ($action != 'edit') { print '
    '; - //print '
    '; - //print ''; // ancre - - /* + + /* * Documents generes - */ - + */ $ref=dol_sanitizeFileName($object->ref); $subdir = get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref; $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref; @@ -2232,25 +2288,23 @@ else $genallowed=$user->rights->fournisseur->facture->creer; $delallowed=$user->rights->fournisseur->facture->supprimer; $modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)?'':$conf->global->INVOICE_SUPPLIER_ADDON_PDF)); - + print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang); $somethingshown=$formfile->numoffiles; - // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice_supplier')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - - - print '
    '; + + print '
    '; //print '
    '; //print '
    '; - + // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); $somethingshown=$formactions->showactions($object,'invoice_supplier',$socid,0,'listaction'.($genallowed?'largetitle':'')); - + print ''; //print '
    '; } @@ -2289,7 +2343,7 @@ else if (! $file || ! is_readable($file)) { $result = $object->generateDocument(GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) + if ($result < 0) { dol_print_error($db,$object->error,$object->errors); exit; @@ -2317,7 +2371,7 @@ else { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'sin'.$object->id); - } + } $formmail->withfrom=1; $liste=array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index fbcb907ec74..1da6e0699fc 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -112,7 +112,9 @@ else if ($action == 'deletecontact' && $user->rights->fournisseur->facture->cree * View */ -llxHeader('',$langs->trans('SupplierInvoice')); +$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('ContactsAddresses'); +$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; +llxHeader('', $title, $helpurl); $form = new Form($db); $formcompany = new FormCompany($db); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 97e84d0cb6e..3ca1c2d05fa 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -81,7 +81,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -llxHeader('',$langs->trans('SupplierInvoice')); +$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Documents'); +$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; +llxHeader('', $title, $helpurl); if ($object->id > 0) { diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 4dad6ea7f86..590d5ea75bd 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -43,7 +43,9 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); * View */ -llxHeader('',$langs->trans('SupplierInvoice')); +$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Info'); +$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; +llxHeader('', $title, $helpurl); $object = new FactureFournisseur($db); $object->fetch($id); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index d234ea01bcb..b8e90dbce10 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -58,7 +58,6 @@ if ($user->societe_id > 0) } $mode=GETPOST("mode"); -$modesearch=GETPOST("mode_search"); $search_product_category=GETPOST('search_product_category','int'); $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref','alpha'):GETPOST('search_ref','alpha'); @@ -215,27 +214,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOS $option=''; } -if ($mode == 'search') -{ - if ($modesearch == 'soc') - { - $sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s "; - $sql.= " WHERE s.nom LIKE '%".$db->escape($socname)."%'"; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; - } - - $resql=$db->query($sql); - if ($resql) - { - if ( $db->num_rows($resql) == 1) - { - $obj = $db->fetch_object($resql); - $socid = $obj->rowid; - } - $db->free($resql); - } -} - if (empty($reshook)) { // Mass actions. Controls on number of lines checked @@ -313,7 +291,7 @@ if ($search_ref) else $sql .= natural_search('f.ref', $search_ref); } if ($search_ref) $sql .= natural_search('f.ref', $search_ref); -if ($search_ref_supplier) $sql .= natural_search('f.ref_supplier', $search_ref_supplier); +if ($search_refsupplier) $sql .= natural_search('f.ref_supplier', $search_refsupplier); if ($search_project) $sql .= natural_search('p.ref', $search_project); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_town) $sql.= natural_search('s.town', $search_town); @@ -322,7 +300,7 @@ if ($search_state) $sql.= natural_search("state.nom",$search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); +if ($search_montant_ht != '') $sql.= natural_search('f.total_ht', $search_montant_ht, 1); if ($search_montant_vat != '') $sql.= natural_search('f.total_tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status); @@ -427,7 +405,7 @@ if ($resql) if ($month_lim) $param.='&month_lim='.urlencode($month_lim); if ($year_lim) $param.='&year_lim=' .urlencode($year_lim); if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_refsupplier) $param.='&search_refsupplier'.urlencode($search_refsupplier); + if ($search_refsupplier) $param.='&search_refsupplier='.urlencode($search_refsupplier); if ($search_label) $param.='&search_label='.urlencode($search_label); if ($search_company) $param.='&search_company='.urlencode($search_company); if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index 1b8a4cd6bbc..eeb9d37f2fd 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -67,7 +67,9 @@ if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) $form = new Form($db); -llxHeader('',$langs->trans('SupplierInvoice')); +$title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Notes'); +$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; +llxHeader('', $title, $helpurl); if ($object->id > 0) { diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 6a4f2255f6b..95ff1620691 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -23,7 +23,7 @@ /** * \file htdocs/fourn/product/list.php * \ingroup produit - * \brief Page liste des produits ou services + * \brief Page to list supplier products and services */ require '../../main.inc.php'; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 4c6aeb99110..1103804b72c 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2012-2015 Laurent Destailleur + * Copyright (C) 2012-2016 Laurent Destailleur * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2014 Ferran Marcet @@ -1010,7 +1010,7 @@ else print ''.$langs->trans("User").''; print ''; - print $userRequest->getNomUrl(1, 'leave'); + print $userRequest->getNomUrl(-1, 'leave'); print ''; // Type @@ -1120,14 +1120,14 @@ else $userCreate->fetch($cp->fk_user_create); print ''; print ''.$langs->trans('RequestByCP').''; - print ''.$userCreate->getNomUrl(1).''; + print ''.$userCreate->getNomUrl(-1).''; print ''; } if (!$edit) { print ''; print ''.$langs->trans('ReviewedByCP').''; - print ''.$valideur->getNomUrl(1).''; + print ''.$valideur->getNomUrl(-1).''; print ''; } else { print ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index b76c90cbf48..75fe446d64d 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -298,11 +298,17 @@ class Holiday extends CommonObject $sql.= " cp.detail_refuse,"; $sql.= " uu.lastname as user_lastname,"; - $sql.= " uu.firstname as user_firstname,"; - + $sql.= " uu.firstname as user_firstname,"; + $sql.= " uu.login as user_login,"; + $sql.= " uu.statut as user_statut,"; + $sql.= " uu.photo as user_photo,"; + $sql.= " ua.lastname as validator_lastname,"; - $sql.= " ua.firstname as validator_firstname"; - + $sql.= " ua.firstname as validator_firstname,"; + $sql.= " ua.login as validator_login,"; + $sql.= " ua.statut as validator_statut,"; + $sql.= " ua.photo as validator_photo"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql.= " WHERE cp.entity IN (".getEntity('holiday', 1).")"; $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau @@ -360,10 +366,16 @@ class Holiday extends CommonObject $tab_result[$i]['user_firstname'] = $obj->user_firstname; $tab_result[$i]['user_lastname'] = $obj->user_lastname; - + $tab_result[$i]['user_login'] = $obj->user_login; + $tab_result[$i]['user_statut'] = $obj->user_statut; + $tab_result[$i]['user_photo'] = $obj->user_photo; + $tab_result[$i]['validator_firstname'] = $obj->validator_firstname; $tab_result[$i]['validator_lastname'] = $obj->validator_lastname; - + $tab_result[$i]['validator_login'] = $obj->validator_login; + $tab_result[$i]['validator_statut'] = $obj->validator_statut; + $tab_result[$i]['validator_photo'] = $obj->validator_photo; + $i++; } @@ -412,10 +424,16 @@ class Holiday extends CommonObject $sql.= " uu.lastname as user_lastname,"; $sql.= " uu.firstname as user_firstname,"; - + $sql.= " uu.login as user_login,"; + $sql.= " uu.statut as user_statut,"; + $sql.= " uu.photo as user_photo,"; + $sql.= " ua.lastname as validator_lastname,"; - $sql.= " ua.firstname as validator_firstname"; - + $sql.= " ua.firstname as validator_firstname,"; + $sql.= " ua.login as validator_login,"; + $sql.= " ua.statut as validator_statut,"; + $sql.= " ua.photo as validator_photo"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql.= " WHERE cp.entity IN (".getEntity('holiday', 1).")"; $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau @@ -473,10 +491,16 @@ class Holiday extends CommonObject $tab_result[$i]['user_firstname'] = $obj->user_firstname; $tab_result[$i]['user_lastname'] = $obj->user_lastname; - + $tab_result[$i]['user_login'] = $obj->user_login; + $tab_result[$i]['user_statut'] = $obj->user_statut; + $tab_result[$i]['user_photo'] = $obj->user_photo; + $tab_result[$i]['validator_firstname'] = $obj->validator_firstname; $tab_result[$i]['validator_lastname'] = $obj->validator_lastname; - + $tab_result[$i]['validator_login'] = $obj->validator_login; + $tab_result[$i]['validator_statut'] = $obj->validator_statut; + $tab_result[$i]['validator_photo'] = $obj->validator_photo; + $i++; } // Retourne 1 et ajoute le tableau à la variable diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index e2554cffffb..4f45704a269 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -121,14 +121,14 @@ if ($object->id) print ''.$langs->trans("User").''; print ''; - print $userRequest->getNomUrl(1); + print $userRequest->getNomUrl(-1); print ''; // Type print ''; print ''.$langs->trans("Type").''; print ''; - $typeleaves=$object->getTypes(1,1); + $typeleaves=$object->getTypes(1,-1); print $typeleaves[$object->fk_type]['label']; print ''; print ''; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 013ee177726..c105e588c15 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -299,7 +299,7 @@ print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],'','','','',$ print_liste_field_titre($langs->trans("Duration"),$_SERVER["PHP_SELF"],'','','','align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateDebCP"),$_SERVER["PHP_SELF"],"cp.date_debut","",'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateFinCP"),$_SERVER["PHP_SELF"],"cp.date_fin","",'','align="center"',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cp.statut","",'','align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cp.statut","",'','align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -318,14 +318,14 @@ print ''; // UTILISATEUR if ($user->rights->holiday->write_all) { - print ''; + print ''; print $form->select_dolusers($search_employe,"search_employe",1,"",0,'','',0,32,0,'',0,'','maxwidth200'); print ''; } else { //print ' '; - print ''; + print ''; print $form->select_dolusers($user->id,"search_employe",1,"",1,'','',0,32,0,'',0,'','maxwidth200'); print ''; } @@ -333,7 +333,7 @@ else // APPROVER if($user->rights->holiday->write_all) { - print ''; + print ''; $validator = new UserGroup($db); $excludefilter=$user->admin?'':'u.rowid <> '.$user->id; @@ -377,7 +377,7 @@ $formother->select_year($year_end,'year_end',1, $min_year, $max_year); print ''; // STATUT -print ''; +print ''; $holiday->selectStatutCP($search_statut); print ''; @@ -404,12 +404,18 @@ if (! empty($holiday->holiday)) $userstatic->id=$infos_CP['fk_user']; $userstatic->lastname=$infos_CP['user_lastname']; $userstatic->firstname=$infos_CP['user_firstname']; - + $userstatic->login=$infos_CP['user_login']; + $userstatic->statut=$infos_CP['user_statut']; + $userstatic->photo=$infos_CP['user_photo']; + // Valideur $approbatorstatic->id=$infos_CP['fk_validator']; $approbatorstatic->lastname=$infos_CP['validator_lastname']; $approbatorstatic->firstname=$infos_CP['validator_firstname']; - + $approbatorstatic->login=$infos_CP['validator_login']; + $approbatorstatic->statut=$infos_CP['validator_statut']; + $approbatorstatic->photo=$infos_CP['validator_photo']; + $date = $infos_CP['date_create']; print ''; @@ -419,8 +425,8 @@ if (! empty($holiday->holiday)) print $holidaystatic->getNomUrl(1); print ''; print ''.dol_print_date($date,'day').''; - print ''.$userstatic->getNomUrl('1', 'leave').''; - print ''.$approbatorstatic->getNomUrl('1').''; + print ''.$userstatic->getNomUrl(-1, 'leave').''; + print ''.$approbatorstatic->getNomUrl(-1).''; print ''; $label=$alltypeleaves[$infos_CP['fk_type']]['label']; print $label?$label:$infos_CP['fk_type']; diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 1b0e779488a..8ee69dc54ad 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -100,8 +100,8 @@ foreach($cp->logs as $logs_CP) print ''; print ''.$logs_CP['rowid'].''; print ''.$logs_CP['date_action'].''; - print ''.$user_action->getNomUrl(1).''; - print ''.$user_update->getNomUrl(1).''; + print ''.$user_action->getNomUrl(-1).''; + print ''.$user_update->getNomUrl(-1).''; print ''.$logs_CP['type_action'].''; print ''; $label=$alltypeleaves[$logs_CP['fk_type']]['label']; diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 5f004f15e09..25c2fbf24c7 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -110,7 +110,8 @@ if ($result) $establishmentstatic->id=$obj->rowid; $establishmentstatic->name=$obj->name; - + $establishmentstatic->status=$obj->status; + $var=!$var; print ''; print ''.$establishmentstatic->getNomUrl(1).''; @@ -119,7 +120,7 @@ if ($result) print ''.$obj->town.''; print ''; - print $establishmenttmp->getLibStatus(5); + print $establishmentstatic->getLibStatus(5); print ''; print "\n"; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 88b765740ef..9ff2e2065cc 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -58,8 +58,8 @@ class Establishment extends CommonObject { $this->db = $db; - $this->statuts_short = array(0 => 'Opened', 1 => 'Closed'); - $this->statuts = array(0 => 'Opened', 1 => 'Closed'); + $this->statuts_short = array(0 => 'Closed', 1 => 'Opened'); + $this->statuts = array(0 => 'Closed', 1 => 'Opened'); return 1; } @@ -157,7 +157,7 @@ class Establishment extends CommonObject $sql .= ", address = '".$this->address."'"; $sql .= ", zip = '".$this->zip."'"; $sql .= ", town = '".$this->town."'"; - + $sql .= ", fk_country = ".($this->country_id > 0 ? $this->country_id : 'null'); $sql .= ", status = '".$this->status."'"; $sql .= ", fk_user_mod = " . $user->id; $sql .= " WHERE rowid = ".$this->id; @@ -273,23 +273,23 @@ class Establishment extends CommonObject } if ($mode == 2) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]),'statut4').' '.$langs->trans($this->statuts_short[$status]); - if ($status==1) return img_picto($langs->trans($this->statuts_short[$status]),'statut8').' '.$langs->trans($this->statuts_short[$status]); + if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]),'statut5').' '.$langs->trans($this->statuts_short[$status]); + if ($status==1) return img_picto($langs->trans($this->statuts_short[$status]),'statut4').' '.$langs->trans($this->statuts_short[$status]); } if ($mode == 3) { - if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut4'); - if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut8'); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut5'); + if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut4'); } if ($mode == 4) { - if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut4').' '.$langs->trans($this->statuts[$status]); - if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut8').' '.$langs->trans($this->statuts[$status]); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut5').' '.$langs->trans($this->statuts[$status]); + if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut4').' '.$langs->trans($this->statuts[$status]); } if ($mode == 5) { - if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut4'); - if ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut8'); + if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut5'); + if ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut4'); } } diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 11179d218f8..eafa302886f 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -40,14 +40,18 @@ $id = GETPOST('id','int'); // List of status static $tmpstatus2label=array( - '0'=>'OpenEtablishment', - '1'=>'CloseEtablishment' + '0'=>'CloseEtablishment', + '1'=>'OpenEtablishment' ); $status2label=array(''); foreach ($tmpstatus2label as $key => $val) $status2label[$key]=$langs->trans($val); $object = new Establishment($db); +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once + + /* * Actions */ @@ -128,12 +132,13 @@ else if ($action == 'update') $error ++; } - if (empty($error)) { + if (empty($error)) + { $object->name = GETPOST('name', 'alpha'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); - $object->country_id = $_POST["country_id"]; + $object->country_id = GETPOST('country_id', 'int'); $object->fk_user_mod = $user->id; $result = $object->update($user); @@ -373,7 +378,8 @@ else if ($id) print ''; // Status - print ''.$langs->trans("Status").''.$object->getLibStatus(4).''; + print ''.$langs->trans("Status").''; + print $object->getLibStatus(4).''; print ""; diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 9f1ecaa6c5d..acc16eb0d3e 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -97,7 +97,7 @@ if (count($listofsearchfields)) { if ($i == 0) print ''.$langs->trans("Search").''; print ''; - print ':'; + print ''; if ($i == 0) print ''; print ''; $i++; @@ -145,7 +145,7 @@ $langs->load("boxes"); // Last leave requests if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) { - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.photo, u.statut, x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE u.rowid = x.fk_user"; $sql.= " AND x.entity = ".$conf->entity; @@ -187,9 +187,12 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) $userstatic->id=$obj->uid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->login=$obj->login; + $userstatic->photo=$obj->photo; + $userstatic->statut=$obj->statut; print ''; print ''.$holidaystatic->getNomUrl(1).''; - print ''.$userstatic->getNomUrl(1, 'leave').''; + print ''.$userstatic->getNomUrl(-1, 'leave').''; print ''.$typeleaves[$obj->fk_type]['label'].''; $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; @@ -218,7 +221,7 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) // Last expense report (old module) if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) { - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut, u.photo, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user"; @@ -258,9 +261,12 @@ if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) $userstatic->id=$obj->uid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->login=$obj->login; + $userstatic->statut=$obj->statut; + $userstatic->photo=$obj->photo; print ''; print ''.$deplacementstatic->getNomUrl(1).''; - print ''.$userstatic->getNomUrl(1).''; + print ''.$userstatic->getNomUrl(-1).''; print ''.$obj->km.''; print ''.dol_print_date($db->jdate($obj->dm),'day').''; print ''.$deplacementstatic->LibStatut($obj->fk_statut,3).''; @@ -282,7 +288,7 @@ if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) // Last expense report (new module) if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) { - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = x.fk_user_author"; @@ -322,9 +328,12 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire $userstatic->id=$obj->uid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->login=$obj->login; + $userstatic->statut=$obj->statut; + $userstatic->photo=$obj->photo; print ''; print ''.$expensereportstatic->getNomUrl(1).''; - print ''.$userstatic->getNomUrl(1).''; + print ''.$userstatic->getNomUrl(-1).''; print ''.price($obj->total_ttc).''; print ''.dol_print_date($db->jdate($obj->dm),'day').''; print ''.$expensereportstatic->LibStatut($obj->status,3).''; diff --git a/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php b/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php index 666c2e57fd4..e8248a385fa 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php @@ -482,7 +482,7 @@ class CommentParser $r['name'] = substr($data, 1); } } - if (isset($r['type']) && Text::endsWith($r['type'], '[]')) { + if (isset($r['type']) && is_string($r['type']) && Text::endsWith($r['type'], '[]')) { $r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2); $r['type'] = 'array'; } diff --git a/htdocs/index.php b/htdocs/index.php index faa2eb9dcee..a723ddb5157 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -24,7 +24,7 @@ * \brief Dolibarr home page */ -define('NOCSRFCHECK',1); // This is login page. We must be able to go on it from another web site. +define('NOCSRFCHECK',1); // This is main home and login page. We must be able to go on it from another web site. require 'main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -546,14 +546,15 @@ foreach($valid_dashboardlines as $board) $boxwork.= ''; //if ($board->nbtodolate > 0) //{ - $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days"); - $boxwork.= ''; - $boxwork.= $board->nbtodolate; - $boxwork.= ''; + $textlate = $langs->trans("NActionsLate",$board->nbtodolate); + $textlate .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; + $boxwork.= ''; + $boxwork.= $board->nbtodolate; + $boxwork.= ''; //} $boxwork.=''; $boxwork.=''; - if ($board->nbtodolate > 0) $boxwork.=img_picto($langs->trans("NActionsLate",$board->nbtodolate).' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')',"warning"); + if ($board->nbtodolate > 0) $boxwork.=img_picto($textlate,"warning"); else $boxwork.=' '; $boxwork.=''; /*print ''; diff --git a/htdocs/install/.gitignore b/htdocs/install/.gitignore index 7e55df64ce7..85797d21c95 100644 --- a/htdocs/install/.gitignore +++ b/htdocs/install/.gitignore @@ -1 +1 @@ -/filelist.xml +/filelist*.xml diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 17784e8b766..3f597c794d1 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -627,22 +627,12 @@ function jscheckparam() ok=false; alert('transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>'); } - else if (document.forminstall.db_create_database.checked == true && (document.forminstall.db_user_root.value == '')) - { - ok=false; - alert('transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>'); - } // If create user asked else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == '')) { ok=false; alert('transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>'); } - else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == '')) - { - ok=false; - alert('transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>'); - } return ok; } diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 068fbc753cb..9669fe89e54 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -724,7 +724,7 @@ INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES ( INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (3,'PROPO' ,'Proposal', 30, 40,1); INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (4,'NEGO' ,'Negotiation', 40, 60,1); INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (5,'PENDING','Pending', 50, 50,0); -INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (6,'WIN' ,'Won', 60, 100,1); +INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (6,'WON' ,'Won', 60, 100,1); INSERT INTO llx_c_lead_status(rowid,code,label,position,percent,active) VALUES (7,'LOST' ,'Lost', 70, 0,1); diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index a9ce468a14c..57a049fa4c9 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -61,6 +61,10 @@ CREATE TABLE llx_product_lot ( ALTER TABLE llx_product_lot ADD UNIQUE INDEX uk_product_lot(fk_product, batch); +-- VPGSQL8.2 ALTER TABLE llx_product_lot ALTER COLUMN entity SET DEFAULT 1; +ALTER TABLE llx_product_lot MODIFY COLUMN entity integer DEFAULT 1; +UPDATE llx_product_lot SET entity = 1 WHERE entity IS NULL; + DROP TABLE llx_stock_serial; ALTER TABLE llx_product ADD COLUMN note_public text; @@ -329,6 +333,9 @@ ALTER TABLE llx_paiement_facture ADD COLUMN multicurrency_amount double(24,8) DE ALTER TABLE llx_paiementfourn ADD COLUMN multicurrency_amount double(24,8) DEFAULT 0; ALTER TABLE llx_paiementfourn_facturefourn ADD COLUMN multicurrency_amount double(24,8) DEFAULT 0; +ALTER TABLE llx_societe_remise ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; + +ALTER TABLE llx_societe_remise_except ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_ht double(24,8) DEFAULT 0 NOT NULL; ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_tva double(24,8) DEFAULT 0 NOT NULL; ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_ttc double(24,8) DEFAULT 0 NOT NULL; @@ -367,7 +374,6 @@ ALTER TABLE llx_product_lang ADD COLUMN import_key varchar(14) DEFAULT NULL; ALTER TABLE llx_actioncomm MODIFY COLUMN elementtype varchar(255) DEFAULT NULL; -DELETE FROM llx_menu where module='expensereport'; ALTER TABLE llx_accounting_system DROP COLUMN fk_pays; ALTER TABLE llx_accounting_account ADD COLUMN fk_accounting_category integer DEFAULT 0 after label; @@ -392,8 +398,8 @@ INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 3,'MARGE',"Marge commerciale", '', 0, 1, '1 + 2', '30', 1, 1); UPDATE llx_accounting_account SET account_parent = '0' WHERE account_parent = ''; --- VMYSQL4.1 ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer DEFAULT 0; --- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_parent TYPE integer USING account_parent::integer; +-- VMYSQL4.1 ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent varchar(32) DEFAULT '0'; +-- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_parent SET DEFAULT '0'; CREATE TABLE llx_accounting_journal ( @@ -537,3 +543,8 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17804', 'Sociedad Civil', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17805', 'Sociedad Anónima', 1); + +-- VMYSQL4.1 ALTER TABLE llx_establishment CHANGE COLUMN fk_user_mod fk_user_mod integer NULL; +-- VPGSQL8.2 ALTER TABLE llx_establishment ALTER COLUMN fk_user_mod DROP NOT NULL; + +ALTER TABLE llx_multicurrency_rate ADD COLUMN entity integer DEFAULT 1; \ No newline at end of file diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index f5f6a1cdf99..33a53a21763 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -13,20 +13,33 @@ -- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex -- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y -- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y --- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; --- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE --- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; --- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; -- Note: fields with type BLOB/TEXT can't have default value. -- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +-- VPGSQL8.2 ALTER TABLE llx_product_lot ALTER COLUMN entity SET DEFAULT 1; +ALTER TABLE llx_product_lot MODIFY COLUMN entity integer DEFAULT 1; +UPDATE llx_product_lot SET entity = 1 WHERE entity IS NULL; + + +ALTER TABLE llx_don ADD COLUMN date_valid datetime; + +DELETE FROM llx_menu where module='expensereport'; + ALTER TABLE llx_user DROP COLUMN phenix_login; ALTER TABLE llx_user DROP COLUMN phenix_pass; +ALTER TABLE llx_user ADD COLUMN dateemployment datetime; ALTER TABLE llx_societe ADD COLUMN fk_account integer; +ALTER TABLE llx_commandedet ADD COLUMN fk_commandefourndet integer DEFAULT NULL after import_key; -- link to detail line of commande fourn (resplenish) +ALTER TABLE llx_commandedet MODIFY COLUMN fk_commandefourndet integer DEFAULT NULL; + ALTER TABLE llx_website ADD COLUMN virtualhost varchar(255) after fk_default_home; ALTER TABLE llx_chargesociales ADD COLUMN fk_account integer after fk_type; @@ -43,3 +56,67 @@ ALTER TABLE llx_notify ADD COLUMN type_target varchar(16) NULL; ALTER TABLE llx_entrepot DROP COLUMN valo_pmp; +ALTER TABLE llx_notify_def MODIFY COLUMN fk_soc integer NULL; +-- VPGSQL8.2 ALTER TABLE llx_notify_def ALTER COLUMN fk_soc SET DEFAULT NULL; + + +create table llx_categorie_project +( + fk_categorie integer NOT NULL, + fk_project integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +ALTER TABLE llx_categorie_project ADD PRIMARY KEY pk_categorie_project (fk_categorie, fk_project); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_project (fk_project); + +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_fk_project_rowid FOREIGN KEY (fk_project) REFERENCES llx_projet (rowid); + +ALTER TABLE llx_societe_remise_except ADD COLUMN entity integer DEFAULT 1 NOT NULL after rowid; +ALTER TABLE llx_societe_remise ADD COLUMN entity integer DEFAULT 1 NOT NULL after rowid; + + +create table llx_expensereport_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_expensereport_extrafields ADD INDEX idx_expensereport_extrafields (fk_object); + +ALTER TABLE llx_cotisation RENAME TO llx_subscription; +ALTER TABLE llx_subscription ADD UNIQUE INDEX uk_subscription (fk_adherent,dateadh); +ALTER TABLE llx_subscription CHANGE COLUMN cotisation subscription real; +ALTER TABLE llx_adherent_type CHANGE COLUMN cotisation subscription varchar(3) NOT NULL DEFAULT 'yes'; + +create table llx_product_lot_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_product_lot_extrafields ADD INDEX idx_product_lot_extrafields (fk_object); + +ALTER TABLE llx_website_page MODIFY content MEDIUMTEXT; + +create table llx_product_warehouse_properties +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_product integer NOT NULL, + fk_entrepot integer NOT NULL, + seuil_stock_alerte integer DEFAULT '0', + desiredstock integer DEFAULT '0', + import_key varchar(14) -- Import key +)ENGINE=innodb; + +ALTER TABLE llx_accounting_bookkeeping ADD COLUMN entity integer DEFAULT 1 NOT NULL; + +ALTER TABLE llx_accounting_account ADD INDEX uk_accounting_account (account_number, entity); + diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 9cc35e50b0d..04eb75f8b51 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -45,7 +45,7 @@ delete from llx_holiday_logs where fk_user_update not IN (select rowid from llx_ update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01'; -update llx_cotisation set fk_bank = null where fk_bank not in (select rowid from llx_bank); +update llx_subscription set fk_bank = null where fk_bank not in (select rowid from llx_bank); update llx_propal set fk_projet = null where fk_projet not in (select rowid from llx_projet); update llx_commande set fk_projet = null where fk_projet not in (select rowid from llx_projet); diff --git a/htdocs/install/mysql/tables/llx_accounting_account.key.sql b/htdocs/install/mysql/tables/llx_accounting_account.key.sql index 93da3526e62..dcf57da5398 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.key.sql @@ -19,7 +19,7 @@ ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_fk_pcg_version (fk_pcg_version); -ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_number (account_number); +ALTER TABLE llx_accounting_account ADD INDEX uk_accounting_account (account_number, entity); -- This keys are created into foreign table after creation of foreign index diff --git a/htdocs/install/mysql/tables/llx_accounting_account.sql b/htdocs/install/mysql/tables/llx_accounting_account.sql index 1d85db2cc48..316aeca2069 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.sql @@ -29,7 +29,7 @@ create table llx_accounting_account pcg_type varchar(20) NOT NULL, pcg_subtype varchar(20) NOT NULL, account_number varchar(32) NOT NULL, - account_parent varchar(32) DEFAULT '', -- Hierarchic parent + account_parent varchar(32) DEFAULT '0', -- Hierarchic parent label varchar(255) NOT NULL, fk_accounting_category integer DEFAULT 0, fk_user_author integer DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 0f0c3d4ebf9..94761416a47 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -20,6 +20,7 @@ CREATE TABLE llx_accounting_bookkeeping ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id doc_date date NOT NULL, doc_type varchar(30) NOT NULL, -- facture_client/reglement_client/facture_fournisseur/reglement_fournisseur doc_ref varchar(300) NOT NULL, -- facture_client/reglement_client/... reference number diff --git a/htdocs/install/mysql/tables/llx_adherent_type.sql b/htdocs/install/mysql/tables/llx_adherent_type.sql index 1602f441cde..c20eade92d6 100644 --- a/htdocs/install/mysql/tables/llx_adherent_type.sql +++ b/htdocs/install/mysql/tables/llx_adherent_type.sql @@ -29,7 +29,7 @@ create table llx_adherent_type tms timestamp, statut smallint NOT NULL DEFAULT 0, libelle varchar(50) NOT NULL, - cotisation varchar(3) NOT NULL DEFAULT 'yes', + subscription varchar(3) NOT NULL DEFAULT 'yes', vote varchar(3) NOT NULL DEFAULT 'yes', note text, mail_valid text -- mail envoye a la validation diff --git a/htdocs/install/mysql/tables/llx_commandedet.sql b/htdocs/install/mysql/tables/llx_commandedet.sql index 9608c2ae44b..913351ef2f8 100644 --- a/htdocs/install/mysql/tables/llx_commandedet.sql +++ b/htdocs/install/mysql/tables/llx_commandedet.sql @@ -57,6 +57,8 @@ create table llx_commandedet fk_unit integer DEFAULT NULL, -- lien vers table des unités import_key varchar(14), + fk_commandefourndet integer DEFAULT NULL, -- link to detail line of commande fourn (resplenish) + fk_multicurrency integer, multicurrency_code varchar(255), multicurrency_subprice double(24,8) DEFAULT 0, diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index 809627a6eb5..b7b7c89f9cd 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -27,7 +27,6 @@ create table llx_don entity integer DEFAULT 1 NOT NULL, -- multi company id tms timestamp, fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate - datec datetime, -- Create date datedon datetime, -- Date of the donation/promise amount real DEFAULT 0, fk_payment integer, @@ -43,9 +42,11 @@ create table llx_don email varchar(255), phone varchar(24), phone_mobile varchar(24), - public smallint DEFAULT 1 NOT NULL, -- Donation is public ? (0,1) - fk_projet integer NULL, -- Donation is given for a project ? + public smallint DEFAULT 1 NOT NULL, -- Donation is public ? (0,1) + fk_projet integer NULL, -- Donation is given for a project ? + datec datetime, -- Create date fk_user_author integer NOT NULL, + date_valid datetime, -- date de validation fk_user_valid integer NULL, note_private text, note_public text, diff --git a/htdocs/install/mysql/tables/llx_establishment.sql b/htdocs/install/mysql/tables/llx_establishment.sql index fcf57ac28b6..667d512762d 100644 --- a/htdocs/install/mysql/tables/llx_establishment.sql +++ b/htdocs/install/mysql/tables/llx_establishment.sql @@ -33,7 +33,7 @@ CREATE TABLE llx_establishment ( profid3 varchar(20), phone varchar(20), fk_user_author integer NOT NULL, - fk_user_mod integer NOT NULL, + fk_user_mod integer, datec datetime NOT NULL, tms timestamp NOT NULL, status tinyint DEFAULT 1 diff --git a/htdocs/install/mysql/tables/llx_expensereport_extrafields.key.sql b/htdocs/install/mysql/tables/llx_expensereport_extrafields.key.sql new file mode 100644 index 00000000000..1982600d8e3 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_expensereport_extrafields.key.sql @@ -0,0 +1,21 @@ +-- =================================================================== +-- Copyright (C) 2016 Laurent Destailleur +-- +-- 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_expensereport_extrafields ADD INDEX idx_expensereport_extrafields (fk_object); + diff --git a/htdocs/install/mysql/tables/llx_expensereport_extrafields.sql b/htdocs/install/mysql/tables/llx_expensereport_extrafields.sql new file mode 100644 index 00000000000..72b6a8c3194 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_expensereport_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2016 Laurent Destailleur +-- +-- 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 . +-- +-- ======================================================================== + +create table llx_expensereport_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index d314cae3727..42f83e16500 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -54,7 +54,8 @@ create table llx_facturedet buy_price_ht double(24,8) DEFAULT 0, -- buying price fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) - fk_code_ventilation integer DEFAULT 0 NOT NULL, + fk_code_ventilation integer DEFAULT 0 NOT NULL, -- Id in table llx_accounting_bookeeping to know accounting account for product line + special_code integer DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- position of line fk_contract_line integer NULL, -- id of contract line when invoice comes from contract lines diff --git a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql index 333f5deab52..545807c8aed 100644 --- a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql +++ b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql @@ -22,5 +22,6 @@ CREATE TABLE llx_multicurrency_rate rowid integer AUTO_INCREMENT PRIMARY KEY, date_sync datetime DEFAULT NULL, rate double NOT NULL DEFAULT 0, - fk_multicurrency integer NOT NULL -) ENGINE=innodb; \ No newline at end of file + fk_multicurrency integer NOT NULL, + entity integer DEFAULT 1 +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_notify_def.sql b/htdocs/install/mysql/tables/llx_notify_def.sql index 28055c76cfe..a3fc123c8dd 100644 --- a/htdocs/install/mysql/tables/llx_notify_def.sql +++ b/htdocs/install/mysql/tables/llx_notify_def.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2016 Laurent Destailleur -- -- 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 @@ -22,7 +23,7 @@ create table llx_notify_def tms timestamp, datec date, -- date de creation fk_action integer NOT NULL, - fk_soc integer NOT NULL, + fk_soc integer, fk_contact integer, fk_user integer, type varchar(16) DEFAULT 'email' diff --git a/htdocs/install/mysql/tables/llx_product_lot_extrafields.key.sql b/htdocs/install/mysql/tables/llx_product_lot_extrafields.key.sql new file mode 100644 index 00000000000..aabf13c3ded --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_lot_extrafields.key.sql @@ -0,0 +1,21 @@ +-- =================================================================== +-- Copyright (C) 2016 Laurent Destailleur +-- +-- 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_product_lot_extrafields ADD INDEX idx_product_lot_extrafields (fk_object); + diff --git a/htdocs/install/mysql/tables/llx_product_lot_extrafields.sql b/htdocs/install/mysql/tables/llx_product_lot_extrafields.sql new file mode 100644 index 00000000000..7e18c8f68ec --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_lot_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2016 Laurent Destailleur +-- +-- 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 . +-- +-- ======================================================================== + +create table llx_product_lot_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_product_stock_entrepot.sql b/htdocs/install/mysql/tables/llx_product_stock_entrepot.sql new file mode 100644 index 00000000000..7b485ca26f6 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_stock_entrepot.sql @@ -0,0 +1,31 @@ +-- ============================================================================ +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2009-2016 Laurent Destailleur +-- Copyright (C) 2012 Juanjo Menent +-- +-- 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 . +-- +-- ============================================================================ + +create table llx_product_warehouse_properties +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_product integer NOT NULL, + fk_entrepot integer NOT NULL, + seuil_stock_alerte integer DEFAULT '0', + desiredstock integer DEFAULT '0', + import_key varchar(14) -- Import key +)ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_societe_remise.sql b/htdocs/install/mysql/tables/llx_societe_remise.sql index 14b4ea85639..a9d41fcd502 100644 --- a/htdocs/install/mysql/tables/llx_societe_remise.sql +++ b/htdocs/install/mysql/tables/llx_societe_remise.sql @@ -1,6 +1,6 @@ -- ======================================================================== -- Copyright (C) 2000-2004 Rodolphe Quiedeville --- Copyright (C) 2011 Regis Houssin +-- Copyright (C) 2011-2016 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -21,13 +21,14 @@ create table llx_societe_remise ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_soc integer NOT NULL, - tms timestamp, - datec datetime, -- creation date - fk_user_author integer, -- creation user - remise_client double(6,3) DEFAULT 0 NOT NULL, -- discount - note text + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_soc integer NOT NULL, + tms timestamp, + datec datetime, -- creation date + fk_user_author integer, -- creation user + remise_client double(6,3) DEFAULT 0 NOT NULL, -- discount + note text )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_societe_remise_except.sql b/htdocs/install/mysql/tables/llx_societe_remise_except.sql index f17d17670d2..4c55e34425c 100644 --- a/htdocs/install/mysql/tables/llx_societe_remise_except.sql +++ b/htdocs/install/mysql/tables/llx_societe_remise_except.sql @@ -21,18 +21,19 @@ create table llx_societe_remise_except ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_soc integer NOT NULL, -- client - datec datetime, - amount_ht double(24,8) NOT NULL, - amount_tva double(24,8) DEFAULT 0 NOT NULL, - amount_ttc double(24,8) DEFAULT 0 NOT NULL, - tva_tx double(6,3) DEFAULT 0 NOT NULL, - fk_user integer NOT NULL, - fk_facture_line integer, - fk_facture integer, - fk_facture_source integer, - description text NOT NULL, + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_soc integer NOT NULL, -- client + datec datetime, + amount_ht double(24,8) NOT NULL, + amount_tva double(24,8) DEFAULT 0 NOT NULL, + amount_ttc double(24,8) DEFAULT 0 NOT NULL, + tva_tx double(6,3) DEFAULT 0 NOT NULL, + fk_user integer NOT NULL, + fk_facture_line integer, + fk_facture integer, + fk_facture_source integer, + description text NOT NULL, multicurrency_amount_ht double(24,8) DEFAULT 0 NOT NULL, multicurrency_amount_tva double(24,8) DEFAULT 0 NOT NULL, multicurrency_amount_ttc double(24,8) DEFAULT 0 NOT NULL diff --git a/htdocs/install/mysql/tables/llx_cotisation.key.sql b/htdocs/install/mysql/tables/llx_subscription.key.sql similarity index 91% rename from htdocs/install/mysql/tables/llx_cotisation.key.sql rename to htdocs/install/mysql/tables/llx_subscription.key.sql index 00998fc69fe..bf84246e8f4 100644 --- a/htdocs/install/mysql/tables/llx_cotisation.key.sql +++ b/htdocs/install/mysql/tables/llx_subscription.key.sql @@ -16,4 +16,4 @@ -- -- ============================================================================ -ALTER TABLE llx_cotisation ADD UNIQUE INDEX uk_cotisation (fk_adherent,dateadh); +ALTER TABLE llx_subscription ADD UNIQUE INDEX uk_subscription (fk_adherent,dateadh); diff --git a/htdocs/install/mysql/tables/llx_cotisation.sql b/htdocs/install/mysql/tables/llx_subscription.sql similarity index 95% rename from htdocs/install/mysql/tables/llx_cotisation.sql rename to htdocs/install/mysql/tables/llx_subscription.sql index 69b1b4167e0..3f54e487060 100644 --- a/htdocs/install/mysql/tables/llx_cotisation.sql +++ b/htdocs/install/mysql/tables/llx_subscription.sql @@ -16,7 +16,7 @@ -- -- =================================================================== -create table llx_cotisation +create table llx_subscription ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -24,7 +24,7 @@ create table llx_cotisation fk_adherent integer, dateadh datetime, datef date, - cotisation real, + subscription real, fk_bank integer DEFAULT NULL, note text )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_user.key.sql b/htdocs/install/mysql/tables/llx_user.key.sql index 49916b68cb8..82d5f28ef06 100644 --- a/htdocs/install/mysql/tables/llx_user.key.sql +++ b/htdocs/install/mysql/tables/llx_user.key.sql @@ -21,8 +21,8 @@ ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_login (login, entity); -ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc); +ALTER TABLE llx_user ADD INDEX idx_user_fk_societe (fk_soc); ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_socpeople (fk_socpeople); ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_fk_member (fk_member); -ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_api_key (api_key); +ALTER TABLE llx_user ADD UNIQUE INDEX uk_user_api_key (api_key); diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 6b3c5b83f6d..15461072b4a 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -78,7 +78,9 @@ create table llx_user nb_holiday integer DEFAULT 0, thm double(24,8), tjm double(24,8), - salary double(24,8), - salaryextra double(24,8), - weeklyhours double(16,8) + + salary double(24,8), -- denormalized value coming from llx_user_employment + salaryextra double(24,8), -- denormalized value coming from llx_user_employment + dateemployment date, -- denormalized value coming from llx_user_employment + weeklyhours double(16,8) -- denormalized value coming from llx_user_employment )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_user_employment.key.sql b/htdocs/install/mysql/tables/llx_user_employment.key.sql new file mode 100644 index 00000000000..fd0aa62567c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_user_employment.key.sql @@ -0,0 +1,21 @@ +-- ============================================================================ +-- Copyright (C) 2016 Laurent Destailleur +-- +-- 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 . +-- +-- =========================================================================== + +ALTER TABLE llx_user_employment ADD UNIQUE INDEX uk_user_employment (ref,entity); + +ALTER TABLE llx_user_employment ADD CONSTRAINT fk_user_employment_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); diff --git a/htdocs/install/mysql/tables/llx_user_employment.sql b/htdocs/install/mysql/tables/llx_user_employment.sql new file mode 100644 index 00000000000..5c6d65a02c2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_user_employment.sql @@ -0,0 +1,39 @@ +-- ============================================================================ +-- Copyright (C) 2016 Laurent Destailleur +-- +-- 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 . +-- +-- This table can be used to store employee working contracts +-- =========================================================================== + +create table llx_user_employment +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + ref varchar(50), -- reference + ref_ext varchar(50), -- reference into an external system (not used by dolibarr) + fk_user integer, + datec datetime, + tms timestamp, + fk_user_creat integer, + fk_user_modif integer, + job varchar(128), -- job position. may be a dictionnary + status integer NOT NULL, -- draft, active, closed + salary double(24,8), -- last and current value stored into llx_user + salaryextra double(24,8), -- last and current value stored into llx_user + weeklyhours double(16,8) -- last and current value stored into llx_user + dateemployment date, -- last and current value stored into llx_user + dateemploymentend date, -- last and current value stored into llx_user +)ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_pages.sql index 28f0c870dea..f1ea66bb56a 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.sql +++ b/htdocs/install/mysql/tables/llx_website_pages.sql @@ -25,7 +25,7 @@ CREATE TABLE llx_website_page title varchar(255), description varchar(255), keywords varchar(255), - content text, + content mediumtext, -- text is not enough in size status integer, date_creation datetime, date_modification datetime, diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index cbacf7454c7..b54dbbbb00f 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -86,7 +86,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_contrat_extrafields CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_contratdet FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_contratdet_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_contratdet_log FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cotisation FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_subscription FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_deplacement FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 4b45dfae3e3..96cc1c4fdcf 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -249,7 +249,7 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $res=dol_include_once("/core/modules/".$file); $res=activateModule($modtoactivatenew,1); - if (! $result) print 'ERROR in activating module file='.$file; + if (! empty($res['errors'])) print 'ERROR in activating module file='.$file; } } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 74e3af98249..8db34216f18 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -397,27 +397,38 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) // Reload menus (this must be always and only into last targeted version) migrate_reload_menu($db,$langs,$conf,$versionto); } - + // Scripts for last version $afterversionarray=explode('.','3.9.9'); $beforeversionarray=explode('.','4.0.9'); if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) { migrate_directories($db,$langs,$conf,'/fckeditor','/medias'); - - // Reload modules (this must be always and only into last targeted version) - $listofmodule=array( - 'MAIN_MODULE_BARCODE'=>'newboxdefonly', - 'MAIN_MODULE_CRON'=>'newboxdefonly', - 'MAIN_MODULE_FACTURE'=>'newboxdefonly', - 'MAIN_MODULE_PRINTING'=>'newboxdefonly', - ); - migrate_reload_modules($db,$langs,$conf,$listofmodule); - - // Reload menus (this must be always and only into last targeted version) - migrate_reload_menu($db,$langs,$conf,$versionto); } + // Scripts for last version + $afterversionarray=explode('.','4.0.9'); + $beforeversionarray=explode('.','5.0.9'); + if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) + { + // Migrate to add entity value into llx_societe_remise + migrate_remise_entity($db,$langs,$conf); + + // Migrate to add entity value into llx_societe_remise_except + migrate_remise_except_entity($db,$langs,$conf); + + // Reload modules (this must be always and only into last targeted version) + $listofmodule=array( + 'MAIN_MODULE_BARCODE'=>'newboxdefonly', + 'MAIN_MODULE_CRON'=>'newboxdefonly', + 'MAIN_MODULE_FACTURE'=>'newboxdefonly', + 'MAIN_MODULE_PRINTING'=>'newboxdefonly', + ); + migrate_reload_modules($db,$langs,$conf,$listofmodule); + + // Reload menus (this must be always and only into last targeted version) + migrate_reload_menu($db,$langs,$conf,$versionto); + } // Can force activation of some module during migration with third paramater = MAIN_MODULE_XXX,MAIN_MODULE_YYY,... if ($enablemodules) @@ -431,8 +442,8 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) } migrate_reload_modules($db,$langs,$conf,$listofmodules,1); } - - + + print '
    '.$langs->trans("MigrationFinished").''; // On commit dans tous les cas. @@ -1329,10 +1340,10 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf) function migrate_price_facture($db,$langs,$conf) { $err=0; - + $tmpmysoc=new Societe($db); $tmpmysoc->setMysoc($conf); - + $db->begin(); print ''; @@ -1449,7 +1460,7 @@ function migrate_price_propal($db,$langs,$conf) { $tmpmysoc=new Societe($db); $tmpmysoc->setMysoc($conf); - + $db->begin(); print ''; @@ -1648,7 +1659,7 @@ function migrate_price_commande($db,$langs,$conf) $tmpmysoc=new Societe($db); $tmpmysoc->setMysoc($conf); - + print ''; print '
    '; @@ -1762,10 +1773,10 @@ function migrate_price_commande($db,$langs,$conf) function migrate_price_commande_fournisseur($db,$langs,$conf) { $db->begin(); - + $tmpmysoc=new Societe($db); $tmpmysoc->setMysoc($conf); - + print ''; print '
    '; @@ -3659,6 +3670,196 @@ function migrate_event_assignement($db,$langs,$conf) print ''; } +/** + * Migrate to add entity value into llx_societe_remise + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void + */ +function migrate_remise_entity($db,$langs,$conf) +{ + print ''; + + print '
    '; + print ''.$langs->trans('MigrationRemiseEntity')."
    \n"; + + $error = 0; + + dolibarr_install_syslog("upgrade2::migrate_remise_entity"); + + $db->begin(); + + $sqlSelect = "SELECT sr.rowid, s.entity"; + $sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise as sr, ".MAIN_DB_PREFIX."societe as s"; + $sqlSelect.= " WHERE sr.fk_soc = s.rowid and sr.entity != s.entity"; + + //print $sqlSelect; + + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise SET"; + $sqlUpdate.= " entity = " . $obj->entity; + $sqlUpdate.= " WHERE rowid = " . $obj->rowid; + + $result=$db->query($sqlUpdate); + if (! $result) + { + $error++; + dol_print_error($db); + } + + print ". "; + $i++; + } + } + else + { + print $langs->trans('AlreadyDone')."
    \n"; + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + $db->rollback(); + } + + + print ''; +} + +/** + * Migrate to add entity value into llx_societe_remise_except + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void + */ +function migrate_remise_except_entity($db,$langs,$conf) +{ + print ''; + + print '
    '; + print ''.$langs->trans('MigrationRemiseExceptEntity')."
    \n"; + + $error = 0; + + dolibarr_install_syslog("upgrade2::migrate_remise_except_entity"); + + $db->begin(); + + $sqlSelect = "SELECT sr.rowid, sr.fk_soc, sr.fk_facture_source, sr.fk_facture, sr.fk_facture_line"; + $sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; + //print $sqlSelect; + + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture)) + { + $fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture); + + $sqlSelect2 = "SELECT f.entity"; + $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sqlSelect2.= " WHERE f.rowid = " . $fk_facture; + } + else if (!empty($obj->fk_facture_line)) + { + $sqlSelect2 = "SELECT f.entity"; + $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; + $sqlSelect2.= " WHERE fd.rowid = " . $obj->fk_facture_line; + $sqlSelect2.= " AND fd.fk_facture = f.rowid"; + } + else + { + $sqlSelect2 = "SELECT s.entity"; + $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sqlSelect2.= " WHERE s.rowid = " . $obj->fk_soc; + } + + $resql2 = $db->query($sqlSelect2); + if ($resql2) + { + if ($db->num_rows($resql2) > 0) + { + $obj2 = $db->fetch_object($resql2); + + $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except SET"; + $sqlUpdate.= " entity = " . $obj2->entity; + $sqlUpdate.= " WHERE rowid = " . $obj->rowid; + + $result=$db->query($sqlUpdate); + if (! $result) + { + $error++; + dol_print_error($db); + } + } + } + else + { + $error++; + dol_print_error($db); + } + + print ". "; + $i++; + } + } + else + { + print $langs->trans('AlreadyDone')."
    \n"; + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + $db->rollback(); + } + + + print ''; +} + /** * Migration directory * @@ -3826,7 +4027,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled $mod=null; - + if ($moduletoreload == 'MAIN_MODULE_AGENDA') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); @@ -3999,7 +4200,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) } if (! empty($mod) && is_object($mod)) - { + { print ''; print ''.$langs->trans('Upgrade').': '; print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated @@ -4031,7 +4232,7 @@ function migrate_reload_menu($db,$langs,$conf,$versionto) $versiontoarray=explode('.',$versionto); - // Migration required when target version is between + // Migration required when target version is between $afterversionarray=explode('.','2.8.9'); $beforeversionarray=explode('.','2.9.9'); if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) @@ -4039,7 +4240,7 @@ function migrate_reload_menu($db,$langs,$conf,$versionto) $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers } - // Migration required when target version is between + // Migration required when target version is between $afterversionarray=explode('.','3.1.9'); $beforeversionarray=explode('.','3.2.9'); if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) @@ -4054,7 +4255,7 @@ function migrate_reload_menu($db,$langs,$conf,$versionto) { $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers } - + foreach ($listofmenuhandler as $key => $val) { print ''; diff --git a/htdocs/langs/ar_SA/admin.lang b/htdocs/langs/ar_SA/admin.lang index 7a74e18dbf0..b92401e009e 100644 --- a/htdocs/langs/ar_SA/admin.lang +++ b/htdocs/langs/ar_SA/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=اسم الملف ومسار YouCanUseDOL_DATA_ROOT=يمكنك استخدام DOL_DATA_ROOT / dolibarr.log لملف الدخول في Dolibarr "وثائق" دليل. يمكنك أن تحدد مسارا مختلفا لتخزين هذا الملف. ErrorUnknownSyslogConstant=ثابت %s ليس ثابت سيسلوغ معروفة OnlyWindowsLOG_USER=نوافذ يعتمد فقط LOG_USER -SyslogSentryDSN=ترقب DSN -SyslogSentryFromProject=DSN من مشروع ترقب بك ##### Donations ##### DonationsSetup=وحدة الإعداد للتبرع DonationsReceiptModel=قالب من استلام التبرع diff --git a/htdocs/langs/bg_BG/admin.lang b/htdocs/langs/bg_BG/admin.lang index f67745edb12..9b158ca8a6d 100644 --- a/htdocs/langs/bg_BG/admin.lang +++ b/htdocs/langs/bg_BG/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Име на файла и пътя YouCanUseDOL_DATA_ROOT=Можете да използвате DOL_DATA_ROOT / dolibarr.log за лог файл в Dolibarr директория "документи". Можете да зададете различен път, за да се съхранява този файл. ErrorUnknownSyslogConstant=Постоянни %s не е известен Syslog постоянно OnlyWindowsLOG_USER=Windows поддържа само LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Настройка на модул Дарение DonationsReceiptModel=Шаблон на получаване на дарение diff --git a/htdocs/langs/bn_BD/admin.lang b/htdocs/langs/bn_BD/admin.lang index f6a9f3010da..af313850ba1 100644 --- a/htdocs/langs/bn_BD/admin.lang +++ b/htdocs/langs/bn_BD/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/bs_BA/admin.lang b/htdocs/langs/bs_BA/admin.lang index 68d33510781..66732bca8db 100644 --- a/htdocs/langs/bs_BA/admin.lang +++ b/htdocs/langs/bs_BA/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang index 190e14dca05..7cb8f45783a 100644 --- a/htdocs/langs/ca_ES/admin.lang +++ b/htdocs/langs/ca_ES/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Nom i ruta de l'arxiu YouCanUseDOL_DATA_ROOT=Utilitza DOL_DATA_ROOT/dolibarr.log per un fitxer de registre en la carpeta documents de Dolibarr. Tanmateix, es pot definir una carpeta diferent per guardar aquest fitxer. ErrorUnknownSyslogConstant=La constant %s no és una constant syslog coneguda OnlyWindowsLOG_USER=Windows només suporta LOG_USER -SyslogSentryDSN=DSN Sentry -SyslogSentryFromProject=DSN del teu projecte Sentry ##### Donations ##### DonationsSetup=Configuració del mòdul donacions DonationsReceiptModel=Plantilla de rebut de donació diff --git a/htdocs/langs/cs_CZ/admin.lang b/htdocs/langs/cs_CZ/admin.lang index 78fa7604ba5..aec2797976b 100644 --- a/htdocs/langs/cs_CZ/admin.lang +++ b/htdocs/langs/cs_CZ/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Název souboru a cesta YouCanUseDOL_DATA_ROOT=Můžete použít DOL_DATA_ROOT / dolibarr.log pro soubor protokolu Dolibarr "Dokumenty" adresáře. Můžete nastavit jinou cestu k uložení tohoto souboru. ErrorUnknownSyslogConstant=Konstantní %s není známo, Syslog konstantní OnlyWindowsLOG_USER=Windows podporuje pouze LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Darování modul nastavení DonationsReceiptModel=Vzor darovací přijetí diff --git a/htdocs/langs/da_DK/admin.lang b/htdocs/langs/da_DK/admin.lang index 225979662f6..5d66d64c891 100644 --- a/htdocs/langs/da_DK/admin.lang +++ b/htdocs/langs/da_DK/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Filnavn og sti YouCanUseDOL_DATA_ROOT=Du kan bruge DOL_DATA_ROOT / dolibarr.log for en logfil i Dolibarr "dokumenter" mappen. Du kan indstille en anden vej til at gemme denne fil. ErrorUnknownSyslogConstant=Konstant %s er ikke en kendt syslog konstant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation modul opsætning DonationsReceiptModel=Skabelon for donationen modtagelse diff --git a/htdocs/langs/de_DE/admin.lang b/htdocs/langs/de_DE/admin.lang index 974c8973461..4697482aa28 100644 --- a/htdocs/langs/de_DE/admin.lang +++ b/htdocs/langs/de_DE/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Dateiname und-pfad YouCanUseDOL_DATA_ROOT=Sie können DOL_DATA_ROOT/dolibarr.log als Protokolldatei in Ihrem Dokumentenverzeichnis verwenden. Bei Bedarf können Sie auch den Pfad der Datei anpassen. ErrorUnknownSyslogConstant=Konstante %s ist nicht als Protokoll-Konstante definiert OnlyWindowsLOG_USER=Windows unterstützt nur LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN Ihres Sentry Projekts ##### Donations ##### DonationsSetup=Spendenmoduleinstellungen DonationsReceiptModel=Vorlage für Spendenquittungen diff --git a/htdocs/langs/el_GR/admin.lang b/htdocs/langs/el_GR/admin.lang index a433818e4a6..5413158e27c 100644 --- a/htdocs/langs/el_GR/admin.lang +++ b/htdocs/langs/el_GR/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index a663d683fe3..f3571d14ea7 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -29,7 +29,7 @@ NewAccount=New accounting account Create=Create CreateMvts=Create movement UpdateMvts=Modification of a movement -WriteBookKeeping=Record accounts in general ledger +WriteBookKeeping=Write records in general ledger Bookkeeping=General ledger AccountBalance=Account balance @@ -54,9 +54,10 @@ ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the breakdown pages " ACCOUNTING_LENGTH_DESCRIPTION=Length for displaying product & services description in listings (Best = 50) ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT=Length for displaying product & services account description form in listings (Best = 50) -ACCOUNTING_LENGTH_GACCOUNT=Length of the general accounts -ACCOUNTING_LENGTH_AACCOUNT=Length of the third party accounts -ACCOUNTING_MANAGE_ZERO=Manage the zero at the end of an accounting account. Needed by some countries. Disable by default. Be careful with the function of length of the accounts. +ACCOUNTING_LENGTH_GACCOUNT=Length of the general accounting accounts +ACCOUNTING_LENGTH_AACCOUNT=Length of the third party accounting accounts +ACCOUNTING_MANAGE_ZERO=Manage the zero at the end of an accounting account. Needed by some countries. Disable by default. Be careful with the function "length of the accounts". +BANK_DISABLE_DIRECT_INPUT=Disable free input of bank transactions (Enabled by default with this module). ACCOUNTING_SELL_JOURNAL=Sell journal ACCOUNTING_PURCHASE_JOURNAL=Purchase journal @@ -88,7 +89,8 @@ NotMatch=Not Set DeleteMvt=Delete general ledger lines DelYear=Year to delete DelJournal=Journal to delete -ConfirmDeleteMvt=This will delete all line of of the general ledger for year and/or from a specifics journal +ConfirmDeleteMvt=This will delete all lines of the general ledger for year and/or from a specifics journal +ConfirmDeleteMvtPartial=This will delete the selected line(s) of the general ledger DelBookKeeping=Delete the records of the general ledger @@ -115,17 +117,20 @@ Pcgtype=Class of account Pcgsubtype=Under class of account Accountparent=Root of the account -DescVentilCustomer=Consult here the annual breakdown accounting of your invoices customers TotalVente=Total turnover before tax TotalMarge=Total sales margin -DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their accounting account -DescVentilTodoCustomer=Ventilate your lines of customer invoice with an accounting account + +DescVentilCustomer=Consult here the list of customer invoice lines binded (or not) to a product bookkeeping account +DescVentilMore=In most cases, if you use predefined products or services and you set the account number on the product/service card, the application will be able to make all the binding between your invoice lines and the bookkeeping account of your chart of accounts, just in one click with the button "%s". If account was not set on product/service cards or if you still has some lines not binded to any account, you will have to make a manual binding from the menu "%s". +DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their product bookkeeping account +DescVentilTodoCustomer=Bind your lines of customer invoice with a product bookkeeping account ChangeAccount=Change the accounting account for lines selected by the account: Vide=- -DescVentilSupplier=Consult here the annual breakdown accounting of your invoices suppliers -DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account +DescVentilSupplier=Consult here the list of supplier invoice lines binded or not yet binded to a product bookkeeping account +DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their bookkeeping account -ValidateHistory=Validate Automatically +ValidateHistory=Bind Automatically +AutomaticBindingDone=Automatic binding done ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s @@ -158,6 +163,8 @@ OptionModeProductSell=Mode sales OptionModeProductBuy=Mode purchases OptionModeProductSellDesc=Show all products with no accounting account defined for sales. OptionModeProductBuyDesc=Show all products with no accounting account defined for purchases. +CleanFixHistory=Remove accountancy code from lines that not exists into charts of account +CleanHistory=Reset all bindings for selected year ## Dictionary Range=Range of accounting account @@ -168,3 +175,8 @@ Formula=Formula ErrorNoAccountingCategoryForThisCountry=No accounting category are available for this country ExportNotSupported=The export format setuped is not supported into this page BookeppingLineAlreayExists=Lines already existing into bookeeping + + +Binded=Lines binded +To bind=Lines to bind + diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1e2e3e68291..626af0340a2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -8,11 +8,16 @@ VersionExperimental=Experimental VersionDevelopment=Development VersionUnknown=Unknown VersionRecommanded=Recommended -FileCheck=Files Integrity +FileCheck=Files integrity checker +FileCheckDesc=This tool allows you to check the integrity of files of your application, comparing each files with the official ones. You can use this tool to detect if some files were modified by a hacker for example. +MakeIntegrityAnalysisFrom=Make integrity analysis of application files from +LocalSignature=Embedded local signature (less reliable) +RemoteSignature=Remote distant signature (more reliable) FilesMissing=Missing Files FilesUpdated=Updated Files -FileCheckDolibarr=Check Dolibarr Files Integrity -XmlNotFound=Xml File of Dolibarr Integrity Not Found +FileCheckDolibarr=Check integrity of application files +AvailableOnlyOnPackagedVersions=The local file for integrity checking is only available when application is installed from a certified package +XmlNotFound=Xml Integrity File of application not found SessionId=Session ID SessionSaveHandler=Handler to save sessions SessionSavePath=Storage session localization @@ -49,7 +54,7 @@ ErrorDecimalLargerThanAreForbidden=Error, a precision higher than %s is n DictionarySetup=Dictionary setup Dictionary=Dictionaries Chartofaccounts=Chart of accounts -Fiscalyear=Fiscal years +Fiscalyear=Fiscal year ErrorReservedTypeSystemSystemAuto=Value 'system' and 'systemauto' for type is reserved. You can use 'user' as value to add your own record ErrorCodeCantContainZero=Code can't contain value 0 DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers) @@ -273,6 +278,7 @@ YouCanSubmitFile=For this step, you can send package using this tool: Select mod CurrentVersion=Dolibarr current version CallUpdatePage=Go to the page that updates the database structure and data: %s. LastStableVersion=Latest stable version +LastActivationDate=Last activation date UpdateServerOffline=Update server offline GenericMaskCodes=You may enter any numbering mask. In this mask, the following tags could be used:
    {000000} corresponds to a number which will be incremented on each %s. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros from the left in order to have as many zeros as the mask.
    {000000+000} same as previous but an offset corresponding to the number to the right of the + sign is applied starting on first %s.
    {000000@x} same as previous but the counter is reset to zero when month x is reached (x between 1 and 12, or 0 to use the early months of fiscal year defined in your configuration, or 99 to reset to zero every month). If this option is used and x is 2 or higher, then sequence {yy}{mm} or {yyyy}{mm} is also required.
    {dd} day (01 to 31).
    {mm} month (01 to 12).
    {yy}, {yyyy} or {y} year over 2, 4 or 1 numbers.
    GenericMaskCodes2={cccc} the client code on n characters
    {cccc000} the client code on n characters is followed by a counter dedicated for customer. This counter dedicated to customer is reset at same time than global counter.
    {tttt} The code of thirdparty type on n characters (see dictionary-thirdparty types).
    @@ -331,7 +337,7 @@ UrlGenerationParameters=Parameters to secure URLs SecurityTokenIsUnique=Use a unique securekey parameter for each URL EnterRefToBuildUrl=Enter reference for object %s GetSecuredUrl=Get calculated URL -ButtonHideUnauthorized=Hide buttons for unauthorized actions instead of showing disabled buttons +ButtonHideUnauthorized=Hide buttons to non admin users for unauthorized actions instead of showing greyed disabled buttons OldVATRates=Old VAT rate NewVATRates=New VAT rate PriceBaseTypeToChange=Modify on prices with base reference value defined on @@ -432,8 +438,8 @@ Module55Name=Barcodes Module55Desc=Barcode management Module56Name=Telephony Module56Desc=Telephony integration -Module57Name=Standing orders -Module57Desc=Standing orders and withdrawal management. Also includes generation of SEPA file for european countries. +Module57Name=Direct bank payment orders +Module57Desc=Management of Direct Debit payment orders. It includes generation of SEPA file for european countries. Module58Name=ClickToDial Module58Desc=Integration of a ClickToDial system (Asterisk, ...) Module59Name=Bookmark4u @@ -470,8 +476,8 @@ Module410Name=Webcalendar Module410Desc=Webcalendar integration Module500Name=Special expenses Module500Desc=Management of special expenses (taxes, social or fiscal taxes, dividends) -Module510Name=Salaries -Module510Desc=Management of employees salaries and payments +Module510Name=Employee contracts and salaries +Module510Desc=Management of employees contracts, salaries and payments Module520Name=Loan Module520Desc=Management of loans Module600Name=Notifications @@ -610,10 +616,10 @@ Permission142=Create/modify all projects and tasks (also private projects i am n Permission144=Delete all projects and tasks (also private projects i am not contact for) Permission146=Read providers Permission147=Read stats -Permission151=Read standing orders -Permission152=Create/modify a standing orders request -Permission153=Transmission standing orders receipts -Permission154=Credit/refuse standing orders receipts +Permission151=Read direct debit payment orders +Permission152=Create/modify a direct debit payment orders +Permission153=Send/Transmit direct debit payment orders +Permission154=Record Credits/Rejects of direct debit payment orders Permission161=Read contracts/subscriptions Permission162=Create/modify contracts/subscriptions Permission163=Activate a service/subscription of a contract @@ -1037,9 +1043,17 @@ SendmailOptionNotComplete=Warning, on some Linux systems, to send email from you PathToDocuments=Path to documents PathDirectory=Directory SendmailOptionMayHurtBuggedMTA=Feature to send mails using method "PHP mail direct" will generate a mail message that might be not correctly parsed by some receiving mail servers. Result is that some mails can't be read by people hosted by those bugged platforms. It's case for some Internet providers (Ex: Orange in France). This is not a problem into Dolibarr nor into PHP but onto receiving mail server. You can however add option MAIN_FIX_FOR_BUGGED_MTA to 1 into setup - other to modify Dolibarr to avoid this. However, you may experience problem with other servers that respect strictly the SMTP standard. The other solution (recommended) is to use the method "SMTP socket library" that has no disadvantages. -TranslationSetup=Configuration de la traduction -TranslationDesc=How to set displayed application language
    * Systemwide: menu Home - Setup - Display
    * Per user: User display setup tab of user card (click on username at the top of the screen). -TranslationOverwriteDesc=You can also override strings filling the following table. Choose your language from "%s" dropdown, insert the key string found in the lang file (langs/xx_XX/somefile.lang) into "%s" and your new translation into "%s". +TranslationSetup=Setup of translation +TranslationKeySearch=Search a translation key or string +TranslationOverwriteKey=Overwrite a translation string +TranslationDesc=How to set displayed application language :
    * Systemwide: menu Home - Setup - Display
    * Per user: User display setup tab of user card (click on username at the top of the screen). +TranslationOverwriteDesc=You can also override strings filling the following table. Choose your language from "%s" dropdown, insert the translation key string into "%s" and your new translation into "%s" +TranslationOverwriteDesc2=You can use the other tab to help you know translation key to use +TranslationString=Translation string +CurrentTranslationString=Current translation string +WarningAtLeastKeyOrTranslationRequired=A search criteria is required at least for key or translation string +NewTranslationStringToShow=New translation string to show +OriginalValueWas=The original translation is overwritten. Original value was:

    %s TotalNumberOfActivatedModules=Total number of activated feature modules: %s / %s YouMustEnableOneModule=You must at least enable 1 module ClassNotFoundIntoPathWarning=Class %s not found into PHP path @@ -1319,8 +1333,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt @@ -1343,7 +1355,7 @@ GenbarcodeLocation=Bar code generation command line tool (used by internal engin BarcodeInternalEngine=Internal engine BarCodeNumberManager=Manager to auto define barcode numbers ##### Prelevements ##### -WithdrawalsSetup=Withdrawal module setup +WithdrawalsSetup=Setup of module Direct debit payment orders ##### ExternalRSS ##### ExternalRSSSetup=External RSS imports setup NewRSS=New RSS Feed @@ -1516,6 +1528,7 @@ OpenFiscalYear=Open fiscal year CloseFiscalYear=Close fiscal year DeleteFiscalYear=Delete fiscal year ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ? +ShowFiscalYear=Show fiscal year AlwaysEditable=Can always be edited MAIN_APPLICATION_TITLE=Force visible name of application (warning: setting your own name here may break autofill login feature when using DoliDroid mobile application) NbMajMin=Minimum number of uppercase characters @@ -1613,3 +1626,5 @@ activateModuleDependNotSatisfied=Module "%s" depends on module "%s" that is miss CommandIsNotInsideAllowedCommands=The command you try to run is not inside list of allowed commands defined into parameter $dolibarr_main_restrict_os_commands into conf.php file. LandingPage=Landing page SamePriceAlsoForSharedCompanies=If you use the multicompany module, with the choice "Single price", price will be also the same for all companies if products are shared between environments +ModuleEnabledAdminMustCheckRights=Module has been activated. Permissions for activated module(s) were given to admin users only. You may need to grant permissions to other users manually if necessary. +UserHasNoPermissions=This user has no permission defined diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 819664dfdc4..3cef6fd6c40 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -32,8 +32,8 @@ IbanNotValid=IBAN is Not Valid BIC=BIC/SWIFT number SwiftValid=BIC/SWIFT is Valid SwiftNotValid=BIC/SWIFT is Not Valid -StandingOrders=Standing orders -StandingOrder=Standing order +StandingOrders=Direct Debit orders +StandingOrder=Direct debit order AccountStatement=Account statement AccountStatementShort=Statement AccountStatements=Account statements @@ -78,6 +78,7 @@ AccountToCredit=Account to credit AccountToDebit=Account to debit DisableConciliation=Disable reconciliation feature for this account ConciliationDisabled=Reconciliation feature disabled +LinkedToAConciliatedTransaction=Linked to a conciliated transaction StatusAccountOpened=Open StatusAccountClosed=Closed AccountIdShort=Number @@ -143,3 +144,5 @@ ConfirmRejectCheck=Are you sure you want to mark this check as rejected ? RejectCheckDate=Date the check was returned CheckRejected=Check returned CheckRejectedAndInvoicesReopened=Check returned and invoices reopened +BankAccountModelModule=Document templates for bank accounts +DocumentModelSepaMandate=Template of SEPA mandate. Usefull for european countries in EEC only. \ No newline at end of file diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index f07b069e031..3210c3ff838 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -142,7 +142,7 @@ ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice t BillFrom=From BillTo=To ActionsOnBill=Actions on invoice -RecurringInvoiceTemplate=Recurring invoice +RecurringInvoiceTemplate=Template/Recurring invoice NoQualifiedRecurringInvoiceTemplateFound=No recurring template invoice qualified for generation. FoundXQualifiedRecurringInvoiceTemplate=Found %s recurring template invoice(s) qualified for generation. NotARecurringInvoiceTemplate=Not a recurring template invoice @@ -209,8 +209,8 @@ EscompteOffered=Discount offered (payment before term) EscompteOfferedShort=Discount SendBillRef=Submission of invoice %s SendReminderBillRef=Submission of invoice %s (reminder) -StandingOrders=Standing orders -StandingOrder=Standing order +StandingOrders=Direct debit orders +StandingOrder=Direct debit order NoDraftBills=No draft invoices NoOtherDraftBills=No other draft invoices NoDraftInvoices=No draft invoices @@ -351,8 +351,8 @@ VarAmount=Variable amount (%% tot.) # PaymentType PaymentTypeVIR=Bank transfer PaymentTypeShortVIR=Bank transfer -PaymentTypePRE=Bank's order -PaymentTypeShortPRE=Bank's order +PaymentTypePRE=Direct debit payment order +PaymentTypeShortPRE=Debit payment order PaymentTypeLIQ=Cash PaymentTypeShortLIQ=Cash PaymentTypeCB=Credit card @@ -381,6 +381,7 @@ ExtraInfos=Extra infos RegulatedOn=Regulated on ChequeNumber=Check N° ChequeOrTransferNumber=Check/Transfer N° +ChequeBordereau=Check schedule ChequeMaker=Check/Transfer transmitter ChequeBank=Bank of Check CheckBank=Check @@ -429,6 +430,7 @@ CantRemoveConciliatedPayment=Can't remove conciliated payment PayedByThisPayment=Paid by this payment ClosePaidInvoicesAutomatically=Classify "Paid" all standard, situation or replacement invoices entirely paid. ClosePaidCreditNotesAutomatically=Classify "Paid" all credit notes entirely paid back. +ClosePaidContributionsAutomatically=Classify "Paid" all social or fiscal contributions entirely paid. AllCompletelyPayedInvoiceWillBeClosed=All invoice with no remain to pay will be automatically closed to status "Paid". ToMakePayment=Pay ToMakePaymentBack=Pay back @@ -477,4 +479,6 @@ updatePriceNextInvoiceErrorUpdateline=Error : update price on invoice line : %s ToCreateARecurringInvoice=To create a recurring invoice for this contract, first create this draft invoice, then convert it into an invoice template and define the frequency for generation of future invoices. ToCreateARecurringInvoiceGene=To generate future invoices regularly and manually, just go on menu %s - %s - %s. ToCreateARecurringInvoiceGeneAuto=If you need to have such invoices generated automatically, ask you administrator to enable and setup module %s. Note that both method (manual and automatic) can be used together with no risk of duplication. +DeleteRepeatableInvoice=Delete template invoice +ConfirmDeleteRepeatableInvoice=Are your sure you want to delete the template invoice ? diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 2e85ba36f1f..98970318e85 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -38,7 +38,7 @@ BoxMyLastBookmarks=My latest %s bookmarks BoxOldestExpiredServices=Oldest active expired services BoxLastExpiredServices=Latest %s oldest contacts with active expired services BoxTitleLastActionsToDo=Latest %s actions to do -BoxTitleLastContracts=Latest %s contracts +BoxTitleLastContracts=Latest %s modified contracts BoxTitleLastModifiedDonations=Latest %s modified donations BoxTitleLastModifiedExpenses=Latest %s modified expense reports BoxGlobalActivity=Global activity (invoices, proposals, orders) @@ -81,4 +81,4 @@ ForCustomersInvoices=Customers invoices ForCustomersOrders=Customers orders ForProposals=Proposals LastXMonthRolling=The latest %s month rolling -ChooseBoxToAdd=Add widget to your dashboard... +ChooseBoxToAdd=Add widget to your dashboard diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 0261c0550cc..69db60c0cc3 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -14,7 +14,7 @@ ShoppingCart=Shopping cart NewSell=New sell AddThisArticle=Add this article RestartSelling=Go back on sell -SellFinished=Sell finished +SellFinished=Sale complete PrintTicket=Print ticket NoProductFound=No article found ProductFound=product found diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 976c8a50d93..1008cd5bd68 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -14,6 +14,7 @@ CustomersCategoriesArea=Customers tags/categories area MembersCategoriesArea=Members tags/categories area ContactsCategoriesArea=Contacts tags/categories area AccountsCategoriesArea=Accounts tags/categories area +ProjectsCategoriesArea=Projects tags/categories area SubCats=Subcategories CatList=List of tags/categories NewCategory=New tag/category @@ -36,6 +37,7 @@ ProductHasNoCategory=This product/service is not in any tags/categories CompanyHasNoCategory=This thirdparty is not in any tags/categories MemberHasNoCategory=This member is not in any tags/categories ContactHasNoCategory=This contact is not in any tags/categories +ProjectHasNoCategory=This project is not in any tags/categories ClassifyInCategory=Add to tag/category NotCategorized=Without tag/category CategoryExistsAtSameLevel=This category already exists with this ref @@ -56,12 +58,14 @@ ProductsCategoriesShort=Products tags/categories MembersCategoriesShort=Members tags/categories ContactCategoriesShort=Contacts tags/categories AccountsCategoriesShort=Accounts tags/categories +ProjectsCategoriesShort=Projects tags/categories ThisCategoryHasNoProduct=This category does not contain any product. ThisCategoryHasNoSupplier=This category does not contain any supplier. ThisCategoryHasNoCustomer=This category does not contain any customer. ThisCategoryHasNoMember=This category does not contain any member. ThisCategoryHasNoContact=This category does not contain any contact. ThisCategoryHasNoAccount=This category does not contain any account. +ThisCategoryHasNoProject=This category does not contain any project. CategId=Tag/category id CatSupList=List of supplier tags/categories CatCusList=List of customer/prospect tags/categories @@ -71,6 +75,7 @@ CatContactList=List of contact tags/categories CatSupLinks=Links between suppliers and tags/categories CatCusLinks=Links between customers/prospects and tags/categories CatProdLinks=Links between products/services and tags/categories +CatProJectLinks=Links between projects and tags/categories DeleteFromCat=Remove from tags/category ExtraFieldsCategories=Complementary attributes CategoriesSetup=Tags/categories setup diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 9f2b9bdd516..8e4132ba6f7 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -13,6 +13,8 @@ MenuNewPrivateIndividual=New private individual NewCompany=New company (prospect, customer, supplier) NewThirdParty=New third party (prospect, customer, supplier) CreateDolibarrThirdPartySupplier=Create a third party (supplier) +CreateThirdPartyOnly=Create thirdpary +CreateThirdPartyAndContact=Create a thirdparty + a child contact ProspectionArea=Prospection area IdThirdParty=Id third party IdCompany=Company Id @@ -38,7 +40,7 @@ ThirdPartySuppliers=Suppliers ThirdPartyType=Third party type Company/Fundation=Company/Foundation Individual=Private individual -ToCreateContactWithSameName=Will create automatically a physical contact with same informations +ToCreateContactWithSameName=Will create automatically a contact/address with same information than thirdparty under the thirdparty. In most cases, even if your thirdparty is a physical people, creating a thirdparty alone is enough. ParentCompany=Parent company Subsidiaries=Subsidiaries ReportByCustomers=Report by customers @@ -261,7 +263,9 @@ AddContactAddress=Create contact/address EditContact=Edit contact EditContactAddress=Edit contact/address Contact=Contact +ContactId=Contact id ContactsAddresses=Contacts/Addresses +FromContactName=Name: NoContactDefinedForThirdParty=No contact defined for this third party NoContactDefined=No contact defined DefaultContact=Default contact/address @@ -353,9 +357,9 @@ ExportCardToFormat=Export card to format ContactNotLinkedToCompany=Contact not linked to any third party DolibarrLogin=Dolibarr login NoDolibarrAccess=No Dolibarr access -ExportDataset_company_1=Third parties (Companies/foundations/physical people) and properties +ExportDataset_company_1=Third parties (Companies / foundations / physical people) and properties ExportDataset_company_2=Contacts and properties -ImportDataset_company_1=Third parties (Companies/foundations/physical people) and properties +ImportDataset_company_1=Third parties (Companies / foundations / physical people) and properties ImportDataset_company_2=Contacts/Addresses (of thirdparties or not) and attributes ImportDataset_company_3=Bank details ImportDataset_company_4=Third parties/Sales representatives (Affect sales representatives users to companies) diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 13433dcac3f..3a7cd41386f 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -49,6 +49,8 @@ SocialContribution=Social or fiscal tax SocialContributions=Social or fiscal taxes SocialContributionsDeductibles=Deductible social or fiscal taxes SocialContributionsNondeductibles=Nondeductible social or fiscal taxes +LabelContrib=Label contribution +TypeContrib=Type contribution MenuSpecialExpenses=Special expenses MenuTaxAndDividends=Taxes and dividends MenuSocialContributions=Social/fiscal taxes diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 949703bb06e..6a700aa5760 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -7,7 +7,7 @@ Permission23103 = Delete Scheduled job Permission23104 = Execute Scheduled job # Admin CronSetup= Scheduled job management setup -URLToLaunchCronJobs=URL to check and launch cron jobs if required +URLToLaunchCronJobs=URL to check and launch qualified cron jobs OrToLaunchASpecificJob=Or to check and launch a specific job KeyForCronAccess=Security key for URL to launch cron jobs FileToLaunchCronJobs=Command line to launch cron jobs @@ -76,3 +76,4 @@ UseMenuModuleToolsToAddCronJobs=Go into menu "Home - Admin tools - Scheduled job JobDisabled=Job disabled MakeLocalDatabaseDumpShort=Local database backup MakeLocalDatabaseDump=Create a local database dump +WarningCronDelayed=Attention, for performance purpose, whatever is next date of execution of active jobs, your jobs may be delayed to a maximum of %s hours before being run. diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index acbb0e286b9..8c40a808074 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -174,6 +174,8 @@ ErrorStockIsNotEnoughToAddProductOnOrder=Stock is not enougth for product %s to ErrorStockIsNotEnoughToAddProductOnInvoice=Stock is not enougth for product %s to add it into a new invoice. ErrorStockIsNotEnoughToAddProductOnShipment=Stock is not enougth for product %s to add it into a new shipment. ErrorStockIsNotEnoughToAddProductOnProposal=Stock is not enougth for product %s to add it into a new proposal. +ErrorFailedToLoadLoginFileForMode=Failed to get the login file for mode '%s'. +ErrorModuleNotFound=File of module was not found. # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 69711cb77cc..cbe453ef245 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -191,6 +191,8 @@ MigrationActioncommElement=Update data on actions MigrationPaymentMode=Data migration for payment mode MigrationCategorieAssociation=Migration of categories MigrationEvents=Migration of events to add event owner into assignement table +MigrationRemiseEntity=Update entity field value of llx_societe_remise +MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_except MigrationReloadModule=Reload module %s ShowNotAvailableOptions=Show not available options HideNotAvailableOptions=Hide not available options diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 8acf2b8621b..d9ac8ea0539 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -67,6 +67,7 @@ SelectDate=Select a date SeeAlso=See also %s SeeHere=See here BackgroundColorByDefault=Default background color +FileRenamed=The file was successfully renamed FileUploaded=The file was successfully uploaded FileWasNotUploaded=A file is selected for attachment but was not yet uploaded. Click on "Attach file" for this. NbOfEntries=Nb of entries @@ -582,6 +583,7 @@ NotEnoughPermissions=You don't have permission for this action SessionName=Session name Method=Method Receive=Receive +CompleteOrNoMoreReceptionExpected=Complete or nothing more expected PartialWoman=Partial TotalWoman=Total NeverReceived=Never received @@ -605,6 +607,7 @@ DisabledModules=Disabled modules For=For ForCustomer=For customer Signature=Signature +DateOfSignature=Date of signature HidePassword=Show command with password hidden UnHidePassword=Show real command with clear password Root=Root diff --git a/htdocs/langs/en_US/multicurrency.lang b/htdocs/langs/en_US/multicurrency.lang index b75942ebb44..10d84a5edc6 100644 --- a/htdocs/langs/en_US/multicurrency.lang +++ b/htdocs/langs/en_US/multicurrency.lang @@ -1,4 +1,5 @@ -# ADMIN +# Dolibarr language file - Source file is en_US - multicurrency +MultiCurrency=Multi currency ErrorAddRateFail=Error in added rate ErrorAddCurrencyFail=Error in added currency ErrorDeleteCurrencyFail=Error delete fail diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index a57bce0569f..2c152f2b081 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -157,3 +157,4 @@ OrderCreated=Your orders have been created OrderFail=An error happened during your orders creation CreateOrders=Create orders ToBillSeveralOrderSelectCustomer=To create an invoice for several orders, click first onto customer, then choose "%s". +CloseReceivedSupplierOrdersAutomatically=Close order to "%s" automatically if all products are received. \ No newline at end of file diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 00ccda00bf5..cdf1313509d 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -19,3 +19,4 @@ printQty=Qty: %d AddDispatchBatchLine=Add a line for Shelf Life dispatching WhenProductBatchModuleOnOptionAreForced=When module Lot/Serial is on, increase/decrease stock mode is forced to last choice and can't be edited. Other options can be defined as you want. ProductDoesNotUseBatchSerial=This product does not use lot/serial number +ProductLotSetup=Setup of module lot/serial diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 8c23135ddbd..07dc78881ed 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -70,11 +70,11 @@ ListOfTasks=List of tasks GoToListOfTimeConsumed=Go to list of time consumed GoToListOfTasks=Go to list of tasks ListProposalsAssociatedProject=List of the commercial proposals associated with the project -ListOrdersAssociatedProject=List of customer's orders associated with the project -ListInvoicesAssociatedProject=List of customer's invoices associated with the project -ListPredefinedInvoicesAssociatedProject=List of customer's template invoices associated with project -ListSupplierOrdersAssociatedProject=List of supplier's orders associated with the project -ListSupplierInvoicesAssociatedProject=List of supplier's invoices associated with the project +ListOrdersAssociatedProject=List of customer orders associated with the project +ListInvoicesAssociatedProject=List of customer invoices associated with the project +ListPredefinedInvoicesAssociatedProject=List of customer template invoices associated with project +ListSupplierOrdersAssociatedProject=List of supplier orders associated with the project +ListSupplierInvoicesAssociatedProject=List of supplier invoices associated with the project ListContractAssociatedProject=List of contracts associated with the project ListFichinterAssociatedProject=List of interventions associated with the project ListExpenseReportsAssociatedProject=List of expense reports associated with the project @@ -153,7 +153,7 @@ PlannedWorkload=Planned workload PlannedWorkloadShort=Workload ProjectReferers=Related items ProjectMustBeValidatedFirst=Project must be validated first -FirstAddRessourceToAllocateTime=Associate a resource to allocate time +FirstAddRessourceToAllocateTime=Assign a user resource to task to allocate time InputPerDay=Input per day InputPerWeek=Input per week InputPerAction=Input per action diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index baf8fcde0db..39f6e70aba6 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -45,6 +45,7 @@ PMPValue=Weighted average price PMPValueShort=WAP EnhancedValueOfWarehouses=Warehouses value UserWarehouseAutoCreate=Create a warehouse automatically when creating a user +AllowAddLimitStockByWarehouse=Allow to add limit and desired stock by product and warehouse IndependantSubProductStock=Product stock and subproduct stock are independant QtyDispatched=Quantity dispatched QtyDispatchedShort=Qty dispatched @@ -135,3 +136,8 @@ OpenInternal=Open for internal actions OpenShipping=Open for shippings OpenDispatch=Open for dispatch UseDispatchStatus=Use dispatch status (aprouve/refuse) +OptionMULTIPRICESIsOn=Option "several prices per segment" is on. It means a product has several selling price so value for sell can't be calculated +ProductStockWarehouseCreated=Stock limit for alert and desired optimal stock correctly created +ProductStockWarehouseUpdated=Stock limit for alert and desired optimal stock correctly updated +ProductStockWarehouseDeleted=Stock limit for alert and desired optimal stock correctly deleted +AddNewProductStockWarehouse=Set new limit for alert and desired optimal stock \ No newline at end of file diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang index 909a4d713c1..e39a69a3dbe 100644 --- a/htdocs/langs/en_US/supplier_proposal.lang +++ b/htdocs/langs/en_US/supplier_proposal.lang @@ -47,6 +47,7 @@ DefaultModelSupplierProposalCreate=Default model creation DefaultModelSupplierProposalToBill=Default template when closing a price request (accepted) DefaultModelSupplierProposalClosed=Default template when closing a price request (refused) ListOfSupplierProposal=List of supplier proposal requests +ListSupplierProposalsAssociatedProject=List of supplier proposals associated with project SupplierProposalsToClose=Supplier proposals to close SupplierProposalsToProcess=Supplier proposals to process LastSupplierProposals=Last price requests diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 6e554c6545e..766e4a9bfe9 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -7,13 +7,13 @@ History=History ListOfSuppliers=List of suppliers ShowSupplier=Show supplier OrderDate=Order date -BuyingPriceMin=Minimum purchase price -BuyingPriceMinShort=Min purchase price -TotalBuyingPriceMinShort=Total of subproducts purchase prices -TotalSellingPriceMinShort=Total of subproducts sell prices +BuyingPriceMin=Best buying price +BuyingPriceMinShort=Best buying price +TotalBuyingPriceMinShort=Total of subproducts buying prices +TotalSellingPriceMinShort=Total of subproducts selling prices SomeSubProductHaveNoPrices=Some sub-products have no price defined -AddSupplierPrice=Add supplier price -ChangeSupplierPrice=Change supplier price +AddSupplierPrice=Add buying price +ChangeSupplierPrice=Change buying price ReferenceSupplierIsAlreadyAssociatedWithAProduct=This reference supplier is already associated with a reference: %s NoRecordedSuppliers=No suppliers recorded SupplierPayment=Supplier payment diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index a723053fa43..b0b1d129c25 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -101,4 +101,5 @@ ColorUser=Color of the user DisabledInMonoUserMode=Disabled in maintenance mode UserAccountancyCode=User accountancy code UserLogoff=User logout -UserLogged=User logged \ No newline at end of file +UserLogged=User logged +DateEmployment=Date of Employment \ No newline at end of file diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index a3626c3c5df..463d1c9e81e 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -12,6 +12,7 @@ EditMenu=Edit menu EditPageMeta=Edit Meta EditPageContent=Edit Content Website=Web site +Webpage=Web page AddPage=Add page PreviewOfSiteNotYetAvailable=Preview of your website %s not yet available. You must first add a page. RequestedPageHasNoContentYet=Requested page with id %s has not content yet or cache file .tpl.php was removed. Edit content of page to solve this. @@ -22,4 +23,6 @@ ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs -SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on %s, define here the virtual hostname so the preview will be done using this direct access instead of Dolibarr URLs wrapper. +SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on %s, define here the virtual hostname so the preview can be done also using this direct web server access and not only using Dolibarr server. +PreviewSiteServedByWebServer=Preview %s in a new tab. The %s will be served by an external web server (like Apache, Nginx, IIS). You must instal and setup this server before.
    URL of %s served by external server:
    %s +PreviewSiteServedByDolibarr=Preview %s in a new tab. The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
    The inconvenient is that URL of pages are using path of your Dolibarr.
    URL of %s served by Dolibarr:
    %s diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 54b3de3915b..5030ebffaac 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -1,27 +1,28 @@ # Dolibarr language file - Source file is en_US - withdrawals -CustomersStandingOrdersArea=Customers standing orders area -StandingOrders=Standing orders -StandingOrder=Standing orders -NewStandingOrder=New standing order +CustomersStandingOrdersArea=Direct debit payment orders area +SuppliersStandingOrdersArea=Direct credit payment orders area +StandingOrders=Direct debit payment orders +StandingOrder=Direct debit payment order +NewStandingOrder=New direct debit order StandingOrderToProcess=To process -WithdrawalsReceipts=Withdrawal receipts -WithdrawalReceipt=Withdrawal receipt -LastWithdrawalReceipts=Latest %s withdrawal receipts -WithdrawalsLines=Withdrawal lines -RequestStandingOrderToTreat=Request for standing orders to process -RequestStandingOrderTreated=Request for standing orders processed +WithdrawalsReceipts=Direct debit orders +WithdrawalReceipt=Direct debit order +LastWithdrawalReceipts=Latest %s direct debit files +WithdrawalsLines=Direct debit order lines +RequestStandingOrderToTreat=Request for direct debit payment order to process +RequestStandingOrderTreated=Request for direct debit payment order processed NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines. -NbOfInvoiceToWithdraw=Nb. of invoice with withdraw request -NbOfInvoiceToWithdrawWithInfo=Nb. of invoice with withdraw request for customers having defined bank account information -InvoiceWaitingWithdraw=Invoice waiting for withdraw +NbOfInvoiceToWithdraw=Nb. of invoice with direct debit order +NbOfInvoiceToWithdrawWithInfo=Nb. of customer invoice with direct debit payment orders having defined bank account information +InvoiceWaitingWithdraw=Invoice waiting for direct debit AmountToWithdraw=Amount to withdraw -WithdrawsRefused=Withdraws refused +WithdrawsRefused=Direct debit refused NoInvoiceToWithdraw=No customer invoice in payment mode "withdraw" is waiting. Go on 'Withdraw' tab on invoice card to make a request. ResponsibleUser=Responsible user -WithdrawalsSetup=Withdrawal setup -WithdrawStatistics=Withdraw's statistics -WithdrawRejectStatistics=Withdraw reject's statistics -LastWithdrawalReceipt=Latest %s withdrawal receipts +WithdrawalsSetup=Direct debit payment setup +WithdrawStatistics=Direct debit payment statistics +WithdrawRejectStatistics=Direct debit payment reject statistics +LastWithdrawalReceipt=Latest %s direct debit receipts MakeWithdrawRequest=Make a withdraw request ThirdPartyBankCode=Third party bank code NoInvoiceCouldBeWithdrawed=No invoice withdrawed with success. Check that invoice are on companies with a valid BAN. @@ -46,7 +47,7 @@ StatusRefused=Refused StatusMotif0=Unspecified StatusMotif1=Insufficient funds StatusMotif2=Request contested -StatusMotif3=No Withdrawal order +StatusMotif3=No direct debit payment order StatusMotif4=Customer Order StatusMotif5=RIB unusable StatusMotif6=Account without balance @@ -61,28 +62,42 @@ NotifyCredit=Withdrawal Credit NumeroNationalEmetter=National Transmitter Number WithBankUsingRIB=For bank accounts using RIB WithBankUsingBANBIC=For bank accounts using IBAN/BIC/SWIFT -BankToReceiveWithdraw=Bank account to receive withdraws +BankToReceiveWithdraw=Bank account to receive direct debit CreditDate=Credit on WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country %s (Your country is not supported) ShowWithdraw=Show Withdraw IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one withdrawal payment not yet processed, it won't be set as paid to allow prior withdrawal management. -DoStandingOrdersBeforePayments=This tab allows you to request a standing order. Once done, go into menu Bank->Withdrawal to manage the standing order. When standing order is closed, payment on invoice will be automatically recorded, and invoice closed if remainder to pay is null. +DoStandingOrdersBeforePayments=This tab allows you to request a direct debit payment order. Once done, go into menu Bank->Withdrawal to manage the direct debit payment order. When payment order is closed, payment on invoice will be automatically recorded, and invoice closed if remainder to pay is null. WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" ThisWillAlsoAddPaymentOnInvoice=This will also apply payments to invoices and will classify them as "Paid" StatisticsByLineStatus=Statistics by status of lines -RUM=RUM -RUMWillBeGenerated=RUM number will be generated once bank account information are saved -WithdrawMode=Withdraw mode (FRST or RECUR) +RUM=UMR +RUMLong=Unique Mandate Reference +RUMWillBeGenerated=UMR number will be generated once bank account information are saved +WithdrawMode=Direct debit mode (FRST or RECUR) WithdrawRequestAmount=Withdraw request amount: WithdrawRequestErrorNilAmount=Unable to create withdraw request for nil amount. +SepaMandate=SEPA Direct Debit Mandate +PleaseReturnMandate=Please return this mandate form to +SEPALegalText=By signing this mandate form, you authorize (A) %s to send instructions to your bank to debit your account and (B) your bank to debit your account in accordance with the instructions from %s. As part of your rights, you are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited. Your rights regarding the above mandate are explained in a statement that you can obtain from your bank. +CreditorIdentifier=Creditor Identifier +CreditorName=Creditor’s Name +SEPAFillForm=(B) Please complete all the fields marked * +SEPAFormYourName=Your name +SEPAFormYourBAN=Your Bank Account Name (IBAN) +SEPAFormYourBIC=Your Bank Identifier Code (BIC) +SEPAFrstOrRecur=Type of payment +ModeRECUR=Reccurent payment +ModeFRST=One-off payment +PleaseCheckOne=Please check one only ### Notifications -InfoCreditSubject=Payment of standing order %s by the bank -InfoCreditMessage=The standing order %s has been paid by the bank
    Data of payment: %s -InfoTransSubject=Transmission of standing order %s to bank -InfoTransMessage=The standing order %s has been sent to bank by %s %s.

    +InfoCreditSubject=Payment of direct debit payment order %s by the bank +InfoCreditMessage=The direct debit payment order %s has been paid by the bank
    Data of payment: %s +InfoTransSubject=Transmission of direct debit payment order %s to bank +InfoTransMessage=The direct debit payment order %s has been sent to bank by %s %s.

    InfoTransData=Amount: %s
    Method: %s
    Date: %s -InfoRejectSubject=Standing order refused -InfoRejectMessage=Hello,

    the standing order of invoice %s related to the company %s, with an amount of %s has been refused by the bank.

    --
    %s +InfoRejectSubject=Direct debit payment order refused +InfoRejectMessage=Hello,

    the direct debit payment order of invoice %s related to the company %s, with an amount of %s has been refused by the bank.

    --
    %s ModeWarning=Option for real mode was not set, we stop after this simulation diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index e18f93f65ab..6002180ad09 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -9,4 +9,5 @@ descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice af descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer order is set to paid descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is validated -descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer invoice is validated \ No newline at end of file +descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer invoice is validated +descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify shipped linked source order on shipping validate if quantity shipped is the same as in order \ No newline at end of file diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index ec2ff713c14..51b0257dc74 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Nombre y ruta del archivo YouCanUseDOL_DATA_ROOT=Puede utilizar DOL_DATA_ROOT/dolibarr.log para un registro en el directorio "documentos" de Dolibarr. Sin embargo, puede establecer un directorio diferente para guardar este archivo. ErrorUnknownSyslogConstant=La constante %s no es una constante syslog conocida OnlyWindowsLOG_USER=Windows sólo soporta LOG_USER -SyslogSentryDSN=DSN Sentry -SyslogSentryFromProject=DSN de su proyecto Sentry ##### Donations ##### DonationsSetup=Configuración del módulo donaciones DonationsReceiptModel=Modelo recepción de donaciones diff --git a/htdocs/langs/et_EE/admin.lang b/htdocs/langs/et_EE/admin.lang index 6f9fb7889f5..3a80b113e4f 100644 --- a/htdocs/langs/et_EE/admin.lang +++ b/htdocs/langs/et_EE/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Faili nimi ja rada YouCanUseDOL_DATA_ROOT=Võid kasutada DOL_DATA_ROOT/dolibarr.log Dolibarri "documents" kausta faili salvestamiseks, aga logifaili salvestamiseks võib ka mõnda muud rada kasutada. ErrorUnknownSyslogConstant=Konstant %s ei ole tuntud Syslogi konstant OnlyWindowsLOG_USER=Windows toetab vaid LOG_USER direktiivi -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Annetuste mooduli seadistamine DonationsReceiptModel=Annetuse kviitungi mall diff --git a/htdocs/langs/eu_ES/admin.lang b/htdocs/langs/eu_ES/admin.lang index 3b21ebfb0c2..5bc663a9acc 100644 --- a/htdocs/langs/eu_ES/admin.lang +++ b/htdocs/langs/eu_ES/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Fitxategiaren izena eta kokapena YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=%s konstantea ez da Syslog-eko konstante ezaguna OnlyWindowsLOG_USER=Windows-ek LOG_USER soilik jasaten du -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/fa_IR/admin.lang b/htdocs/langs/fa_IR/admin.lang index a17c57bf92e..b88f676ba69 100644 --- a/htdocs/langs/fa_IR/admin.lang +++ b/htdocs/langs/fa_IR/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=نام فایل و مسیر YouCanUseDOL_DATA_ROOT=شما می توانید DOL_DATA_ROOT / dolibarr.log برای یک فایل در "اسناد" Dolibarr دایرکتوری استفاده کنید. شما می توانید راه های مختلفی را برای ذخیره این فایل را. ErrorUnknownSyslogConstant=٪ ثابت است ثابت های Syslog شناخته نشده است OnlyWindowsLOG_USER=ویندوز تنها پشتیبانی از LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=راه اندازی ماژول کمک مالی DonationsReceiptModel=الگو از دریافت کمک مالی diff --git a/htdocs/langs/fi_FI/admin.lang b/htdocs/langs/fi_FI/admin.lang index 29baca03280..d9a48ec6121 100644 --- a/htdocs/langs/fi_FI/admin.lang +++ b/htdocs/langs/fi_FI/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Tiedoston nimi ja polku YouCanUseDOL_DATA_ROOT=Voit käyttää DOL_DATA_ROOT / dolibarr.log varten lokitiedoston Dolibarr "asiakirjoihin" hakemistoon. Voit valita eri reitin tallentaa tiedoston. ErrorUnknownSyslogConstant=Constant %s ei ole tunnettu syslog vakio OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Lahjoitus-moduulin asetukset DonationsReceiptModel=Malline lahjoituksen vastaanottamisesta diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 0c73888ac90..5be0bbcd50c 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Nom et chemin du fichier YouCanUseDOL_DATA_ROOT=Vous pouvez utiliser DOL_DATA_ROOT/dolibarr.log pour un journal dans le répertoire "documents" de Dolibarr. Vous pouvez néanmoins définir un chemin différent pour stocker ce fichier. ErrorUnknownSyslogConstant=La constante %s n'est pas une constante syslog connue OnlyWindowsLOG_USER=Windows ne prend en charge que LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN de votre projet Sentry ##### Donations ##### DonationsSetup=Configuration du module Dons DonationsReceiptModel=Modèles de reçu de dons diff --git a/htdocs/langs/fr_FR/users.lang b/htdocs/langs/fr_FR/users.lang index 5e549f607a4..1000fd233d4 100644 --- a/htdocs/langs/fr_FR/users.lang +++ b/htdocs/langs/fr_FR/users.lang @@ -100,3 +100,4 @@ WeeklyHours=Heures de travail hebdomadaires ColorUser=Couleur de l'utilisateur DisabledInMonoUserMode=Désactivé en mode maintenance UserAccountancyCode=Code comptable utilisateur +DateEmployment=Date d'embauche diff --git a/htdocs/langs/he_IL/admin.lang b/htdocs/langs/he_IL/admin.lang index 0ae7e3087e7..b541eb5535c 100644 --- a/htdocs/langs/he_IL/admin.lang +++ b/htdocs/langs/he_IL/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=שם קובץ ונתיב YouCanUseDOL_DATA_ROOT=ניתן להשתמש DOL_DATA_ROOT / dolibarr.log עבור קובץ יומן בספרייה Dolibarr "מסמכים". ניתן להגדיר בדרך אחרת כדי לאחסן קובץ זה. ErrorUnknownSyslogConstant=%s קבועים אינו ידוע Syslog מתמיד OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=מודול תרומה ההתקנה DonationsReceiptModel=תבנית של קבלת תרומה diff --git a/htdocs/langs/hr_HR/admin.lang b/htdocs/langs/hr_HR/admin.lang index 370eba7890f..23bcba937c3 100644 --- a/htdocs/langs/hr_HR/admin.lang +++ b/htdocs/langs/hr_HR/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/hu_HU/admin.lang b/htdocs/langs/hu_HU/admin.lang index a415e54b2db..68de4a4e997 100644 --- a/htdocs/langs/hu_HU/admin.lang +++ b/htdocs/langs/hu_HU/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=A fájl nevét és elérési útvonalát YouCanUseDOL_DATA_ROOT=Használhatja DOL_DATA_ROOT / dolibarr.log egy log fájlt Dolibarr "Dokumentumok" mappa. Beállíthatjuk, más utat kell tárolni ezt a fájlt. ErrorUnknownSyslogConstant=Constant %s nem ismert Syslog állandó OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Adomány modul beállítása DonationsReceiptModel=Sablon az adomány átvételét diff --git a/htdocs/langs/id_ID/admin.lang b/htdocs/langs/id_ID/admin.lang index 9eeb4336aee..76e5c7dd3cf 100644 --- a/htdocs/langs/id_ID/admin.lang +++ b/htdocs/langs/id_ID/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/is_IS/admin.lang b/htdocs/langs/is_IS/admin.lang index 0e0003a5055..719f3db339c 100644 --- a/htdocs/langs/is_IS/admin.lang +++ b/htdocs/langs/is_IS/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Skráarnafn og slóði YouCanUseDOL_DATA_ROOT=Þú getur notað DOL_DATA_ROOT / dolibarr.log fyrir annálinn í Dolibarr "skjöl" skrá. Þú getur stillt mismunandi leið til að geyma þessa skrá. ErrorUnknownSyslogConstant=Constant %s er ekki þekktur skrifað fasti OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Safnast mát skipulag DonationsReceiptModel=Snið af málefnið berst diff --git a/htdocs/langs/it_IT/admin.lang b/htdocs/langs/it_IT/admin.lang index f6d4abf3002..db056af6da2 100644 --- a/htdocs/langs/it_IT/admin.lang +++ b/htdocs/langs/it_IT/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Nome file e percorso YouCanUseDOL_DATA_ROOT=È possibile utilizzare DOL_DATA_ROOT/dolibarr.log come file di log per la directory "documenti". È anche possibile impostare un percorso diverso per tale file. ErrorUnknownSyslogConstant=La costante %s è sconosciuta a syslog. OnlyWindowsLOG_USER=Solo utenti Windows supportano LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Impostazioni modulo donazioni DonationsReceiptModel=Modello di ricevuta per donazioni diff --git a/htdocs/langs/ja_JP/admin.lang b/htdocs/langs/ja_JP/admin.lang index 175e20bd67d..496ae5e2ad0 100644 --- a/htdocs/langs/ja_JP/admin.lang +++ b/htdocs/langs/ja_JP/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=ファイル名とパス YouCanUseDOL_DATA_ROOT=あなたがDolibarr "ドキュメント"ディレクトリ内のログ·ファイルのDOL_DATA_ROOT / dolibarr.logを使用することができます。このファイルを格納する別のパスを設定することができます。 ErrorUnknownSyslogConstant=定数%sは知られているSyslogの定数ではありません。 OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=寄付モジュールのセットアップ DonationsReceiptModel=寄付金の領収書のテンプレート diff --git a/htdocs/langs/ka_GE/admin.lang b/htdocs/langs/ka_GE/admin.lang index f6a9f3010da..af313850ba1 100644 --- a/htdocs/langs/ka_GE/admin.lang +++ b/htdocs/langs/ka_GE/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/kn_IN/admin.lang b/htdocs/langs/kn_IN/admin.lang index f6a9f3010da..af313850ba1 100644 --- a/htdocs/langs/kn_IN/admin.lang +++ b/htdocs/langs/kn_IN/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/ko_KR/admin.lang b/htdocs/langs/ko_KR/admin.lang index 59589ffdb76..51c3ca83ff9 100644 --- a/htdocs/langs/ko_KR/admin.lang +++ b/htdocs/langs/ko_KR/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/lo_LA/admin.lang b/htdocs/langs/lo_LA/admin.lang index f58f571f022..3fe74658f4a 100644 --- a/htdocs/langs/lo_LA/admin.lang +++ b/htdocs/langs/lo_LA/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/lt_LT/admin.lang b/htdocs/langs/lt_LT/admin.lang index 3f397d6d39c..4b49ffdbcbc 100644 --- a/htdocs/langs/lt_LT/admin.lang +++ b/htdocs/langs/lt_LT/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Failo pavadinimas ir kelias YouCanUseDOL_DATA_ROOT=Galite naudoti DOL_DATA_ROOT/dolibarr.log prisijungimo failui Dolibarr "dokuments" kataloge. Galite nustatyti kitokį kelią šio failo saugojimui. ErrorUnknownSyslogConstant=Konstanta %s yra nežinoma Syslog konstanta OnlyWindowsLOG_USER=Windows palaiko tik LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Aukų modulio nuostatos DonationsReceiptModel=Aukų įplaukų šablonas diff --git a/htdocs/langs/lv_LV/admin.lang b/htdocs/langs/lv_LV/admin.lang index ebc4a8edb17..b93c6b2b825 100644 --- a/htdocs/langs/lv_LV/admin.lang +++ b/htdocs/langs/lv_LV/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Faila nosaukums un ceļš YouCanUseDOL_DATA_ROOT=Jūs varat izmantot DOL_DATA_ROOT / dolibarr.log uz log failu Dolibarr "dokumenti" direktorijā. Jūs varat iestatīt citu ceļu, lai saglabātu šo failu. ErrorUnknownSyslogConstant=Constant %s nav zināms Syslog konstante OnlyWindowsLOG_USER=Windows atbalsta tikai LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Ziedojumu moduļa uzstādīšana DonationsReceiptModel=Veidne ziedojuma saņemšanu diff --git a/htdocs/langs/mk_MK/admin.lang b/htdocs/langs/mk_MK/admin.lang index f6a9f3010da..af313850ba1 100644 --- a/htdocs/langs/mk_MK/admin.lang +++ b/htdocs/langs/mk_MK/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/nb_NO/admin.lang b/htdocs/langs/nb_NO/admin.lang index 7c027be7c10..a2dc14f9c2c 100644 --- a/htdocs/langs/nb_NO/admin.lang +++ b/htdocs/langs/nb_NO/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Filnavn og bane YouCanUseDOL_DATA_ROOT=Du kan bruke DOL_DATA_ROOT / dolibarr.log som loggfil i Dolibarr "dokumenter"-mappen. Du kan angi en annen bane for å lagre denne filen. ErrorUnknownSyslogConstant=Konstant %s er ikke en kjent syslog-konstant OnlyWindowsLOG_USER=Windows støtter bare LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN fra ditt Sentry-prosjekt ##### Donations ##### DonationsSetup=Oppsett av Donasjonsmodulen DonationsReceiptModel=Mal for donasjonskvittering diff --git a/htdocs/langs/nl_NL/admin.lang b/htdocs/langs/nl_NL/admin.lang index 2608b70280c..3e628eef6e1 100644 --- a/htdocs/langs/nl_NL/admin.lang +++ b/htdocs/langs/nl_NL/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Bestandsnaam en -pad YouCanUseDOL_DATA_ROOT=U kunt DOL_DATA_ROOT/dolibarr.log gebruiken voor een logbestand in de Dolibarr "documenten"-map. U kunt ook een ander pad gebruiken om dit bestand op te slaan. ErrorUnknownSyslogConstant=Constante %s is geen bekende 'syslog' constante OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donatiemoduleinstellingen DonationsReceiptModel=Sjabloon van donatie-ontvangst diff --git a/htdocs/langs/pl_PL/admin.lang b/htdocs/langs/pl_PL/admin.lang index 92efc057076..8b247add6c7 100644 --- a/htdocs/langs/pl_PL/admin.lang +++ b/htdocs/langs/pl_PL/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Nazwa pliku i ścieżka YouCanUseDOL_DATA_ROOT=Możesz użyć DOL_DATA_ROOT / dolibarr.log do pliku w Dolibarr "dokumenty" katalogu. Można ustawić inną ścieżkę do przechowywania tego pliku. ErrorUnknownSyslogConstant=Stała %s nie jest znany syslog stałej OnlyWindowsLOG_USER=System Windows obsługuje tylko LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Darowizna konfiguracji modułu DonationsReceiptModel=Szablon otrzymania wpłaty diff --git a/htdocs/langs/pt_BR/admin.lang b/htdocs/langs/pt_BR/admin.lang index f0cf4fd2bc1..2b58d946b27 100644 --- a/htdocs/langs/pt_BR/admin.lang +++ b/htdocs/langs/pt_BR/admin.lang @@ -1011,7 +1011,6 @@ SyslogFilename=Nome do arquivo e caminho YouCanUseDOL_DATA_ROOT=Você pode usar DOL_DATA_ROOT/dolibarr.log para um arquivo de log no diretório dos "documentos" do Dolibarr. ErrorUnknownSyslogConstant=A Constante %s não é conhecida pelas constantes do Syslog OnlyWindowsLOG_USER=Somente Windows suporta LOG_USER -SyslogSentryFromProject=DSN do seu projeto Sentry DonationsSetup=Configurações do módulo de doações DonationsReceiptModel=Templates de recibos de doação BarcodeSetup=Configurações de código de barras diff --git a/htdocs/langs/pt_PT/admin.lang b/htdocs/langs/pt_PT/admin.lang index 584e47a4f2a..affbb454602 100644 --- a/htdocs/langs/pt_PT/admin.lang +++ b/htdocs/langs/pt_PT/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Nome e caminho do Ficheiro YouCanUseDOL_DATA_ROOT=Pode utilizar DOL_DATA_ROOT/dolibarr.log para um log na pasta 'documentos' de Dolibarr. ErrorUnknownSyslogConstant=A constante %s não é uma constante syslog conhecida OnlyWindowsLOG_USER=O Windows suporta apenas LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Configuração do módulo Bolsas DonationsReceiptModel=Modelo de recibo de doação diff --git a/htdocs/langs/ro_RO/admin.lang b/htdocs/langs/ro_RO/admin.lang index d924f083038..d5e6a80bb97 100644 --- a/htdocs/langs/ro_RO/admin.lang +++ b/htdocs/langs/ro_RO/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Nume fişier şi calea YouCanUseDOL_DATA_ROOT=Puteţi folosi DOL_DATA_ROOT / dolibarr.log pentru un fişier de log în Dolibarr "Documente" director. Aveţi posibilitatea să setaţi o altă cale de a păstra acest fişier. ErrorUnknownSyslogConstant=Constant %s nu este un cunoscut syslog constant OnlyWindowsLOG_USER=Windows suportă numai LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donatii modul de configurare DonationsReceiptModel=Format de donatie la primirea diff --git a/htdocs/langs/ru_RU/admin.lang b/htdocs/langs/ru_RU/admin.lang index f0aa1c1c573..fa286e546d8 100644 --- a/htdocs/langs/ru_RU/admin.lang +++ b/htdocs/langs/ru_RU/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Имя файла и путь YouCanUseDOL_DATA_ROOT=Вы можете использовать DOL_DATA_ROOT / dolibarr.log в лог-файл в Dolibarr "документы" каталог. Вы можете установить различные пути для хранения этого файла. ErrorUnknownSyslogConstant=Постоянная %s не известны журнала постоянная OnlyWindowsLOG_USER=Windows© поддерживает только LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Пожертвования модуль настройки DonationsReceiptModel=Шаблон дарения получения diff --git a/htdocs/langs/sk_SK/admin.lang b/htdocs/langs/sk_SK/admin.lang index 1e5387da6a9..c7df3c85e6c 100644 --- a/htdocs/langs/sk_SK/admin.lang +++ b/htdocs/langs/sk_SK/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Názov súboru a cesta YouCanUseDOL_DATA_ROOT=Môžete použiť DOL_DATA_ROOT / dolibarr.log pre súbor denníka Dolibarr "Dokumenty" adresára. Môžete nastaviť inú cestu na uloženie tohto súboru. ErrorUnknownSyslogConstant=Konštantná %s nie je známe, Syslog konštantný OnlyWindowsLOG_USER=Windows podporuje iba LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Darovanie modul nastavenia DonationsReceiptModel=Vzor darovacej prijatie diff --git a/htdocs/langs/sl_SI/admin.lang b/htdocs/langs/sl_SI/admin.lang index a13d9171f52..93fa19d44be 100644 --- a/htdocs/langs/sl_SI/admin.lang +++ b/htdocs/langs/sl_SI/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Ime datoteke in pot YouCanUseDOL_DATA_ROOT=Za log datoteko v Dolibarr dokumentni mapi lahko uporabite DOL_DATA_ROOT/dolibarr.log. Za shranjevanje te datoteke lahko nastavite tudi drugačno pot. ErrorUnknownSyslogConstant=Konstanta %s ni znana syslog konstanta OnlyWindowsLOG_USER=Windowsi podpirajo samo LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Nastanitev modula za donacije DonationsReceiptModel=Predloga računa za donacijo diff --git a/htdocs/langs/sq_AL/admin.lang b/htdocs/langs/sq_AL/admin.lang index f6a9f3010da..af313850ba1 100644 --- a/htdocs/langs/sq_AL/admin.lang +++ b/htdocs/langs/sq_AL/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/sr_RS/admin.lang b/htdocs/langs/sr_RS/admin.lang index 4734f844851..48d8543e48a 100644 --- a/htdocs/langs/sr_RS/admin.lang +++ b/htdocs/langs/sr_RS/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN iz Vašeg Sentry projekta ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/sv_SE/admin.lang b/htdocs/langs/sv_SE/admin.lang index 74d9efbb531..c5952bf4c84 100644 --- a/htdocs/langs/sv_SE/admin.lang +++ b/htdocs/langs/sv_SE/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Filnamn och sökväg YouCanUseDOL_DATA_ROOT=Du kan använda DOL_DATA_ROOT / dolibarr.log för en loggfil i Dolibarr "dokument" katalogen. Du kan ställa in en annan väg för att lagra den här filen. ErrorUnknownSyslogConstant=Konstant %s är inte en känd syslog konstant OnlyWindowsLOG_USER=Endast Windows stöder LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation modul setup DonationsReceiptModel=Mall för donation kvitto diff --git a/htdocs/langs/sw_SW/admin.lang b/htdocs/langs/sw_SW/admin.lang index f6a9f3010da..af313850ba1 100644 --- a/htdocs/langs/sw_SW/admin.lang +++ b/htdocs/langs/sw_SW/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/th_TH/admin.lang b/htdocs/langs/th_TH/admin.lang index b4b77a62b42..7d084ae4a6f 100644 --- a/htdocs/langs/th_TH/admin.lang +++ b/htdocs/langs/th_TH/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=ชื่อแฟ้มและเส้นทาง YouCanUseDOL_DATA_ROOT=คุณสามารถใช้ DOL_DATA_ROOT / dolibarr.log สำหรับล็อกไฟล์ใน Dolibarr "เอกสาร" ไดเรกทอรี คุณสามารถตั้งค่าเส้นทางที่แตกต่างกันในการจัดเก็บไฟล์นี้ ErrorUnknownSyslogConstant=% s คงไม่ได้เป็นที่รู้จักกันอย่างต่อเนื่อง Syslog OnlyWindowsLOG_USER=Windows เท่านั้นสนับสนุน LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=บริจาคการติดตั้งโมดูล DonationsReceiptModel=แม่แบบที่ได้รับการบริจาค diff --git a/htdocs/langs/tr_TR/admin.lang b/htdocs/langs/tr_TR/admin.lang index 012d30e7f6c..13b648f434a 100644 --- a/htdocs/langs/tr_TR/admin.lang +++ b/htdocs/langs/tr_TR/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Dosya adı ve yolu YouCanUseDOL_DATA_ROOT=Dolibarr’daki “belgeler” dizinindeki bir log (günlük) dosyası için DOL_DATA_ROOT/dolibarr.log u kullanabilirsiniz. Bu dosyayı saklamak için farklı bir yol (path) kullanabilirsiniz. ErrorUnknownSyslogConstant=%s Değişmezi bilinen bir Syslog değişmezi değildir OnlyWindowsLOG_USER=Windows yalnızca LOG_USER'ı destekler -SyslogSentryDSN=Nöbetçi DSN -SyslogSentryFromProject=Nöbetçi projenizdeki DSN ##### Donations ##### DonationsSetup=Bağış modülü kurulumu DonationsReceiptModel=Bağış makbuzu şablonu diff --git a/htdocs/langs/uk_UA/admin.lang b/htdocs/langs/uk_UA/admin.lang index bd02e55c41e..7545c888763 100644 --- a/htdocs/langs/uk_UA/admin.lang +++ b/htdocs/langs/uk_UA/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/uz_UZ/admin.lang b/htdocs/langs/uz_UZ/admin.lang index f6a9f3010da..af313850ba1 100644 --- a/htdocs/langs/uz_UZ/admin.lang +++ b/htdocs/langs/uz_UZ/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/vi_VN/admin.lang b/htdocs/langs/vi_VN/admin.lang index 8d861787181..3a399186d22 100644 --- a/htdocs/langs/vi_VN/admin.lang +++ b/htdocs/langs/vi_VN/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=Tên tập tin và đường dẫn YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=Cài đặt module Tài trợ DonationsReceiptModel=Mẫu biên nhận Tài trợ diff --git a/htdocs/langs/zh_CN/admin.lang b/htdocs/langs/zh_CN/admin.lang index 28a388d42d3..f235df47386 100644 --- a/htdocs/langs/zh_CN/admin.lang +++ b/htdocs/langs/zh_CN/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=文件名称和路径 YouCanUseDOL_DATA_ROOT=您可以使用 DOL_DATA_ROOT/dolibarr.log 来表示“documents”目录下的日志文件。您可以设置不同的路径来保存此文件。 ErrorUnknownSyslogConstant=常量 %s 不是已知的 Syslog 常数 OnlyWindowsLOG_USER=Windows 仅支持 LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=捐赠模块设置 DonationsReceiptModel=捐赠收据模板 diff --git a/htdocs/langs/zh_TW/admin.lang b/htdocs/langs/zh_TW/admin.lang index e1705410fdd..27eea2ef5c6 100644 --- a/htdocs/langs/zh_TW/admin.lang +++ b/htdocs/langs/zh_TW/admin.lang @@ -1311,8 +1311,6 @@ SyslogFilename=文件名稱和路徑 YouCanUseDOL_DATA_ROOT=你可以使用DOL_DATA_ROOT /可在Dolibarr日誌文件dolibarr.log“文件”目錄。你可以設置一個不同的路徑來存儲該文件。 ErrorUnknownSyslogConstant=恆%s不是一個已知的syslog常數 OnlyWindowsLOG_USER=Windows only supports LOG_USER -SyslogSentryDSN=Sentry DSN -SyslogSentryFromProject=DSN from your Sentry project ##### Donations ##### DonationsSetup=捐贈模組設置 DonationsReceiptModel=模板的捐贈收據 diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 906e44fce72..0a587bde8d4 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -302,13 +302,13 @@ if (! defined('NOTOKENRENEWAL')) if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; $_SESSION['newtoken'] = $token; } -if (! empty($conf->global->MAIN_SECURITY_CSRF)) // Check validity of token, only if option enabled (this option breaks some features sometimes) +if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) // Check validity of token, only if option enabled (this option breaks some features sometimes) { - if (isset($_POST['token']) && isset($_SESSION['token'])) + if ($_SERVER['REQUEST_METHOD'] === 'POST') { - if (($_POST['token'] != $_SESSION['token'])) + if (GETPOST('token') != $_SESSION['token']) { - dol_syslog("Invalid token in ".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action').", _POST['token']=".GETPOST('token').", _SESSION['token']=".$_SESSION['token'],LOG_WARNING); + dol_syslog("Invalid token in ".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action').", _POST['token']=".GETPOST('token').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING); //print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers. unset($_POST); } @@ -986,13 +986,14 @@ function top_httphead() * * @param string $head Optionnal head lines * @param string $title HTML title - * @param int $disablejs More content into html header - * @param int $disablehead More content into html header + * @param int $disablejs Disable js output + * @param int $disablehead Disable head output * @param array $arrayofjs Array of complementary js files * @param array $arrayofcss Array of complementary css files + * @param int $disablejmobile Disable jmobile * @return void */ -function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='') +function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disablejmobile=0) { global $user, $conf, $langs, $db; @@ -1048,12 +1049,13 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs else print ''."\n"; // JQuery print ''."\n"; // Tooltip print ''."\n"; // JNotify + /* Removed a old hidden problematic feature never used in Dolibarr. If an external module need datatable, the module must provide all lib it needs and manage version problems with other dolibarr components if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES'))) // jQuery datatables { print ''."\n"; print ''."\n"; print ''."\n"; - } + }*/ if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) // jQuery plugin "mutiselect", "multiple-select", "select2"... { $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT; @@ -1065,7 +1067,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; } // jQuery jMobile - if (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || ! empty($conf->dol_use_jmobile)) + if (! $disablejmobile && (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || ! empty($conf->dol_use_jmobile))) { print ''."\n"; } @@ -1211,6 +1213,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; }*/ // jQuery DataTables + /* Removed a old hidden problematic feature never used in Dolibarr. If an external module need datatable, the module must provide all lib it needs and manage version problems with other dolibarr components if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES'))) { print ''."\n"; @@ -1223,7 +1226,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; print ''."\n"; print ''."\n"; - } + }*/ // jQuery Timepicker if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) { @@ -1237,7 +1240,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; } // jQuery jMobile - if (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || (! empty($conf->dol_use_jmobile) && $conf->dol_use_jmobile > 0)) + if (! $disablejmobile && (! empty($conf->global->MAIN_USE_JQUERY_JMOBILE) || defined('REQUIRE_JQUERY_JMOBILE') || (! empty($conf->dol_use_jmobile) && $conf->dol_use_jmobile > 0))) { // We must force not using ajax because cache of jquery does not load js of other pages. // This also increase seriously speed onto mobile device where complex js code is very slow and memory very low. @@ -1292,16 +1295,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; } - // Raven.js for client-side Sentry logging support - if (array_key_exists('mod_syslog_sentry', $conf->loghandlers)) { - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - if (! defined('DISABLE_JQUERY')) { - print '' . "\n"; - } - } - // Global js function print ''."\n"; print ''."\n"; @@ -1387,23 +1380,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print '' . "\n"; - if ($conf->use_javascript_ajax) - { - // Raven.js for client-side Sentry logging support - if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN)) - { - // Filter out secret key - $dsn = parse_url($conf->global->SYSLOG_SENTRY_DSN); - $public_dsn = $dsn['scheme'] . '://' . $dsn['user'] .'@' . $dsn['host'] . $dsn['path']; - - print '\n"; - } - } - /* * Top menu */ @@ -1598,38 +1574,38 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && $user->rights->societe->lire) { $langs->load("companies"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', $langs->trans("ThirdParties"), 'soc', 'sall', 'T', 'searchleftt', img_object('','company')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', $langs->trans("ThirdParties"), 'maxwidth100', 'sall', 'T', 'searchleftt', img_object('','company')); } if (! empty($conf->societe->enabled) && $user->rights->societe->lire) { $langs->load("companies"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', $langs->trans("Contacts"), 'contact', 'sall', 'A', 'searchleftc', img_object('','contact')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', $langs->trans("Contacts"), 'maxwidth100', 'sall', 'A', 'searchleftc', img_object('','contact')); } if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) ) { $langs->load("products"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/product/list.php', DOL_URL_ROOT.'/product/list.php', $langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall', 'P', 'searchleftp', img_object('','product')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/product/list.php', DOL_URL_ROOT.'/product/list.php', $langs->trans("Products")."/".$langs->trans("Services"), 'maxwidth100', 'sall', 'P', 'searchleftp', img_object('','product')); } if (! empty($conf->projet->enabled) && $user->rights->projet->lire) { $langs->load("projects"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/projet/list.php', DOL_URL_ROOT.'/projet/list.php', $langs->trans("Projects"), 'project', 'search_all', 'Q', 'searchleftproj', img_object('','projectpub')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/projet/list.php', DOL_URL_ROOT.'/projet/list.php', $langs->trans("Projects"), 'maxwidth100', 'search_all', 'Q', 'searchleftproj', img_object('','projectpub')); } if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire) { $langs->load("members"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/list.php', DOL_URL_ROOT.'/adherents/list.php', $langs->trans("Members"), 'member', 'sall', 'M', 'searchleftm', img_object('','user')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/list.php', DOL_URL_ROOT.'/adherents/list.php', $langs->trans("Members"), 'maxwidth100', 'sall', 'M', 'searchleftm', img_object('','user')); } if (! empty($conf->user->enabled) && $user->rights->user->user->lire) { $langs->load("users"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/user/list.php', DOL_URL_ROOT.'/user/list.php', $langs->trans("Users"), 'user', 'sall', 'M', 'searchleftuser', img_object('','user')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/user/list.php', DOL_URL_ROOT.'/user/list.php', $langs->trans("Users"), 'maxwidth100', 'sall', 'M', 'searchleftuser', img_object('','user')); } } @@ -1824,14 +1800,14 @@ function getHelpParamFor($helppagename,$langs) * @param string $urlaction Url post * @param string $urlobject Url of the link under the search box * @param string $title Title search area - * @param string $htmlmodesearch Value to set into parameter "mode_search" ('soc','contact','products','member',...) + * @param string $htmlmorecss Add more css * @param string $htmlinputname Field Name input form * @param string $accesskey Accesskey * @param string $prefhtmlinputname Complement for id to avoid multiple same id in the page * @param string $img Image to use * @return string */ -function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch,$htmlinputname,$accesskey='', $prefhtmlinputname='',$img='') +function printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey='', $prefhtmlinputname='',$img='') { global $conf,$langs; @@ -1841,24 +1817,27 @@ function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch,$htmlinput $ret=''; $ret.='
    '; - $ret.=''; + if (empty($conf->global->MAIN_HTML5_PLACEHOLDER)) + { + $ret.=''; + } $ret.=''; $ret.=''; - $ret.=''; - $ret.='global->MAIN_HTML5_PLACEHOLDER)) $ret.=' style="text-indent: 22px; background-image: url(\''.$img.'\'); background-repeat: no-repeat; background-position: 3px;"'; $ret.=($accesskey?' accesskey="'.$accesskey.'"':''); if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $ret.=' placeholder="'.strip_tags($title).'"'; // Will work only if MAIN_HTML5_PLACEHOLDER is set to 1 else $ret.=' title="'.$langs->trans("SearchOf").''.strip_tags($title).'"'; - $ret.=' name="'.$htmlinputname.'" id="'.$prefhtmlinputname.$htmlinputname.'" size="10" />'; + $ret.=' name="'.$htmlinputname.'" id="'.$prefhtmlinputname.$htmlinputname.'" />'; $ret.=''; $ret.="
    \n"; return $ret; @@ -1940,7 +1919,7 @@ if (! function_exists("llxFooter")) //console.log($(this).parent().parent().find(\'dd ul\')); $(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\'); // Note: Did not find a way to get exact height (value is update at exit) so i calculate a generic from nb of lines - heigthofcontent = 19 * $(this).parent().parent().find(\'dd div ul li\').length; + heigthofcontent = 21 * $(this).parent().parent().find(\'dd div ul li\').length; if (heigthofcontent > 300) heigthofcontent = 300; // limited by max-height on css .dropdown dd ul posbottom = $(this).parent().parent().find(\'dd\').offset().top + heigthofcontent + 8; //console.log(posbottom); diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 0cd8243f7a8..14a5219d31c 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -86,29 +86,34 @@ $text=$langs->trans("Margins"); $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); $picto='margin'; -dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); print '
    '; + +dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); + print ''; -print ''; +print ''; print ''; // Start date print ''; -print ''; -print ''; -print ''; +print ''; print ''; print "
    '.$langs->trans('SalesRepresentative').'
    '.$langs->trans('SalesRepresentative').''; print $form->select_dolusers($agentid, 'agentid', 1, '', $user->rights->margins->read->all ? 0 : 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
    '.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')'; +print ''; $form->select_date($startdate,'startdate','','',1,"sel",1,1); print ''.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')'; +print ''.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')'; $form->select_date($enddate,'enddate','','',1,"sel",1,1); print ''; print ''; print '
    "; + +dol_fiche_end(); + print '
    '; $sql = "SELECT"; @@ -242,17 +247,14 @@ else } $db->free($result); - -llxFooter(); -$db->close(); - -?> - - +'."\n"; + +llxFooter(); +$db->close(); + diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 5daa387dc76..66ade35e09e 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -118,18 +118,20 @@ llxHeader('', $title); // Show tabs $head = marges_prepare_head($user); $picto = 'margin'; -dol_fiche_head($head, $langs->trans('checkMargins'), $title, 0, $picto); print '
    '; + +dol_fiche_head($head, $langs->trans('checkMargins'), $title, 0, $picto); + print ''; // Start date -print ''; -print ''; +print ''; -print ''; -print ''; +print ''; print 'rights->stock->write) +/*TODO if ($user->rights->stock->lire) { print ''."\n"; } - if ($user->rights->stock->delete) + if ($user->rights->stock->supprimer) { print ''."\n"; } +*/ } print ''."\n"; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index a4ea70f9c2d..2b771a9c9aa 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -22,18 +22,6 @@ * Initialy built by build_class_from_table on 2016-05-17 12:22 */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - // Change this following line to use the correct relative path (../, ../../, etc) $res=0; if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory @@ -93,11 +81,11 @@ if ($user->societe_id > 0) } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('productbatchlist')); +$hookmanager->initHooks(array('product_lotlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('productbatch'); +$extralabels = $extrafields->fetch_name_optionals_label('product_lot'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // List of fields to search into when doing a "search in all" @@ -236,7 +224,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."product_lot as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot_extrafields as ef on (u.rowid = ef.fk_object)"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot_extrafields as ef on (t.rowid = ef.fk_object)"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.rowid = t.fk_product"; //$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")"; @@ -289,15 +277,15 @@ if ($resql) $arrayofselected=is_array($toselect)?$toselect:array(); - $params=''; + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_entity != '') $params.= '&search_entity='.urlencode($search_entity); - if ($search_product != '') $params.= '&search_product='.urlencode($search_product); - if ($search_batch != '') $params.= '&search_batch='.urlencode($search_batch); - if ($search_fk_user_creat != '') $params.= '&search_fk_user_creat='.urlencode($search_fk_user_creat); - if ($search_fk_user_modif != '') $params.= '&search_fk_user_modif='.urlencode($search_fk_user_modif); - if ($search_import_key != '') $params.= '&search_import_key='.urlencode($search_import_key); + if ($search_entity != '') $param.= '&search_entity='.urlencode($search_entity); + if ($search_product != '') $param.= '&search_product='.urlencode($search_product); + if ($search_batch != '') $param.= '&search_batch='.urlencode($search_batch); + if ($search_fk_user_creat != '') $param.= '&search_fk_user_creat='.urlencode($search_fk_user_creat); + if ($search_fk_user_modif != '') $param.= '&search_fk_user_modif='.urlencode($search_fk_user_modif); + if ($search_import_key != '') $param.= '&search_import_key='.urlencode($search_import_key); if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields foreach ($search_array_options as $key => $val) @@ -323,7 +311,7 @@ if ($resql) print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); if ($sall) { @@ -355,14 +343,14 @@ if ($resql) // Fields title print ''; - if (! empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'],$_SERVER['PHP_SELF'],'t.entity','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'],$_SERVER['PHP_SELF'],'t.batch','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'],$_SERVER['PHP_SELF'],'t.entity','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'],$_SERVER['PHP_SELF'],'t.batch','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'],$_SERVER['PHP_SELF'],'t.fk_product','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'],$_SERVER['PHP_SELF'],'t.eatby','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'],$_SERVER['PHP_SELF'],'t.sellby','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'],$_SERVER['PHP_SELF'],'t.fk_user_creat','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'],$_SERVER['PHP_SELF'],'t.fk_user_modif','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'],$_SERVER['PHP_SELF'],'t.import_key','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'],$_SERVER['PHP_SELF'],'t.eatby','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'],$_SERVER['PHP_SELF'],'t.sellby','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'],$_SERVER['PHP_SELF'],'t.fk_user_creat','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'],$_SERVER['PHP_SELF'],'t.fk_user_modif','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'],$_SERVER['PHP_SELF'],'t.import_key','',$param,'',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -448,7 +436,8 @@ if ($resql) print ''; print ''."\n"; - + $productlot = new Productlot($db); + $i=0; $var=true; $totalarray=array(); @@ -459,6 +448,9 @@ if ($resql) { $var = !$var; + $productlot->id = $obj->rowid; + $productlot->batch = $obj->batch; + // You can use here results print ''; if (! empty($arrayfields['t.entity']['checked'])) @@ -468,7 +460,7 @@ if ($resql) } if (! empty($arrayfields['t.batch']['checked'])) { - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['t.fk_product']['checked'])) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index ebd9f63f127..e256cfeaab8 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once './lib/replenishment.lib.php'; $langs->load("products"); @@ -53,6 +54,7 @@ $salert = GETPOST('salert', 'alpha'); $mode = GETPOST('mode','alpha'); $fourn_id = GETPOST('fourn_id','int'); +$fk_entrepot = GETPOST('fk_entrepot','int'); $texte = ''; $sortfield = GETPOST('sortfield','alpha'); @@ -250,17 +252,26 @@ if ($action == 'order' && isset($_POST['valid'])) */ $form = new Form($db); +$formproduct = new FormProduct($db); $title = $langs->trans('Status'); $sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,'; $sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; $sql.= ' p.tms as datem, p.duration, p.tobuy,'; -$sql.= ' p.desiredstock, p.seuil_stock_alerte as alertstock,'; +if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { + $sql.= ' '.$db->ifsql("pse.desiredstock IS NULL", "p.desiredstock", "pse.desiredstock").' as desiredstock,'; + $sql.= ' '.$db->ifsql("pse.seuil_stock_alerte IS NULL", "p.seuil_stock_alerte", "pse.seuil_stock_alerte").' as alertstock,'; +} else { + $sql.= ' p.desiredstock, p.seuil_stock_alerte as alertstock,'; +} $sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; $sql.= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s'; $sql.= ' ON p.rowid = s.fk_product'; +if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_warehouse_properties pse ON (p.rowid = pse.fk_product AND pse.fk_entrepot = '.$fk_entrepot.')'; +} $sql.= ' WHERE p.entity IN (' . getEntity("product", 1) . ')'; if ($sall) { $sql .= ' AND (p.ref LIKE "%'.$db->escape($sall).'%" '; @@ -295,7 +306,11 @@ if (!empty($canvas)) $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"'; $sql.= ' GROUP BY p.rowid, p.ref, p.label, p.description, p.price'; $sql.= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; $sql.= ', p.duration, p.tobuy'; -$sql.= ', p.desiredstock, p.seuil_stock_alerte'; +if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { + $sql.= ', desiredstock, alertstock'; +} else { + $sql.= ', p.desiredstock, p.seuil_stock_alerte'; +} $sql.= ', s.fk_product'; if ($usevirtualstock) @@ -331,24 +346,24 @@ if ($usevirtualstock) $sqlReceptionFourn.= " AND fd.fk_product = p.rowid"; $sqlReceptionFourn.= " AND cf.fk_statut IN (3,4))"; - $sql.= ' HAVING ((('.$db->ifsql("p.desiredstock IS NULL", "0", "p.desiredstock").' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' HAVING ((('.$db->ifsql("desiredstock IS NULL", "0", "desiredstock").' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; - $sql.= ' OR (p.seuil_stock_alerte >= 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' OR (alertstock >= 0 AND (alertstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.'))))'; if ($salert == 'on') // Option to see when stock is lower than alert { - $sql.= ' AND (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; + $sql.= ' AND (alertstock > 0 AND (alertstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; $sql.= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))'; $alertchecked = 'checked'; } } else { - $sql.= ' HAVING ((p.desiredstock > 0 AND (p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; - $sql.= ' OR (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; + $sql.= ' HAVING ((desiredstock > 0 AND (desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql.= ' OR (alertstock > 0 AND (alertstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").'))))'; if ($salert == 'on') // Option to see when stock is lower than alert { - $sql.= ' AND (p.seuil_stock_alerte > 0 AND (p.seuil_stock_alerte > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; + $sql.= ' AND (alertstock > 0 AND (alertstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')))'; $alertchecked = 'checked'; } } @@ -384,16 +399,6 @@ $head[1][2] = 'replenishorders'; print load_fiche_titre($langs->trans('Replenishment'), '', 'title_generic.png'); - -print ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''; - dol_fiche_head($head, 'replenish', '', 0, ''); print $langs->trans("ReplenishmentStatusDesc").'
    '."\n"; @@ -401,21 +406,32 @@ if ($usevirtualstock == 1) { print $langs->trans("CurentSelectionMode").': '; print $langs->trans("CurentlyUsingVirtualStock").' - '; - print ''.$langs->trans("UsePhysicalStock").'
    '; + print ''.$langs->trans("UsePhysicalStock").'
    '; } if ($usevirtualstock == 0) { print $langs->trans("CurentSelectionMode").': '; print $langs->trans("CurentlyUsingPhysicalStock").' - '; - print ''.$langs->trans("UseVirtualStock").'
    '; + print ''.$langs->trans("UseVirtualStock").'
    '; } print '
    '."\n"; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print $formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); +print ' '; +print ''; + if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) { $filters = '&sref=' . $sref . '&snom=' . $snom; $filters .= '&sall=' . $sall; $filters .= '&salert=' . $salert; $filters .= '&mode=' . $mode; + $filters .= '&fk_entrepot=' . $fk_entrepot; print_barre_liste( $texte, $page, @@ -432,6 +448,7 @@ if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) { $filters .= (isset($type)?'&type=' . $type:''); $filters .= '&=' . $salert; $filters .= '&mode=' . $mode; + $filters .= '&fk_entrepot=' . $fk_entrepot; print_barre_liste( $texte, $page, @@ -450,11 +467,21 @@ $param = (isset($type)? '&type=' . $type : ''); $param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&salert=' . $salert; $param .= '&sref=' . $sref; $param .= '&mode=' . $mode; +$param .= '&fk_entrepot=' . $fk_entrepot; $stocklabel = $langs->trans('Stock'); if ($usevirtualstock == 1) $stocklabel = $langs->trans('VirtualStock'); if ($usevirtualstock == 0) $stocklabel = $langs->trans('PhysicalStock'); +print ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''; // Lines of title print ''; @@ -622,6 +649,7 @@ if ($num > $conf->liste_limit) $filters .= '&sall=' . $sall; $filters .= '&salert=' . $salert; $filters .= '&mode=' . $mode; + $filters .= '&fk_entrepot=' . $fk_entrepot; print_barre_liste('', $page, 'replenish.php', $filters, $sortfield, $sortorder, '', $num, 0, ''); } else @@ -631,6 +659,7 @@ if ($num > $conf->liste_limit) $filters .= (isset($type)? '&type=' . $type : ''); $filters .= '&salert=' . $salert; $filters .= '&mode=' . $mode; + $filters .= '&fk_entrepot=' . $fk_entrepot; print_barre_liste('', $page, 'replenish.php', $filters, $sortfield, $sortorder, '', $num, 0, ''); } } diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 5ff7dfff7ae..b609e96661a 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -163,11 +163,21 @@ $result = $object->fetch($id,$ref); * View */ -$helpurl=''; -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +$title = $langs->trans('ProductServiceCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label,16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) +{ + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Translation'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) +{ + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Translation'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +} -llxHeader("", $langs->trans("Translation"), $help_url); +llxHeader('', $title, $helpurl); $form = new Form($db); $formadmin=new FormAdmin($db); @@ -236,6 +246,9 @@ else dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); + print '
    '; + + $cnt_trans = 0; if (! empty($object->multilangs)) { @@ -243,8 +256,8 @@ else { $cnt_trans++; $s=picto_from_langcode($key); - print "
    ".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '')."
    "; print '
    ' . $langs->trans('DateStart') . ' (' . $langs->trans("DateValidation") . ')'; +print '' . $langs->trans('DateStart') . ' (' . $langs->trans("DateValidation") . ')'; $form->select_date($startdate, 'startdate', '', '', 1, "sel", 1, 1); print '' . $langs->trans('DateEnd') . ' (' . $langs->trans("DateValidation") . ')'; +print '' . $langs->trans('DateEnd') . ' (' . $langs->trans("DateValidation") . ')'; $form->select_date($enddate, 'enddate', '', '', 1, "sel", 1, 1); print ''; @@ -137,6 +139,9 @@ print '"; +dol_fiche_end(); + + $sql = "SELECT"; $sql .= " f.facnumber, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty"; $sql .= " ,d.fk_product"; @@ -243,11 +248,11 @@ if ($result) { dol_print_error($db); } -dol_fiche_end(); print '
    ' . "\n"; print '
    '; print '
    '; + print ''; $db->free($result); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index b038f083ba1..54b83aca42c 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -73,9 +73,12 @@ $text=$langs->trans("Margins"); $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); $picto='margin'; -dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); + print '
    '; + +dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); + print ''; $client = false; @@ -161,6 +164,9 @@ if (! empty($conf->global->DISPLAY_MARK_RATES)) { } print "
    "; + +dol_fiche_end(); + print '
    '; $sql = "SELECT"; @@ -319,22 +325,19 @@ else } $db->free($result); - -llxFooter(); -$db->close(); - -?> - - +'; + +llxFooter(); +$db->close(); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index b4609633447..7a2ac98a5f8 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -95,26 +95,28 @@ $text=$langs->trans("Margins"); $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); $picto='margin'; -dol_fiche_head($head, 'productMargins', $titre, 0, $picto); print '
    '; + +dol_fiche_head($head, 'productMargins', $titre, 0, $picto); + print ''; if ($id > 0) { - print ''; + print ''; print ''; - print ''; + print ''; print ''; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef"; } else { - print ''; + print ''; print ''; @@ -122,12 +124,13 @@ else { } // Start date -print ''; -print ''; +print ''; +print ''; -print ''; -print ''; +print ''; print 'trans("MyModule")); - - print ''; - print ''; - print ''; - print ''; - - dol_fiche_head(); - - print '
    '.$langs->trans('ChooseProduct/Service').'
    '.$langs->trans('ChooseProduct/Service').''; print $form->select_produits($id,'id','',20,0,1,2,'',1); print '
    '.$langs->trans('AllProducts').'
    '.$langs->trans('AllProducts').'
    '.$langs->trans('ChooseProduct/Service').'
    '.$langs->trans('ChooseProduct/Service').''; print $form->select_produits('','id','',20,0,1,2,'',1); print '
    '.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')'; +print '
    '.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')'; $form->select_date($startdate,'startdate','','',1,"sel",1,1); print ''.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')'; +print ''.$langs->trans('DateEnd').' ('.$langs->trans("DateValidation").')'; $form->select_date($enddate,'enddate','','',1,"sel",1,1); print ''; @@ -141,25 +144,28 @@ print '
    '; print ''; // Total Margin -print ''; // Margin Rate if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - print ''; } // Mark Rate if (! empty($conf->global->DISPLAY_MARK_RATES)) { - print ''; } print "
    '.$langs->trans("TotalMargin").''; +print '
    '.$langs->trans("TotalMargin").''; print ''; // set by jquery (see below) print '
    '.$langs->trans("MarginRate").''; + print '
    '.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
    '.$langs->trans("MarkRate").''; + print '
    '.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
    "; + +dol_fiche_end(); + print ''; $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; @@ -329,25 +335,25 @@ else $db->free($result); -llxFooter(); -$db->close(); - -?> - +print ' +'; + +llxFooter(); +$db->close(); diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 35bd8e85155..f6d94fb8135 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -69,11 +69,21 @@ if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); - $helpurl=''; - if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; - if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('ProductServiceCard'); + $helpurl = ''; + $shortlabel = dol_trunc($object->label,16); + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) + { + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Card'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + } + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) + { + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Card'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + } - llxHeader("", $langs->trans("CardProduct".$object->type), $help_url); + llxHeader('', $title, $helpurl); /* * En mode visu diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 1d4d1f8f0ca..4797f0985e0 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -91,7 +91,9 @@ if ($socid > 0) dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index b1c69268325..dc0acb48d96 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -48,8 +48,8 @@ $object=new Opensurveysondage($db); $result=$object->fetch(0, $numsondage); if ($result <= 0) { - dol_print_error($db,$object->error); - exit; + dol_print_error($db,$object->error); + exit; } $expiredate=dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); @@ -188,10 +188,11 @@ if ($object->fk_user_creat) $userstatic->fetch($object->fk_user_creat); } - +$title = $object->titre." - ".$langs->trans('Card'); +$helpurl = ''; $arrayofjs=array(); $arrayofcss=array('/opensurvey/css/style.css'); -llxHeader('',$object->titre, 0, 0, 0, 0, $arrayofjs, $arrayofcss); +llxHeader('',$title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices @@ -205,7 +206,6 @@ foreach ($toutsujet as $value) $toutsujet=str_replace("@","
    ",$toutsujet); $toutsujet=str_replace("°","'",$toutsujet); - print '
    '."\n"; print ''; @@ -219,7 +219,7 @@ print ''; $linkback = ''.$langs->trans("BackToList").''; // Ref -print ''; +print ''; print ''; @@ -312,7 +312,11 @@ print ''; // Expire date print ''; // Author @@ -439,8 +443,6 @@ if ($object->allow_comments) { print ''; -print '
    '; - -llxFooterSurvey(); +llxFooter(); $db->close(); diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 02952f4bf75..5ad27731d88 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -228,8 +228,7 @@ class Opensurveysondage extends CommonObject $obj = $this->db->fetch_object($resql); $this->id_sondage = $obj->id_sondage; - //For compatibility - $this->ref = $this->id_sondage; + $this->ref = $this->id_sondage; //For compatibility $this->commentaires = $obj->description; // deprecated $this->description = $obj->description; diff --git a/htdocs/opensurvey/img/cancel.png b/htdocs/opensurvey/img/cancel.png deleted file mode 100644 index c149c2bc017..00000000000 Binary files a/htdocs/opensurvey/img/cancel.png and /dev/null differ diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 93ccd93729b..806609ad7cd 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -49,7 +49,7 @@ $nblignes=$object->fetch_lines(); * Actions */ -//Return to the results +// Return to the results if (GETPOST('retoursondage')) { header('Location: results.php?id='.$_GET['id']); exit; @@ -403,9 +403,11 @@ if ($result <= 0) exit; } +$title = $object->titre." - ".$langs->trans('Card'); +$helpurl = ''; $arrayofjs=array(); $arrayofcss=array('/opensurvey/css/style.css'); -llxHeader('',$object->titre, 0, 0, 0, 0, $arrayofjs, $arrayofcss); +llxHeader('',$title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss); // Define format of choices @@ -432,7 +434,7 @@ print '
    '.$langs->trans('Ref').'
    '.$langs->trans('Ref').''; print $form->showrefnav($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage'); print '
    '.$langs->trans('ExpireDate').''; if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire',0,0,0,'',1,0,1); -else print dol_print_date($object->date_fin,'day'); +else +{ + print dol_print_date($object->date_fin,'day'); + if ($object->date_fin && $object->date_fin < dol_now()) print img_warning($langs->trans("Expired")); +} print '
    '; $linkback = ''.$langs->trans("BackToList").''; // Ref -print ''; +print ''; print ''; @@ -541,7 +543,7 @@ if (GETPOST('ajoutsujet')) //ajout d'une date avec creneau horaire print $langs->trans("AddADate") .':

    '."\n"; print ' '."\n"; - print ''."\n"; + print ''."\n"; for ($i = 0; $i < 24; $i++) { print ''."\n"; } print ''."\n"; print ''."\n"; print '

    '. $langs->trans("AddEndHour") .':

    '."\n"; print ''."\n"; print ''."\n"; if ($user->rights->opensurvey->write) { for ($i = 0; isset($toutsujet[$i]); $i++) { - print ''."\n"; + print ''."\n"; } } @@ -652,10 +654,17 @@ if ($object->format=="D") $next = $toutsujet[$i+1]; } - if (isset($toutsujet[$i+1]) && strftime("%Y",$current) == strftime("%Y",$next)){ + $currenty = 0; + if ($current) $currenty=strftime("%Y",$current); + $next = 0; + if ($next) $nexty=strftime("%Y",$next); + if (isset($toutsujet[$i+1]) && ($currenty == $nexty)) + { $colspan++; } else { - print ''."\n"; + print ''."\n"; $colspan=1; } } @@ -786,7 +795,7 @@ while ($compteur < $num) print ''; } print ''; - print ''; + print ''; print "\n"; $var=True; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index a1f19958cc9..0498c32bf05 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2015 Juanjo Menent * @@ -59,6 +59,21 @@ $fieldstosearchall = array( ); +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=""; + $sall=""; + $search_label=""; + $search_status=""; + $search_array_options=array(); +} + /* * View @@ -110,6 +125,10 @@ if ($result) $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_ref) $param.="&search_ref=".$search_ref; + if ($search_label) $param.="&search_label=".$search_label; + if ($search_status) $param.="&search_status=".$search_status; + if ($sall) $param.="&sall=".$sall; print '
    '; print ''; @@ -126,14 +145,14 @@ if ($result) } $moreforfilter=''; - + print '
    '.$langs->trans('Ref').'
    '.$langs->trans('Ref').''; print $form->showrefnav($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage'); print ''.strftime("%Y", $current).''; + if ($current) print strftime("%Y", $current); + print '
    '."\n"; if ($user->rights->opensurvey->write) { - print ''."\n"; + print ''."\n"; } // Name diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index c9ba1324a70..94ec2a7c247 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Marcos García - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015-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 @@ -133,15 +133,15 @@ llxHeader('', $langs->trans("OpenSurvey"), '', "", 0, 0, $arrayofjs, $arrayofcss print load_fiche_titre($langs->trans("CreatePoll").' (1 / 2)'); -//debut du formulaire +// debut du formulaire print '
    '."\n"; dol_fiche_head(); -//Affichage des différents champs textes a remplir +// Affichage des différents champs textes a remplir print ''."\n"; -print ''."\n"; +print ''."\n"; if (! $_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors'); @@ -180,7 +180,7 @@ if ($_SESSION['allow_comments']) $allow_comments = 'checked'; if (isset($_POST['allow_comments'])) $allow_comments=GETPOST('allow_comments')?'checked':''; print ' '.$langs->trans('CanComment').'
    '."\n"; -if ($_SESSION['allow_spy']) $allow_spy = 'checed'; +if ($_SESSION['allow_spy']) $allow_spy = 'checked'; if (isset($_POST['allow_spy'])) $allow_spy=GETPOST('allow_spy')?'checked':''; print ' '.$langs->trans('CanSeeOthersVote').'
    '."\n"; @@ -193,7 +193,7 @@ if (GETPOST('choix_sondage')) } else { - //affichage des boutons pour choisir sondage date ou autre + // affichage des boutons pour choisir sondage date ou autre print '
    '. $langs->trans("PollTitle") .'
    '. $langs->trans("PollTitle") .'
    '."\n"; print ' '."\n"; print ''."\n"; diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 6587e25ecb1..1496bb3552e 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -209,7 +209,7 @@ function showPaypalPaymentUrl($type,$ref) $out='

    '; $out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'
    '; $url=getPaypalPaymentUrl(0,$type,$ref); - $out.='
    '; + $out.='
    '; return $out; } diff --git a/htdocs/product/admin/product_extrafields.php b/htdocs/product/admin/product_extrafields.php index d0e42276880..ca5944c421f 100644 --- a/htdocs/product/admin/product_extrafields.php +++ b/htdocs/product/admin/product_extrafields.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/societe/admin/societe_extrafields.php + * \file htdocs/product/admin/product_extrafields.php * \ingroup societe * \brief Page to setup extra fields of third party */ @@ -73,8 +73,9 @@ else if (empty($conf->service->enabled)) $textobject = $langs->trans('Products'); } -$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; -llxHeader('',$title); +//$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; +$help_url=''; +llxHeader('',$title,$help_url); $linkback=''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/product/admin/product_lot_extrafields.php b/htdocs/product/admin/product_lot_extrafields.php new file mode 100644 index 00000000000..28b4ee7db1d --- /dev/null +++ b/htdocs/product/admin/product_lot_extrafields.php @@ -0,0 +1,123 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2012 Marcos García + * Copyright (C) 2012 Regis Houssin + * + * 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 . + */ + +/** + * \file htdocs/product/admin/product_lot_extrafields.php + * \ingroup societe + * \brief Page to setup extra fields of third party + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("companies"); +$langs->load("admin"); +$langs->load("products"); +$langs->load("productbatch"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='product_lot'; //Must be the $element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$title = $langs->trans('ProductLotSetup'); +$textobject = $langs->trans("Batch"); + +//$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; +$help_url=''; +llxHeader('',$title,$help_url); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($title,$linkback,'title_setup'); + + +$head = product_lot_admin_prepare_head(); + +dol_fiche_head($head, 'attributes', $textobject, 0, 'stock'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; +} + + +/* ************************************************************************** */ +/* */ +/* Creation of an optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
    "; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition of an optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 85990fe1bd4..c399d222177 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -49,6 +49,8 @@ $action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); $price_by_qty_rowid = GETPOST('pbq', 'int'); $finished = GETPOST('finished', 'int'); +$alsoproductwithnosupplierprice = GETPOST('alsoproductwithnosupplierprice', 'int'); + /* * View @@ -157,7 +159,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } echo json_encode($outjson); -} else { +} +else +{ require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; $langs->load("products"); @@ -181,9 +185,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $form = new Form($db); if (empty($mode) || $mode == 1) { // mode=1: customer - $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); + $arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid); } elseif ($mode == 2) { // mode=2: supplier - $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson); + $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, 0, $alsoproductwithnosupplierprice); } $db->close(); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 5d72f67a0eb..cfcf253eb31 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -135,7 +135,7 @@ if (empty($reshook)) // Type if ($action == 'setfk_product_type' && $user->rights->produit->creer) { - $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type')); + $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -169,7 +169,7 @@ if (empty($reshook)) // Barcode type if ($action == 'setfk_barcode_type' && $createbarcode) { - $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type')); + $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -817,12 +817,19 @@ if (empty($reshook)) * View */ -$helpurl=''; -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - -if (isset($_GET['type'])) $title = $langs->trans('CardProduct'.GETPOST('type')); -else $title = $langs->trans('ProductServiceCard'); +$title = $langs->trans('ProductServiceCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label,16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) +{ + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Card'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) +{ + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Card'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +} llxHeader('', $title, $helpurl); @@ -955,7 +962,7 @@ else print '
    '; } @@ -969,7 +976,7 @@ else // Public URL print ''; // Stock min level @@ -1154,7 +1161,11 @@ else dol_fiche_end(); - print '
    '; + print '
    '; + print ''; + print '     '; + print ''; + print '
    '; print ''; } @@ -1257,7 +1268,7 @@ else print ''; } @@ -1273,7 +1284,7 @@ else // Public Url print ''; // Stock @@ -1364,7 +1375,7 @@ else print ''; // Origin country print ''; } @@ -1515,8 +1526,9 @@ else print ''; print ''; print ''; - print ''; + print ''; print ' '; + print ''; } else { @@ -1836,7 +1848,7 @@ print "\n\n"; * All the "Add to" areas */ -if ($object->id && ($action == '' || $action == 'view') && $object->status) +if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) { //Variable used to check if any text is going to be printed $html = ''; @@ -1969,8 +1981,9 @@ if ($action == '' || $action == 'view') $var=true; - $somethingshown=$formfile->show_documents($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang); - + print $formfile->showdocuments($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); + $somethingshown=$formfile->numoffiles; + print '
    '; print '
    '; diff --git a/htdocs/product/class/api_deprecated_product.class.php b/htdocs/product/class/api_deprecated_product.class.php index 2db0699d661..d4ad8335f54 100644 --- a/htdocs/product/class/api_deprecated_product.class.php +++ b/htdocs/product/class/api_deprecated_product.class.php @@ -94,19 +94,19 @@ class ProductApi extends DolibarrApi * * Get a list of products * - * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) - * @param mixed $to_sell Filter products to sell (1) or not to sell (0) - * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param mixed $to_sell Filter products to sell (1) or not to sell (0) + * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * * @return array Array of product objects * * @url GET /product/list */ - function getList($mode=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getList($sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $to_sell='', $to_buy='') { global $db, $conf; $obj_ret = array(); @@ -149,7 +149,7 @@ class ProductApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $product_static = new Product($db); @@ -174,20 +174,20 @@ class ProductApi extends DolibarrApi * * Get a list of products * - * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) - * @param int $category Use this param to filter list by category - * @param mixed $to_sell Filter products to sell (1) or not to sell (0) - * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param int $category Use this param to filter list by category + * @param mixed $to_sell Filter products to sell (1) or not to sell (0) + * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * * @return array Array of product objects * * @url GET /product/list/category/{category} */ - function getByCategory($mode=0, $category=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getByCategory($sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $category=0, $to_sell='', $to_buy='') { global $db, $conf; $obj_ret = array(); @@ -235,7 +235,7 @@ class ProductApi extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $product_static = new Product($db); diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index d6dc8770b23..210ea09d3d3 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -87,18 +87,18 @@ class Products extends DolibarrApi * * Get a list of products * - * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) - * @param int $category Use this param to filter list by category - * @param mixed $to_sell Filter products to sell (1) or not to sell (0) - * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $mode Use this param to filter list (0 for all, 1 for only product, 2 for only service) + * @param int $category Use this param to filter list by category + * @param mixed $to_sell Filter products to sell (1) or not to sell (0) + * @param mixed $to_buy Filter products to buy (1) or not to buy (0) * * @return array Array of product objects */ - function index($mode=0, $category=0, $to_sell='', $to_buy='', $sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "p.ref", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $category=0, $to_sell='', $to_buy='') { global $db, $conf; $obj_ret = array(); @@ -151,7 +151,7 @@ class Products extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $product_static = new Product($db); diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index a69880f7fa5..cedf40678d2 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -144,7 +144,7 @@ class FormProduct * @param string $morecss Add more css classes * @return string HTML select */ - function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='') + function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200') { global $conf,$langs,$user; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f4cf2c994a6..568d7edf1de 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -195,6 +195,8 @@ class Product extends CommonObject var $buyprice; public $fourn_pu; + public $fourn_price_base_type; + /** * @deprecated * @see ref_supplier @@ -926,7 +928,7 @@ class Product extends CommonObject // Delete all child tables if (! $error) { - $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price'); + $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_lot','product_warehouse_properties'); foreach($elements as $table) { if (! $error) @@ -1316,16 +1318,17 @@ class Product extends CommonObject /** - * Read price used by a provider - * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref + * Read price used by a provider. + * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. + * This also set some properties on product like ->buyprice, ->fourn_pu, ... * * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price - * @param double $qty Quantity asked + * @param double $qty Quantity asked or -1 to get first entry found * @param int $product_id Filter on a particular product id - * @param string $fourn_ref Filter on a supplier ref + * @param string $fourn_ref Filter on a supplier ref. 'none' to exclude ref in search. * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) */ - function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0) + function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='') { global $conf; $result = 0; @@ -1335,14 +1338,15 @@ class Product extends CommonObject $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.rowid = ".$prodfournprice; - if ($qty) $sql.= " AND pfp.quantity <= ".$qty; - + if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; + $sql.= " ORDER BY pfp.quantity DESC"; + dol_syslog(get_class($this)."::get_buyprice first search by prodfournprice/qty", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj && $obj->quantity > 0) // If found + if ($obj && $obj->quantity > 0) // If we found a supplier prices from the id of supplier price { if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) { @@ -1360,7 +1364,8 @@ class Product extends CommonObject } } $this->buyprice = $obj->price; // deprecated - $this->fourn_pu = $obj->price / $obj->quantity; // Prix unitaire du produit pour le fournisseur $fourn_id + $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier + $this->fourn_price_base_type = 'HT'; // Price base type $this->ref_fourn = $obj->ref_fourn; // deprecated $this->ref_supplier = $obj->ref_fourn; // Ref supplier $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier @@ -1369,13 +1374,13 @@ class Product extends CommonObject } else // If not found { - // We do a second search by doing a select again but searching with qty, ref and id product + // We do a second search by doing a select again but searching with qty and id product $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'"; - $sql.= " AND pfp.fk_product = ".$product_id; - $sql.= " AND pfp.quantity <= ".$qty; + $sql.= " WHERE pfp.fk_product = ".$product_id; + if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'"; + if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; $sql.= " ORDER BY pfp.quantity DESC"; $sql.= " LIMIT 1"; @@ -1402,8 +1407,9 @@ class Product extends CommonObject } } $this->buyprice = $obj->price; // deprecated - $this->fourn_qty = $obj->quantity; // min quantity for price - $this->fourn_pu = $obj->price / $obj->quantity; // Prix unitaire du produit pour le fournisseur $fourn_id + $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier + $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier + $this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier $this->ref_fourn = $obj->ref_supplier; // deprecated $this->ref_supplier = $obj->ref_supplier; // Ref supplier $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier @@ -1412,7 +1418,7 @@ class Product extends CommonObject } else { - return -1; // Ce produit n'existe pas avec cette ref fournisseur ou existe mais qte insuffisante + return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité. } } else @@ -3175,7 +3181,7 @@ class Product extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; - if ($option == 'supplier') { + if ($option == 'supplier' || $option == 'category') { $link = ''; - } else if ($option == 'category') { - $link = ''; @@ -3276,23 +3280,23 @@ class Product extends CommonObject } if ($mode == 2) { - if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); - if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); + if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); + if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); } if ($mode == 3) { - if ($status == 0) return img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')),'statut5'); - if ($status == 1) return img_picto(($type==0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')),'statut4'); + if ($status == 0) return img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')),'statut5', 'class="pictostatus"'); + if ($status == 1) return img_picto(($type==0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); } if ($mode == 4) { - if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5').' '.($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); - if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4').' '.($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); + if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); + if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); } if ($mode == 5) { - if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')),'statut5'); - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4'); + if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); + if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); } return $langs->trans('Unknown'); } @@ -3727,11 +3731,11 @@ class Product extends CommonObject if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) { $return.= ''; - $return.= 'dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; + $return.= ''; } else { $return.= ''; - $return.= 'dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; + $return.= ''; } if (empty($nolink)) $return.= ''; diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index a65adb1c4b3..e1644c241e5 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -133,10 +133,6 @@ else if($action==='save_composed_product') * View */ -$helpurl=''; -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - $product_fourn = new ProductFournisseur($db); $productstatic = new Product($db); $form = new Form($db); @@ -177,10 +173,22 @@ if ($action == 'search') $resql = $db->query($sql); } -//print $sql; +$title = $langs->trans('ProductServiceCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label,16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) +{ + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('AssociatedProducts'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) +{ + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('AssociatedProducts'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +} -llxHeader("", $langs->trans("CardProduct".$object->type), $helpurl); +llxHeader('', $title, $helpurl); $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); @@ -199,7 +207,7 @@ if ($id > 0 || ! empty($ref)) dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - print '
    '. $langs->trans("CreateSurveyDate") .'
    '.$langs->trans("BarcodeValue").''; $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); - print ''; + print ''; print '
    '.$langs->trans("PublicUrl").''; - print ''; + print ''; print '
    '.$langs->trans("BarcodeValue").''; $tmpcode=isset($_POST['barcode'])?GETPOST('barcode'):$object->barcode; if (empty($tmpcode) && ! empty($modBarCodeProduct->code_auto)) $tmpcode=$modBarCodeProduct->getNextValue($object,$type); - print ''; + print ''; print '
    '.$langs->trans("PublicUrl").''; - print ''; + print ''; print '
    '.$langs->trans("CustomCode").''.$langs->trans("CountryOrigin").''; - print $form->select_country($object->country_id,'country_id'); + print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
    '; + print '
    '; // Nature if($object->type!=Product::TYPE_SERVICE) @@ -240,7 +248,8 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); - + print '
    '; + $prodsfather = $object->getFather(); // Parent Products $object->get_sousproduits_arbo(); // Load $object->sousprods $prods_arbo=$object->get_arbo_each_prod(); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index cddcff12374..2e241d9c156 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -166,11 +166,21 @@ if ($action=='filemerge') $form = new Form($db); -$helpurl=''; -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +$title = $langs->trans('ProductServiceCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label,16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) +{ + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Documents'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) +{ + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Documents'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +} -llxHeader("", $langs->trans("CardProduct".$object->type), $help_url); +llxHeader('', $title, $helpurl); if ($object->id) @@ -221,6 +231,7 @@ if ($object->id) $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + // Merge propal PDF document PDF files if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 3eb08370aba..05d70e7eb26 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -274,19 +274,26 @@ if (empty($reshook)) * view */ -$helpurl=''; -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +$title = $langs->trans('ProductServiceCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label,16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) +{ + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('BuyingPrices'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) +{ + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('BuyingPrices'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +} + +llxHeader('', $title, $helpurl); $form = new Form($db); if ($id > 0 || $ref) { - if ($action <> 're-edit') - { - llxHeader("", $langs->trans("CardProduct".$object->type), $helpurl); - } - if ($result) { if ($action == 'ask_remove_pf') { @@ -365,7 +372,7 @@ if ($id > 0 || $ref) print '
    '; // Supplier - print ''; print ''; - print ''; + print ''; if ($i == 0) print ''; print ''; $i++; diff --git a/htdocs/product/info.php b/htdocs/product/info.php index 71f1908e434..e29d1a168cb 100644 --- a/htdocs/product/info.php +++ b/htdocs/product/info.php @@ -56,16 +56,24 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e * View */ -$helpurl=''; -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +$title = $langs->trans('ProductServiceCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label,16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) +{ + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Info'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) +{ + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Info'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +} -$title=$langs->trans("Product"); +llxHeader('', $title, $helpurl); $form=new Form($b); -llxHeader('', $title, $help_url); - if ($id > 0 || $ref) { $result = $object->fetch($id,$ref); diff --git a/htdocs/product/note.php b/htdocs/product/note.php index ef53946460f..9a914527a83 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -30,17 +30,20 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -$action = GETPOST('action'); - $langs->load("companies"); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action'); + // Security check -$id = GETPOST('id')?GETPOST('id','int'):GETPOST('socid','int'); -if ($user->societe_id) $id=$user->societe_id; -$result = restrictedArea($user, 'societe', $id, '&societe'); +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); +$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); $object = new Product($db); -if ($id > 0) $object->fetch($id); +if ($id > 0 || ! empty($ref)) $object->fetch($id, $ref); $permissionnote=$user->rights->produit->creer; // Used by the include of actions_setnotes.inc.php @@ -56,15 +59,28 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, * View */ +$form = new Form($db); + $helpurl=''; if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; -$form = new Form($db); +$title = $langs->trans('ProductServiceCard'); +$shortlabel = dol_trunc($object->label,16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) +{ + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Notes'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) +{ + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Notes'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +} -llxHeader('', $langs->trans("ThirdParty").' - '.$langs->trans("Notes"), $help_url); +llxHeader('', $title, $help_url); -if ($id > 0) +if ($id > 0 || ! empty($ref)) { /* * Affichage onglets @@ -77,20 +93,20 @@ if ($id > 0) dol_fiche_head($head, 'note', $titre, 0, $picto); + $linkback = ''.$langs->trans("BackToList").''; - print ''; - print ''; + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); - - print '
    '; + $cssclass='titlefield'; + //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; + //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; + + //print '
    '; print '
    '; - //$colwidth='25'; - $cssclass='titlefield'; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index c645d76062e..4e04a4c626a 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -10,6 +10,7 @@ * Copyright (C) 2014 Ion agorria * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -92,10 +93,18 @@ if (empty($reshook)) $search_soc = ''; } + if ($action == 'setlabelsellingprice' && $user->admin) + { + require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; + $keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.GETPOST('pricelevel'); + dolibarr_set_const($db, $keyforlabel, GETPOST('labelsellingprice','alpha'), 'chaine', 0, '', $conf->entity); + $action = ''; + } + if (($action == 'update_vat') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' - + // We must define tva_tx, npr and local taxes $vatratecode = ''; $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot @@ -619,11 +628,21 @@ if (! empty($id) || ! empty($ref)) $object->fetch($id, $ref); } -$helpurl=''; -if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +$title = $langs->trans('ProductServiceCard'); +$helpurl = ''; +$shortlabel = dol_trunc($object->label,16); +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) +{ + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('SellingPrices'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +} +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) +{ + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('SellingPrices'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +} -llxHeader("", $langs->trans("CardProduct" . $object->type), $hepl_url); +llxHeader('', $title, $helpurl); $head = product_prepare_head($object); $titre = $langs->trans("CardProduct" . $object->type); @@ -651,7 +670,9 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) $soc->fetch($socid); // Selling price - print '
    '; + print ''; print ''; + print ''; + print ''; + print ''; } else { @@ -711,17 +734,46 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) else print vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true); print ''; } - - print ''; + print '
    '.$langs->trans("Supplier").''; + print '
    '.$langs->trans("Supplier").''; if ($rowid) { $supplier=new Fournisseur($db); diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 2d6e0ace9c9..74a974804ff 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -97,7 +97,7 @@ if (count($listofsearchfields)) { if ($i == 0) print '
    '.$langs->trans("Search").'
    :
    ' . $langs->trans("SellingPrice") . '
    '; + print $langs->trans("SellingPrice"); + print ''; if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { print price($object->multiprices_ttc[$soc->price_level]); @@ -698,7 +719,9 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // We show only vat for level 1 - print '
    ' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx[1], true) . '
    ' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx[1], true) . '
    '.$langs->trans("PriceLevel").''.$langs->trans("SellingPrice").''.$langs->trans("MinPrice").'
    '; + + print '
    '; + + print ''; + print ''; + print ''; + print ''; + print ''; + $var=True; + for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { - print ''; + $var = ! $var; + + print ''; // Label of price - print ''; if ($object->multiprices_base_type [$i] == 'TTC') { @@ -750,7 +802,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; // Price by quantity - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // TODO Fix the form included into a tr instead of a td { print ''; print ''; print ''; - foreach ($object->prices_by_qty_list[$i] as $ii => $prices) { + foreach ($object->prices_by_qty_list[$i] as $ii => $prices) + { if ($action == 'edit_price_by_qty' && $rowid == $prices['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { print ''; print ''; @@ -853,7 +906,7 @@ else print ''; // Price by quantity - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // TODO Fix the form inside tr instead of td { print ''; print ''; + + $var = false; for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { $var = !$var; @@ -1247,7 +1302,9 @@ if ($action == 'edit_price' && $object->getRights()->creer) } } + // List of price changes -log historic (ordered by descending date) + if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_price') && ! in_array($action, array('edit_price','edit_vat'))) { $sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.recuperableonly,"; @@ -1281,9 +1338,12 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ if ($num > 0) { + // Default prices or + // Log of previous customer prices $backbutton='' . $langs->trans("Back") . ''; if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"),'','','','','',$backbutton, 0, 0, 'title_accountancy.png'); + else print_barre_liste($langs->trans("PriceByCustomerLog"),'','','','','','', 0, 0, 'title_accountancy.png'); print '
    '; + print $langs->trans("PriceLevel"); + if ($user->admin) print ' id.'">'.img_edit($langs->trans('EditSellingPriceLabel'),0).''; + print ''.$langs->trans("SellingPrice").''.$langs->trans("MinPrice").'
    ' . $langs->trans("SellingPrice") . ' ' . $i; + print ''; $keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$i; - if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); + if (preg_match('/editlabelsellingprice/', $action)) + { + print ''; + print ''; + print ''; + print ''; + print $langs->trans("SellingPrice") . ' ' . $i.' - '; + print ''; + print ' '; + print ''; + } + else + { + print $langs->trans("SellingPrice") . ' ' . $i; + if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); + } print '
    ' . $langs->trans("PriceByQuantity") . ' ' . $i; print ''; @@ -765,7 +817,8 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print '' . $langs->trans("Discount") . ' 
    ' . $langs->trans("PriceByQuantity"); if ($object->prices_by_qty [0] == 0) { @@ -1180,6 +1233,8 @@ if ($action == 'edit_price' && $object->getRights()->creer) print '
    '; @@ -1320,7 +1380,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ { $objp = $db->fetch_object($result); $var = ! $var; - print ''; + print ''; // Date print ""; @@ -1385,8 +1445,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ } print "\n"; - $i ++; + $i++; } + $db->free($result); print "
    " . dol_print_date($db->jdate($objp->dp), "dayhour") . "
    "; print "
    "; @@ -1757,6 +1818,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if (count($prodcustprice->lines) > 0) { + $var = false; foreach ($prodcustprice->lines as $line) { $var = ! $var; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 4106b4ef936..b4573bdc9e7 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -248,8 +248,13 @@ if ($resql) print ''; } - - $param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref"; + $param=''; + if ($tosell) $param.="&tosell=".$tosell; + if ($tobuy) $param.="&tobuy=".$tobuy; + if ($type) $param.="&type=".$type; + if ($fourn_id) $param.="&fourn_id=".$fourn_id; + if ($snom) $param.="&snom=".$snom; + if ($sref) $param.="&sref=".$sref; $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 8b08605a00e..2e4438c416d 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -237,9 +238,18 @@ if ($resql) print $hookmanager->resPrint; print ''; } - - $param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref&batch=$batch&eatby=$eatby&sellby=$sellby"; + + $param=''; + if ($tosell) $param.="&tosell=".$tosell; + if ($tobuy) $param.="&tobuy=".$tobuy; + if ($type) $param.="&type=".$type; + if ($fourn_id) $param.="&fourn_id=".$fourn_id; + if ($snom) $param.="&snom=".$snom; + if ($sref) $param.="&sref=".$sref; + if ($search_batch) $param.="&search_batch=".$search_batch; + /*if ($eatby) $param.="&eatby=".$eatby; + if ($sellby) $param.="&sellby=".$sellby;*/ print ''; @@ -257,8 +267,8 @@ if ($resql) // TODO Add info of running suppliers/customers orders //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy","",$param,'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index c8b952a32b1..ebb28b48287 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -95,7 +95,22 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') else { $result = $object->fetch($id,$ref); - llxHeader("",$langs->trans("CardProduct".$object->type)); + + $title = $langs->trans('ProductServiceCard'); + $helpurl = ''; + $shortlabel = dol_trunc($object->label,16); + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) + { + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Statistics'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + } + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) + { + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Statistics'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + } + + llxHeader('', $title, $helpurl); } diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 6f3f8546454..e9eb3d41859 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -90,7 +90,21 @@ if ($id > 0 || ! empty($ref)) $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - llxHeader("","",$langs->trans("CardProduct".$product->type)); + $title = $langs->trans('ProductServiceCard'); + $helpurl = ''; + $shortlabel = dol_trunc($object->label,16); + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) + { + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Referers'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + } + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) + { + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Referers'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + } + + llxHeader('', $title, $helpurl); if ($result > 0) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 9dcb51fe8ef..60f7938de06 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -111,6 +111,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su $result=$object->delete($user); if ($result > 0) { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: ".DOL_URL_ROOT.'/product/stock/list.php'); exit; } @@ -175,7 +176,7 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("NewWarehouse")); - print "\n"; + print ''."\n"; print ''; print ''; print ''; @@ -234,7 +235,11 @@ if ($action == 'create') dol_fiche_end(); - print '
    '; + print '
    '; + print ''; + print '     '; + print ''; + print '
    '; print ''; } @@ -259,66 +264,141 @@ else dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock'); + $formconfirm = ''; + // Confirm delete third party if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteAWarehouse"),$langs->trans("ConfirmDeleteWarehouse",$object->libelle),"confirm_delete",'',0,2); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteAWarehouse"),$langs->trans("ConfirmDeleteWarehouse",$object->libelle),"confirm_delete",'',0,2); } - print '
    '; - + if (! $formconfirm) { + $parameters = array(); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + // Warehouse card $linkback = ''.$langs->trans("BackToList").''; + + + $morehtmlref='
    '; + $morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu; + /* + // Ref supplier + //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); + //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); + // Thirdparty + //$morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
    '.$langs->trans('Project') . ' '; + if ($user->rights->supplier_proposal->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref.='
    '; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'libelle', $morehtmlref); + + + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + // Ref + /* print ''; + print '';*/ - print ''; + //print ''; // Description - print ''; + print ''; // Address - print ''; // Town - print ''; - print ''; + print ''; + print ''; // Country - print ''; + print '';*/ // Status - print ''; + //print ''; - $calcproductsunique=$object->nb_different_products(); + $calcproductsunique=$object->nb_different_products(); $calcproducts=$object->nb_products(); - - // Total nb of different products - print '"; - + + // Total nb of different products + print '"; + // Nb of products - print '"; - + + print '
    '.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'libelle'); - print '
    '.$langs->trans("LocationSummary").''.$object->lieu.'
    '.$langs->trans("LocationSummary").''.$object->lieu.'
    '.$langs->trans("Description").''.nl2br($object->description).'
    '.$langs->trans("Description").''.nl2br($object->description).'
    '.$langs->trans('Address').''; + /* + print '
    '.$langs->trans('Address').''; print $object->address; print '
    '.$langs->trans('Zip').''.$object->zip.''.$langs->trans('Town').''.$object->town.'
    '.$langs->trans('Zip').''.$object->zip.'
    '.$langs->trans('Town').''.$object->town.'
    '.$langs->trans('Country').''; + print '
    '.$langs->trans('Country').''; if (! empty($object->country_code)) { $img=picto_from_langcode($object->country_code); print ($img?$img.' ':''); } print $object->country; - print '
    '.$langs->trans("Status").''.$object->getLibStatut(4).'
    '.$langs->trans("Status").''.$object->getLibStatut(4).'
    '.$langs->trans("NumberOfDifferentProducts").''; - print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; - print "
    '.$langs->trans("NumberOfDifferentProducts").''; + print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; + print "
    '.$langs->trans("NumberOfProducts").''; + print '
    '.$langs->trans("NumberOfProducts").''; print empty($calcproducts['nb'])?'0':$calcproducts['nb']; print "
    '; + + print ''; + print '
    '; + print '
    '; + print '
    '; + + print ''; + // Value - print '"; - + // Last movement $sql = "SELECT max(m.datem) as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; @@ -326,14 +406,14 @@ else $resqlbis = $db->query($sql); if ($resqlbis) { - $obj = $db->fetch_object($resqlbis); - $lastmovementdate=$db->jdate($obj->datem); + $obj = $db->fetch_object($resqlbis); + $lastmovementdate=$db->jdate($obj->datem); } else { - dol_print_error($db); + dol_print_error($db); } - print '"; - + print "
    '.$langs->trans("EstimatedStockValueShort").''; + print '
    '.$langs->trans("EstimatedStockValueShort").''; print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency); print "
    '.$langs->trans("LastMovement").''; + print '
    '.$langs->trans("LastMovement").''; if ($lastmovementdate) { print dol_print_date($lastmovementdate,'dayhour').' '; @@ -341,13 +421,19 @@ else } else { - print $langs->trans("None"); + print $langs->trans("None"); } print "
    "; print '
    '; + print '
    '; + print ''; + + print '
    '; + + dol_fiche_end(); /* ************************************************************************** */ diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index dce8620d182..aee38a67ccf 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -35,6 +35,7 @@ class Entrepot extends CommonObject { public $element='stock'; public $table_element='entrepot'; + public $picto='stock'; /** * Warehouse closed, inactive @@ -213,24 +214,40 @@ class Entrepot extends CommonObject /** * Delete a warehouse * - * @param User $user Object user that made deletion - * @return int <0 if KO, >0 if OK + * @param User $user Object user that made deletion + * @param int $notrigger 1=No trigger + * @return int <0 if KO, >0 if OK */ - function delete($user) + function delete($user, $notrigger=0) { $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement"; - $sql.= " WHERE fk_entrepot = " . $this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql1=$this->db->query($sql); + if (! $error && empty($notrigger)) + { + // Call trigger + $result=$this->call_trigger('WAREHOUSE_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + + $elements = array('stock_mouvement','product_stock','product_warehouse_properties'); + foreach($elements as $table) + { + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; + $sql.= " WHERE fk_entrepot = " . $this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $result=$this->db->query($sql); + if (! $result) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + } - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock"; - $sql.= " WHERE fk_entrepot = " . $this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql2=$this->db->query($sql); - - if ($resql1 && $resql2) + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."entrepot"; $sql.= " WHERE rowid = " . $this->id; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 0d82d56243a..1532f62aa22 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -149,7 +149,6 @@ class MouvementStock extends CommonObject { if ($eatby) { - $eatbywithouthour=$eatby; $tmparray=dol_getdate($eatby, true); $eatbywithouthour=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility @@ -187,9 +186,8 @@ class MouvementStock extends CommonObject { if ($sellby) { - $sellbywithouthour=$sellby; - $tmparray=dol_getdate($eatby, true); - $eatbywithouthour=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + $tmparray=dol_getdate($sellby, true); + $sellbywithouthour=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); if ($this->db->jdate($obj->sellby) != $sellby && $this->db->jdate($obj->sellby) != $sellbywithouthour) // We test date without hours and with hours for backward compatibility { // If found and eatby/sellby defined into table and provided and differs, return error @@ -442,8 +440,8 @@ class MouvementStock extends CommonObject // $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty; // $sql.= " WHERE rowid = ".$fk_product; // Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql - $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET p.pmp = ".$newpmp.", "; - $sql.= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock ps WHERE ps.fk_product = p.rowid)"; + $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.", "; + $sql.= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; $sql.= " WHERE rowid = ".$fk_product; dol_syslog(get_class($this)."::_create", LOG_DEBUG); @@ -562,7 +560,9 @@ class MouvementStock extends CommonObject */ function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='', $datem='', $eatby='', $sellby='', $batch='', $id_product_batch=0) { - $skip_batch = empty($conf->productbatch->enabled); + global $conf; + + $skip_batch = empty($conf->productbatch->enabled); return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label, '', $datem, $eatby, $sellby, $batch, $skip_batch, $id_product_batch); } diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 9c26b0b7fbc..58adecd9651 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -43,7 +43,10 @@ class Productlot extends CommonObject * @var string Name of table without prefix where object is stored */ public $table_element = 'product_lot'; - + + public $isnolinkedbythird = 1; + public $ismultientitymanaged = 1; + /** * @var ProductlotLine[] Lines */ @@ -119,7 +122,6 @@ class Productlot extends CommonObject // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql.= 'entity,'; $sql.= 'fk_product,'; $sql.= 'batch,'; @@ -129,10 +131,7 @@ class Productlot extends CommonObject $sql.= 'fk_user_creat,'; $sql.= 'fk_user_modif,'; $sql.= 'import_key'; - - $sql .= ') VALUES ('; - $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; $sql .= ' '.(! isset($this->fk_product)?'NULL':$this->fk_product).','; $sql .= ' '.(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").','; @@ -142,8 +141,6 @@ class Productlot extends CommonObject $sql .= ' '.(! isset($this->fk_user_creat)?'NULL':$this->fk_user_creat).','; $sql .= ' '.(! isset($this->fk_user_modif)?'NULL':$this->fk_user_modif).','; $sql .= ' '.(! isset($this->import_key)?'NULL':$this->import_key); - - $sql .= ')'; $this->db->begin(); @@ -162,10 +159,10 @@ class Productlot extends CommonObject // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) $error++; - //// End call triggers + // Call triggers + $result=$this->call_trigger('PRODUCTLOT_CREATE',$user); + if ($result < 0) $error++; + // End call triggers } } @@ -185,17 +182,17 @@ class Productlot extends CommonObject * Load object in memory from the database * * @param int $id Id object - * @param string $ref Ref + * @param int $product_id Id of product, batch number parameter required + * @param string $batch batch number * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = null) + public function fetch($id = 0, $product_id = 0, $batch = '') { dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; - $sql .= " t.entity,"; $sql .= " t.fk_product,"; $sql .= " t.batch,"; @@ -206,11 +203,9 @@ class Productlot extends CommonObject $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; $sql .= " t.import_key"; - - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - if (null !== $ref) { - $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + if ($product_id > 0 && $batch != '') { + $sql .= ' WHERE t.batch = ' . '\'' . $this->db->escape($batch) . '\' AND t.fk_product = ' . $product_id; } else { $sql .= ' WHERE t.rowid = ' . $id; } @@ -222,10 +217,13 @@ class Productlot extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->ref = $obj->rowid; + //$this->ref = $obj->fk_product.'_'.$obj->batch; + + $this->batch = $obj->batch; $this->entity = $obj->entity; $this->fk_product = $obj->fk_product; - $this->batch = $obj->batch; $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); $this->datec = $this->db->jdate($obj->datec); @@ -234,7 +232,12 @@ class Productlot extends CommonObject $this->fk_user_modif = $obj->fk_user_modif; $this->import_key = $obj->import_key; - + // Retrieve all extrafields for invoice + // fetch optionals attributes and labels + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); } $this->db->free($resql); @@ -307,7 +310,8 @@ class Productlot extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - while ($obj = $this->db->fetch_object($resql)) { + while ($obj = $this->db->fetch_object($resql)) + { $line = new ProductlotLine(); $line->id = $obj->rowid; @@ -323,8 +327,6 @@ class Productlot extends CommonObject $line->fk_user_modif = $obj->fk_user_modif; $line->import_key = $obj->import_key; - - $this->lines[$line->id] = $line; } $this->db->free($resql); @@ -373,14 +375,11 @@ class Productlot extends CommonObject $this->import_key = trim($this->import_key); } - - // Check parameters // Put here code to add a control on parameters values // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; $sql .= ' fk_product = '.(isset($this->fk_product)?$this->fk_product:"null").','; $sql .= ' batch = '.(isset($this->batch)?"'".$this->db->escape($this->batch)."'":"null").','; @@ -391,8 +390,6 @@ class Productlot extends CommonObject $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat)?$this->fk_user_creat:"null").','; $sql .= ' fk_user_modif = '.(isset($this->fk_user_modif)?$this->fk_user_modif:"null").','; $sql .= ' import_key = '.(isset($this->import_key)?$this->import_key:"null"); - - $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -408,10 +405,10 @@ class Productlot extends CommonObject // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers + // Call triggers + $result=$this->call_trigger('PRODUCTLOT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers } // Commit or rollback @@ -524,7 +521,7 @@ class Productlot extends CommonObject return - 1; } } - + /** * Return a link to the user card (with optionaly the picto) * Use this->id,this->lastname, this->firstname @@ -546,11 +543,11 @@ class Productlot extends CommonObject $result = ''; $companylink = ''; - $label = '' . $langs->trans("LotSerial") . ''; + $label = '' . $langs->trans("Batch") . ''; $label.= '
    '; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label.= '' . $langs->trans('Batch') . ': ' . $this->batch; - $link = 'ref . $linkend; + $result.= $link . $this->batch . $linkend; return $result; } - /** - * Retourne le libelle du status d'un user (actif, inactif) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - function getLibStatut($mode=0) - { - return $this->LibStatut($this->status,$mode); - } - - /** - * Renvoi le libelle d'un status donne - * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - function LibStatut($status,$mode=0) - { - global $langs; - - if ($mode == 0) - { - $prefix=''; - if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); - } - if ($mode == 1) - { - if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); - } - if ($mode == 2) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - } - if ($mode == 3) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); - } - if ($mode == 4) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - } - if ($mode == 5) - { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); - } - } - - /** + /** * Initialise object with example values * Id must be 0 if object instance is a specimen * @@ -640,8 +582,6 @@ class Productlot extends CommonObject $this->fk_user_creat = ''; $this->fk_user_modif = ''; $this->import_key = ''; - - } } diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php new file mode 100644 index 00000000000..84c1735ff6e --- /dev/null +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -0,0 +1,587 @@ + + * Copyright (C) 2014-2016 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) ---Put here your own copyright and developer email--- + * + * 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 . + */ + +/** + * \file ProductEntrepot/ProductStockEntrepot.class.php + * \ingroup ProductEntrepot + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * Put some comments here + */ + +// 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 ProductStockEntrepot + * + * Put here description of your class + * + * @see CommonObject + */ +class ProductStockEntrepot extends CommonObject +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'ProductStockEntrepot'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'product_warehouse_properties'; + + /** + */ + + public $tms = ''; + public $fk_product; + public $fk_entrepot; + public $seuil_stock_alerte; + public $desiredstock; + public $import_key; + + /** + */ + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + // Clean parameters + + if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); + if (isset($this->fk_entrepot)) $this->fk_entrepot = trim($this->fk_entrepot); + if (isset($this->seuil_stock_alerte)) $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); + if (isset($this->desiredstock)) $this->desiredstock = trim($this->desiredstock); + if (isset($this->import_key)) $this->import_key = trim($this->import_key); + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + + $sql.= 'fk_product,'; + $sql.= 'fk_entrepot,'; + $sql.= 'seuil_stock_alerte,'; + $sql.= 'desiredstock,'; + $sql.= 'import_key'; + + + $sql .= ') VALUES ('; + + $sql .= ' '.(! isset($this->fk_product)?'NULL':$this->fk_product).','; + $sql .= ' '.(! isset($this->fk_entrepot)?'NULL':$this->fk_entrepot).','; + $sql .= ' '.(! isset($this->seuil_stock_alerte)?'0':$this->seuil_stock_alerte).','; + $sql .= ' '.(! isset($this->desiredstock)?'0':$this->desiredstock).','; + $sql .= ' '.(! isset($this->import_key)?'NULL':"'".$this->db->escape($this->import_key)."'"); + + + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_CREATE',$user); + //if ($result < 0) $error++; + //// End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param int $fk_product Id product + * @param int $fk_entrepot Id warehouse + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $fk_product, $fk_entrepot) + { + if(empty($id) && (empty($fk_product) || empty($fk_entrepot))) return -1; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.tms,"; + $sql .= " t.fk_product,"; + $sql .= " t.fk_entrepot,"; + $sql .= " t.seuil_stock_alerte,"; + $sql .= " t.desiredstock,"; + $sql .= " t.import_key"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + if(!empty($id)) $sql .= ' WHERE t.rowid = ' . $id; + else $sql.= ' WHERE t.fk_product = '.$fk_product.' AND t.fk_entrepot = '.$fk_entrepot; + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->tms = $this->db->jdate($obj->tms); + $this->fk_product = $obj->fk_product; + $this->fk_entrepot = $obj->fk_entrepot; + $this->seuil_stock_alerte = $obj->seuil_stock_alerte; + $this->desiredstock = $obj->desiredstock; + $this->import_key = $obj->import_key; + + + } + + // Retrieve all extrafields for invoice + // fetch optionals attributes and labels + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + + // $this->fetch_lines(); + + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Load object in memory from the database + * + * @param int $fk_product Product from which we want to get limit and desired stock by warehouse + * @param int $fk_entrepot Warehouse in which we want to get products limit and desired stock + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAll($fk_product='', $fk_entrepot='', $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.tms,"; + $sql .= " t.fk_product,"; + $sql .= " t.fk_entrepot,"; + $sql .= " t.seuil_stock_alerte,"; + $sql .= " t.desiredstock,"; + $sql .= " t.import_key"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + + $sql .= ' WHERE 1=1'; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + if (count($sqlwhere) > 0) $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); + + if(!empty($fk_product)) $sql .= ' AND fk_product = '.$fk_product; + elseif(!empty($fk_entrepot)) $sql .= ' AND fk_entrepot = '.$fk_entrepot; + // "elseif" used instead of "if" because getting list with specified fk_product and specified fk_entrepot would be the same as doing a fetch + + if (!empty($sortfield)) $sql .= $this->db->order($sortfield,$sortorder); + if (!empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + + $lines = array(); + + $resql = $this->db->query($sql); + if ($resql) { + + while ($obj = $this->db->fetch_object($resql)) { + $lines[$obj->rowid] = array( + 'id'=>$obj->rowid + ,'fk_product'=>$obj->fk_product + ,'fk_entrepot'=>$obj->fk_entrepot + ,'seuil_stock_alerte'=>$obj->seuil_stock_alerte + ,'desiredstock'=>$obj->desiredstock + ); + } + $this->db->free($resql); + + return $lines; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + // Clean parameters + + if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); + if (isset($this->fk_entrepot)) $this->fk_entrepot = trim($this->fk_entrepot); + if (isset($this->seuil_stock_alerte)) $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); + if (isset($this->desiredstock)) $this->desiredstock = trim($this->desiredstock); + if (isset($this->import_key)) $this->import_key = trim($this->import_key); + + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + + $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; + $sql .= ' fk_product = '.(isset($this->fk_product)?$this->fk_product:"null").','; + $sql .= ' fk_entrepot = '.(isset($this->fk_entrepot)?$this->fk_entrepot:"null").','; + $sql .= ' seuil_stock_alerte = '.(isset($this->seuil_stock_alerte)?$this->seuil_stock_alerte:"null").','; + $sql .= ' desiredstock = '.(isset($this->desiredstock)?$this->desiredstock:"null").','; + $sql .= ' import_key = '.(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); + + + $sql .= ' WHERE rowid=' . $this->id; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + if (!$error && !$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + $this->db->begin(); + + if (!$error) { + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_DELETE',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + } + + if (!$error) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; + $sql .= ' WHERE rowid=' . $this->id; + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $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 + */ + public function createFromClone($fromid) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + global $user; + $error = 0; + $object = new ProductStockEntrepot($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->create($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + + return $object->id; + } else { + $this->db->rollback(); + + return - 1; + } + } + + /** + * Return a link to the user card (with optionaly the picto) + * Use this->id,this->lastname, this->firstname + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to + * @param integer $notooltip 1=Disable tooltip + * @param int $maxlen Max length of visible user name + * @param string $morecss Add more css on link + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') + { + global $langs, $conf, $db; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("MyModule") . ''; + $label.= '
    '; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $link = 'ref . $linkend; + return $result; + } + + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Renvoi le libelle d'un status donne + * + * @param int $status Id status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function LibStatut($status,$mode=0) + { + global $langs; + + if ($mode == 0) + { + $prefix=''; + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 1) + { + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 2) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 3) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + } + if ($mode == 4) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 5) + { + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } + } + + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->tms = ''; + $this->fk_product = ''; + $this->fk_entrepot = ''; + $this->seuil_stock_alerte = ''; + $this->desiredstock = ''; + $this->import_key = ''; + + + } + +} diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index 158da034d2f..5f075370df6 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -140,7 +140,7 @@ if ($resql) print '
    '.$langs->trans("SellByDate").''.$langs->trans("Warehouse").''.$langs->trans("FullList").''.$langs->trans("FullList").'
    '; print ""; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("LocationSummary"),$_SERVER["PHP_SELF"], "e.lieu","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stockqty",'',$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "e.valo_pmp",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "estimatedvalue",'',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("EstimatedStockValueSell"), $_SERVER["PHP_SELF"], "",'',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "e.statut",'',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder,'maxwidthsearch '); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index fc16dddda0f..4482e249410 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productstockentrepot.class.php'; if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; $langs->load("products"); @@ -63,12 +64,97 @@ if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldid); +$object = new Product($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + +if ($id > 0 || ! empty($ref)) +{ + $result = $object->fetch($id, $ref); + +} +$modulepart='product'; + +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +$canvas = !empty($object->canvas)?$object->canvas:GETPOST("canvas"); +$objcanvas=null; +if (! empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db,$action); + $objcanvas->getCanvas('stockproduct','card',$canvas); +} + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('stockproductcard','globalcard')); + + /* * Actions */ if ($cancel) $action=''; +$parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if($action == 'addlimitstockwarehouse') { + + $seuil_stock_alerte = GETPOST('seuil_stock_alerte'); + $desiredstock = GETPOST('desiredstock'); + + $maj_ok = true; + if($seuil_stock_alerte == '') { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StockLimit")), null, 'errors'); + $maj_ok = false; + } + if($desiredstock == '') { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DesiredStock")), null, 'errors'); + $maj_ok = false; + } + + if($maj_ok) { + + $pse = new ProductStockEntrepot($db); + if($pse->fetch('', GETPOST('id'), GETPOST('fk_entrepot')) > 0) { + + // Update + $pse->seuil_stock_alerte = $seuil_stock_alerte; + $pse->desiredstock = $desiredstock; + if($pse->update($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseUpdated')); + + } else { + + // Create + $pse->fk_entrepot = GETPOST('fk_entrepot'); + $pse->fk_product = GETPOST('id'); + $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); + $pse->desiredstock = GETPOST('desiredstock'); + if($pse->create($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseCreated')); + + } + + } + + header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id')); + exit; + +} + +if($action == 'delete_productstockwarehouse') +{ + + $pse = new ProductStockEntrepot($db); + $pse->fetch(GETPOST('fk_productstockwarehouse')); + if($pse->delete($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseDeleted')); + + $action = ''; + +} + // Set stock limit if ($action == 'setseuil_stock_alerte') { @@ -409,8 +495,21 @@ if ($id > 0 || $ref) $object->load_stock(); - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - llxHeader("",$langs->trans("CardProduct".$object->type),$help_url); + $title = $langs->trans('ProductServiceCard'); + $helpurl = ''; + $shortlabel = dol_trunc($object->label,16); + if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) + { + $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Stock'); + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + } + if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) + { + $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Stock'); + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + } + + llxHeader('', $title, $helpurl); if ($result > 0) { @@ -492,7 +591,11 @@ if ($id > 0 || $ref) print ''; - + + // Hook formObject + $parameters=array('colspan' => 3); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // Desired stock print ''; print ""; print "
    '.$form->editfieldkey("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).''; print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string'); print '
    '.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); print ''; @@ -651,28 +754,33 @@ else /* */ /* ************************************************************************** */ +$parameters=array(); -if (empty($action) && $object->id) +$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { - print "
    \n"; - if ($user->rights->stock->mouvement->creer) - { - print ''.$langs->trans("StockCorrection").''; - } - - //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) - if ($user->rights->stock->mouvement->creer) + if (empty($action) && $object->id) { - print ''.$langs->trans("StockTransfer").''; + print "
    \n"; + + if ($user->rights->stock->mouvement->creer) + { + print ''.$langs->trans("StockCorrection").''; + } + + //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) + if ($user->rights->stock->mouvement->creer) + { + print ''.$langs->trans("StockTransfer").''; + } + + print '
    '; } - print '
    '; } - - /* * Stock detail (by warehouse). May go down into batch details. */ @@ -811,6 +919,49 @@ print '
    "; +if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { + + print '

    '; + print_titre($langs->trans('AddNewProductStockWarehouse')); + //print '
    '; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + + $pse = new ProductStockEntrepot($db); + $lines = $pse->fetchAll(GETPOST('id')); + + if(!empty($lines)) { + + $var=false; + foreach($lines as $line) { + + $ent = new Entrepot($db); + $ent->fetch($line['fk_entrepot']); + print ''; + print ''; + print ''; + print ''; + print ''; + $var=!$var; + + } + + } + + print "
    '.$formproduct->selectWarehouses('', 'fk_entrepot').'
    '.$ent->getNomUrl(3).''.$line['seuil_stock_alerte'].''.$line['desiredstock'].''.img_delete().'
    "; + + print ''; + +} llxFooter(); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index b750db87234..e1cd07d597b 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -23,18 +23,6 @@ * Initialy built by build_class_from_table on 2016-05-17 12:22 */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - // Change this following line to use the correct relative path (../, ../../, etc) $res=0; if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory @@ -44,18 +32,23 @@ if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@inc if (! $res) die("Include of main fails"); // Change this following line to use the correct relative path from htdocs include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); -dol_include_once('/stock/class/productlot.class.php'); +include_once(DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'); +include_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +dol_include_once('/product/stock/class/productlot.class.php'); // Load traductions files requiredby by page $langs->load("stock"); $langs->load("other"); +$langs->load("productbatch"); // Get parameters $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); $backtopage = GETPOST('backtopage'); -$myparam = GETPOST('myparam','alpha'); - +$batch = GETPOST('batch','alpha'); +$productid = GETPOST('productid','int'); +$ref = GETPOST('ref','alpha'); // ref is productid_batch $search_entity=GETPOST('search_entity','int'); $search_fk_product=GETPOST('search_fk_product','int'); @@ -64,35 +57,48 @@ $search_fk_user_creat=GETPOST('search_fk_user_creat','int'); $search_fk_user_modif=GETPOST('search_fk_user_modif','int'); $search_import_key=GETPOST('search_import_key','int'); +if (empty($action) && empty($id) && empty($ref)) $action='list'; // Protection if external user if ($user->societe_id > 0) { - //accessforbidden(); + //accessforbidden(); } +//$result = restrictedArea($user, 'mymodule', $id); -if (empty($action) && empty($id) && empty($ref)) $action='list'; -// Load object if id or ref is provided as parameter -$object=new Productlot($db); -if (($id > 0 || ! empty($ref)) && $action != 'add') +$object = new ProductLot($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id || $ref) { - $result=$object->fetch($id,$ref); - if ($result < 0) dol_print_error($db); + if ($ref) + { + $tmp=explode('_',$ref); + $productid=$tmp[0]; + $batch=$tmp[1]; + } + $object->fetch($id, $productid, $batch); } // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('productlot')); -$extrafields = new ExtraFields($db); +$hookmanager->initHooks(array('productlotcard','globalcard')); +$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php +$permissionedit = $user->rights->stock->creer; // Used by the include of actions_lineupdown.inc.php -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ + +/* + * Actions + */ $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -100,6 +106,47 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + if ($action == 'seteatby' && $user->rights->stock->creer) + { + $newvalue = dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); + $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); + if ($result < 0) dol_print_error($db, $object->error); + } + + if ($action == 'setsellby' && $user->rights->stock->creer) + { + $newvalue=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); + if ($result < 0) dol_print_error($db, $object->error); + } + + if ($action == 'update_extras') + { + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) $error++; + + if (! $error) + { + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('productlotdao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error++; + } + } else if ($reshook < 0) + $error++; + } + + if ($error) + $action = 'edit_extras'; + } + // Action to add record if ($action == 'add') { @@ -114,14 +161,12 @@ if (empty($reshook)) /* object_prop_getpost_prop */ - $object->entity=GETPOST('entity','int'); - $object->fk_product=GETPOST('fk_product','int'); - $object->batch=GETPOST('batch','alpha'); - $object->fk_user_creat=GETPOST('fk_user_creat','int'); - $object->fk_user_modif=GETPOST('fk_user_modif','int'); - $object->import_key=GETPOST('import_key','int'); - - + $object->entity=GETPOST('entity','int'); + $object->fk_product=GETPOST('fk_product','int'); + $object->batch=GETPOST('batch','alpha'); + $object->fk_user_creat=GETPOST('fk_user_creat','int'); + $object->fk_user_modif=GETPOST('fk_user_modif','int'); + $object->import_key=GETPOST('import_key','int'); if (empty($object->ref)) { @@ -159,16 +204,13 @@ if (empty($reshook)) if ($action == 'update' && ! GETPOST('cancel')) { $error=0; - - - $object->entity=GETPOST('entity','int'); - $object->fk_product=GETPOST('fk_product','int'); - $object->batch=GETPOST('batch','alpha'); - $object->fk_user_creat=GETPOST('fk_user_creat','int'); - $object->fk_user_modif=GETPOST('fk_user_modif','int'); - $object->import_key=GETPOST('import_key','int'); - + $object->entity=GETPOST('entity','int'); + $object->fk_product=GETPOST('fk_product','int'); + $object->batch=GETPOST('batch','alpha'); + $object->fk_user_creat=GETPOST('fk_user_creat','int'); + $object->fk_user_modif=GETPOST('fk_user_modif','int'); + $object->import_key=GETPOST('import_key','int'); if (empty($object->ref)) { @@ -219,13 +261,11 @@ if (empty($reshook)) -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ +/* + * View + */ -llxHeader('','MyPageName',''); +llxHeader('','ProductLot',''); $form=new Form($db); @@ -251,7 +291,7 @@ jQuery(document).ready(function() { // Part to create if ($action == 'create') { - print load_fiche_titre($langs->trans("NewMyModule")); + print load_fiche_titre($langs->trans("Batch")); print '
    '; print ''; @@ -262,12 +302,12 @@ if ($action == 'create') print ''."\n"; // print ''; // -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print '
    '.$langs->trans("Label").'
    '.$langs->trans("Fieldentity").'
    '.$langs->trans("Fieldfk_product").'
    '.$langs->trans("Fieldbatch").'
    '.$langs->trans("Fieldfk_user_creat").'
    '.$langs->trans("Fieldfk_user_modif").'
    '.$langs->trans("Fieldimport_key").'
    '.$langs->trans("Fieldentity").'
    '.$langs->trans("Fieldfk_product").'
    '.$langs->trans("Fieldbatch").'
    '.$langs->trans("Fieldfk_user_creat").'
    '.$langs->trans("Fieldfk_user_modif").'
    '.$langs->trans("Fieldimport_key").'
    '."\n"; @@ -279,64 +319,60 @@ print '
    '.$langs->trans("Fieldimport_key").'
    '."\n"; - // print ''; - // -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - - print '
    '.$langs->trans("Label").'
    '.$langs->trans("Fieldentity").'
    '.$langs->trans("Fieldfk_product").'
    '.$langs->trans("Fieldbatch").'
    '.$langs->trans("Fieldfk_user_creat").'
    '.$langs->trans("Fieldfk_user_modif").'
    '.$langs->trans("Fieldimport_key").'
    '; - - dol_fiche_end(); - - print '
    '; - print '   '; - print '
    '; - - print ''; -} - - - // Part to show record -if ($id && (empty($action) || $action == 'view' || $action == 'delete')) +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - print load_fiche_titre($langs->trans("MyModule")); + $res = $object->fetch_optionals($object->id, $extralabels); + + print load_fiche_titre($langs->trans("Batch")); - dol_fiche_head(); - + $head = productlot_prepare_head($object); + dol_fiche_head($head, 'card', $langs->trans("Batch"), 0, 'stock'); + + if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1); print $formconfirm; } print ''."\n"; - // print ''; - // -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; + + $linkback = '' . $langs->trans("BackToList") . ''; + + // Ref + print ''; + print ''; + print ''; + + // Product + print ''; + // Eat by + print ''; + print ''; + + // Sell by + print ''; + print ''; + + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + print '
    '.$langs->trans("Label").'
    '.$langs->trans("Fieldentity").'$object->entity
    '.$langs->trans("Fieldfk_product").'$object->fk_product
    '.$langs->trans("Fieldbatch").'$object->batch
    '.$langs->trans("Fieldfk_user_creat").'$object->fk_user_creat
    '.$langs->trans("Fieldfk_user_modif").'$object->fk_user_modif
    '.$langs->trans("Fieldimport_key").'$object->import_key
    ' . $langs->trans('Batch') . ''; + print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'batch'); + print '
    '.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock'); + print '
    '; + print $form->editfieldkey($langs->trans('Eatby'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('Eatby'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print '
    '; + print $form->editfieldkey($langs->trans('Sellby'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('Sellby'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print '
    '; dol_fiche_end(); @@ -350,15 +386,16 @@ print '
    '.$langs->trans("Fieldimport_key").'
    '.$obj->batch.''.$productlot->getNomUrl().'
    '; + print ''; print ''; print ''; if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index b9c8e455751..adf6efbc95c 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -90,7 +90,7 @@ if (count($listofsearchfields)) { if ($i == 0) print ''; print ''; - print ''; + print ''; if ($i == 0) print ''; print ''; $i++; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 0c509240684..aa5044da610 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -386,7 +386,7 @@ if ($usertoprocess->id == $user->id) print ''; print ''; print ''; -print ''; +print ''; print "\n"; // By default, we can edit only tasks we are assigned to diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index fa89e06f398..ce39fad4a14 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $langs->load("projects"); $langs->load('companies'); @@ -170,6 +171,17 @@ if (empty($reshook)) setEventMessages($langs->trans($object->error), null, 'errors'); $error++; } + if (! $error && !empty($object->id) > 0) + { + // Category association + $categories = GETPOST('categories'); + $result=$object->setCategories($categories); + if ($result<0) { + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } if (! $error) { @@ -235,7 +247,7 @@ if (empty($reshook)) if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount')); if (isset($_POST['opp_status'])) $object->opp_status = $opp_status; if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; - + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; @@ -246,7 +258,7 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - + if (! $error) { $result=$object->update($user); @@ -254,6 +266,15 @@ if (empty($reshook)) { $error++; setEventMessages($object->error, $object->errors,'errors'); + }else { + // Category association + $categories = GETPOST('categories'); + $result=$object->setCategories($categories); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } } @@ -310,7 +331,7 @@ if (empty($reshook)) if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + $langs->load("other"); $upload_dir = $conf->projet->dir_output; $file = $upload_dir . '/' . GETPOST('file'); @@ -377,7 +398,7 @@ if (empty($reshook)) $clone_notes=GETPOST('clone_notes')?1:0; $move_date=GETPOST('move_date')?1:0; $clone_thirdparty=GETPOST('socid','int')?GETPOST('socid','int'):0; - + $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_project_files,$clone_task_files,$clone_notes,$move_date,0,$clone_thirdparty); if ($result <= 0) { @@ -486,7 +507,7 @@ if ($action == 'create' && $user->rights->projet->creer) print ' '.$langs->trans("AddThirdParty").''; print ''; } - + // Status if ($status != '') { @@ -498,7 +519,9 @@ if ($action == 'create' && $user->rights->projet->creer) // Public print ''; @@ -526,7 +549,7 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print ''; print ''; - + // Opportunity amount print ''; print ''; @@ -544,6 +567,14 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print ''; + if($conf->categorie->enabled) { + // Categories + print '"; + } + // Other options $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -566,13 +597,13 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print ''; - + // Change probability from status print ''; - } - + } + /* * Boutons actions */ @@ -895,7 +949,7 @@ else print ''; } } - + // Validate if ($object->statut == 0 && $user->rights->projet->creer) { @@ -908,7 +962,7 @@ else print ''; } } - + // Close if ($object->statut == 1 && $user->rights->projet->creer) { @@ -921,7 +975,7 @@ else print ''; } } - + // Reopen if ($object->statut == 2 && $user->rights->projet->creer) { @@ -934,8 +988,8 @@ else print ''; } } - - // Add button to create objects from project + + // Add button to create objects from project if (! empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) { if (! empty($conf->propal->enabled) && $user->rights->propal->creer) @@ -989,7 +1043,7 @@ else print ''; } } - + // Clone if ($user->rights->projet->creer) { @@ -1002,7 +1056,7 @@ else print ''; } } - + // Delete if ($user->rights->projet->supprimer || ($object->statut == 0 && $user->rights->projet->creer)) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d5765f102d5..d14645e5e99 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -54,10 +54,10 @@ class Project extends CommonObject var $date_start; var $date_end; var $date_close; - + var $socid; // To store id of thirdparty var $thirdparty_name; // To store name of thirdparty (defined only in some cases) - + var $user_author_id; //!< Id of project creator. Not defined if shared project. var $user_close_id; var $public; //!< Tell if this is a public or private project @@ -234,7 +234,7 @@ class Project extends CommonObject global $langs, $conf; $error=0; - + // Clean parameters $this->title = trim($this->title); $this->description = trim($this->description); @@ -463,9 +463,9 @@ class Project extends CommonObject function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') { $elements = array(); - + if ($this->id <= 0) return $elements; - + if ($type == 'agenda') { $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; @@ -770,7 +770,7 @@ class Project extends CommonObject if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - // TODO What to do if fk_opp_status is not code 'WIN' or 'LOST' + // TODO What to do if fk_opp_status is not code 'WON' or 'LOST' } dol_syslog(get_class($this)."::setClose", LOG_DEBUG); @@ -905,7 +905,7 @@ class Project extends CommonObject if ($moreinpopup) $label.='
    '.$moreinpopup; $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; - if ($option != 'nolink') + if ($option != 'nolink') { if (preg_match('/\.php$/',$option)) { $link = 'societe_id; - + $projectsListId = $this->getProjectsAuthorizedForUser($user,$mine?$mine:($user->rights->projet->all->lire?2:0),1,$socid); - + $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; $sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; $sql.= ")"; @@ -1626,33 +1626,33 @@ class Project extends CommonObject //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - + $resql=$this->db->query($sql); if ($resql) { $project_static = new Project($this->db); - + $response = new WorkboardResponse(); $response->warning_delay = $conf->projet->warning_delay/60/60/24; $response->label = $langs->trans("OpenedProjects"); if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; else $response->url = DOL_URL_ROOT.'/projet/list.php?mode=mine&search_status=1&mainmenu=project'; $response->img = img_object($langs->trans("Projects"),"project"); - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; - + $project_static->statut = $obj->status; $project_static->opp_status = $obj->opp_status; $project_static->datee = $this->db->jdate($obj->datee); - + if ($project_static->hasDelay()) { $response->nbtodolate++; } } - + return $response; } else @@ -1661,8 +1661,8 @@ class Project extends CommonObject return -1; } } - - + + /** * Function used to replace a thirdparty id with another one. * @@ -1679,8 +1679,8 @@ class Project extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - - + + /** * Charge indicateurs this->nb pour le tableau de bord * @@ -1689,16 +1689,16 @@ class Project extends CommonObject function load_state_board() { global $conf; - + $this->nb=array(); - + $sql = "SELECT count(u.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as u"; $sql.= " WHERE"; //$sql.= " WHERE u.fk_statut > 0"; //$sql.= " AND employee != 0"; $sql.= " u.entity IN (".getEntity('projet', 1).")"; - + $resql=$this->db->query($sql); if ($resql) { @@ -1716,8 +1716,8 @@ class Project extends CommonObject return -1; } } - - + + /** * Is the project delayed? * @@ -1726,16 +1726,16 @@ class Project extends CommonObject public function hasDelay() { global $conf; - + if (! ($this->statut == 1)) return false; if (! $this->datee) return false; $now = dol_now(); return $this->datee < ($now - $conf->projet->warning_delay); - } + } + - /** * Charge les informations d'ordre info dans l'objet commande * @@ -1762,27 +1762,87 @@ class Project extends CommonObject $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; } - + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); $this->date_cloture = $this->db->jdate($obj->datecloture); } - + $this->db->free($result); - + } else { dol_print_error($this->db); } } - + + /** + * Sets object to supplied categories. + * + * Deletes object from existing categories not supplied. + * Adds it to non existing supplied categories. + * Existing categories are left untouch. + * + * @param int[]|int $categories Category or categories IDs + */ + public function setCategories($categories) + { + // Decode type + $type_id = Categorie::TYPE_PROJECT; + $type_text = 'project'; + + + // Handle single category + if (!is_array($categories)) { + $categories = array($categories); + } + + // Get current categories + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $c = new Categorie($this->db); + $existing = $c->containing($this->id, $type_id, 'id'); + + // Diff + if (is_array($existing)) { + $to_del = array_diff($existing, $categories); + $to_add = array_diff($categories, $existing); + } else { + $to_del = array(); // Nothing to delete + $to_add = $categories; + } + + // Process + foreach ($to_del as $del) { + if ($c->fetch($del) > 0) { + $result=$c->del_type($this, $type_text); + if ($result<0) { + $this->errors=$c->errors; + $this->error=$c->error; + return -1; + } + } + } + foreach ($to_add as $add) { + if ($c->fetch($add) > 0) { + $result=$c->add_type($this, $type_text); + if ($result<0) { + $this->errors=$c->errors; + $this->error=$c->error; + return -1; + } + } + } + + return 1; + } + } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index e8a5ee57386..502734441d7 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -37,6 +37,7 @@ if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/ if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; @@ -166,7 +167,7 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); if ($code) print $langs->trans("OppStatus".$code); print ''; - + // Opportunity Amount print '
    '.($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
    '.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
    '.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
    '.$langs->trans("Search").'
    :
    '.$langs->trans("T else print ''.$langs->trans("TimeSpentByUser").''.$langs->trans("HourStart").''.$langs->trans("Duration").''.$langs->trans("Note").''.$langs->trans("Note").'
    '.$langs->trans("Visibility").''; - $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); + $array=array(); + if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject"); + if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject"); print $form->selectarray('public',$array,GETPOST('public')?GETPOST('public'):(isset($conf->global->PROJECT_DEFAULT_PUBLIC)?$conf->global->PROJECT_DEFAULT_PUBLIC:$object->public)); print '
    '.$langs->trans("OpportunityAmount").'
    '.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); + print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print "
    '.$langs->trans("OpportunityAmount").''; if (strcmp($object->opp_amount,'')) print price($object->opp_amount,'',$langs,0,0,0,$conf->currency); @@ -194,7 +195,7 @@ $listofreferent=array( 'class'=>'Propal', 'table'=>'propal', 'datefieldname'=>'datep', - 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, 'lang'=>'propal', 'buttonnew'=>'AddProp', 'testnew'=>$user->rights->propal->creer, @@ -234,11 +235,11 @@ $listofreferent=array( 'testnew'=>$user->rights->facture->creer, 'test'=>$conf->facture->enabled && $user->rights->facture->lire), 'proposal_supplier'=>array( - 'name'=>"SuppliersOrders", - 'title'=>"ListSupplierOrdersAssociatedProject", - 'class'=>'CommandeFournisseur', - 'table'=>'commande_fournisseur', - 'datefieldname'=>'date_commande', + 'name'=>"SuppliersProposals", + 'title'=>"ListSupplierProposalsAssociatedProject", + 'class'=>'SupplierProposal', + 'table'=>'supplier_proposal', + 'datefieldname'=>'date', 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id.'&socid='.$socid, 'lang'=>'supplier_proposal', 'buttonnew'=>'AddSupplierProposal', @@ -285,7 +286,7 @@ $listofreferent=array( 'table'=>'fichinter', 'datefieldname'=>'date_valid', 'disableamount'=>1, - 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&projectid='.$id.'&socid='.$socid, + 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', 'testnew'=>$user->rights->ficheinter->creer, @@ -366,19 +367,19 @@ if ($action=="addelement") $tablename = GETPOST("tablename"); $elementselectid = GETPOST("elementselect"); $result=$object->update_element($tablename, $elementselectid); - if ($result<0) + if ($result<0) { setEventMessages($object->error, $object->errors, 'errors'); } } -elseif ($action == "unlink") +elseif ($action == "unlink") { $tablename = GETPOST("tablename"); $elementselectid = GETPOST("elementselect"); $result = $object->remove_element($tablename, $elementselectid); - if ($result < 0) + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -409,7 +410,7 @@ if (! $showdatefilter) print '
    '; print ''; print '
    '; - + $showdatefilter++; } @@ -580,14 +581,14 @@ foreach ($listofreferent as $key => $value) $urlnew=$value['urlnew']; $buttonnew=$value['buttonnew']; $testnew=$value['testnew']; - + if ($qualified) { // If we want the project task array to have details of users //if ($key == 'project_task') $key = 'project_task_time'; - + if ($langtoload) $langs->load($langtoload); - + $element = new $classname($db); $addform=''; @@ -595,7 +596,7 @@ foreach ($listofreferent as $key => $value) $idtofilterthirdparty=0; if (! in_array($tablename, array('facture_fourn', 'commande_fournisseur'))) $idtofilterthirdparty=$object->thirdparty->id; - if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty > 0) + if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty > 0) { $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300'); if (! $selectList || ($selectList<0)) @@ -626,18 +627,19 @@ foreach ($listofreferent as $key => $value) else $addform.=''.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).''; $addform.='
    '; } - + print load_fiche_titre($langs->trans($title), $addform, ''); + print "\n".''."\n"; print ''; print ''; // Remove link print ''; // Ref - print ''; + print ''.$langs->trans("Ref").''; // Date - print ''; // Thirdparty or user @@ -766,16 +768,33 @@ foreach ($listofreferent as $key => $value) print "\n"; // Date - if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') $date=$element->date_commande; - elseif ($tablename == 'projet_task') $date=''; // We show no date. Showing date of beginning of task make user think it is date of time consumed - else + $date=''; + if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines + elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status)) { - $date=$element->date; - if (empty($date)) $date=$element->datep; - if (empty($date)) $date=$element->date_contrat; - if (empty($date)) $date=$element->datev; //Fiche inter + if ($tablename=='don') $date = $element->datedon; + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') + { + $date=($element->date_commande?$element->date_commande:$element->date_valid); + } + elseif ($tablename == 'supplier_proposal') $date=$element->date_validation; // There is no other date for this + elseif ($tablename == 'fichinter') $date=$element->datev; // There is no other date for this + elseif ($tablename == 'projet_task') $date=''; // We show no date. Showing date of beginning of task make user think it is date of time consumed + else + { + $date=$element->date; // invoice, ... + if (empty($date)) $date=$element->date_contrat; + if (empty($date)) $date=$element->datev; + } } - print ''; + print ''; // Third party or user print ''; print ''; - print ''; + print ''; if ($i == 0) print ''; print ''; $i++; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 04edadda890..fb29e4089cc 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -63,6 +63,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; $search_all=GETPOST("search_all"); +$search_categ=GETPOST("search_categ",'alpha'); $search_ref=GETPOST("search_ref"); $search_label=GETPOST("search_label"); $search_societe=GETPOST("search_societe"); @@ -147,6 +148,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_all=''; + $search_categ=''; $search_ref=""; $search_label=""; $search_societe=""; @@ -204,13 +206,16 @@ if ($resql) else dol_print_error($db); if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found + $distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as projectid, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat"; $sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; $sql.= ", s.nom as name, s.rowid as socid"; $sql.= ", cls.code as opp_status_code"; +// We'll need these fields in order to filter by categ +if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // Add fields for extrafields -foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook @@ -219,6 +224,8 @@ $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as ef on (p.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; +// We'll need this table joined to the select in order to filter by categ +if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ // 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 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; if ($search_user > 0) @@ -229,6 +236,8 @@ $sql.= " WHERE p.entity IN (".getEntity('project',1).')'; if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.title', $search_label); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); @@ -266,7 +275,7 @@ if ($search_opp_status) { if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status); if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL"; - if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WIN','LOST'))"; + if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))"; if ($search_opp_status == 'none') $sql .= " AND p.fk_opp_status IS NULL"; } if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); @@ -327,8 +336,8 @@ if ($resql) if ($search_label != '') $param.='&search_label='.$search_label; if ($search_societe != '') $param.='&search_societe='.$search_societe; if ($search_status >= 0) $param.='&search_status='.$search_status; - if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); - if ((is_numeric($search_opp_percent) && $search_opp_percent >= 0) || in_array($search_opp_percent, array('all','none'))) $param.='&search_opp_percent='.urlencode($search_opp_percent); + if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); + if ((is_numeric($search_opp_percent) && $search_opp_percent >= 0) || in_array($search_opp_percent, array('all','openedopp','none'))) $param.='&search_opp_percent='.urlencode($search_opp_percent); if ($search_public != '') $param.='&search_public='.$search_public; if ($search_user > 0) $param.='&search_user='.$search_user; if ($search_sale > 0) $param.='&search_sale='.$search_sale; @@ -372,6 +381,26 @@ if ($resql) print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } + $moreforfilter=''; + + // Filter on categories + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
    '; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$formother->select_categories('project',$search_categ,'search_categ',1); + $moreforfilter.='
    '; + } + + // If the user can view user other than himself + $moreforfilter.='
    '; + $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; + $includeonly=''; + if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.='
    '; + // If the user can view thirdparties other than his' if ($user->rights->societe->client->voir || $socid) { @@ -382,14 +411,6 @@ if ($resql) $moreforfilter.=''; } - // If the user can view user other than himself - $moreforfilter.='
    '; - $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; - $includeonly=''; - if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); - $moreforfilter.='
    '; - if (! empty($moreforfilter)) { print '
    '; @@ -565,7 +586,9 @@ if ($resql) print ''."\n"; - $i = 0; + $i=0; + $var=true; + $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); @@ -591,6 +614,7 @@ if ($resql) print $projectstatic->getNomUrl(1); if ($projectstatic->hasDelay()) print img_warning($langs->trans('Late')); print ''; + if (! $i) $totalarray['nbfield']++; } // Title if (! empty($arrayfields['p.title']['checked'])) @@ -598,6 +622,7 @@ if ($resql) print '
    '; + if (! $i) $totalarray['nbfield']++; } // Company if (! empty($arrayfields['s.nom']['checked'])) @@ -614,6 +639,7 @@ if ($resql) print ' '; } print ''; + if (! $i) $totalarray['nbfield']++; } // Sales Representatives if (! empty($arrayfields['commercial']['checked'])) @@ -655,6 +681,7 @@ if ($resql) print ' '; } print ''; + if (! $i) $totalarray['nbfield']++; } // Date start if (! empty($arrayfields['p.dateo']['checked'])) @@ -662,13 +689,15 @@ if ($resql) print ''; - } + if (! $i) $totalarray['nbfield']++; + } // Date end if (! empty($arrayfields['p.datee']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; } // Visibility if (! empty($arrayfields['p.public']['checked'])) @@ -677,31 +706,46 @@ if ($resql) if ($obj->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print ''; + if (! $i) $totalarray['nbfield']++; } // Amount if (! empty($arrayfields['p.opp_amount']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield']; } if (! empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; - } + if (! $i) $totalarray['nbfield']++; + } if (! empty($arrayfields['p.opp_percent']['checked'])) { print ''; - } + if (! $i) $totalarray['nbfield']++; + } if (! empty($arrayfields['p.budget_amount']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalbudgetfield']=$totalarray['nbfield']; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -719,6 +763,7 @@ if ($resql) print ''; } } + if (! $i) $totalarray['nbfield']++; } // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); @@ -730,6 +775,7 @@ if ($resql) print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['p.tms']['checked'])) @@ -737,16 +783,26 @@ if ($resql) print ''; + if (! $i) $totalarray['nbfield']++; } // Status if (! empty($arrayfields['p.fk_statut']['checked'])) { $projectstatic->statut = $obj->fk_statut; print ''; + if (! $i) $totalarray['nbfield']++; } - // Action column - print ''; - + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + print "\n"; } @@ -754,6 +810,27 @@ if ($resql) $i++; } + + // Show total line + if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield'])) + { + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + elseif ($totalarray['totaloppfield'] == $i) print ''; + elseif ($totalarray['totalbudgetfield'] == $i) print ''; + else print ''; + } + print ''; + } + $db->free($resql); $parameters=array('sql' => $sql); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index f3f58c17119..6689f966c15 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -194,7 +194,7 @@ if ($id > 0 || ! empty($ref)) print '
    '.$langs->trans("Ref").''; + print ''; if (! in_array($tablename, array('projet_task'))) print $langs->trans("Date"); print ''.dol_print_date($date,'day').''; + if ($tablename == 'actioncomm') + { + print dol_print_date($element->datep,'dayhour'); + if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef,'dayhour'); + } + else print dol_print_date($date,'day'); + print ''; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 1b0dec4d9f8..752e3615464 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -114,7 +114,7 @@ if (count($listofsearchfields)) { if ($i == 0) print '
    '.$langs->trans("Search").'
    :
    '; print dol_trunc($obj->title,80); print ''; print dol_print_date($db->jdate($obj->date_start),'day'); print ''; print dol_print_date($db->jdate($obj->date_end),'day'); print ''; - if ($obj->opp_status_code) print price($obj->opp_amount, 1, '', 1, -1, -1, ''); + if ($obj->opp_status_code) + { + print price($obj->opp_amount, 1, '', 1, -1, -1, ''); + $totalarray['totalopp'] += $obj->opp_amount; + } print ''; if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code); print ''; if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%'; print ''; - if ($obj->budget_amount != '') print price($obj->budget_amount, 1, '', 1, -1, -1); + if ($obj->budget_amount != '') + { + print price($obj->budget_amount, 1, '', 1, -1, -1); + $totalarray['totalbudget'] += $obj->budget_amount; + } print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''.$projectstatic->getLibStatut(5).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
    '.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalopp']).''.price($totalarray['totalbudget']).'
    '; // Ref - print '
    '; + print '
    '; print $langs->trans("Ref"); print ''; // Define a complementary filter for search of next/prev ref. @@ -255,7 +255,7 @@ if ($id > 0 || ! empty($ref)) $linkback=GETPOST('withproject')?''.$langs->trans("BackToList").'':''; // Ref - print '
    '.$langs->trans('Ref').''; + print '
    '.$langs->trans('Ref').''; if (! GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 07fda131407..c9a69fc81a4 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -137,7 +137,7 @@ if ($object->id > 0) print ''; // Ref - print '
    '; + print '
    '; print $langs->trans("Ref"); print ''; // Define a complementary filter for search of next/prev ref. @@ -198,7 +198,7 @@ if ($object->id > 0) print ''; // Ref - print ''; - $i = 0; + $plannedworkloadoutputformat='allhourmin'; + $timespentoutputformat='allhourmin'; + if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; + if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + + $now = dol_now(); + $i=0; + $var=true; + $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); @@ -578,6 +586,7 @@ if ($resql) print $projectstatic->getNomUrl(1, 'task'); if ($projectstatic->hasDelay()) print img_warning("Late"); print ''; + if (! $i) $totalarray['nbfield']++; } // Title if (! empty($arrayfields['p.title']['checked'])) @@ -585,6 +594,7 @@ if ($resql) print ''; + if (! $i) $totalarray['nbfield']++; } // Company if (! empty($arrayfields['s.nom']['checked'])) @@ -601,6 +611,7 @@ if ($resql) print ' '; } print ''; + if (! $i) $totalarray['nbfield']++; } // Status if (! empty($arrayfields['p.fk_statut']['checked'])) @@ -608,6 +619,7 @@ if ($resql) print ''; + if (! $i) $totalarray['nbfield']++; } // Ref if (! empty($arrayfields['t.ref']['checked'])) @@ -616,6 +628,7 @@ if ($resql) print $taskstatic->getNomUrl(1,'withproject'); if ($taskstatic->hasDelay()) print img_warning("Late"); print ''; + if (! $i) $totalarray['nbfield']++; } // Label if (! empty($arrayfields['t.label']['checked'])) @@ -623,6 +636,7 @@ if ($resql) print ''; + if (! $i) $totalarray['nbfield']++; } // Date start if (! empty($arrayfields['t.dateo']['checked'])) @@ -630,20 +644,17 @@ if ($resql) print ''; - } + if (! $i) $totalarray['nbfield']++; + } // Date end if (! empty($arrayfields['t.datee']['checked'])) { print ''; + if (! $i) $totalarray['nbfield']++; } - $plannedworkloadoutputformat='allhourmin'; - $timespentoutputformat='allhourmin'; - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; - // Planned workload if (! empty($arrayfields['t.planned_workload']['checked'])) { @@ -658,6 +669,9 @@ if ($resql) } //else print '--:--'; print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield']; + $totalarray['totalplannedworkload'] += $obj->planned_workload; } // Time spent if (! empty($arrayfields['t.duration_effective']['checked'])) @@ -671,6 +685,9 @@ if ($resql) if ($showlineingray) print ''; else print ''; print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield']; + $totalarray['totaldurationeffective'] += $obj->duration_effective; } // Calculated progress if (! empty($arrayfields['t.progress_calculated']['checked'])) @@ -682,6 +699,7 @@ if ($resql) else print $langs->trans('WorkloadNotDefined'); } print ''; + if (! $i) $totalarray['nbfield']++; } // Declared progress if (! empty($arrayfields['t.progress']['checked'])) @@ -692,6 +710,7 @@ if ($resql) print $obj->progress.' %'; } print ''; + if (! $i) $totalarray['nbfield']++; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -707,6 +726,7 @@ if ($resql) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + if (! $i) $totalarray['nbfield']++; } } } @@ -720,6 +740,7 @@ if ($resql) print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['t.tms']['checked'])) @@ -727,6 +748,7 @@ if ($resql) print ''; + if (! $i) $totalarray['nbfield']++; } // Status /*if (! empty($arrayfields['p.fk_statut']['checked'])) @@ -734,9 +756,17 @@ if ($resql) $projectstatic->statut = $obj->fk_statut; print ''; }*/ - // Action column - print ''; - + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + print "\n"; //print projectLinesa(); @@ -744,6 +774,27 @@ if ($resql) $i++; } + + // Show total line + if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield'])) + { + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + elseif ($totalarray['totalplannedworkloadfield'] == $i) print ''; + elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''; + else print ''; + } + print ''; + } + $db->free($resql); $parameters=array('sql' => $sql); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index e62e58df58b..5d5cb38dbe5 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -117,7 +117,7 @@ if ($object->id > 0) print '
    '; + print '
    '; print $langs->trans("Ref"); print ''; if (empty($withproject) || empty($projectstatic->id)) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 47083e9032d..dd97f0a7a15 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -545,7 +545,15 @@ if ($resql) print '
    '; print dol_trunc($obj->projecttitle,80); print ''; print $projectstatic->getLibStatut(1); print ''; print $taskstatic->label; print ''; print dol_print_date($db->jdate($obj->date_start),'day'); print ''; print dol_print_date($db->jdate($obj->date_end),'day'); print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''.$projectstatic->getLibStatut(5).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
    '.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).''.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).'
    '; // Ref - print ''; - print ''; print '';*/ + // Affichage fiche action en mode visu print '
    '; + print '
    '; print $langs->trans("Ref"); print ''; // Define a complementary filter for search of next/prev ref. @@ -172,7 +172,7 @@ if ($object->id > 0) $linkback=GETPOST('withproject')?''.$langs->trans("BackToList").'':''; // Ref - print '
    '.$langs->trans("Ref").''; + print '
    '.$langs->trans("Ref").''; if (empty($withproject) || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 55b286047d9..0dd08bbd342 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -92,8 +92,8 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) $object->description = $_POST['description']; $object->fk_task_parent = $task_parent; $object->planned_workload = $planned_workload; - $object->date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user'); - $object->date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user'); + $object->date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']); + $object->date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); $object->progress = $_POST['progress']; // Fill array 'array_options' with data from add form diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 8eacca6f09e..0caf1461e88 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * @@ -34,25 +34,80 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load('projects'); $id=GETPOST('id','int'); +$projectid=GETPOST('projectid','int'); $ref=GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $withproject=GETPOST('withproject','int'); $project_ref=GETPOST('project_ref','alpha'); +$search_dateday=GETPOST('search_dateday'); +$search_datemonth=GETPOST('search_datemonth'); +$search_dateyear=GETPOST('search_dateyear'); +$search_datehour=''; +$search_datewithhour=''; +$search_note=GETPOST('search_note','alpha'); +$search_duration=GETPOST('search_duration','int'); +$search_value=GETPOST('search_value','int'); + // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; if (!$user->rights->projet->lire) accessforbidden(); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield='t.task_date,t.task_datehour,t.rowid'; +if (! $sortorder) $sortorder='DESC'; + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('projecttaskcard','globalcard')); + $object = new Task($db); $projectstatic = new Project($db); +$extrafields_project = new ExtraFields($db); +$extrafields_task = new ExtraFields($db); + +if ($projectid > 0 || ! empty($ref)) +{ + // fetch optionals attributes and labels + $extralabels_projet=$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); +} +$extralabels_task=$extrafields_task->fetch_name_optionals_label($object->table_element); /* * Actions */ +$parameters=array('socid'=>$socid, 'projectid'=>$projectid); +$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'); + +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $search_date=''; + $search_datehour=''; + $search_datewithhour=''; + $search_note=''; + $search_duration=''; + $search_value=''; + $search_date_creation=''; + $search_date_update=''; + $toselect=''; + $search_array_options=array(); + $action=''; +} + if ($action == 'addtimespent' && $user->rights->projet->lire) { $error=0; @@ -202,7 +257,6 @@ if (GETPOST('projectid')) } - /* * View @@ -223,12 +277,14 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { $result=$projectstatic->fetch($projectidforalltimes); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); } elseif ($object->fetch($id, $ref) >= 0) { $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - + $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); + $object->project = clone $projectstatic; } @@ -247,7 +303,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print ''; - // Budget - print ''; - - // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields_project->attribute_label)) + if ((! $id && ! $ref) || ! empty($projectidforalltimes)) // Not a dedicated task { - print $object->showOptionals($extrafields_project); - } - + // Budget + print ''; + + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$projectstatic,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields_project->attribute_label)) + { + print $projectstatic->showOptionals($extrafields_project); + } + } + print '
    '; @@ -291,19 +347,22 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print dol_print_date($projectstatic->date_end,'day'); print '
    '.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,0,0,0,$conf->currency); - print '
    '.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,0,0,0,$conf->currency); + print '
    '; dol_fiche_end(); @@ -312,7 +371,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) /* * Actions */ - if (empty($id)) + + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { print '
    '; @@ -353,7 +413,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $linkback=$withproject?''.$langs->trans("BackToList").'':''; // Ref - print '
    '; + print '
    '; print $langs->trans("Ref"); print ''; if (! GETPOST('withproject') || empty($projectstatic->id)) @@ -492,19 +552,51 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($projectstatic->id > 0) { + if ($action == 'deleteline') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.'&lineid='.$_GET["lineid"].($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); + } + + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array + $hookmanager->initHooks(array('tasktimelist')); + $extrafields = new ExtraFields($db); + + // Definition of fields for list + $arrayfields=array(); + $arrayfields['t.task_date']=array('label'=>$langs->trans("Date"), 'checked'=>1); + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + { + $arrayfields['t.task_ref']=array('label'=>$langs->trans("Task"), 'checked'=>1); + } + $arrayfields['author']=array('label'=>$langs->trans("By"), 'checked'=>1); + $arrayfields['t.note']=array('label'=>$langs->trans("Note"), 'checked'=>1); + $arrayfields['t.task_duration']=array('label'=>$langs->trans("Duration"), 'checked'=>1); + $arrayfields['value']=array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>$conf->salaries->enabled); + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } + } + /* * List of time spent */ $tasks = array(); - $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm"; - $sql.= ", u.lastname, u.firstname"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE t.fk_user = u.rowid"; + $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; + $sql .= " pt.ref, pt.label,"; + $sql .= " u.lastname, u.firstname"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; - $sql .= " ORDER BY t.task_date DESC, t.task_datehour DESC, t.rowid DESC"; - + else $sql.= " AND pt.fk_projet IN (".$projectidforalltimes.")"; + if ($search_ref) $sql .= natural_search('c.ref', $search_ref); + if ($search_note) $sql .= natural_search('t.note', $search_note); + $sql .= $db->order($sortfield, $sortorder); + $var=true; $resql = $db->query($sql); if ($resql) @@ -534,27 +626,152 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_print_error($db); } - print '
    '; + + $arrayofselected=is_array($toselect)?$toselect:array(); + + $params=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_note != '') $params.= '&search_note='.urlencode($search_note); + if ($search_duration != '') $params.= '&search_field2='.urlencode($search_duration); + if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Add $param from extra fields + /*foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + }*/ + if ($id) $params.='&id='.$id; + if ($projectid) $params.='&projectid='.$projectid; + if ($withproject) $params.='&withproject='.$withproject; + + + $arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + //if ($user->rights->projet->creer) $arrayofmassactions['delete']=$langs->trans("Delete"); + if ($massaction == 'presend') $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + + + + print ''; + if ($optioncss != '') print ''; print ''; - print ''; - print ''; + print ''; + if ($action == 'editline') print ''; + else print ''; + print ''; + print ''; + + print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->salaries->enabled)) + $moreforfilter = ''; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (! empty($moreforfilter)) { - print ''; + print '
    '; + print $moreforfilter; + print '
    '; } - print ''; + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
    '.$langs->trans("Date").''.$langs->trans("By").''.$langs->trans("Note").''.$langs->trans("TimeSpent").''.$langs->trans("Value").' 
    '."\n"; + + print ''; + if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$params,'',$sortfield,$sortorder); + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + { + if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$params,'',$sortfield,$sortorder); + } + if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$params,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$params,'align="right"',$sortfield,$sortorder); + // 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'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } + }*/ + // Hook fields + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; + // Fields title search + print ''; + // LIST_OF_TD_TITLE_SEARCH + if (! empty($arrayfields['t.task_date']['checked'])) print ''; + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + { + if (! empty($arrayfields['t.task_ref']['checked'])) print ''; + } + if (! empty($arrayfields['author']['checked'])) print ''; + if (! empty($arrayfields['t.note']['checked'])) print ''; + if (! empty($arrayfields['t.task_duration']['checked'])) print ''; + if (! empty($arrayfields['value']['checked'])) print ''; + // 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'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } + }*/ + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + print ''."\n"; + + $tasktmp = new Task($db); + + $i = 0; $total = 0; $totalvalue = 0; + $totalarray=array(); foreach ($tasks as $task_time) { $var=!$var; @@ -564,76 +781,119 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $date2=$db->jdate($task_time->task_datehour); // Date - print ''; + if (! $i) $totalarray['nbfield']++; } - else - { - print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); - } - print ''; + // Task + if (! empty($arrayfields['t.task_ref']['checked'])) + { + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + // User - print ''; + if (! empty($arrayfields['author']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Note - print ''; - + if (! empty($arrayfields['t.note']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Time spent - print ''; - + if (! empty($arrayfields['t.task_duration']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield']; + $totalarray['totalduration'] += $task_time->task_duration; + } + // Value spent - if ($conf->salaries->enabled) - { + if (! empty($arrayfields['value']['checked'])) + { print ''; - } + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; + $totalarray['totalvalue'] += $value; + } - // Edit and delete icon - print ''; - + print ''; + if (! $i) $totalarray['nbfield']++; + print "\n"; - $total += $task_time->task_duration; - $totalvalue += price2num($task_time->thm * $task_time->task_duration / 3600); + + $i++; } - print ''; - print ''; - if ($conf->salaries->enabled) + + // Show total line + if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) { - print ''; + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + elseif ($totalarray['totaldurationfield'] == $i) print ''; + elseif ($totalarray['totalvaluefield'] == $i) print ''; + else print ''; + } + print ''; } - print ''; + print ''; print "
    '; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + print $searchpitco; + print '
    '; - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + if (! empty($arrayfields['t.task_date']['checked'])) { - print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); + print ''; + if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); + } + else + { + print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); + } + print ''; + $tasktmp->id = $task_time->fk_task; + $tasktmp->ref = $task_time->ref; + $tasktmp->label = $task_time->label; + print $tasktmp->getNomUrl(1, 'withproject', 'time'); + print ''; - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) - { - $contactsoftask=$object->getListContactId('internal'); - if (!in_array($task_time->fk_user,$contactsoftask)) { - $contactsoftask[]=$task_time->fk_user; - } - if (count($contactsoftask)>0) { - print img_object('','user','class="hideonsmartphone"'); - print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask); - }else { - print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); - } - } - else - { - $userstatic->id = $task_time->fk_user; - $userstatic->lastname = $task_time->lastname; - $userstatic->firstname = $task_time->firstname; - print $userstatic->getNomUrl(1); - } - print ''; + if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); + $contactsoftask=$object->getListContactId('internal'); + if (!in_array($task_time->fk_user,$contactsoftask)) { + $contactsoftask[]=$task_time->fk_user; + } + if (count($contactsoftask)>0) { + print img_object('','user','class="hideonsmartphone"'); + print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask); + }else { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + } + else + { + $userstatic->id = $task_time->fk_user; + $userstatic->lastname = $task_time->lastname; + $userstatic->firstname = $task_time->firstname; + print $userstatic->getNomUrl(1); + } + print ''; - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - } - else - { - print dol_nl2br($task_time->note); - } - print ''; + if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { + print dol_nl2br($task_time->note); + } + print ''; - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); - } - else - { - print convertSecondToTime($task_time->task_duration,'allhourmin'); - } - print ''; + if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); + } + else + { + print convertSecondToTime($task_time->task_duration,'allhourmin'); + } + print ''; - print price(price2num($task_time->thm * $task_time->task_duration / 3600), 1, $langs, 1, -1, -1, $conf->currency); + $value = price2num($task_time->thm * $task_time->task_duration / 3600); + print price($value, 1, $langs, 1, -1, -1, $conf->currency); print ''; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action column + print ''; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { print ''; @@ -653,19 +913,34 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print img_delete(); print ''; } - print '
    '.$langs->trans("Total").''.convertSecondToTime($total,'allhourmin').''.price($totalvalue, 1, $langs, 1, -1, -1, $conf->currency).'
    '.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.convertSecondToTime($totalarray['totalduration'],'allhourmin').''.price($totalarray['totalvalue']).'
     
    "; diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 1dd8fc461e0..e50193d8d51 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -90,7 +90,7 @@ if (empty($reshook)) 'mailmanspip','notification','oauth','syslog','user','webservices', // Extended modules 'memcached','numberwords','zipautofillfr'); - $alwayshiddenuncheckedmodules=array('ftp','webservicesclient','websites', + $alwayshiddenuncheckedmodules=array('ftp','hrm','webservicesclient','websites', // Extended modules 'awstats','bittorrent','bootstrap','cabinetmed','cmcic','concatpdf','customfield','deplacement','dolicloud','filemanager','lightbox','mantis','monitoring','moretemplates','multicompany','nltechno','numberingpack','openstreetmap', 'ovh','phenix','phpsysinfo','pibarcode','postnuke','selectbank','skincoloreditor','submiteverywhere','survey','thomsonphonebook','topten','tvacerfa','voyage','webcalendar','webmail'); @@ -375,8 +375,11 @@ foreach ($demoprofiles as $profilearray) $listofdisabledmodules=explode(',',$profilearray['disablemodules']); $j=0; $nbcolsmod=empty($conf->dol_optimize_smallscreen)?4:3; - foreach($modules as $val) // Loop on qualified (enabled) modules + //var_dump($modules); + foreach($orders as $index => $key) // Loop on qualified (enabled) modules { + //print $index.' '.$key; + $val = $modules[$index]; $modulekeyname=strtolower($val->name); $modulequalified=1; @@ -454,7 +457,7 @@ if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLI } else { - print ''."\n"; + print ''."\n"; } } diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index 4171bbab2e1..404b7085bdb 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -114,7 +114,7 @@ $sql.= " AND statut = 1"; $sql.= " AND public = 1"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($conf->liste_limit+1, $offset); -//$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, zip, town, d.email, t.libelle as type, d.morphy, d.statut, t.cotisation"; +//$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, zip, town, d.email, t.libelle as type, d.morphy, d.statut, t.subscription"; //$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; //$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = $statut"; //$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset); diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 834f17b8b2c..6f242a00544 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -41,7 +41,6 @@ if (GETPOST('sondage')) $object=new Opensurveysondage($db); $result=$object->fetch(0,$numsondage); -if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage); $nblignes=$object->fetch_lines(); @@ -241,6 +240,16 @@ $arrayofjs=array(); $arrayofcss=array('/opensurvey/css/style.css'); llxHeaderSurvey($object->titre, "", 0, 0, $arrayofjs, $arrayofcss); +if (empty($object->ref)) // For survey, id is a hex string +{ + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); + + llxFooterSurvey(); + + $db->close(); + exit; +} // Define format of choices $toutsujet=explode(",",$object->sujet); diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 481fd17f049..1945aa6c8cf 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -649,7 +649,7 @@ if (GETPOST("source") == 'membersubscription' && $valid) $langs->load("members"); require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $member=new Adherent($db); $result=$member->fetch('',$ref); @@ -660,7 +660,7 @@ if (GETPOST("source") == 'membersubscription' && $valid) } else { - $subscription=new Cotisation($db); + $subscription=new Subscription($db); } $amount=$subscription->total_ttc; diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index dcb43c07170..b5d105d6cf6 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -804,7 +804,7 @@ if (GETPOST("source") == 'membersubscription' && $valid) $langs->load("members"); require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $member=new Adherent($db); $result=$member->fetch('',$ref); @@ -815,7 +815,7 @@ if (GETPOST("source") == 'membersubscription' && $valid) } else { - $subscription=new Cotisation($db); + $subscription=new Subscription($db); } $amount=$subscription->total_ttc; diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index 28ff4bdb743..05a291d5c4d 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -82,7 +82,7 @@ else

    This page is a sample of page using tables. It is designed to make test with
    - css (add parameter &theme=newtheme to test another theme or edit css of current theme)
    -- jmobile (add parameter ">dol_use_jmobile=1&dol_optimize_smallscreen=1 to enable view with jmobile)
    +- jmobile (add parameter ">dol_use_jmobile=1&dol_optimize_smallscreen=1 and switch to small screen < 960 to enable view with jmobile)
    - no javascript / usage for bind people (add parameter ">nojs=1 to force disable javascript)
    - dataTables
    - tablednd
    diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php index 8c83a1daebc..44789409058 100644 --- a/htdocs/public/websites/index.php +++ b/htdocs/public/websites/index.php @@ -144,6 +144,7 @@ if (! file_exists($original_file_osencoded)) // Output page content +define('USEDOLIBARRSERVER', 1); print "\n".''."\n"; include_once $original_file_osencoded; diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php index 70d1da95969..7608e1b6cf3 100644 --- a/htdocs/resource/add.php +++ b/htdocs/resource/add.php @@ -135,7 +135,7 @@ if (! $action) // Ref / label $field = 'ref'; print '

    '; + print ''; print $langs->trans('ResourceFormLabel_'.$field); print ''; @@ -166,11 +166,11 @@ if (! $action) dol_fiche_end(''); - echo '
    ', - '', - '   ', - '', - '
    '; + print '
    '; + print ''; + print '     '; + print ''; + print '
    '; print ''; } diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 0a738846363..633be01aa1b 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -339,7 +339,7 @@ class Dolresource extends CommonObject if ($this->db->query($sql)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; - $sql.= " WHERE element_type='resource' AND resource_id ='".$this->db->escape($rowid)."'"; + $sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); if ($this->db->query($sql)) { @@ -393,7 +393,6 @@ class Dolresource extends CommonObject } } } - $sql.= " GROUP BY t.rowid, t.entity, t.ref, t.description, t.fk_code_type_resource, t.tms, ty.label"; $sql.= $this->db->order($sortfield,$sortorder); $this->num_all = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -410,10 +409,9 @@ class Dolresource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + $this->lines=array(); + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); $line = new Dolresource($this->db); $line->id = $obj->rowid; $line->ref = $obj->ref; @@ -421,8 +419,7 @@ class Dolresource extends CommonObject $line->fk_code_type_resource = $obj->fk_code_type_resource; $line->type_label = $obj->type_label; - $this->lines[$i] = $line; - $i++; + $this->lines[] = $line; } $this->db->free($resql); } @@ -473,7 +470,6 @@ class Dolresource extends CommonObject } } } - $sql.= " GROUP BY t.rowid, ty.label"; $sql.= $this->db->order($sortfield,$sortorder); if ($limit) $sql.= $this->db->plimit($limit+1,$offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); @@ -484,10 +480,8 @@ class Dolresource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); $line = new Dolresource($this->db); $line->id = $obj->rowid; $line->resource_id = $obj->resource_id; @@ -502,9 +496,8 @@ class Dolresource extends CommonObject $line->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type); if($obj->element_id && $obj->element_type) $line->objelement = fetchObjectByElement($obj->element_id,$obj->element_type); - $this->lines[$i] = $line; + $this->lines[] = $line; - $i++; } $this->db->free($resql); } @@ -559,7 +552,6 @@ class Dolresource extends CommonObject } } } - $sql.= " GROUP BY t.resource_id"; $sql.= $this->db->order($sortfield,$sortorder); if ($limit) $sql.= $this->db->plimit($limit+1,$offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); @@ -570,10 +562,9 @@ class Dolresource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + $this->lines=array(); + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); $line = new Dolresource($this->db); $line->id = $obj->rowid; $line->resource_id = $obj->resource_id; @@ -584,9 +575,7 @@ class Dolresource extends CommonObject $line->mandatory = $obj->mandatory; $line->fk_user_create = $obj->fk_user_create; - $this->lines[$i] = fetchObjectByElement($obj->resource_id,$obj->resource_type); - - $i++; + $this->lines[] = fetchObjectByElement($obj->resource_id,$obj->resource_type); } $this->db->free($resql); } @@ -759,7 +748,7 @@ class Dolresource extends CommonObject /** * Return an array with resources linked to the element - * + * * @param string $element Element * @param int $element_id Id * @param string $resource_type Type @@ -770,7 +759,7 @@ class Dolresource extends CommonObject // Links beetween objects are stored in this table $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_resources'; - $sql.= " WHERE element_id='".$element_id."' AND element_type='".$element."'"; + $sql.= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'"; if($resource_type) $sql.=" AND resource_type LIKE '%".$resource_type."%'"; $sql .= ' ORDER BY resource_type'; diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index f8e9e052995..27451b07973 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -51,7 +51,7 @@ $hookmanager->initHooks(array('element_resource')); $object->available_resources = array('dolresource'); // Get parameters -$id = GETPOST('id','int'); +$id = GETPOST('id','int'); $action = GETPOST('action','alpha'); $mode = GETPOST('mode','alpha'); $lineid = GETPOST('lineid','int'); @@ -196,24 +196,105 @@ else dol_fiche_head($head, 'resources', $langs->trans("Action"),0,'action'); + $linkback =img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"'); + $linkback.= ''.$langs->trans("BackToList").''; + + // Link to other agenda views + $out=''; + $out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"'); + $out.=''.$langs->trans("ViewPerUser").''; + $out.='
    '; + $out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"'); + $out.=''.$langs->trans("ViewCal").''; + $out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"'); + $out.=''.$langs->trans("ViewWeek").''; + $out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); + $out.=''.$langs->trans("ViewDay").''; + + $linkback.=$out; + + dol_banner_tab($act, 'element_id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '', "&element=".$element); + + print '
    '; + + // Ref + /*print '
    '.$langs->trans("Ref").''; + print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); + print '
    '; - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; + print ''; } - // Title - print ''; + // Full day event + print ''; + + // Date start + print ''; + print ''; + + // Date end + print ''; + + // Status + /*print '';*/ + + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { + print ''; + } + + // Assigned to + print ''; + print '
    '.$langs->trans("Ref").''; - print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); - print '
    '.$langs->trans("Type").''.$act->type.'
    '.$langs->trans("Type").''.$act->type.'
    '.$langs->trans("Title").''.$act->label.'
    '.$langs->trans("EventOnFullDay").''.yn($act->fulldayevent, 3).'
    '.$langs->trans("DateActionStart").''; + if (! $act->fulldayevent) print dol_print_date($act->datep,'dayhour'); + else print dol_print_date($act->datep,'day'); + if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); + print '
    '.$langs->trans("DateActionEnd").''; + if (! $act->fulldayevent) print dol_print_date($act->datef,'dayhour'); + else print dol_print_date($act->datef,'day'); + if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); + print '
    '.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + print $act->getLibStatut(4); + print '
    '.$langs->trans("Location").''.$act->location.'
    '.$langs->trans("ActionAffectedTo").''; + $listofuserid=array(); + if (empty($donotclearsession)) + { + if ($act->userownerid > 0) $listofuserid[$act->userownerid]=array('id'=>$act->userownerid,'transparency'=>$act->transparency); // Owner first + if (! empty($act->userassigned)) // Now concat assigned users + { + // Restore array with key with same value than param 'id' + $tmplist1=$act->userassigned; $tmplist2=array(); + foreach($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $act->userownerid) $listofuserid[$val['id']]=$val; + } + } + $_SESSION['assignedtouser']=json_encode($listofuserid); + } + else + { + if (!empty($_SESSION['assignedtouser'])) + { + $listofuserid=json_decode($_SESSION['assignedtouser'], true); + } + } + print '
    '; + print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print '
    '; + if (in_array($user->id,array_keys($listofuserid))) + { + print '
    '; + print $langs->trans("MyAvailability").': '.(($act->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody + print '
    '; + } + print '
    '; dol_fiche_end(); @@ -225,38 +306,37 @@ else */ if ($element_id && $element == 'societe') { - $socstatic = fetchObjectByElement($element_id,$element); - if (is_object($socstatic)) - { - $savobject = $object; - - $object = $socstatic; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $head = societe_prepare_head($socstatic); - - dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"),0,'company'); - - dol_banner_tab($socstatic, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); - + $socstatic = fetchObjectByElement($element_id, $element); + if (is_object($socstatic)) { + $savobject = $object; + + $object = $socstatic; + + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + $head = societe_prepare_head($socstatic); + + dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"), 0, 'company'); + + dol_banner_tab($socstatic, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + print '
    '; - - print '
    '; + + print '
    '; print ''; - + // Alias name (commercial, trademark or alias name) - print '"; - - print '
    '.$langs->trans('AliasNames').''; + print '
    ' . $langs->trans('AliasNames') . ''; print $socstatic->name_alias; print "
    '; - - print '
    '; - - dol_fiche_end(); - - $object = $savobject; - } + + print '
    '; + + print ''; + + dol_fiche_end(); + + $object = $savobject; + } } /* @@ -303,13 +383,13 @@ else if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - //print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); - - + //print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); + print '
    '; + // Show list of resource links - foreach ($object->available_resources as $modresources => $resources) - { + foreach ($object->available_resources as $modresources => $resources) + { $resources=(array) $resources; // To be sure $resources is an array foreach($resources as $resource_obj) { @@ -327,13 +407,12 @@ else // If we have a specific template we use it if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'))) { - $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); + $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); } else { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; + $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; } - //var_dump($element_id); if ($mode != 'add' || $resource_obj != $resource_type) { diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 4547c7d75da..4a46a5ed934 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -81,7 +81,9 @@ if ($socid) dol_fiche_head($head, 'agenda', $langs->trans("ThirdParty"),0,'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; @@ -113,10 +115,11 @@ if ($socid) print '
    '; - - print '
    '; + //print '
    '; - $object->info($socid); + //print '
    '; + + $object->info($socid); print dol_print_object_info($object, 1); print '
    '; @@ -162,15 +165,39 @@ if ($socid) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { - print '
    '; - - print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - + + $actioncode = ''; + if(!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { + + if (GETPOST('actioncode','array')) + { + $actioncode=GETPOST('actioncode','array',3); + if (! count($actioncode)) $actioncode='0'; + } + else + { + $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + } + + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + + print '
    '; + print ''; + $formactions->select_type_actions($actioncode, "actioncode", '', 0, 0, 0); + print ''; + print '

    ' ; + + + } + + print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); + // List of todo actions - show_actions_todo($conf,$langs,$db,$object,null,0,1); + show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); // List of done actions - show_actions_done($conf,$langs,$db,$object); + show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); } } diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index cd0dd6ae38f..8431f294469 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -84,16 +84,16 @@ class Contacts extends DolibarrApi * * Get a list of contacts * - * @param int $socid ID of thirdparty to filter list * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $socid ID of thirdparty to filter list * @return array Array of contact objects * * @throws RestException */ - function index($socid = 0, $sortfield = "c.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "c.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $socid = 0) { global $db, $conf; $obj_ret = array(); @@ -154,7 +154,7 @@ class Contacts extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $contact_static = new Contact($db); diff --git a/htdocs/societe/class/api_deprecated_contact.class.php b/htdocs/societe/class/api_deprecated_contact.class.php index 2a6a4b948b8..e645c3e15ff 100644 --- a/htdocs/societe/class/api_deprecated_contact.class.php +++ b/htdocs/societe/class/api_deprecated_contact.class.php @@ -167,7 +167,7 @@ class ContactApi extends DolibarrApi { $i = 0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $contact_static = new Contact($db); diff --git a/htdocs/societe/class/api_deprecated_thirdparty.class.php b/htdocs/societe/class/api_deprecated_thirdparty.class.php index 3e2f070b9de..3179cb697ce 100644 --- a/htdocs/societe/class/api_deprecated_thirdparty.class.php +++ b/htdocs/societe/class/api_deprecated_thirdparty.class.php @@ -213,7 +213,7 @@ class ThirdpartyApi extends DolibarrApi { $i = 0; $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $soc_static = new Societe($db); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 12fca598a81..a520a7c8f83 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -87,17 +87,17 @@ class Thirdparties extends DolibarrApi * * Get a list of thirdparties * - * @param int $mode Set to 1 to show only customers - * Set to 2 to show only prospects - * Set to 3 to show only those are not customer neither prospect - * @param string $email Search by email filter * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param int $mode Set to 1 to show only customers + * Set to 2 to show only prospects + * Set to 3 to show only those are not customer neither prospect + * @param string $email Search by email filter * @return array Array of thirdparty objects */ - function index($mode=0, $email=NULL, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function index($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $email=NULL) { global $db, $conf; $obj_ret = array(); @@ -152,7 +152,7 @@ class Thirdparties extends DolibarrApi if ($result) { $num = $db->num_rows($result); - while ($i < $num) + while ($i < min($num, ($limit <= 0 ? $num : $limit))) { $obj = $db->fetch_object($result); $soc_static = new Societe($db); diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 61629e63838..f7bad843709 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -37,6 +37,8 @@ class CompanyBankAccount extends Account var $default_rib; var $frstrecur; + var $rum; + var $date_rum; var $datec; var $datem; @@ -110,6 +112,9 @@ class CompanyBankAccount extends Account { $this->create(); } + + if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1); + if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1); $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET"; $sql.= " bank = '" .$this->db->escape($this->bank)."'"; @@ -126,6 +131,8 @@ class CompanyBankAccount extends Account if ($conf->prelevement->enabled) { $sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'"; + $sql.= ",rum = '".$this->db->escape($this->rum)."'"; + $sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null"); } if (trim($this->label) != '') $sql.= ",label = '".$this->db->escape($this->label)."'"; @@ -299,5 +306,39 @@ class CompanyBankAccount extends Account return -1; } } + + /** + * 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->specimen = 1; + $this->ref = 'CBA'; + $this->label = 'CustomerCorp Bank account'; + $this->bank = 'CustomerCorp Bank'; + $this->courant = Account::TYPE_CURRENT; + $this->clos = Account::STATUS_OPEN; + $this->code_banque = '123'; + $this->code_guichet = '456'; + $this->number = 'CUST12345'; + $this->cle_rib = 50; + $this->bic = 'CC12'; + $this->iban = 'FR999999999'; + $this->domiciliation = 'Bank address of customer corp'; + $this->proprio = 'Owner'; + $this->owner_address = 'Owner address'; + $this->country_id = 1; + + $this->rum = 'UMR-CU1212-0007-5-1475405262'; + $this->date_rum =dol_now() - 10000; + $this->frstrecur = 'FRST'; + + $this->socid = 0; + } + } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 61b3ccae469..88bc3ff216d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1166,7 +1166,7 @@ class Societe extends CommonObject $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; $this->fk_account = $obj->fk_account; - + $this->client = $obj->client; $this->fournisseur = $obj->fournisseur; @@ -1431,6 +1431,18 @@ class Societe extends CommonObject } } + // Remove societe_remise + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise"; + $sql.= " WHERE fk_soc = " . $id; + if (! $this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + } + } + // Remove societe_remise_except if (! $error) { @@ -1542,7 +1554,7 @@ class Societe extends CommonObject */ function set_remise_client($remise, $note, User $user) { - global $langs; + global $conf, $langs; // Nettoyage parametres $note=trim($note); @@ -1574,8 +1586,8 @@ class Societe extends CommonObject // Ecrit trace dans historique des remises $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; - $sql.= " (datec, fk_soc, remise_client, note, fk_user_author)"; - $sql.= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; + $sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; + $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; $sql.= " '".$this->db->escape($note)."',"; $sql.= " ".$user->id; $sql.= ")"; @@ -1684,7 +1696,7 @@ class Societe extends CommonObject $reparray=array(); - $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.email, u.statut, u.entity"; + $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) { @@ -1712,6 +1724,8 @@ class Societe extends CommonObject $reparray[$i]['email']=$obj->email; $reparray[$i]['statut']=$obj->statut; $reparray[$i]['entity']=$obj->entity; + $reparray[$i]['login']=$obj->login; + $reparray[$i]['photo']=$obj->photo; $i++; } return $reparray; @@ -1843,7 +1857,7 @@ class Societe extends CommonObject $label.= '
    '; - if ($option == 'customer' || $option == 'compta') + if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') { $label.= '' . $langs->trans("ShowCustomer") . ''; $link = ''; $link = ''; - $link = ''; - $link = ''; @@ -1922,7 +1926,7 @@ class Societe extends CommonObject } $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; - + if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -1979,23 +1983,23 @@ class Societe extends CommonObject } if ($mode == 2) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4').' '.$langs->trans("InActivity"); + if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); + if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); } if ($mode == 3) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5'); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4'); + if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); + if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); } if ($mode == 4) { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4').' '.$langs->trans("InActivity"); + if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); + if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); } if ($mode == 5) { - if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5'); - if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4'); + if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); + if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); } } @@ -2760,7 +2764,7 @@ class Societe extends CommonObject $url=''; $action = ''; - + $hookmanager->initHooks(array('idprofurl')); $parameters=array('idprof'=>$idprof, 'company'=>$thirdparty); $reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -2773,14 +2777,14 @@ class Societe extends CommonObject //if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid if ($idprof == 1 && $thirdparty->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; if ($idprof == 1 && $thirdparty->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; - + if ($url) return ''.$langs->trans("Check").''; } else { return $hookmanager->resPrint; } - + return ''; } @@ -3508,9 +3512,9 @@ class Societe extends CommonObject */ $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql .= ' WHERE fk_soc = '.(int) $dest_id.' AND fk_user IN ( '; - $sql = ' SELECT fk_user '; - $sql = ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; - $sql = ' WHERE fk_soc = '.(int) $origin_id.') '; + $sql .= ' SELECT fk_user '; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; + $sql .= ' WHERE fk_soc = '.(int) $origin_id.') '; $query = $db->query($sql); diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php index 08d2bdd7a8b..dd8802779b8 100644 --- a/htdocs/societe/commerciaux.php +++ b/htdocs/societe/commerciaux.php @@ -114,7 +114,9 @@ if (! empty($socid)) dol_fiche_head($head, 'salesrepresentative', $langs->trans("ThirdParty"),0,'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; @@ -137,7 +139,7 @@ if (! empty($socid)) print ''.$langs->trans("SalesRepresentatives").''; print ''; - $sql = "SELECT DISTINCT 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, u.photo"; $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)) @@ -184,7 +186,8 @@ if (! empty($socid)) $tmpuser->login = $obj->login; $tmpuser->entity = $obj->entity; $tmpuser->societe_id = $obj->fk_soc; - print $tmpuser->getNomUrl(1); + $tmpuser->photo = $obj->photo; + print $tmpuser->getNomUrl(-1); /*print ''; print img_object($langs->trans("ShowUser"),"user").' '; @@ -227,7 +230,7 @@ if (! empty($socid)) $langs->load("users"); $title=$langs->trans("ListOfUsers"); - $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.login, u.email, u.statut, u.fk_soc"; + $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.login, u.email, u.statut, u.fk_soc, u.photo"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) { @@ -273,10 +276,11 @@ if (! empty($socid)) $tmpuser->login=$obj->login; $tmpuser->email=$obj->email; $tmpuser->societe_id=$obj->fk_soc; - print $tmpuser->getNomUrl(1); + $tmpuser->photo=$obj->photo; + print $tmpuser->getNomUrl(-1); print ''; print ''.$obj->login.''; - print ''.User::LibStatut($obj->statut,0).''; + print ''.$tmpuser->getLibStatut(2).''; print ''.$langs->trans("Add").''; print ''."\n"; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index eb912548caa..85695efff40 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2013-2015 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Ferran Marcet @@ -57,7 +57,7 @@ $month = GETPOST('month','int'); $year = GETPOST('year','int'); // Clean up on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $sref=''; $sprod_fulldescr=''; @@ -114,7 +114,9 @@ if (empty($socid)) $head = societe_prepare_head($object); dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"),0,'company'); -dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 4ad8abc9a43..e64c9c49656 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -109,7 +109,9 @@ if ($object->id) $totalsize+=$file['size']; } - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 6e0dcbec113..333ee590f2d 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 e4e67ba7eab..f466263acdc 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2015 Florian Henry * Copyright (C) 2016 Josep Lluis Amador + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -159,7 +160,8 @@ $arrayfields=array( 's.idprof4'=>array('label'=>$langs->trans("ProfId4Short"), 'checked'=>$checkedprofid4), 's.idprof5'=>array('label'=>$langs->trans("ProfId5Short"), 'checked'=>$checkedprofid5), 's.idprof6'=>array('label'=>$langs->trans("ProfId6Short"), 'checked'=>$checkedprofid6), - 's.fk_prospectlevel'=>array('label'=>$langs->trans("ProspectLevelShort"), 'checked'=>$checkprospectlevel), + 'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1), + 's.fk_prospectlevel'=>array('label'=>$langs->trans("ProspectLevelShort"), 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>$langs->trans("StatusProsp"), 'checked'=>$checkstcomm), 's.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 's.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), @@ -452,6 +454,7 @@ llxHeader('',$langs->trans("ThirdParty"),$help_url); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($search_all != '') $param = "&sall=".urlencode($search_all); if ($sall != '') $param .= "&sall=".urlencode($sall); if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ); if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); @@ -534,6 +537,17 @@ if ($type == 'c' || $type == 'p') $moreforfilter.='
    '; } } +if ($type == 'f') +{ + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
    '; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$formother->select_categories('supplier',$search_categ,'search_categ',1); + $moreforfilter.='
    '; + } +} // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) @@ -543,17 +557,6 @@ if ($user->rights->societe->client->voir || $socid) $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300'); $moreforfilter.='
    '; } -if ($type == 'f') -{ - if (! empty($conf->categorie->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
    '; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories('supplier',$search_categ,'search_categ',1); - $moreforfilter.='
    '; - } -} if (! empty($moreforfilter)) { print '
    '; @@ -567,6 +570,8 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if (empty($arrayfields['customerorsupplier']['checked'])) print ''; + print ''; print ''; @@ -587,7 +592,7 @@ if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titr if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); -print_liste_field_titre(''); // type of customer +if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); // Extra fields @@ -735,17 +740,19 @@ if (! empty($arrayfields['s.idprof6']['checked'])) } // Type (customer/prospect/supplier) -print ''; - +if (! empty($arrayfields['customerorsupplier']['checked'])) +{ + print ''; +} if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) { // Prospect level @@ -946,30 +953,33 @@ while ($i < min($num, $limit)) print "\n"; } // Type - print ''; + if (! empty($arrayfields['customerorsupplier']['checked'])) + { + print ''; + } if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) { // Prospect level diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 5c9bc15328f..e88f94e4287 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -73,12 +73,14 @@ if ($id > 0) dol_fiche_head($head, 'note', $langs->trans("ThirdParty"),0,'company'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - print ''; - print ''; - - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); - + $cssclass='titlefield'; + //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; + //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; + print '
    '; print '
    '; @@ -86,12 +88,12 @@ if ($id > 0) if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print '
    '; + print ''; } if ($object->client) { - print ''; + print ''; } if ($object->client) { - print ''; } - print ''; + print ''; print ''; + print ''; print ''; } print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"'); @@ -395,16 +450,53 @@ if ($socid && $action != 'edit' && $action != "create") // Bank name print ''; // Account number - print ''; + print ''; // IBAN - print ''; + print ''; // BIC - print ''; + print ''; if (! empty($conf->prelevement->enabled)) { // RUM - print ''; + //print ''; + print ''; // FRSTRECUR print ''; @@ -436,6 +528,7 @@ if ($socid && $action != 'edit' && $action != "create") print ''; } print ''; + print ''; } @@ -451,6 +544,68 @@ if ($socid && $action != 'edit' && $action != "create") dol_print_error($db); } + + if ($socid && $action != 'edit' && $action != 'create') + { + /* + * Barre d'actions + */ + print '
    '; + + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Add").''; + } + + print '
    '; + } + + + + + if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) + { + print '
    '; + print ''; // ancre + + /* + * Documents generes + */ + $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; + $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; + $genallowed=$user->rights->societe->creer; + $delallowed=$user->rights->societe->supprimer; + + $var=true; + + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, '', 0, '', $object->default_lang); + + print '
    '; + + + print '
    '; + + print '
    '; + } + /* + include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; + $modellist=ModeleBankAccountDoc::liste_modeles($db); + //print '
    '; -if ($type != '') print ''; -print ''; + if ($type != '') print ''; + print '".$obj->idprof6."'; - $s=''; - if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - $companystatic->name=$langs->trans("Customer"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'customer'); - } - if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { - if ($s) $s.=" / "; - $companystatic->name=$langs->trans("Prospect"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'prospect'); - } - if (! empty($conf->fournisseur->enabled) && $obj->fournisseur) - { - if ($s) $s.=" / "; - $companystatic->name=$langs->trans("Supplier"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'supplier'); - } - print $s; - print ''; + $s=''; + if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + $companystatic->name=$langs->trans("Customer"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'customer'); + } + if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + { + if ($s) $s.=" / "; + $companystatic->name=$langs->trans("Prospect"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'prospect'); + } + if (! empty($conf->fournisseur->enabled) && $obj->fournisseur) + { + if ($s) $s.=" / "; + $companystatic->name=$langs->trans("Supplier"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'supplier'); + } + print $s; + print '
    '.$langs->trans('Prefix').''.$object->prefix_comm.'
    '.$langs->trans('Prefix').''.$object->prefix_comm.'
    '; + print '
    '; print $langs->trans('CustomerCode').''; print $object->code_client; if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -100,7 +102,7 @@ if ($id > 0) if ($object->fournisseur) { - print '
    '; + print '
    '; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -111,13 +113,11 @@ if ($id > 0) print ''; - print '
    '; + //print '
    '; - //$colwidth='25'; - $cssclass='titlefield'; + //print '
    '; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); } diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 11c62f7ccfc..bc754d8e9a4 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -52,7 +52,7 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="a.daten"; +if (! $sortfield) $sortfield="n.daten"; $now=dol_now(); @@ -155,7 +155,9 @@ if ($result > 0) dol_fiche_head($head, 'notify', $langs->trans("ThirdParty"),0,'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; @@ -165,12 +167,12 @@ if ($result > 0) // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print '
    '.$langs->trans('Prefix').''.$object->prefix_comm.'
    '.$langs->trans('Prefix').''.$object->prefix_comm.'
    '; + print '
    '; print $langs->trans('CustomerCode').''; print $object->code_client; if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -179,14 +181,14 @@ if ($result > 0) if ($object->fournisseur) { - print '
    '; + print '
    '; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
    '.$langs->trans("NbOfActiveNotifications").'
    '.$langs->trans("NbOfActiveNotifications").''; $notify=new Notify($db); $tmparray = $notify->getNotificationsArray('', $object->id); @@ -221,9 +223,9 @@ if ($result > 0) // Line with titles print ''; print ''; - print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'"width="45%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'"width="35%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'"width="10%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'"width="45%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",'',$param,'"width="35%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"n.type",'',$param,'"width="10%"',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; @@ -242,11 +244,11 @@ if ($result > 0) $label=($langs->trans("Notify_".$managedeventfornotification['code'])!="Notify_".$managedeventfornotification['code']?$langs->trans("Notify_".$managedeventfornotification['code']):$managedeventfornotification['label']); $actions[$managedeventfornotification['rowid']]=$label; } - print ''; - print ''; print ''; // Show fields of bank account - foreach($account->getFieldsToShow() as $val) { if ($val == 'BankCode') { @@ -308,24 +362,31 @@ if ($socid && $action != 'edit' && $action != "create") $content = $account->code_guichet; } elseif ($val == 'BankAccountNumber') { $content = $account->number; + if (! empty($account->label)) { + if (! checkBanForAccount($account)) { + $content.= ' '.img_picto($langs->trans("NotValid"),'warning'); + } else { + $content.= ' '.img_picto($langs->trans("Valid"),'info'); + } + } } elseif ($val == 'BankAccountNumberKey') { $content = $account->cle_rib; }elseif ($val == 'IBAN') { $content = $account->iban; if (! empty($account->iban)) { if (! checkIbanForAccount($account)) { - $content.= img_picto($langs->trans("IbanNotValid"),'warning'); + $content.= ' '.img_picto($langs->trans("IbanNotValid"),'warning'); } else { - $content.= img_picto($langs->trans("IbanValid"),'info'); + $content.= ' '.img_picto($langs->trans("IbanValid"),'info'); } } }elseif ($val == 'BIC') { $content = $account->bic; if (! empty($account->bic)) { if (! checkSwiftForAccount($account)) { - $content.= img_picto($langs->trans("SwiftNotValid"),'warning'); + $content.= ' '.img_picto($langs->trans("SwiftNotValid"),'warning'); } else { - $content.= img_picto($langs->trans("SwiftValid"),'info'); + $content.= ' '.img_picto($langs->trans("SwiftValid"),'info'); } } } @@ -335,26 +396,20 @@ if ($socid && $action != 'edit' && $action != "create") print ''; } - print '\n"; - print '\n"; - print '\n"; print '
    '; - print $form->selectarray("contactid",$listofemails); + print '
    '; + print $form->selectarray("contactid", $listofemails, '', 0, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); print ''; - print $form->selectarray("actionid",$actions,'',1); + print ''; + print $form->selectarray("actionid", $actions, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidthonsmartphone'); print ''; $type=array('email'=>$langs->trans("EMail")); @@ -268,22 +270,7 @@ if ($result > 0) print ''; print '
    '; - // List of active notifications - print load_fiche_titre($langs->trans("ListOfActiveNotifications"),'',''); - $var=true; - - // Line with titles - print ''; - print ''; - print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'"width="45%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'"width="35%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'"width="10%"',$sortfield,$sortorder); - print_liste_field_titre('','',''); - print ''; - - $langs->load("errors"); - $langs->load("other"); - + // List of notifications enabled for contacts $sql = "SELECT n.rowid, n.type,"; $sql.= " a.code, a.label,"; @@ -294,11 +281,35 @@ if ($result > 0) $sql.= " WHERE a.rowid = n.fk_action"; $sql.= " AND c.rowid = n.fk_contact"; $sql.= " AND c.fk_soc = ".$object->id; - + $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); + } + else + { + dol_print_error($db); + } + + // List of active notifications + print load_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')','',''); + $var=true; + + // Line with titles + print '
    '; + print ''; + print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'"width="45%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",'',$param,'"width="35%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"n.type",'',$param,'"width="10%"',$sortfield,$sortorder); + print_liste_field_titre('','',''); + print ''; + + $langs->load("errors"); + $langs->load("other"); + + if ($num) + { $i = 0; $contactstatic=new Contact($db); @@ -340,10 +351,6 @@ if ($result > 0) } $db->free($resql); } - else - { - dol_print_error($db); - } // List of notifications enabled for fixed email /* @@ -401,20 +408,6 @@ if ($result > 0) print '

    '."\n"; - // List of notifications done - print load_fiche_titre($langs->trans("ListOfNotificationsDone"),'',''); - $var=true; - - // Line with titles - print '
    '; - print ''; - print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("Object"),$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"a.daten",'',$param,'align="right"',$sortfield,$sortorder); - print ''; - // List $sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,"; $sql.= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,"; @@ -424,11 +417,34 @@ if ($result > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as c ON n.fk_contact = c.rowid"; $sql.= " WHERE a.rowid = n.fk_action"; $sql.= " AND n.fk_soc = ".$object->id; + $sql.= $db->order($sortfield, $sortorder); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); + } + else + { + dol_print_error($db); + } + + // List of notifications done + print load_fiche_titre($langs->trans("ListOfNotificationsDone").' ('.$num.')','',''); + $var=true; + + // Line with titles + print '
    '; + print ''; + print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"n.type",'',$param,'',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans("Object"),$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"n.daten",'',$param,'align="right"',$sortfield,$sortorder); + print ''; + + if ($num > 0) + { $i = 0; $contactstatic=new Contact($db); @@ -477,10 +493,6 @@ if ($result > 0) } $db->free($resql); } - else - { - dol_print_error($db); - } print '
    '; } diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 4c988603417..9236fc35f6f 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -151,7 +151,9 @@ $head = societe_prepare_head($object); dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), 0, 'company'); -dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 707fe21a010..fe206dd4cc5 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load("companies"); +$langs->load("projects"); // Security check $socid = GETPOST('socid','int'); @@ -80,7 +81,9 @@ if ($socid) dol_fiche_head($head, 'project', $langs->trans("ThirdParty"),0,'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index d31226ac052..5c989720f1c 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2015-2016 Marcos García @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; @@ -38,203 +39,258 @@ $langs->load("banks"); $langs->load("bills"); // Security check -$socid = GETPOST("socid"); +$socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); -$object = new Societe($db); -$object->fetch($socid); - $id=GETPOST("id","int"); $ribid=GETPOST("ribid","int"); $action=GETPOST("action"); +$object = new Societe($db); +$object->fetch($socid); + +$account = new CompanyBankAccount($db); +$prelevement = new BonPrelevement($db); + +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('thirdpartybancard','globalcard')); + + /* * Actions */ -if ($action == 'update' && ! $_POST["cancel"]) +$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - // Modification - $account = new CompanyBankAccount($db); - - - if (! GETPOST('label')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $action='update'; - $error++; - } - if (! GETPOST('bank')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='update'; - $error++; - } - if ($account->needIBAN() == 1) - { - if (! GETPOST('iban')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='update'; - $error++; - } - if (! GETPOST('bic')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='update'; - $error++; - } - } - - $account->fetch($id); - if (! $error) + if ($cancel) { - $account->socid = $object->id; - - $account->bank = GETPOST('bank','alpha'); - $account->label = GETPOST('label','alpha'); - $account->courant = GETPOST('courant','alpha'); - $account->clos = GETPOST('clos','alpha'); - $account->code_banque = GETPOST('code_banque','alpha'); - $account->code_guichet = GETPOST('code_guichet','alpha'); - $account->number = GETPOST('number','alpha'); - $account->cle_rib = GETPOST('cle_rib','alpha'); - $account->bic = GETPOST('bic','alpha'); - $account->iban = GETPOST('iban','alpha'); - $account->domiciliation = GETPOST('domiciliation','alpha'); - $account->proprio = GETPOST('proprio','alpha'); - $account->owner_address = GETPOST('owner_address','alpha'); - $account->frstrecur = GETPOST('frstrecur','alpha'); - - $result = $account->update($user); - if (! $result) - { - setEventMessages($account->error, $account->errors, 'errors'); - } - else - { - // If this account is the default bank account, we disable others - if ($account->default_rib) - { - $account->setAsDefault($id); // This will make sure there is only one default rib - } - - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; - } + $action=''; + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } } -} -if ($action == 'add' && ! $_POST["cancel"]) -{ - $error=0; - - if (! GETPOST('label')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $action='create'; - $error++; - } - if (! GETPOST('bank')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='create'; - $error++; - } - if ($account->needIBAN() == 1) - { - if (! GETPOST('iban')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='create'; - $error++; - } - if (! GETPOST('bic')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='create'; - $error++; - } - } - - if (! $error) - { - // Ajout - $account = new CompanyBankAccount($db); - - $account->socid = $object->id; - - $account->bank = GETPOST('bank','alpha'); - $account->label = GETPOST('label','alpha'); - $account->courant = GETPOST('courant','alpha'); - $account->clos = GETPOST('clos','alpha'); - $account->code_banque = GETPOST('code_banque','alpha'); - $account->code_guichet = GETPOST('code_guichet','alpha'); - $account->number = GETPOST('number','alpha'); - $account->cle_rib = GETPOST('cle_rib','alpha'); - $account->bic = GETPOST('bic','alpha'); - $account->iban = GETPOST('iban','alpha'); - $account->domiciliation = GETPOST('domiciliation','alpha'); - $account->proprio = GETPOST('proprio','alpha'); - $account->owner_address = GETPOST('owner_address','alpha'); - $account->frstrecur = GETPOST('frstrecur'); - - $result = $account->update($user); // TODO Use create and include update into create method - if (! $result) - { - setEventMessages($account->error, $account->errors, 'errors'); - $_GET["action"]='create'; // Force chargement page création - } - else - { - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; - } - } -} - -if ($action == 'setasdefault') -{ - $account = new CompanyBankAccount($db); - $res = $account->setAsDefault(GETPOST('ribid','int')); - if ($res) + + if ($action == 'update' && ! $_POST["cancel"]) { - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; + // Modification + if (! GETPOST('label')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $action='update'; + $error++; + } + if (! GETPOST('bank')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action='update'; + $error++; + } + if ($account->needIBAN() == 1) + { + if (! GETPOST('iban')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); + $action='update'; + $error++; + } + if (! GETPOST('bic')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); + $action='update'; + $error++; + } + } + + $account->fetch($id); + if (! $error) + { + $account->socid = $object->id; + + $account->bank = GETPOST('bank','alpha'); + $account->label = GETPOST('label','alpha'); + $account->courant = GETPOST('courant','alpha'); + $account->clos = GETPOST('clos','alpha'); + $account->code_banque = GETPOST('code_banque','alpha'); + $account->code_guichet = GETPOST('code_guichet','alpha'); + $account->number = GETPOST('number','alpha'); + $account->cle_rib = GETPOST('cle_rib','alpha'); + $account->bic = GETPOST('bic','alpha'); + $account->iban = GETPOST('iban','alpha'); + $account->domiciliation = GETPOST('domiciliation','alpha'); + $account->proprio = GETPOST('proprio','alpha'); + $account->owner_address = GETPOST('owner_address','alpha'); + $account->frstrecur = GETPOST('frstrecur','alpha'); + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + + $result = $account->update($user); + if (! $result) + { + setEventMessages($account->error, $account->errors, 'errors'); + } + else + { + // If this account is the default bank account, we disable others + if ($account->default_rib) + { + $account->setAsDefault($id); // This will make sure there is only one default rib + } + + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + } } - else + + if ($action == 'add' && ! $_POST["cancel"]) { - setEventMessages($db->lasterror, null, 'errors'); + $error=0; + + if (! GETPOST('label')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $action='create'; + $error++; + } + if (! GETPOST('bank')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action='create'; + $error++; + } + + if (! $error) + { + // Ajout + $account = new CompanyBankAccount($db); + + $account->socid = $object->id; + + $account->bank = GETPOST('bank','alpha'); + $account->label = GETPOST('label','alpha'); + $account->courant = GETPOST('courant','alpha'); + $account->clos = GETPOST('clos','alpha'); + $account->code_banque = GETPOST('code_banque','alpha'); + $account->code_guichet = GETPOST('code_guichet','alpha'); + $account->number = GETPOST('number','alpha'); + $account->cle_rib = GETPOST('cle_rib','alpha'); + $account->bic = GETPOST('bic','alpha'); + $account->iban = GETPOST('iban','alpha'); + $account->domiciliation = GETPOST('domiciliation','alpha'); + $account->proprio = GETPOST('proprio','alpha'); + $account->owner_address = GETPOST('owner_address','alpha'); + $account->frstrecur = GETPOST('frstrecur'); + + // This test can be done only once properties were set + if ($account->needIBAN() == 1) + { + if (! GETPOST('iban')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); + $action='create'; + $error++; + } + if (! GETPOST('bic')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); + $action='create'; + $error++; + } + } + + if (! $error) + { + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + + $result = $account->update($user); // This will set the UMR number. + // TODO Use create and include update into create method + if (! $result) + { + setEventMessages($account->error, $account->errors, 'errors'); + $_GET["action"]='create'; // Force chargement page création + } + else + { + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + } + } } + + if ($action == 'setasdefault') + { + $account = new CompanyBankAccount($db); + $res = $account->setAsDefault(GETPOST('ribid','int')); + if ($res) + { + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + else + { + setEventMessages($db->lasterror, null, 'errors'); + } + } + + if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') + { + $account = new CompanyBankAccount($db); + if ($account->fetch($ribid?$ribid:$id)) + { + $result = $account->delete($user); + if ($result > 0) + { + $url = $_SERVER['PHP_SELF']."?socid=".$object->id; + header('Location: '.$url); + exit; + } + else + { + setEventMessages($account->error, $account->errors, 'errors'); + } + } + else + { + setEventMessages($account->error, $account->errors, 'errors'); + } + } + + $savid=$id; + + // Actions to build doc + $id = $socid; + $upload_dir = $conf->societe->dir_output; + $permissioncreate=$user->rights->societe->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + $id = $savid; } -if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') -{ - $account = new CompanyBankAccount($db); - if ($account->fetch($ribid?$ribid:$id)) - { - $result = $account->delete($user); - if ($result > 0) - { - $url = $_SERVER['PHP_SELF']."?socid=".$object->id; - header('Location: '.$url); - exit; - } - else - { - setEventMessages($account->error, $account->errors, 'errors'); - } - } - else - { - setEventMessages($account->error, $account->errors, 'errors'); - } -} /* @@ -242,21 +298,18 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') */ $form = new Form($db); -$prelevement = new BonPrelevement($db); +$formfile = new FormFile($db); llxHeader(); -$head=societe_prepare_head2($object); +$head=societe_prepare_head($object); - -$account = new CompanyBankAccount($db); if (! $id) $account->fetch(0,$object->id); else $account->fetch($id); if (empty($account->socid)) $account->socid=$object->id; - if ($socid && $action == 'edit' && $user->rights->societe->creer) { print '
    '; @@ -283,7 +336,9 @@ if ($socid && $action != 'edit' && $action != "create") print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $account->getRibLabel()), "confirm_delete", '', 0, 1); } - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; @@ -299,7 +354,6 @@ if ($socid && $action != 'edit' && $action != "create") print '
    '.$account->bank.'
    '.$langs->trans("BankAccountDomiciliation").''; + print '
    '.$langs->trans("BankAccountDomiciliation").''; print $account->domiciliation; print "
    '.$langs->trans("BankAccountOwner").''; + print '
    '.$langs->trans("BankAccountOwner").''; print $account->proprio; print "
    '.$langs->trans("BankAccountOwnerAddress").''; + print '
    '.$langs->trans("BankAccountOwnerAddress").''; print $account->owner_address; print "
    '; - // Check BBAN - if ($account->label && ! checkBanForAccount($account)) - { - print '
    '.$langs->trans("RIBControlError").'
    '; - } - print ""; dol_fiche_end(); @@ -380,7 +435,7 @@ if ($socid && $action != 'edit' && $action != "create") print_liste_field_titre($langs->trans("BIC")); if (! empty($conf->prelevement->enabled)) { - print '
    RUM'.$langs->trans("RUM").''.$langs->trans("WithdrawMode").''.$rib->bank.''.$rib->getRibLabel(false).''; + $string=''; + foreach ($rib->getFieldsToShow() as $val) { + + if ($val == 'BankCode') { + $string .= $rib->code_banque.' '; + } elseif ($val == 'BankAccountNumber') { + $string .= $rib->number.' '; + } elseif ($val == 'DeskCode') { + $string .= $rib->code_guichet.' '; + } elseif ($val == 'BankAccountNumberKey') { + $string .= $rib->cle_rib.' '; + /* Already output after + }elseif ($val == 'BIC') { + $string .= $rib->bic.' '; + }elseif ($val == 'IBAN') { + $string .= $rib->iban.' ';*/ + } + } + print $string; + print ''.$rib->iban.''.$rib->iban; + if (! empty($rib->iban)) { + if (! checkIbanForAccount($rib)) { + print ' '.img_picto($langs->trans("IbanNotValid"),'warning'); + } else { + print ' '.img_picto($langs->trans("IbanValid"),'info'); + } + } + print ''.$rib->bic.''.$rib->bic; + if (! empty($rib->bic)) { + if (! checkSwiftForAccount($rib)) { + print ' '.img_picto($langs->trans("SwiftNotValid"),'warning'); + } else { + print ' '.img_picto($langs->trans("SwiftValid"),'info'); + } + } + print ''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).''.$rib->rum.''.$rib->frstrecur.'
    '; + if (is_array($modellist) && count($modellist) == 1) // If there is only one element + { + $arraykeys=array_keys($modellist); + $modelselected=$arraykeys[0]; + } + $out.= $form->selectarray('model', $modellist, $modelselected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out.= ajax_combobox('model'); + //print $out; + $buttonlabel=$langs->trans("Generate"); + $genbutton = ''; // TODO Add link to generate doc + */ } // Edit @@ -458,14 +613,16 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) { dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; print '
    '; print ''; - print ''; + print ''; print ''; print ''; @@ -509,7 +666,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) } print '"; @@ -518,7 +675,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print "\n"; print '"; @@ -560,7 +717,9 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) { dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; @@ -603,14 +762,14 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) } // IBAN - print '
    '; + print 'needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("IBAN").''; print ''; - print ''; + print 'needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("BIC").''; print ''; print '"; @@ -619,7 +778,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print "\n"; print '"; @@ -663,23 +822,6 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) } - -if ($socid && $action != 'edit' && $action != 'create') -{ - /* - * Barre d'actions - */ - print '
    '; - - if ($user->rights->societe->creer) - { - print ''.$langs->trans("Add").''; - } - - print '
    '; -} - - llxFooter(); $db->close(); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 0eecd8e6b92..3d561275c38 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -228,14 +228,14 @@ if (empty($reshook)) //obtidre selected del combobox $value=GETPOST('lt1'); $object->fetch($socid); - $res=$object->setValueFrom('localtax1_value', $value); + $res=$object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } if($action=='set_localtax2') { //obtidre selected del combobox $value=GETPOST('lt2'); $object->fetch($socid); - $res=$object->setValueFrom('localtax2_value', $value); + $res=$object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } // Add new or update third party @@ -287,7 +287,7 @@ if (empty($reshook)) $object->name_alias = GETPOST('name_alias'); } - $object->address = GETPOST('address', 'alpha'); + $object->address = GETPOST('address'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); $object->country_id = GETPOST('country_id', 'int'); @@ -739,7 +739,7 @@ if ($socid > 0 && empty($object->id)) } $title=$langs->trans("ThirdParty"); -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name; +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card'); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$title,$help_url); @@ -939,13 +939,13 @@ else print ''; print '     '; print ''; @@ -981,7 +981,7 @@ else print ''.fieldLabel('ThirdPartyName','name').''; } print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; - print ''; + print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; @@ -1001,7 +1001,7 @@ else // Alias names (commercial, trademark or alias names) print ''; - print ''; + print ''; // Prospect/Customer print ''; @@ -1015,11 +1015,11 @@ else print ''; print ''; - print '
    '.$langs->trans("LabelRIB").'
    '.$langs->trans("LabelRIB").'
    '.$langs->trans("BankName").'
    '.$langs->trans("BankAccountDomiciliation").''; - print '
    '.$langs->trans("BankAccountOwnerAddress").''; - print "
    needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("IBAN").'
    needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("BIC").'
    '.$langs->trans("BankAccountDomiciliation").''; - print '
    '.$langs->trans("BankAccountOwnerAddress").''; - print '
    '.$langs->trans('Prefix').'
    '.fieldLabel('ProspectCustomer','customerprospect',1).''.fieldLabel('CustomerCode','customer_code').''; + print ''.fieldLabel('CustomerCode','customer_code').''; print ''; print "\n"; + // Date employment + print ''; + print ''; + print "\n"; + // Accountancy code if ($conf->accounting->enabled) { diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index a9eb7771d9d..c046c9869cf 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -49,6 +49,79 @@ class Users extends DolibarrApi $this->useraccount = new User($this->db); } + + /** + * List Users + * + * Get a list of Users + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $user_ids User ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} + * + * @return array Array of User objects + */ + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $user_ids = 0) { + global $db, $conf; + + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->user->user->lire) { + throw new RestException(401, "You are not allowed to read list of users"); + } + + // case of external user, $societe param is ignored and replaced by user's socid + //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; + + $sql = "SELECT t.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as t"; + $sql.= ' WHERE t.entity IN ('.getEntity('user', 1).')'; + if ($user_ids) $sql.=" AND t.rowid IN (".$user_ids.")"; + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + + if ($result) + { + $num = $db->num_rows($result); + while ($i < min($num, ($limit <= 0 ? $num : $limit))) + { + $obj = $db->fetch_object($result); + $user_static = new User($db); + if($user_static->fetch($obj->rowid)) { + $obj_ret[] = parent::_cleanObjectDatas($user_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve User list'); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No User found'); + } + return $obj_ret; + } + /** * Get properties of an user object * diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 144f9ee7891..37832f20ea6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -107,6 +107,7 @@ class User extends CommonObject var $rights; // Array of permissions user->rights->permx var $all_permissions_are_loaded; /**< \private all_permissions_are_loaded */ private $_tab_loaded=array(); // Array of cache of already loaded permissions + var $nb_rights; // Number of rights granted to the user var $conf; // To store personal config var $oldcopy; // To contains a clone of this when we need to save old properties of object @@ -115,13 +116,17 @@ class User extends CommonObject var $parentof; // To store an array of all parents for all ids. var $accountancy_code; // Accountancy code in prevision of the complete accountancy module - var $thm; // Average cost of employee + + var $thm; // Average cost of employee - Used for valuation of time spent var $tjm; // Average cost of employee - var $salary; // Monthly salary - var $salaryextra; // Monthly salary extra - var $weeklyhours; // Weekly hours + + var $salary; // Monthly salary - Denormalized value from llx_user_employment + var $salaryextra; // Monthly salary extra - Denormalized value from llx_user_employment + var $weeklyhours; // Weekly hours - Denormalized value from llx_user_employment var $color; // Define background color for user in agenda + + var $dateemployment; // Define date of employment by company /** * Constructor de la classe @@ -138,6 +143,7 @@ class User extends CommonObject // For cache usage $this->all_permissions_are_loaded = 0; + $this->nb_rights = 0; // Force some default values $this->admin = 0; @@ -187,6 +193,7 @@ class User extends CommonObject $sql.= " u.salaryextra,"; $sql.= " u.weeklyhours,"; $sql.= " u.color,"; + $sql.= " u.dateemployment,"; $sql.= " u.ref_int, u.ref_ext,"; $sql.= " c.code as country_code, c.label as country,"; $sql.= " d.code_departement as state_code, d.nom as state"; @@ -286,6 +293,7 @@ class User extends CommonObject $this->salaryextra = $obj->salaryextra; $this->weeklyhours = $obj->weeklyhours; $this->color = $obj->color; + $this->dateemployment = $this->db->jdate($obj->dateemployment); $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); @@ -629,10 +637,12 @@ class User extends CommonObject if ($subperms) { if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = new stdClass(); + if(empty($this->rights->$module->$perms->$subperms)) $this->nb_rights++; $this->rights->$module->$perms->$subperms = 1; } else { + if(empty($this->rights->$module->$perms)) $this->nb_rights++; $this->rights->$module->$perms = 1; } @@ -679,10 +689,12 @@ class User extends CommonObject if ($subperms) { if (! isset($this->rights->$module->$perms) || ! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = new stdClass(); + if(empty($this->rights->$module->$perms->$subperms)) $this->nb_rights++; $this->rights->$module->$perms->$subperms = 1; } else { + if(empty($this->rights->$module->$perms)) $this->nb_rights++; $this->rights->$module->$perms = 1; } @@ -1260,6 +1272,7 @@ class User extends CommonObject $this->town = empty($this->town)?'':$this->town; $this->accountancy_code = trim($this->accountancy_code); $this->color = empty($this->color)?'':$this->color; + $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; // Check parameters if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email)) @@ -1300,6 +1313,7 @@ class User extends CommonObject $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; $sql.= ", color = '".$this->db->escape($this->color)."'"; + $sql.= ", dateemployment=".(strval($this->dateemployment)!='' ? "'".$this->db->idate($this->dateemployment)."'" : 'null'); $sql.= ", note = '".$this->db->escape($this->note)."'"; $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); $sql.= ", openid = ".($this->openid?"'".$this->db->escape($this->openid)."'":"null"); @@ -1311,7 +1325,7 @@ class User extends CommonObject $sql.= ", weeklyhours= ".($this->weeklyhours != ''?"'".$this->db->escape($this->weeklyhours)."'":"null"); $sql.= ", entity = '".$this->db->escape($this->entity)."'"; $sql.= " WHERE rowid = ".$this->id; - + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -2112,23 +2126,23 @@ class User extends CommonObject } if ($mode == 2) { - if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled'); + if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); } if ($mode == 3) { - if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5'); + if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"'); + if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); } if ($mode == 4) { - if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled'); + if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled'); } if ($mode == 5) { - if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"'); + if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"'); } } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 1da40878a62..541d847a45b 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -450,7 +450,7 @@ else print ""; print ''; diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 6bcd468f62e..a5e9db67867 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -139,7 +139,7 @@ if ($resql) $fuserstatic->email = $obj->email; $fuserstatic->skype = $obj->skype; $fuserstatic->societe_id = $obj->fk_soc; - print $fuserstatic->getNomUrl(1); + print $fuserstatic->getNomUrl(-1); if (! empty($conf->multicompany->enabled) && $obj->admin && ! $obj->entity) { print img_picto($langs->trans("SuperAdministrator"),'redstar'); diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 5d8f02e1c32..459a89e573b 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -57,8 +57,11 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="u.login"; if (! $sortorder) $sortorder="ASC"; +// Initialize context for list +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userlist'; + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('userlist')); +$hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -168,8 +171,6 @@ llxHeader('',$langs->trans("ListOfUsers")); $buttonviewhierarchy=''; -print load_fiche_titre($langs->trans("ListOfUsers"), $buttonviewhierarchy); - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.login, u.email, u.accountancy_code, u.gender, u.employee, u.photo,"; $sql.= " u.datelastlogin, u.datepreviouslogin,"; $sql.= " u.ldap_sid, u.statut, u.entity,"; @@ -227,17 +228,16 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.=$db->order($sortfield,$sortorder); -//$sql.= $db->plimit($conf->liste_limit+1, $offset); -/*$totalnboflines=0; +$nbtotalofrecords=0; $result=$db->query($sql); if ($result) { - $totalnboflines = $db->num_rows($result); + $nbtotalofrecords = $db->num_rows($result); } $sql.= $db->plimit($limit+1, $offset); -*/ + $result = $db->query($sql); if ($result) { @@ -259,6 +259,7 @@ if ($result) if ($search_supervisor > 0) $param.="&search_supervisor=".$search_supervisor; if ($search_statut != '') $param.="&search_statut=".$search_statut; if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($mode != '') $param.='&mode='.$mode; // Add $param from extra fields foreach ($search_array_options as $key => $val) { @@ -267,6 +268,7 @@ if ($result) if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } + $text = $langs->trans("ListOfUsers"); print ''."\n"; if ($optioncss != '') print ''; @@ -274,8 +276,12 @@ if ($result) print ''; print ''; print ''; - - if ($sall) + print ''; + print ''; + + print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); + + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); @@ -434,8 +440,8 @@ if ($result) $user2=new User($db); $var=True; - //while ($i < min($num,$conf->liste_limit)) - while ($i < $num) + $i = 0; + while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); $var=!$var; diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 996a6fba370..ec3691e85db 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -52,7 +52,7 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="a.daten"; +if (! $sortfield) $sortfield="n.daten"; $now=dol_now(); @@ -137,8 +137,11 @@ if ($result > 0) dol_fiche_head($head, 'notify', $langs->trans("User"),0,'user'); - - print '
    '; $tmpcode=$object->code_client; if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0); - print ''; + print ''; print ''; $s=$modCodeClient->getToolTip($langs,$object,0); print $form->textwithpicto('',$s,1); @@ -1039,7 +1039,7 @@ else print ''; // Country - print ''; @@ -1103,9 +1103,9 @@ else // Phone / Fax print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Prof ids $i=1; $j=0; @@ -1137,7 +1137,7 @@ else print ''; print ''; print ''; print ''; } @@ -1510,11 +1510,11 @@ else // Name print ''; - print ''; + print ''; // Alias names (commercial, trademark or alias names) print ''; - print ''; + print ''; // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field @@ -1535,13 +1535,13 @@ else // Prospect/Customer print ''; - print ''; - print '
    '; $tmpcode=$object->code_fournisseur; if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1); - print ''; + print ''; print ''; $s=$modCodeFournisseur->getToolTip($langs,$object,1); print $form->textwithpicto('',$s,1); @@ -1074,7 +1074,7 @@ else print '
    '.fieldLabel('Country','selectcountry_id').''; + print '
    '.fieldLabel('Country','selectcountry_id').''; print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id)); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
    '.fieldLabel('Phone','phone').''.fieldLabel('Fax','fax').'
    '.fieldLabel('VATIntra','intra_vat').''; - $s = ''; + $s = ''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { @@ -1220,7 +1220,7 @@ else if (! empty($conf->global->MAIN_MULTILANGS)) { print '
    '.fieldLabel('DefaultLang','default_lang').''."\n"; - print $formadmin->select_language(($object->default_lang?$object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1); + print $formadmin->select_language(($object->default_lang?$object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1,0,0,'maxwidth200onsmartphone'); print '
    '.fieldLabel('ThirdPartyName','name',1).'
    '.fieldLabel('ProspectCustomer','customerprospect',1).''.fieldLabel('CustomerCode','customer_code').''; + print ''.fieldLabel('CustomerCode','customer_code').''; print ''; - print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Prof ids $i=1; $j=0; @@ -1694,7 +1694,7 @@ else // VAT Code print ''; print ''; // Juridical type - print ''; @@ -2040,7 +2040,7 @@ else { $s=''; $s.=$object->tva_intra; - $s.=''; + $s.=''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { @@ -2267,22 +2267,6 @@ else print $object->showOptionals($extrafields); } - // Ban - if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) - { - print ''; - print ''; - } - // Parent company if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) { diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 69298f263e8..876c383031a 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -149,7 +149,9 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
    '; @@ -211,7 +213,7 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; $sql.= " d.datefin,"; $sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; - $sql.= " t.libelle as type, t.cotisation"; + $sql.= " t.libelle as type, t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_soc=".$id; @@ -290,7 +292,7 @@ if ($id > 0 || ! empty($ref)) // Statut print '
    "; // End of subscription date @@ -306,7 +308,7 @@ if ($id > 0 || ! empty($ref)) else { print ''; print ''; } - + // Multicurrency if (! empty($conf->multicurrency->enabled)) { print ''; print ''; print ''; } @@ -1207,9 +1208,10 @@ if ($action == 'create') if (empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) print ''; - if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '
    '; if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) @@ -1571,7 +1571,7 @@ else if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) { print '
    '.fieldLabel('Supplier','fournisseur',1).''; + print ''.fieldLabel('Supplier','fournisseur',1).''; print $form->selectyesno("fournisseur",$object->fournisseur,1); print ''.fieldLabel('SupplierCode','supplier_code').''; @@ -1656,9 +1656,9 @@ else // Phone / Fax print '
    '.fieldLabel('Phone','phone').''.fieldLabel('Fax','fax').'
    '.fieldLabel('VATIntra','intra_vat').''; - $s =''; + $s =''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { @@ -1782,7 +1782,7 @@ else print '
    '.fieldLabel('JuridicalStatus','forme_juridique_code').''; + print '
    '.fieldLabel('JuridicalStatus','forme_juridique_code').''; print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); print '
    '; - print '
    '; - print $langs->trans('RIB'); - print ''; - if ($user->rights->societe->creer) print ''.img_edit().''; - else print ' '; - print '
    '; - print '
    '; - print $object->display_rib(); - print '
    '; - print $memberstatic->LibStatut($objp->statut,$objp->cotisation,$datefin,2); + print $memberstatic->LibStatut($objp->statut,$objp->subscription,$datefin,2); print "'; - if ($objp->cotisation == 'yes') + if ($objp->subscription == 'yes') { print $langs->trans("SubscriptionNotReceived"); if ($objp->statut > 0) print " ".img_warning(); diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 22d99d3e9c3..fe2add787c4 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -27,10 +27,12 @@ foreach($listsalesrepresentatives as $val) { $userstatic->id=$val['id']; + $userstatic->login=$val['login']; $userstatic->lastname=$val['lastname']; $userstatic->firstname=$val['firstname']; $userstatic->statut=$val['statut']; - print $userstatic->getNomUrl(1); + $userstatic->photo=$val['photo']; + print $userstatic->getNomUrl(-1); $i++; if ($i < $nbofsalesrepresentative) print ', '; } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index e53378e0423..3cec12bac7d 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -25,6 +25,12 @@ * along with this program. If not, see . */ +/** + * \file htdocs/supplier_proposal/card.php + * \ingroup supplier_proposal + * \brief Card supplier proposal + */ + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; @@ -96,6 +102,8 @@ if ($id > 0 || ! empty($ref)) { $hookmanager->initHooks(array('supplier_proposalcard','globalcard')); $permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->supplier_proposal->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit=$user->rights->supplier_proposal->creer; // Used by the include of actions_lineupdown.inc.php /* @@ -109,13 +117,13 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { if ($cancel) $action=''; - + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { @@ -130,8 +138,8 @@ if (empty($reshook)) if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); - } - else + } + else { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; @@ -282,16 +290,6 @@ if (empty($reshook)) $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); } - for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) - { - if ($_POST['idprod' . $i]) { - $xid = 'idprod' . $i; - $xqty = 'qty' . $i; - $xremise = 'remise' . $i; - $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); - } - } - // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) { @@ -354,10 +352,10 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals($lines[$i]->rowid); - $array_option = $lines[$i]->array_options; + $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options); if ($result > 0) { $lineid = $result; @@ -511,22 +509,28 @@ if (empty($reshook)) } } - // Add line - else if ($action == 'addline' && $user->rights->supplier_proposal->creer) { + // Add a product line + if ($action == 'addline' && $user->rights->supplier_proposal->creer) + { + $langs->load('errors'); + $error = 0; // Set if we used free entry or predefined product $predef=''; $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - + $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; + $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod=GETPOST('idprod', 'int'); + $price_ht = ''; $tva_tx = ''; } @@ -536,7 +540,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -559,8 +563,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error ++; } - - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + if (! $error && ($qty >= 0)) { $pu_ht = 0; $pu_ttc = 0; $price_min = 0; @@ -571,150 +574,140 @@ if (empty($reshook)) // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit - if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); + if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + { + $productsupplier = new ProductFournisseur($db); + + if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) + { + $idprod=0; + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + } + if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg)) + { + $idprod=$reg[1]; + $res=$productsupplier->fetch($idprod); + // Call to init properties of $productsupplier + // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price + $productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist + } + elseif (GETPOST('idprodfournprice') > 0) + { + //$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat. + $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist + $res=$productsupplier->fetch($idprod); + } + + if ($idprod > 0) + { + $pu_ht = $productsupplier->fourn_pu; + $price_base_type = $productsupplier->fourn_price_base_type; + $type = $productsupplier->type; + $label = $productsupplier->label; + $desc = $productsupplier->description; + if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); + + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); + if (empty($tva_tx)) $tva_npr=0; + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + $result=$object->addline( + $desc, + $pu_ht, + $qty, + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $productsupplier->id, + $remise_percent, + $price_base_type, + $pu_ttc, + $tva_npr, + $type, + -1, + 0, + GETPOST('fk_parent_line'), + $fournprice, + $buyingprice, + $label, + $array_options, + $ref_fourn + ); + //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; + } + if ($idprod == -99 || $idprod == 0) + { + // Product not selected + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors'); + } + if ($idprod == -1) + { + // Quantity too low + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); + } + } + else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); - // If prices fields are update - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; - - //On garde le prix indiqué dans l'input pour la demande de prix fournisseur - //$pu_ht = $prod->price; - $pu_ht = price2num($price_ht, 'MU'); - //$pu_ttc = $prod->price_ttc; - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - - // On defini prix unitaire - if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) - { - $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; - $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result) { - if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines [0]->price); - $pu_ttc = price($prodcustprice->lines [0]->price_ttc); - $price_base_type = $prodcustprice->lines [0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines [0]->tva_tx; - } - } - } - - // if price ht is forced (ie: calculated by margin rate and cost price) - if (! empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tva_tx != $prod->tva_tx) { - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - } - - $desc = ''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } - - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } - - $type = $prod->type; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); + $fk_unit= GETPOST('units', 'alpha'); + + $tva_tx = price2num($tva_tx); // When vat is text input field + + // Local Taxes + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + + if (GETPOST('price_ht')!=='') + { + $price_base_type = 'HT'; + $ht = price2num(GETPOST('price_ht')); + $ttc = 0; + } + else + { + $ttc = price2num(GETPOST('price_ttc')); + $ht = $ttc / (1 + ($tva_tx / 100)); + $price_base_type = 'HT'; + } + + $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn); + //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); } - // Margin - $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); - $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - - $info_bits = 0; - if ($tva_npr) - $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessages($mesg, null, 'errors'); - } else { - // Insert line - $ref_fourn = GETPOST('fourn_ref'); - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option, $ref_fourn); - - if ($result > 0) { + if (! $error && $result > 0) + { $db->commit(); - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); } + $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); } unset($_POST['prod_entry_mode']); @@ -722,18 +715,23 @@ if (empty($reshook)) unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); + unset($_POST['pu']); unset($_POST['price_ht']); unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); + unset($_POST['label']); unset($_POST['product_ref']); unset($_POST['product_label']); unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + unset($localtax1_tx); + unset($localtax2_tx); unset($_POST['np_marginRate']); unset($_POST['np_markRate']); unset($_POST['dp_desc']); + unset($_POST['idprodfournprice']); unset($_POST['idprod']); unset($_POST['date_starthour']); @@ -748,12 +746,14 @@ if (empty($reshook)) unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - } else { - $db->rollback(); + } + else + { + $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - } + setEventMessages($object->error, $object->errors, 'errors'); } + //} } } @@ -776,12 +776,12 @@ if (empty($reshook)) // Add buying price $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -826,7 +826,7 @@ if (empty($reshook)) if (! $error) { $db->begin(); $ref_fourn = GETPOST('fourn_ref'); - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $array_option, $ref_fourn); + $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $array_options, $ref_fourn); if ($result >= 0) { $db->commit(); @@ -947,7 +947,7 @@ if (empty($reshook)) else if ($action == 'setmode' && $user->rights->supplier_proposal->creer) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } - + // Multicurrency Code else if ($action == 'setmulticurrencycode' && $user->rights->supplier_proposal->creer) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); @@ -955,7 +955,7 @@ if (empty($reshook)) // Multicurrency rate else if ($action == 'setmulticurrencyrate' && $user->rights->supplier_proposal->creer) { - $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int')); + $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); } else if ($action == 'update_extras') { @@ -999,6 +999,7 @@ $formfile = new FormFile($db); $formsupplier_proposal = new FormSupplierProposal($db); $formmargin = new FormMargin($db); $companystatic = new Societe($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); @@ -1142,14 +1143,14 @@ if ($action == 'create') print '
    '.fieldLabel('Currency','multicurrency_code').''; - $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)); + $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)); print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print '
    '; if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) { + print '
    '; + // For backward compatibility print ''; print ''; @@ -1242,42 +1244,11 @@ if ($action == 'create') } print ''; - if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) - print ''; - print ''; print ''; } - if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) - { - print ''; - } - if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '
     
    ' . $langs->trans("CreateEmptyAsk") . '
    '; - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - $lib = $langs->trans("ProductsAndServices"); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { - print ''; - print ''; - print ''; - print ''; - } - print "
    ' . $lib . '' . $langs->trans("Qty") . '' . $langs->trans("ReductionShort") . '
    '; - // multiprix - if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) - $form->select_produits('', "idprod" . $i, '', $conf->product->limit_size, $soc->price_level); - else - $form->select_produits('', "idprod" . $i, '', $conf->product->limit_size); - print '%
    "; - } - print '
    '; + if (! empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) print '
    '; dol_fiche_end(); @@ -1383,11 +1354,63 @@ if ($action == 'create') // Print form confirm print $formconfirm; + + // Supplier proposal card + $linkback = '' . $langs->trans("BackToList") . ''; + + + $morehtmlref='
    '; + // Ref supplier + //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); + //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
    '.$langs->trans('Project') . ' '; + if ($user->rights->supplier_proposal->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
    '; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
    '; + print '
    '; + print '
    '; + print ''; - $linkback = '' . $langs->trans("BackToList") . ''; - // Ref + /* print ''; @@ -1395,9 +1418,10 @@ if ($action == 'create') // Company print ''; print ''; - + */ + // Payment term - print '
    ' . $langs->trans('Ref') . ''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '
    ' . $langs->trans('Supplier') . '' . $soc->getNomUrl(1) . '
    '; + print '
    '; print ''; @@ -1454,6 +1478,7 @@ if ($action == 'create') print ''; // Project + /* if (! empty($conf->projet->enabled)) { $langs->load("projects"); print ''; - } + }*/ // Multicurrency if (! empty($conf->multicurrency->enabled)) @@ -1506,7 +1531,7 @@ if ($action == 'create') $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); } print ''; - + // Multicurrency rate print ''; print '
    '; print $langs->trans('PaymentConditionsShort'); print '
    '; @@ -1485,7 +1510,7 @@ if ($action == 'create') } } print '
    '; @@ -1559,73 +1584,80 @@ if ($action == 'create') // Other attributes $cols = 2; - if (empty($conf->margin->enabled)) $cols++; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + print '
    '; + + print ''; + print '
    '; + print '
    '; + print '
    '; + + print ''; + // Amount HT - print ''; - print ''; - - // Margin Infos - if (! empty($conf->margin->enabled)) { - $rowspan=4; - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) $rowspan++; - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) $rowspan++; - if (!empty($conf->multicurrency->enabled)) $rowspan+=3; - print ''; - } + print ''; + print ''; print ''; // Amount VAT - print ''; - print ''; + print ''; + print ''; print ''; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { - print ''; - print ''; + print ''; + print ''; print ''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 { print ''; - print ''; + print ''; print ''; } // Amount TTC print ''; - print ''; + print ''; print ''; if (!empty($conf->multicurrency->enabled)) { // Multicurrency Amount HT print ''; - print ''; + print ''; print ''; - + // Multicurrency Amount VAT print ''; - print ''; + print ''; print ''; - + // Multicurrency Amount TTC print ''; - print ''; - print ''; + print ''; + print ''; } // Statut - print ''; + //print ''; - print '
    ' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; - $formmargin->displayMarginInfos($object); - print '
    ' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
    ' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
    ' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
    ' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '
    ' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '
    ' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '
    ' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
    ' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
    ' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '
    ' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '

    '; + print '
    '; + + // Margin Infos + /*if (! empty($conf->margin->enabled)) { + $formmargin->displayMarginInfos($object); + }*/ + print '
    '; + print '
    '; + print ''; + + print '

    '; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); @@ -1658,8 +1690,12 @@ if ($action == 'create') print ''; + // Add free products/services form + global $forceall, $senderissupplier, $dateSelector; + $forceall=1; $senderissupplier=2; $dateSelector=0; // $senderissupplier=2 is same than 1 but disable test on minimum qty. + if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); // Form to add new line if ($object->statut == 0 && $user->rights->supplier_proposal->creer) @@ -1669,7 +1705,7 @@ if ($action == 'create') $var = true; // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc); + $object->formAddObjectLine(1, $soc, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1770,7 +1806,7 @@ if ($action == 'create') print ''; } - + // Clone if ($user->rights->supplier_proposal->creer) { print ''; @@ -1883,7 +1919,7 @@ if ($action == 'create') include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'spr'.$object->id); } - + $formmail->withfrom = 1; $liste = array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 00efb287dcc..5a848654b7c 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -48,7 +48,8 @@ class SupplierProposal extends CommonObject public $table_element_line='supplier_proposaldet'; public $fk_element='fk_supplier_proposal'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - + public $picto='propal'; + /** * {@inheritdoc} */ @@ -727,7 +728,7 @@ class SupplierProposal extends CommonObject * this->ref can be set or empty. If empty, we will use "(PROVid)" * * @param User $user User that create - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ function create($user, $notrigger=0) @@ -1192,8 +1193,8 @@ class SupplierProposal extends CommonObject $sql = "SELECT d.rowid, d.fk_supplier_proposal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; - $sql.= ' d.ref_fourn as ref_produit_fourn'; - $sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc'; + $sql.= ' d.ref_fourn as ref_produit_fourn,'; + $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc'; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql.= " WHERE d.fk_supplier_proposal = ".$this->id; @@ -1334,7 +1335,7 @@ class SupplierProposal extends CommonObject * Set status to validated * * @param User $user Object user that validate - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ function valid($user, $notrigger=0) @@ -1542,7 +1543,7 @@ class SupplierProposal extends CommonObject * @param User $user Object user that close * @param int $statut Statut * @param string $note Comment - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ function reopen($user, $statut, $note='', $notrigger=0) @@ -1890,7 +1891,7 @@ class SupplierProposal extends CommonObject * Delete askprice * * @param User $user Object user that delete - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int 1 if ok, otherwise if error */ function delete($user, $notrigger=0) @@ -2724,7 +2725,7 @@ class SupplierProposalLine extends CommonObject /** * Insert object line propal in database * - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ function insert($notrigger=0) @@ -2906,7 +2907,7 @@ class SupplierProposalLine extends CommonObject /** * Update propal line object into DB * - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ function update($notrigger=0) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 512db4b7c4d..e51ddfcdceb 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -9,7 +9,8 @@ * Copyright (C) 2010-2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador -* + * Copyright (C) 2016 Ferran Marcet + * * 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 @@ -195,8 +196,8 @@ $companystatic=new Societe($db); $now=dol_now(); -$sql = 'SELECT s.rowid, s.nom as name, s.town, s.client, s.code_client,'; -$sql.= ' p.rowid as supplier_proposalid, p.note_private, p.total_ht, p.ref, p.fk_statut, p.fk_user_author, p.date_valid, p.date_livraison as dp,'; +$sql = 'SELECT s.rowid as socid, s.nom as name, s.town, s.client, s.code_client,'; +$sql.= ' p.rowid, p.note_private, p.total_ht, p.ref, p.fk_statut, p.fk_user_author, p.date_valid, p.date_livraison as dp,'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= ' u.login'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'supplier_proposal as p'; @@ -281,6 +282,7 @@ if ($result) $param='&socid='.$socid.'&viewstatut='.$viewstatut; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($sall) $param.='&sall='.$sall; if ($month) $param.='&month='.$month; if ($year) $param.='&year='.$year; if ($search_ref) $param.='&search_ref=' .$search_ref; @@ -388,10 +390,10 @@ if ($result) print ''; - + // Check boxes print ''; print "\n"; @@ -402,78 +404,93 @@ if ($result) while ($i < min($num,$limit)) { - $objp = $db->fetch_object($result); + $obj = $db->fetch_object($result); $now = dol_now(); $var=!$var; + + $objectstatic->id=$obj->rowid; + $objectstatic->ref=$obj->ref; + print ''; print '\n"; - $url = DOL_URL_ROOT.'/comm/card.php?socid='.$objp->rowid; + $url = DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid; // Company - $companystatic->id=$objp->rowid; - $companystatic->name=$objp->name; - $companystatic->client=$objp->client; - $companystatic->code_client=$objp->code_client; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->code_client=$obj->code_client; print ''; // Date print '\n"; // Date delivery print '\n"; - print '\n"; + print '\n"; - $userstatic->id=$objp->fk_user_author; - $userstatic->login=$objp->login; + $userstatic->id=$obj->fk_user_author; + $userstatic->login=$obj->login; print '\n"; - print '\n"; + print '\n"; - print ''; + // Action column + print ''; print "\n"; - $total += $objp->total_ht; - $subtotal += $objp->total_ht; + $total += $obj->total_ht; + $subtotal += $obj->total_ht; $i++; } diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index a3799c0eb29..981b654599d 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -92,6 +92,16 @@ if ($id > 0 || ! empty($ref)) print ""; print ''; + // Payment term + print ''; + print ''; print ''; diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js index f01fde4dabb..eb88af48a04 100644 --- a/htdocs/theme/eldy/ckeditor/config.js +++ b/htdocs/theme/eldy/ckeditor/config.js @@ -39,17 +39,17 @@ CKEDITOR.editorConfig = function( config ) ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['BidiLtr', 'BidiRtl'], ['Link','Unlink','Anchor'], - ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'], + ['Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'], ['Styles','Format','Font','FontSize'], ['TextColor','BGColor'], - ['Maximize', 'ShowBlocks','-','About'] + ['Maximize', 'ShowBlocks'] ]; // Used for mailing fields config.toolbar_dolibarr_mailings = [ ['Source','Maximize','Preview'], - ['Cut','Copy','Paste','-','SpellChecker'], + ['Cut','Copy','Paste','-','SpellChecker', 'Scayt'], ['Undo','Redo','-','Find','Replace'], ['Format','Font','FontSize'], ['Bold','Italic','Underline','Strike','Subscript','Superscript','-','TextColor','RemoveFormat'], @@ -62,7 +62,7 @@ CKEDITOR.editorConfig = function( config ) config.toolbar_dolibarr_notes = [ ['Source','Maximize'], - ['Cut','Copy','Paste','-','SpellChecker'], + ['Cut','Copy','Paste','-','SpellChecker', 'Scayt'], ['Undo','Redo','-','Find','Replace'], ['Format','Font','FontSize'], ['Bold','Italic','Underline','Strike','Subscript','Superscript','-','TextColor','RemoveFormat'], @@ -75,7 +75,7 @@ CKEDITOR.editorConfig = function( config ) config.toolbar_dolibarr_details = [ ['Source','Maximize'], - ['Cut','Copy','Paste','-','SpellChecker'], + ['Cut','Copy','Paste','-','SpellChecker', 'Scayt'], ['Format','Font','FontSize'], ['Bold','Italic','Underline','Strike','Subscript','Superscript','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], diff --git a/htdocs/theme/eldy/img/playdisabled.png b/htdocs/theme/eldy/img/playdisabled.png new file mode 100644 index 00000000000..1cf122679e2 Binary files /dev/null and b/htdocs/theme/eldy/img/playdisabled.png differ diff --git a/htdocs/theme/eldy/img/preview.png b/htdocs/theme/eldy/img/preview.png new file mode 100644 index 00000000000..9040bf963f7 Binary files /dev/null and b/htdocs/theme/eldy/img/preview.png differ diff --git a/htdocs/theme/eldy/img/preview_ext.png b/htdocs/theme/eldy/img/preview_ext.png new file mode 100644 index 00000000000..8bf0c65a7c0 Binary files /dev/null and b/htdocs/theme/eldy/img/preview_ext.png differ diff --git a/htdocs/theme/eldy/img/statut0.png b/htdocs/theme/eldy/img/statut0.png index d11252783a4..f5fce354236 100644 Binary files a/htdocs/theme/eldy/img/statut0.png and b/htdocs/theme/eldy/img/statut0.png differ diff --git a/htdocs/theme/eldy/img/statut0_40x40.png b/htdocs/theme/eldy/img/statut0_40x40.png new file mode 100644 index 00000000000..591aac8e9de Binary files /dev/null and b/htdocs/theme/eldy/img/statut0_40x40.png differ diff --git a/htdocs/theme/eldy/img/statut1.png b/htdocs/theme/eldy/img/statut1.png index 88f3b3c53a0..87b09403e68 100644 Binary files a/htdocs/theme/eldy/img/statut1.png and b/htdocs/theme/eldy/img/statut1.png differ diff --git a/htdocs/theme/eldy/img/statut1_40x40.png b/htdocs/theme/eldy/img/statut1_40x40.png new file mode 100644 index 00000000000..6def06ceaff Binary files /dev/null and b/htdocs/theme/eldy/img/statut1_40x40.png differ diff --git a/htdocs/theme/eldy/img/statut2.png b/htdocs/theme/eldy/img/statut2.png deleted file mode 100644 index ad5a7084474..00000000000 Binary files a/htdocs/theme/eldy/img/statut2.png and /dev/null differ diff --git a/htdocs/theme/eldy/img/statut3.png b/htdocs/theme/eldy/img/statut3.png index e7515796683..bf4f7b8e854 100644 Binary files a/htdocs/theme/eldy/img/statut3.png and b/htdocs/theme/eldy/img/statut3.png differ diff --git a/htdocs/theme/eldy/img/statut3_40x40.png b/htdocs/theme/eldy/img/statut3_40x40.png new file mode 100644 index 00000000000..f71ef4eb962 Binary files /dev/null and b/htdocs/theme/eldy/img/statut3_40x40.png differ diff --git a/htdocs/theme/eldy/img/statut4.png b/htdocs/theme/eldy/img/statut4.png index 6dc05edeba7..7a680ad2b2d 100644 Binary files a/htdocs/theme/eldy/img/statut4.png and b/htdocs/theme/eldy/img/statut4.png differ diff --git a/htdocs/theme/eldy/img/statut4_40x40.png b/htdocs/theme/eldy/img/statut4_40x40.png new file mode 100644 index 00000000000..2da24b66484 Binary files /dev/null and b/htdocs/theme/eldy/img/statut4_40x40.png differ diff --git a/htdocs/theme/eldy/img/statut5.png b/htdocs/theme/eldy/img/statut5.png index 53264a0515d..98bb941a0e5 100644 Binary files a/htdocs/theme/eldy/img/statut5.png and b/htdocs/theme/eldy/img/statut5.png differ diff --git a/htdocs/theme/eldy/img/statut5_40x40.png b/htdocs/theme/eldy/img/statut5_40x40.png new file mode 100644 index 00000000000..7cac0ad23ee Binary files /dev/null and b/htdocs/theme/eldy/img/statut5_40x40.png differ diff --git a/htdocs/theme/eldy/img/statut6.png b/htdocs/theme/eldy/img/statut6.png index c76ab86fe60..fe93f1a0bcc 100644 Binary files a/htdocs/theme/eldy/img/statut6.png and b/htdocs/theme/eldy/img/statut6.png differ diff --git a/htdocs/theme/eldy/img/statut6_40x40.png b/htdocs/theme/eldy/img/statut6_40x40.png new file mode 100644 index 00000000000..0b847c322e2 Binary files /dev/null and b/htdocs/theme/eldy/img/statut6_40x40.png differ diff --git a/htdocs/theme/eldy/img/statut7.png b/htdocs/theme/eldy/img/statut7.png index 8871a45519f..77476349d6d 100644 Binary files a/htdocs/theme/eldy/img/statut7.png and b/htdocs/theme/eldy/img/statut7.png differ diff --git a/htdocs/theme/eldy/img/statut7_40x40.png b/htdocs/theme/eldy/img/statut7_40x40.png new file mode 100644 index 00000000000..48314ccb183 Binary files /dev/null and b/htdocs/theme/eldy/img/statut7_40x40.png differ diff --git a/htdocs/theme/eldy/img/statut8.png b/htdocs/theme/eldy/img/statut8.png index c24d4a9dac2..2627aab8710 100644 Binary files a/htdocs/theme/eldy/img/statut8.png and b/htdocs/theme/eldy/img/statut8.png differ diff --git a/htdocs/theme/eldy/img/statut8_40x40.png b/htdocs/theme/eldy/img/statut8_40x40.png new file mode 100644 index 00000000000..0546ac2c773 Binary files /dev/null and b/htdocs/theme/eldy/img/statut8_40x40.png differ diff --git a/htdocs/theme/eldy/img/statut9.png b/htdocs/theme/eldy/img/statut9.png index 9aa2ae34620..e5304dd791b 100644 Binary files a/htdocs/theme/eldy/img/statut9.png and b/htdocs/theme/eldy/img/statut9.png differ diff --git a/htdocs/theme/eldy/img/statut9_40x40.png b/htdocs/theme/eldy/img/statut9_40x40.png new file mode 100644 index 00000000000..445eac35387 Binary files /dev/null and b/htdocs/theme/eldy/img/statut9_40x40.png differ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3c0b7576c69..91fa5dbb0ec 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -101,6 +101,7 @@ $usegradienttop=(isset($conf->global->THEME_ELDY_TOPMENU_BACK1)?0:1); $usegradienttitle=(isset($conf->global->THEME_ELDY_BACKTITLE1)?0:1); $useboldtitle=(isset($conf->global->THEME_ELDY_USEBOLDTITLE)?$conf->global->THEME_ELDY_USEBOLDTITLE:1); $borderwith=2; +$noborderline=0; // Case of option always editable if (! isset($conf->global->THEME_ELDY_BACKBODY)) $conf->global->THEME_ELDY_BACKBODY=$colorbackbody; @@ -276,7 +277,7 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla } input, textarea, select { - border-radius:4px; + border-radius: 2px; border:solid 1px rgba(0,0,0,.3); border-top:solid 1px rgba(0,0,0,.3); border-bottom:solid 1px rgba(0,0,0,.2); @@ -336,7 +337,6 @@ textarea:disabled { input[type=checkbox] { background-color: transparent; border: none; box-shadow: none; } input[type=radio] { background-color: transparent; border: none; box-shadow: none; } input[type=image] { background-color: transparent; border: none; box-shadow: none; } -input[type=text] { min-width: 20px; } input:-webkit-autofill { background-color: !important; background-image:none !important; @@ -379,9 +379,9 @@ fieldset { border: 1px solid #AAAAAA !important; } filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); border: 1px solid #bbbbbb; border-bottom-color: #a2a2a2; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); @@ -546,8 +546,8 @@ div.myavailability { } .checkallactions { vertical-align: top; - margin-top: 6px; - margin-left: 4px; + margin-top: 6px; + margin-left: 4px; } .selectlimit { margin-right: 10px !important; @@ -580,6 +580,14 @@ div.myavailability { .tablelistofcalendars { margin-top: 25px !important; } +.amountalreadypaid { + color: #008800; + font-weight: bold; +} +.amountremaintopay { + color: #880000; + font-weight: bold; +} /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ .table-responsive { @@ -598,17 +606,21 @@ div.myavailability { .clearboth { clear:both; } .hideobject { display: none; } .minwidth50 { min-width: 50px; } -.minwidth100 { min-width: 100px; } -.minwidth200 { min-width: 200px; } -.minwidth300 { min-width: 300px; } -.minwidth400 { min-width: 400px; } -.minwidth500 { min-width: 500px; } -.minwidth50imp { min-width: 50px !important; } -.minwidth100imp { min-width: 100px !important; } -.minwidth200imp { min-width: 200px !important; } -.minwidth300imp { min-width: 300px !important; } -.minwidth400imp { min-width: 400px !important; } -.minwidth500imp { min-width: 500px !important; } +/* rule to reduce top menu - 3rd reduction */ +@media only screen and (min-width: px) +{ + .minwidth100 { min-width: 100px; } + .minwidth200 { min-width: 200px; } + .minwidth300 { min-width: 300px; } + .minwidth400 { min-width: 400px; } + .minwidth500 { min-width: 500px; } + .minwidth50imp { min-width: 50px !important; } + .minwidth100imp { min-width: 100px !important; } + .minwidth200imp { min-width: 200px !important; } + .minwidth300imp { min-width: 300px !important; } + .minwidth400imp { min-width: 400px !important; } + .minwidth500imp { min-width: 500px !important; } +} .maxwidth100 { max-width: 100px; } .maxwidth150 { max-width: 150px; } .maxwidth200 { max-width: 200px; } @@ -635,6 +647,7 @@ div.myavailability { @media only screen and (max-width: 960px) { + .maxwidthonsmartphone { max-width: 100px; } .minwidth50imp { min-width: 50px !important; } .minwidth100imp { min-width: 50px !important; } .minwidth200imp { min-width: 100px !important; } @@ -646,10 +659,13 @@ div.myavailability { /* Force values for small screen */ @media only screen and (max-width: 570px) { + input[type=text] { min-width: 20px; } + .hideonsmartphone { display: none; } .noenlargeonsmartphone { width : 50px !important; display: inline !important; } .maxwidthonsmartphone { max-width: 100px; } .maxwidth100onsmartphone { max-width: 100px; } + .maxwidth150onsmartphone { max-width: 150px; } .maxwidth200onsmartphone { max-width: 200px; } .maxwidth300onsmartphone { max-width: 300px; } .maxwidth400onsmartphone { max-width: 400px; } @@ -869,6 +885,11 @@ div.nopadding { padding-left: 2px; padding-right: 2px; } +.pictostatus { + width: 15px; + vertical-align: middle; + margin-top: -3px +} .pictowarning, .pictopreview { padding-: 3px; } @@ -900,12 +921,12 @@ div.divphotoref { } div.statusref { float: right; - padding-right: 12px; - margin-top: 6px; + padding-left: 12px; + margin-top: 8px; margin-bottom: 10px; clear: both; } -img.photoref { +img.photoref, div.photoref { border: 1px solid #CCC; -moz-box-shadow: 3px 3px 4px #DDD; -webkit-box-shadow: 3px 3px 4px #DDD; @@ -915,6 +936,12 @@ img.photoref { width: 80px; object-fit: contain; } +div.photoref { + display:table-cell; + vertical-align:middle; + text-align:center; +} + img.photorefnoborder { padding: 2px; height: 48px; @@ -938,7 +965,7 @@ $minwidthtmenu=66; /* minimum width for one top menu entry */ $heightmenu=46; /* height of top menu, part with image */ $heightmenu2=48; /* height of top menu, part with login */ $disableimages = 0; -$maxwidthloginblock = 110; +$maxwidthloginblock = 130; if (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = 180; $minwidthtmenu=0; } ?> @@ -1390,6 +1417,9 @@ div.login a:hover { } div.login_block_user { display: inline-block; + global->THEME_TOPMENU_DISABLE_IMAGE)) { ?> + min-width: 120px; + } div.login_block_other { display: inline-block; @@ -1399,7 +1429,7 @@ div.login_block_other { padding-top: 3px; text-align: right; } .login_block_elem { float: right; vertical-align: top; - padding: 0px 0px 0px 4px !important; + padding: 0px 3px 0px 4px !important; height: 16px; } .atoplogin, .atoplogin:hover { @@ -1770,7 +1800,7 @@ img.toolbarbutton { } /* hide the toggler-button when the pane is 'slid open' */ -.ui-layout-resizer-sliding .ui-layout-toggler { +.ui-layout-resizer-sliding .ui-layout-toggler { display: none; } @@ -1867,18 +1897,19 @@ div.tabsElem { div.tabBar { color: #; - padding-top: px; - padding-left: px; - padding-right: px; - padding-bottom: px; + padding-top: 16px; + padding-left: 0px; padding-right: 0px; + /*padding-left: 18px; + padding-right: 18px;*/ + padding-bottom: 14px; margin: 0px 0px 14px 0px; - -moz-border-radius:4px; + /*-moz-border-radius:4px; -webkit-border-radius: 4px; border-radius: 4px; border-right: 1px solid #AAA; - border-bottom: 1px solid #AAA; - border-left: 1px solid #AAA; + border-left: 1px solid #AAA; */ border-top: 1px solid #BBB; + border-bottom: 1px solid #AAA; width: auto; background: rgb(); @@ -1911,12 +1942,11 @@ div.tabsAction > a { a.tabTitle { color:rgba(0,0,0,.5) !important; - margin-right:10px; text-shadow:1px 1px 1px #ffffff; font-family: ; font-weight: normal !important; - padding: 4px 6px 2px 6px; - margin: 0px 6px; + padding: 4px 6px 2px 0px; + margin-right: 10px; text-decoration: none; white-space: nowrap; } @@ -1997,7 +2027,9 @@ span.tabspan { /* Boutons actions */ /* ============================================================================== */ -div.divButAction { margin-bottom: 1.4em; } +div.divButAction { + margin-bottom: 1.4em; +} span.butAction, span.butActionDelete { cursor: pointer; @@ -2062,9 +2094,9 @@ span.butAction, span.butActionDelete { filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); border: 1px solid #bbbbbb; border-bottom-color: #a2a2a2; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); @@ -2217,7 +2249,7 @@ a.butAction:link, a.butAction:visited, a.butAction:hover, a.butAction:active { } End bootstrap */ -global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?> +global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (! $user->admin)) { ?> .butActionRefused { display: none; } @@ -2277,7 +2309,9 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd table.border, table.dataTable, .table-border, .table-border-col, .table-key-border-col, .table-val-border-col, div.border { + border: 1px solid #E0E0E0; + border-collapse: collapse !important; padding: 1px 2px 1px 3px; /* t r b l */ } @@ -2300,8 +2334,16 @@ div .tdtop { } table.border td, div.border div div.tagtd { + padding: 2px 2px 2px 2px; border: 1px solid #E0E0E0; + + padding: 3px 2px 3px 2px; + border-bottom: 1px solid #E0E0E0; + + padding: 3px 2px 3px 2px; + /* border: 1px solid #E0E0E0; */ + border-collapse: collapse; } @@ -2421,6 +2463,10 @@ div.refidno { font-weight: normal; color: #444; font-size: px; + line-height: 21px; +} +div.refidno form { + display: inline-block; } div.pagination { @@ -2455,18 +2501,18 @@ div.pagination li.pagination a, div.pagination li.pagination span { dol_use_jmobile)) { ?> padding: 6px 12px; - border-color: #ccc; margin-left: -1px; line-height: 1.42857143; color: #000; text-decoration: none; - + /* + border-color: #ccc; background-color: #f5f5f5; background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); - background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); + background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);*/ background-repeat: repeat-x; } @@ -2514,7 +2560,7 @@ div.pagination li.noborder a:hover { div.pagination li a, div.pagination li span { background-color: #fff; - border: 1px solid #ddd; + /* border: 1px solid #ddd; */ } div.pagination li:first-child a, div.pagination li:first-child span { @@ -2747,6 +2793,13 @@ tr.liste_titre_topborder td { text-shadow: none !important; color: rgb(); } +.liste_titre td a.notasortlink { + color: rgb(); +} +.liste_titre td a.notasortlink:hover { + background: transparent; +} + tr.liste_titre_sel th, th.liste_titre_sel, tr.liste_titre_sel td, td.liste_titre_sel, form.liste_titre_sel div { font-family: ; @@ -2788,6 +2841,7 @@ tr.liste_sub_total, tr.liste_sub_total td { border-top-width: px !important; border-top-color: rgb() !important; border-top-style: solid !important; + margin: 0px 0px 0px 0px !important; } .paymenttable tr td:first-child, .margintable tr td:first-child { @@ -2829,7 +2883,7 @@ div.tabBar .noborder { margin-bottom: 8px !important;*/ border: 1px solid #CCC; text-align: center; - border-radius: 4px; + border-radius: 2px; } .boxstats:hover { box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.20); @@ -3311,11 +3365,19 @@ td.hidden { } .websitetools { float: right; - padding-top: 2px; + height: 28px; +} +.websiteinputurl { + display: inline-block; + vertical-align: top; } .websiteiframenoborder { border: 0px; } +a.websitebuttonsitepreview img { + width: 26px; + display: inline-block; +} /* ============================================================================== */ @@ -3364,9 +3426,6 @@ li.cal_event { border: none; list-style-type: none; } .cal_event_busy { } .cal_peruserviewname { max-width: 100px; height: 22px; } -.topmenuimage { - background-size: 28px auto; -} /* ============================================================================== */ /* Ajax - Liste deroulante de l'autocompletion */ @@ -3791,6 +3850,7 @@ div.ecmjqft { text-align: center; min-width: px; width: auto; + max-width: 1024px; padding-left: 10px !important; padding-right: 10px !important; } @@ -3798,9 +3858,9 @@ div.ecmjqft { /* use or not ? */ div.jnotify-background { opacity : 0.95 !important; - -moz-box-shadow: 3px 3px 4px #888 !important; - -webkit-box-shadow: 3px 3px 4px #888 !important; - box-shadow: 3px 3px 4px #888 !important; + -moz-box-shadow: 2px 2px 4px #888 !important; + -webkit-box-shadow: 2px 2px 4px #888 !important; + box-shadow: 2px 2px 4px #888 !important; } /* ============================================================================== */ @@ -3914,8 +3974,18 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +.select2-container .select2-choice > .select2-chosen { + margin-right: 23px; +} +.select2-container .select2-choice .select2-arrow { + border-radius: 0; +} +.select2-container-multi .select2-choices { + background-image: none; +} .select2-container .select2-choice { color: #000; + border-radius: 0; } .selectoptiondisabledwhite { background: #FFFFFF !important; @@ -4090,13 +4160,17 @@ dl.dropdown { .dropdown dd ul li { white-space: nowrap; font-weight: normal; + padding: 2px; } .dropdown dd ul li input[type="checkbox"] { margin-right: 3px; } -.dropdown dd ul li a { - padding:5px; - display:block; +.dropdown dd ul li a, .dropdown dd ul li span { + padding: 3px; + display: block; +} +.dropdown dd ul li span { + color: #888; } .dropdown dd ul li a:hover { background-color:#fff; @@ -4238,20 +4312,40 @@ ul.ulmenu { } /* Style for first level menu with jmobile */ +.ui-li .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li { + padding: .9em 15px; + display: block; +} +.ui-btn-up-c { + font-weight: normal; +} +.ui-bar-b { + border: 1px solid #888; + text-shadow: none; +} +.ui-focus, .ui-btn:focus { + -moz-box-shadow: none; + -webkit-box-shadow: none; + box-shadow: none; +} .ui-bar-b, .lilevel0 { - border: 1px solid #888 !important; +/* border: 1px solid #888 !important; */ background: rgb(); background-repeat: repeat-x; +/* background-image: -o-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); background-image: -moz-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); background-image: -webkit-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); background-image: -ms-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); - background-image: linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); + background-image: linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);*/ font-weight: bold; color: rgb() !important; } +.ui-li.ui-last-child, .ui-li.ui-field-contain.ui-last-child { + border-bottom-width: 0px !important; +} .alilevel0 { color: rgb() !important; text-shadow: 1px 0px 1px #; @@ -4264,7 +4358,7 @@ ul.ulmenu { text-shadow: none; } .ui-btn-up-c, .ui-btn-hover-c { - border: 1px solid #ccc; + /* border: 1px solid #ccc; */ text-shadow: none; } .ui-body-c .ui-link, .ui-body-c .ui-link:visited, .ui-body-c .ui-link:hover { @@ -4320,7 +4414,6 @@ border-top-right-radius: 6px; .menu_choix1 a { background: url('') top left no-repeat; } - .menu_choix2 a { background: url('') top left no-repeat; } @@ -4337,12 +4430,36 @@ border-top-right-radius: 6px; padding-top: 18px; padding-left: 54px; font-size: 14px; - height: 40px; + height: 38px; } .menu_choix1 a:hover,.menu_choix2 a:hover { color: #6d3f6d; } - +.menu li.menu_choix1 { + padding-top: 6px; + padding-right: 10px; + padding-bottom: 2px; +} +.menu li.menu_choix2 { + padding-top: 6px; + padding-right: 10px; + padding-bottom: 2px; +} +@media only screen and (max-width: 767px) +{ + .menu_choix1 a, .menu_choix2 a { + background-size: 36px 36px; + height: 30px; + padding-left: 40px; + } + .menu li.menu_choix1, .menu li.menu_choix2 { + padding-left: 4px; + padding-right: 0; + } + .liste_articles { + margin-right: 0 !important; + } +} /* ============================================================================== */ @@ -4378,6 +4495,10 @@ img.demothumb { /* CSS style used for small screen */ /* ============================================================================== */ +.topmenuimage { + background-size: 22px auto; + top: 2px; +} .imgopensurveywizard { padding: 0 4px 0 4px; @@ -4397,11 +4518,21 @@ img.demothumb { margin-left: 4px; width: 80px; } + + div.tabBar { + padding-left: 0px; + padding-right: 0px; + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0px; + border-right: none; + border-left: none; + } } /* nboftopmenuentries = , fontsize= */ /* rule to reduce top menu - 1st reduction */ -@media only screen and (max-width: px) +@media only screen and (max-width: px) { div.tmenucenter { max-width: px; /* size of viewport */ @@ -4415,7 +4546,7 @@ img.demothumb { font-size: 10px; } .topmenuimage { - background-size: 26px auto; + background-size: 22px auto; margin-top: 0px; } @@ -4447,9 +4578,12 @@ img.demothumb { background-size: 20px auto; margin-top: 2px; } + select { + width: 100%; + } } /* rule to reduce top menu - 3rd reduction */ -@media only screen and (max-width: 660px) +@media only screen and (max-width: px) { /* Reduce login top right info */ .usertextatoplogin { @@ -4467,6 +4601,9 @@ img.demothumb { padding-: 78px; } + div.login_block_user { + min-width: 0; + } div.login_block { top: 2px; @@ -4475,6 +4612,9 @@ img.demothumb { max-width: 82px; } + .login_block_elem { + padding: 0 !important; + } li.tmenu, li.tmenusel { min-width: 32px; } @@ -4496,6 +4636,12 @@ img.demothumb { position: absolute; width: px; } + select { + width: 100%; + max-width: 100px; + min-width: 0 !important; + } + } browser->layout != 'phone') { print "padding-".$left.": 16px;\n"; } else print "margin-top: 10px;\n"; ?> } -/* Force values for small screen */ +/* Force values on one colum for small screen */ @media only screen and (max-width: 900px) { div.fiche { @@ -1165,7 +1167,7 @@ div.mainmenu { div.mainmenu.home{ background-image: url(); - background-position-x: middle; + background-position-x: center; } div.mainmenu.accountancy { @@ -1279,7 +1281,7 @@ foreach($mainmenuusedarray as $val) $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$generic.".png",1); $found=1; if ($generic < 4) $generic++; - print "/* A mainmenu entry but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; + print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; } if ($found) { @@ -1775,7 +1777,7 @@ img.toolbarbutton { } /* hide the toggler-button when the pane is 'slid open' */ -.ui-layout-resizer-sliding ui-layout-toggler { +.ui-layout-resizer-sliding .ui-layout-toggler { display: none; } @@ -2014,8 +2016,8 @@ span.tabspan { /* Boutons actions */ /* ============================================================================== */ -div.divButAction { - margin-bottom: 1.4em; +div.divButAction { + margin-bottom: 1.4em; vertical-align: top; } @@ -2278,6 +2280,12 @@ table.noborder tr, div.noborder form { border-top-color: rgb(); border-top-style: solid; } +.liste_titre_add td, .liste_titre_add .tagtd +{ + border-top-width: 1px; + border-top-color: rgb(); + border-top-style: solid; +} table.liste th, table.noborder th, table.noborder tr.liste_titre td { padding: 8px 2px 8px 3px; /* t r b l */ @@ -2332,6 +2340,10 @@ div.refidno { font-weight: normal; color: #444; font-size: px; + line-height: 21px; +} +div.refidno form { + display: inline-block; } div.pagination { @@ -2627,6 +2639,12 @@ tr.liste_titre_topborder td { text-shadow: none !important; color: rgb(); } +.liste_titre td a.notasortlink { + color: rgb(); +} +.liste_titre td a.notasortlink:hover { + background: transparent; +} div.liste_titre { padding-left: 3px; } @@ -3208,7 +3226,18 @@ td.hidden { } .websitetools { float: right; - padding-top: 2px; + height: 28px; +} +.websiteinputurl { + display: inline-block; + vertical-align: top; +} +.websiteiframenoborder { + border: 0px; +} +a.websitebuttonsitepreview img { + width: 26px; + display: inline-block; } .websiteiframenoborder { border: 0px; @@ -3687,6 +3716,7 @@ div.ecmjqft { text-align: center; min-width: px; width: auto; + max-width: 1024px; padding-left: 10px !important; padding-right: 10px !important; } @@ -3694,9 +3724,9 @@ div.ecmjqft { /* use or not ? */ div.jnotify-background { opacity : 0.95 !important; - -moz-box-shadow: 3px 3px 4px #888 !important; - -webkit-box-shadow: 3px 3px 4px #888 !important; - box-shadow: 3px 3px 4px #888 !important; + -moz-box-shadow: 2px 2px 4px #888 !important; + -webkit-box-shadow: 2px 2px 4px #888 !important; + box-shadow: 2px 2px 4px #888 !important; } /* ============================================================================== */ @@ -3811,6 +3841,12 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +.select2-container .select2-choice > .select2-chosen { + margin-right: 23px; +} +.select2-container .select2-choice .select2-arrow { + border-radius: 0; +} .select2-container .select2-choice { color: #000; } @@ -3986,13 +4022,17 @@ dl.dropdown { .dropdown dd ul li { white-space: nowrap; font-weight: normal; + padding: 2px; } .dropdown dd ul li input[type="checkbox"] { margin-right: 3px; } -.dropdown dd ul li a { - padding:5px; - display:block; +.dropdown dd ul li a, .dropdown dd ul li span { + padding: 3px; + display: block; +} +.dropdown dd ul li span { + color: #888; } .dropdown dd ul li a:hover { background-color:#fff; @@ -4136,11 +4176,11 @@ ul.ulmenu { background: rgb(); background-repeat: repeat-x; - background-image: -o-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); + /*background-image: -o-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); background-image: -moz-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); background-image: -webkit-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); background-image: -ms-linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); - background-image: linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%); + background-image: linear-gradient(bottom, rgba(0,0,0,0.3) 0%, rgba(250,250,250,0.3) 100%);*/ font-weight: bold; color: rgb() !important; @@ -4229,7 +4269,31 @@ border-top-right-radius: 6px; .menu_choix1 a:hover,.menu_choix2 a:hover { color: #6d3f6d; } - +.menu li.menu_choix1 { + padding-top: 6px; + padding-right: 10px; + padding-bottom: 2px; +} +.menu li.menu_choix2 { + padding-top: 6px; + padding-right: 10px; + padding-bottom: 2px; +} +@media only screen and (max-width: 767px) +{ + .menu_choix1 a, .menu_choix2 a { + background-size: 36px 36px; + background-position-y: 6px; + padding-left: 40px; + } + .menu li.menu_choix1, .menu li.menu_choix2 { + padding-left: 4px; + padding-right: 0; + } + .liste_articles { + margin-right: 0 !important; + } +} @@ -4288,6 +4352,17 @@ img.demothumb { position: absolute; width: px; } + + div.tabBar { + padding-left: 0px; + padding-right: 0px; + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0px; + border-right: none; + border-left: none; + } + } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 032628e4e67..fb3ad2fe3f0 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -216,6 +216,8 @@ if (empty($reshook)) { $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; $object->color = GETPOST("color") != '' ? GETPOST("color") : ''; + $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear')); + $object->dateemployment = $dateemployment; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); @@ -263,10 +265,7 @@ if (empty($reshook)) { { $langs->load("errors"); $db->rollback(); - if (is_array($object->errors) && count($object->errors)) - { - setEventMessages($object->error, $object->errors, 'errors'); - } + setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; // Go back to create page } } @@ -360,6 +359,8 @@ if (empty($reshook)) { $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; $object->color = GETPOST("color") != '' ? GETPOST("color") : ''; + $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth'), GETPOST('dateemploymentday'), GETPOST('dateemploymentyear')); + $object->dateemployment = $dateemployment; if (! empty($conf->multicompany->enabled)) { @@ -753,7 +754,7 @@ if (($action == 'create') || ($action == 'adduserldap')) // Employee print ''; print ''; // Position/Job @@ -1060,6 +1061,13 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print ''; print "\n"; + + // Date employment + print ''; + print ''; + print "\n"; // Accountancy code if ($conf->accounting->enabled) @@ -1131,6 +1139,10 @@ else $object->fetch($id); if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); + + // Check if user has rights + $object->getrights(); + if(empty($object->nb_rights)) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings'); // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon @@ -1415,6 +1427,13 @@ else print ''; } + // Date employment + print ''; + print ''; + print "\n"; + print '
    '; $formsupplier_proposal->selectSupplierProposalStatus($viewstatut,1); print ''; - print ''; - print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; print '
    '; - $objectstatic->id=$objp->supplier_proposalid; - $objectstatic->ref=$objp->ref; - print ''; + // Picto + Ref print ''; - - print ''; - - // Ref + if ($warnornote) + { + print ''; + } + // Other picto tool print '
    '; print $objectstatic->getNomUrl(1); print ''; - if ($objp->fk_statut == 1 && $db->jdate($objp->dfv) < ($now - $conf->supplier_proposal->cloture->warning_delay)) print img_warning($langs->trans("Late")); - if (! empty($objp->note_private)) + // Warning + $warnornote=''; + if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); + if (! empty($obj->note_private)) { - print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; - print ''; + $warnornote.=($warnornote?' ':''); + $warnornote.= ''; + $warnornote.= ''.img_picto($langs->trans("ViewPrivateNote"),'object_generic').''; + $warnornote.= ''; } - print ''; + print $warnornote; + print ''; - $filename=dol_sanitizeFileName($objp->ref); - $filedir=$conf->supplier_proposal->dir_output . '/' . dol_sanitizeFileName($objp->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->supplier_proposalid; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->supplier_proposal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '
    '; print "
    '; print $companystatic->getNomUrl(1,'customer'); print ''; - print dol_print_date($db->jdate($objp->date_valid), 'day'); + print dol_print_date($db->jdate($obj->date_valid), 'day'); print "'; - print dol_print_date($db->jdate($objp->dp), 'day'); + print dol_print_date($db->jdate($obj->dp), 'day'); print "'.price($objp->total_ht)."'.price($obj->total_ht)."'; if ($userstatic->id) print $userstatic->getLoginUrl(1); else print ' '; print "'.$objectstatic->LibStatut($objp->fk_statut,5)."'.$objectstatic->LibStatut($obj->fk_statut,5)." '; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
    ".$langs->trans("Supplier")."'.$object->thirdparty->getNomUrl(1).'
    '; + print ''; + print '
    '; + print $langs->trans('PaymentConditionsShort'); + print '
    '; + print '
    '; + $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none', 1); + print '
    '.$langs->trans('SupplierProposalDate').''; print dol_print_date($object->date_livraison,'daytext'); print '
    '.fieldLabel('Employee','employee',0).''; - print $form->selectyesno("employee",(isset($_POST['employee'])?GETPOST('employee'):0),1); + print $form->selectyesno("employee",(GETPOST('employee')?GETPOST('employee'):0),1); print '
    '.$langs->trans("DateEmployment").''; + echo $form->select_date(GETPOST('dateemployment'),'dateemployment',0,0,1,'form'.'dateemployment',1,0,1); + print '
    '.$object->accountancy_code.'
    '.$langs->trans("DateEmployment").''; + print dol_print_date($object->dateemployment); + print '
    '; print ''; @@ -2189,6 +2208,13 @@ else print '
    '.$langs->trans("DateEmployment").''; + echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1); + print '
    '; - print ''.img_object($langs->trans("ShowUser"),"user").' '.$useringroup->login.''; + print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar'); else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star'); print '
    '; + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); + + /*print '
    '; // Ref print ''; @@ -160,7 +163,7 @@ if ($result > 0) print ''; print "\n"; - print '
    '.$langs->trans("Ref").''.dol_print_email($object->email,0,0,1).'
    '; + print '
    ';*/ dol_fiche_end(); @@ -187,9 +190,9 @@ if ($result > 0) // Line with titles print ''; print ''; - print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'"width="45%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'"width="35%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'"width="10%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'"width="45%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",'',$param,'"width="35%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"n.type",'',$param,'"width="10%"',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; @@ -242,22 +245,6 @@ if ($result > 0) print ''; print '
    '; - // List of active notifications - print_fiche_titre($langs->trans("ListOfActiveNotifications"),'',''); - $var=true; - - // Line with titles - print '
    '; - print ''; - print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'"width="45%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'"width="35%"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'"width="10%"',$sortfield,$sortorder); - print_liste_field_titre('','',''); - print ''; - - $langs->load("errors"); - $langs->load("other"); - // List of notifications enabled for contacts $sql = "SELECT n.rowid, n.type,"; $sql.= " a.code, a.label,"; @@ -268,12 +255,36 @@ if ($result > 0) $sql.= " WHERE a.rowid = n.fk_action"; $sql.= " AND c.rowid = n.fk_user"; $sql.= " AND c.rowid = ".$object->id; - + $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i = 0; + } + else + { + dol_print_error($db); + } + + // List of active notifications + print_fiche_titre($langs->trans("ListOfActiveNotifications").' ('.$num.')','',''); + $var=true; + + // Line with titles + print '
    '; + print ''; + print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'"width="45%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",'',$param,'"width="35%"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"n.type",'',$param,'"width="10%"',$sortfield,$sortorder); + print_liste_field_titre('','',''); + print ''; + + $langs->load("errors"); + $langs->load("other"); + + if ($num) + { + $i = 0; $userstatic=new user($db); @@ -314,10 +325,7 @@ if ($result > 0) } $db->free($resql); } - else - { - dol_print_error($db); - } + // List of notifications enabled for fixed email /* @@ -375,20 +383,6 @@ if ($result > 0) print '

    '."\n"; - // List of notifications done - print_fiche_titre($langs->trans("ListOfNotificationsDone"),'',''); - $var=true; - - // Line with titles - print '
    '; - print ''; - print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname",'',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.titre",'',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder); - //print_liste_field_titre($langs->trans("Object"),$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"a.daten",'',$param,'align="right"',$sortfield,$sortorder); - print ''; - // List $sql = "SELECT n.rowid, n.daten, n.email, n.objet_type as object_type, n.objet_id as object_id, n.type,"; $sql.= " c.rowid as id, c.lastname, c.firstname, c.email as contactemail,"; @@ -398,11 +392,34 @@ if ($result > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as c ON n.fk_user = c.rowid"; $sql.= " WHERE a.rowid = n.fk_action"; $sql.= " AND n.fk_user = ".$object->id; - + $sql.= $db->order($sortfield, $sortorder); + $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); + } + else + { + dol_print_error($db); + } + + // List of notifications done + print_fiche_titre($langs->trans("ListOfNotificationsDone").' ('.$num.')','',''); + $var=true; + + // Line with titles + print '
    '; + print ''; + print_liste_field_titre($langs->trans("Target"),$_SERVER["PHP_SELF"],"c.lastname,c.firstname",'',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"n.type",'',$param,'',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans("Object"),$_SERVER["PHP_SELF"],"",'',$param,'"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"n.daten",'',$param,'align="right"',$sortfield,$sortorder); + print ''; + + if ($num) + { $i = 0; $userstatic=new User($db); @@ -451,10 +468,6 @@ if ($result > 0) } $db->free($resql); } - else - { - dol_print_error($db); - } print '
    '; } diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index a5df31c2a7e..99e8ea59e6f 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2012 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -14,16 +14,16 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * + * Path to WSDL is: http://localhost/dolibarr/webservices/server_actioncomm.php?wsdl */ /** * \file htdocs/webservices/server_actioncomm.php * \brief File that is entry point to call Dolibarr WebServices - * \version $Id: server_actioncomm.php,v 1.7 2010/12/19 11:49:37 eldy Exp $ */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once("../master.inc.php"); require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP diff --git a/htdocs/webservices/server_category.php b/htdocs/webservices/server_category.php index 2bf914ebd38..9ef07dda952 100644 --- a/htdocs/webservices/server_category.php +++ b/htdocs/webservices/server_category.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2012 JF FERRY * * This program is free software; you can redistribute it and/or modify @@ -21,8 +21,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once("../master.inc.php"); require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index f439e791cb4..cab58268f57 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2012 JF FERRY * * This program is free software; you can redistribute it and/or modify @@ -21,8 +21,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once("../master.inc.php"); require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP @@ -660,7 +659,7 @@ function updateContact($authentication,$contact) $object->civility_id=$contact['civility_id']; $object->poste=$contact['poste']; - $object->statut=$contact['statut']; + $object->statut=$contact['status']; //Retreive all extrafield for contact diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 04ce0c3cf48..54f5e3c564c 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2016 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -21,8 +21,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 28518d24763..f477ccfed9c 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2012 JF FERRY * Copyright (C) 2012 Regis Houssin * @@ -22,9 +22,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ - -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP @@ -935,7 +933,7 @@ function updateOrder($authentication,$order) if (isset($order['billed'])) { if ($order['billed']) $result=$object->classifyBilled($fuser); - if (! $order['billed']) $result=$object->classifyBilled($fuser); + if (! $order['billed']) $result=$object->classifyUnBilled($fuser); } //Retreive all extrafield for object diff --git a/htdocs/webservices/server_other.php b/htdocs/webservices/server_other.php index ba948d463ea..8ac519ae87e 100644 --- a/htdocs/webservices/server_other.php +++ b/htdocs/webservices/server_other.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * * 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 @@ -20,8 +20,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index aa43dbb185c..385c7dc3b95 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2012 JF FERRY * * This program is free software; you can redistribute it and/or modify @@ -23,8 +23,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php index 8838f726d63..5400e069c3f 100644 --- a/htdocs/webservices/server_project.php +++ b/htdocs/webservices/server_project.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2016 Ion Agorria * * This program is free software; you can redistribute it and/or modify @@ -21,8 +21,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index fea871ac077..ea162ef2a8b 100644 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * * 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 @@ -20,8 +20,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 50b8e80e363..6b2c94a36fd 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * * 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 @@ -20,8 +20,7 @@ * \brief File that is entry point to call Dolibarr WebServices */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 6339486922f..c4d8ce08724 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * * 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 @@ -18,11 +18,9 @@ /** * \file htdocs/webservices/server_user.php * \brief File that is entry point to call Dolibarr WebServices - * \version $Id: server_user.php,v 1.7 2010/12/19 11:49:37 eldy Exp $ */ -// This is to make Dolibarr working with Plesk -set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); +if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); require_once '../master.inc.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 65e56e030a1..63dc35b8084 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -183,7 +183,7 @@ class WebsitePage extends CommonObject * Load object in memory from the database * * @param int $id Id object - * @param string $website_id Web site page + * @param string $website_id Web site id * @param string $page Page name * * @return int <0 if KO, 0 if not found, >0 if OK @@ -376,14 +376,11 @@ class WebsitePage extends CommonObject $this->status = trim($this->status); } - - // Check parameters // Put here code to add a control on parameters values // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' fk_website = '.(isset($this->fk_website)?$this->fk_website:"null").','; $sql .= ' pageurl = '.(isset($this->pageurl)?"'".$this->db->escape($this->pageurl)."'":"null").','; $sql .= ' title = '.(isset($this->title)?"'".$this->db->escape($this->title)."'":"null").','; @@ -394,8 +391,6 @@ class WebsitePage extends CommonObject $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); - - $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -407,6 +402,12 @@ class WebsitePage extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } + if ($this->old_object->pageurl != $this->pageurl) + { + dol_syslog("The alias was changed, we must rename/recreate the page file into document"); + + } + if (!$error && !$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 655bdd18e9f..d0aa6424787 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -177,48 +177,9 @@ if ($action == 'add') { $db->rollback(); } -} - -// Update page -if ($action == 'update') -{ - $db->begin(); - - $res = $object->fetch(0, $website); - - $objectpage->fk_website = $object->id; - $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); - - $res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl); - - if ($res > 0) - { - $objectpage->title = GETPOST('WEBSITE_TITLE'); - $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); - $objectpage->keyword = GETPOST('WEBSITE_KEYWORD'); - - $res = $objectpage->update($user); - if (! $res > 0) - { - $error++; - setEventMessages($objectpage->error, $objectpage->errors, 'errors'); - } - - if (! $error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - $action=''; - } - else - { - $db->rollback(); - } - } - else - { - dol_print_error($db); - } + + $action = 'preview'; + $id = $objectpage->id; } // Update page @@ -261,35 +222,48 @@ if ($action == 'delete') // Update css if ($action == 'updatecss') { - $db->begin(); + //$db->begin(); $res = $object->fetch(0, $website); + /* $res = $object->update($user); if ($res > 0) { $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); $action=''; } else { + $error++; $db->rollback(); }*/ - $csscontent =''."\n"; + $csscontent.= '"."\n"; + $csscontent.= ''."\n"; $csscontent.= GETPOST('WEBSITE_CSS_INLINE'); + dol_syslog("Save file css into ".$filecss); + dol_mkdir($pathofwebsite); $result = file_put_contents($filecss, $csscontent); if (! empty($conf->global->MAIN_UMASK)) @chmod($filecss, octdec($conf->global->MAIN_UMASK)); - - if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs'); - else setEventMessages('Failed to write file '.$fileindex, null, 'errors'); + if (! $result) + { + $error++; + setEventMessages('Failed to write file '.$filecss, null, 'errors'); + } + + if (! $error) + { + setEventMessages($langs->trans("Saved"), null, 'mesgs'); + } + $action='preview'; } @@ -335,7 +309,7 @@ if ($action == 'setashome') } } -// Update page +// Update page (meta) if ($action == 'updatemeta') { $db->begin(); @@ -346,7 +320,7 @@ if ($action == 'updatemeta') $res = $objectpage->fetch($pageid, $object->fk_website); if ($res > 0) { - $oldobjectpage = clone $objectpage; + $objectpage->old_object = clone $objectpage; $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); $objectpage->title = GETPOST('WEBSITE_TITLE'); @@ -364,32 +338,54 @@ if ($action == 'updatemeta') { $db->commit(); - $fileoldalias=$pathofwebsite.'/'.$oldobjectpage->pageurl.'.php'; + $filemaster=$pathofwebsite.'/master.inc.php'; + $fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; - - // Generate the alias.php page - //----------------------------- + dol_mkdir($pathofwebsite); - dol_delete_file($fileoldalias); + + + // Now generate the master.inc.php page + dol_syslog("We regenerate the master file"); + dol_delete_file($filemaster); + + $mastercontent = ''."\n"; + $result = file_put_contents($filemaster, $mastercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); + + if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + + + // Now generate the alias.php page + if (! empty($fileoldalias)) + { + dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias); + dol_delete_file($fileoldalias); + } $aliascontent = 'id.".tpl.php'\n"; + $aliascontent.= "include_once './page".$objectpage->id.".tpl.php';\n"; $aliascontent.= '?>'."\n"; $result = file_put_contents($filealias, $aliascontent); if (! empty($conf->global->MAIN_UMASK)) @chmod($filealias, octdec($conf->global->MAIN_UMASK)); - if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs'); - else setEventMessages('Failed to write file '.$filealias, null, 'errors'); + if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); - // Now create the .tpl file (duplicate code with actions updatecontent but we need this to save new header) - dol_mkdir($pathofwebsite); + dol_syslog("We regenerate the tpl page filetpl=".$filetpl); + dol_delete_file($filetpl); - $tplcontent = ''."\n"; + $tplcontent =''; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= '
    '."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -412,7 +408,7 @@ if ($action == 'updatemeta') if ($result) { - //setEventMessages($langs->trans("Saved"), null, 'mesgs'); + setEventMessages($langs->trans("Saved"), null, 'mesgs'); //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); //exit; } @@ -449,7 +445,7 @@ if ($action == 'updatecontent') /* $objectpage->content = preg_replace('//s', '', $objectpage->content); */ $res = $objectpage->update($user); - if (! $res > 0) + if ($res < 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); @@ -459,12 +455,53 @@ if ($action == 'updatecontent') { $db->commit(); + $filemaster=$pathofwebsite.'/master.inc.php'; + //$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; + $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; + + dol_mkdir($pathofwebsite); + + + // Now generate the master.inc.php page + dol_syslog("We regenerate the master file"); + dol_delete_file($filemaster); + + $mastercontent = ''."\n"; + $result = file_put_contents($filemaster, $mastercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); + + if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + + + // Now generate the alias.php page + if (! empty($fileoldalias)) + { + dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias); + dol_delete_file($fileoldalias); + } + + $aliascontent = 'id.".tpl.php';\n"; + $aliascontent.= '?>'."\n"; + $result = file_put_contents($filealias, $aliascontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filealias, octdec($conf->global->MAIN_UMASK)); + + if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); + + // Now create the .tpl file // TODO Keep a one time generate file or include a dynamicaly generated content ? - dol_mkdir($pathofwebsite); dol_delete_file($filetpl); - $tplcontent = ''."\n"; + $tplcontent =''; + $tplcontent.= ""."\n"; + $tplcontent.= ''."\n"; $tplcontent.= '
    '."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -516,7 +553,7 @@ $help_url=''; llxHeader('', $langs->trans("WebsiteSetup"), $help_url); -print "\n".'
    '; +print "\n".'
    '; print ''; if ($action == 'create') { @@ -590,47 +627,19 @@ if (count($object->records) > 0) $realurl=$urlwithroot.'/public/websites/index.php?website='.$website; $dataroot=DOL_DATA_ROOT.'/websites/'.$website; if (! empty($object->virtualhost)) $realurl=$object->virtualhost; - // TODO If virtual url defined, we use it - - /*print ' - '.$langs->trans("RealURL").' '; - print ' '; - print ''.$langs->trans("ViewSiteInNewTab").'';*/ - + } + + if ($website && $action == 'preview') + { + $disabled=''; + if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; + print '   '; - - print $langs->trans("ViewWebsiteInProduction").': '; - print ''; - //print ''; - $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); - print $form->textwithpicto('', $htmltext); - print ''.$langs->trans("ViewSiteInNewTab").''; - // Example : Adding jquery code - if (! empty($conf->use_javascript_ajax)) - { - print ''; - } + //print ''; + print ''; + print ''; + print ''; } print '
    '; @@ -640,13 +649,22 @@ if (count($object->records) > 0) if ($action == 'preview') { - $disabled=''; - if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; - - //print ''; - print ''; - print ''; - print ''; + print '
    '; + print ''; + //print ''; + $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); + print $form->textwithpicto('', $htmltext); + print '
    '; + + $urlext=$realurl; + $urlint=DOL_URL_ROOT.'/public/websites/index.php?website='.$website; + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlext), 1, 'preview_ext'); + print ''; + + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlint), 1, 'preview'); + print ''; } if (in_array($action, array('editcss','editmenu','create'))) @@ -674,60 +692,55 @@ if (count($object->records) > 0) print $langs->trans("Page").': '; print '
    '; print '
    '; - $out=''; - $out.=''; + if ($atleastonepage) { - $firstpageid=0;$homepageid=0; + if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one + { + $firstpageid=0;$homepageid=0; + foreach($array as $key => $valpage) + { + if (empty($firstpageid)) $firstpageid=$valpage->id; + if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; + } + $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page + } + foreach($array as $key => $valpage) { - if (empty($firstpageid)) $firstpageid=$valpage->id; - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; + $out.=''; } - $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page - } - - foreach($array as $key => $valpage) - { - $out.=''; } + else $out.=''; + $out.=''; + print $out; + } + else + { + print $langs->trans("New"); } - else $out.=''; - $out.=''; - print $out; print ''; //print $form->selectarray('page', $array); - if ($website && $pageid > 0) - { - print ' - '.$langs->trans("RealURL").' '; - $realurl=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; - print ' '; - print ''.$langs->trans("ViewPageInNewTab").''; // View page in new Tab - //print ''; - } - - print '
    '; - print '
    '; - print '
    '; - - print '
    '; - if ($action == 'preview') { $disabled=''; if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; - + if ($pageid > 0) { + print '   '; + if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; else print ''; print ''; @@ -738,15 +751,80 @@ if (count($object->records) > 0) } } + print '
    '; + print '
    '; + print '
    '; + + print '
    '; + + if ($website && $pageid > 0 && $action == 'preview') + { + $websitepage = new WebSitePage($db); + $websitepage->fetch($pageid); + + $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; + $pagealias = $websitepage->pageurl; + + print '
    '; + print ''; + //print ''; + $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); + print $form->textwithpicto('', $htmltext); + print '
    '; + + $urlext=$realurl.'/'.$pagealias.'.php'; + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $urlext), 1, 'preview_ext'); + print ''; + + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage), 1, 'preview'); + print ''; // View page in new Tab + //print ''; + + // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext + } if (! in_array($action, array('editcss','editmenu','create'))) { if ($action != 'preview') print ''; if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; } - + print '
    '; + if ($action == 'preview') + { + // Adding jquery code to change on the fly url of preview ext + if (! empty($conf->use_javascript_ajax)) + { + print ''; + } + } } } else @@ -775,12 +853,15 @@ if ($action == 'editcss') print '
    '; $csscontent = @file_get_contents($filecss); - + // Clean php css file to get only css part + $csscontent = preg_replace('//s', '', $csscontent); + dol_fiche_head(); + print ''."\n"; print ''; - print '
    '; + print '
    '; print $langs->trans('WebSite'); print ''; print $website; @@ -817,6 +898,7 @@ if ($action == 'editmeta' || $action == 'create') dol_fiche_head(); + print ''."\n"; print ''; if ($action != 'create') @@ -836,7 +918,7 @@ if ($action == 'editmeta' || $action == 'create') if (GETPOST('WEBSITE_DESCRIPTION')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION'); if (GETPOST('WEBSITE_KEYWORDS')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS'); - print '
    '; + print '
    '; print $langs->trans('WEBSITE_PAGENAME'); print ''; print ''; @@ -871,11 +953,13 @@ if ($action == 'editmeta' || $action == 'create') if ($action == 'editmedia') { + print ''."\n"; print '
    '.$langs->trans("FeatureNotYetAvailable").''; } if ($action == 'editmenu') { + print ''."\n"; print '
    '.$langs->trans("FeatureNotYetAvailable").''; } @@ -895,10 +979,10 @@ if ($action == 'editcontent') require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,5,60); - $doleditor->Create(); + $doleditor->Create(0, '', false); } -print ''; +print "
    \n\n"; diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index 98ec3dd84cd..4ec31ea3789 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -366,7 +366,7 @@ if ($resql) /*elseif ($links[$key]['type']=='sc') { if ($accountelem) $accountelem.= ', '; - //$accountelem.= ''; + //$accountelem.= ''; //$accountelem.= img_object($langs->transnoentitiesnoconv('ShowBill'),'bill').' '; $accountelem.= $langs->transnoentitiesnoconv("SocialContribution"); //$accountelem.= ''; diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 38054c48c69..e10d089c2a8 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -27,7 +27,6 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOLOGIN')) define('NOLOGIN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); @@ -110,8 +109,8 @@ else { if (empty($user->id)) { - echo "User user login: ".$userlogin." does not exists"; - dol_syslog("User user login:".$userlogin." does not exists", LOG_ERR); + echo "User login: ".$userlogin." does not exists"; + dol_syslog("User login:".$userlogin." does not exists", LOG_ERR); exit(-1); } } @@ -125,8 +124,7 @@ if (isset($argv[3]) || $argv[3]) $object = new Cronjob($db); $filter=array(); -if (empty($id)) { - $filter=array(); +if (! empty($id)) { $filter['t.rowid']=$id; } @@ -153,22 +151,25 @@ if(is_array($object->lines) && (count($object->lines)>0)) //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { - dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourtext')." line->dateend:".dol_print_date($line->dateend,'dayhourtext')." now:".dol_print_date($now,'dayhourtext')); + dol_syslog("cron_run_jobs.php:: to run line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); $cronjob=new Cronjob($db); $result=$cronjob->fetch($line->id); if ($result<0) { - echo "Error:".$cronjob->error; - dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); + echo "Error cronjob->fetch: ".$cronjob->error."\n"; + echo "Failed to fetch job ".$line->id."\n"; + dol_syslog("cron_run_jobs.php::fetch Error ".$cronjob->error, LOG_ERR); exit(-1); } // Execute job $result=$cronjob->run_jobs($userlogin); if ($result<0) { - echo "Error:".$cronjob->error; - dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR); + echo "Error cronjob->run_job: ".$cronjob->error."\n"; + echo "At least one job failed. Go on menu Home-Setup-Admin tools to see result for each job.\n"; + echo "You can also enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n"; + dol_syslog("cron_run_jobs.php::run_jobs Error ".$cronjob->error, LOG_ERR); exit(-1); } @@ -176,12 +177,17 @@ if(is_array($object->lines) && (count($object->lines)>0)) $result=$cronjob->reprogram_jobs($userlogin, $now); if ($result<0) { - echo "Error:".$cronjob->error; - dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR); + echo "Error cronjob->reprogram_job: ".$cronjob->error."\n"; + echo "Enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n"; + dol_syslog("cron_run_jobs.php::reprogram_jobs Error ".$cronjob->error, LOG_ERR); exit(-1); } } + else + { + dol_syslog("cron_run_jobs.php:: job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + } } } diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php index 1a8c673c5f9..d381c32676a 100755 --- a/scripts/withdrawals/build_withdrawal_file.php +++ b/scripts/withdrawals/build_withdrawal_file.php @@ -70,6 +70,7 @@ if (! isset($argv[1])) { // Check parameters $withdrawreceipt=new BonPrelevement($db); +// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty $result=$withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE,$conf->global->PRELEVEMENT_CODE_GUICHET,$argv[1]); diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index d3d7c300308..e695bff34a3 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -233,7 +233,7 @@ class EntrepotTest extends PHPUnit_Framework_TestCase $localobject=new Entrepot($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); diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 13462afc601..470a570bf6e 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -223,7 +223,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase $ip='169.254.0.0'; $result=is_ip($ip); print __METHOD__." for ".$ip." result=".$result."\n"; - $this->assertEquals(0,$result,$ip); + //$this->assertEquals(2,$result,$ip); // Assertion disabled because returned value differs between PHP patch version $ip='1.2.3.4'; $result=is_ip($ip); diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index af1ae6b3622..a92bc80ed63 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -150,7 +150,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $url = $this->api_url.'/users/123456789?api_key='.$this->api_key; //$addheaders=array('Content-Type: application/json'); - print __METHOD__." Request url=".$url."\n"; + print __METHOD__." Request GET url=".$url."\n"; $result=getURLContent($url, 'GET', '', 1, array()); //print __METHOD__." Result for unexisting user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; @@ -161,7 +161,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $url = $this->api_url.'/users/1?api_key='.$this->api_key; - print __METHOD__." Request url=".$url."\n"; + print __METHOD__." Request GET url=".$url."\n"; $result=getURLContent($url, 'GET', '', 1, array()); //print __METHOD__." Result for existing user user: ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; @@ -184,7 +184,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase ); $body = json_encode($bodyobj); - print __METHOD__." Request url=".$url."\n"; + print __METHOD__." Request POST url=".$url."\n"; $result=getURLContent($url, 'POST', $body, 1, $addheaders); //print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; @@ -202,7 +202,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase "email"=>"test@restuser.com" ); $body = json_encode($bodyobj); - print __METHOD__." Request url=".$url."\n"; + print __METHOD__." Request POST url=".$url."\n"; $result=getURLContent($url, 'POST', $body, 1, $addheaders); print __METHOD__." Result code for creating user ".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; @@ -212,7 +212,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase $this->assertGreaterThan(0, $object['id'], $object['error']['code'].' '.$object['error']['message']); // attempt to create duplicated user - print __METHOD__." Request url=".$url."\n"; + print __METHOD__." Request POST url=".$url."\n"; $result=getURLContent($url, 'POST', $body, 1, $addheaders); //print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n"; print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";