diff --git a/.travis.yml b/.travis.yml index 26d4c64fef2..a4f8ecd8270 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ before_script: - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE myapp_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'DROP DATABASE IF EXISTS myapp_test;'; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS myapp_test;'; fi" - - sh -c "if [ '$DB' = 'mysql' ]; then mysql -D myapp_test < $(pwd)/dev/initdata/mysqldump_dolibarr_3.5.0.sql; fi" + - sh -c "if [ '$DB' = 'mysql' ]; then mysql -D myapp_test < $(pwd)/dev/initdata/mysqldump_dolibarr_3.4.0.sql; fi" - echo Create config file htdocs/conf/conf.php - echo ' htdocs/conf/conf.php - sh -c "if [ '$DB' = 'pgsql' ]; then echo '$'dolibarr_main_db_type=\'pgsql\'';' >> htdocs/conf/conf.php; fi" @@ -80,10 +80,18 @@ before_script: - sudo /etc/init.d/apache2 restart - wget http://localhost/ - cat index.html - + script: + - cd htdocs/install + - php upgrade.php 3.4.0 3.5.0 > upgrade.log + - php upgrade2.php 3.4.0 3.5.0 > upgrade2.log + - php upgrade.php 3.5.0 3.6.0 >> upgrade.log + - php upgrade2.php 3.5.0 3.6.0 >> upgrade2.log + - cd ../.. +# - cat upgrade.log +# - cat upgrade2.log # - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml --coverage-text test/phpunit/AllTests.php # - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml --coverage-text test/phpunit/BuildDocTest.php # - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/WebservicesOtherTest.php diff --git a/COPYRIGHT b/COPYRIGHT index db0cb532478..799e49cd60b 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -50,6 +50,9 @@ http://www.fsf.org/licensing/licenses/index_html Copyright --------- +Copyright (C) 2014 +- Marcos García + Copyright (C) 2013 - Christophe Battarel - Laurent Destailleur diff --git a/ChangeLog b/ChangeLog index 63c19ea52e6..ad9fd2c08f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,8 +7,14 @@ For users: - New: Add list of orders products in tab "consumption" on thirdparties. - New: Add graph stats for suppliers orders in tab "stats" on products. - New: Add option MAIN_HIDE_INACTIVETAB_ON_PRINT to hide inactive tabs when you - use the "print" view on screen. + use the "print" view on screen. - New: Add menu entry to barcode genration page. +- New: Add option MAIN_AUTO_TIMESTAMP_IN_NOTES to automatically add timestamp + and user line into editionf field when editing a note. +- New: Add button cancel into edition of notes. +- New: Improved Opensurvey module and added options to disable comments and disable + public votes +- New: The box "balance of bank accounts" show all opened accounts. For translators: - Update language files. @@ -17,7 +23,16 @@ For developers: - New: Add path file of trigger into admin trigger list page. - New: More phpunit tests. - New: Payments and supplier payment pages tabs can now be extended from modules. +- New: Add option 'aZ' into GETPOST function to check parameters contains + only a to z or A to Z characters. +- New: Opensurvey polls tab cards can now be extended from external modules. +- New: Triggers OPENSURVEY_CREATE, OPENSURVEY_DELETE +WARNING: Following change may create regression for some external modules, but was necessary to make +Dolibarr better: + +- The deprecated way (with 4 parameters) to declare a new tab into a module descriptor file has been +removed. You must now use the 6 parameters way. See file modMyModule.class.php for example. ***** ChangeLog for 3.5 compared to 3.4.* ***** @@ -153,56 +168,63 @@ parameter. All methods addline in this case were modified to remove this paramet +***** ChangeLog for 3.4.3 compared to 3.4.2 ***** +Fix: Bad get of localtaxes into contracts add lines + ***** ChangeLog for 3.4.2 compared to 3.4.1 ***** -Fix: field's problem into company's page (RIB) -Fix: Document cerfa doesn't contained firstname & lastname from donator +Fix: field's problem into company's page (RIB). +Fix: Document cerfa doesn't contained firstname & lastname from donator. Fix: Bad rounding on margin calculations and display. Fix: Option drop table into backup was broken. -Fix: [ bug #1105 ] Searching Boxes other search option -Fix: wrong buy price update -Fix: [ bug #1142 ] Set paiement on invoice (PGSql) -Fix: [ bug #1145 ] Agenda button list type do not display -Fix: [ bug #1148 ] Product consomation : supplier order bad status -Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists -Fix: [ bug #1174 ] Product translated description not good into PDF -Fix: [ bug #1163 ] SQL Error when searching for supplier orders -Fix: [ bug #1162 ] Translaction for morning and afternoon -Fix: [ bug #1161 ] Search on product label +Fix: [ bug #1105 ] Searching Boxes other search option. +Fix: wrong buy price update. +Fix: [ bug #1142 ] Set paiement on invoice (PGSql). +Fix: [ bug #1145 ] Agenda button list type do not display. +Fix: [ bug #1148 ] Product consomation : supplier order bad status. +Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists. +Fix: [ bug #1174 ] Product translated description not good into PDF. +Fix: [ bug #1163 ] SQL Error when searching for supplier orders. +Fix: [ bug #1162 ] Translaction for morning and afternoon. +Fix: [ bug #1161 ] Search on product label. Fix: [ bug #1075 ] POS module doesn't decrement stock of products in delayed payment mode. -Fix: [ bug #1171 ] Documents lost in interventions after validating -Fix: fix unsubscribe URL into mailing when sending manually (not by script) -Fix: [ bug #1182 ] ODT company_country tag is htmlencoded -Fix: [ bug #1196 ] Product barcode search does not expect 13th digit on EAN13 type -Fix: [ bug #1202 ] Wrong amount in deposit % invoice from proposal +Fix: [ bug #1171 ] Documents lost in interventions after validating. +Fix: fix unsubscribe URL into mailing when sending manually (not by script). +Fix: [ bug #1182 ] ODT company_country tag is htmlencoded. +Fix: [ bug #1196 ] Product barcode search does not expect 13th digit on EAN13 type. +Fix: [ bug #1202 ] Wrong amount in deposit % invoice from proposal. +Fix: Removed analytics tags into doc page. +Fix: Call Image on this instead of pdf. +Fix: Missing parameter for photo. +Fix: Bad SQL request for turnover report. ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** -Fix: Display buying price on line edit when no supplier price is defined -Fix: Retrieving of margin info when invoice created automatically from order -Fix: Reordering supplier products in list by supplier or supplier ref was crashing -Fix: [ bug #1029 ] Tulip numbering mask -Fix: Supplier invoice and supplier order are not displayed into object link into agenda event card -Fix: [ bug #1033 ] SUPPLIER REF disappeared -Fix: update extrafield do not display immediately after update -Fix: Fix bug with canvas thirdparty -Fix: [ bug #1037 ] Consumption> Supplier invoices related -Fix: User group name do not display in card (view or edit mode) -Fix: Link "Show all supplier invoice" on supplier card not working -Fix: [ bug #1039 ] Pre-defined invoices conversion -Fix: If only service module is activated, it's impossible to delete service -Fix: [ bug #1043 ] Bad interventions ref numbering -Fix: Mailing module : if an email is already in destinaires list all other email from selector was not inserted -Fix: Localtaxes balance not showing -Fix: Intervention box links to contracts id -Fix: Compatibility with multicompany module -Fix: Edit propal line was losing product supplier price id -Fix: Delete linked element to supplier invoice when deleted -Fix: [ bug #1061 ] Bad info shipped products -Fix: [ bug #1062 ] Documents lost in propals and contracts validating -Fix: Supplier price displayed on document lines and margin infos didnt take discount -Fix: sorting on qty did not work in supplier product list -Fix: there was no escaping on filter fields in supplier product list -Fix: bugs on margin reports and better margin calculation on credit notes -Qual: Add travis-ci integration +Fix: Display buying price on line edit when no supplier price is defined. +Fix: Retrieving of margin info when invoice created automatically from order. +Fix: Reordering supplier products in list by supplier or supplier ref was crashing. +Fix: [ bug #1029 ] Tulip numbering mask. +Fix: Supplier invoice and supplier order are not displayed into object link into agenda event card. +Fix: [ bug #1033 ] SUPPLIER REF disappeared. +Fix: update extrafield do not display immediatly after update. +Fix: Fix bug with canvas thirdparty. +Fix: [ bug #1037 ] Consumption> Supplier invoices related. +Fix: User group name do not display in card (view or edit mode). +Fix: Link "Show all supplier invoice" on suplier card not working. +Fix: [ bug #1039 ] Pre-defined invoices conversion. +Fix: If only service module is activated, it's impossible to delete service. +Fix: [ bug #1043 ] Bad interventions ref numbering. +Fix: Mailing module : if an email is already in destinaires list all other email from selector was not inserted. +Fix: Localtaxes balance not showing. +Fix: Intervention box links to contracts id. +Fix: Compatiblity with multicompany module. +Fix: Edit propal line was losing product supplier price id. +Fix: Delete linked element to supplier invoice when deleted. +Fix: [ bug #1061 ] Bad info shipped products. +Fix: [ bug #1062 ] Documents lost in propals and contracts validating. +Fix: Supplier price displayed on document lines and margin infos didnt take discount. +Fix: sorting on qty did not work in supplier product list. +Fix: there was no escaping on filter fields in supplier product list. +Fix: bugs on margin reports and better margin calculation on credit notes. +Qual: Add travis-ci integration. ***** ChangeLog for 3.4 compared to 3.3.* ***** For users: @@ -301,6 +323,7 @@ backport commit 384e3812eb73a15adafb472cacfb93397a54459b to fix W3C/edit contrac ***** ChangeLog for 3.3.5 compared to 3.3.4 ***** +- Fix: Change to make debian package ok despite removal of ckeditor. - Fix: jcrop file to match debian rules - Fix: Add missing country UK. - Fix: Minor fix into package. diff --git a/README.md b/README.md index bad4d47ffc2..574e74da85c 100644 --- a/README.md +++ b/README.md @@ -76,61 +76,63 @@ See ChangeLog file found into package. ### Main modules/features: -- Customers, Prospects or Suppliers directory -- Products and services catalog -- Bank accounts management -- Orders management -- Commercial proposals management -- Contracts management -- Invoices management -- Payments management -- Standing orders management -- Stock management -- Shipping management +- Customers, Prospects or Suppliers directory. +- Products and services catalog. +- Bank accounts management. +- Orders management. +- Commercial proposals management. +- Contracts management. +- Invoices management. +- Payments management. +- Standing orders management. +- Stock management. +- Shipping management. - PDF or ODT generation for invoice, proposals, orders... -- Agenda with ical,vcal export for third tools integration -- EDM (Electronic Document Management) -- Foundations members management -- Employee's holidays management -- Mass Emailing -- Realize surveys -- Point of Sale +- Agenda with ical,vcal export for third tools integration. +- EDM (Electronic Document Management). +- Foundations members management. +- Employee's holidays management. +- Mass Emailing. +- Realize surveys. +- Point of Sale. ### Other modules: -- Bookmarks management -- Donations management -- Reporting -- Data export/import -- LDAP connectivity -- Third parties or products categories -- ClickToDial integration -- RSS integration +- Bookmarks management. +- Donations management. +- Reporting. +- Data export/import. +- Third parties or products categories. +- LDAP connectivity. +- ClickToDial integration. +- RSS integration. +- Can be extended with a lot of other external modules available onto DoliStore.com. ### Miscellaneous: - Multi-user, with several permissions levels for each feature. -- Serveral 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 menu and permissions). - Very user friendly and easy to use. -- Optional WYSIWYG forms, optional Ajax forms. -- Several skins. -- Code is highly customizable (a lot of use of modules and submodules). -- Works with Mysql 4.1 or higher, or PostgreSql 8.14 or higher. -- Works with PHP 5.0 or higher. -- An easy to understand and maintain code (PHP with no heavy frameworks). -- A trigger architecture to allow you to make Dolibarr business events run PHP code to update your own information system. -- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM called "Non Perçue Récupérable"). - +- Highly customizable: Enable only modules you need, 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.2.1, MySql 4.1 or PostgreSQL 8.1. +- Compatible with all Cloud solutions that match MySql, PHP or PostgreSQL prerequisites. +- An easy to understand, maintain and code interfaces with your own system information (PHP with no heavy frameworks, trigger and hook architecture). +- Support countries specific features: + Spanish Tax RE and ISPF. + French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM). + Canadian double taxes (federal/province) and other countries using cumulative VAT. + Tunisian tax stamp. + Compatible with European directives (2006/112/CE ... 2010/45/UE) (http://europa.eu/legislation_summaries/taxation/l31057_en.htm) + ... ## WHAT DOLIBARR CAN'T DO YET (TODO LIST) This is features that Dolibarr does not support completely yet: -- No double party accountancy (only bank management). +- No double party accountancy (only bank and treasury management). - Dolibarr manage one currency at once (mono-currency). -- Dolibarr manage one master company/foundation (mono-company). If you want to manage several companies or foundations, you must install several time the software (on same server or not). Another solution is to extend Dolibarr with the addon Module MultiCompany that allows to manage several companies in one Dolibarr instance (one database but with a logical isolation of datas). -- Dolibarr does not contains Payroll module. +- Dolibarr manage one master activity (mono-company). If you want to manage several companies or foundations, you must install several time the software (on same server or not). Another solution is to extend Dolibarr with the addon Module MultiCompany that allows to manage several companies in one Dolibarr instance (one database but with a logical isolation of datas). - Tasks on module project can't have dependencies between each other. +- Dolibarr does not contains Payroll module. - Dolibarr does not include any Webmail. - Dolibarr can't do coffee (not yet). diff --git a/build/debian/README.howto b/build/debian/README.howto index cbd4e13f993..6adf020dbfd 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -120,8 +120,11 @@ Puis pour se connecter et préparer l'environnement > apt-get install links mysql-client Pour tester un package -> cp *.deb /srv/chroot/unstable/tmp +> cp ../build-area/* /srv/chroot/unstable/tmp > sudo schroot -c name_of_chroot +> cd /tmp +> lintian --pedantic -E -I dolibarr*.deb +> lintian --pedantic -E -I dolibarr*.dsc > dpkg -i dolibarr*.deb > apt-get install -f diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index deeb34caa66..224798a2fd2 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -134,6 +134,7 @@ class modMyModule extends DolibarrModules // 'payment' to add a tab in payment view // 'payment_supplier' to add a tab in supplier payment view // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'opensurveypoll' to add a tab in opensurvey poll view $this->tabs = array(); // Dictionnaries diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 7c3b1f6c479..03d40dbb085 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -158,7 +158,7 @@ foreach ($modulesdir as $dir) if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0; if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0; // We discard modules according to property disabled - if (isset($objMod->hidden) && $objMod->hidden) $modulequalified=false; + if (! empty($objMod->hidden)) $modulequalified=false; // Define array $categ with categ with at least one qualified module if ($modulequalified) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 5737b632b32..2ed50dc6f2a 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -26,8 +26,10 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; $langs->load("admin"); +$langs->load("members"); $langs->load("errors"); // Choix de l'annee d'impression ou annee courante. @@ -36,124 +38,166 @@ $year=dol_print_date($now,'%Y'); $month=dol_print_date($now,'%m'); $day=dol_print_date($now,'%d'); $forbarcode=GETPOST('forbarcode'); -$forbartype=GETPOST('forbartype'); +$fk_barcode_type=GETPOST('fk_barcode_type'); $mode=GETPOST('mode'); -$model=GETPOST("model"); // Doc template to use for business cards -$modellabel=GETPOST("modellabel"); // Doc template to use for address sheet +$modellabel=GETPOST("modellabel"); // Doc template to use +$numberofsticker=GETPOST('numberofsticker','int'); + $mesg=''; +$action=GETPOST('action'); + /* * Actions */ -if ($action == 'builddoc' && empty($forbarcode)) +if ($action == 'builddoc') { - $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Barcode")); -} -if ($action == 'builddoc' && empty($forbartype)) -{ - $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("BarcodeType")); -} + $result=0; $error=0; -if ((! empty($forbarcode) || ! empty($forbartype) || ! empty($mode)) && ! $mesg) -{ - // List of values to scan for a replacement - $substitutionarray = array ( - '%LOGIN%'=>$user->login, - '%COMPANY%'=>$mysoc->name, - '%ADDRESS%'=>$mysoc->address, - '%ZIP%'=>$mysoc->zip, - '%TOWN%'=>$mysoc->town, - '%COUNTRY%'=>$mysoc->country, - '%COUNTRY_CODE%'=>$mysoc->country_code, - '%EMAIL%'=>$mysoc->email, - '%YEAR%'=>$year, - '%MONTH%'=>$month, - '%DAY%'=>$day, - '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, - '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" - ); - complete_substitutions_array($substitutionarray, $langs); - - // For business cards - if (empty($mode) || $mode=='card' || $mode=='cardlogin') + if (empty($forbarcode)) // barcode value { - $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); - $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); - $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); - $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("BarcodeValue")),'errors'); + $error++; + } + if (empty($fk_barcode_type)) // barcode type = barcode encoding + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("BarcodeType")),'errors'); + $error++; + } - if (is_numeric($forbarcode) || $forbartype) + if (! $error) + { + // Get encoder (barcode_type_coder) from barcode type id (barcode_type) + $stdobject=new GenericObject($db); + $stdobject->barcode_type=$fk_barcode_type; + $result=$stdobject->fetch_barcode(); + if ($result <= 0) { - for($j=0;$j<100;$j++) + $error++; + setEventMessage('Failed to get bar code type information '.$stdobject->error, 'errors'); + } + } + + if (! $error) + { + $code=$forbarcode; + $generator=$stdobject->barcode_type_coder; + $encoding=strtoupper($stdobject->barcode_type_code); + $barcodeimage=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; + + $diroutput=$conf->barcode->dir_temp; + dol_mkdir($diroutput); + + // Generate barcode + $dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->modules_parts['barcode']); + + foreach($dirbarcode as $reldir) + { + $dir=dol_buildpath($reldir,0); + $newdir=dol_osencode($dir); + + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) + if (! is_dir($newdir)) continue; + + $result=@include_once $newdir.$generator.'.modules.php'; + if ($result) break; + } + + // Load barcode class + $classname = "mod".ucfirst($generator); + $module = new $classname($db); + if ($module->encodingIsSupported($encoding)) + { + dol_delete_file($barcodeimage); + // File is created with full name $barcodeimage = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png'; + $result=$module->writeBarCode($code,$encoding,'Y',4); + + if ($result <= 0 || ! dol_is_file($barcodeimage)) + { + $error++; + setEventMessage('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), 'errors'); + } + } + else + { + $error++; + setEventMessage("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, 'errors'); + } + } + + if (! $error) + { + // List of values to scan for a replacement + $substitutionarray = array ( + '%LOGIN%'=>$user->login, + '%COMPANY%'=>$mysoc->name, + '%ADDRESS%'=>$mysoc->address, + '%ZIP%'=>$mysoc->zip, + '%TOWN%'=>$mysoc->town, + '%COUNTRY%'=>$mysoc->country, + '%COUNTRY_CODE%'=>$mysoc->country_code, + '%EMAIL%'=>$mysoc->email, + '%YEAR%'=>$year, + '%MONTH%'=>$month, + '%DAY%'=>$day, + '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, + '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" + ); + complete_substitutions_array($substitutionarray, $langs); + + // For labels + if ($mode == 'label') + { + if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="%PHOTO%"; + $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); + $textheader=''; + $textfooter=''; + $textright=''; + $forceimgscalewidth=(empty($conf->global->BARCODE_FORCEIMGSCALEWIDTH)?1:$conf->global->BARCODE_FORCEIMGSCALEWIDTH); + $forceimgscaleheight=(empty($conf->global->BARCODE_FORCEIMGSCALEHEIGHT)?1:$conf->global->BARCODE_FORCEIMGSCALEHEIGHT); + + for ($i=0; $i < $numberofsticker; $i++) { $arrayofmembers[]=array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF ); } } - else + + $i++; + $mesg=''; + + // Build and output PDF + if ($mode == 'label') { - $arrayofmembers[]=array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo - ); + if (! count($arrayofmembers)) + { + $mesg=$langs->trans("ErrorRecordNotFound"); + } + if (empty($modellabel) || $modellabel == '-1') + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); + } + if (! $mesg) $result=members_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs, $diroutput); } - } - // For labels - if ($mode == 'label') - { - if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="%FULLNAME%\n%ADDRESS%\n%ZIP% %TOWN%\n%COUNTRY%"; - $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); - $textheader=''; - $textfooter=''; - $textright=''; - - $arrayofmembers[]=array('textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo); - } - - $i++; - - // Build and output PDF - if ($mode == 'label') - { - if (! count($arrayofmembers)) + if ($result <= 0) { - $mesg=$langs->trans("ErrorRecordNotFound"); + dol_print_error('',$result); } - if (empty($modellabel) || $modellabel == '-1') - { - $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); - } - if (! $mesg) $result=members_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); - } - if ($result <= 0) - { - dol_print_error('',$result); + if (! $mesg) + { + $db->close(); + exit; + } } - - if (! $mesg) - { - $db->close(); - exit; - } } @@ -168,16 +212,25 @@ llxHeader('',$langs->trans("BarCodePrintsheet")); print_fiche_titre($langs->trans("BarCodePrintsheet")); print '
'; -print $langs->trans("PageToGenerateBarCodeSheets").'
'; +print $langs->trans("PageToGenerateBarCodeSheets",$langs->transnoentitiesnoconv("BuildPageToPrint")).'
'; print '
'; dol_htmloutput_errors($mesg); -print img_picto('','puce').' '.$langs->trans("BarCodePrintsheet").' '; +//print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").'
'; +//print '
'; + print '
'; print ''; print ''; -print $langs->trans("DescADHERENT_ETIQUETTE_TYPE").' '; + +print '
'; + +// Sheet format +print '
'; +print '
'; +print $langs->trans("DescADHERENT_ETIQUETTE_TYPE").'   '; +print '
'; // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php) $arrayoflabels=array(); foreach(array_keys($_Avery_Labels) as $codecards) @@ -185,12 +238,64 @@ foreach(array_keys($_Avery_Labels) as $codecards) $arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name']; } print $form->selectarray('modellabel',$arrayoflabels,(GETPOST('modellabel')?GETPOST('modellabel'):$conf->global->ADHERENT_ETIQUETTE_TYPE),1,0,0); -print '
'.$langs->trans("Barcode").': '; -print '
'.$langs->trans("Bartype").': '; +print '
'; +// Number of stickers to print +print '
'; +print '
'; +print $langs->trans("NumberOfStickers").'   '; +print '
'; +print ''; +print '
'; + +print '
'; + + +print '
'; + +// Checkbox to select from free text +print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; +print '
'; + +/* +print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; +print $form->select_produits(GETPOST('productid'), 'productid', ''); +print '
'; + +print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; +print $form->select_company(GETPOST('socid'), 'socid', '', 1); +print '
'; +*/ + +print '
'; + +// Barcode type +print '
'; +print '
'; +print $langs->trans("BarcodeType").'   '; +print '
'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; +$formbarcode = new FormBarCode($db); +$formbarcode->select_barcode_type($fk_barcode_type, 'fk_barcode_type', 1); +print '
'; + +// Barcode value +print '
'; +print '
'; +print $langs->trans("BarcodeValue").'   '; +print '
'; +print ''; +print '
'; + +/* $barcodestickersmask=GETPOST('barcodestickersmask'); -print '
'.$langs->trans("BarcodeStickersMask").': '; -print '
'; +print '
'.$langs->trans("BarcodeStickersMask").':
'; +print ''; +print '
'; +*/ + +print '
'; + print ''; print '
'; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 4ab19b7f915..7a6e34ec346 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -499,7 +499,7 @@ class Categorie $column_name=$type; if ($type=='contact') $column_name='socpeople'; if ($type=='fournisseur') $column_name='societe'; - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type; $sql .= " WHERE fk_categorie = ".$this->id; $sql .= " AND fk_".$column_name." = ".$obj->id; @@ -528,16 +528,20 @@ class Categorie } /** - * Return list of contents of a category + * Return list of fetched instance of elements having this category * - * @param string $field Field name for select in table. Full field name will be fk_field. - * @param string $classname PHP Class of object to store entity - * @param string $category_table Table name for select in table. Full table name will be PREFIX_categorie_table. - * @param string $object_table Table name for select in table. Full table name will be PREFIX_table. - * @return void + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @return mixed -1 if KO, array of instance of object if OK */ - function get_type($field,$classname,$category_table='',$object_table='') + function getObjectsInCateg($type) { + $field=''; $classname=''; $category_table=''; $object_table=''; + if ($type=='product') { $field='product'; $classname='Product'; } + if ($type=='customer') { $field='societe'; $classname='Societe'; } + if ($type=='supplier') { $field='societe'; $classname='Fournisseur'; $category_table='fournisseur'; } + if ($type=='member') { $field='member'; $classname='Adherent'; $category_table=''; $object_table='adherent'; } + if ($type=='contact') { $field='socpeople'; $classname='Contact'; $category_table='contact'; $object_table='socpeople'; } + $objs = array(); // Clean parameters @@ -551,7 +555,7 @@ class Categorie $sql.= " AND c.fk_categorie = ".$this->id; $sql.= " AND c.fk_".$field." = o.rowid"; - dol_syslog(get_class($this)."::get_type sql=".$sql); + dol_syslog(get_class($this)."::getObjectsInCateg sql=".$sql); $resql = $this->db->query($sql); if ($resql) { @@ -566,7 +570,7 @@ class Categorie else { $this->error=$this->db->error().' sql='.$sql; - dol_syslog(get_class($this)."::get_type ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::getObjectsInCateg ".$this->error, LOG_ERR); return -1; } } @@ -583,7 +587,6 @@ class Categorie $sql.= " WHERE fk_parent = ".$this->id; $res = $this->db->query($sql); - if ($res) { $cats = array (); @@ -1054,23 +1057,24 @@ class Categorie } /** - * Return list of categories linked to element of id $id and type $typeid + * Return list of categories (id or instances) linked to element of id $id and type $type + * Should be named getListOfCategForObject * * @param int $id Id of element - * @param int $typeid Type of link (0 or 'product', 1 or 'supplier', 2 or 'customer', 3 or 'member', ...) - * @param string $mode 'object'=Get array of categories, 'label'=Get array of category labels + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. + * @param string $mode 'object'=Get array of fetched category instances, 'label'=Get array of category labels * @return mixed Array of category objects or < 0 if KO */ - function containing($id,$typeid,$mode='object') + function containing($id,$type,$mode='object') { $cats = array(); - $table=''; $type=''; - if ($typeid == 0 || $typeid == 'product') { $typeid=0; $table='product'; $type='product'; } - else if ($typeid == 1 || $typeid == 'supplier') { $typeid=1; $table='societe'; $type='fournisseur'; } - else if ($typeid == 2 || $typeid == 'customer') { $typeid=2; $table='societe'; $type='societe'; } - else if ($typeid == 3 || $typeid == 'member') { $typeid=3; $table='member'; $type='member'; } - else if ($typeid == 4 || $typeid == 'contact') { $typeid=4; $table='socpeople'; $type='contact'; } + $typeid=-1; $table='';; + if ($type == '0' || $type == 'product') { $typeid=0; $table='product'; $type='product'; } + else if ($type == '1' || $type == 'supplier') { $typeid=1; $table='societe'; $type='fournisseur'; } + else if ($type == '2' || $type == 'customer') { $typeid=2; $table='societe'; $type='societe'; } + else if ($type == '3' || $type == 'member') { $typeid=3; $table='member'; $type='member'; } + else if ($type == '4' || $type == 'contact') { $typeid=4; $table='socpeople'; $type='contact'; } $sql = "SELECT ct.fk_categorie, c.label"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct, ".MAIN_DB_PREFIX."categorie as c"; @@ -1110,7 +1114,7 @@ class Categorie * * @param int $id Id * @param string $nom Name - * @param string $type Type + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. * @param boolean $exact Exact string search (true/false) * @param boolean $case Case sensitive (true/false) * @return array Array of category id @@ -1119,9 +1123,16 @@ class Categorie { $cats = array(); + $typeid=-1; + if ($type == 0 || $type == 'product') { $typeid=0; } + else if ($type == 1 || $type == 'supplier') { $typeid=1; } + else if ($type == 2 || $type == 'customer') { $typeid=2; } + else if ($type == 3 || $type == 'member') { $typeid=3; } + else if ($type == 4 || $type == 'contact') { $typeid=4; } + // Generation requete recherche $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE type = ".$type." "; + $sql.= " WHERE type = ".$typeid; $sql.= " AND entity IN (".getEntity('category',1).")"; if ($nom) { diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 6316436f69a..53bd6179000 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -92,13 +92,13 @@ if ($id > 0 && $removeelem > 0) $elementtype = 'member'; } else if ($type == 4 && $user->rights->societe->creer) { - + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; } - + $result=$object->del_type($tmpobject,$elementtype); if ($result < 0) dol_print_error('',$object->error); } @@ -247,7 +247,7 @@ else if ($object->type == 0) { - $prods = $object->get_type("product","Product"); + $prods = $object->getObjectsInCateg("product"); if ($prods < 0) { dol_print_error(); @@ -297,7 +297,7 @@ if ($object->type == 0) if ($object->type == 1) { - $socs = $object->get_type("societe","Fournisseur","fournisseur"); + $socs = $object->getObjectsInCateg("supplier"); if ($socs < 0) { dol_print_error(); @@ -334,7 +334,7 @@ if ($object->type == 1) print $langs->trans("DeleteFromCat").""; } print ''; - + print "\n"; } } @@ -348,7 +348,7 @@ if ($object->type == 1) if($object->type == 2) { - $socs = $object->get_type("societe","Societe"); + $socs = $object->getObjectsInCateg("customer"); if ($socs < 0) { dol_print_error(); @@ -365,6 +365,8 @@ if($object->type == 2) $var=true; foreach ($socs as $key => $soc) { + if ($user->societe_id > 0 && $soc->id != $user->societe_id) continue; // External user always see only themself + $i++; $var=!$var; print "\t\n"; @@ -402,7 +404,7 @@ if ($object->type == 3) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $prods = $object->get_type("member","Adherent","","adherent"); + $prods = $object->getObjectsInCateg("member"); if ($prods < 0) { dol_print_error($db,$object->error); @@ -454,7 +456,7 @@ if ($object->type == 3) //Categorie contact if($object->type == 4) { - $contacts = $object->get_type("socpeople","Contact",'contact',"socpeople"); + $contacts = $object->getObjectsInCateg("contact"); if ($contacts < 0) { dol_print_error(); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index c97b841e3a1..f3b4f5e1d5e 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -312,11 +312,9 @@ $sql.= ' a.priority, a.fulldayevent, a.location,'; $sql.= ' a.fk_soc, a.fk_contact,'; $sql.= ' ca.code'; $sql.= ' FROM ('.MAIN_DB_PREFIX.'c_actioncomm as ca,'; -$sql.= " ".MAIN_DB_PREFIX.'user as u,'; $sql.= " ".MAIN_DB_PREFIX."actioncomm as a)"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= ' WHERE a.fk_action = ca.id'; -$sql.= ' AND a.fk_user_author = u.rowid'; $sql.= ' AND a.entity IN ('.getEntity().')'; if ($actioncode) $sql.=" AND ca.code='".$db->escape($actioncode)."'"; if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); @@ -325,28 +323,28 @@ if ($user->societe_id) $sql.= ' AND a.fk_soc = '.$user->societe_id; // To limit if ($action == 'show_day') { $sql.= " AND ("; - $sql.= " (datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; + $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; $sql.= " OR "; - $sql.= " (datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; + $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; $sql.= " OR "; - $sql.= " (datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; - $sql.= " AND datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; + $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,$day,$year))."'"; + $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,$day,$year))."')"; $sql.= ')'; } else { // To limit array $sql.= " AND ("; - $sql.= " (datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; // Start 7 days before + $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; // Start 7 days before $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; // End 7 days after + 3 to go from 28 to 31 $sql.= " OR "; - $sql.= " (datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; + $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; $sql.= " OR "; - $sql.= " (datep < '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; - $sql.= " AND datep2 > '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; + $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; + $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; $sql.= ')'; } if ($type) $sql.= " AND ca.id = ".$type; @@ -1012,7 +1010,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa // Must defined rule to choose color of who to use. // event->usertodo->id will still contains user id of owner // event->userstodo will be an array in future. - // $color=$user->color; + // $color=$user->color; } else if ($event->type_code == 'ICALEVENT') { diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 3510df7339e..dfd88d42cbd 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -71,6 +71,11 @@ $object->substitutionarray=array( '__UNSUBSCRIBE__' => 'TagUnsubscribe' //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet ); +if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) +{ + $object->substitutionarray['__SECUREKEYPAYPAL__']='SecureKeyPaypal'; + if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $object->substitutionarray['__SECUREKEYPAYPAL_MEMBER__']='SecureKeyPaypalUniquePerMember'; +} $object->substitutionarrayfortest=array( '__ID__' => 'TESTIdRecord', @@ -86,7 +91,7 @@ $object->substitutionarrayfortest=array( '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''), '__CHECK_READ__' => 'TagCheckMail', '__UNSUBSCRIBE__' => 'TagUnsubscribe' -//,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet + //,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet ); @@ -222,7 +227,12 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes') '__OTHER4__' => $other4, '__OTHER5__' => $other5 ); - + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); + } $substitutionisok=true; complete_substitutions_array($substitutionarray, $langs); $newsubject=make_substitutions($subject,$substitutionarray); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index ef37fa534bd..a4767f26ed1 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -96,6 +96,7 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('propalcard')); +$permissionnote=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php /* @@ -105,6 +106,9 @@ $hookmanager->initHooks(array('propalcard')); $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { @@ -232,18 +236,6 @@ else if ($action == 'set_ref_client' && $user->rights->propal->creer) $object->set_ref_client($user, $_POST['ref_client']); } -else if ($action == 'setnote_public' && $user->rights->propal->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->propal->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - // Create proposal else if ($action == 'add' && $user->rights->propal->creer) { diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 2855a296010..7e31518d402 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -44,23 +44,15 @@ $result = restrictedArea($user, 'propale', $id, 'propal'); $object = new Propal($db); + /******************************************************************************/ /* Actions */ /******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} +$permission=$user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -else if ($action == 'setnote_private' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} /******************************************************************************/ diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index d40d8bf5a7c..f326cf33b8f 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -93,14 +93,18 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ordercard')); +$permissionnote=$user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ + +/* + * Actions + */ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) { @@ -552,18 +556,6 @@ else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); } -else if ($action == 'setnote_public' && $user->rights->commande->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->commande->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - // Add a new line else if ($action == 'addline' && $user->rights->commande->creer) { diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 58023beec33..9d740dc1089 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -50,24 +50,15 @@ if (! $object->fetch($id, $ref) > 0) dol_print_error($db); } +$permissionnote=$user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions */ -if ($action == 'setnote_public' && $user->rights->commande->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -else if ($action == 'setnote_private' && $user->rights->commande->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} /* * View diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index a7b51fb5fb0..45d242bd4e5 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -52,7 +52,9 @@ $startyear=$year-1; $endyear=$year; $langs->load('orders'); +$langs->load('companies'); $langs->load('other'); +$langs->load('suppliers'); /* diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 66644cde848..b5ff84546fd 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -27,8 +27,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** - * \class Deplacement - * \brief Class to manage trips and working credit notes + * Class to manage trips and working credit notes */ class Deplacement extends CommonObject { @@ -65,6 +64,9 @@ class Deplacement extends CommonObject { $this->db = $db; + $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Closed'); + $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Closed'); + return 1; } @@ -327,7 +329,6 @@ class Deplacement extends CommonObject } if ($mode == 4) { - //if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); } diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 808d9163222..6d5f08873e3 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -51,10 +51,15 @@ $object = new Deplacement($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('tripsandexpensescard')); +$permissionnote=$user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions -*/ + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + if ($action == 'validate' && $user->rights->deplacement->creer) { $object->fetch($id); @@ -231,23 +236,11 @@ else if ($action == 'setkm' && $user->rights->deplacement->creer) $result=$object->setValueFrom('km',GETPOST('km','int')); if ($result < 0) dol_print_error($db, $object->error); } -else if ($action == 'setnote_public' && $user->rights->deplacement->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db, $object->error); -} -else if ($action == 'setnote_private' && $user->rights->deplacement->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db, $object->error); -} /* * View -*/ + */ llxHeader(); @@ -301,7 +294,7 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePublic').''; print ''; - + $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), 600, 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100); print $doleditor->Create(1); @@ -313,7 +306,7 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePrivate').''; print ''; - + $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), 600, 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, 100); print $doleditor->Create(1); @@ -400,7 +393,7 @@ else if ($id) $doleditor = new DolEditor('note_public', $object->note_public, 600, 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '100'); print $doleditor->Create(1); - + print ""; // Private note @@ -437,7 +430,7 @@ else if ($id) if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete"); - + } $soc = new Societe($db); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 044cc203cf8..d059e47d555 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -100,6 +100,8 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('invoicecard')); +$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions @@ -108,6 +110,8 @@ $hookmanager->initHooks(array('invoicecard')); $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) @@ -367,20 +371,6 @@ else if ($action == 'set_ref_client' && $user->rights->facture->creer) $object->set_ref_client($_POST['ref_client']); } -else if ($action == 'setnote_public' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - // Classify to validated else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) { diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 6092ba39e85..001473b0568 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -45,29 +45,20 @@ $result=restrictedArea($user,'facture',$id,''); $object = new Facture($db); $object->fetch($id); - -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ - -if ($action == 'setnote_public' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Affichage fiche */ -/******************************************************************************/ +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + + +/* + * View + */ llxHeader(); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 95ca831c37c..e24ca5dd56b 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2013 Antoine Iauch + * Copyright (C) 2013 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 @@ -173,23 +174,21 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl // SQL request $catotal=0; -if ($modecompta == 'CREANCES-DETTES') { +if ($modecompta == 'CREANCES-DETTES') +{ $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label,"; $sql.= " sum(l.total_ht) as amount, sum(l.total_ttc) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= " JOIN ".MAIN_DB_PREFIX."facturedet as l"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON l.fk_facture = f.rowid"; - if ($selected_cat === -2) { - $sql.=" LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; - } - if ($selected_cat && $selected_cat !== -2) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = " . $selected_cat; - if ($subcat) { - $sql.=" OR c.fk_parent = " . $selected_cat; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l, ".MAIN_DB_PREFIX."product as p"; + if ($selected_cat === -2) // Without any category + { + $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; + } + else if ($selected_cat) // Into a specific category + { + $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; } - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_categorie = c.rowid"; - } $sql.= " WHERE l.fk_product = p.rowid"; + $sql.= " AND l.fk_facture = f.rowid"; $sql.= " AND f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql.= " AND f.type IN (0,1,2)"; @@ -199,16 +198,21 @@ if ($modecompta == 'CREANCES-DETTES') { if ($date_start && $date_end) { $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } - if ($selected_cat === -2) { - $sql.=" AND cp.fk_product is null"; - } - if ($selected_cat && $selected_cat !== -2) { - $sql.= " AND cp.fk_product = p.rowid"; - } + if ($selected_cat === -2) // Without any category + { + $sql.=" AND cp.fk_product is null"; + } + else if ($selected_cat) { // Into a specific category + $sql.= " AND (c.rowid = ".$selected_cat; + if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat; + $sql.= ")"; + $sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; + } $sql.= " AND f.entity = ".$conf->entity; - $sql.= " GROUP BY p.rowid "; - $sql.= "ORDER BY p.ref "; + $sql.= " GROUP BY p.rowid"; + $sql.= " ORDER BY p.ref"; + dol_syslog("cabyprodserv sql=".$sql); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -384,7 +388,10 @@ if ($modecompta == 'CREANCES-DETTES') { print ''; } else { // $modecompta != 'CREANCES-DETTES' - print '
'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant") . '
'; + // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an + // invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ? + // Because there is no way to know this, this report is not relevant. + print '
'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant") . '
'; } llxFooter(); diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index f154b2a69f6..97333f1758c 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2013 Antoine Iauch @@ -180,17 +180,14 @@ $catotal=0; if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name,"; $sql.= " sum(f.total) as amount, sum(f.total_ttc) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " JOIN ".MAIN_DB_PREFIX."facture as f"; - if ($selected_cat === -2) { + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + if ($selected_cat === -2) // Without any category + { $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe"; } - if ($selected_cat && $selected_cat !== -2) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = ".$selected_cat; - if ($subcat) { - $sql.=" OR c.fk_parent = " . $selected_cat; - } - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON cs.fk_categorie = c.rowid"; + else if ($selected_cat) // Into a specific category + { + $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; } $sql.= " WHERE f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { @@ -202,28 +199,50 @@ if ($modecompta == 'CREANCES-DETTES') { if ($date_start && $date_end) { $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } - if ($selected_cat === -2) { + if ($selected_cat === -2) // Without any category + { $sql.=" AND cs.fk_societe is null"; } - if ($selected_cat && $selected_cat !== -2) { - $sql.= " AND cs.fk_societe = s.rowid"; + else if ($selected_cat) { // Into a specific category + $sql.= " AND (c.rowid = ".$selected_cat; + if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat; + $sql.= ")"; + $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_societe = s.rowid"; } - } else { +} else { /* * 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 .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; - $sql .= " WHERE p.rowid = pf.fk_paiement"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if ($selected_cat === -2) // Without any category + { + $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_societe"; + } + else if ($selected_cat) // Into a specific category + { + $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs"; + } + $sql.= " WHERE p.rowid = pf.fk_paiement"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.fk_soc = s.rowid"; if ($date_start && $date_end) { $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } + if ($selected_cat === -2) // Without any category + { + $sql.=" AND cs.fk_societe is null"; + } + else if ($selected_cat) { // Into a specific category + $sql.= " AND (c.rowid = ".$selected_cat; + if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat; + $sql.= ")"; + $sql.= " AND cs.fk_categorie = c.rowid AND cs.fk_societe = s.rowid"; + } } $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; @@ -231,6 +250,7 @@ $sql.= " GROUP BY s.rowid, s.nom"; $sql.= " ORDER BY s.rowid"; //echo $sql; +dol_syslog("casoc sql=".$sql); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -251,7 +271,7 @@ if ($result) { // On ajoute les paiements anciennes version, non lies par paiement_facture if ($modecompta != 'CREANCES-DETTES') { - $sql = "SELECT '0' as socid, 'Autres' as name, sum(DISTINCT p.amount) as amount_ttc"; + $sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p"; @@ -483,4 +503,4 @@ print ''; llxFooter(); $db->close(); -?> \ No newline at end of file +?> diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 27a56b48825..4adb109b89f 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -41,26 +41,15 @@ $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Contact($db); if ($id > 0) $object->fetch($id); +$permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php + + /* * Actions */ -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) setEventMessage($object->error,'errors'); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -else if ($action == 'setnote_private' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) setEventMessage($object->error,'errors'); -} /* * View @@ -91,16 +80,16 @@ if ($id > 0) print ''; $linkback = ''.$langs->trans("BackToList").''; - + // Ref print ''; - + // Name print ''; print ''; - + // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { @@ -108,10 +97,10 @@ if ($id > 0) { $objsoc = new Societe($db); $objsoc->fetch($object->socid); - + print ''; } - + else { print ''; } } - + // Civility print ''; - + // Date To Birth print ''; if (! empty($object->birthday)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - + print '"; } print ""; - + print "
'.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback); print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; @@ -119,20 +108,20 @@ if ($id > 0) print '
'.$langs->trans("UserTitle").''; print $object->getCivilityLabel(); print '
'.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); - + print '   '; //var_dump($birthdatearray); $ageyear=convertSecondToTime($now-$object->birthday,'year')-1970; @@ -140,8 +129,8 @@ if ($id > 0) if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; - - + + print '   -   '; if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); else print $langs->trans("BirthdayAlertOff"); @@ -152,7 +141,7 @@ if ($id > 0) print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown")."
"; print '
'; diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index f045fb30cc3..ca87d798507 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -3,8 +3,8 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2012 Juanjo Menent - * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -66,11 +66,15 @@ $hookmanager->initHooks(array('contractcard')); $object = new Contrat($db); +$permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once + if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { $object->fetch($id); @@ -448,8 +452,8 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $desc=$product_desc; } - $localtax1_tx=get_localtax($tva_tx,1,$object->societe); - $localtax2_tx=get_localtax($tva_tx,2,$object->societe); + $localtax1_tx=get_localtax($tva_tx,1,$object->thirdparty); + $localtax2_tx=get_localtax($tva_tx,2,$object->thirdparty); // ajout prix achat $fk_fournprice = $_POST['fournprice']; @@ -669,18 +673,6 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra } } -else if ($action == 'setnote_public' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { if ($action == 'addcontact') diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index e2bac1c6016..05c4608da8a 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -43,28 +43,20 @@ $result=restrictedArea($user,'contrat',$id); $object = new Contrat($db); $object->fetch($id,$ref); +$permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_public')), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} +/* + * Actions + */ -else if ($action == 'setnote_private' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_private')), ENT_QUOTES),'_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -/******************************************************************************/ -/* Affichage fiche */ -/******************************************************************************/ +/* + * View + */ llxHeader(); diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php new file mode 100644 index 00000000000..3b2bbef75bb --- /dev/null +++ b/htdocs/core/actions_setnotes.inc.php @@ -0,0 +1,47 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/actions_setnotes.inc.php + * \brief Code for actions on setting notes of object page + */ + + +// $action must be defined +// $permission must be defined to permission to edit object +// $object must be defined (object is loaded in this file with fetch) +// $id must be defined (object is loaded in this file with fetch) + +// Set public note +if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel')) +{ + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); + if ($result < 0) setEventMessage($object->error,'errors'); +} +// Set public note +else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel')) +{ + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); + if ($result < 0) setEventMessage($object->error,'errors'); +} + +?> \ No newline at end of file diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 2389a681000..e2ad29b8562 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -213,30 +213,42 @@ if ($type == 'directory') $textifempty = $langs->trans('NoFileFound'); } else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); - + $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname,'',$url); } } -if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) + +if ($section) { - if ($section) - { - $param.=($param?'?':'').(preg_replace('/^&/','',$param)); + $useajax=1; + if (! empty($conf->dol_use_jmobile)) $useajax=0; + if (empty($conf->use_javascript_ajax)) $useajax=0; + if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $useglobalvars=1; - $form = new Form($db); - $formquestion=array('urlfile'=>array('type'=>'hidden','value'=>'','name'=>'urlfile')); - print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",'deletefile'); + $param.=($param?'?':'').(preg_replace('/^&/','',$param)); - // Enable jquery handlers on new generated HTML objects - print ''."\n"; - } + if ($useajax || $action == 'delete') + { + $urlfile=''; + if ($action == 'delete') $urlfile=GETPOST('urlfile'); + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + $useglobalvars=1; + $form = new Form($db); + $formquestion=array('urlfile'=>array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile')); + print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0)); + } + + if ($useajax) + { + // Enable jquery handlers on new generated HTML objects + print ''."\n"; + } } // Close db if mode is not noajax diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 9b80ffefb74..17fd2a63fed 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -85,7 +85,7 @@ class box_comptes extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE entity = ".$conf->entity; $sql.= " AND clos = 0"; - $sql.= " AND courant = 1"; + //$sql.= " AND courant = 1"; $sql.= " ORDER BY label"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 86d924b5fa2..ee5ab2cbae9 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -170,7 +170,8 @@ abstract class CommonDocGenerator 'company_idprof4'=>$object->idprof4, 'company_idprof5'=>$object->idprof5, 'company_idprof6'=>$object->idprof6, - 'company_note'=>$object->note + 'company_note_public'=>$object->note_public, + 'company_note_private'=>$object->note_private ); // Retrieve extrafields @@ -260,7 +261,7 @@ abstract class CommonDocGenerator $array_key.'_total_localtax2'=>price2num($object->total_localtax2), $array_key.'_total_ttc'=>price2num($object->total_ttc), $array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()), - + $array_key.'_vatrate'=>vatrate($object->tva), $array_key.'_note_private'=>$object->note, $array_key.'_note'=>$object->note_public, @@ -314,7 +315,7 @@ abstract class CommonDocGenerator 'line_date_end'=>$line->date_end ); } - + /** * Define array with couple substitution key => substitution value * diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 2ed38d94e4a..903694128f9 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -156,15 +156,19 @@ class Conf if ($value && preg_match('/^MAIN_MODULE_/',$key)) { - // If this is constant for a new tab page activated by a module. + // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs']. if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i',$key)) { $partname = 'tabs'; $params=explode(':',$value,2); if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } - $this->modules_parts[$partname][$params[0]][]=$value; + $this->modules_parts[$partname][$params[0]][]=$value; // $value may be a string or an array } - // If this is constant for all generic part activated by a module + // If this is constant for all generic part activated by a module. It initializes + // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'], + // modules_parts['models'], modules_parts['theme'] + // modules_parts['sms'], + // modules_parts['css'], ... elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i',$key,$reg)) { $modulename = strtolower($reg[1]); @@ -176,7 +180,7 @@ class Conf else if (in_array($partname,array('models','theme'))) $value = '/'.$modulename.'/'; else if (in_array($partname,array('sms'))) $value = $modulename; else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe - $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); + $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array } // If this is a module constant (must be at end) elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i',$key,$reg)) @@ -403,7 +407,7 @@ class Conf $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024); // Define list of limited modules - if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,facture,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda'; // '' 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,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda'; // '' means 'all'. Note that contact is added here as it should be a module later. // Timeouts if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 39916775507..130c8b24d38 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -670,7 +670,14 @@ class ExtraFields } elseif ($type == 'select') { - $out=''; foreach ($param['options'] as $key=>$val ) { list($val, $parent) = explode('|', $val); @@ -683,7 +690,14 @@ class ExtraFields } elseif ($type == 'sellist') { - $out=''; if (is_array($param['options'])) { $param_list=array_keys($param['options']); @@ -753,6 +767,7 @@ class ExtraFields $fields_label = explode('|',$InfoFieldList[1]); if(is_array($fields_label)) { + $notrans = true; foreach ($fields_label as $field_toshow) { $labeltoshow.= $obj->$field_toshow.' '; @@ -778,12 +793,15 @@ class ExtraFields } else { - $translabel=$langs->trans($obj->$InfoFieldList[1]); - if ($translabel!=$obj->$InfoFieldList[1]) { - $labeltoshow=dol_trunc($translabel,18); - } - else { - $labeltoshow=dol_trunc($obj->$InfoFieldList[1],18); + if(!$notrans) + { + $translabel=$langs->trans($obj->$InfoFieldList[1]); + if ($translabel!=$obj->$InfoFieldList[1]) { + $labeltoshow=dol_trunc($translabel,18); + } + else { + $labeltoshow=dol_trunc($obj->$InfoFieldList[1],18); + } } if (empty($labeltoshow)) $labeltoshow='(not defined)'; if ($value==$obj->rowid) @@ -954,11 +972,11 @@ class ExtraFields { foreach ($fields_label as $field_toshow) { - $translabel=$langs->trans($obj->$InfoFieldList[1]); - if ($translabel!=$obj->$InfoFieldList[1]) { - $value=dol_trunc($translabel,18).' '; + $translabel=$langs->trans($field_toshow); + if ($translabel!=$field_toshow) { + $value.=dol_trunc($translabel,18).' '; }else { - $value=$obj->$InfoFieldList[1].' '; + $value.=$obj->$field_toshow.' '; } } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8c1c4ac7987..ba76f142534 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -122,7 +122,7 @@ class Form * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter * @param string $typeofdata Type of data ('string' by default, 'amount', 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select:xxx'...) - * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value) + * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value). Use '' to use same than $value * @param object $extObject External object * @param string $success Success message * @param string $moreparam More param to add on a href URL @@ -189,7 +189,13 @@ class Form $ret.=$doleditor->Create(1); } $ret.=''; - if ($typeofdata != 'day' && $typeofdata != 'datepicker' && $typeofdata != 'datehourpicker') $ret.=''; + if ($typeofdata != 'day' && $typeofdata != 'datepicker' && $typeofdata != 'datehourpicker') + { + $ret.=''; + $ret.='

'."\n"; + $ret.=''; + $ret.=''; + } $ret.=''."\n"; $ret.=''."\n"; } @@ -2525,6 +2531,19 @@ class Form if (is_array($formquestion) && ! empty($formquestion)) { + // First add hidden fields and value + foreach ($formquestion as $key => $input) + { + if (is_array($input) && ! empty($input)) + { + if ($input['type'] == 'hidden') + { + $more.=''."\n"; + } + } + } + + // Now add questions $more.=''."\n"; $more.=''."\n"; foreach ($formquestion as $key => $input) @@ -2584,10 +2603,6 @@ class Form $more.=$input['value']; $more.=''."\n"; } - else if ($input['type'] == 'hidden') - { - $more.=''; - } } } $more.='
'.(! empty($formquestion['text'])?$formquestion['text']:'').'
'."\n"; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 0559c7b56da..9c0968436d3 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -813,7 +813,12 @@ class FormFile else $filepath=$file['name']; */ - print ''.img_delete().''; + $useajax=1; + if (! empty($conf->dol_use_jmobile)) $useajax=0; + if (empty($conf->use_javascript_ajax)) $useajax=0; + if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; + + print ''.img_delete().''; } else print ' '; print ""; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 070019a50de..1437d5d9974 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -557,18 +557,17 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); print_fiche_titre($title,$buttoncreate,''); - print "\n".''."\n"; - - - $param="socid=".$object->id; - if ($search_status != '') $param.='&search_status='.$search_status; - if ($search_name != '') $param.='&search_name='.urlencode($search_name); - print ''; print ''; print ''; print ''; + print "\n".'
'."\n"; + + $param="socid=".$object->id; + if ($search_status != '') $param.='&search_status='.$search_status; + if ($search_name != '') $param.='&search_name='.urlencode($search_name); + $colspan=9; print ''; print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"p.lastname","",$param,'',$sortfield,$sortorder); @@ -579,14 +578,14 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"p.email","",$param,'',$sortfield,$sortorder); if (! empty($conf->skype->enabled)) { - $colspan++; - print ''; + $colspan++; + print ''; } print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"p.statut","",$param,'',$sortfield,$sortorder); // Copy to clipboard print ""; // Add to agenda - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (! empty($conf->agenda->enabled) && ! empty($user->rights->agenda->myactions->create)) { $colspan++; print ''; @@ -602,7 +601,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print ''; print ''; - print ''; + print ''; print ''; @@ -611,12 +610,12 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print ''; if (! empty($conf->skype->enabled)) { - $colspan++; - print ''; + $colspan++; + print ''; } - + // Status - print ''; @@ -769,6 +768,8 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') } print "\n
'.$langs->trans("Skype").''.$langs->trans("Skype").'         '; + print ''; print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); print '
\n"; + print ''."\n"; + print "
\n"; ?> "; } } // Form to add comment -print '
' .$langs->trans("AddACommentForPoll") . "
\n"; +if ($object->allow_comments) { + print '
' .$langs->trans("AddACommentForPoll") . "
\n"; -print '
'."\n"; -print $langs->trans("Name") .' : '; -print '   '."\n"; -print '
'."\n"; -print ''."\n"; + print '
'."\n"; + print $langs->trans("Name") .': '; + print '   '."\n"; + print '
'."\n"; + print ''."\n"; -print '
'."\n"; // div add comment + print '
'."\n"; // div add comment +} print '

'; -/* -// Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - -$message=''; -$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/studs.php',1).'?sondage='.$numsondage; -$urlvcal=''.$url.''; -$message.=img_picto('','object_globe.png').' '.$langs->trans("UrlForSurvey").': '.$urlvcal; - -print '
'.$message.'
'; -*/ - - print ''."\n"; llxFooterSurvey(); diff --git a/htdocs/opensurvey/adminstuds_preview.php b/htdocs/opensurvey/results.php similarity index 80% rename from htdocs/opensurvey/adminstuds_preview.php rename to htdocs/opensurvey/results.php index 62fbadda1ac..365ea3cd9e3 100644 --- a/htdocs/opensurvey/adminstuds_preview.php +++ b/htdocs/opensurvey/results.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +17,7 @@ */ /** - * \file htdocs/opensurvey/adminstuds_preview.php + * \file htdocs/opensurvey/results.php * \ingroup opensurvey * \brief Page to preview votes of a survey */ @@ -30,13 +31,12 @@ require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); // Security check -if (!$user->admin) accessforbidden(); +if (!$user->rights->opensurvey->read) accessforbidden(); // Init vars $action=GETPOST('action'); -$numsondageadmin=GETPOST("sondage"); -$numsondage=substr($numsondageadmin, 0, 16); +$numsondage= GETPOST("id"); $object=new Opensurveysondage($db); $result=$object->fetch(0,$numsondage); @@ -49,10 +49,16 @@ $nblignes=count($object->fetch_lines()); * Actions */ +//Return to the results +if (GETPOST('retoursondage')) { + header('Location: results.php?id='.$_GET['id']); + die; +} + $nbcolonnes = substr_count($object->sujet, ',') + 1; // Add vote -if (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"])) +if (isset($_POST["boutonp"])) { if (GETPOST('nom')) { @@ -119,7 +125,10 @@ for ($i=0; $i<$nblignes; $i++) } if ($testmodifier) { - //var_dump($_POST);exit; + + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + $nouveauchoix = ''; for ($i = 0; $i < $nbcolonnes; $i++) { @@ -148,8 +157,11 @@ if ($testmodifier) } // Add column (not for date) -if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && ($object->format == "A" || $object->format == "A+")) +if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && ($object->format == "A")) { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + $nouveauxsujets=$object->sujet; //on rajoute la valeur a la fin de tous les sujets deja entrés @@ -163,11 +175,17 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && ($object->format dol_syslog("sql=".$sql); $resql = $db->query($sql); if (! $resql) dol_print_error($db); + else { + header('Location: results.php?id='.$object->id_sondage); + } } // Add column (with format date) -if (isset($_POST["ajoutercolonne"]) && ($object->format == "D" || $object->format == "D+")) +if (isset($_POST["ajoutercolonne"]) && ($object->format == "D")) { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + $nouveauxsujets=$object->sujet; if (isset($_POST["nouveaujour"]) && $_POST["nouveaujour"] != "vide" && @@ -242,16 +260,8 @@ if (isset($_POST["ajoutercolonne"]) && ($object->format == "D" || $object->forma dol_syslog("sql=".$sql); $resql = $db->query($sql); if (! $resql) dol_print_error($db); - - if ($nouvelledate > strtotime($object->date_fin)) - { - $date_fin=$nouvelledate+200000; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'opensurvey_sondage'; - $sql.= " SET date_fin = '".$db->escape($date_fin)."'"; - $sql.= " WHERE id_sondage = '".$db->escape($numsondage)."'"; - dol_syslog("sql=".$sql); - $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + else { + header('Location: results.php?id='.$object->id_sondage); } } @@ -266,8 +276,11 @@ if (isset($_POST["ajoutercolonne"]) && ($object->format == "D" || $object->forma // Delete line for ($i = 0; $i < $nblignes; $i++) { - if (isset($_POST["effaceligne$i"]) || isset($_POST['effaceligne'.$i.'_x'])) + if (isset($_POST["effaceligne$i"])) { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + $compteur=0; // Loop on each answer @@ -298,8 +311,11 @@ for ($i = 0; $i < $nblignes; $i++) // Delete column for ($i = 0; $i < $nbcolonnes; $i++) { - if ((isset($_POST["effacecolonne$i"]) || isset($_POST['effacecolonne'.$i.'_x'])) && $nbcolonnes > 1) + if (isset($_POST["effacecolonne$i"]) && $nbcolonnes > 1) { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + $db->begin(); $toutsujet = explode(",",$object->sujet); @@ -382,8 +398,7 @@ $form=new Form($db); $result=$object->fetch(0,$numsondage); if ($result <= 0) { - print $langs->trans("ErrorRecordNotFound"); - llxFooter(); + dol_print_error($db,$object->error); exit; } @@ -404,19 +419,9 @@ $toutsujet=str_replace("@","
",$toutsujet); $toutsujet=str_replace("°","'",$toutsujet); -print '
'."\n"; +print ''."\n"; -$head = array(); - -$head[0][0] = 'adminstuds.php?sondage='.$object->id_sondage_admin; -$head[0][1] = $langs->trans("Card"); -$head[0][2] = 'general'; -$h++; - -$head[1][0] = 'adminstuds_preview.php?sondage='.$object->id_sondage_admin; -$head[1][1] = $langs->trans("SurveyResults").'/'.$langs->trans("Preview"); -$head[1][2] = 'preview'; -$h++; +$head = opensurvey_prepare_head($object); print dol_get_fiche_head($head,'preview',$langs->trans("Survey"),0,dol_buildpath('/opensurvey/img/object_opensurvey.png',1),1); @@ -428,12 +433,12 @@ $linkback = ''.$langs->trans('Ref').''; print ''; -print $form->showrefnav($object, 'sondage', $linkback, 1, 'id_sondage_admin', 'id_sondage_admin'); +print $form->showrefnav($object, 'sondage', $linkback, 1, 'id_sondage', 'id_sondage'); print ''; print ''; // Type -$type=($object->format=="A"||$object->format=="A+")?'classic':'date'; +$type=($object->format=="A")?'classic':'date'; print ''.$langs->trans("Type").''; print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1); print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate").''; @@ -459,42 +464,42 @@ print ''."\n"; print '
'; - -showlogo(); - - // Add form to add a field if (GETPOST('ajoutsujet')) { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + //on recupere les données et les sujets du sondage - print '
'."\n"; - print ''; + print ''."\n"; print ''; print '
'."\n"; print "

"."\n"; // Add new column - if ($object->format=="A"||$object->format=="A+") + if ($object->format=="A") { - print $langs->trans("AddNewColumn") .' :

'; + print $langs->trans("AddNewColumn") .':

'; print $langs->trans("Title").'
'; $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList")); print $langs->trans("Type").' '.$form->selectarray("typecolonne", $tmparray, GETPOST('typecolonne')).'

'; print ''; print '     '; - print ''; + print ''; print '

'."\n"; } else { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + + $formother=new FormOther($db); //ajout d'une date avec creneau horaire - //print _("You can add a new scheduling date to your poll.
If you just want to add a new hour to an existant date, put the same date and choose a new hour.") .'

'."\n"; - print $langs->trans("AddADate") .' :

'."\n"; + print $langs->trans("AddADate") .':

'."\n"; print ''."\n"; - print ''."\n"; + print $formother->select_month('', 'nouveaumois', 1); + + print ' '; + + print $formother->select_year('', 'nouvelleannee', 1, 0, 5, 0, 1); - - print ''."\n"; - print '

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

'."\n"; + print '

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

'."\n"; print ''."\n"; - print '

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

'."\n"; + print '

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

'."\n"; print ''; +print ''."\n"; print '
'."\n"; -print '
'."\n"; // Start to show survey result print ''."\n"; @@ -604,15 +577,18 @@ print ''."\n"; print ''."\n"; //boucle pour l'affichage des boutons de suppression de colonne -for ($i = 0; isset($toutsujet[$i]); $i++) { - print ''."\n"; +if ($user->rights->opensurvey->write) { + for ($i = 0; isset($toutsujet[$i]); $i++) { + + print ''."\n"; + } } print ''."\n"; // Show choice titles -if ($object->format=="D"||$object->format=="D+") +if ($object->format=="D") { //affichage des sujets du sondage print ''."\n"; @@ -644,7 +620,11 @@ if ($object->format=="D"||$object->format=="D+") } } - print ''."\n"; + if ($user->rights->opensurvey->write) { + print ''."\n"; + } + print ''."\n"; print ''."\n"; print ''."\n"; @@ -670,7 +650,10 @@ if ($object->format=="D"||$object->format=="D+") } } - print ''."\n"; + if ($user->rights->opensurvey->write) { + print ''."\n"; + } + print ''."\n"; print ''."\n"; print ''."\n"; @@ -694,7 +677,9 @@ if ($object->format=="D"||$object->format=="D+") } } - print ''."\n"; + if ($user->rights->opensurvey->write) { + print ''."\n"; + } print ''."\n"; //affichage des horaires @@ -706,13 +691,16 @@ if ($object->format=="D"||$object->format=="D+") for ($i = 0; isset($toutsujet[$i]); $i++) { $heures=explode('@', $toutsujet[$i]); if (isset($heures[1])) { - print ''."\n"; + print ''."\n"; } else { print ''."\n"; } } - print ''."\n"; + if ($user->rights->opensurvey->write) { + print ''."\n"; + } + print ''."\n"; } } @@ -726,10 +714,10 @@ else for ($i = 0; isset($toutsujet[$i]); $i++) { $tmp=explode('@',$toutsujet[$i]); - print ''."\n"; + print ''."\n"; } - print ''."\n"; + print ''."\n"; print ''."\n"; } @@ -755,12 +743,14 @@ while ($compteur < $num) $ensemblereponses = $obj->reponses; - print ''."\n"; - print ''."\n"; - + print ''."\n"; + print ''."\n"; // si la ligne n'est pas a changer, on affiche les données if (! $testligneamodifier) @@ -870,7 +860,7 @@ while ($compteur < $num) } // Button edit at end of line - if ($compteur != $ligneamodifier) + if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) { print ''."\n"; } @@ -909,7 +899,7 @@ if (empty($testligneamodifier)) if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst'))) { print '= 2) } // S'il a oublié de remplir un nom -if ((isset($_POST["boutonp"]) || isset($_POST["boutonp_x"])) && $_POST["nom"] == "") { - print ''."\n"; - print "'."\n"; +if (isset($_POST["boutonp"]) && $_POST["nom"] == "") { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")), 'errors'); } if (isset($erreur_prenom) && $erreur_prenom) { - print ''."\n"; - print "\n"; - print ''."\n"; -} - -if (isset($erreur_injection) && $erreur_injection) { - print ''."\n"; - print "\n"; - print ''."\n"; + setEventMessage($langs->trans('VoteNameAlreadyExists'), 'errors'); } if (isset($erreur_ajout_date) && $erreur_ajout_date) { - print ''."\n"; - print "\n"; - print ''."\n"; + setEventMessage($langs->trans("ErrorWrongDate"), 'errors'); } //fin du tableau @@ -1026,7 +1004,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) { $meilleursujet.=", "; - if ($object->format == "D" || $object->format == "D+") { + if ($object->format == "D") { $meilleursujetexport = $toutsujet[$i]; if (strpos($toutsujet[$i], '@') !== false) { @@ -1039,7 +1017,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { else { $tmps=explode('@',$toutsujet[$i]); - $meilleursujet .= $tmps[0]; + $meilleursujet .= dol_htmlentities($tmps[0]); } $compteursujet++; @@ -1056,9 +1034,9 @@ if ($nbofcheckbox >= 2) print '

'."\n"; if (isset($meilleurecolonne) && $compteursujet == "1") { - print " " . $langs->trans('TheBestChoice') . " : $meilleursujet " . $langs->trans("with") . " $meilleurecolonne " . $vote_str . ".\n"; + print " " . $langs->trans('TheBestChoice') . ": ".$meilleursujet." " . $langs->trans("with") . " $meilleurecolonne " . $vote_str . ".\n"; } elseif (isset($meilleurecolonne)) { - print " " . $langs->trans('TheBestChoices') . " : $meilleursujet " . $langs->trans("with") . " $meilleurecolonne " . $vote_str . ".\n"; + print " " . $langs->trans('TheBestChoices') . ": ".$meilleursujet." " . $langs->trans("with") . " $meilleurecolonne " . $vote_str . ".\n"; } print '


'."\n"; } diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php new file mode 100644 index 00000000000..c00ddf38384 --- /dev/null +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -0,0 +1,164 @@ + + * Copyright (C) 2014 Marcos García + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/opensurvey/wizard/choix_autre.php + * \ingroup opensurvey + * \brief Page to create a new survey (choice selection) + */ + +require_once('../../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); + +// Security check +if (!$user->rights->opensurvey->write) accessforbidden(); + +/* + * Action + */ + +// Set session vars +if (isset($_SESSION["nbrecases"])) { + for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { + if (isset($_POST["choix"][$i])) { + $_SESSION["choix$i"]=$_POST["choix"][$i]; + } + if (isset($_POST["typecolonne"][$i])) { + $_SESSION["typecolonne$i"]=$_POST["typecolonne"][$i]; + } + } +} else { //nombre de cases par défaut + $_SESSION["nbrecases"]=5; +} + +if (isset($_POST["ajoutcases"])) { + $_SESSION["nbrecases"]=$_SESSION["nbrecases"]+5; +} + +// Create survey into database +if (isset($_POST["confirmecreation"])) +{ + //recuperation des données de champs textes + $toutchoix = ''; + for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) + { + if (! empty($_POST["choix"][$i])) + { + $toutchoix.=','; + $toutchoix.=str_replace(array(",","@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i])?'':'@'.$_POST["typecolonne"][$i]); + } + } + + $toutchoix=substr("$toutchoix",1); + $_SESSION["toutchoix"]=$toutchoix; + + //test de remplissage des cases + $testremplissage = ''; + for ($i=0;$i<$_SESSION["nbrecases"];$i++) + { + if (isset($_POST["choix"][$i])) + { + $testremplissage="ok"; + } + } + + //message d'erreur si aucun champ renseigné + if ($testremplissage != "ok" || (!$toutchoix)) { + setEventMessage($langs->trans("ErrorOpenSurveyOneChoice"), 'errors'); + } else { + + //format du sondage AUTRE + $_SESSION["formatsondage"]="A"; + + // Add into database + ajouter_sondage(); + } +} + + + + +/* + * View + */ + +$form=new Form($db); + +$arrayofjs=array(); +$arrayofcss=array('/opensurvey/css/style.css'); +llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); + +if (empty($_SESSION['titre'])) +{ + dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection')); + llxFooterSurvey(); + exit; +} + + +//partie creation du sondage dans la base SQL +//On prépare les données pour les inserer dans la base + +print ''."\n"; + +print_fiche_titre($langs->trans("CreatePoll").' (2 / 2)'); + + +print '
'. $langs->trans("PollOnChoice") .'

'."\n"; + +print '
'."\n"; +print '
id_sondage_admin.'">'.$langs->trans("Add").''; + print 'id_sondage.'">'.$langs->trans("Add").'
id_sondage_admin.'">'.$langs->trans("Add").'id_sondage.'">'.$langs->trans("Add").'
id_sondage_admin.'">'.$langs->trans("Add").'id_sondage.'">'.$langs->trans("Add").'
'.$heures[1].''.dol_htmlentities($heures[1]).'id_sondage_admin.'">'.$langs->trans("Add").'id_sondage.'">'.$langs->trans("Add").'
'.$tmp[0].''.dol_htmlentities($tmp[0]).''.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).''.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).'
'."\n"; + + if ($user->rights->opensurvey->write) { + print ''."\n"; + } + // Name - $nombase=str_replace("°","'",$obj->nom); - print ''.$nombase.''.dol_htmlentities($obj->nom).'
" . _("Enter a name !") . "\n"; - print '
" . _("The name you've chosen already exist in this poll!") . "
" . _("Characters \" ' < et > are not permitted") . "
" . _("The date is not correct !") . "
'."\n"; + +//affichage des cases texte de formulaire +for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { + $j = $i + 1; + if (isset($_SESSION["choix$i"]) === false) { + $_SESSION["choix$i"] = ''; + } + print ''."\n"; +} + +print '
'. $langs->trans("TitleChoice") .' '.$j.': '; + $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList")); + print '   '.$langs->trans("Type").' '.$form->selectarray("typecolonne[]", $tmparray, $_SESSION["typecolonne$i"]); + print '
'."\n"; + +//ajout de cases supplementaires +print ''."\n"; +print ''."\n"; +print '
'. $langs->trans("5MoreChoices") .'
'."\n"; +print'
'."\n"; + +print ''."\n"; +print ''."\n"; +print '
'."\n"; + +//fin du formulaire et bandeau de pied +print ''."\n"; + + +print ''."\n"; +print '


'."\n"; +print '
'."\n"; + +llxFooter(); + +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/opensurvey/public/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php similarity index 77% rename from htdocs/opensurvey/public/choix_date.php rename to htdocs/opensurvey/wizard/choix_date.php index f651a91899d..3de7d10f8a1 100644 --- a/htdocs/opensurvey/public/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,33 +17,128 @@ */ /** - * \file htdocs/opensurvey/public/choix_date.php + * \file htdocs/opensurvey/wizard/choix_date.php * \ingroup opensurvey * \brief Page to create a new survey (date selection) */ -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. require_once('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); -$origin=GETPOST('origin','alpha'); +// Security check +if (!$user->rights->opensurvey->write) accessforbidden(); +//le format du sondage est DATE +$_SESSION["formatsondage"] = "D"; + +//traitement de l'entrée des heures dans les cases texte +$erreur = false; /* * Actions */ // Insert survey -if (GETPOST('confirmation') || GETPOST('confirmation_x')) +if (GETPOST('confirmation')) { - if (is_array($_SESSION['totalchoixjour'])) + + //On sauvegarde les heures deja entrées + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) { $nbofchoice=count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) - { + + for ($i = 0; $i < $nbofchoice; $i++) { + //affichage des 5 cases horaires + for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { + + $_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j]; + + $case = $j + 1; + + if (isset($_POST['horaires'.$i]) === false || isset($_POST['horaires'.$i][$j]) === false) { + $errheure[$i][$j]=true; + $erreur=true; + continue; + } + + //si c'est un creneau type 8:00-11:00 + if (preg_match("/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $_POST["horaires$i"][$j], $creneaux)) { + //on recupere les deux parties du preg_match qu'on redécoupe autour des ":" + $debutcreneau=explode(":", $creneaux[1]); + $fincreneau=explode(":", $creneaux[2]); + + //comparaison des heures de fin et de debut + //si correctes, on entre les données dans la variables de session + if ($debutcreneau[0] < 24 && $fincreneau[0] < 24 && $debutcreneau[1] < 60 && $fincreneau[1] < 60 && ($debutcreneau[0] < $fincreneau[0] || ($debutcreneau[0] == $fincreneau[0] && $debutcreneau[1] < $fincreneau[1]))) { + $_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2]; + } else { //sinon message d'erreur et nettoyage de la case + $errheure[$i][$j]=true; + $erreur=true; + } + } elseif (preg_match(";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $_POST["horaires$i"][$j], $creneaux)) { //si c'est un creneau type 8h00-11h00 + //on recupere les deux parties du preg_match qu'on redécoupe autour des "H" + $debutcreneau=preg_split("/h/i", $creneaux[1]); + $fincreneau=preg_split("/h/i", $creneaux[2]); + + //comparaison des heures de fin et de debut + //si correctes, on entre les données dans la variables de session + if ($debutcreneau[0] < 24 && $fincreneau[0] < 24 && $debutcreneau[1] < 60 && $fincreneau[1] < 60 && ($debutcreneau[0] < $fincreneau[0] || ($debutcreneau[0] == $fincreneau[0] && $debutcreneau[1] < $fincreneau[1]))) { + $_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2]; + } else { //sinon message d'erreur et nettoyage de la case + $errheure[$i][$j]=true; + $erreur=true; + } + } elseif (preg_match(";^(\d{1,2}):(\d{2})$;", $_POST["horaires$i"][$j], $heures)) { //si c'est une heure simple type 8:00 + //si valeures correctes, on entre les données dans la variables de session + if ($heures[1] < 24 && $heures[2] < 60) { + $_SESSION["horaires$i"][$j] = $heures[0]; + } else { //sinon message d'erreur et nettoyage de la case + $errheure[$i][$j]=true; + $erreur=true; + } + } elseif (preg_match(";^(\d{1,2})h(\d{0,2})$;i", $_POST["horaires$i"][$j], $heures)) { //si c'est une heure encore plus simple type 8h + //si valeures correctes, on entre les données dans la variables de session + if ($heures[1] < 24 && $heures[2] < 60) { + $_SESSION["horaires$i"][$j] = $heures[0]; + } else { //sinon message d'erreur et nettoyage de la case + $errheure[$i][$j]=true; + $erreur=true; + } + } elseif (preg_match(";^(\d{1,2})-(\d{1,2})$;", $_POST["horaires$i"][$j], $heures)) { //si c'est un creneau simple type 8-11 + //si valeures correctes, on entre les données dans la variables de session + if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) { + $_SESSION["horaires$i"][$j] = $heures[0]; + } else { //sinon message d'erreur et nettoyage de la case + $errheure[$i][$j]=true; + $erreur=true; + } + } elseif (preg_match(";^(\d{1,2})h-(\d{1,2})h$;", $_POST["horaires$i"][$j], $heures)) { //si c'est un creneau H type 8h-11h + //si valeures correctes, on entre les données dans la variables de session + if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) { + $_SESSION["horaires$i"][$j] = $heures[0]; + } else { //sinon message d'erreur et nettoyage de la case + $errheure[$i][$j]=true; + $erreur=true; + } + } elseif ($_POST["horaires$i"][$j]=="") { //Si la case est vide + unset($_SESSION["horaires$i"][$j]); + } else { //pour tout autre format, message d'erreur + $errheure[$i][$j]=true; + $erreur=true; + } + + if (issetAndNoEmpty('horaires'.$i, $_SESSION) === false || issetAndNoEmpty($j, $_SESSION['horaires'.$i]) === false) { + if (issetAndNoEmpty('horaires'.$i, $_SESSION) === true) { + $_SESSION["horaires$i"][$j] = ''; + } else { + $_SESSION["horaires$i"] = array(); + $_SESSION["horaires$i"][$j] = ''; + } + } + } + if ($_SESSION["horaires$i"][0] == "" && $_SESSION["horaires$i"][1] == "" && $_SESSION["horaires$i"][2] == "" && $_SESSION["horaires$i"][3] == "" && $_SESSION["horaires$i"][4] == "") { $choixdate.=","; $choixdate .= $_SESSION["totalchoixjour"][$i]; @@ -58,11 +154,22 @@ if (GETPOST('confirmation') || GETPOST('confirmation_x')) } } } + + if (isset($errheure)) { + setEventMessage($langs->trans("ErrorBadFormat"), 'errors'); + } } - else dol_print_error('','array not defined'); - $_SESSION["toutchoix"]=substr("$choixdate",1); - ajouter_sondage($origin); + //If just one day and no other time options, error message + if (count($_SESSION["totalchoixjour"])=="1" && $_POST["horaires0"][0]=="" && $_POST["horaires0"][1]=="" && $_POST["horaires0"][2]=="" && $_POST["horaires0"][3]=="" && $_POST["horaires0"][4]=="") { + setEventMessage($langs->trans("MoreChoices"), 'errors'); + $erreur=true; + } + + if (!$erreur) { + $_SESSION["toutchoix"]=substr("$choixdate",1); + ajouter_sondage(); + } } // Reset days @@ -84,22 +191,22 @@ if (GETPOST('reset')) { * View */ -if (! isset($_SESSION['nom']) && ! isset($_SESSION['adresse']) && ! isset($_SESSION['commentaires']) && ! isset($_SESSION['mail'])) +if (! isset($_SESSION['commentaires']) && ! isset($_SESSION['mail'])) { - dol_print_error('',"You haven't filled the first section of the poll creation"); + dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection')); exit; } $arrayofjs=array(); $arrayofcss=array('/opensurvey/css/style.css'); -llxHeaderSurvey($langs->trans("OpenSurvey"), "", 0, 0, $arrayofjs, $arrayofcss); +llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); //nombre de cases par défaut if (! isset($_SESSION["nbrecaseshoraires"])) { $_SESSION["nbrecaseshoraires"]=5; } -elseif ((GETPOST('ajoutcases') || GETPOST('ajoutcases_x')) && $_SESSION["nbrecaseshoraires"] == 5) +elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) { $_SESSION["nbrecaseshoraires"]=10; } @@ -115,14 +222,14 @@ if (! isset($_SESSION['mois'])) $_SESSION['mois']= date('n'); if (! isset($_SESSION['annee'])) $_SESSION['annee']= date('Y'); //mise a jour des valeurs de session si bouton retour a aujourd'hui -if ((!issetAndNoEmpty('anneeavant_x') && !issetAndNoEmpty('anneeapres_x') && !issetAndNoEmpty('moisavant_x') && !issetAndNoEmpty('moisapres_x') && !issetAndNoEmpty('choixjourajout')) && !issetAndNoEmpty('choixjourretrait') || (issetAndNoEmpty('retourmois') || issetAndNoEmpty('retourmois_x'))){ +if ((!issetAndNoEmpty('choixjourajout')) && !issetAndNoEmpty('choixjourretrait') || issetAndNoEmpty('retourmois')){ $_SESSION["jour"]=date("j"); $_SESSION["mois"]=date("n"); $_SESSION["annee"]=date("Y"); } //mise a jour des valeurs de session si mois avant -if (issetAndNoEmpty('moisavant') || issetAndNoEmpty('moisavant_x')) { +if (issetAndNoEmpty('moisavant')) { if ($_SESSION["mois"] == 1) { $_SESSION["mois"] = 12; $_SESSION["annee"] = $_SESSION["annee"]-1; @@ -144,7 +251,7 @@ if (issetAndNoEmpty('moisavant') || issetAndNoEmpty('moisavant_x')) { } //mise a jour des valeurs de session si mois apres -if (issetAndNoEmpty('moisapres') || issetAndNoEmpty('moisapres_x')) { +if (issetAndNoEmpty('moisapres')) { if ($_SESSION["mois"] == 12) { $_SESSION["mois"] = 1; $_SESSION["annee"] += 1; @@ -167,7 +274,7 @@ if (issetAndNoEmpty('moisapres') || issetAndNoEmpty('moisapres_x')) { } //mise a jour des valeurs de session si annee avant -if (issetAndNoEmpty('anneeavant') || issetAndNoEmpty('anneeavant_x')) { +if (issetAndNoEmpty('anneeavant')) { $_SESSION["annee"] -= 1; //On sauvegarde les heures deja entrées @@ -184,7 +291,7 @@ if (issetAndNoEmpty('anneeavant') || issetAndNoEmpty('anneeavant_x')) { } //mise a jour des valeurs de session si annee apres -if (issetAndNoEmpty('anneeapres') || issetAndNoEmpty('anneeapres_x')) { +if (issetAndNoEmpty('anneeapres')) { $_SESSION["annee"] += 1; //On sauvegarde les heures deja entrées @@ -204,10 +311,6 @@ if (issetAndNoEmpty('anneeapres') || issetAndNoEmpty('anneeapres_x')) { $nbrejourmois = date("t", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee"])); $premierjourmois = date("N", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee"])) - 1; -//le format du sondage est DATE -$_SESSION["formatsondage"] = "D"; -$_SESSION["formatcanedit"] = $_SESSION["canedit"]; - //traduction de la valeur du mois if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13) { @@ -220,10 +323,9 @@ else //Debut du formulaire et bandeaux de tete -print '
'."\n"; -print ''; +print ''."\n"; -print '
'. $langs->trans("CreatePoll")." (2 / 2)" .'
'."\n"; +print_fiche_titre($langs->trans("CreatePoll").' (2 / 2)'); //affichage de l'aide pour les jours print '
'."\n"; @@ -233,11 +335,11 @@ print '
'."\n"; //debut du tableau qui affiche le calendrier print '
'."\n"; print ''."\n"; -print ''; +print ''; print ''; -print ''; +print ''."\n"; print '
'.$motmois.' '.$_SESSION["annee"].'
'; print ''; -print '
'; +print ''; print '
'."\n"; print ''."\n"; @@ -385,117 +487,14 @@ print ''."\n"; print '
'."\n"; print '
'."\n"; -//traitement de l'entrée des heures dans les cases texte -$errheure = $erreur = false; -if (issetAndNoEmpty('choixheures') || issetAndNoEmpty('choixheures_x')) { - //On sauvegarde les heures deja entrées - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) - { - $nbofchoice=count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) { - //affichage des 5 cases horaires - for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { - $_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j]; - } - } - } - - //affichage des horaires - if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) - { - $nbofchoice=count($_SESSION["totalchoixjour"]); - for ($i = 0; $i < $nbofchoice; $i++) { - //affichage des 5 cases horaires - for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { - $case = $j + 1; - - if (isset($_POST['horaires'.$i]) === false || isset($_POST['horaires'.$i][$j]) === false) { - $errheure[$i][$j]=true; - $erreur=true; - $_SESSION["horaires$i"][$j]=$_POST["horaires$i"][$j]; - continue; - } - - //si c'est un creneau type 8:00-11:00 - if (preg_match("/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $_POST["horaires$i"][$j], $creneaux)) { - //on recupere les deux parties du preg_match qu'on redécoupe autour des ":" - $debutcreneau=explode(":", $creneaux[1]); - $fincreneau=explode(":", $creneaux[2]); - - //comparaison des heures de fin et de debut - //si correctes, on entre les données dans la variables de session - if ($debutcreneau[0] < 24 && $fincreneau[0] < 24 && $debutcreneau[1] < 60 && $fincreneau[1] < 60 && ($debutcreneau[0] < $fincreneau[0] || ($debutcreneau[0] == $fincreneau[0] && $debutcreneau[1] < $fincreneau[1]))) { - $_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2]; - } else { //sinon message d'erreur et nettoyage de la case - $errheure[$i][$j]=true; - $erreur=true; - } - } elseif (preg_match(";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $_POST["horaires$i"][$j], $creneaux)) { //si c'est un creneau type 8h00-11h00 - //on recupere les deux parties du preg_match qu'on redécoupe autour des "H" - $debutcreneau=preg_split("/h/i", $creneaux[1]); - $fincreneau=preg_split("/h/i", $creneaux[2]); - - //comparaison des heures de fin et de debut - //si correctes, on entre les données dans la variables de session - if ($debutcreneau[0] < 24 && $fincreneau[0] < 24 && $debutcreneau[1] < 60 && $fincreneau[1] < 60 && ($debutcreneau[0] < $fincreneau[0] || ($debutcreneau[0] == $fincreneau[0] && $debutcreneau[1] < $fincreneau[1]))) { - $_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2]; - } else { //sinon message d'erreur et nettoyage de la case - $errheure[$i][$j]=true; - $erreur=true; - } - } elseif (preg_match(";^(\d{1,2}):(\d{2})$;", $_POST["horaires$i"][$j], $heures)) { //si c'est une heure simple type 8:00 - //si valeures correctes, on entre les données dans la variables de session - if ($heures[1] < 24 && $heures[2] < 60) { - $_SESSION["horaires$i"][$j] = $heures[0]; - } else { //sinon message d'erreur et nettoyage de la case - $errheure[$i][$j]=true; - $erreur=true; - } - } elseif (preg_match(";^(\d{1,2})h(\d{0,2})$;i", $_POST["horaires$i"][$j], $heures)) { //si c'est une heure encore plus simple type 8h - //si valeures correctes, on entre les données dans la variables de session - if ($heures[1] < 24 && $heures[2] < 60) { - $_SESSION["horaires$i"][$j] = $heures[0]; - } else { //sinon message d'erreur et nettoyage de la case - $errheure[$i][$j]=true; - $erreur=true; - } - } elseif (preg_match(";^(\d{1,2})-(\d{1,2})$;", $_POST["horaires$i"][$j], $heures)) { //si c'est un creneau simple type 8-11 - //si valeures correctes, on entre les données dans la variables de session - if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) { - $_SESSION["horaires$i"][$j] = $heures[0]; - } else { //sinon message d'erreur et nettoyage de la case - $errheure[$i][$j]=true; - $erreur=true; - } - } elseif (preg_match(";^(\d{1,2})h-(\d{1,2})h$;", $_POST["horaires$i"][$j], $heures)) { //si c'est un creneau H type 8h-11h - //si valeures correctes, on entre les données dans la variables de session - if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) { - $_SESSION["horaires$i"][$j] = $heures[0]; - } else { //sinon message d'erreur et nettoyage de la case - $errheure[$i][$j]=true; - $erreur=true; - } - } elseif ($_POST["horaires$i"][$j]=="") { //Si la case est vide - unset($_SESSION["horaires$i"][$j]); - } else { //pour tout autre format, message d'erreur - //$errheure[$i][$j]=true; - //$erreur=true; - $_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j]; - } - } - } - } -} - print '
'."\n"; // affichage de tous les jours choisis -if (issetAndNoEmpty('totalchoixjour', $_SESSION) && (!issetAndNoEmpty('choixheures_x') || $erreur)) -//if (1==1 || GETPOST($_SESSION['totalchoixjour']) && (! GETPOST('choixheures_x') || $erreur)) +if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) { //affichage des jours print '
'."\n"; - print ''. $langs->trans("SelectedDays") .' :'."
\n"; + print ''. $langs->trans("SelectedDays") .':'."
\n"; print $langs->trans("SelectDayDesc")."
\n"; print ''."\n"; print ''."\n"; @@ -507,44 +506,29 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) && (!issetAndNoEmpty('choixheur } if ($_SESSION["nbrecaseshoraires"] < 10) { - print ''."\n"; + print ''."\n"; } print ''."\n"; //affichage de la liste des jours choisis $nbofchoice=count($_SESSION["totalchoixjour"]); + for ($i=0; $i<$nbofchoice; $i++) { print ''."\n"; print ''; - $affichageerreurfindeligne=false; - //affichage des cases d'horaires for ($j=0;$j<$_SESSION["nbrecaseshoraires"];$j++) { //si on voit une erreur, le fond de la case est rouge if (isset($errheure[$i][$j]) && $errheure[$i][$j]) { print ''."\n"; - $affichageerreurfindeligne=true; } else { //sinon la case est vide normalement - if (issetAndNoEmpty('horaires'.$i, $_SESSION) === false || issetAndNoEmpty($j, $_SESSION['horaires'.$i]) === false) { - if (issetAndNoEmpty('horaires'.$i, $_SESSION) === true) { - $_SESSION["horaires$i"][$j] = ''; - } else { - $_SESSION["horaires$i"] = array(); - $_SESSION["horaires$i"][$j] = ''; - } - } - + print ''."\n"; } } - - if ($affichageerreurfindeligne) { - print ''."\n"; - } - print ''."\n"; } @@ -555,33 +539,7 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) && (!issetAndNoEmpty('choixheur print ''."\n"; print ''."\n"; print''."\n"; - print ''."\n"; - print '
'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')'. _("Bad format!") .'


'."\n"; - - //si un seul jour et aucunes horaires choisies, : message d'erreur - if ((GETPOST('choixheures') || GETPOST('choixheures_x')) && (count($_SESSION["totalchoixjour"])=="1" && $_POST["horaires0"][0]=="" && $_POST["horaires0"][1]=="" && $_POST["horaires0"][2]=="" && $_POST["horaires0"][3]=="" && $_POST["horaires0"][4]=="")) { - print '
'. _("Enter more choices for the voters") .'
'."\n"; - $erreur=true; - } -} - -//s'il n'y a pas d'erreur et que le bouton de creation est activé, on demande confirmation -if (!$erreur && (GETPOST('choixheures') || GETPOST('choixheures_x'))) { - $taille_tableau=count($_SESSION["totalchoixjour"])-1; - $jour_arret = $_SESSION["totalchoixjour"][$taille_tableau]+200000; - $date_fin=dol_print_date($jour_arret, 'dayhourtext'); - - print '
'. $langs->trans("PollWillExpire",2) .'
'. $langs->trans("RemovalDate") .' : '.$date_fin.'
'."\n"; - print '
'."\n"; - print '
'."\n"; - print ''. _("Once you have confirmed the creation of your poll, you will be automatically redirected on the page of your poll.
Then, you will receive quickly an email contening the link to your poll for sending it to the voters.") .'
'."\n"; - print'
'."\n"; - // print'

'."\n"; - // print 'Pour finir la création du sondage, cliquez sur le bouton ajout ci-dessous'."\n"; - // print '

'."\n"; - print ''."\n"; - print ''."\n"; - print''."\n"; + print ''."\n"; print '
'. $langs->trans("BackToHoursSetup") .'
'. $langs->trans("CreatePoll") .'
'."\n"; } @@ -594,7 +552,7 @@ print ''."\n"; print '



'."\n"; print '
'."\n"; -llxFooterSurvey(); +llxFooter(); $db->close(); ?> \ No newline at end of file diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php new file mode 100644 index 00000000000..26411fa18b5 --- /dev/null +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -0,0 +1,205 @@ + + * Copyright (C) 2014 Marcos García + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/opensurvey/wizard/create_survey.php + * \ingroup opensurvey + * \brief Page to create a new survey + */ + +require_once('../../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); + +// Security check +if (!$user->rights->opensurvey->write) accessforbidden(); + +$langs->load("opensurvey"); + +// On teste toutes les variables pour supprimer l'ensemble des warnings PHP +// On transforme en entites html les données afin éviter les failles XSS +$post_var = array('titre', 'commentaires', 'mailsonde', 'creation_sondage_date', 'creation_sondage_autre'); +foreach ($post_var as $var) +{ + $$var = GETPOST($var); +} + +// On initialise egalement la session car sinon bonjour les warning :-) +$session_var = array('titre', 'commentaires', 'mailsonde'); +foreach ($session_var as $var) +{ + if (isset($_SESSION[$var])) $_SESSION[$var] = null; +} + +// On initialise également les autres variables +$cocheplus = ''; +$cochemail = ''; + +// Jump to correct page +if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) +{ + $_SESSION["titre"] = $titre; + $_SESSION["commentaires"] = $commentaires; + + if (GETPOST('mailsonde') == 'on') { + $_SESSION["mailsonde"] = true; + } else { + $_SESSION["mailsonde"] = false; + } + + if (GETPOST('allow_comments') == 'on') { + $_SESSION['allow_comments'] = true; + } else { + $_SESSION['allow_comments'] = false; + } + + if (GETPOST('allow_spy') == 'on') { + $_SESSION['allow_spy'] = true; + } else { + $_SESSION['allow_spy'] = false; + } + + $testdate = false; + + if (GETPOST('champdatefin')) + { + $registredate=explode("/",$_POST["champdatefin"]); + if (is_array($registredate) && count($registredate) === 3) { + $time = mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]); + + if ($time !== false && date('d/m/Y', $time) === $_POST["champdatefin"]) { + //Expire date is not before today + if ($time - dol_now() > 0) { + $testdate = true; + $_SESSION['champdatefin'] = $time; + } + } + } + } + + if (!$testdate) { + setEventMessage($langs->trans('ErrorOpenSurveyDateFormat'), 'errors'); + } + + if ($titre && $testdate) + { + if (! empty($creation_sondage_date)) + { + header("Location: choix_date.php"); + exit(); + } + + if (! empty($creation_sondage_autre)) + { + header("Location: choix_autre.php"); + exit(); + } + } +} + + + + +/* + * View + */ + +$form = new Form($db); + +$arrayofjs=array(); +$arrayofcss=array('/opensurvey/css/style.css'); +llxHeader('', $langs->trans("OpenSurvey"), '', "", 0, 0, $arrayofjs, $arrayofcss); + +print_fiche_titre($langs->trans("CreatePoll").' (1 / 2)'); + +//debut du formulaire +print '
'."\n"; + +//Affichage des différents champs textes a remplir +print ''."\n"; + +print ''."\n"; +if (! $_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) +{ + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PollTitle")), 'errors'); +} + +print ''."\n"; +print ''."\n"; +print ''."\n"; + +print ''."\n"; +print '
'. $langs->trans("PollTitle") .'
'. $langs->trans("Description") .'
'. $langs->trans("ExpireDate") .''; + +if (!GETPOST('champdatefin')) { + //172800 = 48 hours + $champdatefin = time() + 172800; +} else { + $champdatefin = -1; +} + +print $form->select_date($champdatefin,'champdatefin','','','',"add",1,0); + +print '
'."\n"; + +//focus javascript sur le premier champ +print ''."\n"; + +print '
'."\n"; + +// Check or not + +if ($_SESSION["mailsonde"]) $cochemail="checked"; + +print ' '. $langs->trans("ToReceiveEMailForEachVote") .'
'."\n"; + +if ($_SESSION['allow_comments']) $allow_comments = "checked"; + +print ' '.$langs->trans('CanComment').'
'."\n"; + +if ($_SESSION['allow_spy']) $allow_spy = "checked"; + +print ' '.$langs->trans('CanSeeOthersVote').'
'."\n"; + +if (GETPOST('choix_sondage')) +{ + if (GETPOST('choix_sondage') == 'date') print ''; + else print ''; + print ''; + print '
trans("TypeDate"):$langs->trans("TypeClassic")).')">'; +} +else +{ + //affichage des boutons pour choisir sondage date ou autre + print '
'."\n"; + print ' '."\n"; + print ''."\n"; + print ' '."\n"; + print ''."\n"; + print '
'. $langs->trans("CreateSurveyDate") .'
'. $langs->trans("CreateSurveyStandard") .'
'."\n"; +} +print '


'."\n"; +print '
'."\n"; + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/opensurvey/public/index.php b/htdocs/opensurvey/wizard/index.php similarity index 58% rename from htdocs/opensurvey/public/index.php rename to htdocs/opensurvey/wizard/index.php index 2c78a86cb9d..87852231f80 100644 --- a/htdocs/opensurvey/public/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,44 +22,38 @@ //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. require_once('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); -$origin=GETPOST('origin','alpha'); +// Security check +if (!$user->rights->opensurvey->write) accessforbidden(); $langs->load("opensurvey"); - /* * View */ $arrayofjs=array(); $arrayofcss=array('/opensurvey/css/style.css'); -llxHeaderSurvey($langs->trans("OpenSurvey"), "", 0, 0, $arrayofjs, $arrayofcss); +llxHeader('', $langs->trans("OpenSurvey"), '', "", 0, 0, $arrayofjs, $arrayofcss); + +print_fiche_titre($langs->trans("CreatePoll")); print '
-
- -
-

'.$langs->trans("OpenSurveyDesc").' '.$langs->trans("OpenSurveyNoRegistration").'

-

'; -print $langs->trans("OrganizeYourMeetingEasily").' +'; +print '

'.$langs->trans("OrganizeYourMeetingEasily").'


-
-
+
+
'; -llxFooterSurvey(); +llxFooter(); $db->close(); ?> diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 065b3191bec..367d5bcd6d6 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2973,7 +2973,7 @@ class Product extends CommonObject // Objet $obj=array(); $obj['photo']=$photo; - if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) $obj['photo_vignette']=$dirthumb . $photo_vignette; + if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) $obj['photo_vignette']='thumbs/' . $photo_vignette; else $obj['photo_vignette']=""; $tabobj[$nbphoto-1]=$obj; diff --git a/htdocs/product/composition/fiche.php b/htdocs/product/composition/fiche.php index f770e48b715..7b35aa158c6 100644 --- a/htdocs/product/composition/fiche.php +++ b/htdocs/product/composition/fiche.php @@ -375,7 +375,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''.$langs->trans("TotalBuyingPriceMin").': '; if ($atleastonenotdefined) print $langs->trans("Unknown").' ('.$langs->trans("SomeSubProductHaveNoPrices").')'; - print ''; + print ''; print ''.($atleastonenotdefined?'':price($total,'','',0,0,-1,$conf->currency)).''; if (! empty($conf->stock->enabled)) print ' '; print ''; @@ -436,7 +436,7 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->categorie->enabled)) { print ''.$langs->trans("CategoryFilter").'   '; - print ''.$form->select_all_categories(0, $parent).''; + print ''.$form->select_all_categories(0, $parent).''; } print ''; print ''; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 788bd8fee09..27bab21d2e8 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -176,7 +176,7 @@ $sql = 'SELECT p.rowid, p.ref, p.label, p.price,'; $sql.= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; $sql.= ' p.tms as datem, p.duration, p.tobuy, p.seuil_stock_alerte,'; $sql.= ' p.desiredstock,'; -$sql.= ' SUM('.$db->ifsql("s.reel IS NULL", "s.reel", "0").') as stock_physique'; +$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'; @@ -219,7 +219,7 @@ $sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel $sql.= ' AND p.desiredstock > 0'; if ($salert == 'on') // Option to see when stock is lower than alert { - $sql .= ' AND SUM('.$db->ifsql("s.reel IS NULL", "s.reel", "0").') < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL'; + $sql .= ' AND SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') < p.seuil_stock_alerte AND p.seuil_stock_alerte is not NULL'; $alertchecked = 'checked="checked"'; } $sql.= $db->order($sortfield,$sortorder); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index cea067d67e5..9924dddf4f4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1281,7 +1281,7 @@ class Project extends CommonObject } /** - * Clean task not linked to a parent + * Clean tasks not linked to an existing parent * * @return int Nb of records deleted */ @@ -1292,7 +1292,7 @@ class Project extends CommonObject // There is orphelins. We clean that $listofid=array(); - // Get list of id in array listofid + // Get list of all id in array listofid $sql='SELECT rowid FROM '.MAIN_DB_PREFIX.'projet_task'; $resql = $this->db->query($sql); if ($resql) @@ -1313,19 +1313,24 @@ class Project extends CommonObject if (count($listofid)) { - // Removed orphelins records - print 'Some orphelins were found and restored to be parents so records are visible again: '; - print join(',',$listofid); + print 'Code asked to check and clean orphelins.'; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; $sql.= " SET fk_task_parent = 0"; - $sql.= " WHERE fk_task_parent NOT IN (".join(',',$listofid).")"; + $sql.= " WHERE fk_task_parent NOT IN (".join(',',$listofid).")"; // So we update only records linked to a non existing parent $resql = $this->db->query($sql); if ($resql) { $nb=$this->db->affected_rows($sql); + if ($nb > 0) + { + // Removed orphelins records + print 'Some orphelins were found and modified to be parent so records are visible again: '; + print join(',',$listofid); + } + return $nb; } else diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index dddab2a5e79..9eb3ca646b3 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -47,25 +47,14 @@ $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $id); +$permissionnote=$user->rights->projet->creer; // Used by the include of actions_setnotes.inc.php -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ +/* + * Actions + */ -if ($action == 'setnote_public' && $user->rights->projet->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -if ($action == 'setnote_private' && $user->rights->projet->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once /* diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index c45248db741..794a1198c35 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -79,7 +79,7 @@ $userAccess=0; /* * Actions -*/ + */ if ($action == 'createtask' && $user->rights->projet->creer) { @@ -396,8 +396,7 @@ else print ''; // Get list of tasks in tasksarray and taskarrayfiltered - // We need all tasks (even not limited to a user because a task to user - // can have a parent that is not affected to him). + // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); // We load also tasks limited to a particular user $tasksrole=($mode=='mine' ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$object->id,0) : ''); @@ -426,7 +425,7 @@ else { // Show all lines in taskarray (recursive function to go down on tree) $j=0; - $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, '', 1); + $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $id, 1); } else { @@ -437,13 +436,16 @@ else // Test if database is clean. If not we clean it. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'
'; - if ($mode=='mine') + if (! empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) { - if ($nboftaskshown < count($tasksrole)) $object->clean_orphelins(); - } - else - { - if ($nboftaskshown < count($tasksarray)) $object->clean_orphelins(); + if ($mode=='mine') + { + if ($nboftaskshown < count($tasksrole)) $object->clean_orphelins(); + } + else + { + if ($nboftaskshown < count($tasksarray)) $object->clean_orphelins(); + } } } diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index 077a56c1976..8795cf98486 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -80,7 +80,7 @@ else else print $langs->trans("ProjectsPublicDesc").'

'; } -// Get list of project id allowed to user +// Get list of project id allowed to user (in a string list separated by coma) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); // Get list of tasks in tasksarray and taskarrayfiltered @@ -121,7 +121,7 @@ print "\n"; // Show all lines in taskarray (recursive function to go down on tree) $j=0; $level=0; -$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId); +$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId, 0); print ""; print ''; diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 1b6bebeb9d5..c2e2451263d 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -85,18 +85,7 @@ $permission=($user->rights->projet->creer || $user->rights->projet->all->creer); * Actions */ -if ($action == 'setnote_public' && ! empty($permission)) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote_private' && ! empty($permission)) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private'); - if ($result < 0) dol_print_error($db,$object->error); -} - +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; /* diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 3e3082cc981..34a96f7bcb6 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -38,12 +38,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); -} +if (is_int($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index 0fc725c8ed4..2a9b3465543 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -27,12 +27,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : 1); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); -} +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_int($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index d186467ee04..1b6d23d946c 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -27,12 +27,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : 1); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); -} +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_int($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 77437c110d2..b8bad33c08f 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -27,6 +27,12 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_int($entity)) define("DOLENTITY", $entity); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php index f01628324bb..b1639ec379e 100644 --- a/htdocs/public/paybox/paymentko.php +++ b/htdocs/public/paybox/paymentko.php @@ -26,6 +26,12 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_int($entity)) define("DOLENTITY", $entity); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -95,7 +101,7 @@ llxHeaderPayBox($langs->trans("PaymentForm")); print ''."\n"; print '
'."\n"; -print $langs->trans("YourPaymentHasNotBeenRecorded")."
\n"; +print $langs->trans("YourPaymentHasNotBeenRecorded")."

\n"; if (! empty($conf->global->PAYBOX_MESSAGE_KO)) print $conf->global->PAYBOX_MESSAGE_KO; diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php index e204b6d6697..159d29bb78c 100644 --- a/htdocs/public/paybox/paymentok.php +++ b/htdocs/public/paybox/paymentok.php @@ -26,6 +26,12 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_int($entity)) define("DOLENTITY", $entity); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -118,7 +124,7 @@ if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) } -print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; +print $langs->trans("YourPaymentHasBeenRecorded")."

\n"; if (! empty($conf->global->PAYBOX_MESSAGE_OK)) print $conf->global->PAYBOX_MESSAGE_OK; diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 81c362633ed..91d1f67a3b9 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -29,12 +29,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); -} +if (is_int($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index 012880f817a..6076c54bd03 100644 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -29,11 +29,12 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module. This should be useless. Because entity must be retreive from object ref and not from url. -$entity=GETPOST('entity')?GETPOST('entity','int'):1; +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_int($entity)) define("DOLENTITY", $entity); - require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; @@ -100,7 +101,7 @@ llxHeaderPaypal($langs->trans("PaymentForm")); // Show ko message print ''."\n"; print '
'."\n"; -print $langs->trans("YourPaymentHasNotBeenRecorded")."
"; +print $langs->trans("YourPaymentHasNotBeenRecorded")."

"; $PAYPALTOKEN=GETPOST('TOKEN'); if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index 47fd55dc5d6..32aa3fd4b49 100644 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -29,11 +29,12 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module. This should be useless. Because entity must be retreive from object ref and not from url. -$entity=GETPOST('entity')?GETPOST('entity','int'):1; +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retreive from object ref and not from url. +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_int($entity)) define("DOLENTITY", $entity); - require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; @@ -128,33 +129,6 @@ if ($PAYPALTOKEN) dol_syslog("Call paymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal'); - // Send an email - //if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=/',$fulltag)) - if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) - { - //$sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL; - $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; - $from=$conf->global->MAILING_EMAIL_FROM; - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile( - '['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived"), - $sendto, - $from, - $langs->transnoentitiesnoconv("NewPaypalPaymentReceived")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt - ); - - $result=$mailfile->sendfile(); - if ($result) - { - dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal'); - } - else - { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal'); - } - } - - // Validate record if (! empty($paymentType)) { @@ -183,7 +157,7 @@ if ($PAYPALTOKEN) $NOTE=urldecode($resArray["NOTE"]); print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; - print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."
\n"; + print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."

\n"; if (! empty($conf->global->PAYPAL_MESSAGE_OK)) print $conf->global->PAYPAL_MESSAGE_OK; // Appel des triggers @@ -192,6 +166,30 @@ if ($PAYPALTOKEN) $result=$interface->run_triggers('PAYPAL_PAYMENT_OK',$object,$user,$langs,$conf); if ($result < 0) { $error++; $errors=$interface->errors; } // Fin appel triggers + + // Send an email + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile( + '['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived"), + $sendto, + $from, + $langs->transnoentitiesnoconv("NewPaypalPaymentReceived")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt + ); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal'); + } + } } else { @@ -208,6 +206,30 @@ if ($PAYPALTOKEN) echo "Error Severity Code: " . $ErrorSeverityCode; if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email; + + // Send an email + if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) + { + $sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + $from=$conf->global->MAILING_EMAIL_FROM; + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile( + '['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("ValidationOfPaypalPaymentFailed"), + $sendto, + $from, + $langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt."\nErrorCode=".$ErrorCode."\nErrorLongMsg=".$ErrorLongMsg + ); + + $result=$mailfile->sendfile(); + if ($result) + { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal'); + } + else + { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal'); + } + } } } else diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index fb8274e5524..4a4e7bc6f74 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -4,7 +4,7 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site. require '../../main.inc.php'; -if (empty($conf->global->MAIN_FEATURES_LEVEL)) +if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { print "Page available onto dev environment only"; exit; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 664be4b9a05..941a5445ff1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -306,6 +306,12 @@ class Societe extends CommonObject $contact->socid = $this->id; // fk_soc $contact->statut = 1; $contact->priv = 0; + $contact->country_id = $this->country_id; + $contact->address = $this->address; + $contact->email = $this->email; + $contact->zip = $this->zip; + $contact->town = $this->town; + $contact->phone_pro = $this->phone; $result = $contact->create($user); if ($result < 0) { $this->error = $contact->error; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 5225a30786b..301629dd17a 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2013 Juanjo Menent * * Version V1.1 Initial version of Philippe Berthet @@ -30,10 +30,7 @@ require("../main.inc.php"); require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.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.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; // Security check $socid = GETPOST('socid','int'); @@ -104,10 +101,6 @@ if (empty($socid)) $head = societe_prepare_head($object); dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"),0,'company'); -print '
'; -print ''; -print ''; - print ''; print ''; print '
'.$langs->trans('ThirdPartyName').''; @@ -160,47 +153,61 @@ dol_fiche_end(); print '
'; +print ''; +print ''; +print ''."\n"; + + $sql_select=''; if ($type_element == 'invoice') -{ // Customer : show products from invoices -$documentstatic=new Facture($db); -$sql_select = 'SELECT f.rowid as doc_id, f.facnumber as doc_number, f.type as doc_type, f.datef as datePrint, '; -$tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; -$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; -$where.= " AND d.fk_facture = f.rowid"; -$where.= " AND f.entity = ".$conf->entity; -$datePrint = 'f.datef'; -$doc_number='f.facnumber'; -$thirdTypeSelect='customer'; +{ // Customer : show products from invoices + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $documentstatic=new Facture($db); + $sql_select = 'SELECT f.rowid as doc_id, f.facnumber as doc_number, f.type as doc_type, f.datef as datePrint, '; + $tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; + $where.= " AND d.fk_facture = f.rowid"; + $where.= " AND f.entity = ".$conf->entity; + $datePrint = 'f.datef'; + $doc_number='f.facnumber'; + $thirdTypeSelect='customer'; } if ($type_element == 'order') { + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $documentstatic=new Commande($db); - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, "1" as doc_type, f.date_commande as datePrint, '; - $tables_from = MAIN_DB_PREFIX."commande as f,".MAIN_DB_PREFIX."commandedet as d"; - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; - $where.= " AND d.fk_commande = f.rowid"; - $where.= " AND f.entity = ".$conf->entity; - $datePrint = 'f.date_creation'; - $doc_number='f.ref'; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, "1" as doc_type, c.date_commande as datePrint, '; + $tables_from = MAIN_DB_PREFIX."commande as c,".MAIN_DB_PREFIX."commandedet as d"; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where.= " AND d.fk_commande = c.rowid"; + $where.= " AND c.entity = ".$conf->entity; + $datePrint = 'c.datef'; + $doc_number='c.ref'; $thirdTypeSelect='customer'; - -} -if ($type_element == 'supplier_order') -{ // Supplier : Show products from orders. -$documentstatic=new CommandeFournisseur($db); -$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, "1" as doc_type, c.date_valid as datePrint, '; -$tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; -$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; -$where.= " AND d.fk_commande = c.rowid"; -$datePrint = 'c.date_creation'; -$doc_number='c.ref'; -$thirdTypeSelect='supplier'; } if ($type_element == 'supplier_invoice') -{ - // TODO - +{ // Supplier : Show products from invoices. + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $documentstatic=new FactureFournisseur($db); + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, "1" as doc_type, f.datef as datePrint, '; + $tables_from = MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."facture_fourn_det as d"; + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; + $where.= " AND d.fk_facture_fourn = f.rowid"; + $datePrint = 'f.datef'; + $doc_number='f.ref'; + $thirdTypeSelect='supplier'; +} +if ($type_element == 'supplier_order') +{ // Supplier : Show products from orders. + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $documentstatic=new CommandeFournisseur($db); + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, "1" as doc_type, c.date_valid as datePrint, '; + $tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where.= " AND d.fk_commande = c.rowid"; + $datePrint = 'c.date_valid'; + $doc_number='c.ref'; + $thirdTypeSelect='supplier'; } $sql = $sql_select; diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 1928ba914a0..0d87f98854b 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -40,26 +40,15 @@ $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); if ($id > 0) $object->fetch($id); +$permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php + + /* * Actions */ -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) setEventMessage($object->error,'errors'); -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once -else if ($action == 'setnote_private' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) setEventMessage($object->error,'errors'); -} /* * View diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index ca83d9e0a53..5e1a6ed40d7 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1826,7 +1826,7 @@ else else { $langs->load("mails"); - print ''; + print ''; } if ($user->rights->societe->creer) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index e1c13988d6e..379feea6bd3 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1357,7 +1357,7 @@ div.tabs { /* margin: 0px 0px 2px 6px; padding: 0px 6px 3px 0px; */ text-align: ; - + margin-left: 4px !important; clear:both; height:100%; } @@ -2761,7 +2761,7 @@ a.tab span.ui-btn-inner } .ui-link { - color: rgb() !important; + color: rgb(); } .liste_titre .ui-link { color: # !important; @@ -2843,10 +2843,21 @@ ul.ulmenu { border: 1px solid #ccc; text-shadow: none; } +.ui-body-c .ui-link, .ui-body-c .ui-link:visited, .ui-body-c .ui-link:hover { + color: rgb(); +} .ui-btn-up-c .vsmenudisabled { color: # !important; text-shadow: none !important; } +.ui-controlgroup-horizontal .ui-btn.ui-first-child { +-webkit-border-top-left-radius: 6px; +border-top-left-radius: 6px; +} +.ui-controlgroup-horizontal .ui-btn.ui-last-child { +-webkit-border-top-right-radius: 6px; +border-top-right-radius: 6px; +} .alilevel1 { color: # !important; text-shadow: 1px 0px 1px #; @@ -2859,14 +2870,6 @@ ul.ulmenu { background-image: -o-linear-gradient( #ddd,#d1d1d1 ) !important; background-image: linear-gradient( #ddd,#d1d1d1 ) !important; } - -.overflowwithjm200 -{ - max-width: 200px; - overflow: hidden; - white-space: nowrap; -} - close(); diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 55de6300de9..6d845a42c26 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -333,11 +333,11 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='') { $product=new Product($db); $result=$product->fetch($id,$ref,$ref_ext); - + if ($result > 0) { $product->load_stock(); - + $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); $pdir = get_exdir($product->id,2) . $product->id ."/photos/"; $dir = $dir . '/'. $pdir; @@ -552,7 +552,7 @@ function updateProductOrService($authentication,$product) $newobject=new Product($db); $newobject->fetch($product['id']); - + if (isset($product['ref'])) $newobject->ref=$product['ref']; if (isset($product['ref_ext'])) $newobject->ref_ext=$product['ref_ext']; $newobject->type=$product['type']; @@ -741,7 +741,7 @@ function getProductsForCategory($authentication,$id) $sql .= " ORDER BY fk_".$field." ASC" ; - dol_syslog("GetProductsForCategory::get_type sql=".$sql); + dol_syslog("getProductsForCategory get id of product into category sql=".$sql); $res = $db->query($sql); if ($res) { diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index c6fffdcc59f..4742cf59b18 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -145,19 +145,25 @@ if ($resql) $other4=$other[3]; $other5=$other[4]; $substitutionarray=array( - '__ID__' => $obj->source_id, - '__EMAIL__' => $obj->email, - '__CHECK_READ__' => '', - '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', - '__MAILTOEMAIL__' => ''.$obj2->email.'', - '__LASTNAME__' => $obj2->lastname, - '__FIRSTNAME__' => $obj2->firstname, - '__OTHER1__' => $other1, - '__OTHER2__' => $other2, - '__OTHER3__' => $other3, - '__OTHER4__' => $other4, - '__OTHER5__' => $other5 + '__ID__' => $obj->source_id, + '__EMAIL__' => $obj->email, + '__CHECK_READ__' => '', + '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', + '__MAILTOEMAIL__' => ''.$obj2->email.'', + '__LASTNAME__' => $obj2->lastname, + '__FIRSTNAME__' => $obj2->firstname, + '__OTHER1__' => $other1, + '__OTHER2__' => $other2, + '__OTHER3__' => $other3, + '__OTHER4__' => $other4, + '__OTHER5__' => $other5 ); + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); + } complete_substitutions_array($substitutionarray,$langs); $newsubject=make_substitutions($subject,$substitutionarray); diff --git a/scripts/odt2pdf/odt2pdf.sh b/scripts/odt2pdf/odt2pdf.sh index 9268b4a680f..0599e4291c5 100755 --- a/scripts/odt2pdf/odt2pdf.sh +++ b/scripts/odt2pdf/odt2pdf.sh @@ -22,7 +22,7 @@ if [ -f "$1.odt" ] nbprocess=$(pgrep -c soffice) if [ $nbprocess -ne 1 ] then - soffice --invisible --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard --headless + soffice --invisible --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard --headless& retcode=$? if [ $retcode -ne 0 ] then diff --git a/test/phpunit/FunctionsTest.php b/test/phpunit/FunctionsTest.php index 1fa41f0c460..c58da9efa38 100755 --- a/test/phpunit/FunctionsTest.php +++ b/test/phpunit/FunctionsTest.php @@ -192,15 +192,30 @@ class FunctionsTest extends PHPUnit_Framework_TestCase */ public function testDolHtmlCleanLastBr() { + $input="A string\n"; + $after=dol_htmlcleanlastbr($input); + $this->assertEquals("A string",$after); + + $input="A string first\nA string second\n"; + $after=dol_htmlcleanlastbr($input); + $this->assertEquals("A string first\nA string second",$after); + + $input="A string\n\n\n"; + $after=dol_htmlcleanlastbr($input); + $this->assertEquals("A string",$after); + $input="A string
"; $after=dol_htmlcleanlastbr($input); $this->assertEquals("A string",$after); + $input="A string first
\nA string second
"; $after=dol_htmlcleanlastbr($input); $this->assertEquals("A string first
\nA string second",$after); + $input="A string\n
\n"; $after=dol_htmlcleanlastbr($input); $this->assertEquals("A string",$after); + $input="A string\n

\n\n"; $after=dol_htmlcleanlastbr($input); $this->assertEquals("A string",$after); @@ -215,22 +230,44 @@ class FunctionsTest extends PHPUnit_Framework_TestCase */ public function testDolHtmlEntitiesBr() { - $input="A string\nwith a é, &, < and >."; // Text not already HTML + // Text not already HTML + + $input="A string\nwith a é, &, < and >."; $after=dol_htmlentitiesbr($input,0); // Add
before \n $this->assertEquals("A string
\nwith a é, &, < and >.",$after); - $input="A string\nwith a é, &, < and >."; // Text not already HTML + $input="A string\nwith a é, &, < and >."; $after=dol_htmlentitiesbr($input,1); // Replace \n with
$this->assertEquals("A string
with a é, &, < and >.",$after); - $input="A string
\nwith a é, &, < and >."; // Text already HTML, so &,<,> should not be converted + $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned + $after=dol_htmlentitiesbr($input,0); // Add
before \n + $this->assertEquals("A string
\nwith a é, &, < and >.",$after); + + $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned + $after=dol_htmlentitiesbr($input,1); // Replace \n with
+ $this->assertEquals("A string
with a é, &, < and >.",$after); + + // Text already HTML, so &,<,> should not be converted + + $input="A string
\nwith a é, &, < and >."; $after=dol_htmlentitiesbr($input); $this->assertEquals("A string
\nwith a é, &, < and >.",$after); - $input="
  • \nA string with a é, &, < and >.
  • \nAnother string"; // Text already HTML, so &,<,> should not be converted + $input="
  • \nA string with a é, &, < and >.
  • \nAnother string"; $after=dol_htmlentitiesbr($input); $this->assertEquals("
  • \nA string with a é, &, < and >.
  • \nAnother string",$after); + $input="A string
    \nwith a é, &, < and >.
    "; // With some
    at end that should be cleaned + $after=dol_htmlentitiesbr($input); + $this->assertEquals("A string
    \nwith a é, &, < and >.",$after); + + $input="
  • \nA string with a é, &, < and >.
  • \nAnother string
    "; // With some
    at end that should be cleaned + $after=dol_htmlentitiesbr($input); + $this->assertEquals("
  • \nA string with a é, &, < and >.
  • \nAnother string",$after); + + // TODO Add test with param $removelasteolbr = 0 + return true; } diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php new file mode 100644 index 00000000000..017f4affbc6 --- /dev/null +++ b/test/phpunit/PaypalTest.php @@ -0,0 +1,146 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file test/phpunit/PaypalTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/geturl.lib.php'; +require_once dirname(__FILE__).'/../../htdocs/paypal/lib/paypal.lib.php'; + +if (empty($user->id)) +{ + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class PaypalTest extends PHPUnit_Framework_TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return ProductTest + */ + function __construct() + { + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + + if (empty($conf->paypal->enabled)) { print __METHOD__." Module Paypal must be enabled.\n"; die(); } + + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; + } + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + /** + * testProductCreate + * + * @return void + */ + public function testPaypalOk() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $urltotest=getPaypalPaymentUrl(1,'free'); + print "urltotest=".$urltotest."\n"; + + $result=getURLContent($urltotest, 'GET'); + + print __METHOD__." result=".$result."\n"; + $this->assertLessThanOrEqual($result, 0); + + return $result; + } + +} +?> \ No newline at end of file