diff --git a/COPYRIGHT b/COPYRIGHT index 959acc9eb2a..c838353b740 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -12,8 +12,7 @@ Composant Version License Compatible GPL Usage ---------------------------------------------------------------------------- PHP libraries: AdoDb-Date 0.21 Modified BSD License Yes Date convertion (not into rpm package) -ArtiChow 1.07 Public Domain Yes Graphics -CKEditor 3.6.1 GPL or LGPL 2.1 or MPL 1.1 Yes Editor WYSIWYG +CKEditor 3.6.2 GPL or LGPL 2.1 or MPL 1.1 Yes Editor WYSIWYG FPDI 1.4.1 Apache Software License 2.0 ? PDF templates management GeoIP 2004 LGPL 2.1 Yes Sample code to make geoip convert (not into deb package) NuSoap 0.9.5 LGPL 2.1 Yes Library to develop SOAP Web services (not into rpm and deb package) diff --git a/ChangeLog b/ChangeLog index 92e60740ea0..3d54d0197c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ WARNING: Because of a major datastructure change onto supplier prices tabkes, be to make a backup of your database before making upgrade. For users: +- New: Each user can remove/add its own boxes. - New: Can use personalized fields of products/services. - New: Can attach files on social contributions. - New: Show payments terms and conditions onto muscadet template. @@ -52,6 +53,7 @@ For users: - New: Default output charset are utf8 into backup tool. - New: Add brazilian states. - New: Increase usability of module project. +- New: [ task #285 ] Add search filter on project in tasks list. - New: Automatic list of documents in ECM module is ok for customers, suppliers invoice, orders, customers orders, proposals and social contributions. - New: All professional id can contains up to 128 chars instead of 32. @@ -78,6 +80,7 @@ For developers: - New: A page can force reload of css style sheet - New: A module can add import description for import wizard, even for tables with foreign keys. - New: Can add tabs on statistics views. +- New: Add CSS id/class into public payment pages. - Qual: Add a lot of more PHPUnit tests. - Qual: Data structure for supplier prices is simpler. - Qual: Removed no more used external libraries. diff --git a/build.xml b/build.xml index 0394e263846..fbfd6c3f4f6 100644 --- a/build.xml +++ b/build.xml @@ -2,7 +2,7 @@ - + @@ -43,6 +43,7 @@ + \ No newline at end of file diff --git a/build/debian/dolibarr.lintian-overrides b/build/debian/dolibarr.lintian-overrides index 32dfaadc8ef..019115d037a 100755 --- a/build/debian/dolibarr.lintian-overrides +++ b/build/debian/dolibarr.lintian-overrides @@ -1,4 +1 @@ -# Embedded libraries, which don't seem to be available in Debian in correct version -# or because they were modified and are specific dolibarr code -# -# There is no embeded library in this package that are available into other Debian packages. +# No overrided lintian rules is this version. diff --git a/build/debian/dolibarr.postinst b/build/debian/dolibarr.postinst index cdee802e986..91e3d9346e8 100644 --- a/build/debian/dolibarr.postinst +++ b/build/debian/dolibarr.postinst @@ -83,15 +83,29 @@ case "$1" in chown -R root:www-data $installconfig chmod -R 660 $installconfig - # Create an empty conf.php with permission to web server if [ ! -f $config ] then + # Create an empty conf.php with permission to web server echo Create empty file $config touch $config - chown -R root:www-data $config chmod -R 660 $config + chown -R root:www-data $config + else + # File already exist. We add params not found. + // Add new params to overwrite path to use shared libraries/fonts + grep -q -c "dolibarr_lib_ADODB_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_FPDI_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || echo "" >> $config + grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "" >> $config + grep -q -c "dolibarr_js_CKEDITOR" $config || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY" $config || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_UI" $config || echo "" >> $config + grep -q -c "dolibarr_js_JQUERY_FLOT" $config || echo "" >> $config + grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "" >> $config fi - db_get dolibarr/reconfigure-webserver diff --git a/build/rpm/conf.php b/build/rpm/conf.php index 78ac824b12f..2e8bd46cf0f 100755 --- a/build/rpm/conf.php +++ b/build/rpm/conf.php @@ -1,8 +1,8 @@ \ No newline at end of file diff --git a/dev/codesniffer/jenkins_ruleset.xml b/dev/codesniffer/jenkins_ruleset.xml index eee5cef0284..3d3b037d3a0 100755 --- a/dev/codesniffer/jenkins_ruleset.xml +++ b/dev/codesniffer/jenkins_ruleset.xml @@ -89,7 +89,7 @@ - + @@ -191,6 +191,9 @@ + + 0 + 0 diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml index 19576d8313e..53fd15787ab 100755 --- a/dev/codesniffer/ruleset.xml +++ b/dev/codesniffer/ruleset.xml @@ -89,7 +89,7 @@ - + @@ -191,6 +191,9 @@ + + 0 + 0 diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 60bc466a907..f9901feb7bd 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -87,10 +87,6 @@ class modMyModule extends DolibarrModules // Data directories to create when module is enabled. // Example: this->dirs = array("/mymodule/temp"); $this->dirs = array(); - $r=0; - - // Relative path to module style sheet if exists. Example: '/mymodule/css/mycss.css'. - //$this->style_sheet = '/mymodule/mymodule.css.php'; // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. $this->config_page_url = array("mysetuppage.php@mymodule"); diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index 4c9a22b1ecf..9e331e72b2f 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -109,7 +109,6 @@ jQuery(document).ready(function() { { jQuery("#myid").removeAttr(\'disabled\'); jQuery("#myid").attr(\'disabled\',\'disabled\'); - } } init_myfunc(); jQuery("#mybutton").click(function() { @@ -125,6 +124,6 @@ $somethingshown=$myobject->showLinkedObjectBlock(); // End of page -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/dev/translation/autotranslator.class.php b/dev/translation/autotranslator.class.php index b6fbe202ba1..c111fdd1bd5 100644 --- a/dev/translation/autotranslator.class.php +++ b/dev/translation/autotranslator.class.php @@ -27,34 +27,34 @@ */ class autoTranslator { - private $translatedFiles = array(); - private $destLang = ''; - private $refLang = ''; - private $langDir = ''; - private $limittofile = ''; - private $time; - private $time_end; - private $outputpagecode = 'UTF-8'; - private $apikey; - //private $outputpagecode = 'ISO-8859-1'; + private $_translatedFiles = array(); + private $_destlang = ''; + private $_refLang = ''; + private $_langDir = ''; + private $_limittofile = ''; + private $_time; + private $_time_end; + private $_outputpagecode = 'UTF-8'; + private $_apikey; + //private $_outputpagecode = 'ISO-8859-1'; const DIR_SEPARATOR = '/'; - function __construct($destLang,$refLang,$langDir,$limittofile,$apikey) + function __construct($_destlang,$_refLang,$_langDir,$_limittofile,$_apikey) { // Set enviorment variables - $this->destLang = $destLang; - $this->refLang = $refLang; - $this->langDir = $langDir.self::DIR_SEPARATOR; - $this->time = date('Y-m-d H:i:s'); - $this->limittofile = $limittofile; - $this->apikey = $apikey; + $this->_destlang = $_destlang; + $this->_refLang = $_refLang; + $this->_langDir = $_langDir.self::DIR_SEPARATOR; + $this->_time = date('Y-m-d H:i:s'); + $this->_limittofile = $_limittofile; + $this->_apikey = $_apikey; // Translate //ini_set('default_charset','UTF-8'); - ini_set('default_charset',$this->outputpagecode); - $this->parseRefLangTranslationFiles(); + ini_set('default_charset',$this->_outputpagecode); + $this->parse_refLangTranslationFiles(); } @@ -63,31 +63,31 @@ class autoTranslator * * @return void */ - private function parseRefLangTranslationFiles() + private function parse_refLangTranslationFiles() { - $files = $this->getTranslationFilesArray($this->refLang); + $files = $this->getTranslationFilesArray($this->_refLang); $counter = 1; foreach($files as $file) { - if ($this->limittofile && $this->limittofile != $file) continue; + if ($this->_limittofile && $this->_limittofile != $file) continue; $counter++; $fileContent = null; - $refPath = $this->langDir.$this->refLang.self::DIR_SEPARATOR.$file; + $refPath = $this->_langDir.$this->_refLang.self::DIR_SEPARATOR.$file; $fileContent = file($refPath,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); print "Processing file " . $file . ", with ".count($fileContent)." lines
\n"; // Define target dirs - $targetlangs=array($this->destLang); - if ($this->destLang == 'all') + $targetlangs=array($this->_destlang); + if ($this->_destlang == 'all') { $targetlangs=array(); // If we must process all languages - $arraytmp=dol_dir_list($this->langDir,'directories',0); + $arraytmp=dol_dir_list($this->_langDir,'directories',0); foreach($arraytmp as $dirtmp) { - if ($dirtmp['name'] === $this->refLang) continue; // We discard source language + if ($dirtmp['name'] === $this->_refLang) continue; // We discard source language $tmppart=explode('_',$dirtmp['name']); if (preg_match('/^en/i',$dirtmp['name'])) continue; // We discard en_* languages if (preg_match('/^fr/i',$dirtmp['name'])) continue; // We discard fr_* languages @@ -103,17 +103,17 @@ class autoTranslator } // Process translation of source file for each target languages - foreach($targetlangs as $mydestLang) + foreach($targetlangs as $my_destlang) { - $this->translatedFiles = array(); + $this->_translatedFiles = array(); - $destPath = $this->langDir.$mydestLang.self::DIR_SEPARATOR.$file; + $destPath = $this->_langDir.$my_destlang.self::DIR_SEPARATOR.$file; // Check destination file presence if (! file_exists($destPath)) { // No file present, we generate file echo "File not found: " . $destPath . ". We generate it.
\n"; - $this->createTranslationFile($destPath,$mydestLang); + $this->createTranslationFile($destPath,$my_destlang); } else { @@ -128,11 +128,11 @@ class autoTranslator $value = $this->getLineValue($line); if ($key && $value) { - $newlines+=$this->translateFileLine($fileContentDest,$file,$key,$value,$mydestLang); + $newlines+=$this->translateFileLine($fileContentDest,$file,$key,$value,$my_destlang); } } - $this->updateTranslationFile($destPath,$file,$mydestLang); + $this->updateTranslationFile($destPath,$file,$my_destlang); echo "New translated lines: " . $newlines . "
\n"; //if ($counter ==3) die('fim'); } @@ -144,24 +144,24 @@ class autoTranslator * * @param string $destPath Target path * @param string $file File - * @param string $mydestLang Target language code + * @param string $my_destlang Target language code * @return void */ - private function updateTranslationFile($destPath,$file,$mydestLang) + private function updateTranslationFile($destPath,$file,$my_destlang) { - $this->time_end = date('Y-m-d H:i:s'); + $this->_time_end = date('Y-m-d H:i:s'); - if (count($this->translatedFiles[$file])>0) + if (count($this->_translatedFiles[$file])>0) { $fp = fopen($destPath, 'a'); fwrite($fp, "\r\n"); fwrite($fp, "\r\n"); - fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->time.").\r\n"); - fwrite($fp, "// Reference language: ".$this->refLang." -> ".$mydestLang."\r\n"); - foreach( $this->translatedFiles[$file] as $line) { + fwrite($fp, "// START - Lines generated via autotranslator.php tool (".$this->_time.").\r\n"); + fwrite($fp, "// Reference language: ".$this->_refLang." -> ".$my_destlang."\r\n"); + foreach( $this->_translatedFiles[$file] as $line) { fwrite($fp, $line . "\r\n"); } - fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->time_end.").\r\n"); + fwrite($fp, "// STOP - Lines generated via autotranslator.php tool (".$this->_time_end.").\r\n"); fclose($fp); } return; @@ -171,32 +171,32 @@ class autoTranslator * Create a new translation file * * @param string $path Path - * @param string $mydestlang Target language code + * @param string $my_destlang Target language code * @return void */ - private function createTranslationFile($path,$mydestlang) + private function createTranslationFile($path,$my_destlang) { $fp = fopen($path, 'w+'); fwrite($fp, "/*\r\n"); - fwrite($fp, " * Language code: {$mydestlang}\r\n"); + fwrite($fp, " * Language code: {$my_destlang}\r\n"); fwrite($fp, " * Automatic generated via autotranslator.php tool\r\n"); - fwrite($fp, " * Generation date " . $this->time. "\r\n"); + fwrite($fp, " * Generation date " . $this->_time. "\r\n"); fwrite($fp, " */\r\n"); fclose($fp); return; } /** - * Put in array translatedFiles[$file], line of a new tranlated pair + * Put in array _translatedFiles[$file], line of a new tranlated pair * * @param string $content Existing content of dest file * @param string $file Target file name translated (xxxx.lang) * @param string $key Key to translate * @param string $value Existing value in source file - * @param string $mydestLang Language code (ie: fr_FR) + * @param string $my_destlang Language code (ie: fr_FR) * @return int 0=Nothing translated, 1=Record translated */ - private function translateFileLine($content,$file,$key,$value,$mydestLang) + private function translateFileLine($content,$file,$key,$value,$my_destlang) { //print "key =".$key."\n"; @@ -211,21 +211,21 @@ class autoTranslator } } - if ($key == 'CHARSET') $val=$this->outputpagecode; + if ($key == 'CHARSET') $val=$this->_outputpagecode; else if (preg_match('/^Format/',$key)) $val=$value; else if ($value=='-') $val=$value; else { // If not translated then translate - if ($this->outputpagecode == 'UTF-8') $val=$this->translateTexts(array($value),substr($this->refLang,0,2),substr($mydestLang,0,2)); - else $val=utf8_decode($this->translateTexts(array($value),substr($this->refLang,0,2),substr($mydestLang,0,2))); + if ($this->_outputpagecode == 'UTF-8') $val=$this->translateTexts(array($value),substr($this->_refLang,0,2),substr($my_destlang,0,2)); + else $val=utf8_decode($this->translateTexts(array($value),substr($this->_refLang,0,2),substr($my_destlang,0,2))); } $val=trim($val); if (empty($val)) return 0; - $this->translatedFiles[$file][] = $key . '=' . $val ; + $this->_translatedFiles[$file][] = $key . '=' . $val ; return 1; } @@ -261,7 +261,7 @@ class autoTranslator */ private function getTranslationFilesArray($lang) { - $dir = new DirectoryIterator($this->langDir.$lang); + $dir = new DirectoryIterator($this->_langDir.$lang); while($dir->valid()) { if(!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./',$dir->getFilename())) { $files[] = $dir->getFilename(); @@ -297,8 +297,8 @@ class autoTranslator //$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair); // Example: http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Setup%20area&langpair=en_US|fr_FR // Define GET URL v2 - $url = "https://www.googleapis.com/language/translate/v2?key=".$this->apikey."&q=".urlencode($src_text_to_translate)."&source=".urlencode($src_lang)."&target=".urlencode($dest_lang); - // Example: https://www.googleapis.com/language/translate/v2?key=APIKEY&q=Setup%20area&source=en_US&target=fr_FR + $url = "https://www.googleapis.com/language/translate/v2?key=".$this->_apikey."&q=".urlencode($src_text_to_translate)."&source=".urlencode($src_lang)."&target=".urlencode($dest_lang); + // Example: https://www.googleapis.com/language/translate/v2?key=_apikey&q=Setup%20area&source=en_US&target=fr_FR // Send request //print "Url to translate: ".$url."\n"; diff --git a/dev/translation/autotranslator.php b/dev/translation/autotranslator.php index f99fc48f5ca..eb8250c1754 100644 --- a/dev/translation/autotranslator.php +++ b/dev/translation/autotranslator.php @@ -55,7 +55,7 @@ print "***** ".$script_file." (".$version.") *****\n"; $dir=DOL_DOCUMENT_ROOT."/langs"; // Check parameters -if (! isset($argv[2])) { +if (! isset($argv[3])) { print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n"; print "Example: ".$script_file." en_US pt_PT 123456\n"; print "Rem: lang_code to use can be found on http://www.google.com/language_tools\n"; diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 8d33ae52e5a..82f817e2f21 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -972,7 +972,7 @@ if ($rowid) $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); $texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); - $tmp='global->ADHERENT_DEFAULT_SENDINFOBYMAIL?' checked="checked"':'').'>'; + $tmp='global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked="checked"':'').'>'; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent.=''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 105c4c2485e..778835bbb67 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1741,7 +1741,6 @@ class Adherent extends CommonObject /** * Return full address of member * - * * @param int $withcountry 1=Add country into address string * @param string $sep Separator to use to build string * @return string Full address string diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 2e7a4bdde0c..8b2a12a7217 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -24,6 +24,7 @@ require("../main.inc.php"); include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/infobox.class.php"); include_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); $langs->load("admin"); @@ -51,69 +52,110 @@ if ($action == 'addconst') if ($action == 'add') { - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."boxes"; - $sql.= " WHERE fk_user = 0"; - $sql.= " AND box_id = ".$_POST["boxid"]; - $sql.= " AND position = ".$_POST["pos"]; + $error=0; - $resql = $db->query($sql); - dol_syslog("boxes.php::search if box active sql=".$sql); - if ($resql) + $db->begin(); + + // Initialize distinctfkuser with all already existing values of fk_user (user that use a personalized view of boxes for pos) + $distinctfkuser=array(); + if (! $error) { - $num = $db->num_rows($resql); - if ($num == 0) + $sql = "SELECT fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."user_param"; + $sql.= " WHERE param = 'MAIN_BOXES_".$db->escape(GETPOST("pos","alpha"))."' AND value = '1'"; + $sql.= " AND entity = ".$conf->entity; + $resql = $db->query($sql); + dol_syslog("boxes.php search fk_user to activate box for sql=".$sql); + if ($resql) { - $db->begin(); - - // Si la boite n'est pas deja active, insert with box_order='' - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; - $sql.= "box_id"; - $sql.= ", position"; - $sql.= ", box_order"; - $sql.= ", fk_user"; - $sql.= ") values ("; - $sql.= $_POST["boxid"]; - $sql.= ", ".$_POST["pos"]; - $sql.= ", ''"; - $sql.= ", 0"; - $sql.= ")"; - - dol_syslog("boxes.php activate box sql=".$sql); - $resql = $db->query($sql); - - // Remove all personalized setup when a box is activated or disabled - $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; - $sql.= " WHERE param LIKE 'MAIN_BOXES_%'"; - dol_syslog("boxes.php delete user_param sql=".$sql); - $resql = $db->query($sql); - - $db->commit(); + $num = $db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj=$db->fetch_object($resql); + $distinctfkuser[$obj->fk_user]=$obj->fk_user; + $i++; + } } + else + { + $errmesg=$db->lasterror(); + $error++; + } + } + foreach($distinctfkuser as $fk_user) + { + if (! $error && $fk_user != 0) // We will add fk_user = 0 later. + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; + $sql.= "box_id, position, box_order, fk_user"; + $sql.= ") values ("; + $sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', ".$fk_user; + $sql.= ")"; + + dol_syslog("boxes.php activate box sql=".$sql); + $resql = $db->query($sql); + if (! $resql) + { + $errmesg=$db->lasterror(); + $error++; + } + } + } + + // If value 0 was not included, we add it. + if (! $error) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; + $sql.= "box_id, position, box_order, fk_user"; + $sql.= ") values ("; + $sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', 0"; + $sql.= ")"; + + dol_syslog("boxes.php activate box sql=".$sql); + $resql = $db->query($sql); + if (! $resql) + { + $errmesg=$db->lasterror(); + $error++; + } + } + + if (! $error) + { Header("Location: boxes.php"); + $db->commit(); exit; } else { - dol_print_error($db); + $db->rollback(); } } if ($action == 'delete') { - $db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; + $sql = "SELECT box_id FROM ".MAIN_DB_PREFIX."boxes"; $sql.= " WHERE rowid=".$rowid; $resql = $db->query($sql); + $obj=$db->fetch_object($resql); + if (! empty($obj->box_id)) + { + $db->begin(); - // Remove all personalized setup when a box is activated or disabled - $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; - $sql.= " WHERE param LIKE 'MAIN_BOXES_%'"; - $resql = $db->query($sql); + // Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes) + // $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; + // $sql.= " WHERE param LIKE 'MAIN_BOXES_%'"; + // $resql = $db->query($sql); - $db->commit(); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; + $sql.= " WHERE box_id=".$obj->box_id; + $resql = $db->query($sql); + + $db->commit(); + } } if ($action == 'switch') @@ -154,12 +196,19 @@ if ($action == 'switch') * View */ +$form=new Form($db); +$emptyuser=new User($db); +//$infobox=new InfoBox($db); + llxHeader('',$langs->trans("Boxes")); print_fiche_titre($langs->trans("Boxes"),'','setup'); print $langs->trans("BoxesDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; +dol_htmloutput_errors($errmesg); + + /* * Recherche des boites actives par defaut pour chaque position possible * On stocke les boites actives par defaut dans $boxes[position][id_boite]=1 @@ -195,20 +244,21 @@ if ($resql) // This occurs just after an insert. if ($decalage) { - $sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$decalage." WHERE rowid=".$obj->rowid; + $sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$decalage."' WHERE rowid=".$obj->rowid; $db->query($sql); } } if ($decalage) { - // Si on a renumerote, on corrige champ box_order + // Si on a renumerote, on corrige champ box_order // This occurs just after an insert. $sql = "SELECT box_order"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes"; $sql.= " WHERE length(box_order) <= 2"; - $result = $db->query($sql); + dol_syslog("Execute requests to renumber box order sql=".$sql); + $result = $db->query($sql); if ($result) { while ($record = $db->fetch_array($result)) @@ -218,13 +268,13 @@ if ($resql) if (preg_match("/[13579]{1}/",substr($record['box_order'],-1))) { $box_order = "A0".$record['box_order']; - $sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = ".$record['box_order']; + $sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'"; $resql = $db->query($sql); } else if (preg_match("/[02468]{1}/",substr($record['box_order'],-1))) { $box_order = "B0".$record['box_order']; - $sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = ".$record['box_order']; + $sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'"; $resql = $db->query($sql); } } @@ -233,13 +283,13 @@ if ($resql) if (preg_match("/[13579]{1}/",substr($record['box_order'],-1))) { $box_order = "A".$record['box_order']; - $sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = ".$record['box_order']; + $sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'"; $resql = $db->query($sql); } else if (preg_match("/[02468]{1}/",substr($record['box_order'],-1))) { $box_order = "B".$record['box_order']; - $sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = ".$record['box_order']; + $sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'"; $resql = $db->query($sql); } } @@ -251,6 +301,7 @@ if ($resql) // Available boxes +$boxtoadd=InfoBox::listboxes($db,'available',-1,$emptyuser,$actives); print "
\n"; print_titre($langs->trans("BoxesAvailable")); @@ -262,103 +313,45 @@ print ''.$langs->trans("Note").'/'.$langs->trans("Parameters").''; print ''.$langs->trans("SourceFile").''; print ''.$langs->trans("ActivateOn").''; print "\n"; - -$sql = "SELECT rowid, file, note, tms"; -$sql.= " FROM ".MAIN_DB_PREFIX."boxes_def"; -$sql.= " WHERE entity = ".$conf->entity; -$resql = $db->query($sql); $var=true; - -if ($resql) +foreach($boxtoadd as $box) { - $form=new Form($db); + $var=!$var; - $num = $db->num_rows($resql); - $i = 0; + if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg)) + { + $logo = $box->boximg; + } + else + { + $logo=preg_replace("/^object_/i","",$box->boximg); + } - // Boucle sur toutes les boites - while ($i < $num) - { - $obj = $db->fetch_object($resql); + print "\n".''."\n"; + print '
'; + print ''; + print ''; + print ''.img_object("",$logo).' '.$box->boxlabel.''; + print '' . ($box->note?$box->note:' ') . ''; + print '' . $box->sourcefile . ''; - if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs)) - { - $boxname = $regs[1]; - $module = $regs[2]; - $sourcefile = "/".$module."/core/boxes/".$boxname.".php"; - } - else - { - $boxname=preg_replace('/.php$/i','',$obj->file); - $sourcefile = "/core/boxes/".$boxname.".php"; - } + // Pour chaque position possible, on affiche un lien d'activation si boite non deja active pour cette position + print ''; + print $form->selectarray("pos",$pos_name); + print ''; + print ''; + print ' '; + print ''; - dol_include_once($sourcefile); - if (class_exists($boxname)) - { - $box=new $boxname($db,$obj->note); - - $enabled=true; - if ($box->depends && count($box->depends) > 0) - { - foreach($box->depends as $module) - { - if (empty($conf->$module->enabled)) $enabled=false; - } - } - - if ($enabled) - { - //if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1) - if (in_array($obj->rowid, $actives)) - { - // La boite est deja activee - } - else - { - $var=!$var; - - if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg)) - { - $logo = $box->boximg; - } - else - { - $logo=preg_replace("/^object_/i","",$box->boximg); - } - - print "\n".''."\n"; - print ''; - print ''; - print ''; - print ''.img_object("",$logo).' '.$box->boxlabel.''; - print '' . ($obj->note?$obj->note:' ') . ''; - print '' . $sourcefile . ''; - - // Pour chaque position possible, on affiche un lien - // d'activation si boite non deja active pour cette position - print ''; - print $form->selectarray("pos",$pos_name); - print ''; - print ''; - print ' '; - print ''; - - print '
'; - } - } - } - - $i++; - } - - $db->free($resql); + print ''; + print ''; } print ''; // Activated boxes +$boxactivated=InfoBox::listboxes($db,'activated',-1,$emptyuser); print "
\n\n"; print_titre($langs->trans("BoxesActivated")); @@ -372,89 +365,39 @@ print ''.$langs->trans("PositionByDefa print ''.$langs->trans("Disable").''; print ''."\n"; -$sql = "SELECT b.rowid, b.box_id, b.position,"; -$sql.= " bd.file, bd.note, bd.tms"; -$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd"; -$sql.= " WHERE b.box_id = bd.rowid"; -$sql.= " AND bd.entity = ".$conf->entity; -$sql.= " AND b.fk_user=0"; -$sql.= " ORDER by b.position, b.box_order"; // Note box_order return A01,A03...,B02,B04... - -$resql = $db->query($sql); - -if ($resql) +$var=true; +$box_order=1; +$foundrupture=1; +foreach($boxactivated as $key => $box) { - $num = $db->num_rows($resql); - $i = 0; - $var=true; + $var = ! $var; - $box_order=1; - $foundrupture=1; - - // On lit avec un coup d'avance - $obj = $db->fetch_object($resql); - - while ($obj && $i < $num) + if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg)) { - $var = ! $var; - $objnext = $db->fetch_object($resql); - - if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs)) - { - $boxname = $regs[1]; - $module = $regs[2]; - $sourcefile = "/".$module."/core/boxes/".$boxname.".php"; - } - else - { - $boxname=preg_replace('/.php$/i','',$obj->file); - $sourcefile = "/core/boxes/".$boxname.".php"; - } - - dol_include_once($sourcefile); - if (class_exists($boxname)) - { - $box=new $boxname($db,$obj->note); - - if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg)) - { - $logo = $box->boximg; - } - else - { - $logo=preg_replace("/^object_/i","",$box->boximg); - } - - print "\n".''."\n"; - print ''; - print ''.img_object("",$logo).' '.$box->boxlabel.''; - print '' . ($obj->note?$obj->note:' ') . ''; - print '' . $pos_name[$obj->position] . ''; - $hasnext=true; - $hasprevious=true; - if ($foundrupture) { $hasprevious=false; $foundrupture=0; } - if (! $objnext || $obj->position != $objnext->position) { $hasnext=false; $foundrupture=1; } - print ''.$box_order.''; - print ''; - print ($hasnext?''.img_down().' ':''); - print ($hasprevious?''.img_up().'':''); - print ''; - print ''; - print ''.img_delete().''; - print ''; - - print ''."\n"; - } - $i++; - - $box_order++; - - if (! $foundrupture) $objprevious = $obj; - else $box_order=1; - $obj=$objnext; + $logo = $box->boximg; + } + else + { + $logo=preg_replace("/^object_/i","",$box->boximg); } - $db->free($resql); + print "\n".''."\n"; + print ''; + print ''.img_object("",$logo).' '.$box->boxlabel.''; + print '' . ($box->note?$box->note:' ') . ''; + print '' . $pos_name[$box->position] . ''; + $hasnext=($key < (count($boxactivated)-1)); + $hasprevious=($key != 0); + print ''.($key+1).''; + print ''; + print ($hasnext?''.img_down().' ':''); + print ($hasprevious?''.img_up().'':''); + print ''; + print ''; + print ''.img_delete().''; + print ''; + + print ''."\n"; } print '
'; @@ -490,7 +433,7 @@ print ''; print ''; -$db->close(); - llxFooter(); + +$db->close(); ?> diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 2ace9e20590..67b6f9ac83b 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2010 Juanjo Menent - * Copyright (C) 2011 Philippe Grand +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2011 Philippe Grand * * 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 @@ -269,8 +270,8 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit') * Edition des parametres */ print "\n".' diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 99e0d8f0ecd..325d1c834bc 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -33,6 +33,8 @@ if (! $user->admin) accessforbidden(); * View */ +$label=getStaticMember($db, 'label'); + $help_url='EN:Restores|FR:Restaurations|ES:Restauraciones'; llxHeader('','',$help_url); @@ -48,6 +50,10 @@ jQuery(document).ready(function() { jQuery("#radio_dump_postgresql").click(function() { jQuery("#postgresql_options").show(); }); + }); trans("RestoreDesc",DOL_DATA_ROOT).'

'; print $langs->trans("RestoreDesc2",DOL_DATA_ROOT).'

'; print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'

'; -$label=getStaticMember($db, 'label'); - ?>
@@ -166,7 +170,7 @@ else if ($label == 'PostgreSQL') print '
'; print '
'; - if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
'.$langs->trans("UnHidePassword").''; + //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
'.$langs->trans("UnHidePassword").''; //else print '
'.$langs->trans("HidePassword").''; ?> diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php new file mode 100755 index 00000000000..a80406f4ce0 --- /dev/null +++ b/htdocs/admin/translation.php @@ -0,0 +1,72 @@ + + * Copyright (C) 2009 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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/admin/translation.php + * \brief Page to show translation information + */ + +require("../main.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); + +$langs->load("companies"); +$langs->load("products"); +$langs->load("admin"); +$langs->load("sms"); +$langs->load("other"); +$langs->load("errors"); + +if (!$user->admin) accessforbidden(); + + +$action=GETPOST('action'); + + +/* + * Actions + */ + +// None + + + +/* + * View + */ + +$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración'; +llxHeader('',$langs->trans("Setup"),$wikihelp); + +print_fiche_titre($langs->trans("TranslationSetup"),'','setup'); + +print $langs->trans("TranslationDesc")."
\n"; +print "
\n"; + +dol_htmloutput_mesg($message); + +print $langs->trans("CurrentUserLanguage").': '.$langs->defaultlang.'
'; +print img_warning().' '.$langs->trans("SomeTranslationAreUncomplete").'
'; + +$urlwikitranslatordoc='http://wiki.dolibarr.org/index.php/Translator_documentation'; +print $langs->trans("SeeAlso").': '.$urlwikitranslatordoc.'
'; + + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/boxes.php b/htdocs/boxes.php deleted file mode 100644 index c83a37ef87e..00000000000 --- a/htdocs/boxes.php +++ /dev/null @@ -1,429 +0,0 @@ - - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 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/boxes.php - * \brief File of class to manage widget boxes - * \author Rodolphe Qiedeville - * \author Laurent Destailleur - */ - - - -/** - * Show a HTML Tab with boxes of a particular area including personalized choices of user - * - * @param User $user Object User - * @param String $areacode Code of area for pages (0=value for Home page) - * @return int <0 if KO, Nb of boxes shown of OK (0 to n) - */ -function printBoxesArea($user,$areacode) -{ - global $conf,$langs,$db; - - $infobox=new InfoBox($db); - $boxarray=$infobox->listboxes($areacode,$user); - - if (count($boxarray)) - { - print load_fiche_titre($langs->trans("OtherInformationsBoxes"),'','','','otherboxes'); - print ''; - print '"; - print "
'."\n"; - - print '
'; - - print "\n\n"; - print '
'."\n"; - - // Define $box_max_lines - $box_max_lines=5; - if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES; - - $ii=0; - foreach ($boxarray as $key => $box) - { - if (preg_match('/^A/i',$box->box_order)) // column A - { - $ii++; - //print 'box_id '.$boxarray[$ii]->box_id.' '; - //print 'box_order '.$boxarray[$ii]->box_order.'
'; - // Affichage boite key - $box->loadBox($box_max_lines); - $box->showBox(); - } - } - - $emptybox=new ModeleBoxes($db); - $emptybox->box_id='A'; - $emptybox->info_box_head=array(); - $emptybox->info_box_contents=array(); - $emptybox->showBox(array(),array()); - - print "
\n"; - print "\n"; - - print '
'; - - print "\n\n"; - print '\n"; - print "\n"; - - print '
'; - print "\n"; - - print "
"; - - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''."\n"; - } - } - - return count($boxarray); -} - - - -/** - * Class to manage boxes on pages - */ -class InfoBox -{ - var $db; - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - function InfoBox($db) - { - $this->db=$db; - } - - - /** - * Return array of boxes qualified for area and user - * - * @param string $zone Name or area (0 for Homepage, ...) - * @param User $user Objet user - * @return array Array of boxes - */ - function listBoxes($zone,$user) - { - global $conf; - - $boxes=array(); - - $confuserzone='MAIN_BOXES_'.$zone; - if ($user->id && $user->conf->$confuserzone) - { - // Get list of boxes of a particular user (if this one has its own list) - $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user,"; - $sql.= " d.file, d.note"; - $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE b.box_id = d.rowid"; - $sql.= " AND d.entity = ".$conf->entity; - $sql.= " AND b.position = ".$zone; - $sql.= " AND b.fk_user = ".$user->id; - $sql.= " ORDER BY b.box_order"; - - dol_syslog("InfoBox::listBoxes get user box list sql=".$sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $j = 0; - while ($j < $num) - { - $obj = $this->db->fetch_object($result); - - if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs)) - { - $boxname = $regs[1]; - $module = $regs[2]; - $sourcefile = dol_buildpath("/".$module."/core/boxes/".$boxname.".php"); - } - else - { - $boxname=preg_replace('/\.php$/i','',$obj->file); - $sourcefile = "/core/boxes/".$boxname.".php"; - } - - dol_include_once($sourcefile); // Do not use dol_include_once here because sourcefile is already good fullpath - if (class_exists($boxname)) - { - $box=new $boxname($this->db,$obj->note); - - $box->rowid=$obj->rowid; - $box->box_id=$obj->box_id; - $box->position=$obj->position; - $box->box_order=$obj->box_order; - $box->fk_user=$obj->fk_user; - $enabled=true; - if ($box->depends && count($box->depends) > 0) - { - foreach($box->depends as $module) - { - //print $module.'
'; - if (empty($conf->$module->enabled)) $enabled=false; - } - } - if ($enabled) $boxes[]=$box; - } - $j++; - } - } - else - { - $this->error=$this->db->error(); - dol_syslog("InfoBox::listBoxes Error ".$this->error, LOG_ERR); - return array(); - } - } - else - { - // Recupere liste des boites active par defaut pour tous - $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user,"; - $sql.= " d.file, d.note"; - $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE b.box_id = d.rowid"; - $sql.= " AND d.entity = ".$conf->entity; - $sql.= " AND b.position = ".$zone; - $sql.= " AND b.fk_user = 0"; - $sql.= " ORDER BY b.box_order"; - - dol_syslog("InfoBox::listBoxes get default box list sql=".$sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $j = 0; - while ($j < $num) - { - $obj = $this->db->fetch_object($result); - - if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs)) - { - $boxname = $regs[1]; - $module = $regs[2]; - $relsourcefile = "/".$module."/core/boxes/".$boxname.".php"; - } - else - { - $boxname=preg_replace('/.php$/i','',$obj->file); - $relsourcefile = "/core/boxes/".$boxname.".php"; - } - - dol_include_once($relsourcefile); - if (class_exists($boxname)) - { - $box=new $boxname($this->db,$obj->note); - - $box->rowid=$obj->rowid; - $box->box_id=$obj->box_id; - $box->position=$obj->position; - $box->box_order=$obj->box_order; - if (is_numeric($box->box_order)) - { - if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order; - elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order; - } - $box->fk_user=$obj->fk_user; - $enabled=true; - if ($box->depends && count($box->depends) > 0) - { - foreach($box->depends as $module) - { - //print $boxname.'-'.$module.'
'; - if (empty($conf->$module->enabled)) $enabled=false; - } - } - if ($enabled) $boxes[]=$box; - } - $j++; - } - } - else - { - $this->error=$this->db->error(); - dol_syslog("InfoBox::listBoxes Error ".$this->error, LOG_ERR); - return array(); - } - } - - return $boxes; - } - - - - /** - * Save order of boxes for area and user - * - * @param string $zone Name of area (0 for Homepage, ...) - * @param string $boxorder List of boxes with correct order 'A:123,456,...-B:789,321...' - * @param int $userid Id of user - * @return int <0 if KO, >= 0 if OK - */ - function saveboxorder($zone,$boxorder,$userid=0) - { - global $conf; - - $error=0; - - require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); - - dol_syslog("InfoBoxes::saveboxorder zone=".$zone." user=".$userid); - - if (! $userid || $userid == 0) return 0; - - $user = new User($this->db); - $user->id=$userid; - - $this->db->begin(); - - // Sauve parametre indiquant que le user a une - $confuserzone='MAIN_BOXES_'.$zone; - $tab[$confuserzone]=1; - if (dol_set_user_param($this->db, $conf, $user, $tab) < 0) - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -3; - } - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; - $sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def"; - $sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid"; - $sql.= " AND ".MAIN_DB_PREFIX."boxes_def.entity = ".$conf->entity; - $sql.= " AND ".MAIN_DB_PREFIX."boxes.fk_user = ".$userid; - $sql.= " AND ".MAIN_DB_PREFIX."boxes.position = ".$zone; - - dol_syslog("InfoBox::saveboxorder sql=".$sql); - $result = $this->db->query($sql); - if ($result) - { - $colonnes=explode('-',$boxorder); - foreach ($colonnes as $collist) - { - $part=explode(':',$collist); - $colonne=$part[0]; - $list=$part[1]; - dol_syslog('InfoBox::saveboxorder column='.$colonne.' list='.$list); - - $i=0; - $listarray=explode(',',$list); - foreach ($listarray as $id) - { - if (is_numeric($id)) - { - //dol_syslog("aaaaa".count($listarray)); - $i++; - $ii=sprintf('%02d',$i); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes"; - $sql.= "(box_id, position, box_order, fk_user)"; - $sql.= " values ("; - $sql.= " ".$id.","; - $sql.= " ".$zone.","; - $sql.= " '".$colonne.$ii."',"; - $sql.= " ".$userid; - $sql.= ")"; - - dol_syslog("InfoBox::saveboxorder sql=".$sql); - $result = $this->db->query($sql); - if ($result < 0) - { - $error++; - break; - } - } - } - } - if ($error) - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -2; - } - else - { - $this->db->commit(); - return 1; - } - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - dol_syslog("InfoBox::saveboxorder ".$this->error); - return -1; - } - } - -} - -?> diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index f5c28edfab4..fcad5848c17 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -75,7 +75,7 @@ class Facturation public function Facturation() { $this->raz(); - $this->raz_pers(); + $this->razPers(); } @@ -115,7 +115,7 @@ class Facturation // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte,$this->prix(),$this->remise_percent(),$vat_rate,0,0,0,'HT',0); + $resultarray=calcul_price_total($this->qte,$this->prix(),$this->remisePercent(),$vat_rate,0,0,0,'HT',0); // Calcul du total ht sans remise $total_ht = $resultarray[0]; @@ -123,14 +123,14 @@ class Facturation $total_ttc = $resultarray[2]; // Calcul du montant de la remise - if ($this->remise_percent()) + if ($this->remisePercent()) { - $remise_percent = $this->remise_percent(); + $remise_percent = $this->remisePercent(); } else { $remise_percent = 0; } $montant_remise_ht = ($resultarray[6] - $resultarray[0]); - $this->montant_remise($montant_remise_ht); + $this->montantRemise($montant_remise_ht); $product = new Product($db); $product->fetch($this->id); @@ -234,8 +234,8 @@ class Facturation $this->ref('RESET'); $this->qte('RESET'); $this->stock('RESET'); - $this->remise_percent('RESET'); - $this->montant_remise('RESET'); + $this->remisePercent('RESET'); + $this->montantRemise('RESET'); $this->prix('RESET'); $this->tva('RESET'); } @@ -245,13 +245,13 @@ class Facturation * * @return void */ - public function raz_pers() + private function razPers() { - $this->num_facture('RESET'); + $this->numInvoice('RESET'); $this->getSetPaymentMode('RESET'); - $this->montant_encaisse('RESET'); - $this->montant_rendu('RESET'); - $this->paiement_le('RESET'); + $this->montantEncaisse('RESET'); + $this->montantRendu('RESET'); + $this->paiementLe('RESET'); $this->prix_total_ht('RESET'); $this->montant_tva('RESET'); @@ -368,7 +368,7 @@ class Facturation * @param string $aRemisePercent Discount * @return string Discount */ - public function remise_percent($aRemisePercent=null) + public function remisePercent($aRemisePercent=null) { if ( !$aRemisePercent ) @@ -392,7 +392,7 @@ class Facturation * @param int $aMontantRemise Amount * @return string Amount */ - public function montant_remise($aMontantRemise=null) + public function montantRemise($aMontantRemise=null) { if ( !$aMontantRemise ) { @@ -467,7 +467,7 @@ class Facturation * @param string $aNumFacture Invoice ref * @return string Invoice ref */ - public function num_facture( $aNumFacture=null ) + public function numInvoice( $aNumFacture=null ) { if ( !$aNumFacture ) { @@ -516,7 +516,7 @@ class Facturation * @param int $aMontantEncaisse Amount * @return int Amount */ - public function montant_encaisse( $aMontantEncaisse=null ) + public function montantEncaisse( $aMontantEncaisse=null ) { if ( !$aMontantEncaisse ) { @@ -541,7 +541,7 @@ class Facturation * @param int $aMontantRendu Amount * @return int Amount */ - public function montant_rendu( $aMontantRendu=null ) + public function montantRendu( $aMontantRendu=null ) { if ( !$aMontantRendu ) { @@ -565,7 +565,7 @@ class Facturation * @param date $aPaiementLe Date * @return date Date */ - public function paiement_le( $aPaiementLe=null ) + public function paiementLe( $aPaiementLe=null ) { if ( !$aPaiementLe ) { diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index 310ee0af9da..3d1f28768bf 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -154,9 +154,9 @@ $tab_tva = $ret; // Reinitialisation du mode de paiement, en cas de retour aux achats apres validation $obj_facturation->getSetPaymentMode('RESET'); -$obj_facturation->montant_encaisse('RESET'); -$obj_facturation->montant_rendu('RESET'); -$obj_facturation->paiement_le('RESET'); +$obj_facturation->montantEncaisse('RESET'); +$obj_facturation->montantRendu('RESET'); +$obj_facturation->paiementLe('RESET'); // Affichage des templates diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 556f895e1df..408e36bc725 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -36,7 +36,7 @@ switch ( $_GET['action'] ) $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; $sql.= " WHERE p.entity IN (".getEntity('product', 1).")"; - + // Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ... if ( $_POST['hdnSource'] == 'LISTE' ) { @@ -138,7 +138,7 @@ switch ( $_GET['action'] ) { $obj_facturation->qte($_POST['txtQte']); $obj_facturation->tva($_POST['selTva']); - $obj_facturation->remise_percent($_POST['txtRemise']); + $obj_facturation->remisePercent($_POST['txtRemise']); $obj_facturation->ajoutArticle(); } diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index 040f0f8fd4b..fdcda6e3e7c 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -25,7 +25,7 @@ $langs->load("main"); - + load("main"); // Affichage des infos en fonction du mode de paiement if ( $obj_facturation->getsetPaymentMode() == 'DIF' ) { - echo (''); + echo (''); } else { - echo (''); + echo (''); } // Affichage du montant rendu (reglement en especes) - if ( $obj_facturation->montant_rendu() ) { + if ( $obj_facturation->montantRendu() ) { - echo (''); + echo (''); } diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 5c149ed7b02..5bf7bdab68b 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -50,7 +50,7 @@ switch ($action) $invoice->type=0; $num=$invoice->getNextNumRef($company); - $obj_facturation->num_facture($num); + $obj_facturation->numInvoice($num); $obj_facturation->getSetPaymentMode($_POST['hdnChoix']); @@ -63,20 +63,20 @@ switch ($action) } if ( $mode_reglement != 'DIF') { - $obj_facturation->montant_encaisse($montant); + $obj_facturation->montantEncaisse($montant); //Determination de la somme rendue $total = $obj_facturation->prix_total_ttc(); - $encaisse = $obj_facturation->montant_encaisse(); + $encaisse = $obj_facturation->montantEncaisse(); - $obj_facturation->montant_rendu($encaisse - $total); + $obj_facturation->montantRendu($encaisse - $total); } else { //$txtDatePaiement=$_POST['txtDatePaiement']; $datePaiement=dol_mktime(0,0,0,$_POST['txtDatePaiementmonth'],$_POST['txtDatePaiementday'],$_POST['txtDatePaiementyear']); $txtDatePaiement=dol_print_date($datePaiement,'dayrfc'); - $obj_facturation->paiement_le($txtDatePaiement); + $obj_facturation->paiementLe($txtDatePaiement); } $redirection = 'affIndex.php?menu=validation'; @@ -115,8 +115,8 @@ switch ($action) $mode_reglement_id = dol_getIdFromCode($db,'LIQ','c_paiement'); $cond_reglement_id = 0; $note .= $langs->trans("Cash")."\n"; - $note .= $langs->trans("Received").' : '.$obj_facturation->montant_encaisse()." ".$conf->currency."\n"; - $note .= $langs->trans("Rendu").' : '.$obj_facturation->montant_rendu()." ".$conf->currency."\n"; + $note .= $langs->trans("Received").' : '.$obj_facturation->montantEncaisse()." ".$conf->currency."\n"; + $note .= $langs->trans("Rendu").' : '.$obj_facturation->montantRendu()." ".$conf->currency."\n"; $note .= "\n"; $note .= '--------------------------------------'."\n\n"; break; @@ -209,10 +209,10 @@ switch ($action) // Si paiement differe ... if ( $obj_facturation->getSetPaymentMode() == 'DIF' ) { - $resultcreate=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiement_le())); + $resultcreate=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiementLe())); if ($resultcreate > 0) { - $resultvalid=$invoice->validate($user,$obj_facturation->num_facture()); + $resultvalid=$invoice->validate($user,$obj_facturation->numInvoice()); } else { @@ -226,7 +226,7 @@ switch ($action) $resultcreate=$invoice->create($user,0,0); if ($resultcreate > 0) { - $resultvalid=$invoice->validate($user, $obj_facturation->num_facture(), (isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0)); + $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), (isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0)); $id = $invoice->id; @@ -235,7 +235,7 @@ switch ($action) $payment->datepaye=$now; $payment->bank_account=$conf_fkaccount; $payment->amounts[$invoice->id]=$obj_facturation->prix_total_ttc(); - $payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->num_facture(); + $payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice(); $payment->paiementid=$invoice->mode_reglement_id; $payment->num_paiement=''; diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 1a159d03257..e6d334965c4 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Brice Davoleau - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent @@ -38,6 +38,8 @@ $ref = GETPOST('ref'); $type = GETPOST('type'); $mesg = GETPOST('mesg'); +$removecat = GETPOST('removecat','int'); + $dbtablename = ''; @@ -65,6 +67,7 @@ if ($id || $ref) $elementtype = 'societe'; $objecttype = 'societe&categorie'; $objectid = isset($id)?$id:(isset($socid)?$socid:''); + $dbtablename = '&societe'; $fieldid = 'rowid'; } if ($type == 3) { @@ -86,7 +89,7 @@ $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid */ //Suppression d'un objet d'une categorie -if ($_REQUEST["removecat"]) +if ($removecat > 0) { if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) { @@ -112,7 +115,7 @@ if ($_REQUEST["removecat"]) $result = $object->fetch($objectid); } $cat = new Categorie($db); - $result=$cat->fetch($_REQUEST["removecat"]); + $result=$cat->fetch($removecat); $result=$cat->del_type($object,$elementtype); } @@ -269,11 +272,11 @@ if ($socid) dol_htmloutput_mesg($mesg); - if ($soc->client) formCategory($db,$soc,2); + if ($soc->client) formCategory($db,$soc,2,$socid); if ($soc->client && $soc->fournisseur) print '

'; - if ($soc->fournisseur) formCategory($db,$soc,1); + if ($soc->fournisseur) formCategory($db,$soc,1,$socid); } else if ($id || $ref) { @@ -423,7 +426,7 @@ else if ($id || $ref) * @param int $typeid Type of category (0, 1, 2, 3) * @return int 0 */ -function formCategory($db,$object,$typeid) +function formCategory($db,$object,$typeid,$socid=0) { global $user,$langs,$form,$bc; @@ -498,7 +501,7 @@ function formCategory($db,$object,$typeid) if ($typeid == 3) $permission=$user->rights->adherent->creer; if ($permission) { - print ""; + print ""; print img_delete($langs->trans("DeleteFromCat")).' '; print $langs->trans("DeleteFromCat").""; } @@ -529,7 +532,7 @@ function formCategory($db,$object,$typeid) return 0; } -$db->close(); llxFooter(); -?> +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 7a7cc186a6d..2a8e52e7cad 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2005 Davoleau Brice * Copyright (C) 2005 Rodolphe Quiedeville - * Copyright (C) 2006-2011 Regis Houssin + * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * @@ -125,6 +125,7 @@ class Categorie * @return int -1 : erreur SQL * -2 : nouvel ID inconnu * -3 : categorie invalide + * -4 : category already exists */ function create($user='') { @@ -141,8 +142,10 @@ class Categorie { $this->error=$langs->trans("ImpossibleAddCat"); $this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel"); - return -1; + return -4; } + + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description,"; if ($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) @@ -176,7 +179,8 @@ class Categorie if($this->add_fille() < 0) { $this->error=$langs->trans("ImpossibleAssociateCategory"); - return -1; + $this->db->rollback(); + return -3; } } @@ -186,17 +190,21 @@ class Categorie $result=$interface->run_triggers('CATEGORY_CREATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - + + $this->db->commit(); return $id; } else { + $this->db->rollback(); return -2; } } else { - dol_print_error($this->db); + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::create error ".$this->error." sql=".$sql, LOG_ERR); + $this->db->rollback(); return -1; } } @@ -589,11 +597,11 @@ class Categorie */ function get_desc($cate) { - $sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie "; - $sql .= "WHERE rowid = ".$cate; + $sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE rowid = ".$cate; - $res = $this->db->query($sql); - $n = $this->db->fetch_array($res); + $res = $this->db->query($sql); + $n = $this->db->fetch_array($res); return($n[0]); } @@ -632,8 +640,6 @@ class Categorie */ function get_full_arbo($type,$markafterid=0) { - global $conf; - $this->cats = array(); // Charge tableau des meres @@ -641,7 +647,7 @@ class Categorie $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association ca"; $sql.= ", ".MAIN_DB_PREFIX."categorie as c"; $sql.= " WHERE ca.fk_categorie_mere = c.rowid"; - $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; // Load array this->motherof dol_syslog("Categorie::get_full_arbo build motherof array sql=".$sql, LOG_DEBUG); @@ -665,7 +671,7 @@ class Categorie $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_association as ca"; $sql.= " ON c.rowid = ca.fk_categorie_mere"; $sql.= " WHERE c.type = ".$type; - $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; $sql.= " ORDER BY c.label, c.rowid"; dol_syslog("Categorie::get_full_arbo get category list sql=".$sql, LOG_DEBUG); @@ -811,6 +817,7 @@ class Categorie function get_all_categories () { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE entity IN (".getEntity('category',1).")"; $res = $this->db->query($sql); if ($res) @@ -839,6 +846,7 @@ class Categorie { $sql = "SELECT count(rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE entity IN (".getEntity('category',1).")"; $res = $this->db->query($sql); if ($res) { @@ -870,6 +878,7 @@ class Categorie $sql.= " ON c.rowid=ca.fk_categorie_fille"; $sql.= " WHERE ca.fk_categorie_mere=".$this->id_mere; $sql.= " AND c.label='".$this->db->escape($this->label)."'"; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; } else // mother_id undefined (so it's root) { @@ -883,8 +892,9 @@ class Categorie $sql.= " ON c.rowid!=ca.fk_categorie_fille"; $sql.= " WHERE c.type=".$this->type; $sql.= " AND c.label='".$this->db->escape($this->label)."'"; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; } - dol_syslog("Categorie::already_exists sql=".$sql); + dol_syslog(get_class($this)."::already_exists sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -896,13 +906,19 @@ class Categorie * So if the result have the same id, update is not for label, and if result have an other one, * update may be for label. */ - if($obj[0] > 0 && $obj[0] != $this->id) return 1; + if($obj[0] > 0 && $obj[0] != $this->id) + { + dol_syslog(get_class($this)."::already_exists category with name=".$this->label." exist rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG); + return 1; + } } + dol_syslog(get_class($this)."::already_exists no category with same name=".$this->label." rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG); return 0; } else { - dol_print_error($this->db); + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::already_exists error ".$this->error." sql=".$sql, LOG_ERR); return -1; } } @@ -1101,6 +1117,7 @@ class Categorie $sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON ct.fk_categorie = c.rowid"; $sql.= " WHERE ct.fk_".$table." = ".$id." AND c.type = ".$typeid; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; $res = $this->db->query($sql); if ($res) @@ -1135,8 +1152,9 @@ class Categorie $cats = array (); // Generation requete recherche - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie "; - $sql .= "WHERE type = ".$type." "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE type = ".$type." "; + $sql.= " AND entity IN (".getEntity('category',1).")"; if ($nom) { if (! $exact) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index ca82944a32a..015b964d452 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -1,7 +1,7 @@ * Copyright (C) 2006-2010 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Patrick Raguin * * This program is free software; you can redistribute it and/or modify @@ -41,7 +41,7 @@ if ($id == "") } // Security check -$result = restrictedArea($user, 'categorie', $id); +$result = restrictedArea($user, 'categorie', $id, '&category'); diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 8dc601e996f..4da7f4e3f6b 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,12 +29,13 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/treeview.lib.php"); -$type=(GETPOST('type') ? GETPOST('type') : 0); - -if (!$user->rights->categorie->lire) accessforbidden(); - $langs->load("categories"); +if (! $user->rights->categorie->lire) accessforbidden(); + +$id=GETPOST('id','int'); +$type=(GETPOST('type') ? GETPOST('type') : 0); + /* * View @@ -88,9 +89,9 @@ print '
'; - // Delivery address - if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) - { - print ''; - print ''; - } - // Model print ''; print ''; diff --git a/htdocs/comm/address.php b/htdocs/comm/address.php index 72abc9da7d1..b4059a94445 100644 --- a/htdocs/comm/address.php +++ b/htdocs/comm/address.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ /** * \file htdocs/comm/address.php * \ingroup societe - * \brief Tab address of customer + * \brief Tab address of thirdparty */ require("../main.inc.php"); @@ -31,58 +31,73 @@ require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php"); $langs->load("companies"); $langs->load("commercial"); -$id = isset($_GET["id"])?$_GET["id"]:''; -$origin = isset($_GET["origin"])?$_GET["origin"]:''; -$originid = isset($_GET["originid"])?$_GET["originid"]:''; -$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:''; -if (! $socid && ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add' && $_REQUEST["action"] != 'update')) accessforbidden(); +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); +$backtopage = GETPOST('backtopage','alpha'); +$origin = GETPOST('origin','alpha'); +$originid = GETPOST('originid','int'); +$socid = GETPOST('socid','int'); +if (! $socid && ($action != 'create' && $action != 'add' && $action != 'update')) accessforbidden(); // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid); +$object = new Address($db); + /* * Actions */ -if ($_POST["action"] == 'add' || $_POST["action"] == 'update') +// Cancel +if (GETPOST("cancel") && ! empty($backtopage)) +{ + header("Location: ".$backtopage); + exit; +} + +if ($action == 'add' || $action == 'update') { - $address = new Address($db); - - $address->socid = $_POST["socid"]; - $address->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:''); - $address->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:''); - $address->address = $_POST["address"]; - $address->cp = $_POST["zipcode"]; - $address->ville = $_POST["town"]; - $address->zip = $_POST["zipcode"]; - $address->town = $_POST["town"]; - $address->pays_id = $_POST["country_id"]; - $address->country_id= $_POST["country_id"]; - $address->tel = $_POST["tel"]; - $address->fax = $_POST["fax"]; - $address->note = $_POST["note"]; - - if ($_POST["action"] == 'add') + $object->socid = $socid; + $object->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:''); + $object->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:''); + $object->address = $_POST["address"]; + $object->zip = $_POST["zipcode"]; + $object->town = $_POST["town"]; + $object->country_id = $_POST["country_id"]; + $object->phone = $_POST["phone"]; + $object->fax = $_POST["fax"]; + $object->note = $_POST["note"]; + + // Add new address + if ($action == 'add') { - $socid = $_POST["socid"]; - $origin = $_POST["origin"]; - $originid = $_POST["originid"]; - $result = $address->create($socid, $user); + $result = $object->create($socid, $user); if ($result >= 0) { - if ($origin == 'commande') + if (! empty($backtopage)) + { + Header("Location: ".$backtopage); + exit; + } + else if ($origin == 'commande') { - Header("Location: ../commande/fiche.php?action=editdelivery_adress&socid=".$socid."&id=".$originid); + Header("Location: ../commande/contact.php?action=editdelivery_adress&socid=".$socid."&id=".$originid); exit; } elseif ($origin == 'propal') { - Header("Location: ../comm/propal.php?action=editdelivery_adress&socid=".$socid."&id=".$originid); + Header("Location: ../comm/propal/contact.php?action=editdelivery_adress&socid=".$socid."&id=".$originid); exit; } + elseif ($origin == 'shipment') + { + Header("Location: ../expedition/fiche.php?id=".$originid); + exit; + } else { Header("Location: ".$_SERVER['PHP_SELF']."?socid=".$socid); @@ -91,28 +106,31 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update') } else { - $mesg = $address->error; - $_GET["action"]='create'; + $mesg = $object->error; + $action='create'; } } - - if ($_POST["action"] == 'update') + + // Update address + else if ($action == 'update') { - $socid = $_POST["socid"]; - $origin = $_POST["origin"]; - $originid = $_POST["originid"]; - $result = $address->update($_POST["id"], $socid, $user); + $result = $object->update($_POST["id"], $socid, $user); if ($result >= 0) { - if ($origin == 'commande') + if (! empty($backtopage)) + { + Header("Location: ".$backtopage); + exit; + } + else if ($origin == 'commande') { - Header("Location: ../commande/fiche.php?id=".$originid); + Header("Location: ../commande/contact.php?id=".$originid); exit; } elseif ($origin == 'propal') { - Header("Location: ../comm/propal.php?id=".$originid); + Header("Location: ../comm/propal/contact.php?id=".$originid); exit; } elseif ($origin == 'shipment') @@ -129,17 +147,16 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update') else { $reload = 0; - $mesg = $address->error; - $_GET["action"]= "edit"; + $mesg = $object->error; + $actino= "edit"; } } } -if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->supprimer) +else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) { - $address = new Address($db); - $result = $address->delete($_GET["id"], $socid); + $result = $object->delete($id, $socid); if ($result == 0) { @@ -149,7 +166,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user- else { $reload = 0; - $_GET["action"]=''; + $action=''; } } @@ -167,7 +184,7 @@ $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("Se dol_htmloutput_errors($mesg); -if ($_GET["action"] == 'create' || $_POST["action"] == 'create') +if ($action == 'create') { if ($user->rights->societe->creer) { @@ -175,132 +192,122 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create') * Creation */ - $address = new Address($db); - - $societe=new Societe($db); - $societe->fetch($socid); - $head = societe_prepare_head($societe); - - dol_fiche_head($head, 'customer', $societe->nom); - if ($_POST["label"] && $_POST["name"]) { - $address->socid = $_POST["socid"]; - $address->label = $_POST["label"]; - $address->name = $_POST["name"]; - $address->address = $_POST["address"]; - $address->cp = $_POST["zipcode"]; - $address->ville = $_POST["town"]; - $address->tel = $_POST["tel"]; - $address->fax = $_POST["fax"]; - $address->note = $_POST["note"]; + $object->socid = $socid; + $object->label = $_POST["label"]; + $object->name = $_POST["name"]; + $object->address = $_POST["address"]; + $object->zip = $_POST["zipcode"]; + $object->town = $_POST["town"]; + $object->phone = $_POST["phone"]; + $object->fax = $_POST["fax"]; + $object->note = $_POST["note"]; } // On positionne pays_id, pays_code et libelle du pays choisi - $address->country_id=$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; - if ($address->country_id) + $object->country_id = (GETPOST('country_id','int') ? GETPOST('country_id','int') : $mysoc->country_id); + if ($object->country_id) { - $tmparray=getCountry($address->country_id,'all'); - $address->pays_code = $tmparray['code']; - $address->pays = $tmparray['label']; - $address->country_code = $tmparray['code']; - $address->country = $tmparray['label']; + $tmparray=getCountry($object->country_id,'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } + + print_fiche_titre($langs->trans("AddAddress")); - print_titre($langs->trans("AddAddress")); print "
\n"; - if ($address->error) - { - print '
'; - print nl2br($address->error); - print '
'; - } - // If javascript enabled, we add interactivity on mandatory fields if ($conf->use_javascript_ajax) { print "\n".''."\n"; } print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print '
trans("Invoice"); ?>num_facture(); ?>
trans("Invoice"); ?>numInvoice(); ?>
trans("TotalHT"); ?>prix_total_ht(),'MT').' '.$conf->currency; ?>
'.$langs->trans("DateEcheance").''.$obj_facturation->paiement_le().'
'.$langs->trans("DateEcheance").''.$obj_facturation->paiementLe().'
'.$langs->trans("Received").''.price2num($obj_facturation->montant_encaisse(),'MT').' '.$conf->currency.'
'.$langs->trans("Received").''.price2num($obj_facturation->montantEncaisse(),'MT').' '.$conf->currency.'
'.$langs->trans("Change").''.price2num($obj_facturation->montant_rendu(),'MT').' '.$conf->currency.'
'.$langs->trans("Change").''.price2num($obj_facturation->montantRendu(),'MT').' '.$conf->currency.'
'; /* * Categories found */ -if($_POST['catname'] || $_REQUEST['id']) +if($_POST['catname'] || $id > 0) { - $cats = $categstatic->rechercher($_REQUEST['id'],$_POST['catname'],$_POST['type']); + $cats = $categstatic->rechercher($id,$_POST['catname'],$type); print ''; print ''; @@ -235,8 +236,7 @@ foreach($fulltree as $key => $val) $resarray=tree_showpad($fulltree,$key); $a=$resarray[0]; $nbofsubdir=$resarray[1]; - $c=$resarray[2]; - $nboffilesinsubdir=$resarray[3]; + $nboffilesinsubdir=$resarray[2]; print ''; // Show picto @@ -309,7 +309,7 @@ if ($nbofentries == 0) print "
'.$langs->trans("FoundCats").'
"; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 747d2c92a5b..7730347f286 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,7 +48,7 @@ if ($id == "") } // Security check -$result = restrictedArea($user, 'categorie', $id); +$result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 5efa8c9ecec..bcf8fd65675 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2006-2010 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ if ($id == "") } // Security check -$result = restrictedArea($user, 'categorie', $id); +$result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); $result=$object->fetch($id); diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 468c2181349..1b60e197126 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -201,19 +201,6 @@ if ($action == 'create') } print '
'.$langs->trans('DeliveryAddress').''; - $numaddress = $form->select_address($soc->fk_delivery_address, $_GET['socid'],'fk_address',1); - if ($numaddress==0) - { - print '   id.'&action=create>'.$langs->trans("AddAddress").''; - } - print '
'.$langs->trans("DefaultModel").'
'; - print ''; - print ''; + print ''; + print ''; print ''; // Zip print ''; // Town print ''; print ''; - print ''; + print ''; - print ''; + print ''; print ''; print '
'.$langs->trans('Label').'
'.$langs->trans('Name').'
'.$langs->trans('Label').'
'.$langs->trans('Name').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; - print $formcompany->select_ziptown($address->cp,'zipcode',array('town','selectcountry_id'),6); + print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id'),6); print '
'.$langs->trans('Town').''; - print $formcompany->select_ziptown($address->ville,'town',array('zipcode','selectcountry_id')); + print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id')); print '
'.$langs->trans('Country').''; - print $form->select_country($address->country_id,'selectcountry_id'); + print $form->select_country($object->country_id,'selectcountry_id'); print '
'.$langs->trans('Phone').'
'.$langs->trans('Phone').'
'.$langs->trans('Fax').'
'.$langs->trans('Fax').'
'.$langs->trans('Note').'
'."\n"; print '
'; - print '
'."\n"; + print ''; + if (! empty($backtopage)) + { + print '     '; + print ''; + } + print ''."\n"; print ''."\n"; } } -elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') +elseif ($action == 'edit') { /* * Fiche societe en mode edition */ - $address = new Address($db); $societe=new Societe($db); - $societe->fetch($_GET["socid"]); + $societe->fetch($socid); $head = societe_prepare_head($societe); - dol_fiche_head($head, 'customer', $societe->nom); + dol_fiche_head($head, 'card', $societe->nom); print_titre($langs->trans("EditAddress")); print "
\n"; @@ -309,83 +316,80 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') { if ($reload || ! $_POST["name"]) { - $address->socid = $socid; - $address->fetch_address($id); + $object->socid = $socid; + $object->fetch_address($id); } else { - $address->id = $_POST["id"]; - $address->socid = $_POST["socid"]; - $address->label = $_POST["label"]; - $address->name = $_POST["name"]; - $address->address = $_POST["address"]; - $address->cp = $_POST["zipcode"]; - $address->ville = $_POST["town"]; - $address->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; - $address->tel = $_POST["tel"]; - $address->fax = $_POST["fax"]; - $address->note = $_POST["note"]; + $object->id = $id; + $object->socid = $socid; + $object->label = $_POST["label"]; + $object->name = $_POST["name"]; + $object->address = $_POST["address"]; + $object->zip = $_POST["zipcode"]; + $object->town = $_POST["town"]; + $object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; + $object->phone = $_POST["phone"]; + $object->fax = $_POST["fax"]; + $object->note = $_POST["note"]; // On positionne country_id, pays_code et libelle du pays choisi - if ($address->country_id) + if ($object->country_id) { - $tmparray=getCountry($address->country_id,'all'); - $address->pays_code = $tmparray['code']; - $address->pays = $tmparray['label']; - $address->country_code = $tmparray['code']; - $address->country = $tmparray['label']; + $tmparray=getCountry($object->country_id,'all'); + $object->country_code = $tmparray['code']; + $object->country = $tmparray['label']; } } - if ($address->error) - { - print '
'; - print $address->error; - print '
'; - } - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Zip print ''; // Town print ''; print ''; - print ''; + print ''; - print ''; + print ''; print ''; - - print ''; - - print '
'.$langs->trans('AddressLabel').'
'.$langs->trans('Name').'
'.$langs->trans('AddressLabel').'
'.$langs->trans('Name').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; - print $formcompany->select_ziptown($address->cp,'zipcode',array('town','selectcountry_id'),6); + print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id'),6); print '
'.$langs->trans('Town').''; - print $formcompany->select_ziptown($address->ville,'town',array('zipcode','selectcountry_id')); + print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id')); print '
'.$langs->trans('Country').''; - print $form->select_country($address->country_id,'country_id'); + print $form->select_country($object->country_id,'country_id'); print '
'.$langs->trans('Phone').'
'.$langs->trans('Phone').'
'.$langs->trans('Fax').'
'.$langs->trans('Fax').'
'.$langs->trans('Note').'
'; + + print '
'; + + print '
'; + print ''; + print '   '; + print ''; + print '
'; + print '
'; } } @@ -394,37 +398,30 @@ else /* * Fiche societe en mode visu */ - $address = new Address($db); - $result=$address->fetch_lines($socid); + + $result=$object->fetch_lines($socid); if ($result < 0) { - dol_print_error($db,$address->error); + dol_print_error($db,$object->error); exit; } $societe=new Societe($db); - $societe->fetch($address->socid); + $societe->fetch($object->socid); $head = societe_prepare_head($societe); dol_fiche_head($head, 'customer', $societe->nom); // Confirmation delete - if ($_GET["action"] == 'delete') + if ($action == 'delete') { $form = new Form($db); - $ret=$form->form_confirm($_SERVER['PHP_SELF']."?socid=".$address->socid."&id=".$_GET["id"],$langs->trans("DeleteAddress"),$langs->trans("ConfirmDeleteAddress"),"confirm_delete"); + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?socid=".$object->socid."&id=".$id,$langs->trans("DeleteAddress"),$langs->trans("ConfirmDeleteAddress"),"confirm_delete"); if ($ret == 'html') print '
'; } - if ($address->error) - { - print '
'; - print $address->error; - print '
'; - } - - $nblines = count($address->lines); + $nblines = count($object->lines); if ($nblines) { for ($i = 0 ; $i < $nblines ; $i++) @@ -432,20 +429,20 @@ else print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ""; + print ""; - print '"; - print '"; + print '"; + print '"; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; print ''; @@ -460,12 +457,12 @@ else if ($user->rights->societe->creer) { - print ''.$langs->trans("Modify").''; + print ''.$langs->trans("Modify").''; } if ($user->rights->societe->supprimer) { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } @@ -484,21 +481,21 @@ else * Bouton actions */ - if ($_GET["action"] == '') + if ($action == '') { print '
'; if ($user->rights->societe->creer) { - print ''.$langs->trans("Add").''; + print ''.$langs->trans("Add").''; } print '
'; } } -$db->close(); - +// End of page llxFooter(); +$db->close(); ?> diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 38c20e438a6..4e74ec1c293 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -125,8 +125,9 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - - print_barre_liste($langs->trans("ListOfContacts").($label?" (".$label.")":""),$page, $_SERVER["PHP_SELF"], "&type=$type",$sortfield,$sortorder,"",$num); + + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); + print_barre_liste($title.($label?" (".$label.")":""),$page, $_SERVER["PHP_SELF"], "&type=$type",$sortfield,$sortorder,"",$num); print '
'.$langs->trans('AddressLabel').''.$address->lines[$i]->label.''.$langs->trans('Note').' :
'.nl2br($address->lines[$i]->note).'
'.$langs->trans('Name').''.$address->lines[$i]->name.'
'.$langs->trans('AddressLabel').''.$object->lines[$i]->label.''.$langs->trans('Note').' :
'.nl2br($object->lines[$i]->note).'
'.$langs->trans('Name').''.$object->lines[$i]->name.'
".$langs->trans('Address')."".nl2br($address->lines[$i]->address)."
".$langs->trans('Address')."".nl2br($object->lines[$i]->address)."
'.$langs->trans('Zip').''.$address->lines[$i]->cp."
'.$langs->trans('Town').''.$address->lines[$i]->ville."
'.$langs->trans('Zip').''.$object->lines[$i]->zip."
'.$langs->trans('Town').''.$object->lines[$i]->town."
'.$langs->trans('Country').''.$address->lines[$i]->pays.'
'.$langs->trans('Country').''.$object->lines[$i]->country.'
'.$langs->trans('Phone').''.dol_print_phone($address->lines[$i]->tel,$address->lines[$i]->country_code,0,$address->socid,'AC_TEL').'
'.$langs->trans('Phone').''.dol_print_phone($object->lines[$i]->phone,$object->lines[$i]->country_code,0,$object->socid,'AC_TEL').'
'.$langs->trans('Fax').''.dol_print_phone($address->lines[$i]->fax,$address->lines[$i]->country_code,0,$address->socid,'AC_FAX').'
'.$langs->trans('Fax').''.dol_print_phone($object->lines[$i]->fax,$object->lines[$i]->country_code,0,$object->socid,'AC_FAX').'
'; print ''; diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index cc83e426ca0..0787a99c1ad 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -37,7 +37,6 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/co if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); if ($conf->adherent->enabled) require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); if ($conf->ficheinter->enabled) require_once(DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php"); -if (!empty($conf->global->MAIN_MODULE_CHRONODOCS)) require_once(DOL_DOCUMENT_ROOT."/chronodocs/chronodocs_entries.class.php"); $langs->load("companies"); if ($conf->contrat->enabled) $langs->load("contracts"); @@ -46,7 +45,6 @@ if ($conf->facture->enabled) $langs->load("bills"); if ($conf->projet->enabled) $langs->load("projects"); if ($conf->ficheinter->enabled) $langs->load("interventions"); if ($conf->notification->enabled) $langs->load("mails"); -if (!empty($conf->global->MAIN_MODULE_CHRONODOCS)) $langs->load("chronodocs"); // Security check $id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); @@ -85,34 +83,19 @@ if ($action == 'setcustomeraccountancycode') $action=""; } -if ($action == 'attribute_prefix' && $user->rights->societe->creer) -{ - $object->fetch($id); - $object->attribute_prefix($db, $id); -} // conditions de reglement if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); - $object->cond_reglement=$_POST['cond_reglement_id']; - - // TODO move to DAO class - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET cond_reglement='".$_POST['cond_reglement_id']; - $sql.= "' WHERE rowid='".$id."'"; - $result = $db->query($sql); - if (! $result) dol_print_error($result); + $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); + if ($result < 0) dol_print_error($db,$object->error); } // mode de reglement if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); - $object->mode_reglement=$_POST['mode_reglement_id']; - - // TODO move to DAO class - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET mode_reglement='".$_POST['mode_reglement_id']; - $sql.= "' WHERE rowid='".$id."'"; - $result = $db->query($sql); - if (! $result) dol_print_error($result); + $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); + if ($result < 0) dol_print_error($db,$object->error); } // assujetissement a la TVA if ($action == 'setassujtva' && $user->rights->societe->creer) @@ -382,42 +365,6 @@ if ($id > 0) print ''; } - // Old way to define delivery address (deprecated). - // Now all addresses types (like delivery addresses, invoices addresses,...) are saved as contacts. - if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) // Hidden deprecated feature. - { - print ''; - print ''; - } - // Module Adherent if ($conf->adherent->enabled) { @@ -839,11 +786,6 @@ if ($id > 0) } } - /*if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans("AddContact").''; - }*/ - print ''; print "
\n"; @@ -853,6 +795,12 @@ if ($id > 0) // List of contacts show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } + + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { @@ -871,7 +819,7 @@ else } +// End of page llxFooter(); - $db->close(); ?> diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index a7ec49e4aa9..accc3314bd0 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -515,7 +515,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) print ''; print '
'; - print '
'; - print $langs->trans("DeliveriesAddress"); - print ''; - if ($user->rights->societe->creer) - { - print ''.img_edit($langs->trans("Modify")).''; - } - print '
'; - print '
'; - - // TODO move to DAO class - $sql = "SELECT count(rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_address"; - $sql.= " WHERE fk_soc =".$object->id; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $objal = $db->fetch_object($resql); - print $objal->nb?($objal->nb):$langs->trans("NoOtherDeliveryAddress"); - } - else - { - dol_print_error($db); - } - - print '
'; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print '
'; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 489a7b8398f..0dd7b00c318 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -77,9 +77,10 @@ class Mailing extends CommonObject } /** - * \brief Create an EMailing - * \param user Object of user making creation - * \return -1 if error, Id of created object if OK + * Create an EMailing + * + * @param User $user Object of user making creation + * @return int -1 if error, Id of created object if OK */ function create($user) { @@ -133,9 +134,10 @@ class Mailing extends CommonObject } /** - * \brief Update emailing record - * \param user Object of user making change - * \return < 0 if KO, > 0 if OK + * Update emailing record + * + * @param User $user Object of user making change + * @return int < 0 if KO, > 0 if OK */ function update($user) { @@ -165,9 +167,10 @@ class Mailing extends CommonObject } /** - * \brief Get object from database - * \param rowid id du mailing - * \return int + * Get object from database + * + * @param int $rowid Id of emailing + * @return int <0 if KO, >0 if OK */ function fetch($rowid) { @@ -227,9 +230,10 @@ class Mailing extends CommonObject /** - * \brief Load an object from its id and create a new one in database - * \param fromid Id of object to clone - * \return int New id of clone + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @return int New id of clone */ function createFromClone($fromid,$option1,$option2) { @@ -303,9 +307,10 @@ class Mailing extends CommonObject } /** - * \brief Validate emailing - * \param user Objet user qui valide - * \return int <0 if KO, >0 if OK + * Validate emailing + * + * @param User $user Objet user qui valide + * @return int <0 if KO, >0 if OK */ function valid($user) { @@ -328,9 +333,10 @@ class Mailing extends CommonObject /** - * \brief Delete emailing - * \param rowid id du mailing a supprimer - * \return int 1 en cas de succes + * Delete emailing + * + * @param int $rowid id du mailing a supprimer + * @return int 1 en cas de succes */ function delete($rowid) { @@ -353,9 +359,10 @@ class Mailing extends CommonObject /** - * \brief Change status of each recipient - * \param user Objet user qui valide - * \return int <0 if KO, >0 if OK + * Change status of each recipient + * + * @param User $user Objet user qui valide + * @return int <0 if KO, >0 if OK */ function reset_targets_status($user) { @@ -379,9 +386,10 @@ class Mailing extends CommonObject /** - * \brief Retourne le libelle du statut d'un mailing (brouillon, validee, ... - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * \return string Libelle + * Retourne le libelle du statut d'un mailing (brouillon, validee, ... + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @return string Label */ function getLibStatut($mode=0) { @@ -389,10 +397,11 @@ class Mailing extends CommonObject } /** - * \brief Renvoi le libelle d'un statut donn� - * \param statut Id statut - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * \return string Libelle du statut + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label */ function LibStatut($statut,$mode=0) { diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 6cf95d57994..736a46e7036 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -48,7 +48,9 @@ $substitutionarray=array( '__OTHER2__' => 'Other2', '__OTHER3__' => 'Other3', '__OTHER4__' => 'Other4', -'__OTHER5__' => 'Other5' +'__OTHER5__' => 'Other5', +'__SIGNATURE__' => 'Signature', +'__PERSONALIZED__' => 'Personalized' ); $substitutionarrayfortest=array( '__ID__' => 'TESTIdRecord', @@ -61,7 +63,9 @@ $substitutionarrayfortest=array( '__OTHER2__' => 'TESTOther2', '__OTHER3__' => 'TESTOther3', '__OTHER4__' => 'TESTOther4', -'__OTHER5__' => 'TESTOther5' +'__OTHER5__' => 'TESTOther5', +'__SIGNATURE__' => 'TESTSignature', +'__PERSONALIZED__' => 'TESTPersonalized' ); @@ -192,7 +196,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes') '__OTHER4__' => $other4, '__OTHER5__' => $other5 ); - + $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 a5293e711dd..57dd86b63ac 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -66,8 +66,6 @@ $month=GETPOST("month"); // Nombre de ligne pour choix de produit/service predefinis $NBLINES=4; -$object = new Propal($db); - // Security check $module='propale'; if (isset($socid)) @@ -85,6 +83,14 @@ else if (isset($id) && $id > 0) if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, $module, $objectid, $dbtable); +$object = new Propal($db); + +// Load object +if ($id > 0 || ! empty($ref)) +{ + $ret=$object->fetch($id, $ref); +} + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); $hookmanager=new HookManager($db); @@ -144,39 +150,32 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop } // Remove line -else if ($action == 'confirm_deleteline' && $confirm == 'yes') +else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer) { - if ($user->rights->propale->creer) - { - $object->fetch($id); - $object->fetch_thirdparty(); - $result = $object->deleteline($lineid); - // reorder lines - if ($result) $object->line_order(true); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); - } - - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - } + $object->fetch($id); + $object->fetch_thirdparty(); + $result = $object->deleteline($lineid); + // reorder lines + if ($result) $object->line_order(true); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); + } + + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; } // Validation @@ -210,7 +209,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr } } -else if ($action == 'setdate') +else if ($action == 'setdate' && $user->rights->propale->creer) { $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); @@ -227,26 +226,19 @@ else if ($action == 'setdate') if ($result < 0) dol_print_error($db,$object->error); } } -else if ($action == 'setecheance') +else if ($action == 'setecheance' && $user->rights->propale->creer) { $object->fetch($id); $result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); if ($result < 0) dol_print_error($db,$object->error); } -else if ($action == 'setdate_livraison') +else if ($action == 'setdate_livraison' && $user->rights->propale->creer) { $object->fetch($id); $result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); if ($result < 0) dol_print_error($db,$object->error); } -else if ($action == 'setaddress' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->set_adresse_livraison($user,$_POST['fk_address']); - if ($result < 0) dol_print_error($db,$object->error); -} - // Positionne ref client else if ($action == 'set_ref_client' && $user->rights->propale->creer) { @@ -254,6 +246,20 @@ else if ($action == 'set_ref_client' && $user->rights->propale->creer) $object->set_ref_client($user, $_POST['ref_client']); } +else if ($action == 'setnote_public' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + // Create proposal else if ($action == 'add' && $user->rights->propale->creer) { @@ -396,7 +402,7 @@ else if ($action == 'add' && $user->rights->propale->creer) } // Classify billed -else if ($action == 'classifybilled') +else if ($action == 'classifybilled' && $user->rights->propale->cloturer) { $object->fetch($id); $object->cloture($user, 4, ''); @@ -425,7 +431,6 @@ else if ($action == 'setstatut' && $user->rights->propale->cloturer) { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'
'; $action='statut'; - $action='statut'; } else { @@ -486,11 +491,11 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P if ($result > 0) { - $objectref = dol_sanitizeFileName($object->ref); - $file = $conf->propale->dir_output . '/' . $objectref . '/' . $objectref . '.pdf'; +// $objectref = dol_sanitizeFileName($object->ref); +// $file = $conf->propal->dir_output . '/' . $objectref . '/' . $objectref . '.pdf'; - if (is_readable($file)) - { +// if (is_readable($file)) +// { if ($_POST['sendto']) { // Le destinataire a ete fourni via le champ libre @@ -612,13 +617,13 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; dol_syslog('Recipient email is empty'); } - } +/* } else { $langs->load("errors"); $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; dol_syslog('Failed to read file: '.$file); - } + }*/ } else { @@ -838,7 +843,7 @@ else if ($action == "addline" && $user->rights->propale->creer) } // Mise a jour d'une ligne dans la propale -if ($action == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) +else if ($action == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) { if (! $object->fetch($_POST["id"]) > 0) { @@ -945,31 +950,31 @@ else if ($action == 'builddoc' && $user->rights->propale->creer) } // Set project -else if ($action == 'classin') +else if ($action == 'classin' && $user->rights->propale->creer) { $object->fetch($id); $object->setProject($_POST['projectid']); } // Delai de livraison -else if ($action == 'setavailability') +else if ($action == 'setavailability' && $user->rights->propale->creer) { $object->fetch($id); $result = $object->availability($_POST['availability_id']); } // Origine de la propale -else if ($action == 'setdemandreason') +else if ($action == 'setdemandreason' && $user->rights->propale->creer) { $object->fetch($id); $result = $object->demand_reason($_POST['demand_reason_id']); } // Conditions de reglement -else if ($action == 'setconditions') +else if ($action == 'setconditions' && $user->rights->propale->creer) { $object->fetch($id); - $result = $object->cond_reglement($_POST['cond_reglement_id']); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int')); } else if ($action == 'setremisepercent' && $user->rights->propale->creer) @@ -985,10 +990,10 @@ else if ($action == 'setremiseabsolue' && $user->rights->propale->creer) } // Mode de reglement -else if ($action == 'setmode') +else if ($action == 'setmode' && $user->rights->propale->creer) { $object->fetch($id); - $result = $object->mode_reglement($_POST['mode_reglement_id']); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); } /* @@ -1039,6 +1044,68 @@ else if ($action == 'down' && $user->rights->propale->creer) exit; } +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +{ + if ($action == 'addcontact' && $user->rights->propale->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // Bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->propale->creer) + { + if ($object->fetch($id) > 0) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->propale->creer) + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + dol_print_error($db); + } + } +} + /* * View @@ -1062,8 +1129,6 @@ if ($id > 0 || ! empty($ref)) dol_htmloutput_mesg($mesg,$mesgs); - $object->fetch($id,$ref); - $soc = new Societe($db); $soc->fetch($object->socid); @@ -1087,25 +1152,25 @@ if ($id > 0 || ! empty($ref)) } // Confirm delete - if ($action == 'delete') + else if ($action == 'delete') { $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp',$object->ref), 'confirm_delete','',0,1); } // Confirm reopen - if ($action == 'reopen') + else if ($action == 'reopen') { $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp',$object->ref), 'confirm_reopen','',0,1); } // Confirmation delete product/service line - if ($action == 'ask_deleteline') + else if ($action == 'ask_deleteline') { $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); } // Confirm validate proposal - if ($action == 'validate') + else if ($action == 'validate') { $error=0; @@ -1180,8 +1245,6 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - $rowspan=11; - // Company print ''.$langs->trans('Company').''.$soc->getNomUrl(1).''; print ''; @@ -1247,20 +1310,6 @@ if ($id > 0 || ! empty($ref)) } print ''; - if ($conf->projet->enabled) $rowspan++; - if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) $rowspan++; - - //Local taxes - if ($mysoc->country_code=='ES') - { - if($mysoc->localtax1_assuj=="1") $rowspan++; - if($mysoc->localtax2_assuj=="1") $rowspan++; - } - - // Notes - print ''.$langs->trans('NotePublic').' :
'. nl2br($object->note_public).''; - print ''; - // Date end proposal print ''; print ''; @@ -1338,29 +1387,6 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // Delivery address (deprecated) - if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) - { - print ''; - print ''; - - if ($action != 'editdelivery_address' && $object->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; - print ''; - - if ($action == 'editdelivery_address') - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','propal',$object->id); - } - else - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','propal',$object->id); - } - print ''; - } - // Delivery delay print ''; print ''; - print ''; + print ''; print ''; // Amount VAT print ''; - print ''; + print ''; print ''; // Amount Local Taxes @@ -1494,26 +1520,44 @@ if ($id > 0 || ! empty($ref)) if ($mysoc->localtax1_assuj=="1") //Localtax1 RE { print ''; - print ''; + print ''; print ''; } if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF { print ''; - print ''; + print ''; print ''; } } // Amount TTC print ''; - print ''; + print ''; print ''; // Statut print ''; + print '
'; @@ -1480,12 +1506,12 @@ if ($id > 0 || ! empty($ref)) // Amount HT print '
'.$langs->trans('AmountHT').''.price($object->total_ht).''.price($object->total_ht).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.price($object->total_tva).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.price($object->total_ttc).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('Status').''.$object->getLibStatut(4).'

'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + /* * Lines */ @@ -1626,16 +1670,11 @@ if ($id > 0 || ! empty($ref)) // Send if ($object->statut == 1 || $object->statut == 2) { - $propref = dol_sanitizeFileName($object->ref); - $file = $conf->propale->dir_output . '/'.$propref.'/'.$propref.'.pdf'; - if (file_exists($file)) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propale->propal_advance->send) - { - print ''.$langs->trans('SendByMail').''; - } - else print ''.$langs->trans('SendByMail').''; - } + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propale->propal_advance->send) + { + print ''.$langs->trans('SendByMail').''; + } + else print ''.$langs->trans('SendByMail').''; } // Create an order @@ -1698,7 +1737,7 @@ if ($id > 0 || ! empty($ref)) * Documents generes */ $filename=dol_sanitizeFileName($object->ref); - $filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref); + $filedir=$conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed=$user->rights->propale->creer; $delallowed=$user->rights->propale->supprimer; @@ -1731,7 +1770,33 @@ if ($id > 0 || ! empty($ref)) if ($action == 'presend') { $ref = dol_sanitizeFileName($object->ref); - $file = $conf->propale->dir_output . '/' . $ref . '/' . $ref . '.pdf'; + include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref); + $file=$fileparams['fullname']; + + // Build document if it not exists + if (! $file || ! is_readable($file)) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref); + $file=$fileparams['fullname']; + } print '
'; print_titre($langs->trans('SendPropalByMail')); @@ -1758,6 +1823,8 @@ if ($id > 0 || ! empty($ref)) // Tableau des substitutions $formmail->substit['__PROPREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=''; + $formmail->substit['__PERSONALIZED__']=''; // Tableau des parametres complementaires $formmail->param['action']='send'; $formmail->param['models']='propal_send'; @@ -1765,10 +1832,10 @@ if ($id > 0 || ! empty($ref)) $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; // Init list of files - if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + if (GETPOST("mode")=='init') { $formmail->clear_attached_files(); - $formmail->add_attached_files($file,dol_sanitizeFilename($object->ref).'.pdf','application/pdf'); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); } $formmail->show_form(); @@ -1938,7 +2005,7 @@ else print ''; $filename=dol_sanitizeFileName($objp->ref); - $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($objp->ref); + $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->propalid; $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; @@ -2013,7 +2080,7 @@ else } +// End of page llxFooter(); - $db->close(); ?> diff --git a/htdocs/comm/propal/apercu.php b/htdocs/comm/propal/apercu.php index ea03bf2875a..af6b1a9d4f3 100644 --- a/htdocs/comm/propal/apercu.php +++ b/htdocs/comm/propal/apercu.php @@ -119,7 +119,7 @@ if ($id > 0 || ! empty($ref)) * Documents */ $objectref = dol_sanitizeFileName($object->ref); - $dir_output = $conf->propale->dir_output . "/"; + $dir_output = $conf->propal->dir_output . "/"; $filepath = $dir_output . $objectref . "/"; $file = $filepath . $objectref . ".pdf"; $filedetail = $filepath . $objectref . "-detail.pdf"; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 52782681785..0b7d018136c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -39,2447 +39,2368 @@ require_once(DOL_DOCUMENT_ROOT ."/contact/class/contact.class.php"); */ class Propal extends CommonObject { - public $element='propal'; - public $table_element='propal'; - public $table_element_line='propaldet'; - public $fk_element='fk_propal'; - protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - - var $id; - - var $socid; // Id client - var $client; // Objet societe client (a charger par fetch_client) - - var $contactid; - var $fk_project; - var $author; - var $ref; - var $ref_client; - var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed) - var $datec; // Date of creation - var $datev; // Date of validation - var $date; // Date of proposal - var $datep; // Same than date - var $date_livraison; - var $fin_validite; - - var $user_author_id; - var $user_valid_id; - var $user_close_id; - - var $total_ht; // Total net of tax - var $total_tva; // Total VAT - var $total_localtax1; // Total Local Taxes 1 - var $total_localtax2; // Total Local Taxes 2 - var $total_ttc; // Total with tax - var $price; // deprecated (for compatibility) - var $tva; // deprecated (for compatibility) - var $total; // deprecated (for compatibility) - - var $cond_reglement_id; - var $cond_reglement_code; - var $mode_reglement_id; - var $mode_reglement_code; - var $remise; - var $remise_percent; - var $remise_absolue; - var $note; - var $note_public; - var $fk_delivery_address; // deprecated (for compatibility) - var $fk_address; - var $address_type; - var $adresse; - var $availability_id; - var $availability_code; - var $demand_reason_id; - var $demand_reason_code; - - var $products=array(); - - var $lines = array(); - var $line; - - var $origin; - var $origin_id; - - var $labelstatut=array(); - var $labelstatut_short=array(); - - // Pour board - var $nbtodo; - var $nbtodolate; - - var $specimen; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param int $socid Id third party - * @param int $propalid Id proposal - */ - function Propal($db, $socid="", $propalid=0) - { - global $conf,$langs; - - $this->db = $db; - $this->socid = $socid; - $this->id = $propalid; - $this->products = array(); - $this->remise = 0; - $this->remise_percent = 0; - $this->remise_absolue = 0; - - $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; - - $langs->load("propal"); - $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); - $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); - $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); - $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); - $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); - $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); - $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); - $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); - $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); - $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); - } - - - /** - * Add line into array products - * $this->client doit etre charge - * - * @param int $idproduct Product Id to add - * @param int $qty Quantity - * @param int $remise_percent Discount effected on Product - * - * TODO Remplacer les appels a cette fonction par generation objet Ligne - * insere dans tableau $this->products - */ - function add_product($idproduct, $qty, $remise_percent=0) - { - global $conf, $mysoc; - - if (! $qty) $qty = 1; - - dol_syslog("Propal::add_product $idproduct, $qty, $remise_percent"); - if ($idproduct > 0) - { - $prod=new Product($this->db); - $prod->fetch($idproduct); - - $productdesc = $prod->description; - - $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); - // local taxes - $localtax1_tx = get_default_localtax($mysoc,$this->client,1,$prod->tva_tx); - $localtax2_tx = get_default_localtax($mysoc,$this->client,2,$prod->tva_tx); - - // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) - { - $price = $prod->multiprices[$this->client->price_level]; - } - else - { - $price = $prod->price; - } - - $line = new PropaleLigne($this->db); - - $line->fk_product=$idproduct; - $line->desc=$productdesc; - $line->qty=$qty; - $line->subprice=$price; - $line->remise_percent=$remise_percent; - $line->tva_tx=$tva_tx; - - $this->products[]=$line; - } - } - - /** - * Adding line of fixed discount in the proposal in DB - * - * @param int @idremise Id of fixed discount - * @return int >0 si ok, <0 si ko - */ - function insert_discount($idremise) - { - global $langs; - - include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); - include_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); - - $this->db->begin(); - - $remise=new DiscountAbsolute($this->db); - $result=$remise->fetch($idremise); - - if ($result > 0) - { - if ($remise->fk_facture) // Protection against multiple submission - { - $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); - $this->db->rollback(); - return -5; - } - - $propalligne=new PropaleLigne($this->db); - $propalligne->fk_propal=$this->id; - $propalligne->fk_remise_except=$remise->id; - $propalligne->desc=$remise->description; // Description ligne - $propalligne->tva_tx=$remise->tva_tx; - $propalligne->subprice=-$remise->amount_ht; - $propalligne->fk_product=0; // Id produit predefini - $propalligne->qty=1; - $propalligne->remise=0; - $propalligne->remise_percent=0; - $propalligne->rang=-1; - $propalligne->info_bits=2; - - // TODO deprecated - $propalligne->price=-$remise->amount_ht; - - $propalligne->total_ht = -$remise->amount_ht; - $propalligne->total_tva = -$remise->amount_tva; - $propalligne->total_ttc = -$remise->amount_ttc; - - $result=$propalligne->insert(); - if ($result > 0) - { - $result=$this->update_price(1); - if ($result > 0) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } - else - { - $this->error=$propalligne->error; - $this->db->rollback(); - return -2; - } - } - else - { - $this->db->rollback(); - return -2; - } - } - - /** - * Add a proposal line into database (linked to product/service or not) - * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel - * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini - * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit) - * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) - * - * @param int $propalid Id de la propale - * @param string $desc Description de la ligne - * @param double $pu_ht Prix unitaire - * @param double $qty Quantite - * @param double $txtva Taux de tva - * @param double $txlocaltax1 Local tax 1 rate - * @param double $txlocaltax2 Local tax 2 rate - * @param int $fk_product Id du produit/service predefini - * @param double $remise_percent Pourcentage de remise de la ligne - * @param string $price_base_type HT or TTC - * @param dobule $pu_ttc Prix unitaire TTC - * @param int $info_bits Bits de type de lignes - * @param int $type Type of line (product, service) - * @param int $rang Position of line - * @param int $special_code Special code - * @param int $fk_parent_line Id of parent line - * @return int >0 if OK, <0 if KO - * - * @see add_product - */ - function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0) - { - global $conf; - - dol_syslog("Propal::Addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); - include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); - - // Clean parameters - if (empty($remise_percent)) $remise_percent=0; - if (empty($qty)) $qty=0; - if (empty($info_bits)) $info_bits=0; - if (empty($rang)) $rang=0; - if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; - - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - $pu_ht=price2num($pu_ht); - $pu_ttc=price2num($pu_ttc); - $txtva=price2num($txtva); - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); - if ($price_base_type=='HT') - { - $pu=$pu_ht; - } - else - { - $pu=$pu_ttc; - } - - // Check parameters - if ($type < 0) return -1; - - if ($this->statut == 0) - { - $this->db->begin(); - - // Calcul du total TTC et de la TVA pour la ligne a partir de - // qty, pu, remise_percent et txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1 = $tabprice[9]; - $total_localtax2 = $tabprice[10]; - - // Rang to use - $rangtouse = $rang; - if ($rangtouse == -1) - { - $rangmax = $this->line_max($fk_parent_line); - $rangtouse = $rangmax + 1; - } - - // TODO A virer - // Anciens indicateurs: $price, $remise (a ne plus utiliser) - $price = $pu; - $remise = 0; - if ($remise_percent > 0) - { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; - } - - // Insert line - $this->line=new PropaleLigne($this->db); - - $this->line->fk_propal=$propalid; - $this->line->desc=$desc; - $this->line->qty=$qty; - $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=$txlocaltax1; - $this->line->localtax2_tx=$txlocaltax2; - $this->line->fk_product=$fk_product; - $this->line->remise_percent=$remise_percent; - $this->line->subprice=$pu_ht; - $this->line->rang=$rangtouse; - $this->line->info_bits=$info_bits; - $this->line->total_ht=$total_ht; - $this->line->total_tva=$total_tva; - $this->line->total_localtax1=$total_localtax1; - $this->line->total_localtax2=$total_localtax2; - $this->line->total_ttc=$total_ttc; - $this->line->product_type=$type; - $this->line->special_code=$special_code; - $this->line->fk_parent_line=$fk_parent_line; - - // Mise en option de la ligne - //if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty) $ligne->special_code=3; - if (empty($qty) && empty($special_code)) $this->line->special_code=3; - - // TODO deprecated - $this->line->price=$price; - $this->line->remise=$remise; - - $result=$this->line->insert(); - if ($result > 0) - { - // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); - - // Mise a jour informations denormalisees au niveau de la propale meme - $result=$this->update_price(1); - if ($result > 0) - { - $this->db->commit(); - return $this->line->rowid; - } - else - { - $this->error=$this->db->error(); - dol_syslog("Error sql=$sql, error=".$this->error,LOG_ERR); - $this->db->rollback(); - return -1; - } - } - else - { - $this->error=$this->line->error; - $this->db->rollback(); - return -2; - } - } - } - - - /** - * Update a proposal line - * - * @param int $rowid Id de la ligne - * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) - * @param double $qty Quantity - * @param double $remise_percent Remise effectuee sur le produit - * @param double $txtva Taux de TVA - * @param double $txlocaltax1 Local tax 1 rate - * @param double $txlocaltax2 Local tax 2 rate - * @param string $desc Description - * @param double $price_base_type HT ou TTC - * @param int $info_bits Miscellanous informations - * @param int $special_code Set special code ('' = we don't change it) - * @param int $fk_parent_line Id of line parent - * @param int $skip_update_total Skip update total - * @return int 0 if OK, <0 if KO - */ - function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0) - { - global $conf,$user,$langs; - - dol_syslog("Propal::UpdateLine $rowid, $pu, $qty, $remise_percent, $txtva, $desc, $price_base_type, $info_bits"); - include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); - - // Clean parameters - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - $pu = price2num($pu); - $txtva = price2num($txtva); - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); - if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag - if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag - - if ($this->statut == 0) - { - $this->db->begin(); - - // Calcul du total TTC et de la TVA pour la ligne a partir de - // qty, pu, remise_percent et txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); - $total_ht = $tabprice[0]; - $total_tva = $tabprice[1]; - $total_ttc = $tabprice[2]; - $total_localtax1 = $tabprice[9]; - $total_localtax2 = $tabprice[10]; - - // Anciens indicateurs: $price, $remise (a ne plus utiliser) - $price = $pu; - if ($remise_percent > 0) - { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; - } - - // Update line - $this->line=new PropaleLigne($this->db); - - // Stock previous line records - $staticline=new PropaleLigne($this->db); - $staticline->fetch($rowid); - $this->line->oldline = $staticline; - - // Reorder if fk_parent_line change - if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) - { - $rangmax = $this->line_max($fk_parent_line); - $this->line->rang = $rangmax + 1; - } - - $this->line->rowid = $rowid; - $this->line->desc = $desc; - $this->line->qty = $qty; - $this->line->tva_tx = $txtva; - $this->line->localtax1_tx = $txlocaltax1; - $this->line->localtax2_tx = $txlocaltax2; - $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu; - $this->line->info_bits = $info_bits; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; - $this->line->special_code = $special_code; - $this->line->fk_parent_line = $fk_parent_line; - $this->line->skip_update_total = $skip_update_total; - - // TODO deprecated - $this->line->price=$price; - $this->line->remise=$remise; - - $result=$this->line->update(); - if ($result > 0) - { - // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); - - $this->update_price(1); - - $this->fk_propal = $this->id; - $this->rowid = $rowid; - - $this->db->commit(); - return $result; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - dol_syslog("Propal::UpdateLine Error=".$this->error, LOG_ERR); - return -1; - } - } - else - { - dol_syslog("Propal::UpdateLigne Erreur -2 Propal en mode incompatible pour cette action"); - return -2; - } - } - - - /** - * Delete detail line - * - * @param int $lineid Id of line to delete - * @return int >0 if OK, <0 if KO - */ - function deleteline($lineid) - { - if ($this->statut == 0) - { - $line=new PropaleLigne($this->db); - - // For triggers - $line->fetch($lineid); - - if ($line->delete() > 0) - { - $this->update_price(1); - - return 1; - } - else - { - return -1; - } - } - else - { - return -2; - } - } - - - /** - * Create commercial proposal into database - * this->ref can be set or empty. If empty, we will use "(PROVid)" - * - * @param User $user User that create - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers - * @return int <0 if KO, >=0 if OK - */ - function create($user='', $notrigger=0) - { - global $langs,$conf,$mysoc; - $error=0; - - $now=dol_now(); - - // Clean parameters - if (empty($this->date)) $this->date=$this->datep; - $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); + public $element='propal'; + public $table_element='propal'; + public $table_element_line='propaldet'; + public $fk_element='fk_propal'; + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + + var $id; + + var $socid; // Id client + var $client; // Objet societe client (a charger par fetch_client) + + var $contactid; + var $fk_project; + var $author; + var $ref; + var $ref_client; + var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed) + var $datec; // Date of creation + var $datev; // Date of validation + var $date; // Date of proposal + var $datep; // Same than date + var $date_livraison; + var $fin_validite; + + var $user_author_id; + var $user_valid_id; + var $user_close_id; + + var $total_ht; // Total net of tax + var $total_tva; // Total VAT + var $total_localtax1; // Total Local Taxes 1 + var $total_localtax2; // Total Local Taxes 2 + var $total_ttc; // Total with tax + var $price; // deprecated (for compatibility) + var $tva; // deprecated (for compatibility) + var $total; // deprecated (for compatibility) + + var $cond_reglement_id; + var $cond_reglement_code; + var $mode_reglement_id; + var $mode_reglement_code; + var $remise; + var $remise_percent; + var $remise_absolue; + var $note; // deprecated (for compatibility) + var $note_private; + var $note_public; + var $fk_delivery_address; // deprecated (for compatibility) + var $fk_address; + var $address_type; + var $adresse; + var $availability_id; + var $availability_code; + var $demand_reason_id; + var $demand_reason_code; + + var $products=array(); + var $extraparams=array(); + + var $lines = array(); + var $line; + + var $origin; + var $origin_id; + + var $labelstatut=array(); + var $labelstatut_short=array(); + + // Pour board + var $nbtodo; + var $nbtodolate; + + var $specimen; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party + * @param int $propalid Id proposal + */ + function Propal($db, $socid="", $propalid=0) + { + global $conf,$langs; + + $this->db = $db; + $this->socid = $socid; + $this->id = $propalid; + $this->products = array(); + $this->remise = 0; + $this->remise_percent = 0; + $this->remise_absolue = 0; + + $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; + + $langs->load("propal"); + $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); + $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); + $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); + $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); + $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); + $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); + $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); + $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); + $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); + $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); + } + + + /** + * Add line into array products + * $this->client doit etre charge + * + * @param int $idproduct Product Id to add + * @param int $qty Quantity + * @param int $remise_percent Discount effected on Product + * @return int <0 if KO, >0 if OK + * + * TODO Remplacer les appels a cette fonction par generation objet Ligne + * insere dans tableau $this->products + */ + function add_product($idproduct, $qty, $remise_percent=0) + { + global $conf, $mysoc; + + if (! $qty) $qty = 1; + + dol_syslog("Propal::add_product $idproduct, $qty, $remise_percent"); + if ($idproduct > 0) + { + $prod=new Product($this->db); + $prod->fetch($idproduct); + + $productdesc = $prod->description; + + $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); + // local taxes + $localtax1_tx = get_default_localtax($mysoc,$this->client,1,$prod->tva_tx); + $localtax2_tx = get_default_localtax($mysoc,$this->client,2,$prod->tva_tx); + + // multiprix + if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) + { + $price = $prod->multiprices[$this->client->price_level]; + } + else + { + $price = $prod->price; + } + + $line = new PropaleLigne($this->db); + + $line->fk_product=$idproduct; + $line->desc=$productdesc; + $line->qty=$qty; + $line->subprice=$price; + $line->remise_percent=$remise_percent; + $line->tva_tx=$tva_tx; + + $this->products[]=$line; + } + } + + /** + * Adding line of fixed discount in the proposal in DB + * + * @param int $idremise Id of fixed discount + * @return int >0 if OK, <0 if KO + */ + function insert_discount($idremise) + { + global $langs; + + include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); + include_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); + + $this->db->begin(); + + $remise=new DiscountAbsolute($this->db); + $result=$remise->fetch($idremise); + + if ($result > 0) + { + if ($remise->fk_facture) // Protection against multiple submission + { + $this->error=$langs->trans("ErrorDiscountAlreadyUsed"); + $this->db->rollback(); + return -5; + } + + $propalligne=new PropaleLigne($this->db); + $propalligne->fk_propal=$this->id; + $propalligne->fk_remise_except=$remise->id; + $propalligne->desc=$remise->description; // Description ligne + $propalligne->tva_tx=$remise->tva_tx; + $propalligne->subprice=-$remise->amount_ht; + $propalligne->fk_product=0; // Id produit predefini + $propalligne->qty=1; + $propalligne->remise=0; + $propalligne->remise_percent=0; + $propalligne->rang=-1; + $propalligne->info_bits=2; + + // TODO deprecated + $propalligne->price=-$remise->amount_ht; + + $propalligne->total_ht = -$remise->amount_ht; + $propalligne->total_tva = -$remise->amount_tva; + $propalligne->total_ttc = -$remise->amount_ttc; + + $result=$propalligne->insert(); + if ($result > 0) + { + $result=$this->update_price(1); + if ($result > 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$propalligne->error; + $this->db->rollback(); + return -2; + } + } + else + { + $this->db->rollback(); + return -2; + } + } + + /** + * Add a proposal line into database (linked to product/service or not) + * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel + * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit) + * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) + * + * @param int $propalid Id de la propale + * @param string $desc Description de la ligne + * @param double $pu_ht Prix unitaire + * @param double $qty Quantite + * @param double $txtva Taux de tva + * @param double $txlocaltax1 Local tax 1 rate + * @param double $txlocaltax2 Local tax 2 rate + * @param int $fk_product Id du produit/service predefini + * @param double $remise_percent Pourcentage de remise de la ligne + * @param string $price_base_type HT or TTC + * @param dobule $pu_ttc Prix unitaire TTC + * @param int $info_bits Bits de type de lignes + * @param int $type Type of line (product, service) + * @param int $rang Position of line + * @param int $special_code Special code + * @param int $fk_parent_line Id of parent line + * @return int >0 if OK, <0 if KO + * + * @see add_product + */ + function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0) + { + global $conf; + + dol_syslog("Propal::Addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); + include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); + + // Clean parameters + if (empty($remise_percent)) $remise_percent=0; + if (empty($qty)) $qty=0; + if (empty($info_bits)) $info_bits=0; + if (empty($rang)) $rang=0; + if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + + $remise_percent=price2num($remise_percent); + $qty=price2num($qty); + $pu_ht=price2num($pu_ht); + $pu_ttc=price2num($pu_ttc); + $txtva=price2num($txtva); + $txlocaltax1=price2num($txlocaltax1); + $txlocaltax2=price2num($txlocaltax2); + if ($price_base_type=='HT') + { + $pu=$pu_ht; + } + else + { + $pu=$pu_ttc; + } + + // Check parameters + if ($type < 0) return -1; + + if ($this->statut == 0) + { + $this->db->begin(); + + // Calcul du total TTC et de la TVA pour la ligne a partir de + // qty, pu, remise_percent et txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + + // Rang to use + $rangtouse = $rang; + if ($rangtouse == -1) + { + $rangmax = $this->line_max($fk_parent_line); + $rangtouse = $rangmax + 1; + } + + // TODO A virer + // Anciens indicateurs: $price, $remise (a ne plus utiliser) + $price = $pu; + $remise = 0; + if ($remise_percent > 0) + { + $remise = round(($pu * $remise_percent / 100), 2); + $price = $pu - $remise; + } + + // Insert line + $this->line=new PropaleLigne($this->db); + + $this->line->fk_propal=$propalid; + $this->line->desc=$desc; + $this->line->qty=$qty; + $this->line->tva_tx=$txtva; + $this->line->localtax1_tx=$txlocaltax1; + $this->line->localtax2_tx=$txlocaltax2; + $this->line->fk_product=$fk_product; + $this->line->remise_percent=$remise_percent; + $this->line->subprice=$pu_ht; + $this->line->rang=$rangtouse; + $this->line->info_bits=$info_bits; + $this->line->total_ht=$total_ht; + $this->line->total_tva=$total_tva; + $this->line->total_localtax1=$total_localtax1; + $this->line->total_localtax2=$total_localtax2; + $this->line->total_ttc=$total_ttc; + $this->line->product_type=$type; + $this->line->special_code=$special_code; + $this->line->fk_parent_line=$fk_parent_line; + + // Mise en option de la ligne + //if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty) $ligne->special_code=3; + if (empty($qty) && empty($special_code)) $this->line->special_code=3; + + // TODO deprecated + $this->line->price=$price; + $this->line->remise=$remise; + + $result=$this->line->insert(); + if ($result > 0) + { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); + + // Mise a jour informations denormalisees au niveau de la propale meme + $result=$this->update_price(1); + if ($result > 0) + { + $this->db->commit(); + return $this->line->rowid; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Error sql=$sql, error=".$this->error,LOG_ERR); + $this->db->rollback(); + return -1; + } + } + else + { + $this->error=$this->line->error; + $this->db->rollback(); + return -2; + } + } + } + + + /** + * Update a proposal line + * + * @param int $rowid Id de la ligne + * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) + * @param double $qty Quantity + * @param double $remise_percent Remise effectuee sur le produit + * @param double $txtva Taux de TVA + * @param double $txlocaltax1 Local tax 1 rate + * @param double $txlocaltax2 Local tax 2 rate + * @param string $desc Description + * @param double $price_base_type HT ou TTC + * @param int $info_bits Miscellanous informations + * @param int $special_code Set special code ('' = we don't change it) + * @param int $fk_parent_line Id of line parent + * @param int $skip_update_total Skip update total + * @return int 0 if OK, <0 if KO + */ + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0) + { + global $conf,$user,$langs; + + dol_syslog("Propal::UpdateLine $rowid, $pu, $qty, $remise_percent, $txtva, $desc, $price_base_type, $info_bits"); + include_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); + + // Clean parameters + $remise_percent=price2num($remise_percent); + $qty=price2num($qty); + $pu = price2num($pu); + $txtva = price2num($txtva); + $txlocaltax1=price2num($txlocaltax1); + $txlocaltax2=price2num($txlocaltax2); + if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag + if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag + + if ($this->statut == 0) + { + $this->db->begin(); + + // Calcul du total TTC et de la TVA pour la ligne a partir de + // qty, pu, remise_percent et txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); + $total_ht = $tabprice[0]; + $total_tva = $tabprice[1]; + $total_ttc = $tabprice[2]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; + + // Anciens indicateurs: $price, $remise (a ne plus utiliser) + $price = $pu; + if ($remise_percent > 0) + { + $remise = round(($pu * $remise_percent / 100), 2); + $price = $pu - $remise; + } + + // Update line + $this->line=new PropaleLigne($this->db); + + // Stock previous line records + $staticline=new PropaleLigne($this->db); + $staticline->fetch($rowid); + $this->line->oldline = $staticline; + + // Reorder if fk_parent_line change + if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + { + $rangmax = $this->line_max($fk_parent_line); + $this->line->rang = $rangmax + 1; + } + + $this->line->rowid = $rowid; + $this->line->desc = $desc; + $this->line->qty = $qty; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = $txlocaltax1; + $this->line->localtax2_tx = $txlocaltax2; + $this->line->remise_percent = $remise_percent; + $this->line->subprice = $pu; + $this->line->info_bits = $info_bits; + $this->line->total_ht = $total_ht; + $this->line->total_tva = $total_tva; + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; + $this->line->total_ttc = $total_ttc; + $this->line->special_code = $special_code; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->skip_update_total = $skip_update_total; + + // TODO deprecated + $this->line->price=$price; + $this->line->remise=$remise; + + $result=$this->line->update(); + if ($result > 0) + { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); + + $this->update_price(1); + + $this->fk_propal = $this->id; + $this->rowid = $rowid; + + $this->db->commit(); + return $result; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + dol_syslog("Propal::UpdateLine Error=".$this->error, LOG_ERR); + return -1; + } + } + else + { + dol_syslog("Propal::UpdateLigne Erreur -2 Propal en mode incompatible pour cette action"); + return -2; + } + } + + + /** + * Delete detail line + * + * @param int $lineid Id of line to delete + * @return int >0 if OK, <0 if KO + */ + function deleteline($lineid) + { + if ($this->statut == 0) + { + $line=new PropaleLigne($this->db); + + // For triggers + $line->fetch($lineid); + + if ($line->delete() > 0) + { + $this->update_price(1); + + return 1; + } + else + { + return -1; + } + } + else + { + return -2; + } + } + + + /** + * Create commercial proposal into database + * this->ref can be set or empty. If empty, we will use "(PROVid)" + * + * @param User $user User that create + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if KO, >=0 if OK + */ + function create($user='', $notrigger=0) + { + global $langs,$conf,$mysoc; + $error=0; + + $now=dol_now(); + + // Clean parameters + if (empty($this->date)) $this->date=$this->datep; + $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); if (empty($this->availability_id)) $this->availability_id=0; if (empty($this->demand_reason_id)) $this->demand_reason_id=0; - dol_syslog(get_class($this)."::create"); + dol_syslog(get_class($this)."::create"); - // Check parameters - $soc = new Societe($this->db); - $result=$soc->fetch($this->socid); - if ($result < 0) - { - $this->error="Failed to fetch company"; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -3; - } - if (empty($this->date)) - { - $this->error="Date of proposal is required"; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -4; - } - if (! empty($this->ref)) - { - $result=$this->verifyNumRef(); // Check ref is not yet used - } + // Check parameters + $soc = new Societe($this->db); + $result=$soc->fetch($this->socid); + if ($result < 0) + { + $this->error="Failed to fetch company"; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -3; + } + if (empty($this->date)) + { + $this->error="Date of proposal is required"; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -4; + } + if (! empty($this->ref)) + { + $result=$this->verifyNumRef(); // Check ref is not yet used + } - $this->db->begin(); + $this->db->begin(); - $this->fetch_thirdparty(); + $this->fetch_thirdparty(); - // Insert into database - $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal ("; - $sql.= "fk_soc"; - $sql.= ", price"; - $sql.= ", remise"; - $sql.= ", remise_percent"; - $sql.= ", remise_absolue"; - $sql.= ", tva"; - $sql.= ", total"; - $sql.= ", datep"; - $sql.= ", datec"; - $sql.= ", ref"; - $sql.= ", fk_user_author"; - $sql.= ", note"; - $sql.= ", note_public"; - $sql.= ", model_pdf"; - $sql.= ", fin_validite"; - $sql.= ", fk_cond_reglement"; - $sql.= ", fk_mode_reglement"; - $sql.= ", ref_client"; - $sql.= ", date_livraison"; - $sql.= ", fk_availability"; - $sql.= ", fk_demand_reason"; - $sql.= ", fk_projet"; - $sql.= ", entity"; - $sql.= ") "; - $sql.= " VALUES ("; - $sql.= $this->socid; - $sql.= ", 0"; - $sql.= ", ".$this->remise; - $sql.= ", ".($this->remise_percent?$this->remise_percent:'null'); - $sql.= ", ".($this->remise_absolue?$this->remise_absolue:'null'); - $sql.= ", 0"; - $sql.= ", 0"; - $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", '(PROV)'"; - $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); - $sql.= ", '".$this->db->escape($this->note)."'"; - $sql.= ", '".$this->db->escape($this->note_public)."'"; - $sql.= ", '".$this->modelpdf."'"; - $sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"null"); - $sql.= ", ".$this->cond_reglement_id; - $sql.= ", ".$this->mode_reglement_id; - $sql.= ", '".$this->db->escape($this->ref_client)."'"; - $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null"); - $sql.= ", ".$this->availability_id; - $sql.= ", ".$this->demand_reason_id; - $sql.= ", ".($this->fk_project?$this->fk_project:"null"); - $sql.= ", ".$conf->entity; - $sql.= ")"; + // Insert into database + $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal ("; + $sql.= "fk_soc"; + $sql.= ", price"; + $sql.= ", remise"; + $sql.= ", remise_percent"; + $sql.= ", remise_absolue"; + $sql.= ", tva"; + $sql.= ", total"; + $sql.= ", datep"; + $sql.= ", datec"; + $sql.= ", ref"; + $sql.= ", fk_user_author"; + $sql.= ", note"; + $sql.= ", note_public"; + $sql.= ", model_pdf"; + $sql.= ", fin_validite"; + $sql.= ", fk_cond_reglement"; + $sql.= ", fk_mode_reglement"; + $sql.= ", ref_client"; + $sql.= ", date_livraison"; + $sql.= ", fk_availability"; + $sql.= ", fk_demand_reason"; + $sql.= ", fk_projet"; + $sql.= ", entity"; + $sql.= ") "; + $sql.= " VALUES ("; + $sql.= $this->socid; + $sql.= ", 0"; + $sql.= ", ".$this->remise; + $sql.= ", ".($this->remise_percent?$this->remise_percent:'null'); + $sql.= ", ".($this->remise_absolue?$this->remise_absolue:'null'); + $sql.= ", 0"; + $sql.= ", 0"; + $sql.= ", '".$this->db->idate($this->date)."'"; + $sql.= ", '".$this->db->idate($now)."'"; + $sql.= ", '(PROV)'"; + $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); + $sql.= ", '".$this->db->escape($this->note)."'"; + $sql.= ", '".$this->db->escape($this->note_public)."'"; + $sql.= ", '".$this->modelpdf."'"; + $sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"null"); + $sql.= ", ".$this->cond_reglement_id; + $sql.= ", ".$this->mode_reglement_id; + $sql.= ", '".$this->db->escape($this->ref_client)."'"; + $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null"); + $sql.= ", ".$this->availability_id; + $sql.= ", ".$this->demand_reason_id; + $sql.= ", ".($this->fk_project?$this->fk_project:"null"); + $sql.= ", ".$conf->entity; + $sql.= ")"; - dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal"); + dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal"); - if ($this->id) - { - if (empty($this->ref)) $this->ref='(PROV'.$this->id.')'; - $sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->ref."' WHERE rowid=".$this->id; + if ($this->id) + { + if (empty($this->ref)) $this->ref='(PROV'.$this->id.')'; + $sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->ref."' WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::create sql=".$sql); - $resql=$this->db->query($sql); - if (! $resql) $error++; + dol_syslog(get_class($this)."::create sql=".$sql); + $resql=$this->db->query($sql); + if (! $resql) $error++; - /* - * Insertion du detail des produits dans la base - */ - if (! $error) - { - $fk_parent_line=0; - $num=count($this->lines); + /* + * Insertion du detail des produits dans la base + */ + if (! $error) + { + $fk_parent_line=0; + $num=count($this->lines); - for ($i=0;$i<$num;$i++) - { - // Reset fk_parent_line for no child products and special product - if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } + for ($i=0;$i<$num;$i++) + { + // Reset fk_parent_line for no child products and special product + if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } - $result = $this->addline( - $this->id, - $this->lines[$i]->desc, - $this->lines[$i]->subprice, - $this->lines[$i]->qty, - $this->lines[$i]->tva_tx, - $this->lines[$i]->localtax1_tx, - $this->lines[$i]->localtax2_tx, - $this->lines[$i]->fk_product, - $this->lines[$i]->remise_percent, - 'HT', - 0, - 0, - $this->lines[$i]->product_type, - $this->lines[$i]->rang, - $this->lines[$i]->special_code, - $fk_parent_line - ); + $result = $this->addline( + $this->id, + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->fk_product, + $this->lines[$i]->remise_percent, + 'HT', + 0, + 0, + $this->lines[$i]->product_type, + $this->lines[$i]->rang, + $this->lines[$i]->special_code, + $fk_parent_line + ); - if ($result < 0) - { - $error++; - $this->error=$this->db->error; - dol_print_error($this->db); - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $this->lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - } + if ($result < 0) + { + $error++; + $this->error=$this->db->error; + dol_print_error($this->db); + break; + } + // Defined the new fk_parent_line + if ($result > 0 && $this->lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + } - // Add linked object - if (! $error && $this->origin && $this->origin_id) - { - $ret = $this->add_object_linked(); - if (! $ret) dol_print_error($this->db); - } + // Add linked object + if (! $error && $this->origin && $this->origin_id) + { + $ret = $this->add_object_linked(); + if (! $ret) dol_print_error($this->db); + } - // Set delivery address - if (! $error && $this->fk_delivery_address) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_adresse_livraison = ".$this->fk_delivery_address; - $sql.= " WHERE ref = '".$this->ref."'"; - $sql.= " AND entity = ".$conf->entity; + // Set delivery address + if (! $error && $this->fk_delivery_address) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_adresse_livraison = ".$this->fk_delivery_address; + $sql.= " WHERE ref = '".$this->ref."'"; + $sql.= " AND entity = ".$conf->entity; - $result=$this->db->query($sql); - } + $result=$this->db->query($sql); + } - if (! $error) - { - // Mise a jour infos denormalisees - $resql=$this->update_price(1); - if ($resql) - { - if (! $notrigger) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } - } - else - { - $error++; - } - } - } - else - { - $error++; - } + if (! $error) + { + // Mise a jour infos denormalisees + $resql=$this->update_price(1); + if ($resql) + { + if (! $notrigger) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } + } + else + { + $error++; + } + } + } + else + { + $error++; + } - if (! $error) - { - $this->db->commit(); - dol_syslog(get_class($this)."::create done id=".$this->id); - return $this->id; - } - else - { - $this->error=$this->db->error(); - dol_syslog(get_class($this)."::create -2 ".$this->error, LOG_ERR); - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->error(); - dol_syslog(get_class($this)."::create -1 ".$this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - } + if (! $error) + { + $this->db->commit(); + dol_syslog(get_class($this)."::create done id=".$this->id); + return $this->id; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::create -2 ".$this->error, LOG_ERR); + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::create -1 ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } - /** - * Insert into DB a proposal object completely defined by its data members (ex, results from copy). - * @param User $user User that create - * @return int Id of the new object if ok, <0 if ko - * @see create - */ - function create_from($user) - { - $this->products=$this->lines; + /** + * Insert into DB a proposal object completely defined by its data members (ex, results from copy). + * + * @param User $user User that create + * @return int Id of the new object if ok, <0 if ko + * @see create + */ + function create_from($user) + { + $this->products=$this->lines; - return $this->create(); - } + return $this->create(); + } - /** - * Load an object from its id and create a new one in database - * - * @param int $socid Id of thirdparty - * @param HookManager $hookmanager Hook manager instance - * @return int New id of clone - */ - function createFromClone($socid=0,$hookmanager=false) - { - global $user,$langs,$conf; + /** + * Load an object from its id and create a new one in database + * + * @param int $socid Id of thirdparty + * @param HookManager $hookmanager Hook manager instance + * @return int New id of clone + */ + function createFromClone($socid=0,$hookmanager=false) + { + global $user,$langs,$conf; - $error=0; - $now=dol_now(); + $error=0; + $now=dol_now(); - $this->db->begin(); + $this->db->begin(); - // Load source object - $objFrom = dol_clone($this); + // Load source object + $objFrom = dol_clone($this); - $objsoc=new Societe($this->db); + $objsoc=new Societe($this->db); - // Change socid if needed - if (! empty($socid) && $socid != $this->socid) - { - if ($objsoc->fetch($socid) > 0) - { - $this->socid = $objsoc->id; - $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $this->fk_project = ''; - $this->fk_delivery_address = ''; - } + // Change socid if needed + if (! empty($socid) && $socid != $this->socid) + { + if ($objsoc->fetch($socid) > 0) + { + $this->socid = $objsoc->id; + $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $this->fk_project = ''; + $this->fk_delivery_address = ''; + } - // TODO Change product price if multi-prices - } - else - { - $objsoc->fetch($this->socid); - } + // TODO Change product price if multi-prices + } + else + { + $objsoc->fetch($this->socid); + } - $this->id=0; - $this->statut=0; + $this->id=0; + $this->statut=0; - if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) - { - $this->error='ErrorSetupNotComplete'; - return -1; - } + if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) + { + $this->error='ErrorSetupNotComplete'; + return -1; + } - // Clear fields - $this->user_author = $user->id; - $this->user_valid = ''; - $this->date = $now; - $this->datep = $now; // deprecated - $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); - $this->ref_client = ''; + // Clear fields + $this->user_author = $user->id; + $this->user_valid = ''; + $this->date = $now; + $this->datep = $now; // deprecated + $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); + $this->ref_client = ''; - // Set ref - require_once(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"); - $obj = $conf->global->PROPALE_ADDON; - $modPropale = new $obj; - $this->ref = $modPropale->getNextValue($objsoc,$this); + // Set ref + require_once(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"); + $obj = $conf->global->PROPALE_ADDON; + $modPropale = new $obj; + $this->ref = $modPropale->getNextValue($objsoc,$this); - // Create clone - $result=$this->create($user); - if ($result < 0) $error++; + // Create clone + $result=$this->create($user); + if ($result < 0) $error++; - if (! $error) - { - // Hook of thirdparty module - if (is_object($hookmanager)) - { - $parameters=array('objFrom'=>$objFrom); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) $error++; - } + if (! $error) + { + // Hook of thirdparty module + if (is_object($hookmanager)) + { + $parameters=array('objFrom'=>$objFrom); + $action=''; + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) $error++; + } - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_CLONE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PROPAL_CLONE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } - // End - if (! $error) - { - $this->db->commit(); - return $this->id; - } - else - { - $this->db->rollback(); - return -1; - } - } + // End + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -1; + } + } - /** - * Load a proposal from database and its ligne array - * - * @param int $rowid id of object to load - * @param string $ref Ref of proposal - * @return int >0 if OK, <0 if KO - */ - function fetch($rowid,$ref='') - { - global $conf; + /** + * Load a proposal from database and its ligne array + * + * @param int $rowid id of object to load + * @param string $ref Ref of proposal + * @return int >0 if OK, <0 if KO + */ + function fetch($rowid,$ref='') + { + global $conf; - $sql = "SELECT p.rowid,ref,remise,remise_percent,remise_absolue,fk_soc"; - $sql.= ", total, tva, localtax1, localtax2, total_ht"; - $sql.= ", datec"; - $sql.= ", date_valid as datev"; - $sql.= ", datep as dp"; - $sql.= ", fin_validite as dfv"; - $sql.= ", date_livraison as date_livraison"; - $sql.= ", ca.code as availability_code, ca.label as availability"; - $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; - $sql.= ", model_pdf, ref_client"; - $sql.= ", note, note_public"; - $sql.= ", fk_projet, fk_statut"; - $sql.= ", fk_user_author, fk_user_valid, fk_user_cloture"; - $sql.= ", fk_adresse_livraison"; - $sql.= ", p.fk_availability"; - $sql.= ", p.fk_demand_reason"; - $sql.= ", p.fk_cond_reglement"; - $sql.= ", p.fk_mode_reglement"; - $sql.= ", c.label as statut_label"; - $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; - $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_demand_reason = dr.rowid'; - $sql.= " WHERE p.fk_statut = c.id"; - $sql.= " AND p.entity = ".$conf->entity; - if ($ref) $sql.= " AND p.ref='".$ref."'"; - else $sql.= " AND p.rowid=".$rowid; + $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; + $sql.= ", p.datec"; + $sql.= ", p.date_valid as datev"; + $sql.= ", p.datep as dp"; + $sql.= ", p.fin_validite as dfv"; + $sql.= ", p.date_livraison as date_livraison"; + $sql.= ", p.model_pdf, p.ref_client, p.extraparams"; + $sql.= ", p.note as note_private, p.note_public"; + $sql.= ", p.fk_projet, p.fk_statut"; + $sql.= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; + $sql.= ", p.fk_adresse_livraison"; + $sql.= ", p.fk_availability"; + $sql.= ", p.fk_demand_reason"; + $sql.= ", p.fk_cond_reglement"; + $sql.= ", p.fk_mode_reglement"; + $sql.= ", c.label as statut_label"; + $sql.= ", ca.code as availability_code, ca.label as availability"; + $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; + $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; + $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_demand_reason = dr.rowid'; + $sql.= " WHERE p.fk_statut = c.id"; + $sql.= " AND p.entity = ".$conf->entity; + if ($ref) $sql.= " AND p.ref='".$ref."'"; + else $sql.= " AND p.rowid=".$rowid; - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->ref_client = $obj->ref_client; - $this->remise = $obj->remise; - $this->remise_percent = $obj->remise_percent; - $this->remise_absolue = $obj->remise_absolue; - $this->total = $obj->total; // TODO obsolete - $this->total_ht = $obj->total_ht; - $this->total_tva = $obj->tva; - $this->total_localtax1 = $obj->localtax1; - $this->total_localtax2 = $obj->localtax2; - $this->total_ttc = $obj->total; - $this->socid = $obj->fk_soc; - $this->fk_project = $obj->fk_projet; - $this->modelpdf = $obj->model_pdf; - $this->note = $obj->note; - $this->note_public = $obj->note_public; - $this->statut = $obj->fk_statut; - $this->statut_libelle = $obj->statut_label; + $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; + $this->remise = $obj->remise; + $this->remise_percent = $obj->remise_percent; + $this->remise_absolue = $obj->remise_absolue; + $this->total = $obj->total; // TODO obsolete + $this->total_ht = $obj->total_ht; + $this->total_tva = $obj->tva; + $this->total_localtax1 = $obj->localtax1; + $this->total_localtax2 = $obj->localtax2; + $this->total_ttc = $obj->total; + $this->socid = $obj->fk_soc; + $this->fk_project = $obj->fk_projet; + $this->modelpdf = $obj->model_pdf; + $this->note = $obj->note_private; // TODO obsolete + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->statut = $obj->fk_statut; + $this->statut_libelle = $obj->statut_label; - $this->datec = $this->db->jdate($obj->datec); //TODO obsolete - $this->datev = $this->db->jdate($obj->datev); //TODO obsolete - $this->date_creation = $this->db->jdate($obj->datec); //Creation date + $this->datec = $this->db->jdate($obj->datec); // TODO obsolete + $this->datev = $this->db->jdate($obj->datev); // TODO obsolete + $this->date_creation = $this->db->jdate($obj->datec); //Creation date $this->date_validation = $this->db->jdate($obj->datev); //Validation date - $this->date = $this->db->jdate($obj->dp); // Proposal date - $this->datep = $this->db->jdate($obj->dp); // deprecated - $this->fin_validite = $this->db->jdate($obj->dfv); - $this->date_livraison = $this->db->jdate($obj->date_livraison); - $this->availability_id = $obj->fk_availability; - $this->availability_code = $obj->availability_code; - $this->availability = $obj->availability; - $this->demand_reason_id = $obj->fk_demand_reason; - $this->demand_reason_code = $obj->demand_reason_code; - $this->demand_reason = $obj->demand_reason; - $this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete - $this->fk_address = $obj->fk_adresse_livraison; + $this->date = $this->db->jdate($obj->dp); // Proposal date + $this->datep = $this->db->jdate($obj->dp); // deprecated + $this->fin_validite = $this->db->jdate($obj->dfv); + $this->date_livraison = $this->db->jdate($obj->date_livraison); + $this->availability_id = $obj->fk_availability; + $this->availability_code = $obj->availability_code; + $this->availability = $obj->availability; + $this->demand_reason_id = $obj->fk_demand_reason; + $this->demand_reason_code = $obj->demand_reason_code; + $this->demand_reason = $obj->demand_reason; + $this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete + $this->fk_address = $obj->fk_adresse_livraison; - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement; - $this->cond_reglement_id = $obj->fk_cond_reglement; - $this->cond_reglement_code = $obj->cond_reglement_code; - $this->cond_reglement = $obj->cond_reglement; - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement = $obj->cond_reglement; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; - $this->user_author_id = $obj->fk_user_author; - $this->user_valid_id = $obj->fk_user_valid; - $this->user_close_id = $obj->fk_user_cloture; + $this->extraparams = (array) json_decode($obj->extraparams, true); - if ($obj->fk_statut == 0) - { - $this->brouillon = 1; - } + $this->user_author_id = $obj->fk_user_author; + $this->user_valid_id = $obj->fk_user_valid; + $this->user_close_id = $obj->fk_user_cloture; - $this->db->free($resql); + if ($obj->fk_statut == 0) + { + $this->brouillon = 1; + } - $this->lines = array(); + $this->db->free($resql); - /* - * Lignes propales liees a un produit ou non - */ - $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; - $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.marge_tx, d.marque_tx, d.special_code, d.rang, d.product_type,"; + $this->lines = array(); + + /* + * Lignes propales liees a un produit ou non + */ + $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.marge_tx, d.marque_tx, d.special_code, d.rang, d.product_type,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label'; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; - $sql.= " WHERE d.fk_propal = ".$this->id; - $sql.= " ORDER by d.rang"; + $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; + $sql.= " WHERE d.fk_propal = ".$this->id; + $sql.= " ORDER by d.rang"; - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; - while ($i < $num) - { - $objp = $this->db->fetch_object($result); + while ($i < $num) + { + $objp = $this->db->fetch_object($result); - $line = new PropaleLigne($this->db); + $line = new PropaleLigne($this->db); - $line->rowid = $objp->rowid; - $line->fk_propal = $objp->fk_propal; - $line->fk_parent_line = $objp->fk_parent_line; - $line->product_type = $objp->product_type; - $line->desc = $objp->description; // Description ligne - $line->qty = $objp->qty; - $line->tva_tx = $objp->tva_tx; - $line->localtax1_tx = $objp->localtax1_tx; - $line->localtax2_tx = $objp->localtax2_tx; - $line->subprice = $objp->subprice; - $line->fk_remise_except = $objp->fk_remise_except; - $line->remise_percent = $objp->remise_percent; - $line->price = $objp->price; // TODO deprecated + $line->rowid = $objp->rowid; + $line->fk_propal = $objp->fk_propal; + $line->fk_parent_line = $objp->fk_parent_line; + $line->product_type = $objp->product_type; + $line->desc = $objp->description; // Description ligne + $line->qty = $objp->qty; + $line->tva_tx = $objp->tva_tx; + $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax2_tx = $objp->localtax2_tx; + $line->subprice = $objp->subprice; + $line->fk_remise_except = $objp->fk_remise_except; + $line->remise_percent = $objp->remise_percent; + $line->price = $objp->price; // TODO deprecated - $line->info_bits = $objp->info_bits; - $line->total_ht = $objp->total_ht; - $line->total_tva = $objp->total_tva; - $line->total_localtax1 = $objp->total_localtax1; - $line->total_localtax2 = $objp->total_localtax2; - $line->total_ttc = $objp->total_ttc; - $line->marge_tx = $objp->marge_tx; - $line->marque_tx = $objp->marque_tx; - $line->special_code = $objp->special_code; - $line->rang = $objp->rang; + $line->info_bits = $objp->info_bits; + $line->total_ht = $objp->total_ht; + $line->total_tva = $objp->total_tva; + $line->total_localtax1 = $objp->total_localtax1; + $line->total_localtax2 = $objp->total_localtax2; + $line->total_ttc = $objp->total_ttc; + $line->marge_tx = $objp->marge_tx; + $line->marque_tx = $objp->marque_tx; + $line->special_code = $objp->special_code; + $line->rang = $objp->rang; - $line->fk_product = $objp->fk_product; + $line->fk_product = $objp->fk_product; $line->ref = $objp->product_ref; // TODO deprecated $line->product_ref = $objp->product_ref; $line->libelle = $objp->product_label; // TODO deprecated $line->label = $objp->product_label; // TODO deprecated $line->product_label = $objp->product_label; - $line->product_desc = $objp->product_desc; // Description produit + $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; - $this->lines[$i] = $line; - //dol_syslog("1 ".$line->fk_product); - //print "xx $i ".$this->lines[$i]->fk_product; - $i++; - } - $this->db->free($result); - } - else - { - $this->error=$this->db->error(); - dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); - return -1; - } - - return 1; - } - - $this->error="Record Not Found"; - return 0; - } - else - { - $this->error=$this->db->error(); - dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); - return -1; - } - } - - /** - * Set status to validated - * - * @param User $user Object user that validate - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers - * @return int <0 if KO, >=0 if OK - */ - function valid($user, $notrigger=0) - { - global $conf,$langs; - - $error=0; - $now=dol_now(); - - if ($user->rights->propale->valider) - { - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id; - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - dol_syslog(get_class($this).'::valid sql='.$sql); - if ($this->db->query($sql)) - { - if (! $notrigger) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_VALIDATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } - - if (! $error) - { - $this->brouillon=0; - $this->statut = 1; - $this->user_valid_id=$user->id; - $this->datev=$now; - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -2; - } - } - else - { - $this->db->rollback(); - return -1; - } - } - } - - - /** - * Define proposal date - * - * @param User $user Object user that modify - * @param timestamp $date Date - * @return int <0 if KO, >0 if OK - */ - function set_date($user, $date) - { - if (empty($date)) - { - $this->error='ErrorBadParameter'; - dol_syslog(get_class($this)."::set_date ".$this->error, LOG_ERR); - return -1; - } - - if ($user->rights->propale->creer) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'"; - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - dol_syslog(get_class($this)."::set_date sql=".$sql); - if ($this->db->query($sql) ) - { - $this->date = $date; - $this->datep = $date; // deprecated - return 1; - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::set_date ".$this->error, LOG_ERR); - return -1; - } - } - } - - /** - * Define end validity date - * - * @param User $user Object user that modify - * @param timestamp $date_fin_validite End of validity date - * @return int <0 if KO, >0 if OK - */ - function set_echeance($user, $date_fin_validite) - { - if ($user->rights->propale->creer) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null'); - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - if ($this->db->query($sql) ) - { - $this->fin_validite = $date_fin_validite; - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog(get_class($this)."::set_echeance Erreur SQL".$this->error, LOG_ERR); - return -1; - } - } - } - - /** - * Set delivery date - * - * @param User $user Object user that modify - * @param timestamp $date_livraison Delivery date - * @return int <0 if ko, >0 if ok - */ - function set_date_livraison($user, $date_livraison) - { - if ($user->rights->propale->creer) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; - $sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null'); - $sql.= " WHERE rowid = ".$this->id; - - if ($this->db->query($sql)) - { - $this->date_livraison = $date_livraison; - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog(get_class($this)."::set_date_livraison Erreur SQL"); - return -1; - } - } - } - - /** - * Define delivery address - * - * @param User $user Object user that modify - * @param int $fk_address Delivery address id - * @return int <0 si ko, >0 si ok - */ - function set_adresse_livraison($user, $fk_address) - { - if ($user->rights->propale->creer) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_adresse_livraison = '".$fk_address."'"; - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - if ($this->db->query($sql) ) - { - $this->fk_delivery_address = $fk_address; - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("Propal::set_adresse_livraison Erreur SQL"); - return -1; - } - } - } - - /** - * Set delivery - * - * @param User $user Object user that modify - * @param int $id Availability id - * @return int <0 if KO, >0 if OK - */ - function set_availability($user, $id) - { - if ($user->rights->propale->creer) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; - $sql.= " SET fk_availability = '".$id."'"; - $sql.= " WHERE rowid = ".$this->id; - - if ($this->db->query($sql)) - { - $this->fk_availability = $id; - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("Propal::set_availability Erreur SQL"); - return -1; - } - } - } - - /** - * Set source of demand - * - * @param User $user Object user that modify - * @param int $id Input reason id - * @return int <0 if KO, >0 if OK - */ - function set_demand_reason($user, $id) - { - if ($user->rights->propale->creer) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; - $sql.= " SET fk_demand_reason = '".$id."'"; - $sql.= " WHERE rowid = ".$this->id; - - if ($this->db->query($sql)) - { - $this->fk_demand_reason = $id; - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("Propal::set_demand_reason Erreur SQL"); - return -1; - } - } - } - - /** - * Set customer reference number - * - * @param User $user Object user that modify - * @param string $ref_client Customer reference - * @return int <0 if ko, >0 if ok - */ - function set_ref_client($user, $ref_client) - { - if ($user->rights->propale->creer) - { - dol_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); - $sql.= ' WHERE rowid = '.$this->id; - if ($this->db->query($sql) ) - { - $this->ref_client = $ref_client; - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog('Propale::set_ref_client Erreur '.$this->error.' - '.$sql); - return -2; - } - } - else - { - return -1; - } - } - - /** - * Set an overall discount on the proposal - * - * @param User $user Object user that modify - * @param double $remise Amount discount - * @return int <0 if ko, >0 if ok - */ - function set_remise_percent($user, $remise) - { - $remise=trim($remise)?trim($remise):0; - - if ($user->rights->propale->creer) - { - $remise = price2num($remise); - - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise; - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - if ($this->db->query($sql) ) - { - $this->remise_percent = $remise; - $this->update_price(1); - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("Propal::set_remise_percent Error sql=$sql"); - return -1; - } - } - } - - - /** - * Set an absolute overall discount on the proposal - * - * @param User $user Object user that modify - * @param double $remise Amount discount - * @return int <0 if ko, >0 if ok - */ - function set_remise_absolue($user, $remise) - { - $remise=trim($remise)?trim($remise):0; - - if ($user->rights->propale->creer) - { - $remise = price2num($remise); - - $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; - $sql.= " SET remise_absolue = ".$remise; - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - if ($this->db->query($sql) ) - { - $this->remise_absolue = $remise; - $this->update_price(1); - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("Propal::set_remise_absolue Error sql=$sql"); - return -1; - } - } - } - - - - /** - * Close the commercial proposal - * - * @param User $user Object user that close - * @param int $statut Statut - * @param text $note Comment - * @return int <0 if KO, >0 if OK - */ - function reopen($user, $statut, $note) - { - global $langs,$conf; - - $this->statut = $statut; - $error=0; - - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate(mktime()).", fk_user_cloture=".$user->id; - $sql.= " WHERE rowid = ".$this->id; - - $resql=$this->db->query($sql); - if ($resql) - { - - } - } - - - /** - * Close the commercial proposal - * - * @param User $user Object user that close - * @param int $statut Statut - * @param text $note Comment - * @return int <0 if KO, >0 if OK - */ - function cloture($user, $statut, $note) - { - global $langs,$conf; - - $this->statut = $statut; - $error=0; - - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; - $sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate(mktime()).", fk_user_cloture=".$user->id; - $sql.= " WHERE rowid = ".$this->id; - - $resql=$this->db->query($sql); - if ($resql) - { - if ($statut == 2) - { - // Classe la societe rattachee comme client - $soc=new Societe($this->db); - $soc->id = $this->socid; - $result=$soc->set_as_client(); - - if ($result < 0) - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -2; - } - - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_CLOSE_SIGNED',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } - else - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_CLOSE_REFUSED',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } - - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } - - /** - * Class invoiced the Propal - * - * @return int <0 si ko, >0 si ok - */ - function classer_facturee() - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = 4'; - $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; - if ($this->db->query($sql) ) - { - return 1; - } - else - { - dol_print_error($this->db); - } - } - - /** - * Set draft status - * - * @param User $user Object user that modify - * @return int <0 if KO, >0 if OK - */ - function set_draft($user) - { - global $conf,$langs; - - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0"; - $sql.= " WHERE rowid = ".$this->id; - - if ($this->db->query($sql)) - { - return 1; - } - else - { - return -1; - } - } - - - /** - * Return list of proposal (eventually filtered on user) into an array - * - * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref) - * @param int $draft 0=not draft, 1=draft - * @param int $notcurrentuser 0=current user, 1=not current user - * @param int $socid Id third pary - * @param int $limit For pagination - * @param int $offset For pagination - * @param string $sortfield Sort criteria - * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK - */ - function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC') - { - global $conf,$user; - - $ga = array(); - - $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; - $sql.= " p.datep as dp, p.fin_validite as datelimite"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - $sql.= " WHERE p.entity = ".$conf->entity; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.fk_statut = c.id"; - if ($socid) $sql.= " AND s.rowid = ".$socid; - if ($draft) $sql.= " AND p.fk_statut = 0"; - if ($notcurrentuser) $sql.= " AND p.fk_user_author <> ".$user->id; - $sql.= $this->db->order($sortfield,$sortorder); - $sql.= $this->db->plimit($limit,$offset); - - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - if ($num) - { - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - - if ($shortlist) - { - $ga[$obj->propalid] = $obj->ref; - } - else - { - $ga[$i]['id'] = $obj->propalid; - $ga[$i]['ref'] = $obj->ref; - } - - $i++; - } - } - return $ga; - } - else - { - dol_print_error($this->db); - return -1; - } - } - - /** - * Returns an array with the numbers of related invoices - * - * @return array Array of invoices - */ - function getInvoiceArrayList() - { - return $this->InvoiceArrayList($this->id); - } - - /** - * Returns an array with id and ref of related invoices - * - * @param int $id Id propal - * @return array Array of invoices id - */ - function InvoiceArrayList($id) - { - $ga = array(); - $linkedInvoices = array(); - - $this->fetchObjectLinked($id,$this->element); - foreach($this->linkedObjectsIds as $objecttype => $objectid) - { - $numi=count($objectid); - for ($i=0;$i<$numi;$i++) - { - // Cas des factures liees directement - if ($objecttype == 'facture') - { - $linkedInvoices[] = $objectid[$i]; - } - // Cas des factures liees via la commande - else - { - $this->fetchObjectLinked($objectid[$i],$objecttype); - foreach($this->linkedObjectsIds as $subobjecttype => $subobjectid) - { - $numj=count($subobjectid); - for ($j=0;$j<$numj;$j++) - { - $linkedInvoices[] = $subobjectid[$j]; - } - } - } - } - } - - if (count($linkedInvoices) > 0) - { - $sql= "SELECT rowid as facid, facnumber, total, datef as df, fk_user_author, fk_statut, paye"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture"; - $sql.= " WHERE rowid IN (".implode(',',$linkedInvoices).")"; - - dol_syslog("Propal::InvoiceArrayList sql=".$sql); - $resql=$this->db->query($sql); - - if ($resql) - { - $tab_sqlobj=array(); - $nump = $this->db->num_rows($resql); - for ($i = 0;$i < $nump;$i++) - { - $sqlobj = $this->db->fetch_object($resql); - $tab_sqlobj[] = $sqlobj; - } - $this->db->free($resql); - - $nump = count($tab_sqlobj); - - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = array_shift($tab_sqlobj); - - $ga[$i] = $obj; - - $i++; - } - } - return $ga; - } - else - { - return -1; - } - } - else return $ga; - } - - /** - * Delete proposal - * - * @param User $user Object user that delete - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers - * @return int 1 if ok, otherwise if error - */ - function delete($user, $notrigger=0) - { - global $conf,$langs; + $this->lines[$i] = $line; + //dol_syslog("1 ".$line->fk_product); + //print "xx $i ".$this->lines[$i]->fk_product; + $i++; + } + $this->db->free($result); + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); + return -1; + } + + return 1; + } + + $this->error="Record Not Found"; + return 0; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * Set status to validated + * + * @param User $user Object user that validate + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if KO, >=0 if OK + */ + function valid($user, $notrigger=0) + { + global $conf,$langs; + + $error=0; + $now=dol_now(); + + if ($user->rights->propale->valider) + { + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + dol_syslog(get_class($this).'::valid sql='.$sql); + if ($this->db->query($sql)) + { + if (! $notrigger) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PROPAL_VALIDATE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } + + if (! $error) + { + $this->brouillon=0; + $this->statut = 1; + $this->user_valid_id=$user->id; + $this->datev=$now; + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -2; + } + } + else + { + $this->db->rollback(); + return -1; + } + } + } + + + /** + * Define proposal date + * + * @param User $user Object user that modify + * @param timestamp $date Date + * @return int <0 if KO, >0 if OK + */ + function set_date($user, $date) + { + if (empty($date)) + { + $this->error='ErrorBadParameter'; + dol_syslog(get_class($this)."::set_date ".$this->error, LOG_ERR); + return -1; + } + + if ($user->rights->propale->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'"; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + dol_syslog(get_class($this)."::set_date sql=".$sql); + if ($this->db->query($sql) ) + { + $this->date = $date; + $this->datep = $date; // deprecated + return 1; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::set_date ".$this->error, LOG_ERR); + return -1; + } + } + } + + /** + * Define end validity date + * + * @param User $user Object user that modify + * @param timestamp $date_fin_validite End of validity date + * @return int <0 if KO, >0 if OK + */ + function set_echeance($user, $date_fin_validite) + { + if ($user->rights->propale->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null'); + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + if ($this->db->query($sql) ) + { + $this->fin_validite = $date_fin_validite; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::set_echeance Erreur SQL".$this->error, LOG_ERR); + return -1; + } + } + } + + /** + * Set delivery date + * + * @param User $user Object user that modify + * @param timestamp $date_livraison Delivery date + * @return int <0 if ko, >0 if ok + */ + function set_date_livraison($user, $date_livraison) + { + if ($user->rights->propale->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null'); + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->date_livraison = $date_livraison; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::set_date_livraison Erreur SQL"); + return -1; + } + } + } + + /** + * Set delivery + * + * @param User $user Object user that modify + * @param int $id Availability id + * @return int <0 if KO, >0 if OK + */ + function set_availability($user, $id) + { + if ($user->rights->propale->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET fk_availability = '".$id."'"; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->fk_availability = $id; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Propal::set_availability Erreur SQL"); + return -1; + } + } + } + + /** + * Set source of demand + * + * @param User $user Object user that modify + * @param int $id Input reason id + * @return int <0 if KO, >0 if OK + */ + function set_demand_reason($user, $id) + { + if ($user->rights->propale->creer) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET fk_demand_reason = '".$id."'"; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->fk_demand_reason = $id; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Propal::set_demand_reason Erreur SQL"); + return -1; + } + } + } + + /** + * Set customer reference number + * + * @param User $user Object user that modify + * @param string $ref_client Customer reference + * @return int <0 if ko, >0 if ok + */ + function set_ref_client($user, $ref_client) + { + if ($user->rights->propale->creer) + { + dol_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\''); + $sql.= ' WHERE rowid = '.$this->id; + if ($this->db->query($sql) ) + { + $this->ref_client = $ref_client; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog('Propale::set_ref_client Erreur '.$this->error.' - '.$sql); + return -2; + } + } + else + { + return -1; + } + } + + /** + * Set an overall discount on the proposal + * + * @param User $user Object user that modify + * @param double $remise Amount discount + * @return int <0 if ko, >0 if ok + */ + function set_remise_percent($user, $remise) + { + $remise=trim($remise)?trim($remise):0; + + if ($user->rights->propale->creer) + { + $remise = price2num($remise); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql) ) + { + $this->remise_percent = $remise; + $this->update_price(1); + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Propal::set_remise_percent Error sql=$sql"); + return -1; + } + } + } + + + /** + * Set an absolute overall discount on the proposal + * + * @param User $user Object user that modify + * @param double $remise Amount discount + * @return int <0 if ko, >0 if ok + */ + function set_remise_absolue($user, $remise) + { + $remise=trim($remise)?trim($remise):0; + + if ($user->rights->propale->creer) + { + $remise = price2num($remise); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; + $sql.= " SET remise_absolue = ".$remise; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql) ) + { + $this->remise_absolue = $remise; + $this->update_price(1); + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Propal::set_remise_absolue Error sql=$sql"); + return -1; + } + } + } + + + + /** + * Close the commercial proposal + * + * @param User $user Object user that close + * @param int $statut Statut + * @param text $note Comment + * @return int <0 if KO, >0 if OK + */ + function reopen($user, $statut, $note) + { + global $langs,$conf; + + $this->statut = $statut; + $error=0; + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate(mktime()).", fk_user_cloture=".$user->id; + $sql.= " WHERE rowid = ".$this->id; + + $resql=$this->db->query($sql); + if ($resql) + { + + } + } + + + /** + * Close the commercial proposal + * + * @param User $user Object user that close + * @param int $statut Statut + * @param text $note Comment + * @return int <0 if KO, >0 if OK + */ + function cloture($user, $statut, $note) + { + global $langs,$conf; + + $this->statut = $statut; + $error=0; + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate(mktime()).", fk_user_cloture=".$user->id; + $sql.= " WHERE rowid = ".$this->id; + + $resql=$this->db->query($sql); + if ($resql) + { + if ($statut == 2) + { + // Classe la societe rattachee comme client + $soc=new Societe($this->db); + $soc->id = $this->socid; + $result=$soc->set_as_client(); + + if ($result < 0) + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PROPAL_CLOSE_SIGNED',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } + else + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PROPAL_CLOSE_REFUSED',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } + + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** + * Class invoiced the Propal + * + * @return int <0 si ko, >0 si ok + */ + function classer_facturee() + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = 4'; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; + if ($this->db->query($sql) ) + { + return 1; + } + else + { + dol_print_error($this->db); + } + } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @return int <0 if KO, >0 if OK + */ + function set_draft($user) + { + global $conf,$langs; + + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0"; + $sql.= " WHERE rowid = ".$this->id; + + if ($this->db->query($sql)) + { + $this->statut = 0; + return 1; + } + else + { + return -1; + } + } + + + /** + * Return list of proposal (eventually filtered on user) into an array + * + * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref) + * @param int $draft 0=not draft, 1=draft + * @param int $notcurrentuser 0=current user, 1=not current user + * @param int $socid Id third pary + * @param int $limit For pagination + * @param int $offset For pagination + * @param string $sortfield Sort criteria + * @param string $sortorder Sort order + * @return int -1 if KO, array with result if OK + */ + function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC') + { + global $conf,$user; + + $ga = array(); + + $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; + $sql.= " p.datep as dp, p.fin_validite as datelimite"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " AND p.fk_soc = s.rowid"; + $sql.= " AND p.fk_statut = c.id"; + if ($socid) $sql.= " AND s.rowid = ".$socid; + if ($draft) $sql.= " AND p.fk_statut = 0"; + if ($notcurrentuser) $sql.= " AND p.fk_user_author <> ".$user->id; + $sql.= $this->db->order($sortfield,$sortorder); + $sql.= $this->db->plimit($limit,$offset); + + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + + if ($shortlist) + { + $ga[$obj->propalid] = $obj->ref; + } + else + { + $ga[$i]['id'] = $obj->propalid; + $ga[$i]['ref'] = $obj->ref; + } + + $i++; + } + } + return $ga; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Returns an array with the numbers of related invoices + * + * @return array Array of invoices + */ + function getInvoiceArrayList() + { + return $this->InvoiceArrayList($this->id); + } + + /** + * Returns an array with id and ref of related invoices + * + * @param int $id Id propal + * @return array Array of invoices id + */ + function InvoiceArrayList($id) + { + $ga = array(); + $linkedInvoices = array(); + + $this->fetchObjectLinked($id,$this->element); + foreach($this->linkedObjectsIds as $objecttype => $objectid) + { + $numi=count($objectid); + for ($i=0;$i<$numi;$i++) + { + // Cas des factures liees directement + if ($objecttype == 'facture') + { + $linkedInvoices[] = $objectid[$i]; + } + // Cas des factures liees via la commande + else + { + $this->fetchObjectLinked($objectid[$i],$objecttype); + foreach($this->linkedObjectsIds as $subobjecttype => $subobjectid) + { + $numj=count($subobjectid); + for ($j=0;$j<$numj;$j++) + { + $linkedInvoices[] = $subobjectid[$j]; + } + } + } + } + } + + if (count($linkedInvoices) > 0) + { + $sql= "SELECT rowid as facid, facnumber, total, datef as df, fk_user_author, fk_statut, paye"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture"; + $sql.= " WHERE rowid IN (".implode(',',$linkedInvoices).")"; + + dol_syslog("Propal::InvoiceArrayList sql=".$sql); + $resql=$this->db->query($sql); + + if ($resql) + { + $tab_sqlobj=array(); + $nump = $this->db->num_rows($resql); + for ($i = 0;$i < $nump;$i++) + { + $sqlobj = $this->db->fetch_object($resql); + $tab_sqlobj[] = $sqlobj; + } + $this->db->free($resql); + + $nump = count($tab_sqlobj); + + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = array_shift($tab_sqlobj); + + $ga[$i] = $obj; + + $i++; + } + } + return $ga; + } + else + { + return -1; + } + } + else return $ga; + } + + /** + * Delete proposal + * + * @param User $user Object user that delete + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int 1 if ok, otherwise if error + */ + function delete($user, $notrigger=0) + { + global $conf,$langs; require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - $error=0; + $error=0; - $this->db->begin(); - - if (! $error && ! $notrigger) - { - // Call triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // End call triggers - } - - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; - if ($this->db->query($sql)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id; - if ($this->db->query($sql)) - { - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) $error++; - - // Delete linked contacts - $res = $this->delete_linked_contact(); - if ($res < 0) $error++; - - if (! $error) - { - // We remove directory - $propalref = dol_sanitizeFileName($this->ref); - if ($conf->propale->dir_output) - { - $dir = $conf->propale->dir_output . "/" . $propalref ; - $file = $conf->propale->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; - if (file_exists($file)) - { - dol_delete_preview($this); - - if (!dol_delete_file($file)) - { - $this->error='ErrorFailToDeleteFile'; - $this->db->rollback(); - return 0; - } - } - if (file_exists($dir)) - { - $res=@dol_delete_dir($dir); - if (! $res) - { - $this->error='ErrorFailToDeleteDir'; - $this->db->rollback(); - return 0; - } - } - } - } - - if (! $error) - { - dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return 0; - } - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return -3; - } - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - } + $this->db->begin(); + + if (! $error && ! $notrigger) + { + // Call triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PROPAL_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // End call triggers + } + + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; + if ($this->db->query($sql)) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id; + if ($this->db->query($sql)) + { + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) $error++; + + // Delete linked contacts + $res = $this->delete_linked_contact(); + if ($res < 0) $error++; + + if (! $error) + { + // We remove directory + $propalref = dol_sanitizeFileName($this->ref); + if ($conf->propal->dir_output) + { + $dir = $conf->propal->dir_output . "/" . $propalref ; + $file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; + if (file_exists($file)) + { + dol_delete_preview($this); + + if (!dol_delete_file($file)) + { + $this->error='ErrorFailToDeleteFile'; + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) + { + $res=@dol_delete_dir($dir); + if (! $res) + { + $this->error='ErrorFailToDeleteDir'; + $this->db->rollback(); + return 0; + } + } + } + } + + if (! $error) + { + dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); + return 0; + } + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); + return -3; + } + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } + + /** + * Change the delivery time + * + * @param int $availability_id Id of new delivery time + * @return int >0 if OK, <0 if KO + */ + function availability($availability_id) + { + dol_syslog('Propale::availability('.$availability_id.')'); + if ($this->statut >= 0) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; + $sql .= ' SET fk_availability = '.$availability_id; + $sql .= ' WHERE rowid='.$this->id; + if ( $this->db->query($sql) ) + { + $this->availability_id = $availability_id; + return 1; + } + else + { + dol_syslog('Propale::availability Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog('Propale::availability, etat propale incompatible'); + $this->error='Etat propale incompatible '.$this->statut; + return -2; + } + } + + /** + * Change source demand + * + * @param int $demand_reason_id Id of new source demand + * @return int >0 si ok, <0 si ko + */ + function demand_reason($demand_reason_id) + { + dol_syslog('Propale::demand_reason('.$demand_reason_id.')'); + if ($this->statut >= 0) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; + $sql .= ' SET fk_demand_reason = '.$demand_reason_id; + $sql .= ' WHERE rowid='.$this->id; + if ( $this->db->query($sql) ) + { + $this->demand_reason_id = $demand_reason_id; + return 1; + } + else + { + dol_syslog('Propale::demand_reason Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog('Propale::demand_reason, etat propale incompatible'); + $this->error='Etat propale incompatible '.$this->statut; + return -2; + } + } - /** - * Change the payments conditions of the invoice - * - * @param int $cond_reglement_id Id of new payment condition - * @return int >0 if OK, <0 if KO - */ - function cond_reglement($cond_reglement_id) - { - dol_syslog('Propale::cond_reglement('.$cond_reglement_id.')'); - if ($this->statut >= 0) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_cond_reglement = '.$cond_reglement_id; - $sql .= ' WHERE rowid='.$this->id; - if ( $this->db->query($sql) ) - { - $this->cond_reglement_id = $cond_reglement_id; - return 1; - } - else - { - dol_syslog('Propale::cond_reglement Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); - return -1; - } - } - else - { - dol_syslog('Propale::cond_reglement, etat propale incompatible'); - $this->error='Etat propale incompatible '.$this->statut; - return -2; - } - } + /** + * Object Proposal Information + * + * @param int $id Proposal id + * @return void + */ + function info($id) + { + $sql = "SELECT c.rowid, "; + $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; + $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; + $sql.= " WHERE c.rowid = ".$id; + + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->rowid; + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_validation = $this->db->jdate($obj->datev); + $this->date_cloture = $this->db->jdate($obj->dateo); + + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } - /** - * Change the payment mode - * - * @param int $mode_reglement_id Id of new payment mode - * @return int >0 if OK, <0 if KO - */ - function mode_reglement($mode_reglement_id) - { - dol_syslog('Propale::mode_reglement('.$mode_reglement_id.')'); - if ($this->statut >= 0) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_mode_reglement = '.$mode_reglement_id; - $sql .= ' WHERE rowid='.$this->id; - if ( $this->db->query($sql) ) - { - $this->mode_reglement_id = $mode_reglement_id; - return 1; - } - else - { - dol_syslog('Propale::mode_reglement Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); - return -1; - } - } - else - { - dol_syslog('Propale::mode_reglement, etat propale incompatible'); - $this->error='Etat facture incompatible '.$this->statut; - return -2; - } - } + } + $this->db->free($result); - /** - * Change the delivery time - * - * @param int $availability_id Id of new delivery time - * @return int >0 if OK, <0 if KO - */ - function availability($availability_id) - { - dol_syslog('Propale::availability('.$availability_id.')'); - if ($this->statut >= 0) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_availability = '.$availability_id; - $sql .= ' WHERE rowid='.$this->id; - if ( $this->db->query($sql) ) - { - $this->availability_id = $availability_id; - return 1; - } - else - { - dol_syslog('Propale::availability Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); - return -1; - } - } - else - { - dol_syslog('Propale::availability, etat propale incompatible'); - $this->error='Etat propale incompatible '.$this->statut; - return -2; - } - } - - /** - * Change source demand - * - * @param int $demand_reason_id Id of new source demand - * @return int >0 si ok, <0 si ko - */ - function demand_reason($demand_reason_id) - { - dol_syslog('Propale::demand_reason('.$demand_reason_id.')'); - if ($this->statut >= 0) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_demand_reason = '.$demand_reason_id; - $sql .= ' WHERE rowid='.$this->id; - if ( $this->db->query($sql) ) - { - $this->demand_reason_id = $demand_reason_id; - return 1; - } - else - { - dol_syslog('Propale::demand_reason Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); - return -1; - } - } - else - { - dol_syslog('Propale::demand_reason, etat propale incompatible'); - $this->error='Etat propale incompatible '.$this->statut; - return -2; - } - } + } + else + { + dol_print_error($this->db); + } + } - /** - * Object Proposal Information - * - * @param int $id Proposal id - */ - function info($id) - { - $sql = "SELECT c.rowid, "; - $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; - $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; - $sql.= " WHERE c.rowid = ".$id; + /** + * Return label of status of proposal (draft, validated, ...) + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Label + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->statut,$mode); + } - $result = $this->db->query($sql); + /** + * Return label of a status (draft, validated, ...) + * + * @param int $statut id statut + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Label + */ + function LibStatut($statut,$mode=1) + { + global $langs; + $langs->load("propal"); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_validation = $this->db->jdate($obj->datev); - $this->date_cloture = $this->db->jdate($obj->dateo); - - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - - if ($obj->fk_user_valid) - { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } - - if ($obj->fk_user_cloture) - { - $cluser = new User($this->db); - $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; - } + if ($mode == 0) + { + return $this->labelstatut[$statut]; + } + if ($mode == 1) + { + return $this->labelstatut_short[$statut]; + } + if ($mode == 2) + { + if ($statut==0) return img_picto($langs->trans('PropalStatusDraftShort'),'statut0').' '.$this->labelstatut_short[$statut]; + if ($statut==1) return img_picto($langs->trans('PropalStatusOpenedShort'),'statut1').' '.$this->labelstatut_short[$statut]; + if ($statut==2) return img_picto($langs->trans('PropalStatusSignedShort'),'statut3').' '.$this->labelstatut_short[$statut]; + if ($statut==3) return img_picto($langs->trans('PropalStatusNotSignedShort'),'statut5').' '.$this->labelstatut_short[$statut]; + if ($statut==4) return img_picto($langs->trans('PropalStatusBilledShort'),'statut6').' '.$this->labelstatut_short[$statut]; + } + if ($mode == 3) + { + if ($statut==0) return img_picto($langs->trans('PropalStatusDraftShort'),'statut0'); + if ($statut==1) return img_picto($langs->trans('PropalStatusOpenedShort'),'statut1'); + if ($statut==2) return img_picto($langs->trans('PropalStatusSignedShort'),'statut3'); + if ($statut==3) return img_picto($langs->trans('PropalStatusNotSignedShort'),'statut5'); + if ($statut==4) return img_picto($langs->trans('PropalStatusBilledShort'),'statut6'); + } + if ($mode == 4) + { + if ($statut==0) return img_picto($langs->trans('PropalStatusDraft'),'statut0').' '.$this->labelstatut[$statut]; + if ($statut==1) return img_picto($langs->trans('PropalStatusOpened'),'statut1').' '.$this->labelstatut[$statut]; + if ($statut==2) return img_picto($langs->trans('PropalStatusSigned'),'statut3').' '.$this->labelstatut[$statut]; + if ($statut==3) return img_picto($langs->trans('PropalStatusNotSigned'),'statut5').' '.$this->labelstatut[$statut]; + if ($statut==4) return img_picto($langs->trans('PropalStatusBilled'),'statut6').' '.$this->labelstatut[$statut]; + } + if ($mode == 5) + { + if ($statut==0) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusDraftShort'),'statut0'); + if ($statut==1) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusOpenedShort'),'statut1'); + if ($statut==2) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusSignedShort'),'statut3'); + if ($statut==3) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusNotSignedShort'),'statut5'); + if ($statut==4) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusBilledShort'),'statut6'); + } + } - } - $this->db->free($result); - - } - else - { - dol_print_error($this->db); - } - } - - - /** - * Return label of status of proposal (draft, validated, ...) - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Label - */ - function getLibStatut($mode=0) - { - return $this->LibStatut($this->statut,$mode); - } - - /** - * Return label of a status (draft, validated, ...) - * - * @param int $statut id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Label - */ - function LibStatut($statut,$mode=1) - { - global $langs; - $langs->load("propal"); - - if ($mode == 0) - { - return $this->labelstatut[$statut]; - } - if ($mode == 1) - { - return $this->labelstatut_short[$statut]; - } - if ($mode == 2) - { - if ($statut==0) return img_picto($langs->trans('PropalStatusDraftShort'),'statut0').' '.$this->labelstatut_short[$statut]; - if ($statut==1) return img_picto($langs->trans('PropalStatusOpenedShort'),'statut1').' '.$this->labelstatut_short[$statut]; - if ($statut==2) return img_picto($langs->trans('PropalStatusSignedShort'),'statut3').' '.$this->labelstatut_short[$statut]; - if ($statut==3) return img_picto($langs->trans('PropalStatusNotSignedShort'),'statut5').' '.$this->labelstatut_short[$statut]; - if ($statut==4) return img_picto($langs->trans('PropalStatusBilledShort'),'statut6').' '.$this->labelstatut_short[$statut]; - } - if ($mode == 3) - { - if ($statut==0) return img_picto($langs->trans('PropalStatusDraftShort'),'statut0'); - if ($statut==1) return img_picto($langs->trans('PropalStatusOpenedShort'),'statut1'); - if ($statut==2) return img_picto($langs->trans('PropalStatusSignedShort'),'statut3'); - if ($statut==3) return img_picto($langs->trans('PropalStatusNotSignedShort'),'statut5'); - if ($statut==4) return img_picto($langs->trans('PropalStatusBilledShort'),'statut6'); - } - if ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans('PropalStatusDraft'),'statut0').' '.$this->labelstatut[$statut]; - if ($statut==1) return img_picto($langs->trans('PropalStatusOpened'),'statut1').' '.$this->labelstatut[$statut]; - if ($statut==2) return img_picto($langs->trans('PropalStatusSigned'),'statut3').' '.$this->labelstatut[$statut]; - if ($statut==3) return img_picto($langs->trans('PropalStatusNotSigned'),'statut5').' '.$this->labelstatut[$statut]; - if ($statut==4) return img_picto($langs->trans('PropalStatusBilled'),'statut6').' '.$this->labelstatut[$statut]; - } - if ($mode == 5) - { - if ($statut==0) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusDraftShort'),'statut0'); - if ($statut==1) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusOpenedShort'),'statut1'); - if ($statut==2) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusSignedShort'),'statut3'); - if ($statut==3) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusNotSignedShort'),'statut5'); - if ($statut==4) return $this->labelstatut_short[$statut].' '.img_picto($langs->trans('PropalStatusBilledShort'),'statut6'); - } - } - - - /** + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @param int $mode "opened" for proposal to close, "signed" for proposal to invoice * @return int <0 if KO, >0 if OK - */ - function load_board($user,$mode) - { - global $conf, $user; + */ + function load_board($user,$mode) + { + global $conf, $user; - $now=gmmktime(); + $now=gmmktime(); - $this->nbtodo=$this->nbtodolate=0; - $clause = " WHERE"; + $this->nbtodo=$this->nbtodolate=0; + $clause = " WHERE"; - $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; - $clause = " AND"; - } - $sql.= $clause." p.entity = ".$conf->entity; - if ($mode == 'opened') $sql.= " AND p.fk_statut = 1"; - if ($mode == 'signed') $sql.= " AND p.fk_statut = 2"; - if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id; + $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = " AND"; + } + $sql.= $clause." p.entity = ".$conf->entity; + if ($mode == 'opened') $sql.= " AND p.fk_statut = 1"; + if ($mode == 'signed') $sql.= " AND p.fk_statut = 2"; + if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id; - $resql=$this->db->query($sql); - if ($resql) - { - if ($mode == 'opened') $delay_warning=$conf->propal->cloture->warning_delay; - if ($mode == 'signed') $delay_warning=$conf->propal->facturation->warning_delay; + $resql=$this->db->query($sql); + if ($resql) + { + if ($mode == 'opened') $delay_warning=$conf->propal->cloture->warning_delay; + if ($mode == 'signed') $delay_warning=$conf->propal->facturation->warning_delay; - while ($obj=$this->db->fetch_object($resql)) - { - $this->nbtodo++; - if ($mode == 'opened') - { - $datelimit = $this->db->jdate($obj->datefin); - if ($datelimit < ($now - $delay_warning)) - { - $this->nbtodolate++; - } - } - // TODO Definir regle des propales a facturer en retard - // if ($mode == 'signed' && ! count($this->FactureListeArray($obj->rowid))) $this->nbtodolate++; - } - return 1; - } - else - { - $this->error=$this->db->error(); - return -1; - } - } + while ($obj=$this->db->fetch_object($resql)) + { + $this->nbtodo++; + if ($mode == 'opened') + { + $datelimit = $this->db->jdate($obj->datefin); + if ($datelimit < ($now - $delay_warning)) + { + $this->nbtodolate++; + } + } + // TODO Definir regle des propales a facturer en retard + // if ($mode == 'signed' && ! count($this->FactureListeArray($obj->rowid))) $this->nbtodolate++; + } + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } - /** + /** * Initialise an instance with random values. * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() - { - global $user,$langs,$conf; + */ + function initAsSpecimen() + { + global $user,$langs,$conf; - // Charge tableau des produits prodids - $prodids = array(); - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product', 1).")"; - $resql = $this->db->query($sql); - if ($resql) - { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) - { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } + // Charge tableau des produits prodids + $prodids = array(); + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql.= " WHERE entity IN (".getEntity('product', 1).")"; + $resql = $this->db->query($sql); + if ($resql) + { + $num_prods = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_prods) + { + $i++; + $row = $this->db->fetch_row($resql); + $prodids[$i] = $row[0]; + } + } - // Initialise parametres - $this->id=0; - $this->ref = 'SPECIMEN'; - $this->ref_client='NEMICEPS'; - $this->specimen=1; - $this->socid = 1; - $this->date = time(); - $this->fin_validite = $this->date+3600*24*30; - $this->cond_reglement_id = 1; - $this->cond_reglement_code = 'RECEP'; - $this->mode_reglement_id = 7; - $this->mode_reglement_code = 'CHQ'; - $this->availability_id = 1; - $this->availability_code = 'DSP'; - $this->demand_reason_id = 1; - $this->demand_reason_code = 'SRC_00'; - $this->note_public='This is a comment (public)'; - $this->note='This is a comment (private)'; - // Lines - $nbp = 5; - $xnbp = 0; - while ($xnbp < $nbp) - { - $line=new PropaleLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->price=100; - $line->tva_tx=19.6; + // Initialise parametres + $this->id=0; + $this->ref = 'SPECIMEN'; + $this->ref_client='NEMICEPS'; + $this->specimen=1; + $this->socid = 1; + $this->date = time(); + $this->fin_validite = $this->date+3600*24*30; + $this->cond_reglement_id = 1; + $this->cond_reglement_code = 'RECEP'; + $this->mode_reglement_id = 7; + $this->mode_reglement_code = 'CHQ'; + $this->availability_id = 1; + $this->availability_code = 'DSP'; + $this->demand_reason_id = 1; + $this->demand_reason_code = 'SRC_00'; + $this->note_public='This is a comment (public)'; + $this->note='This is a comment (private)'; + // Lines + $nbp = 5; + $xnbp = 0; + while ($xnbp < $nbp) + { + $line=new PropaleLigne($this->db); + $line->desc=$langs->trans("Description")." ".$xnbp; + $line->qty=1; + $line->subprice=100; + $line->price=100; + $line->tva_tx=19.6; $line->localtax1_tx=0; $line->localtax2_tx=0; - if ($xnbp == 2) - { - $line->total_ht=50; - $line->total_ttc=59.8; - $line->total_tva=9.8; - $line->remise_percent=50; - } - else - { - $line->total_ht=100; - $line->total_ttc=119.6; - $line->total_tva=19.6; - $line->remise_percent=00; - } + if ($xnbp == 2) + { + $line->total_ht=50; + $line->total_ttc=59.8; + $line->total_tva=9.8; + $line->remise_percent=50; + } + else + { + $line->total_ht=100; + $line->total_ttc=119.6; + $line->total_tva=19.6; + $line->remise_percent=00; + } - $prodid = rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $prodid = rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; - $this->lines[$xnbp]=$line; + $this->lines[$xnbp]=$line; - $this->total_ht += $line->total_ht; - $this->total_tva += $line->total_tva; - $this->total_ttc += $line->total_ttc; + $this->total_ht += $line->total_ht; + $this->total_tva += $line->total_tva; + $this->total_ttc += $line->total_ttc; - $xnbp++; - } - } + $xnbp++; + } + } - /** - * Charge indicateurs this->nb de tableau de bord - * - * @return int <0 if ko, >0 if ok - */ - function load_state_board() - { - global $conf, $user; + /** + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if ko, >0 if ok + */ + function load_state_board() + { + global $conf, $user; - $this->nb=array(); - $clause = "WHERE"; + $this->nb=array(); + $clause = "WHERE"; - $sql = "SELECT count(p.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; - $clause = "AND"; - } - $sql.= " ".$clause." p.entity = ".$conf->entity; + $sql = "SELECT count(p.rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->societe_id) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql.= " WHERE sc.fk_user = " .$user->id; + $clause = "AND"; + } + $sql.= " ".$clause." p.entity = ".$conf->entity; - $resql=$this->db->query($sql); - if ($resql) - { - while ($obj=$this->db->fetch_object($resql)) - { - $this->nb["proposals"]=$obj->nb; - } - return 1; - } - else - { - dol_print_error($this->db); - $this->error=$this->db->error(); - return -1; - } - } + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj=$this->db->fetch_object($resql)) + { + $this->nb["proposals"]=$obj->nb; + } + return 1; + } + else + { + dol_print_error($this->db); + $this->error=$this->db->error(); + return -1; + } + } - /** - * Returns the reference to the following non used Proposal used depending on the active numbering module - * defined into PROPALE_ADDON - * - * @param Societe $soc Object thirdparty - * @return string Reference libre pour la propale - */ - function getNextNumRef($soc) - { - global $conf, $db, $langs; - $langs->load("propal"); + /** + * Returns the reference to the following non used Proposal used depending on the active numbering module + * defined into PROPALE_ADDON + * + * @param Societe $soc Object thirdparty + * @return string Reference libre pour la propale + */ + function getNextNumRef($soc) + { + global $conf, $db, $langs; + $langs->load("propal"); - $dir = DOL_DOCUMENT_ROOT . "/core/modules/propale/"; + $dir = DOL_DOCUMENT_ROOT . "/core/modules/propale/"; - if (! empty($conf->global->PROPALE_ADDON)) - { - $file = $conf->global->PROPALE_ADDON.".php"; + if (! empty($conf->global->PROPALE_ADDON)) + { + $file = $conf->global->PROPALE_ADDON.".php"; - // Chargement de la classe de numerotation - $classname = $conf->global->PROPALE_ADDON; - require_once($dir.$file); + // Chargement de la classe de numerotation + $classname = $conf->global->PROPALE_ADDON; + require_once($dir.$file); - $obj = new $classname(); + $obj = new $classname(); - $numref = ""; - $numref = $obj->getNextValue($soc,$this); + $numref = ""; + $numref = $obj->getNextValue($soc,$this); - if ( $numref != "") - { - return $numref; - } - else - { - $this->error=$obj->error; - //dol_print_error($db,"Propale::getNextNumRef ".$obj->error); - return ""; - } - } - else - { - $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); - return ""; - } - } + if ( $numref != "") + { + return $numref; + } + else + { + $this->error=$obj->error; + //dol_print_error($db,"Propale::getNextNumRef ".$obj->error); + return ""; + } + } + else + { + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; + } + } - /** - * Return clicable link of object (with eventually picto) - * - * @param int $withpicto Add picto into link - * @param string $option Where point the link ('compta', 'expedition', 'document', ...) - * @param string $get_params Parametres added to url - * @return string String with URL - */ - function getNomUrl($withpicto=0,$option='', $get_params='') - { - global $langs; + /** + * Return clicable link of object (with eventually picto) + * + * @param int $withpicto Add picto into link + * @param string $option Where point the link ('compta', 'expedition', 'document', ...) + * @param string $get_params Parametres added to url + * @return string String with URL + */ + function getNomUrl($withpicto=0,$option='', $get_params='') + { + global $langs; - $result=''; - if ($option == '') - { - $lien = ''; - } - if ($option == 'compta') // deprecated - { - $lien = ''; - } - if ($option == 'expedition') - { - $lien = ''; - } - if ($option == 'document') - { - $lien = ''; - } - $lienfin=''; + $result=''; + if ($option == '') + { + $lien = ''; + } + if ($option == 'compta') // deprecated + { + $lien = ''; + } + if ($option == 'expedition') + { + $lien = ''; + } + if ($option == 'document') + { + $lien = ''; + } + $lienfin=''; - $picto='propal'; - $label=$langs->trans("ShowPropal").': '.$this->ref; + $picto='propal'; + $label=$langs->trans("ShowPropal").': '.$this->ref; - if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); - if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$lien.$this->ref.$lienfin; - return $result; - } + if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); + if ($withpicto && $withpicto != 2) $result.=' '; + $result.=$lien.$this->ref.$lienfin; + return $result; + } - /** - * Retrieve an array of propal lines - * - * @return int <0 if ko, >0 if ok - */ - function getLinesArray() - { - $sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,'; - $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; - $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.marge_tx, pt.marque_tx, pt.pa_ht, pt.special_code,'; - $sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang,'; - $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; - $sql.= ' p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; - $sql.= ' WHERE pt.fk_propal = '.$this->id; - $sql.= ' ORDER BY pt.rang ASC, pt.rowid'; + /** + * Retrieve an array of propal lines + * + * @return int <0 if ko, >0 if ok + */ + function getLinesArray() + { + $sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,'; + $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; + $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.marge_tx, pt.marque_tx, pt.pa_ht, pt.special_code,'; + $sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang,'; + $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; + $sql.= ' p.description as product_desc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; + $sql.= ' WHERE pt.fk_propal = '.$this->id; + $sql.= ' ORDER BY pt.rang ASC, pt.rowid'; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - $this->lines[$i]->id = $obj->rowid; - $this->lines[$i]->description = $obj->description; - $this->lines[$i]->fk_product = $obj->fk_product; - $this->lines[$i]->ref = $obj->ref; - $this->lines[$i]->product_label = $obj->product_label; - $this->lines[$i]->product_desc = $obj->product_desc; - $this->lines[$i]->fk_product_type = $obj->fk_product_type; // deprecated - $this->lines[$i]->product_type = $obj->product_type; - $this->lines[$i]->qty = $obj->qty; - $this->lines[$i]->subprice = $obj->subprice; - $this->lines[$i]->pa_ht = $obj->pa_ht; - $this->lines[$i]->fk_remise_except = $obj->fk_remise_except; - $this->lines[$i]->remise_percent = $obj->remise_percent; - $this->lines[$i]->tva_tx = $obj->tva_tx; - $this->lines[$i]->info_bits = $obj->info_bits; - $this->lines[$i]->total_ht = $obj->total_ht; - $this->lines[$i]->total_tva = $obj->total_tva; - $this->lines[$i]->total_ttc = $obj->total_ttc; - $this->lines[$i]->marge_tx = $obj->marge_tx; - $this->lines[$i]->marque_tx = $obj->marque_tx; - $this->lines[$i]->special_code = $obj->special_code; - $this->lines[$i]->rang = $obj->rang; - $this->lines[$i]->date_start = $this->db->jdate($obj->date_start); - $this->lines[$i]->date_end = $this->db->jdate($obj->date_end); + $this->lines[$i]->id = $obj->rowid; + $this->lines[$i]->description = $obj->description; + $this->lines[$i]->fk_product = $obj->fk_product; + $this->lines[$i]->ref = $obj->ref; + $this->lines[$i]->product_label = $obj->product_label; + $this->lines[$i]->product_desc = $obj->product_desc; + $this->lines[$i]->fk_product_type = $obj->fk_product_type; // deprecated + $this->lines[$i]->product_type = $obj->product_type; + $this->lines[$i]->qty = $obj->qty; + $this->lines[$i]->subprice = $obj->subprice; + $this->lines[$i]->pa_ht = $obj->pa_ht; + $this->lines[$i]->fk_remise_except = $obj->fk_remise_except; + $this->lines[$i]->remise_percent = $obj->remise_percent; + $this->lines[$i]->tva_tx = $obj->tva_tx; + $this->lines[$i]->info_bits = $obj->info_bits; + $this->lines[$i]->total_ht = $obj->total_ht; + $this->lines[$i]->total_tva = $obj->total_tva; + $this->lines[$i]->total_ttc = $obj->total_ttc; + $this->lines[$i]->marge_tx = $obj->marge_tx; + $this->lines[$i]->marque_tx = $obj->marque_tx; + $this->lines[$i]->special_code = $obj->special_code; + $this->lines[$i]->rang = $obj->rang; + $this->lines[$i]->date_start = $this->db->jdate($obj->date_start); + $this->lines[$i]->date_end = $this->db->jdate($obj->date_end); - $i++; - } - $this->db->free($resql); + $i++; + } + $this->db->free($resql); - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("Error sql=$sql, error=".$this->error,LOG_ERR); - return -1; - } - } + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("Error sql=$sql, error=".$this->error,LOG_ERR); + return -1; + } + } } @@ -2490,363 +2411,371 @@ class Propal extends CommonObject */ class PropaleLigne { - var $db; - var $error; + var $db; + var $error; - var $oldline; + var $oldline; - // From llx_propaldet - var $rowid; - var $fk_propal; - var $fk_parent_line; - var $desc; // Description ligne - var $fk_product; // Id produit predefini - var $product_type = 0; // Type 0 = product, 1 = Service + // From llx_propaldet + var $rowid; + var $fk_propal; + var $fk_parent_line; + var $desc; // Description ligne + var $fk_product; // Id produit predefini + var $product_type = 0; // Type 0 = product, 1 = Service - var $qty; - var $tva_tx; - var $subprice; - var $remise_percent; - var $fk_remise_except; + var $qty; + var $tva_tx; + var $subprice; + var $remise_percent; + var $fk_remise_except; - var $rang = 0; - var $marge_tx; - var $marque_tx; + var $rang = 0; + var $marge_tx; + var $marque_tx; - var $special_code; // Liste d'options non cumulabels: - // 1: frais de port - // 2: ecotaxe - // 3: ?? + var $special_code; // Liste d'options non cumulabels: + // 1: frais de port + // 2: ecotaxe + // 3: ?? - var $info_bits = 0; // Liste d'options cumulables: - // Bit 0: 0 si TVA normal - 1 si TVA NPR - // Bit 1: 0 ligne normale - 1 si ligne de remise fixe + var $info_bits = 0; // Liste d'options cumulables: + // Bit 0: 0 si TVA normal - 1 si TVA NPR + // Bit 1: 0 ligne normale - 1 si ligne de remise fixe - var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne - var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne - var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne + var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne + var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - // Ne plus utiliser - var $remise; - var $price; + // Ne plus utiliser + var $remise; + var $price; - // From llx_product - var $ref; // Reference produit - var $libelle; // Label produit - var $product_desc; // Description produit + // From llx_product + var $ref; // Reference produit + var $libelle; // Label produit + var $product_desc; // Description produit - var $localtax1_tx; - var $localtax2_tx; - var $total_localtax1; - var $total_localtax2; + var $localtax1_tx; + var $localtax2_tx; + var $total_localtax1; + var $total_localtax2; - var $skip_update_total; // Skip update price total for special lines + var $skip_update_total; // Skip update price total for special lines - /** - * Class line Contructor - * - * @param DoliDB $DB Database handler - */ - function PropaleLigne($DB) - { - $this->db= $DB; - } + /** + * Class line Contructor + * + * @param DoliDB $DB Database handler + */ + function PropaleLigne($DB) + { + $this->db= $DB; + } - /** - * Retrieve the propal line object - * - * @param int $rowid propal line id - */ - function fetch($rowid) - { - $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.description, pd.price, pd.qty, pd.tva_tx,'; - $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; - $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.marge_tx, pd.marque_tx, pd.special_code, pd.rang,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; - $sql.= ' WHERE pd.rowid = '.$rowid; - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); + /** + * Retrieve the propal line object + * + * @param int $rowid Propal line id + * @return int <0 if KO, >0 if OK + */ + function fetch($rowid) + { + $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; + $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.marge_tx, pd.marque_tx, pd.special_code, pd.rang,'; + $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; + $sql.= ' WHERE pd.rowid = '.$rowid; + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; - $this->fk_propal = $objp->fk_propal; - $this->fk_parent_line = $objp->fk_parent_line; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->price = $objp->price; // deprecated - $this->subprice = $objp->subprice; - $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->info_bits = $objp->info_bits; + $this->rowid = $objp->rowid; + $this->fk_propal = $objp->fk_propal; + $this->fk_parent_line = $objp->fk_parent_line; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->price = $objp->price; // deprecated + $this->subprice = $objp->subprice; + $this->tva_tx = $objp->tva_tx; + $this->remise = $objp->remise; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; - $this->marge_tx = $objp->marge_tx; - $this->marque_tx = $objp->marque_tx; - $this->special_code = $objp->special_code; - $this->rang = $objp->rang; + $this->marge_tx = $objp->marge_tx; + $this->marque_tx = $objp->marque_tx; + $this->special_code = $objp->special_code; + $this->rang = $objp->rang; - $this->ref = $objp->product_ref; // deprecated + $this->ref = $objp->product_ref; // deprecated $this->product_ref = $objp->product_ref; $this->libelle = $objp->product_libelle; // deprecated $this->product_label = $objp->product_libelle; - $this->product_desc = $objp->product_desc; + $this->product_desc = $objp->product_desc; - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } - /** - * Insert object line propal in database - * - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers - * @return int <0 if KO, >0 if OK - */ - function insert($notrigger=0) - { - global $conf,$langs,$user; + /** + * Insert object line propal in database + * + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if KO, >0 if OK + */ + function insert($notrigger=0) + { + global $conf,$langs,$user; - $error=0; + $error=0; - dol_syslog("PropaleLigne::insert rang=".$this->rang); + dol_syslog("PropaleLigne::insert rang=".$this->rang); - // Clean parameters - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->rang)) $this->rang=0; - if (empty($this->remise)) $this->remise=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + // Clean parameters + if (empty($this->tva_tx)) $this->tva_tx=0; + if (empty($this->localtax1_tx)) $this->localtax1_tx=0; + if (empty($this->localtax2_tx)) $this->localtax2_tx=0; + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->rang)) $this->rang=0; + if (empty($this->remise)) $this->remise=0; + if (empty($this->remise_percent)) $this->remise_percent=0; + if (empty($this->info_bits)) $this->info_bits=0; + if (empty($this->special_code)) $this->special_code=0; + if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - // Check parameters - if ($this->product_type < 0) return -1; + // Check parameters + if ($this->product_type < 0) return -1; - $this->db->begin(); + $this->db->begin(); - // Insert line into database - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet'; - $sql.= ' (fk_propal, fk_parent_line, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; - $sql.= ' subprice, remise_percent, '; - $sql.= ' info_bits, '; - $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, special_code, rang, marge_tx, marque_tx)'; - $sql.= " VALUES (".$this->fk_propal.","; - $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; - $sql.= " '".$this->db->escape($this->desc)."',"; - $sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").","; - $sql.= " '".$this->product_type."',"; - $sql.= " ".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").","; - $sql.= " ".price2num($this->qty).","; - $sql.= " ".price2num($this->tva_tx).","; - $sql.= " ".price2num($this->localtax1_tx).","; - $sql.= " ".price2num($this->localtax2_tx).","; - $sql.= " ".($this->subprice?price2num($this->subprice):'null').","; - $sql.= " ".price2num($this->remise_percent).","; - $sql.= " '".$this->info_bits."',"; - $sql.= " ".price2num($this->total_ht).","; - $sql.= " ".price2num($this->total_tva).","; - $sql.= " ".price2num($this->total_localtax1).","; - $sql.= " ".price2num($this->total_localtax2).","; - $sql.= " ".price2num($this->total_ttc).","; - $sql.= ' '.$this->special_code.','; - $sql.= ' '.$this->rang.','; - if (isset($this->marge_tx)) $sql.= ' '.$this->marge_tx.','; - else $sql.= ' null,'; - if (isset($this->marque_tx)) $sql.= ' '.$this->marque_tx; - else $sql.= ' null'; - $sql.= ')'; + // Insert line into database + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet'; + $sql.= ' (fk_propal, fk_parent_line, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; + $sql.= ' subprice, remise_percent, '; + $sql.= ' info_bits, '; + $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, special_code, rang, marge_tx, marque_tx)'; + $sql.= " VALUES (".$this->fk_propal.","; + $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; + $sql.= " '".$this->db->escape($this->desc)."',"; + $sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").","; + $sql.= " '".$this->product_type."',"; + $sql.= " ".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").","; + $sql.= " ".price2num($this->qty).","; + $sql.= " ".price2num($this->tva_tx).","; + $sql.= " ".price2num($this->localtax1_tx).","; + $sql.= " ".price2num($this->localtax2_tx).","; + $sql.= " ".($this->subprice?price2num($this->subprice):'null').","; + $sql.= " ".price2num($this->remise_percent).","; + $sql.= " '".$this->info_bits."',"; + $sql.= " ".price2num($this->total_ht).","; + $sql.= " ".price2num($this->total_tva).","; + $sql.= " ".price2num($this->total_localtax1).","; + $sql.= " ".price2num($this->total_localtax2).","; + $sql.= " ".price2num($this->total_ttc).","; + $sql.= ' '.$this->special_code.','; + $sql.= ' '.$this->rang.','; + if (isset($this->marge_tx)) $sql.= ' '.$this->marge_tx.','; + else $sql.= ' null,'; + if (isset($this->marque_tx)) $sql.= ' '.$this->marque_tx; + else $sql.= ' null'; + $sql.= ')'; - dol_syslog("PropaleLigne::insert sql=$sql"); - $resql=$this->db->query($sql); - if ($resql) - { - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet'); - if (! $notrigger) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result = $interface->run_triggers('LINEPROPAL_INSERT',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } + dol_syslog("PropaleLigne::insert sql=$sql"); + $resql=$this->db->query($sql); + if ($resql) + { + $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet'); + if (! $notrigger) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result = $interface->run_triggers('LINEPROPAL_INSERT',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error()." sql=".$sql; - dol_syslog("PropaleLigne::insert Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - } + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error()." sql=".$sql; + dol_syslog("PropaleLigne::insert Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } - /** - * Delete line in database - * @return int <0 if ko, >0 if ok - */ - function delete() - { - global $conf,$langs,$user; + /** + * Delete line in database + * + * @return int <0 if ko, >0 if ok + */ + function delete() + { + global $conf,$langs,$user; - $error=0; - $this->db->begin(); + $error=0; + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid; - dol_syslog("PropaleLigne::delete sql=".$sql, LOG_DEBUG); - if ($this->db->query($sql) ) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result = $interface->run_triggers('LINEPROPAL_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid; + dol_syslog("PropaleLigne::delete sql=".$sql, LOG_DEBUG); + if ($this->db->query($sql) ) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result = $interface->run_triggers('LINEPROPAL_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers - $this->db->commit(); + $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error()." sql=".$sql; - dol_syslog("PropaleLigne::delete Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - } + return 1; + } + else + { + $this->error=$this->db->error()." sql=".$sql; + dol_syslog("PropaleLigne::delete Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + } - /** - * Update propal line object into DB - * - * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers - * @return int <0 if ko, >0 if ok - */ - function update($notrigger=0) - { - global $conf,$langs,$user; + /** + * Update propal line object into DB + * + * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers + * @return int <0 if ko, >0 if ok + */ + function update($notrigger=0) + { + global $conf,$langs,$user; - $error=0; + $error=0; - // Clean parameters - if (empty($this->tva_tx)) $this->tva_tx=0; - if (empty($this->localtax1_tx)) $this->localtax1_tx=0; - if (empty($this->localtax2_tx)) $this->localtax2_tx=0; - if (empty($this->total_localtax1)) $this->total_localtax1=0; - if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->marque_tx)) $this->marque_tx=0; - if (empty($this->marge_tx)) $this->marge_tx=0; - if (empty($this->remise)) $this->remise=0; - if (empty($this->remise_percent)) $this->remise_percent=0; - if (empty($this->info_bits)) $this->info_bits=0; - if (empty($this->special_code)) $this->special_code=0; - if (empty($this->fk_parent_line)) $this->fk_parent_line=0; + // Clean parameters + if (empty($this->tva_tx)) $this->tva_tx=0; + if (empty($this->localtax1_tx)) $this->localtax1_tx=0; + if (empty($this->localtax2_tx)) $this->localtax2_tx=0; + if (empty($this->total_localtax1)) $this->total_localtax1=0; + if (empty($this->total_localtax2)) $this->total_localtax2=0; + if (empty($this->marque_tx)) $this->marque_tx=0; + if (empty($this->marge_tx)) $this->marge_tx=0; + if (empty($this->remise)) $this->remise=0; + if (empty($this->remise_percent)) $this->remise_percent=0; + if (empty($this->info_bits)) $this->info_bits=0; + if (empty($this->special_code)) $this->special_code=0; + if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - $this->db->begin(); + $this->db->begin(); - // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; - $sql.= " description='".$this->db->escape($this->desc)."'"; - $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; - $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); - $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); - $sql.= " , qty='".price2num($this->qty)."'"; - $sql.= " , subprice=".price2num($this->subprice).""; - $sql.= " , remise_percent=".price2num($this->remise_percent).""; - $sql.= " , price=".price2num($this->price).""; // TODO A virer - $sql.= " , remise=".price2num($this->remise).""; // TODO A virer - $sql.= " , info_bits='".$this->info_bits."'"; - if (empty($this->skip_update_total)) - { - $sql.= " , total_ht=".price2num($this->total_ht).""; - $sql.= " , total_tva=".price2num($this->total_tva).""; - $sql.= " , total_ttc=".price2num($this->total_ttc).""; - } - $sql.= " , marge_tx='".$this->marge_tx."'"; - $sql.= " , marque_tx='".$this->marque_tx."'"; - $sql.= " , info_bits=".$this->info_bits; - if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; - $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); - if (! empty($this->rang)) $sql.= ", rang=".$this->rang; - $sql.= " WHERE rowid = ".$this->rowid; + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; + $sql.= " description='".$this->db->escape($this->desc)."'"; + $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; + $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); + $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); + $sql.= " , qty='".price2num($this->qty)."'"; + $sql.= " , subprice=".price2num($this->subprice).""; + $sql.= " , remise_percent=".price2num($this->remise_percent).""; + $sql.= " , price=".price2num($this->price).""; // TODO A virer + $sql.= " , remise=".price2num($this->remise).""; // TODO A virer + $sql.= " , info_bits='".$this->info_bits."'"; + if (empty($this->skip_update_total)) + { + $sql.= " , total_ht=".price2num($this->total_ht).""; + $sql.= " , total_tva=".price2num($this->total_tva).""; + $sql.= " , total_ttc=".price2num($this->total_ttc).""; + } + $sql.= " , marge_tx='".$this->marge_tx."'"; + $sql.= " , marque_tx='".$this->marque_tx."'"; + $sql.= " , info_bits=".$this->info_bits; + if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; + $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); + if (! empty($this->rang)) $sql.= ", rang=".$this->rang; + $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if (! $notrigger) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result = $interface->run_triggers('LINEPROPAL_UPDATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if (! $notrigger) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result = $interface->run_triggers('LINEPROPAL_UPDATE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + } - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -2; - } - } + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -2; + } + } - /** - * Update DB line fields total_xxx - * Used by migration - * - * @return int <0 if ko, >0 if ok - */ - function update_total() - { - $this->db->begin(); + /** + * Update DB line fields total_xxx + * Used by migration + * + * @return int <0 if ko, >0 if ok + */ + function update_total() + { + $this->db->begin(); - // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; - $sql.= " total_ht=".price2num($this->total_ht,'MT').""; - $sql.= ",total_tva=".price2num($this->total_tva,'MT').""; - $sql.= ",total_ttc=".price2num($this->total_ttc,'MT').""; - $sql.= " WHERE rowid = ".$this->rowid; + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; + $sql.= " total_ht=".price2num($this->total_ht,'MT').""; + $sql.= ",total_tva=".price2num($this->total_tva,'MT').""; + $sql.= ",total_ttc=".price2num($this->total_ttc,'MT').""; + $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog("PropaleLigne::update_total sql=$sql"); + dol_syslog("PropaleLigne::update_total sql=$sql"); - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("PropaleLigne::update_total Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -2; - } - } + $resql=$this->db->query($sql); + if ($resql) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("PropaleLigne::update_total Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -2; + } + } } diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 809a5e3a76a..46ce0ac7afe 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -27,6 +27,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); $langs->load("facture"); @@ -34,15 +35,17 @@ $langs->load("orders"); $langs->load("sendings"); $langs->load("companies"); -$id=GETPOST('id', 'int'); -$ref= GETPOST('ref', 'alpha'); -$lineid=GETPOST('lineid', 'int'); -$action=GETPOST('action', 'alpha'); +$id=GETPOST('id','int'); +$ref= GETPOST('ref','alpha'); +$lineid=GETPOST('lineid','int'); +$action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'propale', $id, 'propal'); +$object = new Propal($db); + /* * Ajout d'un nouveau contact @@ -50,42 +53,39 @@ $result = restrictedArea($user, 'propale', $id, 'propal'); if ($action == 'addcontact' && $user->rights->propale->creer) { - - $result = 0; - $propal = new Propal($db); - $result = $propal->fetch($id); + $result = $object->fetch($id); if ($result > 0 && $id > 0) { - $result = $propal->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$propal->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($propal->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; } else { - $mesg = '
'.$propal->error.'
'; + $mesg = '
'.$object->error.'
'; } } } // Bascule du statut d'un contact -if ($action == 'swapstatut' && $user->rights->propale->creer) +else if ($action == 'swapstatut' && $user->rights->propale->creer) { - $propal = new Propal($db); - if ($propal->fetch($id) > 0) + if ($object->fetch($id) > 0) { - $result=$propal->swapContactStatus(GETPOST('ligne')); + $result=$object->swapContactStatus(GETPOST('ligne')); } else { @@ -94,15 +94,14 @@ if ($action == 'swapstatut' && $user->rights->propale->creer) } // Efface un contact -if ($action == 'deleteline' && $user->rights->propale->creer) +else if ($action == 'deletecontact' && $user->rights->propale->creer) { - $propal = new Propal($db); - $propal->fetch($id); - $result = $propal->delete_contact($lineid); + $object->fetch($id); + $result = $object->delete_contact($lineid); if ($result >= 0) { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$propal->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else @@ -111,6 +110,13 @@ if ($action == 'deleteline' && $user->rights->propale->creer) } } +else if ($action == 'setaddress' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->setDeliveryAddress($_POST['fk_address']); + if ($result < 0) dol_print_error($db,$object->error); +} + /* * View @@ -120,8 +126,7 @@ llxHeader('', $langs->trans("Proposal"), "Propal"); $form = new Form($db); $formcompany= new FormCompany($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$formother = new FormOther($db); /* *************************************************************************** */ @@ -133,13 +138,12 @@ dol_htmloutput_mesg($mesg); if ($id > 0 || ! empty($ref)) { - $propal = New Propal($db); - if ($propal->fetch($id,$ref) > 0) + if ($object->fetch($id,$ref) > 0) { $soc = new Societe($db); - $soc->fetch($propal->socid); + $soc->fetch($object->socid); - $head = propal_prepare_head($propal); + $head = propal_prepare_head($object); dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal'); /* @@ -151,7 +155,7 @@ if ($id > 0 || ! empty($ref)) // Ref print ''.$langs->trans('Ref').''; - print $form->showrefnav($propal,'ref',$linkback,1,'ref','ref',''); + print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); print ''; // Ref client @@ -161,202 +165,47 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - print $propal->ref_client; + print $object->ref_client; print ''; print ''; // Customer - if ( is_null($propal->client) ) - $propal->fetch_thirdparty(); + if (is_null($object->client)) $object->fetch_thirdparty(); print "".$langs->trans("Company").""; - print ''.$propal->client->getNomUrl(1).''; + print ''.$object->client->getNomUrl(1).''; + + // Delivery address + if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) + { + print ''; + print ''; + + if ($action != 'editdelivery_address' && $object->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; + print ''; + + if ($action == 'editdelivery_address') + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id); + } + else + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id); + } + print ''; + } print ""; print ''; - - /* - * Lignes de contacts - */ - print '
'; - - /* - * Ajouter une ligne de contact - * Non affiche en mode modification de ligne - */ - if ($action != 'editline' && $user->rights->propale->creer) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var = false; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to add an internal contact - print ""; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to add an external contact - $var=!$var; - print ""; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - } - - - // Liste des contacts lies - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $companystatic = new Societe($db); - $var = true; - - foreach(array('internal','external') as $source) - { - $tab = $propal->liste_contact(-1,$source); - $num=count($tab); - - $i = 0; - while ($i < $num) - { - $var = !$var; - - print ''; - - // Source - print ''; - - // Societe - print ''; - - // Contact - print ''; - - // Type de contact - print ''; - - // Statut - print ''; - - // Icon update et delete - print ''; - - print "\n"; - - $i ++; - } - } - print "
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").' 
'; - print img_object('','user').' '.$langs->trans("Users"); - print ''; - print $conf->global->MAIN_INFO_SOCIETE_NOM; - print ''; - // On recupere les id des users deja selectionnes - //$userAlreadySelected = $propal->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type - $form->select_users($user->id,'contactid',0,$userAlreadySelected); - print ''; - $formcompany->selectTypeContact($propal, '', 'type','internal'); - print '
'; - print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); - print ''; - $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$propal->client->id; - $selectedCompany = $formcompany->selectCompaniesForNewContact($propal, 'id', $selectedCompany, 'newcompany'); - print ''; - $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); - if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); - print ''; - $formcompany->selectTypeContact($propal, '', 'type','external'); - print '
 
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").''.$langs->trans("Status").' 
'; - if ($tab[$i]['source']=='internal') print $langs->trans("User"); - if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); - print ''; - if ($tab[$i]['socid'] > 0) - { - $companystatic->fetch($tab[$i]['socid']); - print $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - print $conf->global->MAIN_INFO_SOCIETE_NOM; - } - if (! $tab[$i]['socid']) - { - print ' '; - } - print ''; - if ($tab[$i]['source']=='internal') - { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - print $userstatic->getNomUrl(1); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; - print $contactstatic->getNomUrl(1); - } - print ''.$tab[$i]['libelle'].''; - // Activation desativation du contact - if ($propal->statut >= 0) print ''; - print $contactstatic->LibStatut($tab[$i]['status'],3); - if ($propal->statut >= 0) print ''; - print ''; - if ($user->rights->propale->creer) - { - print ' '; - print ''; - print img_delete(); - print ''; - } - print '
"; + + print '
'; + + // Contacts lines + include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); + } else { @@ -364,8 +213,6 @@ if ($id > 0 || ! empty($ref)) } } -llxFooter(); - $db->close(); - +llxFooter(); ?> \ No newline at end of file diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 30592f90426..45c4732f836 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -70,7 +70,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { $object->fetch_thirdparty(); - $upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); if (dol_mkdir($upload_dir) >= 0) { @@ -106,7 +106,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { $object->fetch_thirdparty(); - $upload_dir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); $mesg = '
'.$langs->trans("FileWasRemoved").'
'; @@ -128,7 +128,7 @@ if ($id > 0 || ! empty($ref)) { $object->fetch_thirdparty(); - $upload_dir = $conf->propale->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); $head = propal_prepare_head($object); dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal'); diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 665b01882a5..65867a55128 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -248,7 +248,7 @@ if ($resql) print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; @@ -318,7 +318,7 @@ if ($conf->propal->enabled && $user->rights->propale->lire) print ''; print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print ''; diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 80ab342df3f..961112151ac 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,57 +32,35 @@ $langs->load('propal'); $langs->load('compta'); $langs->load('bills'); -$id = isset($_GET["id"])?$_GET["id"]:''; +$id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'propale', $id, 'propal'); +$object = new Propal($db); /******************************************************************************/ /* Actions */ /******************************************************************************/ -if ($_POST["action"] == 'update_public' && $user->rights->propale->creer) -{ - $propal = new Propal($db); - $propal->fetch($_GET["id"]); - - $db->begin(); - - $res=$propal->update_note_public($_POST["note_public"],$user); - if ($res < 0) - { - $mesg='
'.$propal->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } +if ($action == 'setnote_public' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } -if ($_POST['action'] == 'update' && $user->rights->propale->creer) -{ - $propal = new Propal($db); - $propal->fetch($_GET["id"]); - - $db->begin(); - - $res=$propal->update_note($_POST["note"],$user); - if ($res < 0) - { - $mesg='
'.$propal->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } -} - - /******************************************************************************/ /* Affichage fiche */ @@ -92,21 +70,18 @@ llxHeader(); $form = new Form($db); -$id = $_GET["id"]; -$ref= $_GET["ref"]; if ($id > 0 || ! empty($ref)) { if ($mesg) print $mesg; $now=gmmktime(); - $propal = new Propal($db); - if ($propal->fetch($id, $ref)) + if ($object->fetch($id, $ref)) { $societe = new Societe($db); - if ( $societe->fetch($propal->socid) ) + if ( $societe->fetch($object->socid) ) { - $head = propal_prepare_head($propal); + $head = propal_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal'); print ''; @@ -115,7 +90,7 @@ if ($id > 0 || ! empty($ref)) // Ref print ''; // Ref client @@ -125,15 +100,15 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'.$langs->trans('Ref').''; - print $form->showrefnav($propal,'ref',$linkback,1,'ref','ref',''); + print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); print '
'; print ''; - print $propal->ref_client; + print $object->ref_client; print ''; print ''; // Customer - if ( is_null($propal->client) ) - $propal->fetch_thirdparty(); + if ( is_null($object->client) ) + $object->fetch_thirdparty(); print "".$langs->trans("Company").""; - print ''.$propal->client->getNomUrl(1).''; + print ''.$object->client->getNomUrl(1).''; // Ligne info remises tiers print ''.$langs->trans('Discounts').''; @@ -148,17 +123,17 @@ if ($id > 0 || ! empty($ref)) // Date print ''.$langs->trans('Date').''; - print dol_print_date($propal->date,'daytext'); + print dol_print_date($object->date,'daytext'); print ''; print ''; // Date fin propal print ''; print ''.$langs->trans('DateEndPropal').''; - if ($propal->fin_validite) + if ($object->fin_validite) { - print dol_print_date($propal->fin_validite,'daytext'); - if ($propal->statut == 1 && $propal->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + print dol_print_date($object->fin_validite,'daytext'); + if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); } else { @@ -167,63 +142,18 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // Note publique - print ''.$langs->trans("NotePublic").' :'; - print ''; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($propal->note_public?nl2br($propal->note_public):" "); - } - print ""; - - // Note privee - if (! $user->societe_id) - { - print ''.$langs->trans("NotePrivate").' :'; - print ''; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($propal->note?nl2br($propal->note):" "); - } - print ""; - } - print ""; - print ''; + print '
'; - /* - * Actions - */ + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); - print '
'; - if ($user->rights->propale->creer && $_GET['action'] <> 'edit') - { - print ''.$langs->trans('Modify').''; - } - print '
'; + dol_fiche_end(); } } } -$db->close(); + llxFooter(); +$db->close(); ?> diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 408abed65cf..c4058efea80 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -58,7 +58,7 @@ llxHeader(); print_fiche_titre($langs->trans("ProposalsStatistics"), $mesg); -$dir=$conf->propale->dir_temp; +$dir=$conf->propal->dir_temp; dol_mkdir($dir); diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 60779d92ab3..4d1a0341b5a 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -27,7 +27,7 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; echo '
'; print_titre($langs->trans('RelatedCommercialProposals')); ?> - +
diff --git a/htdocs/comm/prospect/class/prospect.class.php b/htdocs/comm/prospect/class/prospect.class.php index 7a5928058e1..f4813d96da8 100644 --- a/htdocs/comm/prospect/class/prospect.class.php +++ b/htdocs/comm/prospect/class/prospect.class.php @@ -50,8 +50,9 @@ class Prospect extends Societe /** - * \brief Charge indicateurs this->nb de tableau de bord - * \return int <0 if KO, >0 if OK + * Charge indicateurs this->nb de tableau de bord + * + * @return int <0 if KO, >0 if OK */ function load_state_board() { @@ -92,9 +93,10 @@ class Prospect extends Societe /** - * \brief Return status of prospect - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * \return string Libelle + * Return status of prospect + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @return string Libelle */ function getLibProspStatut($mode=0) { @@ -102,10 +104,11 @@ class Prospect extends Societe } /** - * \brief Return label of a given status - * \param statut Id statut - * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * \return string Libelle du statut + * Return label of a given status + * + * @param int $statut Id statut + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @return string Libelle du statut */ function LibProspStatut($statut,$mode=0) { @@ -141,8 +144,9 @@ class Prospect extends Societe } /** - * \brief Renvoi le libelle du niveau - * \return string Libelle + * Renvoi le libelle du niveau + * + * @return string Libelle */ function getLibLevel() { @@ -150,9 +154,10 @@ class Prospect extends Societe } /** - * \brief Renvoi le libelle du niveau - * \param fk_prospectlevel Prospect level - * \return string Libelle du niveau + * Renvoi le libelle du niveau + * + * @param int $fk_prospectlevel Prospect level + * @return string Libelle du niveau */ function LibLevel($fk_prospectlevel) { diff --git a/htdocs/comm/prospect/fiche.php b/htdocs/comm/prospect/fiche.php index 020cc203f10..c3c11d8f7c8 100644 --- a/htdocs/comm/prospect/fiche.php +++ b/htdocs/comm/prospect/fiche.php @@ -312,8 +312,6 @@ if ($socid > 0) } } - //print ''.$langs->trans("AddContact").''; - print ''; print '
'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a828997f3a7..8c4a8b6f06e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -83,6 +83,10 @@ class Commande extends CommonObject var $rang; var $special_code; var $source; // Origin of order + var $note; // deprecated + var $note_private; + var $note_public; + var $extraparams=array(); var $origin; var $origin_id; @@ -506,6 +510,7 @@ class Commande extends CommonObject * Cancel an order * If stock is decremented on order validation, we must reincrement it * + * @param User $user Object user * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ @@ -584,7 +589,7 @@ class Commande extends CommonObject * Note that this->ref can be set or empty. If empty, we will use "(PROV)" * * @param User $user Objet user that make creation - * @param int notrigger Disable all triggers + * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ function create($user, $notrigger=0) @@ -667,25 +672,25 @@ class Commande extends CommonObject } $result = $this->addline( - $this->id, - $this->lines[$i]->desc, - $this->lines[$i]->subprice, - $this->lines[$i]->qty, - $this->lines[$i]->tva_tx, - $this->lines[$i]->localtax1_tx, - $this->lines[$i]->localtax2_tx, - $this->lines[$i]->fk_product, - $this->lines[$i]->remise_percent, - $this->lines[$i]->info_bits, - $this->lines[$i]->fk_remise_except, - 'HT', - 0, - $this->lines[$i]->date_start, - $this->lines[$i]->date_end, - $this->lines[$i]->product_type, - $this->lines[$i]->rang, - $this->lines[$i]->special_code, - $fk_parent_line + $this->id, + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->fk_product, + $this->lines[$i]->remise_percent, + $this->lines[$i]->info_bits, + $this->lines[$i]->fk_remise_except, + 'HT', + 0, + $this->lines[$i]->date_start, + $this->lines[$i]->date_end, + $this->lines[$i]->product_type, + $this->lines[$i]->rang, + $this->lines[$i]->special_code, + $fk_parent_line ); if ($result < 0) { @@ -707,7 +712,7 @@ class Commande extends CommonObject if ($this->id) { $this->ref="(PROV".$this->id.")"; - + // Add object linked if (is_array($this->linked_objects) && ! empty($this->linked_objects)) { @@ -719,25 +724,25 @@ class Commande extends CommonObject dol_print_error($this->db); $error++; } - + // TODO mutualiser if ($origin == 'propal' && $origin_id) { // On recupere les differents contact interne et externe $prop = new Propal($this->db, $this->socid, $origin_id); - + // On recupere le commercial suivi propale $this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL'); - + if ($this->userid) { //On passe le commercial suivi propale en commercial suivi commande $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal'); } - + // On recupere le contact client suivi propale $this->contactid = $prop->getIdcontact('external', 'CUSTOMER'); - + if ($this->contactid) { //On passe le contact client suivi propale en contact client suivi commande @@ -868,6 +873,7 @@ class Commande extends CommonObject function createFromProposal($object) { global $conf,$user,$langs; + global $hookmanager; $error=0; @@ -915,16 +921,26 @@ class Commande extends CommonObject $this->note = $object->note; $this->note_public = $object->note_public; - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; + + // Possibility to add external linked objects with hooks + $this->linked_objects[$this->origin] = $this->origin_id; + if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + { + $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); + } $ret = $this->create($user); if ($ret > 0) { // Actions hooked (by external module) - include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); - $hookmanager=new HookManager($this->db); + if (! is_object($hookmanager)) + { + include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); + $hookmanager=new HookManager($this->db); + } $hookmanager->initHooks(array('orderdao')); $parameters=array('objFrom'=>$object); @@ -970,6 +986,8 @@ class Commande extends CommonObject * @param timestamp $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) * @param int $type Type of line (0=product, 1=service) * @param int $rang Position of line + * @param int $special_code Special code + * @param int $fk_parent_line Parent line * @return int >0 if OK, <0 if KO * * @see add_product @@ -1210,7 +1228,7 @@ class Commande extends CommonObject $sql.= ', c.date_commande'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as facturee'; - $sql.= ', c.note, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison'; + $sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison, c.extraparams'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', ca.code as availability_code'; @@ -1255,7 +1273,8 @@ class Commande extends CommonObject $this->remise_absolue = $obj->remise_absolue; $this->source = $obj->source; $this->facturee = $obj->facturee; - $this->note = $obj->note; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->fk_project = $obj->fk_projet; $this->modelpdf = $obj->model_pdf; @@ -1274,6 +1293,8 @@ class Commande extends CommonObject $this->fk_delivery_address = $obj->fk_adresse_livraison; $this->propale_id = $obj->fk_source; + $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->lines = array(); if ($this->statut == 0) $this->brouillon = 1; @@ -1553,6 +1574,8 @@ class Commande extends CommonObject /** * Returns a array with expeditions lines number * + * @return int Nb of shipments + * * TODO deprecated, move to Shipping class */ function nb_expedition() @@ -1844,34 +1867,6 @@ class Commande extends CommonObject } } - /** - * Set address - * - * @param User $user Object user making change - * @param int $fk_address Adress of delivery - * @return int <0 ig KO, >0 if Ok - */ - function set_adresse_livraison($user, $fk_address) - { - if ($user->rights->commande->creer) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_adresse_livraison = '".$fk_address."'"; - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; - - if ($this->db->query($sql) ) - { - $this->fk_delivery_address = $fk_address; - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("Commande::set_adresse_livraison Erreur SQL"); - return -1; - } - } - } - /** * Set availability * @@ -1975,75 +1970,6 @@ class Commande extends CommonObject } } - /** - * Change les conditions de reglement de la commande - * - * @param int $cond_reglement_id Id de la nouvelle condition de reglement - * @return int >0 if OK, <0 if KO - */ - function cond_reglement($cond_reglement_id) - { - dol_syslog('Commande::cond_reglement('.$cond_reglement_id.')'); - if ($this->statut >= 0) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET fk_cond_reglement = '.$cond_reglement_id; - $sql .= ' WHERE rowid='.$this->id; - if ( $this->db->query($sql) ) - { - $this->cond_reglement_id = $cond_reglement_id; - return 1; - } - else - { - dol_syslog('Commande::cond_reglement Erreur '.$sql.' - '.$this->db->error(), LOG_ERR); - $this->error=$this->db->lasterror(); - return -1; - } - } - else - { - dol_syslog('Commande::cond_reglement, etat commande incompatible', LOG_ERR); - $this->error='Etat commande incompatible '.$this->statut; - return -2; - } - } - - - /** - * Change le mode de reglement - * - * @param int $mode Id du nouveau mode - * @return int >0 si ok, <0 si ko - */ - function mode_reglement($mode_reglement_id) - { - dol_syslog('Commande::mode_reglement('.$mode_reglement_id.')'); - if ($this->statut >= 0) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET fk_mode_reglement = '.$mode_reglement_id; - $sql .= ' WHERE rowid='.$this->id; - if ( $this->db->query($sql) ) - { - $this->mode_reglement_id = $mode_reglement_id; - return 1; - } - else - { - dol_syslog('Commande::mode_reglement Erreur '.$sql.' - '.$this->db->error(), LOG_ERR); - $this->error=$this->db->lasterror(); - return -1; - } - } - else - { - dol_syslog('Commande::mode_reglement, etat facture incompatible', LOG_ERR); - $this->error='Etat commande incompatible '.$this->statut; - return -2; - } - } - /** * Change le delai de livraison * @@ -2114,6 +2040,7 @@ class Commande extends CommonObject /** * Set customer ref + * * @param User $user User that make change * @param string $ref_client Customer ref * @return int <0 if KO, >0 if OK @@ -2184,7 +2111,7 @@ class Commande extends CommonObject * @param double $pu Prix unitaire * @param double $qty Quantity * @param double $remise_percent Pourcentage de remise de la ligne - * @param double $tva_tx Taux TVA + * @param double $txtva Taux TVA * @param double $txlocaltax1 Local tax 1 rate * @param double $txlocaltax2 Local tax 2 rate * @param string $price_base_type HT or TTC @@ -2192,6 +2119,8 @@ class Commande extends CommonObject * @param timestamp $date_start Start date of the line * @param timestamp $date_end End date of the line * @param int $type Type of line (0=product, 1=service) + * @param int $fk_parent_line Parent line id + * @param int $skip_update_total Skip update of total * @return int < 0 if KO, > 0 if OK */ function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0) @@ -2323,7 +2252,7 @@ class Commande extends CommonObject $error = 0; $this->db->begin(); - + if (! $error && ! $notrigger) { // Appel des triggers @@ -2335,7 +2264,7 @@ class Commande extends CommonObject } // Fin appel triggers } - + if (! $error) { // Delete order details @@ -2346,7 +2275,7 @@ class Commande extends CommonObject dol_syslog(get_class($this)."::delete error", LOG_ERR); $error++; } - + // Delete order $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); @@ -2355,15 +2284,15 @@ class Commande extends CommonObject dol_syslog(get_class($this)."::delete error", LOG_ERR); $error++; } - + // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; - + // Delete linked contacts $res = $this->delete_linked_contact(); if ($res < 0) $error++; - + // On efface le repertoire de pdf provisoire $comref = dol_sanitizeFileName($this->ref); if ($conf->commande->dir_output) @@ -2373,7 +2302,7 @@ class Commande extends CommonObject if (file_exists($file)) // We must delete all files before deleting directory { dol_delete_preview($this); - + if (!dol_delete_file($file)) { $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); @@ -2392,7 +2321,7 @@ class Commande extends CommonObject } } } - + if (! $error) { dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); @@ -2500,7 +2429,7 @@ class Commande extends CommonObject if ($statut==3 && ! $facturee) return $langs->trans('StatusOrderToBill'); if ($statut==3 && $facturee) return $langs->trans('StatusOrderProcessed'); } - if ($mode == 1) + elseif ($mode == 1) { if ($statut==-1) return $langs->trans('StatusOrderCanceledShort'); if ($statut==0) return $langs->trans('StatusOrderDraftShort'); @@ -2509,7 +2438,7 @@ class Commande extends CommonObject if ($statut==3 && ! $facturee) return $langs->trans('StatusOrderToBillShort'); if ($statut==3 && $facturee) return $langs->trans('StatusOrderProcessed'); } - if ($mode == 2) + elseif ($mode == 2) { if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort'); if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort'); @@ -2518,7 +2447,7 @@ class Commande extends CommonObject if ($statut==3 && ! $facturee) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBillShort'); if ($statut==3 && $facturee) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessedShort'); } - if ($mode == 3) + elseif ($mode == 3) { if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0'); @@ -2527,7 +2456,7 @@ class Commande extends CommonObject if ($statut==3 && ! $facturee) return img_picto($langs->trans('StatusOrderToBill'),'statut7'); if ($statut==3 && $facturee) return img_picto($langs->trans('StatusOrderProcessed'),'statut6'); } - if ($mode == 4) + elseif ($mode == 4) { if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled'); if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft'); @@ -2536,7 +2465,7 @@ class Commande extends CommonObject if ($statut==3 && ! $facturee) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBill'); if ($statut==3 && $facturee) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessed'); } - if ($mode == 5) + elseif ($mode == 5) { if ($statut==-1) return $langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5'); if ($statut==0) return $langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0'); @@ -2584,7 +2513,8 @@ class Commande extends CommonObject /** * Charge les informations d'ordre info dans l'objet commande * - * @param int $id Id of order + * @param int $id Id of order + * @return void */ function info($id) { @@ -2899,7 +2829,8 @@ class OrderLine /** * Load line order * - * @param rowid id line order + * @param int $rowid Id line order + * @return int <0 if KO, >0 if OK */ function fetch($rowid) { diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index bc8ca78ad55..7aa1f4280b6 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -51,11 +51,11 @@ class CommandeStats extends Stats * @param string $mode Option * @param int $userid Id user for filter */ - function CommandeStats($DB, $socid=0, $mode, $userid=0) + function CommandeStats($db, $socid, $mode, $userid=0) { global $user, $conf; - $this->db = $DB; + $this->db = $db; $this->socid = $socid; $this->userid = $userid; @@ -88,7 +88,7 @@ class CommandeStats extends Stats /** * Return orders number by month for a year - * + * * @param int $year year for stats * @return array array with number by month */ @@ -110,7 +110,7 @@ class CommandeStats extends Stats /** * Return orders number by year - * + * * @return array array with number by year * */ @@ -175,7 +175,7 @@ class CommandeStats extends Stats /** * Return nb, total and average - * + * * @return array Array of values */ function getAllByYear() diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 828dc7c0a26..9e4cfd2923b 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2011 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,61 +27,62 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/order.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); $langs->load("orders"); $langs->load("sendings"); $langs->load("companies"); -$comid = isset($_GET["id"])?$_GET["id"]:''; +$id=GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'commande', $comid,''); +$result = restrictedArea($user, 'commande', $id,''); +$object = new Commande($db); /* * Ajout d'un nouveau contact */ -if ($_POST["action"] == 'addcontact' && $user->rights->commande->creer) +if ($action == 'addcontact' && $user->rights->commande->creer) { + $result = $object->fetch($id); - $result = 0; - $commande = new Commande($db); - $result = $commande->fetch($_GET["id"]); - - if ($result > 0 && $_GET["id"] > 0) + if ($result > 0 && $id > 0) { - $result = $commande->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { - Header("Location: contact.php?id=".$commande->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($commande->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; } else { - $mesg = '
'.$commande->error.'
'; + $mesg = '
'.$object->error.'
'; } } } // bascule du statut d'un contact -if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer) +else if ($action == 'swapstatut' && $user->rights->commande->creer) { - $commande = new Commande($db); - if ($commande->fetch(GETPOST('id','int'))) + if ($object->fetch($id)) { - $result=$commande->swapContactStatus(GETPOST('ligne')); + $result=$object->swapContactStatus(GETPOST('ligne')); } else { @@ -90,15 +91,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer) } // Efface un contact -if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer) +else if ($action == 'deletecontact' && $user->rights->commande->creer) { - $commande = new Commande($db); - $commande->fetch($_GET["id"]); - $result = $commande->delete_contact($_GET["lineid"]); + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); if ($result >= 0) { - Header("Location: contact.php?id=".$commande->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -106,6 +106,11 @@ if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer) } } +else if ($action == 'setaddress' && $user->rights->commande->creer) +{ + $object->fetch($id); + $object->setDeliveryAddress($_POST['fk_address']); +} /* * View @@ -115,6 +120,7 @@ llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES $form = new Form($db); $formcompany = new FormCompany($db); +$formother = new FormOther($db); $contactstatic=new Contact($db); $userstatic=new User($db); @@ -126,19 +132,17 @@ $userstatic=new User($db); /* *************************************************************************** */ dol_htmloutput_mesg($mesg); -$id = $_GET['id']; -$ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { $langs->trans("OrderCard"); - $commande = new Commande($db); - if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0) + + if ($object->fetch($id, $ref) > 0) { $soc = new Societe($db); - $soc->fetch($commande->socid); + $soc->fetch($object->socid); - $head = commande_prepare_head($commande); + $head = commande_prepare_head($object); dol_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), 0, 'order'); @@ -149,7 +153,7 @@ if ($id > 0 || ! empty($ref)) // Ref print '
"; // Ref commande client @@ -159,201 +163,48 @@ if ($id > 0 || ! empty($ref)) print ''; print '
trans("Ref"); ?> trans('RefCustomer'); ?>
'.$langs->trans("Ref").''; - print $form->showrefnav($commande,'ref','',1,'ref','ref'); + print $form->showrefnav($object,'ref','',1,'ref','ref'); print "
'; print ''; - print $commande->ref_client; + print $object->ref_client; print ''; print ''; // Customer - if ( is_null($commande->client) ) - $commande->fetch_thirdparty(); + if (is_null($object->client)) $object->fetch_thirdparty(); print "".$langs->trans("Company").""; - print ''.$commande->client->getNomUrl(1).''; + print ''.$object->client->getNomUrl(1).''; + + // Delivery address + if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) + { + print ''; + print ''; + + if ($action != 'editdelivery_address' && $object->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; + print ''; + + if ($action == 'editdelivery_address') + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id); + } + else + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id); + } + print ''; + } + print ""; print ''; - /* - * Lignes de contacts - */ - echo '
'; + print '
'; + + // Contacts lines + include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); - /* - * Ajouter une ligne de contact - * Non affiche en mode modification de ligne - */ - if ($_GET["action"] != 'editline' && $user->rights->commande->creer) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var = false; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Ligne ajout pour contact interne - print ''; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Ligne ajout pour contact externe - $var=!$var; - print ''; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ""; - - print ''; - } - - // List of linked contacts - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $companystatic=new Societe($db); - $var = true; - - foreach(array('internal','external') as $source) - { - $tab = $commande->liste_contact(-1,$source); - $num=count($tab); - - $i = 0; - while ($i < $num) - { - $var = !$var; - - print ''; - - // Source - print ''; - - // Societe - print ''; - - // Contact - print ''; - - // Type de contact - print ''; - - // Statut - print ''; - - // Icon update et delete - print ''; - - print "\n"; - - $i ++; - } - } - print "
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").'  
'; - print img_object('','user').' '.$langs->trans("Users"); - print ''; - print $conf->global->MAIN_INFO_SOCIETE_NOM; - print ''; - //$userAlreadySelected = $commande->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type - $form->select_users($user->id,'contactid',0,$userAlreadySelected); - print ''; - $formcompany->selectTypeContact($commande, '', 'type','internal'); - print '
'; - print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); - print ''; - $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$commande->client->id; - $selectedCompany = $formcompany->selectCompaniesForNewContact($commande, 'id', $selectedCompany, 'newcompany'); - print ''; - $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); - if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); - print ''; - $formcompany->selectTypeContact($commande, '', 'type','external'); - print '
 
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").''.$langs->trans("Status").' 
'; - if ($tab[$i]['source']=='internal') print $langs->trans("User"); - if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); - print ''; - if ($tab[$i]['socid'] > 0) - { - $companystatic->fetch($tab[$i]['socid']); - print $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - print $conf->global->MAIN_INFO_SOCIETE_NOM; - } - if (! $tab[$i]['socid']) - { - print ' '; - } - print ''; - if ($tab[$i]['source']=='internal') - { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - print $userstatic->getNomUrl(1); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; - print $contactstatic->getNomUrl(1); - } - print ''.$tab[$i]['libelle'].''; - // Activation desativation du contact - if ($commande->statut >= 0) print ''; - print $contactstatic->LibStatut($tab[$i]['status'],3); - if ($commande->statut >= 0) print ''; - print ''; - if ($commande->statut < 5 && $user->rights->commande->creer) - { - print ' '; - print ''; - print img_delete(); - print ''; - } - print '
"; } else { @@ -362,7 +213,7 @@ if ($id > 0 || ! empty($ref)) } } -$db->close(); +$db->close(); llxFooter(); ?> \ No newline at end of file diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index f4838e1663e..fabaa069a9b 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -189,7 +189,8 @@ else Header('Location: index.php'); } -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 86a33feb3f6..e3096ffdac9 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -29,7 +29,6 @@ */ require("../main.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formorder.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/modules/commande/modules_commande.php"); @@ -105,7 +104,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } // Reopen a closed order -if ($action == 'reopen' && $user->rights->commande->creer) +else if ($action == 'reopen' && $user->rights->commande->creer) { $object->fetch($id); if ($object->statut == 3) @@ -124,7 +123,7 @@ if ($action == 'reopen' && $user->rights->commande->creer) } // Suppression de la commande -if ($action == 'confirm_delete' && $confirm == 'yes') +else if ($action == 'confirm_delete' && $confirm == 'yes') { if ($user->rights->commande->supprimer) { @@ -143,7 +142,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') } // Remove a product line -if ($action == 'confirm_deleteline' && $confirm == 'yes') +else if ($action == 'confirm_deleteline' && $confirm == 'yes') { if ($user->rights->commande->creer) { @@ -179,14 +178,14 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes') } // Categorisation dans projet -if ($action == 'classin') +else if ($action == 'classin') { $object->fetch($id); $object->setProject($_POST['projectid']); } // Add order -if ($action == 'add' && $user->rights->commande->creer) +else if ($action == 'add' && $user->rights->commande->creer) { $datecommande = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datelivraison = dol_mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']); @@ -379,26 +378,26 @@ if ($action == 'add' && $user->rights->commande->creer) } -if ($action == 'classifybilled') +else if ($action == 'classifybilled') { $object->fetch($id); $object->classer_facturee(); } // Positionne ref commande client -if ($action == 'set_ref_client' && $user->rights->commande->creer) +else if ($action == 'set_ref_client' && $user->rights->commande->creer) { $object->fetch($id); $object->set_ref_client($user, $_POST['ref_client']); } -if ($action == 'setremise' && $user->rights->commande->creer) +else if ($action == 'setremise' && $user->rights->commande->creer) { $object->fetch($id); $object->set_remise($user, $_POST['remise']); } -if ($action == 'setabsolutediscount' && $user->rights->commande->creer) +else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { if ($_POST["remise_id"]) { @@ -414,7 +413,7 @@ if ($action == 'setabsolutediscount' && $user->rights->commande->creer) } } -if ($action == 'setdate' && $user->rights->commande->creer) +else if ($action == 'setdate' && $user->rights->commande->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $date=dol_mktime(0, 0, 0, $_POST['order_month'], $_POST['order_day'], $_POST['order_year']); @@ -427,7 +426,7 @@ if ($action == 'setdate' && $user->rights->commande->creer) } } -if ($action == 'setdate_livraison' && $user->rights->commande->creer) +else if ($action == 'setdate_livraison' && $user->rights->commande->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $datelivraison=dol_mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); @@ -440,56 +439,64 @@ if ($action == 'setdate_livraison' && $user->rights->commande->creer) } } -if ($action == 'setaddress' && $user->rights->commande->creer) +else if ($action == 'setmode' && $user->rights->commande->creer) { $object->fetch($id); - $object->set_adresse_livraison($user,$_POST['fk_address']); -} - -if ($action == 'setmode' && $user->rights->commande->creer) -{ - $object->fetch($id); - $result=$object->mode_reglement($_POST['mode_reglement_id']); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setavailability' && $user->rights->commande->creer) +else if ($action == 'setavailability' && $user->rights->commande->creer) { $object->fetch($id); $result=$object->availability($_POST['availability_id']); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setdemandreason' && $user->rights->commande->creer) +else if ($action == 'setdemandreason' && $user->rights->commande->creer) { $object->fetch($id); $result=$object->demand_reason($_POST['demand_reason_id']); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setconditions' && $user->rights->commande->creer) +else if ($action == 'setconditions' && $user->rights->commande->creer) { $object->fetch($id); - $result=$object->cond_reglement($_POST['cond_reglement_id']); + $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setremisepercent' && $user->rights->facture->creer) +else if ($action == 'setremisepercent' && $user->rights->commande->creer) { $object->fetch($id); $result = $object->set_remise($user, $_POST['remise_percent']); } -if ($action == 'setremiseabsolue' && $user->rights->facture->creer) +else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) { $object->fetch($id); $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); } +else if ($action == 'setnote_public' && $user->rights->commande->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->commande->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + /* * Ajout d'une ligne produit dans la commande */ -if ($action == 'addline' && $user->rights->commande->creer) +else if ($action == 'addline' && $user->rights->commande->creer) { $result=0; @@ -674,7 +681,7 @@ if ($action == 'addline' && $user->rights->commande->creer) /* * Mise a jour d'une ligne dans la commande */ -if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save')) +else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save')) { if (! $object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); @@ -774,13 +781,13 @@ if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] } } -if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel')) +else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel')) { Header('Location: fiche.php?id='.$id); // Pour reaffichage de la fiche en cours d'edition exit; } -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) +else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { $idwarehouse=GETPOST('idwarehouse'); @@ -819,7 +826,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->command } // Go back to draft status -if ($action == 'confirm_modif' && $user->rights->commande->creer) +else if ($action == 'confirm_modif' && $user->rights->commande->creer) { $idwarehouse=GETPOST('idwarehouse'); @@ -861,7 +868,7 @@ if ($action == 'confirm_modif' && $user->rights->commande->creer) } } -if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer) +else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande->cloturer) { $object->fetch($id); // Load order and lines @@ -869,7 +876,7 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->commande-> if ($result < 0) $mesgs=$object->errors; } -if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) +else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { $idwarehouse=GETPOST('idwarehouse'); @@ -898,7 +905,7 @@ if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande- * Ordonnancement des lignes */ -if ($action == 'up' && $user->rights->commande->creer) +else if ($action == 'up' && $user->rights->commande->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -921,7 +928,7 @@ if ($action == 'up' && $user->rights->commande->creer) exit; } -if ($action == 'down' && $user->rights->commande->creer) +else if ($action == 'down' && $user->rights->commande->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -943,7 +950,7 @@ if ($action == 'down' && $user->rights->commande->creer) exit; } -if ($action == 'builddoc') // In get or post +else if ($action == 'builddoc') // In get or post { /* * Generate order document @@ -983,7 +990,7 @@ if ($action == 'builddoc') // In get or post } // Remove file in doc form -if ($action == 'remove_file') +else if ($action == 'remove_file') { if ($object->fetch($id)) { @@ -1041,11 +1048,11 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P if ($result > 0) { - $ref = dol_sanitizeFileName($object->ref); - $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; +// $ref = dol_sanitizeFileName($object->ref); +// $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - if (is_readable($file)) - { +// if (is_readable($file)) +// { if ($_POST['sendto']) { // Le destinataire a ete fourni via le champ libre @@ -1160,14 +1167,14 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P $mesg.=''; } } - } +/* } else { $langs->load("other"); $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; $action='presend'; dol_syslog('Recipient email is empty'); - } + }*/ } else { @@ -1184,6 +1191,67 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P } } +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +{ + if ($action == 'addcontact' && $user->rights->commande->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->commande->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->commande->creer) + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } + } +} + /* * View @@ -1193,7 +1261,6 @@ llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES $form = new Form($db); $formfile = new FormFile($db); -$formother = new FormOther($db); $formorder = new FormOrder($db); @@ -1244,13 +1311,16 @@ if ($action == 'create' && $user->rights->commande->creer) $ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); $soc = $objectsrc->client; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + + $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); + $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); // Object source contacts list $srccontactslist = $objectsrc->liste_contact(-1,'external',1); @@ -1330,15 +1400,6 @@ if ($action == 'create' && $user->rights->commande->creer) $form->select_date($datedelivery,'liv_','','','',"crea_commande",1,1); print ""; - // Delivery address - if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) - { - print ''.$langs->trans('DeliveryAddress').''; - $numaddress = $formother->select_address($soc->fk_delivery_address, $socid,'fk_address',1); - print '   '.$langs->trans("AddAddress").''; - print ''; - } - // Conditions de reglement print ''.$langs->trans('PaymentConditionsShort').''; $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id',-1,1); @@ -1400,8 +1461,8 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''.$langs->trans('NotePublic').''; print ''; - print ''; + print ''; + print ''; // Note privee if (! $user->societe_id) @@ -1409,8 +1470,8 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''.$langs->trans('NotePrivate').''; print ''; - print ''; + print ''; + print ''; } if (is_object($objectsrc)) @@ -1797,33 +1858,6 @@ else print $object->date_livraison ? dol_print_date($object->date_livraison,'daytext') : ' '; } print ''; - print ''.$langs->trans('NotePublic').' :
'; - print dol_htmlcleanlastbr($object->note_public); - print ''; - print ''; - - // Delivery address - if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) - { - print ''; - print ''; - - if ($action != 'editdelivery_adress' && $object->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socid.'&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; - print ''; - - if ($action == 'editdelivery_adress') - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$socid,'fk_address','commande',$object->id); - } - else - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$socid,'none','commande',$object->id); - } - print ''; - } // Terms of payment print ''; @@ -1975,9 +2009,26 @@ else print ''.$object->getLibStatut(4).''; print ''; - print '
'; + print '
'; print "\n"; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + /* * Lines */ @@ -2045,16 +2096,11 @@ else // Send if ($object->statut > 0) { - $comref = dol_sanitizeFileName($object->ref); - $file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf'; - if (file_exists($file)) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) - { - print ''.$langs->trans('SendByMail').''; - } - else print ''.$langs->trans('SendByMail').''; + print ''.$langs->trans('SendByMail').''; } + else print ''.$langs->trans('SendByMail').''; } // Ship @@ -2184,7 +2230,33 @@ else if ($action == 'presend') { $ref = dol_sanitizeFileName($object->ref); - $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; + include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref); + $file=$fileparams['fullname']; + + // Build document if it not exists + if (! $file || ! is_readable($file)) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref); + $file=$fileparams['fullname']; + } print '
'; print_titre($langs->trans('SendOrderByMail')); @@ -2210,6 +2282,8 @@ else $formmail->withcancel=1; // Tableau des substitutions $formmail->substit['__ORDERREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=''; + $formmail->substit['__PERSONALIZED__']=''; // Tableau des parametres complementaires $formmail->param['action']='send'; $formmail->param['models']='order_send'; @@ -2217,10 +2291,10 @@ else $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; // Init list of files - if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + if (GETPOST("mode")=='init') { $formmail->clear_attached_files(); - $formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf'); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); } // Show form diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 17d71af6cb7..614c28421a2 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,25 +27,24 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'); require_once(DOL_DOCUMENT_ROOT ."/commande/class/commande.class.php"); -$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:""; - -if (!$user->rights->commande->lire) accessforbidden(); $langs->load("companies"); $langs->load("bills"); $langs->load("orders"); +$id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); + // Security check $socid=0; -$comid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'commande',$comid,''); +$result=restrictedArea($user,'commande',$id,''); -$id = $_GET['id']; -$ref= $_GET['ref']; -$commande = new Commande($db); -if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0) +$object = new Commande($db); +if (! $object->fetch($id, $ref) > 0) { dol_print_error($db); } @@ -55,25 +54,19 @@ if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0) * Actions */ -if ($_POST["action"] == 'update' && $user->rights->commande->creer) +if ($action == 'setnote_public' && $user->rights->commande->creer) { - $db->begin(); - - $resPrivateNote=$commande->update_note($_POST["note"]); - $resPublicNote=$commande->update_note_public($_POST["note_public"]); - - if ($resPrivateNote < 0 || $resPublicNote < 0) - { - $mesg='
'.$commande->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } - +else if ($action == 'setnote' && $user->rights->commande->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} /* * View @@ -86,17 +79,17 @@ $form = new Form($db); if ($id > 0 || ! empty($ref)) { $soc = new Societe($db); - $soc->fetch($commande->socid); + $soc->fetch($object->socid); - $head = commande_prepare_head($commande); + $head = commande_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans("CustomerOrder"), 0, 'order'); print ''; // Ref - print '"; // Ref commande client @@ -106,7 +99,7 @@ if ($id > 0 || ! empty($ref)) print ''; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($commande,'ref','',1,'ref','ref'); + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); print "
'; print ''; - print $commande->ref_client; + print $object->ref_client; print ''; print ''; @@ -114,64 +107,16 @@ if ($id > 0 || ! empty($ref)) print "".$langs->trans("Company").""; print ''.$soc->getNomUrl(1).''; - // Note publique - print ''.$langs->trans("NotePublic").' :'; - print ''; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - } - else - { - print ($commande->note_public?nl2br($commande->note_public):" "); - } - print ""; - - // Note private - if (! $user->societe_id) - { - print ''.$langs->trans("NotePrivate").' :'; - print ''; - if ($_GET["action"] == 'edit') - { - print '
"; - } - else - { - print ($commande->note?nl2br($commande->note):" "); - } - print ""; - } print ""; - if ($_GET["action"] == 'edit') - { - print '
'; - print ' '; - print '
'; - print '
'; - } + print '
'; + + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); print ''; - - /* - * Actions - */ - - print '
'; - - if ($user->rights->commande->creer && $_GET["action"] <> 'edit') - { - print "id."&action=edit\">".$langs->trans('Modify').""; - } - - print "
"; } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 9823a2b7f53..8b169a90f3b 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -29,7 +29,7 @@ echo '
'; print_titre($langs->trans('RelatedOrders')); ?> - +
diff --git a/htdocs/compta/bank/bilan.php b/htdocs/compta/bank/bilan.php index 63aab99a330..d12b2560f97 100644 --- a/htdocs/compta/bank/bilan.php +++ b/htdocs/compta/bank/bilan.php @@ -28,6 +28,12 @@ if (!$user->rights->banque->lire) accessforbidden(); +/** + * Get result of sql for field amount + * + * @param string $sql SQL string + * @return int Amount + */ function valeur($sql) { global $db; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 8b2e472b257..9158f11148b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1,36 +1,34 @@ * Copyright (C) 2003 Jean-Louis Bergamo -* Copyright (C) 2004-2010 Laurent Destailleur -* Copyright (C) 2004 Christophe Combelles -* Copyright (C) 2005-2010 Regis Houssin -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 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 . -*/ + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Christophe Combelles + * Copyright (C) 2005-2010 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ /** * \file htdocs/compta/bank/class/account.class.php * \ingroup banque * \brief File of class to manage bank accounts */ - require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); /** - * \class Account - * \brief Class to manage bank accounts + * Class to manage bank accounts */ class Account extends CommonObject { @@ -46,7 +44,7 @@ class Account extends CommonObject //! Name var $bank; var $clos; - var $rappro; // If bank need to be conciliated + var $rappro=1; // If bank need to be conciliated var $url; //! BBAN field for French Code banque var $code_banque; @@ -130,12 +128,12 @@ class Account extends CommonObject /** * Add a link between bank line record and its source * - * @param line_id Id ecriture bancaire - * @param url_id Id parametre url - * @param url Url - * @param label Link label - * @param type Type of link ('payment', 'company', 'member', ...) - * @return int <0 if KO, id line if OK + * @param int $line_id Id ecriture bancaire + * @param int $url_id Id parametre url + * @param string $url Url + * @param string $label Link label + * @param string $type Type of link ('payment', 'company', 'member', ...) + * @return int <0 if KO, id line if OK */ function add_url_line($line_id, $url_id, $url, $label, $type) { @@ -171,10 +169,10 @@ class Account extends CommonObject * TODO Move this into AccountLine * Return array with links from llx_bank_url * - * @param fk_bank To search using bank transaction id - * @param url_id To search using link to - * @param type To search using type - * @return array Array of links + * @param int $fk_bank To search using bank transaction id + * @param int $url_id To search using link to + * @param string $type To search using type + * @return array Array of links */ function get_url($fk_bank='', $url_id='', $type='') { @@ -227,18 +225,18 @@ class Account extends CommonObject /** * Add an entry into table ".MAIN_DB_PREFIX."bank * - * @param $date Date operation - * @param $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ... - * @param $label Descripton - * @param $amount Amount - * @param $num_chq Numero cheque ou virement - * @param $categorie Categorie optionnelle - * @param $user User that create - * @param $emetteur Name of cheque writer - * @param $banque Bank of cheque writer - * @return int Rowid of added entry, <0 if KO + * @param timsestmap $date Date operation + * @param string $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ... + * @param string $label Descripton + * @param float $amount Amount + * @param string $num_chq Numero cheque ou virement + * @param string $categorie Categorie optionnelle + * @param User $user User that create + * @param string $emetteur Name of cheque writer + * @param string $banque Bank of cheque writer + * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user, $emetteur='',$banque='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, $user, $emetteur='',$banque='') { // Clean parameters $emetteur=trim($emetteur); @@ -266,12 +264,12 @@ class Account extends CommonObject // Check parameters if (! $oper) { - $this->error="Account::addline oper not defined"; + $this->error="oper not defined"; return -1; } if (! $this->rowid) { - $this->error="Account::addline this->rowid not defined"; + $this->error="this->rowid not defined"; return -2; } if ($this->courant == 2 && $oper != 'LIQ') @@ -309,7 +307,7 @@ class Account extends CommonObject $sql.= ", ".($banque?"'".$this->db->escape($banque)."'":"null"); $sql.= ")"; - dol_syslog("Account::addline sql=".$sql); + dol_syslog(get_class($this)."::addline sql=".$sql); if ($this->db->query($sql)) { $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank"); @@ -337,35 +335,45 @@ class Account extends CommonObject else { $this->error=$this->db->lasterror(); - dol_syslog("Account::addline ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::addline ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } } /** - * Create bank account into database + * Create bank account into database * - * @param user Object user making action - * @return int < 0 if KO, > 0 if OK + * @param User $user Object user making action + * @return int < 0 if KO, > 0 if OK */ function create($user='') { global $langs,$conf; - // Check parameters + // Clean parameters if (! $this->min_allowed) $this->min_allowed=0; if (! $this->min_desired) $this->min_desired=0; - if (empty($this->fk_pays)) + $this->state_id = ($this->state_id?$this->state_id:$this->fk_departement); + $this->country_id = ($this->country_id?$this->country_id:$this->fk_pays); + + // Check parameters + if (empty($this->country_id)) { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Country")); - dol_syslog("Account::update ".$this->error, LOG_ERR); + $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Country")); + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } if (empty($this->ref)) { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); - dol_syslog("Account::update ".$this->error, LOG_ERR); + $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")); + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -1; + } + if (empty($this->date_solde)) + { + $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateInitialBalance")); + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } @@ -398,43 +406,48 @@ class Account extends CommonObject $sql.= ", ".price2num($this->min_allowed); $sql.= ", ".price2num($this->min_desired); $sql.= ", '".$this->db->escape($this->comment)."'"; - $sql.= ", ".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); - $sql.= ", ".$this->fk_pays; + $sql.= ", ".($this->state_id>0?"'".$this->state_id."'":"null"); + $sql.= ", ".$this->country_id; $sql.= ")"; - dol_syslog("Account::create sql=".$sql); + dol_syslog(get_class($this)."::create sql=".$sql); $resql=$this->db->query($sql); if ($resql) { - if ($this->db->affected_rows($resql)) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account"); - if ( $this->update() ) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank ("; - $sql.= "datec"; - $sql.= ", label"; - $sql.= ", amount"; - $sql.= ", fk_account"; - $sql.= ", datev"; - $sql.= ", dateo"; - $sql.= ", fk_type"; - $sql.= ", rappro"; - $sql.= ") VALUES ("; - $sql.= $this->db->idate($now); - $sql.= ", '(".$langs->trans("InitialBankBalance").")'"; - $sql.= ", ".price2num($this->solde); - $sql.= ", '".$this->id."'"; - $sql.= ", '".$this->db->idate($this->date_solde)."'"; - $sql.= ", '".$this->db->idate($this->date_solde)."'"; - $sql.= ", 'SOLD'"; - $sql.= ", 0"; // Not conciliated by default - $sql.= ")"; + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account"); - $this->db->query($sql); + $result=$this->update(); + if ($result > 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank ("; + $sql.= "datec"; + $sql.= ", label"; + $sql.= ", amount"; + $sql.= ", fk_account"; + $sql.= ", datev"; + $sql.= ", dateo"; + $sql.= ", fk_type"; + $sql.= ", rappro"; + $sql.= ") VALUES ("; + $sql.= "'".$this->db->idate($now)."'"; + $sql.= ", '(".$langs->trans("InitialBankBalance").")'"; + $sql.= ", ".price2num($this->solde); + $sql.= ", '".$this->id."'"; + $sql.= ", '".$this->db->idate($this->date_solde)."'"; + $sql.= ", '".$this->db->idate($this->date_solde)."'"; + $sql.= ", 'SOLD'"; + $sql.= ", 0"; // Not conciliated by default + $sql.= ")"; + + $resql=$this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + dol_syslog($this->error, LOG_ERR); + return -3; } - return $this->id; } + return $this->id; } else { @@ -455,26 +468,30 @@ class Account extends CommonObject /** * Update bank account card * - * @param user Object user making action - * @return int <0 si ko, >0 si ok + * @param User $user Object user making action + * @return int <0 si ko, >0 si ok */ function update($user='') { global $langs,$conf; - // Check parameters + // Clean parameters if (! $this->min_allowed) $this->min_allowed=0; if (! $this->min_desired) $this->min_desired=0; - if (empty($this->fk_pays)) + $this->state_id = ($this->state_id?$this->state_id:$this->fk_departement); + $this->country_id = ($this->country_id?$this->country_id:$this->fk_pays); + + // Check parameters + if (empty($this->country_id)) { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Country")); - dol_syslog("Account::update ".$this->error, LOG_ERR); + $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Country")); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } if (empty($this->ref)) { - $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); - dol_syslog("Account::update ".$this->error, LOG_ERR); + $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } if (! $this->label) $this->label = "???"; @@ -496,13 +513,13 @@ class Account extends CommonObject $sql.= ",min_desired = '".price2num($this->min_desired)."'"; $sql.= ",comment = '".$this->db->escape($this->comment)."'"; - $sql.= ",fk_departement = ".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); - $sql.= ",fk_pays = ".$this->fk_pays; + $sql.= ",fk_departement = ".($this->state_id>0?"'".$this->state_id."'":"null"); + $sql.= ",fk_pays = ".$this->country_id; $sql.= " WHERE rowid = ".$this->id; $sql.= " AND entity = ".$conf->entity; - dol_syslog("Account::update sql=".$sql); + dol_syslog(get_class($this)."::update sql=".$sql); $result = $this->db->query($sql); if ($result) { @@ -520,22 +537,26 @@ class Account extends CommonObject /** * Update BBAN (RIB) account fields * - * @param user Object user making update - * @return int <0 if KO, >0 if OK + * @param User $user Object user making update + * @return int <0 if KO, >0 if OK */ function update_bban($user='') { global $conf,$langs; + // Clean parameters + $this->state_id = ($this->state_id?$this->state_id:$this->fk_departement); + $this->country_id = ($this->country_id?$this->country_id:$this->fk_pays); + // Chargement librairie pour acces fonction controle RIB require_once(DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'); - dol_syslog("Account::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban"); + dol_syslog(get_class($this)."::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban"); // Check parameters if (! $this->ref) { - $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref")); + $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->trans("Ref")); return -2; } @@ -550,12 +571,12 @@ class Account extends CommonObject $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql.= ",adresse_proprio = '".$this->db->escape($this->adresse_proprio)."'"; - $sql.= ",fk_departement = ".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); - $sql.= ",fk_pays = ".$this->fk_pays; + $sql.= ",fk_departement = ".($this->state_id>0?"'".$this->state_id."'":"null"); + $sql.= ",fk_pays = ".$this->country_id; $sql.= " WHERE rowid = ".$this->id; $sql.= " AND entity = ".$conf->entity; - dol_syslog("Account::update_bban sql=$sql"); + dol_syslog(get_class($this)."::update_bban sql=$sql"); $result = $this->db->query($sql); if ($result) @@ -574,9 +595,10 @@ class Account extends CommonObject /** * Load a bank account into memory from database * - * @param id Id of bank account to get - * @param ref Ref of bank account to get - * @param ref_ext External ref of bank account to get + * @param int $id Id of bank account to get + * @param string $ref Ref of bank account to get + * @param string $ref_ext External ref of bank account to get + * @return int <0 if KO, >0 if OK */ function fetch($id,$ref='',$ref_ext='') { @@ -602,7 +624,7 @@ class Account extends CommonObject if ($id) $sql.= " AND ba.rowid = ".$id; if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'"; - dol_syslog("Account::fetch sql=".$sql); + dol_syslog(get_class($this)."::fetch sql=".$sql); $result = $this->db->query($sql); if ($result) { @@ -697,8 +719,8 @@ class Account extends CommonObject /** * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) * - * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * @return string Libelle + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @return string Libelle */ function getLibStatut($mode=0) { @@ -706,10 +728,11 @@ class Account extends CommonObject } /** - * Renvoi le libelle d'un statut donne - * @param statut Id statut - * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut */ function LibStatut($statut,$mode=0) { @@ -751,6 +774,7 @@ class Account extends CommonObject /** * Renvoi si un compte peut etre supprimer ou non (sans mouvements) + * * @return boolean vrai si peut etre supprime, faux sinon */ function can_be_deleted() @@ -775,6 +799,8 @@ class Account extends CommonObject /** * Return error + * + * @return string Error string */ function error() { @@ -856,9 +882,10 @@ class Account extends CommonObject /** * Renvoie nom clicable (avec eventuellement le picto) - * @param withpicto Inclut le picto dans le lien - * @param mode ''=Link to card, 'transactions'=Link to transactions card - * @return string Chaine avec URL + * + * @param int $withpicto Inclut le picto dans le lien + * @param string $mode ''=Link to card, 'transactions'=Link to transactions card + * @return string Chaine avec URL */ function getNomUrl($withpicto=0, $mode='') { @@ -888,6 +915,7 @@ class Account extends CommonObject /** * Return if an account has valid information + * * @return int 1 if correct, <=0 if wrong */ function verif() @@ -913,7 +941,8 @@ class Account extends CommonObject /** * Return account country code - * @return String country code + * + * @return string country code */ function getCountryCode() { @@ -948,6 +977,7 @@ class Account extends CommonObject /** * Return if a bank account is defined with detailed information (bank code, desk code, number and key) + * * @return int 0=Use only an account number * 1=Need Bank, Desk, Number and Key (France, Spain, ...) * 2=Neek Bank only (BSB for Australia) @@ -970,6 +1000,8 @@ class Account extends CommonObject */ function initAsSpecimen() { + $this->ref = 'MBA'; + $this->label = 'My Bank account'; $this->bank = 'MyBank'; $this->courant = 1; $this->clos = 0; @@ -983,14 +1015,14 @@ class Account extends CommonObject $this->domiciliation = 'The bank addresse'; $this->proprio = 'Owner'; $this->adresse_proprio = 'Owner address'; + $this->country_id = 1; } } /** - * \class AccountLine - * \brief Class to manage bank transaction lines + * Class to manage bank transaction lines */ class AccountLine extends CommonObject { @@ -1032,10 +1064,11 @@ class AccountLine extends CommonObject /** * Load into memory content of a bank transaction line - * @param rowid Id of bank transaction to load - * @param ref Ref of bank transaction to load - * @param num External num to load (ex: num of transaction for paypal fee) - * @return int <0 if KO, >0 if OK + * + * @param int $rowid Id of bank transaction to load + * @param string $ref Ref of bank transaction to load + * @param string $num External num to load (ex: num of transaction for paypal fee) + * @return int <0 if KO, >0 if OK */ function fetch($rowid,$ref='',$num='') { @@ -1058,7 +1091,7 @@ class AccountLine extends CommonObject else if ($ref) $sql.= " AND b.rowid='".$ref."'"; else $sql.= " AND b.rowid=".$rowid; - dol_syslog("AccountLine::fetch sql=".$sql); + dol_syslog(get_class($this)."::fetch sql=".$sql); $result = $this->db->query($sql); if ($result) { @@ -1104,8 +1137,8 @@ class AccountLine extends CommonObject /** * Delete transaction bank line record * - * @param user User object that delete - * @return int <0 if KO, >0 if OK + * @param User $user User object that delete + * @return int <0 if KO, >0 if OK */ function delete($user=0) { @@ -1128,12 +1161,12 @@ class AccountLine extends CommonObject } $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid; - dol_syslog("AccountLine::delete sql=".$sql); + dol_syslog(get_class($this)."::delete sql=".$sql); $result = $this->db->query($sql); if (! $result) $nbko++; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$this->rowid; - dol_syslog("AccountLine::delete sql=".$sql); + dol_syslog(get_class($this)."::delete sql=".$sql); $result = $this->db->query($sql); if (! $result) $nbko++; @@ -1153,8 +1186,8 @@ class AccountLine extends CommonObject /** * Delete bank line records * - * @param user User object that delete - * @return int <0 if KO, >0 if OK + * @param User $user User object that delete + * @return int <0 if KO, >0 if OK */ function delete_urls($user=0) { @@ -1170,7 +1203,7 @@ class AccountLine extends CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$this->rowid; - dol_syslog("AccountLine::delete_urls sql=".$sql); + dol_syslog(get_class($this)."::delete_urls sql=".$sql); $result = $this->db->query($sql); if (! $result) $nbko++; @@ -1190,9 +1223,9 @@ class AccountLine extends CommonObject /** * Update bank account record in database * - * @param user Object user making update - * @param notrigger 0=Disable all triggers - * @return int <0 if KO, >0 if OK + * @param User $user Object user making update + * @param int $notrigger 0=Disable all triggers + * @return int <0 if KO, >0 if OK */ function update($user,$notrigger=0) { @@ -1204,7 +1237,7 @@ class AccountLine extends CommonObject $sql.= " dateo='".$this->db->idate($this->dateo)."'"; $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog("AccountLine::update sql=".$sql); + dol_syslog(get_class($this)."::update sql=".$sql); $resql = $this->db->query($sql); if ($resql) { @@ -1215,7 +1248,7 @@ class AccountLine extends CommonObject { $this->db->rollback(); $this->error=$this->db->error(); - dol_syslog("AccountLine::update ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } } @@ -1224,9 +1257,9 @@ class AccountLine extends CommonObject /** * Update conciliation field * - * @param user Objet user making update - * @param cat Category id - * @return int <0 if KO, >0 if OK + * @param User $user Objet user making update + * @param int $cat Category id + * @return int <0 if KO, >0 if OK */ function update_conciliation($user,$cat) { @@ -1238,7 +1271,7 @@ class AccountLine extends CommonObject $sql.= ", fk_user_rappro = ".$user->id; $sql.= " WHERE rowid = ".$this->id; - dol_syslog("AccountLine::update_conciliation sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::update_conciliation sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1252,7 +1285,7 @@ class AccountLine extends CommonObject $sql.= ", ".$cat; $sql.= ")"; - dol_syslog("AccountLine::update_conciliation sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::update_conciliation sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); // No error check. Can fail if category already affected @@ -1274,8 +1307,8 @@ class AccountLine extends CommonObject /** * Increase/decrease value date of a rowid * - * @param int $rowid - * @param int sign 1 or -1 + * @param int $rowid Id of line + * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ function datev_change($rowid,$sign=1) @@ -1335,7 +1368,8 @@ class AccountLine extends CommonObject /** * Charge les informations d'ordre info dans l'objet * - * @param rowid Id of object + * @param int $rowid Id of object + * @return void */ function info($rowid) { @@ -1380,10 +1414,10 @@ class AccountLine extends CommonObject /** * Renvoie nom clicable (avec eventuellement le picto) * - * @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - * @param maxlen Longueur max libelle - * @param option Option ('showall') - * @return string Chaine avec URL + * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * @param int $maxlen Longueur max libelle + * @param string $option Option ('showall') + * @return string Chaine avec URL */ function getNomUrl($withpicto=0,$maxlen=0,$option='') { diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 061d7055637..4bcc156c417 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -58,9 +58,9 @@ class BankCateg // extends CommonObject /** * Create in database * - * @param user User that create - * @param notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK */ function create($user, $notrigger=0) { @@ -126,9 +126,10 @@ class BankCateg // extends CommonObject /** - * \brief Load object in memory from database - * \param id id object - * \return int <0 if KO, >0 if OK + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK */ function fetch($id) { @@ -166,10 +167,11 @@ class BankCateg // extends CommonObject /** - * \brief Update database - * \param user User that modify - * \param notrigger 0=launch triggers after, 1=disable triggers - * \return int <0 if KO, >0 if OK + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK */ function update($user=0, $notrigger=0) { @@ -230,10 +232,11 @@ class BankCateg // extends CommonObject /** - * \brief Delete object in database - * \param user User that delete - * \param notrigger 0=launch triggers after, 1=disable triggers - * \return int <0 if KO, >0 if OK + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK */ function delete($user, $notrigger=0) { @@ -287,9 +290,10 @@ class BankCateg // extends CommonObject /** - * \brief Load an object from its id and create a new one in database - * \param fromid Id of object to clone - * \return int New id of clone + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * @return int New id of clone */ function createFromClone($fromid) { diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index f61d78641bb..90f4c73dddf 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -508,7 +508,7 @@ else // Type print ''; print ''; // Currency diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 0d924bbc0d5..f32d0c615f0 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -229,7 +229,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // Sort array if (! $error) { - array_multisort ($tab_sqlobjOrder,$tab_sqlobj); + array_multisort($tab_sqlobjOrder,$tab_sqlobj); //Apply distinct filter foreach ($tab_sqlobj as $key=>$value) { diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php index 6b5771a2bec..20c5acab754 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/virement.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copytight (C) 2005-2009 Regis Houssin + * Copytight (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,18 +32,20 @@ $langs->load("banks"); if (! $user->rights->banque->transfer) accessforbidden(); +$action = GETPOST('action','alpha'); + /* * Action ajout d'un virement */ -if ($_POST["action"] == 'add') +if ($action == 'add') { $langs->load("errors"); $mesg=''; - $dateo = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); - $label = $_POST["label"]; - $amount= $_POST["amount"]; + $dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); + $label = GETPOST('label','alpha'); + $amount= GETPOST('amount','int'); if (! $label) { @@ -54,12 +57,12 @@ if ($_POST["action"] == 'add') $error=1; $mesg.="
".$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"))."
"; } - if (! $_POST['account_from']) + if (! GETPOST('account_from','int')) { $error=1; $mesg.="
".$langs->trans("ErrorFieldRequired",$langs->transnoentities("TransferFrom"))."
"; } - if (! $_POST['account_to']) + if (! GETPOST('account_to','int')) { $error=1; $mesg.="
".$langs->trans("ErrorFieldRequired",$langs->transnoentities("TransferTo"))."
"; @@ -69,10 +72,10 @@ if ($_POST["action"] == 'add') require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'); $accountfrom=new Account($db); - $accountfrom->fetch($_POST["account_from"]); + $accountfrom->fetch(GETPOST('account_from','int')); $accountto=new Account($db); - $accountto->fetch($_POST["account_to"]); + $accountto->fetch(GETPOST('account_to','int')); if ($accountto->id != $accountfrom->id) { @@ -133,6 +136,18 @@ llxHeader(); $form=new Form($db); +$account_from=''; +$account_to=''; +$label=''; +$amount=''; + +if($error) +{ + $account_from = GETPOST('account_from','int'); + $account_to = GETPOST('account_to','int'); + $label = GETPOST('label','alpha'); + $amount = GETPOST('amount','int'); +} print_fiche_titre($langs->trans("BankTransfer")); @@ -153,18 +168,18 @@ print ''; $var=false; print '
"; print "\n"; print "\n"; -print ''; -print ''; +print ''; +print ''; print "
trans("Ref"); ?> trans("Date"); ?>
'.$langs->trans("AccountType").''; - print $form->select_type_comptes_financiers((isset($_POST["type"])?$_POST["type"]:$account->type),"type"); + print $formbank->select_type_comptes_financiers((isset($_POST["type"])?$_POST["type"]:$account->type),"type"); print '
'; -print $form->select_comptes($_POST['account_from'],'account_from',0,'',1); +print $form->select_comptes($account_from,'account_from',0,'',1); print "\n"; -print $form->select_comptes($_POST['account_to'],'account_to',0,'',1); +print $form->select_comptes($account_to,'account_to',0,'',1); print ""; $form->select_date($dateo,'','','','','add'); print "
"; diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index eb3292da8f1..c6a41159583 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -64,13 +64,6 @@ llxHeader(); $thirdpartystatic=new Societe($db); -if ($action == 'attribute_prefix') -{ - $societe = new Societe($db); - $societe->fetch($socid); - $societe->attribute_prefix($db, $socid); -} - if ($action == 'note') { $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$note."' WHERE rowid=".$socid; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 93035ad912a..8b24f22f2cd 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,6 +50,7 @@ class Deplacement extends CommonObject var $socid; var $statut; // 0=draft, 1=validated var $fk_project; + var $extraparams=array(); /** * Constructor @@ -209,7 +210,7 @@ class Deplacement extends CommonObject */ function fetch($id) { - $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note, note_public, fk_projet"; + $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note, note_public, fk_projet, extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement"; $sql.= " WHERE rowid = ".$id; @@ -230,6 +231,8 @@ class Deplacement extends CommonObject $this->note_private = $obj->note; $this->note_public = $obj->note_public; $this->fk_project = $obj->fk_projet; + + $this->extraparams = (array) json_decode($obj->extraparams, true); return 1; } diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 9ad9791293c..68a8608fd09 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -108,9 +108,10 @@ class DeplacementStats extends Stats /** - * \brief Renvoie le montant de facture par mois pour une annee donnee - * \param year Year to scan - * \return array Array of values + * Renvoie le montant de facture par mois pour une annee donnee + * + * @param int $year Year to scan + * @return array Array of values */ function getAmountByMonth($year) { @@ -127,9 +128,10 @@ class DeplacementStats extends Stats } /** - * \brief Return average amount - * \param year Year to scan - * \return array Array of values + * Return average amount + * + * @param int $year Year to scan + * @return array Array of values */ function getAverageByMonth($year) { @@ -144,8 +146,9 @@ class DeplacementStats extends Stats } /** - * \brief Return nb, total and average - * \return array Array of values + * Return nb, total and average + * + * @return array Array of values */ function getAllByYear() { diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 66680ef089d..95ed1c35a4e 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -1,18 +1,18 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin - * + * Copyright (C) 2005-2012 Regis Houssin + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 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 . */ @@ -70,7 +70,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) } /* -if ($action == 'unblock' && $user->rights->deplacement->unvalidate) +else if ($action == 'unblock' && $user->rights->deplacement->unvalidate) { $object->fetch($id); if ($object->fk_statut == '1') // Not blocked... @@ -99,7 +99,7 @@ if ($action == 'unblock' && $user->rights->deplacement->unvalidate) } }*/ -if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) +else if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) { $result=$object->delete($id); if ($result >= 0) @@ -113,7 +113,7 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplaceme } } -if ($action == 'add' && $user->rights->deplacement->creer) +else if ($action == 'add' && $user->rights->deplacement->creer) { if (! $_POST["cancel"]) { @@ -172,13 +172,13 @@ if ($action == 'add' && $user->rights->deplacement->creer) } // Update record -if ($action == 'update' && $user->rights->deplacement->creer) +else if ($action == 'update' && $user->rights->deplacement->creer) { if (empty($_POST["cancel"])) { $result = $object->fetch($id); - $object->date = dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $object->date = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $object->km = $_POST["km"]; $object->type = $_POST["type"]; $object->fk_user = $_POST["fk_user"]; @@ -206,7 +206,7 @@ if ($action == 'update' && $user->rights->deplacement->creer) } // Set into a project -if ($action == 'classin') +else if ($action == 'classin' && $user->rights->deplacement->creer) { $object->fetch($id); $result=$object->setProject($_POST['projectid']); @@ -214,26 +214,26 @@ if ($action == 'classin') } // Set fields -if ($action == 'setdated') +else if ($action == 'setdated' && $user->rights->deplacement->creer) { $dated=dol_mktime($_POST['datedhour'], $_POST['datedmin'], $_POST['datedsec'], $_POST['datedmonth'], $_POST['datedday'], $_POST['datedyear']); $object->fetch($id); $result=$object->setValueFrom('dated',$dated,'','','date'); if ($result < 0) dol_print_error($db, $object->error); } -if ($action == 'setkm') +else if ($action == 'setkm' && $user->rights->deplacement->creer) { $object->fetch($id); $result=$object->setValueFrom('km',GETPOST('km')); if ($result < 0) dol_print_error($db, $object->error); } -if ($action == 'setnote_public') +else if ($action == 'setnote_public' && $user->rights->deplacement->creer) { $object->fetch($id); $result=$object->setValueFrom('note_public',GETPOST('note_public')); if ($result < 0) dol_print_error($db, $object->error); } -if ($action == 'setnote') +else if ($action == 'setnote' && $user->rights->deplacement->creer) { $object->fetch($id); $result=$object->setValueFrom('note',GETPOST('note')); @@ -424,7 +424,7 @@ else if ($id) print ''; // Ref - print ''; @@ -495,24 +495,12 @@ else if ($id) // Statut print ''; - // Public note - print '"; + print "
'.$langs->trans("Ref").''; + print '
'.$langs->trans("Ref").''; print $form->showrefnav($object,'id','',1,'rowid','ref',''); print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'; - print $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); - print ''; - print $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); - print "

"; - // Private note - if (! $user->societe_id) - { - print ''; - print $form->editfieldkey("NotePrivate",'note',$object->note_private,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); - print ''; - print $form->editfieldval("NotePrivate",'note',$object->note_private,$object,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); - print ""; - } - - print ""; + // Notes + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); print ''; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index cc3d4542316..881fb54cbc0 100755 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -75,7 +75,7 @@ if (trim($search_ref) != '') $sql.= ' AND d.rowid LIKE \'%'.$db->escape(trim($search_ref)) . '%\''; } $sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit + 1 ,$offset); +$sql.= $db->plimit($limit + 1, $offset); //print $sql; $resql=$db->query($sql); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 1de845e0041..8d9e9305d16 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -38,8 +38,12 @@ require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); +if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); +if ($conf->projet->enabled) +{ + require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); + require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); +} $langs->load('bills'); //print 'ee'.$langs->trans('BillsCustomer');exit; @@ -91,7 +95,7 @@ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks // Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') +if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) { if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { @@ -117,7 +121,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') } // Change status of invoice -if ($action == 'reopen' && $user->rights->facture->creer) +else if ($action == 'reopen' && $user->rights->facture->creer) { $result = $object->fetch($id); if ($object->statut == 2 @@ -137,77 +141,68 @@ if ($action == 'reopen' && $user->rights->facture->creer) } // Delete invoice -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) +else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) { - if ($user->rights->facture->supprimer) - { - $result = $object->fetch($id); - $result = $object->delete(); - if ($result > 0) - { - Header('Location: '.$_SERVER["PHP_SELF"]); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - } - } + $result = $object->fetch($id); + $result = $object->delete(); + if ($result > 0) + { + Header('Location: '.$_SERVER["PHP_SELF"]); + exit; + } + else + { + $mesg='
'.$object->error.'
'; + } } // Delete line -if ($action == 'confirm_deleteline' && $confirm == 'yes') +else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { - if ($user->rights->facture->creer) - { - $object->fetch($id); - $object->fetch_thirdparty(); - - $result = $object->deleteline($_GET['lineid'], $user); - if ($result > 0) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($id); // Reload to get new records - $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); - } - if ($result >= 0) - { - Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); - exit; - } - } - else - { - $mesg='
'.$object->error.'
'; - $action=''; - } - } + $object->fetch($id); + $object->fetch_thirdparty(); + + $result = $object->deleteline($_GET['lineid'], $user); + if ($result > 0) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($id); // Reload to get new records + $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); + } + if ($result >= 0) + { + Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); + exit; + } + } + else + { + $mesg='
'.$object->error.'
'; + $action=''; + } } // Delete link of credit note to invoice -if ($action == 'unlinkdiscount') +else if ($action == 'unlinkdiscount' && $user->rights->facture->creer) { - if ($user->rights->facture->creer) - { - $discount=new DiscountAbsolute($db); - $result=$discount->fetch($_GET["discountid"]); - $discount->unlink_invoice(); - } + $discount=new DiscountAbsolute($db); + $result=$discount->fetch($_GET["discountid"]); + $discount->unlink_invoice(); } // Validation -if ($action == 'valid') +else if ($action == 'valid' && $user->rights->facture->creer) { $object->fetch($id); @@ -224,7 +219,7 @@ if ($action == 'valid') else { // Si non avoir, le signe doit etre positif - if ($object->total_ht < 0) + if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) { $mesg='
'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'
'; $action=''; @@ -232,7 +227,7 @@ if ($action == 'valid') } } -if ($action == 'set_thirdparty') +else if ($action == 'set_thirdparty' && $user->rights->facture->creer) { $object->fetch($id); $object->setValueFrom('fk_soc',$socid); @@ -241,20 +236,20 @@ if ($action == 'set_thirdparty') exit; } -if ($action == 'classin') +else if ($action == 'classin' && $user->rights->facture->creer) { $object->fetch($id); $object->setProject($_POST['projectid']); } -if ($action == 'setmode') +else if ($action == 'setmode' && $user->rights->facture->creer) { $object->fetch($id); - $result=$object->mode_reglement($_POST['mode_reglement_id']); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setinvoicedate') +else if ($action == 'setinvoicedate' && $user->rights->facture->creer) { $object->fetch($id); $object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']); @@ -263,28 +258,20 @@ if ($action == 'setinvoicedate') if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setpaymentterm') +else if ($action == 'setconditions' && $user->rights->facture->creer) { $object->fetch($id); - $date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']); - $result=$object->cond_reglement($object->cond_reglement_id,$date_lim_reglement); + $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); if ($result < 0) dol_print_error($db,$object->error); } -if ($action == 'setconditions') -{ - $object->fetch($id); - $result=$object->cond_reglement($_POST['cond_reglement_id']); - if ($result < 0) dol_print_error($db,$object->error); -} - -if ($action == 'setremisepercent' && $user->rights->facture->creer) +else if ($action == 'setremisepercent' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->set_remise($user, $_POST['remise_percent']); } -if ($action == "setabsolutediscount" && $user->rights->facture->creer) +else if ($action == "setabsolutediscount" && $user->rights->facture->creer) { // POST[remise_id] ou POST[remise_id_for_payment] if (! empty($_POST["remise_id"])) @@ -317,14 +304,28 @@ if ($action == "setabsolutediscount" && $user->rights->facture->creer) } } -if ($action == 'set_ref_client') +else if ($action == 'set_ref_client' && $user->rights->facture->creer) { $object->fetch($id); $object->set_ref_client($_POST['ref_client']); } +else if ($action == 'setnote_public' && $user->rights->facture->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->facture->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + // Classify to validated -if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) +else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) { $idwarehouse=GETPOST('idwarehouse'); @@ -371,7 +372,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v } // Go back to draft status (unvalidate) -if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) +else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) { $idwarehouse=GETPOST('idwarehouse'); @@ -444,13 +445,13 @@ if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS } // Classify "paid" -if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) +else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) { $object->fetch($id); $result = $object->set_paid($user); } // Classif "paid partialy" -if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) +else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) { $object->fetch($id); $close_code=$_POST["close_code"]; @@ -465,7 +466,7 @@ if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->f } } // Classify "abandoned" -if ($action == 'confirm_canceled' && $confirm == 'yes') +else if ($action == 'confirm_canceled' && $confirm == 'yes') { $object->fetch($id); $close_code=$_POST["close_code"]; @@ -481,7 +482,7 @@ if ($action == 'confirm_canceled' && $confirm == 'yes') } // Convertir en reduc -if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) +else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) { $db->begin(); @@ -556,7 +557,7 @@ if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->f /* * Insert new invoice in database */ -if ($action == 'add' && $user->rights->facture->creer) +else if ($action == 'add' && $user->rights->facture->creer) { $object->socid=GETPOST('socid','int'); @@ -739,10 +740,11 @@ if ($action == 'add' && $user->rights->facture->creer) if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { $element = $subelement = 'contrat'; } if ($element == 'inter') { $element = $subelement = 'ficheinter'; } + if ($element == 'shipping') {$element = $subelement = 'expedition'; } $object->origin = $_POST['origin']; $object->origin_id = $_POST['originid']; - + // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) @@ -916,7 +918,7 @@ if ($action == 'add' && $user->rights->facture->creer) } // Add a new line -if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer) +else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer) { $result=0; @@ -1124,7 +1126,7 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact $action=''; } -if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save')) +else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save')) { if (! $object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); @@ -1212,15 +1214,14 @@ if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] } } -if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) +else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // Pour reaffichage de la fiche en cours d'edition exit; } - // Modify line position (up) -if ($action == 'up' && $user->rights->facture->creer) +else if ($action == 'up' && $user->rights->facture->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -1242,7 +1243,7 @@ if ($action == 'up' && $user->rights->facture->creer) exit; } // Modify line position (down) -if ($action == 'down' && $user->rights->facture->creer) +else if ($action == 'down' && $user->rights->facture->creer) { $object->fetch($id); $object->fetch_thirdparty(); @@ -1311,11 +1312,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($result > 0) { - $ref = dol_sanitizeFileName($object->ref); - $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; +// $ref = dol_sanitizeFileName($object->ref); +// $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - if (is_readable($file)) - { +// if (is_readable($file)) +// { if ($_POST['sendto']) { // Le destinataire a ete fourni via le champ libre @@ -1444,13 +1445,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $mesg.=''; } } - } +/* } else { $langs->load("other"); $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; dol_syslog('Recipient email is empty'); - } + }*/ } else { @@ -1472,7 +1473,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO /* * Generate document */ -if (GETPOST('action') == 'builddoc') // En get ou en post +else if ($action == 'builddoc') // En get ou en post { $object->fetch($id); $object->fetch_thirdparty(); @@ -1505,6 +1506,66 @@ if (GETPOST('action') == 'builddoc') // En get ou en post } } +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +{ + if ($action == 'addcontact' && $user->rights->facture->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->facture->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->facture->creer) + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } + } +} /* @@ -2093,8 +2154,11 @@ else //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); } - - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,"yes",($conf->notification->enabled?0:2)); + if ($object->type != 2 && $object->total_ttc < 0) // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on + { + $text.='
'.img_warning().' '.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive"); + } + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,(($object->type != 2 && $object->total_ttc < 0)?"no":"yes"),($conf->notification->enabled?0:2)); } // Confirm back to draft status @@ -2349,7 +2413,7 @@ else if ($absolute_creditnote > 0) // If not, link will be added later { if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.')
'; - else print '.'; + else print '. '; } else print '. '; } @@ -2372,7 +2436,8 @@ else { // Remise dispo de type avoir if (! $absolute_discount) print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer); + //$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer); + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0); // We must allow credit not even if amount is higher } } if (! $absolute_discount && ! $absolute_creditnote) @@ -2733,6 +2798,23 @@ else print '
'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } /* * Lines @@ -2826,14 +2908,13 @@ else // Validate if ($object->statut == 0 && count($object->lines) > 0 && ( - (($object->type == 0 || $object->type == 1 || $object->type == 3 || $object->type == 4) && $object->total_ttc >= 0) + (($object->type == 0 || $object->type == 1 || $object->type == 3 || $object->type == 4) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == 2 && $object->total_ttc <= 0)) ) { if ($user->rights->facture->valider) { - print ''.$langs->trans('Validate').''; + print ''.$langs->trans('Validate').''; } } @@ -3049,10 +3130,12 @@ else } $ref = dol_sanitizeFileName($object->ref); - $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; + include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); + $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref); + $file=$fileparams['fullname']; - // Construit PDF si non existant - if (! is_readable($file)) + // Build document if it not exists + if (! $file || ! is_readable($file)) { // Define output language $outputlangs = $langs; @@ -3064,12 +3147,15 @@ else $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=facture_pdf_create($db, $object, $_REQUEST['model'], $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); + + $result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager); if ($result <= 0) { dol_print_error($db,$result); exit; } + $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref); + $file=$fileparams['fullname']; } print '
'; @@ -3096,6 +3182,8 @@ else $formmail->withcancel=1; // Tableau des substitutions $formmail->substit['__FACREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=''; + $formmail->substit['__PERSONALIZED__']=''; // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; @@ -3103,10 +3191,10 @@ else $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; // Init list of files - if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + if (GETPOST("mode")=='init') { $formmail->clear_attached_files(); - $formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf'); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); } $formmail->show_form(); @@ -3379,7 +3467,7 @@ else } } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b2e2db358bb..4573728299d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -72,7 +72,8 @@ class Facture extends CommonObject var $total_ht=0; var $total_tva=0; var $total_ttc=0; - var $note; + var $note; // deprecated + var $note_private; var $note_public; //! 0=draft, //! 1=validated (need to be paid), @@ -101,6 +102,7 @@ class Facture extends CommonObject var $products=array(); // deprecated var $lines=array(); var $line; + var $extraparams=array(); //! Pour board var $nbtodo; var $nbtodolate; @@ -134,7 +136,8 @@ class Facture extends CommonObject // Clean parameters if (empty($this->type)) $this->type = 0; $this->ref_client=trim($this->ref_client); - $this->note=trim($this->note); + $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); $this->note_public=trim($this->note_public); if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; @@ -217,7 +220,7 @@ class Facture extends CommonObject $sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL'); $sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL'); $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ",".($this->note?"'".$this->db->escape($this->note)."'":"null"); + $sql.= ",".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ",".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ",".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); $sql.= ",".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); @@ -253,6 +256,32 @@ class Facture extends CommonObject dol_print_error($this->db); $error++; } + + // TODO mutualiser + if ($origin == 'commande') + { + // On recupere les differents contact interne et externe + $order = new Commande($this->db); + $order->id = $origin_id; + + // On recupere le commercial suivi propale + $this->userid = $order->getIdcontact('internal', 'SALESREPFOLL'); + + if ($this->userid) + { + //On passe le commercial suivi commande en commercial suivi paiement + $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal'); + } + + // On recupere le contact client facturation commande + $this->contactid = $order->getIdcontact('external', 'BILLING'); + + if ($this->contactid) + { + //On passe le contact client facturation commande en contact client facturation + $this->add_contact($this->contactid[0], 'BILLING', 'external'); + } + } } } @@ -643,8 +672,15 @@ class Facture extends CommonObject $this->note = $object->note; $this->note_public = $object->note_public; - $this->origin = $object->element; - $this->origin_id = $object->id; + $this->origin = $object->element; + $this->origin_id = $object->id; + + // Possibility to add external linked objects with hooks + $this->linked_objects[$this->origin] = $this->origin_id; + if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + { + $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); + } $ret = $this->create($user); @@ -730,9 +766,9 @@ class Facture extends CommonObject $sql.= ', f.datec as datec'; $sql.= ', f.date_valid as datev'; $sql.= ', f.tms as datem'; - $sql.= ', f.note, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf'; + $sql.= ', f.note as note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf'; $sql.= ', f.fk_facture_source'; - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet'; + $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; @@ -785,12 +821,15 @@ class Facture extends CommonObject $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $this->fk_project = $obj->fk_projet; $this->fk_facture_source = $obj->fk_facture_source; - $this->note = $obj->note; + $this->note = $obj->note_private; // deprecated + $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; $this->modelpdf = $obj->model_pdf; + $this->extraparams = (array) json_decode($obj->extraparams, true); + if ($this->statut == 0) $this->brouillon = 1; /* @@ -926,7 +965,8 @@ class Facture extends CommonObject if (isset($this->increment)) $this->increment=trim($this->increment); if (isset($this->close_code)) $this->close_code=trim($this->close_code); if (isset($this->close_note)) $this->close_note=trim($this->close_note); - if (isset($this->note)) $this->note=trim($this->note); + if (isset($this->note) || isset($this->note_private)) $this->note=(isset($this->note) ? trim($this->note) : trim($this->note_private)); // deprecated + if (isset($this->note) || isset($this->note_private)) $this->note_private=(isset($this->note_private) ? trim($this->note_private) : trim($this->note)); if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf); if (isset($this->import_key)) $this->import_key=trim($this->import_key); @@ -964,7 +1004,7 @@ class Facture extends CommonObject $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").","; $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").","; $sql.= " date_lim_reglement=".(strval($this->date_lim_reglement)!='' ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'null').","; - $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; + $sql.= " note=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").""; @@ -2660,91 +2700,6 @@ class Facture extends CommonObject } } - /** - * Change les conditions de reglement de la facture - * - * @param int $cond_reglement_id Id de la nouvelle condition de reglement - * @param date $date Date to force payment term - * @return int >0 si ok, <0 si ko - */ - function cond_reglement($cond_reglement_id,$date='') - { - if ($this->statut >= 0 && $this->paye == 0) - { - // Define cond_reglement_id and datelim - if (strval($date) != '') - { - $datelim=$date; - $cond_reglement_id=0; - } - else - { - $datelim=$this->calculate_date_lim_reglement($cond_reglement_id); - $cond_reglement_id=$cond_reglement_id; - } - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET fk_cond_reglement = '.$cond_reglement_id.','; - $sql.= ' date_lim_reglement='.$this->db->idate($datelim); - $sql.= ' WHERE rowid='.$this->id; - - dol_syslog(get_class($this)."::cond_reglement sql=".$sql, LOG_DEBUG); - if ( $this->db->query($sql) ) - { - $this->cond_reglement_id = $cond_reglement_id; - return 1; - } - else - { - dol_syslog(get_class($this)."::cond_reglement Erreur ".$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); - return -1; - } - } - else - { - dol_syslog(get_class($this)."::cond_reglement, etat facture incompatible"); - $this->error='Entity status not compatible '.$this->statut.' '.$this->paye; - return -2; - } - } - - - /** - * Change le mode de reglement - * - * @param int $mode_reglement_id Id du nouveau mode - * @return int >0 if OK, <0 if KO - */ - function mode_reglement($mode_reglement_id) - { - dol_syslog(get_class($this).'::mode_reglement('.$mode_reglement_id.')', LOG_DEBUG); - if ($this->statut >= 0 && $this->paye == 0) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql .= ' SET fk_mode_reglement = '.$mode_reglement_id; - $sql .= ' WHERE rowid='.$this->id; - if ( $this->db->query($sql) ) - { - $this->mode_reglement_id = $mode_reglement_id; - return 1; - } - else - { - dol_syslog(get_class($this).'::mode_reglement Erreur '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); - return -1; - } - } - else - { - dol_syslog(get_class($this).'::mode_reglement, etat facture incompatible'); - $this->error='Etat facture incompatible '.$this->statut.' '.$this->paye; - return -2; - } - } - - /** * Renvoi si les lignes de facture sont ventilees et/ou exportees en compta * @@ -3118,12 +3073,14 @@ class Facture extends CommonObject $this->specimen=1; $this->socid = 1; $this->date = $nownotime; + $this->date_lim_reglement = $nownotime + 3600 * 24 *30; $this->cond_reglement_id = 1; $this->cond_reglement_code = 'RECEP'; $this->date_lim_reglement=$this->calculate_date_lim_reglement(); $this->mode_reglement_id = 7; $this->mode_reglement_code = 'CHQ'; $this->note_public='This is a comment (public)'; + $this->note_private='This is a comment (private)'; $this->note='This is a comment (private)'; if (empty($option) || $option != 'nolines') diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 8e34d0aa48f..d840db56dce 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2009 Destailleur Laurent + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,56 +33,57 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); $langs->load("bills"); $langs->load("companies"); -$facid = GETPOST('facid'); -$id = GETPOST('facid'); -$ref= GETPOST('ref'); +$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility +$ref = GETPOST('ref'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'facture', $facid); +$result = restrictedArea($user, 'facture', $id); + +$object = new Facture($db); /* * Ajout d'un nouveau contact */ -if ($_POST["action"] == 'addcontact' && $user->rights->facture->creer) +if ($action == 'addcontact' && $user->rights->facture->creer) { - $result = 0; - $facture = new Facture($db); - $result = $facture->fetch($facid); + $result = $object->fetch($id); - if ($result > 0 && $facid > 0) + if ($result > 0 && $id > 0) { - $result = $facture->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { - Header("Location: contact.php?facid=".$facture->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($facture->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; } else { - $mesg = '
'.$facture->error.'
'; + $mesg = '
'.$object->error.'
'; } } } // bascule du statut d'un contact -if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer) +else if ($action == 'swapstatut' && $user->rights->facture->creer) { - $facture = new Facture($db); - if ($facture->fetch($facid)) + if ($object->fetch($id)) { - $result=$facture->swapContactStatus(GETPOST('ligne')); + $result=$object->swapContactStatus(GETPOST('ligne')); } else { @@ -90,15 +92,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer) } // Efface un contact -if ($_GET["action"] == 'deleteline' && $user->rights->facture->creer) +else if ($action == 'deletecontact' && $user->rights->facture->creer) { - $facture = new Facture($db); - $facture->fetch($facid); - $result = $facture->delete_contact($_GET["lineid"]); + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); if ($result >= 0) { - Header("Location: contact.php?facid=".$facture->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -128,12 +129,11 @@ dol_htmloutput_mesg($mesg); if ($id > 0 || ! empty($ref)) { - $facture = new Facture($db); - if ($facture->fetch($id, $ref) > 0) + if ($object->fetch($id, $ref) > 0) { - $facture->fetch_thirdparty(); + $object->fetch_thirdparty(); - $head = facture_prepare_head($facture); + $head = facture_prepare_head($object); dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), 0, 'bill'); @@ -147,7 +147,7 @@ if ($id > 0 || ! empty($ref)) print ''; $morehtmlref=''; $discount=new DiscountAbsolute($db); - $result=$discount->fetch(0,$facture->id); + $result=$discount->fetch(0,$object->id); if ($result > 0) { $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')'; @@ -156,198 +156,20 @@ if ($id > 0 || ! empty($ref)) { dol_print_error('',$discount->error); } - print $form->showrefnav($facture,'ref','',1,'facnumber','ref',$morehtmlref); + print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print ''; // Customer print "".$langs->trans("Company").""; - print ''.$facture->client->getNomUrl(1,'compta').''; + print ''.$object->client->getNomUrl(1,'compta').''; print ""; print ''; - - /* - * Lignes de contacts - */ - echo '
'; - - /* - * Ajouter une ligne de contact - * Non affiche en mode modification de ligne - */ - if ($_GET["action"] != 'editline' && $user->rights->facture->creer) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var = false; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to add an internal contact - print ""; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to add an external contact - $var=!$var; - print ""; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ""; - - print ''; - } - - // List of linked contacts - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $companystatic = new Societe($db); - $var = true; - - foreach(array('internal','external') as $source) - { - $tab = $facture->liste_contact(-1,$source); - $num=count($tab); - - $i = 0; - while ($i < $num) - { - $var = !$var; - - print ''; - - // Source - print ''; - - // Third party - print ''; - - // Contact - print ''; - - // Type of contact - print ''; - - // Status - print ''; - - // Icon update et delete - print ''; - - print "\n"; - - $i ++; - } - } - print "
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").' 
'; - print img_object('','user').' '.$langs->trans("Users"); - print ''; - print $mysoc->name; - print ''; - // Ge get ids of alreadey selected users - //$userAlreadySelected = $facture->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $form->select_users($user->id,'contactid',0,$userAlreadySelected); - print ''; - $formcompany->selectTypeContact($facture, '', 'type','internal'); - print '
'; - print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); - print ''; - $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id; - $selectedCompany = $formcompany->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany'); - print ''; - $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); - if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); - print ''; - $formcompany->selectTypeContact($facture, '', 'type','external'); - print '
 
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").''.$langs->trans("Status").' 
'; - if ($tab[$i]['source']=='internal') print $langs->trans("User"); - if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); - print ''; - if ($tab[$i]['socid'] > 0) - { - $companystatic->fetch($tab[$i]['socid']); - print $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - print $mysoc->name; - } - if (! $tab[$i]['socid']) - { - print ' '; - } - print ''; - if ($tab[$i]['source']=='internal') - { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - print $userstatic->getNomUrl(1); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; - print $contactstatic->getNomUrl(1); - } - print ''.$tab[$i]['libelle'].''; - // Activate/Unactivate contact - if ($facture->statut >= 0) print ''; - print $contactstatic->LibStatut($tab[$i]['status'],3); - if ($facture->statut >= 0) print ''; - print ''; - if ($user->rights->facture->creer) - { - print ' '; - print ''; - print img_delete(); - print ''; - } - print '
"; + print '
'; + + // Contacts lines + include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); } else { @@ -356,7 +178,7 @@ if ($id > 0 || ! empty($ref)) } } -$db->close(); llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index ea22971c1bf..80d6bf6ca53 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,64 +28,42 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); -$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:""; - -if (!$user->rights->facture->lire) - accessforbidden(); - $langs->load("companies"); $langs->load("bills"); +$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); + // Security check -if ($user->societe_id > 0) -{ - unset($_GET["action"]); - $socid = $user->societe_id; -} +$socid=0; +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,'facture',$id,''); - -$fac = new Facture($db); -$fac->fetch($_GET["facid"]); +$object = new Facture($db); +$object->fetch($id); /******************************************************************************/ /* Actions */ /******************************************************************************/ -if ($_POST["action"] == 'update_public' && $user->rights->facture->creer) +if ($action == 'setnote_public' && $user->rights->facture->creer) { - $db->begin(); - - $res=$fac->update_note_public($_POST["note_public"],$user); - if ($res < 0) - { - $mesg='
'.$fac->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } -if ($_POST["action"] == 'update' && $user->rights->facture->creer) +else if ($action == 'setnote' && $user->rights->facture->creer) { - $db->begin(); - - $res=$fac->update_note($_POST["note"],$user); - if ($res < 0) - { - $mesg='
'.$fac->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } - /******************************************************************************/ /* Affichage fiche */ /******************************************************************************/ @@ -93,28 +72,26 @@ llxHeader(); $form = new Form($db); -$id = $_GET['facid']; -$ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { - $fac = new Facture($db); - $fac->fetch($id,$ref); + $object = new Facture($db); + $object->fetch($id,$ref); $soc = new Societe($db); - $soc->fetch($fac->socid); + $soc->fetch($object->socid); - $head = facture_prepare_head($fac); + $head = facture_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), 0, 'bill'); print ''; // Ref - print ''; + print ''; print ''; // Company print ''; print ''; - // Note publique - print ''; - print '"; - - // Note priv�e - if (! $user->societe_id) - { - print ''; - print '"; - } - print "
'.$langs->trans('Ref').'
'.$langs->trans('Ref').''; $morehtmlref=''; $discount=new DiscountAbsolute($db); - $result=$discount->fetch(0,$fac->id); + $result=$discount->fetch(0,$object->id); if ($result > 0) { $morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')'; @@ -123,72 +100,24 @@ if ($id > 0 || ! empty($ref)) { dol_print_error('',$discount->error); } - print $form->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref); + print $form->showrefnav($object,'ref','',1,'facnumber','ref',$morehtmlref); print '
'.$langs->trans("Company").''.$soc->getNomUrl(1,'compta').'
'.$langs->trans("NotePublic").' :'; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($fac->note_public?nl2br($fac->note_public):" "); - } - print "
'.$langs->trans("NotePrivate").' :'; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($fac->note?nl2br($fac->note):" "); - } - print "
"; + print '
'; - /* - * Actions - */ - print ''; - print '
'; - - if ($user->rights->facture->creer && $_GET["action"] <> 'edit') - { - print "id&action=edit\">".$langs->trans('Modify').""; - } - - print "
"; - + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + dol_fiche_end(); } -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index a4cd0a7cf30..eeaf57341a0 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -29,7 +29,7 @@ echo '
'; if ($num > 1) print_titre($langs->trans("RelatedBills")); else print_titre($langs->trans("RelatedBill")); ?> - +
diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 97683e912b8..6c1ef48f957 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -64,7 +64,7 @@ class localtax extends CommonObject global $conf, $langs; $error=0; - + // Clean parameters $this->amount=trim($this->amount); $this->label=trim($this->label); @@ -131,7 +131,7 @@ class localtax extends CommonObject global $conf, $langs; $error=0; - + // Clean parameters $this->amount=trim($this->amount); $this->label=trim($this->label); @@ -250,7 +250,7 @@ class localtax extends CommonObject global $conf, $langs; $error=0; - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax"; $sql.= " WHERE rowid=".$this->id; @@ -300,6 +300,8 @@ class localtax extends CommonObject /** * Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de localtax, non ? * + * @param int $year Year + * @return int ??? */ function solde($year = 0) { @@ -317,8 +319,9 @@ class localtax extends CommonObject /** * Total de la localtax des factures emises par la societe. * + * @param int $year Year + * @return int ??? */ - function localtax_sum_collectee($year = 0) { @@ -357,8 +360,9 @@ class localtax extends CommonObject /** * localtax payed * + * @param int $year Year + * @return int ??? */ - function localtax_sum_payee($year = 0) { @@ -398,8 +402,9 @@ class localtax extends CommonObject * localtax payed * Total de la localtax payed * + * @param int $year Year + * @return int ??? */ - function localtax_sum_reglee($year = 0) { diff --git a/htdocs/compta/paiement/avalider.php b/htdocs/compta/paiement/avalider.php index 1fde3bd1a19..7cfe2104b45 100644 --- a/htdocs/compta/paiement/avalider.php +++ b/htdocs/compta/paiement/avalider.php @@ -71,7 +71,7 @@ if ($socid) } $sql.= " AND p.statut = 0"; $sql.= " ORDER BY $sortfield $sortorder"; -$sql.= $db->plimit($limit +1 ,$offset); +$sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); if ($resql) @@ -96,7 +96,7 @@ if ($resql) $objp = $db->fetch_object($resql); $var=!$var; print ""; - print ''; + print ''; print '\n"; print "\n"; print ''; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index f031189d25c..7967db52988 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -72,7 +72,7 @@ class RemiseCheque extends CommonObject $sql.= " WHERE bc.entity = ".$conf->entity; if ($id) $sql.= " AND bc.rowid = ".$id; if ($ref) $sql.= " AND bc.number = '".$this->db->escape($ref)."'"; - + dol_syslog("RemiseCheque::fetch sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -113,13 +113,13 @@ class RemiseCheque extends CommonObject /** * Create a receipt to send cheques * - * @param user User making creation - * @param account_id Bank account for cheque receipt - * @param limit Limit number of cheque to this - * @param toRemise array with cheques to remise - * @return int <0 if KO, >0 if OK + * @param User $user User making creation + * @param int $account_id Bank account for cheque receipt + * @param int $limit Limit number of cheque to this + * @param array $toRemise array with cheques to remise + * @return int <0 if KO, >0 if OK */ - function create($user, $account_id, $limit=40,$toRemise) + function create($user, $account_id, $limit=40, $toRemise) { global $conf; @@ -271,7 +271,8 @@ class RemiseCheque extends CommonObject /** * Supprime la remise en base * - * @param user utilisateur qui effectue l'operation + * @param User $user Utilisateur qui effectue l'operation + * @return void */ function delete($user='') { @@ -326,8 +327,8 @@ class RemiseCheque extends CommonObject /** * Validate a receipt * - * @param user User - * @return int <0 if KO, >0 if OK + * @param User $user User + * @return int <0 if KO, >0 if OK */ function validate($user) { @@ -472,11 +473,11 @@ class RemiseCheque extends CommonObject /** * Build document * - * @param model Model name - * @param outputlangs Object langs - * @return int <0 if KO, >0 if OK + * @param string $model Model name + * @param Tranlsate $outputlangs Object langs + * @return int <0 if KO, >0 if OK */ - function generatePdf($model='blochet', $outputlangs) + function generatePdf($model, $outputlangs) { global $langs,$conf; @@ -555,8 +556,9 @@ class RemiseCheque extends CommonObject } /** - * \brief Mets a jour le montant total - * \return int 0 en cas de succes + * Mets a jour le montant total + * + * @return int 0 en cas de succes */ function updateAmount() { @@ -614,9 +616,10 @@ class RemiseCheque extends CommonObject } /** - * \brief Insere la remise en base - * \param account_id Compte bancaire concerne - * \return int + * Insere la remise en base + * + * @param int $account_id Compte bancaire concerne + * @return int */ function removeCheck($account_id) { @@ -643,8 +646,9 @@ class RemiseCheque extends CommonObject return 0; } /** - * \brief Charge les proprietes ref_previous et ref_next - * \return int <0 si ko, 0 si ok + * Charge les proprietes ref_previous et ref_next + * + * @return int <0 if KO, 0 if OK */ function load_previous_next_id() { @@ -684,9 +688,10 @@ class RemiseCheque extends CommonObject /** * Set the creation date - * @param user Object user - * @param date Date creation - * @return int <0 if KO, >0 if OK + * + * @param User $user Object user + * @param timestamp $date Date creation + * @return int <0 if KO, >0 if OK */ function set_date($user, $date) { @@ -719,9 +724,10 @@ class RemiseCheque extends CommonObject /** * Renvoie nom clicable (avec eventuellement le picto) - * @param withpicto Inclut le picto dans le lien - * @param option Sur quoi pointe le lien - * @return string Chaine avec URL + * + * @param int $withpicto Inclut le picto dans le lien + * @param string $option Sur quoi pointe le lien + * @return string Chaine avec URL */ function getNomUrl($withpicto=0,$option='') { @@ -741,9 +747,10 @@ class RemiseCheque extends CommonObject } /** - * \brief Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * \return string Libelle + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle */ function getLibStatut($mode=0) { @@ -751,10 +758,11 @@ class RemiseCheque extends CommonObject } /** - * Return label of a status - * @param status Statut - * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * Return label of a status + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut */ function LibStatut($status,$mode=0) { diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 4ddf75a2887..9b0168bd0c2 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -44,7 +44,7 @@ $accountstatic=new Account($db); llxHeader('',$langs->trans("ChequesArea")); -print_fiche_titre($langs->trans("ChequesArea") ); +print_fiche_titre($langs->trans("ChequesArea")); print '
trans("Ref"); ?> trans("Date"); ?>
'.''.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid.''.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."$objp->paiement_type $objp->num_paiement'.price($objp->amount).'
'; diff --git a/htdocs/compta/paiement/cheque/liste.php b/htdocs/compta/paiement/cheque/liste.php index b454b56bdc5..4ccdef894d3 100644 --- a/htdocs/compta/paiement/cheque/liste.php +++ b/htdocs/compta/paiement/cheque/liste.php @@ -66,7 +66,7 @@ if ($_GET["search_montant"]) $sql.=" AND bc.amount=".price2num($_GET["search_montant"]); } $sql.= " ORDER BY $sortfield $sortorder"; -$sql.= $db->plimit($limit+1 ,$offset); +$sql.= $db->plimit($limit+1, $offset); //print "$sql"; $resql = $db->query($sql); diff --git a/htdocs/compta/paiement/cheque/pre.inc.php b/htdocs/compta/paiement/cheque/pre.inc.php index f0d49b6b3d1..98ed62325d6 100644 --- a/htdocs/compta/paiement/cheque/pre.inc.php +++ b/htdocs/compta/paiement/cheque/pre.inc.php @@ -32,14 +32,16 @@ $langs->load("categories"); /** * Replace the default llxHeader function - * @param $head - * @param $title - * @param $help_url - * @param $target - * @param $disablejs - * @param $disablehead - * @param $arrayofjs - * @param $arrayofcss + * + * @param string $head Optionnal head lines + * @param string $title HTML title + * @param string $help_url Link to online url help to show on left menu + * @param string $target Force target on menu links + * @param int $disablejs More content into html header + * @param int $disablehead More content into html header + * @param array $arrayofjs Array of complementary js files + * @param array $arrayofcss Array of complementary css files + * @return none */ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='') { diff --git a/htdocs/compta/paiement/liste.php b/htdocs/compta/paiement/liste.php index b7c53db2c67..e09dfbaf7be 100644 --- a/htdocs/compta/paiement/liste.php +++ b/htdocs/compta/paiement/liste.php @@ -115,7 +115,7 @@ else if ($_REQUEST["search_company"]) $sql .=" AND s.nom LIKE '%".$db->escape($_REQUEST["search_company"])."%'"; } $sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($limit+1 ,$offset); +$sql.= $db->plimit($limit+1, $offset); //print "$sql"; $resql = $db->query($sql); diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 74311782b3e..7c8f346017c 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -28,6 +28,7 @@ require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class. require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php"); $langs->load("widthdrawals"); $langs->load("companies"); @@ -80,7 +81,6 @@ $bprev = new BonPrelevement($db); llxHeader('', $langs->trans("NewStandingOrder")); -require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php"); if (prelevement_check_config() < 0) { $langs->load("errors"); diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index a208b9d6b47..dbdf3b535af 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -27,6 +27,7 @@ require("../bank/pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php"); $langs->load("withdrawals"); $langs->load("categories"); @@ -49,7 +50,6 @@ $result = restrictedArea($user, 'prelevement','',''); llxHeader('',$langs->trans("CustomersStandingOrdersArea")); -require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php"); if (prelevement_check_config() < 0) { $langs->load("errors"); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 8dc51a45b4e..0f141549ab1 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -75,7 +75,7 @@ class Tva extends CommonObject global $conf, $langs; $error=0; - + // Clean parameters $this->amount=trim($this->amount); $this->label=trim($this->label); @@ -147,7 +147,7 @@ class Tva extends CommonObject global $conf, $langs; $error=0; - + // Clean parameters $this->amount=trim($this->amount); $this->label=trim($this->label); @@ -273,7 +273,7 @@ class Tva extends CommonObject global $conf, $langs; $error=0; - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."tva"; $sql.= " WHERE rowid=".$this->id; @@ -460,9 +460,10 @@ class Tva extends CommonObject /** - * \brief Ajoute un paiement de TVA - * \param user Object user that insert - * \return int <0 if KO, rowid in tva table if OK + * Ajoute un paiement de TVA + * + * @param User $user Object user that insert + * @return int <0 if KO, rowid in tva table if OK */ function addPayment($user) { @@ -572,9 +573,10 @@ class Tva extends CommonObject } /** - * \brief Mise a jour du lien entre le paiement tva et la ligne g�n�r�e dans llx_bank - * \param id_bank Id compte bancaire - * \return int <0 if KO, >0 if OK + * Mise a jour du lien entre le paiement tva et la ligne g�n�r�e dans llx_bank + * + * @param int $id_bank Id compte bancaire + * @return int <0 if KO, >0 if OK */ function update_fk_bank($id_bank) { @@ -594,11 +596,12 @@ class Tva extends CommonObject /** - \brief Renvoie nom clicable (avec eventuellement le picto) - \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - \param option Sur quoi pointe le lien - \return string Chaine avec URL - */ + * Renvoie nom clicable (avec eventuellement le picto) + * + * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * @param string $option Sur quoi pointe le lien + * @return string Chaine avec URL + */ function getNomUrl($withpicto=0,$option='') { global $langs; diff --git a/htdocs/compta/tva/quadri.php b/htdocs/compta/tva/quadri.php index 70eb871b5c8..d6dd4cf00ec 100644 --- a/htdocs/compta/tva/quadri.php +++ b/htdocs/compta/tva/quadri.php @@ -51,9 +51,10 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); * to report the amounts for different VAT rates as different lines. * This function also accounts recurrent invoices. * - * @param db Database handler - * @param y Year - * @param q Year quarter (1-4) + * @param DoliDB $db Database handler + * @param int $y Year + * @param int $q Year quarter (1-4) + * @return void */ function tva_coll($db,$y,$q) { @@ -118,9 +119,10 @@ function tva_coll($db,$y,$q) * The function gets the VAT in split results, as the VAT declaration asks * to report the amounts for different VAT rates as different lines * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Year quarter (1-4) + * @param DoliDB $db Database handler object + * @param int $y Year + * @param int $q Year quarter (1-4) + * @return void */ function tva_paye($db, $y,$q) { @@ -289,16 +291,16 @@ if ($conf->global->COMPTA_MODE == "CREANCES-DETTES") $i++; } - print '' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; } diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 2d5e6c62eed..dafb75b4e04 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -70,8 +70,8 @@ abstract class ActionsContactCardCommon /** * Get object * - * @param int Object id - * @return object Object loaded + * @param int $id Object id + * @return object Object loaded */ function getObject($id) { @@ -226,8 +226,8 @@ abstract class ActionsContactCardCommon /** * Set content of ->tpl array, to use into template * - * @param string $action Type of action - * @return string HTML output + * @param string &$action Type of action + * @return string HTML output */ function assign_values(&$action) { diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 4230d8bbe38..ed186b92348 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -52,9 +52,12 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $this->canvas = $canvas; $this->card = $card; } - + /** * Return the title of card + * + * @param string $action Code action + * @return string Title */ private function getTitle($action) { @@ -62,24 +65,25 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $out=''; - if ($action == 'view') $out.= $langs->trans("Contact"); - if ($action == 'edit') $out.= $langs->trans("EditContact"); - if ($action == 'create') $out.= $langs->trans("NewContact"); - + if ($action == 'view') $out.= (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contact") : $langs->trans("ContactAddress")); + if ($action == 'edit') $out.= (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("EditContact") : $langs->trans("EditContactAddress")); + if ($action == 'create') $out.= (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")); + return $out; } /** * Assign custom values for canvas * - * @param string $action Type of action - * @return void + * @param string &$action Type of action + * @param int $id Id + * @return void */ function assign_values(&$action, $id) { global $conf, $db, $langs, $user; global $form; - + $ret = $this->getObject($id); parent::assign_values($action); diff --git a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php index 78565b9f25b..78e03875100 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php @@ -36,7 +36,7 @@ echo $this->control->tpl['ajax_selectcountry']; ?> -
'.$langs->trans("Total").':'.price($subtot_coll_total).''.price($subtot_coll_vat).''.price($subtot_paye_total).''.price($subtot_paye_vat).''.price($total).'' . - '
'.$langs->trans("Total").':'.price($subtot_coll_total).''.price($subtot_coll_vat).''.price($subtot_paye_total).''.price($subtot_paye_vat).''.price($total).''; + print '
+
diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index 2ba3716dc6d..cf8ac2d8b3e 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -44,7 +44,7 @@ echo $this->control->tpl['ajax_selectcountry']; -
trans("Lastname").' / '.$langs->trans("Label"); ?>
+
diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index 53531c72d0e..fe878bf95f0 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -29,7 +29,7 @@ dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors'] control->tpl['action_create_user']) echo $this->control->tpl['action_create_user']; ?> control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> -
trans("Ref"); ?>
+
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 0fb3a29af78..c3f307f6b34 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -130,7 +130,7 @@ if (empty($reshook)) if ($canvas) $object->canvas=$canvas; $object->socid = $_POST["socid"]; - $object->name = $_POST["name"]; + $object->lastname = $_POST["lastname"]; $object->firstname = $_POST["firstname"]; $object->civilite_id = $_POST["civilite_id"]; $object->poste = $_POST["poste"]; @@ -154,13 +154,13 @@ if (empty($reshook)) $object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]); $object->birthday_alert = $_POST["birthday_alert"]; - if (! $_POST["name"]) + if (! $_POST["lastname"]) { $error++; $errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")); $action = 'create'; } - - if ($_POST["name"]) + + if (! $error) { $id = $object->create($user); if ($id <= 0) @@ -205,13 +205,13 @@ if (empty($reshook)) if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) { - if (empty($_POST["name"])) + if (empty($_POST["lastname"])) { $error++; $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); $action = 'edit'; } - if (! count($errors)) + if (! $error) { $object->fetch($_POST["contactid"]); @@ -221,7 +221,7 @@ if (empty($reshook)) $object->old_firstname = $_POST["old_firstname"]; $object->socid = $_POST["socid"]; - $object->name = $_POST["name"]; + $object->lastname = $_POST["lastname"]; $object->firstname = $_POST["firstname"]; $object->civilite_id = $_POST["civilite_id"]; $object->poste = $_POST["poste"]; @@ -325,7 +325,8 @@ else // Show tabs $head = contact_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("ContactsAddresses"), 0, 'contact'); + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); + dol_fiche_head($head, 'card', $title, 0, 'contact'); } if ($user->rights->societe->contact->creer) @@ -350,7 +351,8 @@ else $object->country = $tmparray['label']; } - print_fiche_titre($langs->trans("AddContact")); + $title = $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + print_fiche_titre($title); // Affiche les erreurs dol_htmloutput_errors($error,$errors); @@ -375,7 +377,7 @@ else print '
trans("Ref"); ?>
'; // Name - print ''; + print ''; print ''; // Company @@ -556,7 +558,7 @@ else print ''; // Name - print ''; + print ''; print ''; // Company @@ -574,7 +576,7 @@ else print $formcompany->select_civility(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id); print ''; - print ''; + print ''; // Address print ''; @@ -735,7 +737,7 @@ else print ''; // Name - print ''; + print ''; print ''; // Company @@ -760,7 +762,7 @@ else print ''; // Role - print ''; + print ''; // Address print '"; // Customer print ""; - print ''; + print ''; // Ligne info remises tiers print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").'name).'">
'.$langs->trans("Lastname").' / '.$langs->trans("Label").'lastname).'">'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("Lastname").' / '.$langs->trans("Label").'name).'">
'.$langs->trans("Lastname").' / '.$langs->trans("Label").'lastname).'">'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("PostOrFunction" ).'poste).'">
'.$langs->trans("PostOrFunction").'poste).'">
'.$langs->trans("Address").'
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->name.'
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("PostOrFunction" ).''.$object->poste.'
'.$langs->trans("PostOrFunction").''.$object->poste.'
'.$langs->trans("Address").''; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index eb047e0b0a0..b6723bb6623 100755 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -62,29 +62,31 @@ $limit = $conf->liste_limit; $offset = $limit * $page; $langs->load("companies"); -$titre=$langs->trans("ListOfContacts"); +$titre = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); if ($type == "c") { - $titre=$langs->trans("ListOfContacts").' ('.$langs->trans("ThirdPartyCustomers").')'; + $titre.=' ('.$langs->trans("ThirdPartyCustomers").')'; $urlfiche="fiche.php"; } -if ($type == "p") +else if ($type == "p") { - $titre=$langs->trans("ListOfContacts").' ('.$langs->trans("ThirdPartyProspects").')'; + $titre.=' ('.$langs->trans("ThirdPartyProspects").')'; $urlfiche="prospect/fiche.php"; } -if ($type == "f") { - $titre=$langs->trans("ListOfContacts").' ('.$langs->trans("ThirdPartySuppliers").')'; +else if ($type == "f") +{ + $titre.=' ('.$langs->trans("ThirdPartySuppliers").')'; $urlfiche="fiche.php"; } -if ($type == "o") { - $titre=$langs->trans("ListOfContacts").' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; +else if ($type == "o") +{ + $titre.=' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; $urlfiche=""; } if ($view == 'phone') { $text=" (Vue Telephones)"; } if ($view == 'mail') { $text=" (Vue EMail)"; } if ($view == 'recent') { $text=" (Recents)"; } -$titre = $titre." $text"; +$titre.= " $text"; if ($_POST["button_removefilter"]) { @@ -109,7 +111,8 @@ if ($search_priv < 0) $search_priv=''; * View */ -llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); +$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); $form=new Form($db); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index b2e6162c333..7771520978d 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004-2010 Destailleur Laurent - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2010-2011 Juanjo Menent +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2012 Destailleur Laurent + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2008 Raphael Bertrand + * Copyright (C) 2010-2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,9 +27,6 @@ */ require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); -require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); -require_once(DOL_DOCUMENT_ROOT."/core/lib/price.lib.php"); - /** * \class Contrat @@ -59,11 +56,14 @@ class Contrat extends CommonObject var $commercial_signature_id; var $commercial_suivi_id; - var $note; + var $note; // deprecated + var $note_private; var $note_public; var $fk_projet; + var $extraparams=array(); + var $lines=array(); @@ -75,8 +75,6 @@ class Contrat extends CommonObject function Contrat($db) { $this->db = $db; - $this->product = new Product($db); - $this->societe = new Societe($db); } /** @@ -130,12 +128,12 @@ class Contrat extends CommonObject /** * Activate a contract line * - * @param user Objet User qui active le contrat - * @param line_id Id de la ligne de detail a activer - * @param date Date d'ouverture - * @param date_end Date fin prevue - * @param comment A comment typed by user - * @return int <0 if KO, >0 if OK + * @param User $user Objet User qui active le contrat + * @param int $line_id Id de la ligne de detail a activer + * @param timestamp $date Date d'ouverture + * @param timestamp $date_end Date fin prevue + * @param string $comment A comment typed by user + * @return int <0 if KO, >0 if OK */ function active_line($user, $line_id, $date, $date_end='', $comment='') { @@ -180,11 +178,11 @@ class Contrat extends CommonObject /** * Close a contract line * - * @param user Objet User qui active le contrat - * @param line_id Id de la ligne de detail a activer - * @param date_end Date fin - * @param comment A comment typed by user - * @return int <0 if KO, >0 if OK + * @param User $user Objet User qui active le contrat + * @param int $line_id Id de la ligne de detail a activer + * @param timestamp $date_end Date fin + * @param string $comment A comment typed by user + * @return int <0 if KO, >0 if OK */ function close_line($user, $line_id, $date_end, $comment='') { @@ -278,10 +276,10 @@ class Contrat extends CommonObject /** * Validate a contract * - * @param user Objet User - * @param langs Environnement langue de l'utilisateur - * @param conf Environnement de configuration lors de l'operation - * @return int <0 if KO, >0 if OK + * @param User $user Objet User + * @param Translate $langs Environnement langue de l'utilisateur + * @param Conf $conf Environnement de configuration lors de l'operation + * @return int <0 if KO, >0 if OK */ function validate($user,$langs,$conf) { @@ -314,6 +312,7 @@ class Contrat extends CommonObject * Load a contract from database * * @param int $id Id of contract to load + * @param string $ref Ref * @return int <0 if KO, id of contract if OK */ function fetch($id,$ref='') @@ -323,7 +322,7 @@ class Contrat extends CommonObject $sql.= " fk_user_author,"; $sql.= " fk_projet,"; $sql.= " fk_commercial_signature, fk_commercial_suivi,"; - $sql.= " note, note_public"; + $sql.= " note as note_private, note_public, extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; if ($ref) $sql.= " WHERE ref='".$ref."'"; else $sql.= " WHERE rowid=".$id; @@ -336,25 +335,27 @@ class Contrat extends CommonObject if ($result) { - $this->id = $result["rowid"]; - $this->ref = (!isset($result["ref"]) || !$result["ref"]) ? $result["rowid"] : $result["ref"]; - $this->statut = $result["statut"]; - $this->mise_en_service = $this->db->jdate($result["datemise"]); - $this->date_contrat = $this->db->jdate($result["datecontrat"]); + $this->id = $result["rowid"]; + $this->ref = (!isset($result["ref"]) || !$result["ref"]) ? $result["rowid"] : $result["ref"]; + $this->statut = $result["statut"]; + $this->mise_en_service = $this->db->jdate($result["datemise"]); + $this->date_contrat = $this->db->jdate($result["datecontrat"]); - $this->user_author_id = $result["fk_user_author"]; + $this->user_author_id = $result["fk_user_author"]; - $this->commercial_signature_id = $result["fk_commercial_signature"]; - $this->commercial_suivi_id = $result["fk_commercial_suivi"]; + $this->commercial_signature_id = $result["fk_commercial_signature"]; + $this->commercial_suivi_id = $result["fk_commercial_suivi"]; - $this->note = $result["note"]; - $this->note_public = $result["note_public"]; + $this->note = $result["note_private"]; // deprecated + $this->note_private = $result["note_private"]; + $this->note_public = $result["note_public"]; - $this->fk_projet = $result["fk_projet"]; + $this->fk_projet = $result["fk_projet"]; - $this->socid = $result["fk_soc"]; - $this->fk_soc = $result["fk_soc"]; - $this->societe->fetch($result["fk_soc"]); // TODO A virer car la societe doit etre chargee par appel de fetch_client() + $this->socid = $result["fk_soc"]; + $this->fk_soc = $result["fk_soc"]; + + $this->extraparams = (array) json_decode($result["extraparams"], true); $this->db->free($resql); @@ -690,10 +691,10 @@ class Contrat extends CommonObject /** * Supprime l'objet de la base * - * @param user Utilisateur qui supprime - * @param langs Environnement langue de l'utilisateur - * @param conf Environnement de configuration lors de l'operation - * @return int < 0 si erreur, > 0 si ok + * @param User $user Utilisateur qui supprime + * @param Translate $langs Environnement langue de l'utilisateur + * @param Conf $conf Environnement de configuration lors de l'operation + * @return int < 0 si erreur, > 0 si ok */ function delete($user,$langs='',$conf='') { @@ -810,22 +811,22 @@ class Contrat extends CommonObject /** * Ajoute une ligne de contrat en base * - * @param desc Description de la ligne - * @param pu_ht Prix unitaire HT - * @param qty Quantite - * @param txtva Taux tva - * @param txlocaltax1 Local tax 1 rate - * @param txlocaltax2 Local tax 2 rate - * @param fk_product Id produit - * @param remise_percent Pourcentage de remise de la ligne - * @param date_start Date de debut prevue - * @param date_end Date de fin prevue - * @param price_base_type HT ou TTC - * @param pu_ttc Prix unitaire TTC - * @param info_bits Bits de type de lignes - * @return int <0 si erreur, >0 si ok + * @param string $desc Description de la ligne + * @param float $pu_ht Prix unitaire HT + * @param int $qty Quantite + * @param float $txtva Taux tva + * @param float $txlocaltax1 Local tax 1 rate + * @param float $txlocaltax2 Local tax 2 rate + * @param int $fk_product Id produit + * @param float $remise_percent Pourcentage de remise de la ligne + * @param timestamp $date_start Date de debut prevue + * @param timestamp $date_end Date de fin prevue + * @param float $price_base_type HT ou TTC + * @param float $pu_ttc Prix unitaire TTC + * @param int $info_bits Bits de type de lignes + * @return int <0 si erreur, >0 si ok */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0, $info_bits=0) { global $user, $langs, $conf; @@ -936,21 +937,21 @@ class Contrat extends CommonObject /** * Mets a jour une ligne de contrat * - * @param rowid Id de la ligne de facture - * @param desc Description de la ligne - * @param pu Prix unitaire - * @param qty Quantite - * @param remise_percent Pourcentage de remise de la ligne - * @param date_start Date de debut prevue - * @param date_end Date de fin prevue - * @param tvatx Taux TVA - * @param localtax1tx Local tax 1 rate - * @param localtax2tx Local tax 2 rate - * @param date_debut_reel Date de debut reelle - * @param date_fin_reel Date de fin reelle - * @return int < 0 si erreur, > 0 si ok + * @param int $rowid Id de la ligne de facture + * @param string $desc Description de la ligne + * @param float $pu Prix unitaire + * @param int $qty Quantite + * @param float $remise_percent Pourcentage de remise de la ligne + * @param timestamp $date_start Date de debut prevue + * @param timestamp $date_end Date de fin prevue + * @param float $tvatx Taux TVA + * @param float $localtax1tx Local tax 1 rate + * @param float $localtax2tx Local tax 2 rate + * @param timestamp $date_debut_reel Date de debut reelle + * @param timestamp $date_fin_reel Date de fin reelle + * @return int < 0 si erreur, > 0 si ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start='', $date_end='', $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='') + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0, $localtax2tx=0, $date_debut_reel='', $date_fin_reel='') { global $user, $conf, $langs; @@ -1026,9 +1027,9 @@ class Contrat extends CommonObject /** * Delete a contract line * - * @param idline Id of line to delete - * @param user User that delete - * @return int >0 if OK, <0 if KO + * @param int $idline Id of line to delete + * @param User $user User that delete + * @return int >0 if OK, <0 if KO */ function deleteline($idline,$user) { @@ -1069,7 +1070,8 @@ class Contrat extends CommonObject /** * Update statut of contract according to services * - * @return int <0 if KO, >0 if OK + * @param User $user Object user + * @return int <0 if KO, >0 if OK */ function update_statut($user) { @@ -1092,8 +1094,8 @@ class Contrat extends CommonObject /** * Return label of a contract status * - * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services - * @return string Label + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services + * @return string Label */ function getLibStatut($mode) { @@ -1103,9 +1105,9 @@ class Contrat extends CommonObject /** * Renvoi label of a given contrat status * - * @param statut Status id - * @param mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services - * @return string Label + * @param int $statut Status id + * @param int $mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services + * @return string Label */ function LibStatut($statut,$mode) { @@ -1238,8 +1240,8 @@ class Contrat extends CommonObject /** * Return list of line rowid * - * @param statut Status of lines to get - * @return array Array of line's rowid + * @param int $statut Status of lines to get + * @return array Array of line's rowid */ function array_detail($statut=-1) { @@ -1274,8 +1276,8 @@ class Contrat extends CommonObject /** * Return list of other contracts for same company than current contract * - * @param option 'all' or 'others' - * @return array Array of contracts id + * @param string $option 'all' or 'others' + * @return array Array of contracts id */ function getListOfContracts($option='all') { @@ -1313,9 +1315,9 @@ class Contrat extends CommonObject /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param user Objet user - * @param mode "inactive" pour services a activer, "expired" pour services expires - * @return int <0 if KO, >0 if OK + * @param User $user Objet user + * @param string $mode "inactive" pour services a activer, "expired" pour services expires + * @return int <0 if KO, >0 if OK */ function load_board($user,$mode) { @@ -1510,8 +1512,7 @@ class Contrat extends CommonObject /** - * \class ContratLigne - * \brief Classe permettant la gestion des lignes de contrats + * Classe permettant la gestion des lignes de contrats */ class ContratLigne { @@ -1570,10 +1571,10 @@ class ContratLigne /** - * Return label of this contract line status + * Return label of this contract line status * - * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle */ function getLibStatut($mode) { @@ -1581,12 +1582,12 @@ class ContratLigne } /** - * Return label of a contract line status + * Return label of a contract line status * - * @param statut id statut - * @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @param expired 0=Not expired, 1=Expired, -1=Both or unknown - * @return string Libelle + * @param int $statut Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $expired 0=Not expired, 1=Expired, -1=Both or unknown + * @return string Libelle */ function LibStatut($statut,$mode,$expired=-1) { @@ -1645,8 +1646,9 @@ class ContratLigne /** * Renvoie nom clicable (avec eventuellement le picto) * - * @param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - * @return string Chaine avec URL + * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * @param int $maxlength Max length + * @return string Chaine avec URL */ function getNomUrl($withpicto=0,$maxlength=0) { @@ -1670,9 +1672,9 @@ class ContratLigne /** * Load object in memory from database * - * @param id id object - * @param ref Ref of contract - * @return int <0 if KO, >0 if OK + * @param int $id Id object + * @param string $ref Ref of contract + * @return int <0 if KO, >0 if OK */ function fetch($id, $ref='') { diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 158fe53da6c..7a35a414481 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -1,6 +1,7 @@ - * Copyright (C) 2005-2009 Destailleur Laurent +/* Copyright (C) 2005 Patrick Rouillon + * Copyright (C) 2005-2009 Destailleur Laurent + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,71 +33,74 @@ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); $langs->load("contracts"); $langs->load("companies"); -$contratid = isset($_GET["id"])?$_GET["id"]:''; +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$socid = GETPOST('socid','int'); +$id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'contrat', $contratid); +$result=restrictedArea($user,'contrat',$id); + +$object = new Contrat($db); /* * Ajout d'un nouveau contact */ -if ($_POST["action"] == 'addcontact' && $user->rights->contrat->creer) +if ($action == 'addcontact' && $user->rights->contrat->creer) { - $result = 0; - $contrat = new Contrat($db); - $result = $contrat->fetch($_GET["id"]); + $result = $object->fetch($id); - if ($result > 0 && $_POST["id"] > 0) + if ($result > 0 && $id > 0) { - $result = $contrat->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { - Header("Location: contact.php?id=".$contrat->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - if ($contrat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; } else { - $mesg = '
'.$contrat->error.'
'; + $mesg = '
'.$object->error.'
'; } } } // bascule du statut d'un contact -if ($_GET["action"] == 'swapstatut' && $user->rights->contrat->creer) +if ($action == 'swapstatut' && $user->rights->contrat->creer) { - $contrat = new Contrat($db); - if ($contrat->fetch(GETPOST('id','int'))) + if ($object->fetch($id)) { - $result=$contrat->swapContactStatus(GETPOST('ligne')); + $result=$object->swapContactStatus(GETPOST('ligne')); } else { - dol_print_error($db,$contrat->error); + dol_print_error($db,$object->error); } } // Efface un contact -if ($_GET["action"] == 'deleteline' && $user->rights->contrat->creer) +if ($action == 'deletecontact' && $user->rights->contrat->creer) { - $contrat = new Contrat($db); - $contrat->fetch($_GET["id"]); - $result = $contrat->delete_contact($_GET["lineid"]); + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); if ($result >= 0) { - Header("Location: contact.php?id=".$contrat->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } } @@ -120,18 +124,16 @@ dol_htmloutput_mesg($mesg); /* Mode vue et edition */ /* */ /* *************************************************************************** */ -$id = $_GET["id"]; -if ($id > 0) + +if ($id > 0 || ! empty($ref)) { - $contrat = New Contrat($db); - if ($contrat->fetch($id) > 0) + if ($object->fetch($id, $ref) > 0) { - if ($mesg) print $mesg; + dol_htmloutput_mesg($mesg); - $soc = new Societe($db); - $soc->fetch($contrat->socid); + $object->fetch_thirdparty(); - $head = contract_prepare_head($contrat); + $head = contract_prepare_head($object); $hselected=1; @@ -144,18 +146,18 @@ if ($id > 0) // Reference du contrat print '
'.$langs->trans("Ref").''; - print $contrat->ref; + print $object->ref; print "
".$langs->trans("Customer")."'.$soc->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
'.$langs->trans('Discount').''; - if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client); + if ($object->thirdparty->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$contrat->societe->getAvailableDiscounts(); + $absolute_discount=$object->thirdparty->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->currency)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); @@ -164,192 +166,12 @@ if ($id > 0) print "
"; - print ''; - - - /* - * Lignes de contacts - */ - echo '
'; - - /* - * Ajouter une ligne de contact - * Non affich� en mode modification de ligne - */ - if ($_GET["action"] != 'editline' && $user->rights->contrat->creer) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var = false; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Ligne ajout pour contact interne - print ""; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Ligne ajout pour contact externe - $var=!$var; - print ""; - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ""; - - } - - print ''; - - // Liste des contacts li�s - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $companystatic = new Societe($db); - $var = true; - - foreach(array('internal','external') as $source) - { - $tab = $contrat->liste_contact(-1,$source); - $num=count($tab); - - $i = 0; - while ($i < $num) - { - $var = !$var; - - print ''; - - // Source - print ''; - - // Societe - print ''; - - // Contact - print ''; - - // Type de contact - print ''; - - // Statut - print ''; - - // Icon delete - print ''; - - print "\n"; - - $i ++; - } - } - print "
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").' 
'; - print img_object('','user').' '.$langs->trans("Users"); - print ''; - print $conf->global->MAIN_INFO_SOCIETE_NOM; - print ''; - //$userAlreadySelected = $contrat->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type - $form->select_users($user->id,'contactid',0,$userAlreadySelected); - print ''; - $formcompany->selectTypeContact($contrat, '', 'type','internal'); - print '
'; - print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); - print ''; - $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$contrat->societe->id; - $selectedCompany = $formcompany->selectCompaniesForNewContact($contrat, 'id', $selectedCompany, 'newcompany'); - print ''; - $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); - if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); - print ''; - $formcompany->selectTypeContact($contrat, '', 'type','external'); - print '
 
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").''.$langs->trans("Status").' 
'; - if ($tab[$i]['source']=='internal') print $langs->trans("User"); - if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); - print ''; - if ($tab[$i]['socid'] > 0) - { - $companystatic->fetch($tab[$i]['socid']); - print $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - print $conf->global->MAIN_INFO_SOCIETE_NOM; - } - if (! $tab[$i]['socid']) - { - print ' '; - } - print ''; - if ($tab[$i]['source']=='internal') - { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - print $userstatic->getNomUrl(1); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; - print $contactstatic->getNomUrl(1); - } - print ''.$tab[$i]['libelle'].''; - // Activation desativation du contact - if ($contrat->statut >= 0) print ''; - print $contactstatic->LibStatut($tab[$i]['status'],3); - if ($contrat->statut >= 0) print ''; - print ''; - if ($user->rights->contrat->creer) - { - print ' '; - print ''; - print img_delete(); - print ''; - } - print '
"; - + + print '
'; + + // Contacts lines + include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); } else @@ -358,7 +180,7 @@ if ($id > 0) } } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index dccdf853615..3cacf53ee17 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2012 Juanjo Menent +/* Copyright (C) 2003-2004 Rodolphe Quiedeville + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010-2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,11 +27,13 @@ require ("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/price.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/modules/contract/modules_contract.php"); +if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); -if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"); $langs->load("contracts"); @@ -40,13 +42,15 @@ $langs->load("companies"); $langs->load("bills"); $langs->load("products"); -$action=GETPOST('action'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); $socid = GETPOST('socid','int'); -$contratid = GETPOST('id','int'); +$id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'contrat',$contratid,'contrat'); +$result=restrictedArea($user,'contrat',$id); $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; @@ -57,14 +61,14 @@ $object = new Contrat($db); * Actions */ -if ($action == 'confirm_active' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->activer) +if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { - $object->fetch($_GET["id"]); + $object->fetch($id); $result = $object->active_line($user, $_GET["ligne"], $_GET["date"], $_GET["dateend"], $_GET["comment"]); if ($result > 0) { - Header("Location: fiche.php?id=".$object->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -72,14 +76,14 @@ if ($action == 'confirm_active' && $_REQUEST["confirm"] == 'yes' && $user->right } } -if ($action == 'confirm_closeline' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->activer) +else if ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer) { - $object->fetch($_GET["id"]); + $object->fetch($id); $result = $object->close_line($user, $_GET["ligne"], $_GET["dateend"], urldecode($_GET["comment"])); if ($result > 0) { - Header("Location: fiche.php?id=".$object->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { @@ -144,25 +148,24 @@ if ($_POST["remonth"] && $_POST["reday"] && $_POST["reyear"]) $datecontrat = dol_mktime($_POST["rehour"], $_POST["remin"], 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } -if ($action == 'add') +else if ($action == 'add' && $user->rights->contrat->creer) { - $object->socid = $_POST["socid"]; - $object->date_contrat = $datecontrat; + $object->socid = $socid; + $object->date_contrat = $datecontrat; - $object->commercial_suivi_id = $_POST["commercial_suivi_id"]; - $object->commercial_signature_id = $_POST["commercial_signature_id"]; + $object->commercial_suivi_id = $_POST["commercial_suivi_id"]; + $object->commercial_signature_id = $_POST["commercial_signature_id"]; - $object->note = trim($_POST["note"]); - $object->fk_project = trim($_POST["projectid"]); - $object->remise_percent = trim($_POST["remise_percent"]); - $object->ref = trim($_POST["ref"]); + $object->note = trim($_POST["note"]); + $object->fk_project = trim($_POST["projectid"]); + $object->remise_percent = trim($_POST["remise_percent"]); + $object->ref = trim($_POST["ref"]); // Check if (empty($datecontrat)) { $error++; $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'
'; - $_GET["socid"]=$_POST["socid"]; $action='create'; } @@ -171,28 +174,27 @@ if ($action == 'add') $result = $object->create($user,$langs,$conf); if ($result > 0) { - Header("Location: fiche.php?id=".$object->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { $mesg='
'.$object->error.'
'; } - $_GET["socid"]=$_POST["socid"]; $action='create'; } } -if ($action == 'classin') +else if ($action == 'classin' && $user->rights->contrat->creer) { - $object->fetch($_GET["id"]); + $object->fetch($id); $object->setProject($_POST["projectid"]); } -if ($action == 'addline' && $user->rights->contrat->creer) +else if ($action == 'addline' && $user->rights->contrat->creer) { if ($_POST["pqty"] && (($_POST["pu"] != '' && $_POST["desc"]) || $_POST["idprod"])) { - $ret=$object->fetch($_GET["id"]); + $ret=$object->fetch($id); if ($ret < 0) { dol_print_error($db,$object->error); @@ -340,9 +342,9 @@ if ($action == 'addline' && $user->rights->contrat->creer) } } -if ($action == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cancel"]) +else if ($action == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cancel"]) { - $ret=$object->fetch($_GET["id"]); + $ret=$object->fetch($id); if ($ret < 0) { dol_print_error($db,$object->error); @@ -394,14 +396,14 @@ if ($action == 'updateligne' && $user->rights->contrat->creer && ! $_POST["cance } } -if ($action == 'confirm_deleteline' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->creer) +else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) { - $object->fetch($_GET["id"]); + $object->fetch($id); $result = $object->deleteline($_GET["lineid"],$user); if ($result >= 0) { - Header("Location: fiche.php?id=".$object->id); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else @@ -410,62 +412,129 @@ if ($action == 'confirm_deleteline' && $_REQUEST["confirm"] == 'yes' && $user->r } } -if ($action == 'confirm_valid' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->creer) +else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) { - $object->fetch($_GET["id"]); + $object->fetch($id); $result = $object->validate($user,$langs,$conf); } // Close all lines -if ($action == 'confirm_close' && $_REQUEST["confirm"] == 'yes' && $user->rights->contrat->creer) +else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) { - $object->fetch($_GET["id"]); + $object->fetch($id); $result = $object->cloture($user,$langs,$conf); } -if ($action == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') +else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) { - if ($user->rights->contrat->supprimer) - { - $object->id = $_GET["id"]; - $result=$object->delete($user,$langs,$conf); - if ($result >= 0) - { - Header("Location: index.php"); - return; - } - else - { - $mesg='
'.$object->error.'
'; - } - } + $object->fetch($id); + $result=$object->delete($user,$langs,$conf); + if ($result >= 0) + { + Header("Location: index.php"); + return; + } + else + { + $mesg='
'.$object->error.'
'; + } } -if ($action == 'confirm_move' && $_REQUEST["confirm"] == 'yes') +else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { - if ($user->rights->contrat->creer) - { - if ($_POST['newcid'] > 0) - { - $contractline = new ContratLigne($db); - $result=$contractline->fetch($_GET["lineid"]); - $contractline->fk_contrat = $_POST["newcid"]; - $result=$contractline->update($user,1); - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF'].'?id='.$_GET['id']); - return; - } - else - { - $mesg='
'.$object->error.'
'; - } - } - else - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefNewContract")).'
'; - } - } + if ($_POST['newcid'] > 0) + { + $contractline = new ContratLigne($db); + $result=$contractline->fetch($_GET["lineid"]); + $contractline->fk_contrat = $_POST["newcid"]; + $result=$contractline->update($user,1); + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + return; + } + else + { + $mesg='
'.$object->error.'
'; + } + } + else + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefNewContract")).'
'; + } +} + +else if ($action == 'setnote_public' && $user->rights->contrat->creer) +{ + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->contrat->creer) +{ + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +{ + if ($action == 'addcontact' && $user->rights->contrat->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->contrat->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->contrat->creer) + { + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } + } } @@ -475,7 +544,6 @@ if ($action == 'confirm_move' && $_REQUEST["confirm"] == 'yes') llxHeader('',$langs->trans("ContractCard"),"Contrat"); -$form = new Form($db); $form = new Form($db); $objectlignestatic=new ContratLigne($db); @@ -500,7 +568,7 @@ if ($action == 'create') $numct = $object->getNextNumRef($soc); - print '
'; + print ''; print ''; print ''; @@ -578,14 +646,11 @@ else { $now=dol_now(); - $id = $_GET["id"]; - $ref= $_GET['ref']; if ($id > 0 || ! empty($ref)) { - $result=$object->fetch($_GET['id'],$_GET['ref']); + $result=$object->fetch($id,$ref); if ($result > 0) { - $id = $object->id; // if $_GET['ref'] $result=$object->fetch_lines(); } if ($result < 0) @@ -595,6 +660,8 @@ else } dol_htmloutput_errors($mesg,''); + + $object->fetch_thirdparty(); $nbofservices=count($object->lines); @@ -619,7 +686,7 @@ else */ if ($action == 'delete') { - $ret=$form->form_confirm("fiche.php?id=$id",$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete",'',0,1); + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete",'',0,1); if ($ret == 'html') print '
'; } @@ -629,7 +696,7 @@ else if ($action == 'valid') { //$numfa = contrat_get_num($soc); - $ret=$form->form_confirm("fiche.php?id=$id",$langs->trans("ValidateAContract"),$langs->trans("ConfirmValidateContract"),"confirm_valid",'',0,1); + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ValidateAContract"),$langs->trans("ConfirmValidateContract"),"confirm_valid",'',0,1); if ($ret == 'html') print '
'; } @@ -638,7 +705,7 @@ else */ if ($action == 'close') { - $ret=$form->form_confirm("fiche.php?id=$id",$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1); + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1); if ($ret == 'html') print '
'; } @@ -647,7 +714,7 @@ else */ if ($object->brouillon && $user->rights->contrat->creer) { - print ''; + print ''; print ''; print ''; } @@ -661,13 +728,13 @@ else // Customer print "".$langs->trans("Customer").""; - print ''.$object->societe->getNomUrl(1).''; + print ''.$object->thirdparty->getNomUrl(1).''; // Ligne info remises tiers print ''.$langs->trans('Discount').''; - if ($object->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$object->societe->remise_client); + if ($object->thirdparty->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$object->societe->getAvailableDiscounts(); + $absolute_discount=$object->thirdparty->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); @@ -692,16 +759,16 @@ else print ''; - if ($action != "classify" && $user->rights->projet->creer) print ''; + if ($action != "classify" && $user->rights->projet->creer) print ''; print '
'; print $langs->trans("Project"); print ''.img_edit($langs->trans("SetProject")).'id.'">'.img_edit($langs->trans("SetProject")).'
'; print ''; if ($action == "classify") { - $form->form_project("fiche.php?id=$id",$object->socid,$object->fk_project,"projectid"); + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,"projectid"); } else { - $form->form_project("fiche.php?id=$id",$object->socid,$object->fk_project,"none"); + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,"none"); } print ""; } @@ -714,6 +781,24 @@ else } echo '
'; + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + $servicepos=(isset($_REQUEST["servicepos"])?$_REQUEST["servicepos"]:1); $colorb='666666'; @@ -724,9 +809,11 @@ else * Lines of contracts */ $productstatic=new Product($db); - + + // TODO move css and DAO + // Title line for service - print ''; // Array with (n*2)+1 lines + print '
'; // Array with (n*2)+1 lines $cursorline=1; while ($cursorline <= $nbofservices) { @@ -769,7 +856,7 @@ else $var=!$var; - if ($_REQUEST["action"] != 'editline' || $_GET["rowid"] != $objp->rowid) + if ($action != 'editline' || $_GET["rowid"] != $objp->rowid) { print ''; // Libelle @@ -807,7 +894,7 @@ else print ''; print ''; print ''; print ''; @@ -928,7 +1015,7 @@ else /* * Confirmation to delete service line of contract */ - if ($_REQUEST["action"] == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == $_GET["rowid"]) + if ($action == 'deleteline' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == $_GET["rowid"]) { $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".$_GET["rowid"],$langs->trans("DeleteContractLine"),$langs->trans("ConfirmDeleteContractLine"),"confirm_deleteline",'',0,1); if ($ret == 'html') print '
'; if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) { - print ''; + print ''; print img_picto($langs->trans("MoveToAnotherContract"),'uparrow'); print ''; } @@ -816,7 +903,7 @@ else } if ($user->rights->contrat->creer && ($object->statut >= 0)) { - print ''; + print ''; print img_edit(); print ''; } @@ -826,7 +913,7 @@ else if ( $user->rights->contrat->creer && ($object->statut >= 0)) { print ' '; - print ''; + print ''; print img_delete(); print ''; } @@ -865,7 +952,7 @@ else // Ligne en mode update else { - print ""; + print ''; print ''; print ''; print ''; @@ -887,7 +974,7 @@ else } print ''; - print $form->load_tva("eltva_tx",$objp->tva_tx,$mysoc,$object->societe); + print $form->load_tva("eltva_tx",$objp->tva_tx,$mysoc,$object->thirdparty); print '
'; @@ -937,7 +1024,7 @@ else /* * Confirmation to move service toward another contract */ - if ($_REQUEST["action"] == 'move' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == $_GET["rowid"]) + if ($action == 'move' && ! $_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline-1]->id == $_GET["rowid"]) { $arraycontractid=array(); foreach($arrayothercontracts as $contractcursor) @@ -957,7 +1044,7 @@ else /* * Confirmation de la validation activation */ - if ($_REQUEST["action"] == 'active' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($action == 'active' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == $_GET["ligne"]) { $dateactstart = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $dateactend = dol_mktime(12, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); @@ -969,7 +1056,7 @@ else /* * Confirmation de la validation fermeture */ - if ($_REQUEST["action"] == 'closeline' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($action == 'closeline' && ! $_REQUEST["cancel"] && $user->rights->contrat->activer && $object->lines[$cursorline-1]->id == $_GET["ligne"]) { $dateactstart = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $dateactend = dol_mktime(12, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); @@ -989,7 +1076,7 @@ else print ''; if ($user->societe_id == 0) { - if ($object->statut > 0 && $_REQUEST["action"] != 'activateline' && $_REQUEST["action"] != 'unactivateline') + if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') { $action='activateline'; if ($objp->statut == 4) $action='unactivateline'; @@ -1032,7 +1119,7 @@ else print ''; } - if ($user->rights->contrat->activer && $_REQUEST["action"] == 'activateline' && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline-1]->id == $_GET["ligne"]) { /** * Activer la ligne de contrat @@ -1082,7 +1169,7 @@ else print '
'; } - if ($user->rights->contrat->activer && $_REQUEST["action"] == 'unactivateline' && $object->lines[$cursorline-1]->id == $_GET["ligne"]) + if ($user->rights->contrat->activer && $action == 'unactivateline' && $object->lines[$cursorline-1]->id == $_GET["ligne"]) { /** * Desactiver la ligne de contrat @@ -1161,17 +1248,17 @@ else $var=false; // Service sur produit predefini - print '
'; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ""; print ''; // multiprix if($conf->global->PRODUIT_MULTIPRICES) - $form->select_produits('','idprod',1,$conf->product->limit_size,$object->societe->price_level); + $form->select_produits('','idprod',1,$conf->product->limit_size,$object->thirdparty->price_level); else $form->select_produits('','idprod',1,$conf->product->limit_size); if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; @@ -1179,7 +1266,7 @@ else print ''; print ''; - print '%'; + print '%'; print ''; print ''."\n"; @@ -1197,21 +1284,21 @@ else $var=!$var; // Service libre - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ""; print ''; print ''; - print $form->load_tva("tva_tx",-1,$mysoc,$object->societe); + print $form->load_tva("tva_tx",-1,$mysoc,$object->thirdparty); print ''; print ''; print ''; - print '%'; + print '%'; print ''; print ''."\n"; @@ -1249,14 +1336,14 @@ else if ($object->statut == 0 && $nbofservices) { - if ($user->rights->contrat->creer) print ''.$langs->trans("Validate").''; + if ($user->rights->contrat->creer) print ''.$langs->trans("Validate").''; else print ''.$langs->trans("Validate").''; } if ($conf->facture->enabled && $object->statut > 0) { $langs->load("bills"); - if ($user->rights->facture->creer) print ''.$langs->trans("CreateBill").''; + if ($user->rights->facture->creer) print ''.$langs->trans("CreateBill").''; else print ''.$langs->trans("CreateBill").''; } @@ -1264,7 +1351,7 @@ else { //if (! $numactive) //{ - print ''.$langs->trans("CloseAllContracts").''; + print ''.$langs->trans("CloseAllContracts").''; //} //else //{ @@ -1277,7 +1364,7 @@ else // - Droit de supprimer if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer) { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } print ""; @@ -1296,7 +1383,7 @@ else } } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index ea8ff2a549a..177e27f2598 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -85,7 +85,7 @@ if ($sall) $sql.= " AND (s.nom like '%".$db->escape($sall)."%' OR cd. $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut,"; $sql.= " s.nom, s.rowid"; $sql.= " ORDER BY $sortfield $sortorder"; -$sql.= $db->plimit($conf->liste_limit + 1 ,$offset); +$sql.= $db->plimit($conf->liste_limit + 1, $offset); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index 4f758b4c327..0855fc6ec29 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -1,6 +1,7 @@ - * Copyright (C) 2004-2007 Laurent Destailleur +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,60 +25,39 @@ require ("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'); -if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); - -$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:""; - -if (!$user->rights->contrat->lire) - accessforbidden(); +require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); $langs->load("companies"); $langs->load("contracts"); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$socid=GETPOST('socid','int'); +$id=GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); + // Security check -$id = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'contrat',$id,''); +$result=restrictedArea($user,'contrat',$id); - -$contrat = new Contrat($db); -$contrat->fetch($_GET["id"]); +$object = new Contrat($db); +$object->fetch($id,$ref); /******************************************************************************/ /* Actions */ /******************************************************************************/ -if ($_POST["action"] == 'update_public' && $user->rights->contrat->creer) +if ($action == 'setnote_public' && $user->rights->contrat->creer) { - $db->begin(); - - $res=$contrat->update_note_public($_POST["note_public"],$user); - if ($res < 0) - { - $mesg='
'.$contrat->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } -if ($_POST["action"] == 'update' && $user->rights->contrat->creer) +else if ($action == 'setnote' && $user->rights->contrat->creer) { - $db->begin(); - - $res=$contrat->update_note($_POST["note"],$user); - if ($res < 0) - { - $mesg='
'.$contrat->error.'
'; - $db->rollback(); - } - else - { - $db->commit(); - } + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } @@ -90,14 +70,13 @@ llxHeader(); $form = new Form($db); -if ($_GET["id"]) +if ($id > 0 || ! empty($ref)) { dol_htmloutput_mesg($mesg); - $soc = new Societe($db); - $soc->fetch($contrat->societe->id); + $object->fetch_thirdparty(); - $head = contract_prepare_head($contrat); + $head = contract_prepare_head($object); $hselected = 2; @@ -107,82 +86,34 @@ if ($_GET["id"]) print ''; // Reference - print ''; + print ''; // Societe print ''; - print ''; + print ''; // Ligne info remises tiers print ''; + + print "
'.$langs->trans('Ref').''.$contrat->ref.'
'.$langs->trans('Ref').''.$object->ref.'
'.$langs->trans("Customer").''.$soc->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
'.$langs->trans('Discount').''; - if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client); + if ($object->thirdparty->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$contrat->societe->getAvailableDiscounts(); + $absolute_discount=$object->thirdparty->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->currency)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); print '.'; print '
"; - // Note publique - print ''.$langs->trans("NotePublic").' :'; - print ''; - if ($_GET["action"] == 'edit') - { - print ''; - print ''; - print ''; - print '
"; - print ''; - print ''; - } - else - { - print ($contrat->note_public?nl2br($contrat->note_public):" "); - } - print ""; + print '
'; - // Note priv�e - if (! $user->societe_id) - { - print ''.$langs->trans("NotePrivate").' :'; - print ''; - if ($_GET["action"] == 'edit') - { - print '
'; - print ''; - print ''; - print '
"; - print ''; - print '
'; - } - else - { - print ($contrat->note?nl2br($contrat->note):" "); - } - print ""; - } - - print ""; - - - /* - * Actions - */ - print ''; - print '
'; - - if ($user->rights->contrat->creer && $_GET["action"] <> 'edit') - { - print "id."&action=edit\">".$langs->trans('Modify').""; - } - - print "
"; + include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'); + dol_fiche_end(); } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 30e0e81a72c..433df3249d8 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -101,7 +101,7 @@ $filter_date2=dol_mktime(0,0,0,$_REQUEST['op2month'],$_REQUEST['op2day'],$_REQUE if (! empty($_REQUEST['filter_op1']) && $_REQUEST['filter_op1'] != -1 && $filter_date1 != '') $sql.= " AND date_ouverture_prevue ".$_REQUEST['filter_op1']." ".$db->idate($filter_date1); if (! empty($_REQUEST['filter_op2']) && $_REQUEST['filter_op2'] != -1 && $filter_date2 != '') $sql.= " AND date_fin_validite ".$_REQUEST['filter_op2']." ".$db->idate($filter_date2); $sql .= $db->order($sortfield,$sortorder); -$sql .= $db->plimit($limit + 1 ,$offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; dol_syslog("contrat/services.php sql=".$sql); diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index c05ad0aeb13..3b19e505783 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -28,7 +28,7 @@ $langs->load("contracts"); echo '
'; print_titre($langs->trans('RelatedContracts')); ?> - +
diff --git a/htdocs/core/ajax/ajaxfiletree.php b/htdocs/core/ajax/ajaxfiletree.php new file mode 100644 index 00000000000..c29408dcd08 --- /dev/null +++ b/htdocs/core/ajax/ajaxfiletree.php @@ -0,0 +1,217 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/core/ajax/ajaxFileTree.php + * \ingroup ecm + * \brief This script returns content of a directory for filetree + * \version $Id: ajaxFileTree.php,v 1.8 2011/07/06 17:03:41 eldy Exp $ + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +// C'est un wrapper, donc header vierge +function llxHeader() { } + +$res=0; +$res=@include("../../main.inc.php"); +include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); +include_once(DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'); +include_once(DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'); +include_once(DOL_DOCUMENT_ROOT."/ecm/class/ecmdirectory.class.php"); + +$openeddir = GETPOST('openeddir'); +$modulepart= GETPOST('modulepart'); +$selecteddir = urldecode(GETPOST('dir')); // relative patch. We must keep the urldecode here because para comes from jqueyrFileTree that url encode it. +if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' + +$langs->load("ecm"); + +// Define selecteddir (fullpath). +if ($modulepart == 'ecm') $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); + + +// Security: +// On interdit les remontees de repertoire ainsi que les pipe dans +// les noms de fichiers. +if (preg_match('/\.\./',$fullpathselecteddir) || preg_match('/[<>|]/',$fullpathselecteddir)) +{ + dol_syslog("Refused to deliver file ".$original_file); + // Do no show plain path in shown error message + dol_print_error(0,$langs->trans("ErrorFileNameInvalid",GETPOST("file"))); + exit; +} + +// Check permissions +if ($modulepart == 'ecm') +{ + if (! $user->rights->ecm->read) accessforbidden(); +} + + + +/* + * View + */ +$userstatic=new User($db); +$form=new Form($db); +$ecmdirstatic = new EcmDirectory($db); + +// Load full tree. We will use it to define nbofsubdir and nboffilesinsubdir +if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); + +// Try to find key into $sqltree +$current_ecmdir_id=-1; +foreach($sqltree as $keycursor => $val) +{ + //print $val['fullrelativename']." == ".$selecteddir; + if ($val['fullrelativename'] == $selecteddir) + { + $current_ecmdir_id = $keycursor; + } +} + +if( file_exists($fullpathselecteddir) ) +{ + $files = @scandir($fullpathselecteddir); + if ($files) + { + natcasesort($files); + if( count($files) > 2 ) /* The 2 accounts for . and .. */ + { + echo "
    \n"; + + // All dirs + foreach( $files as $file ) // $file can be '.', '..', or 'My dir' + { + $nbofsubdir=0; + $nboffilesinsubdir=0; + + // Try to find key into $sqltree + $ecmdir_id=-1; + foreach($sqltree as $ecmdir_idcursor => $val) + { + //print "-- ".$val['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file).'
    '; + if ($val['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) + { + $ecmdir_id = $ecmdir_idcursor; + $resarray=tree_showpad($sqltree,$ecmdir_id,1); + $a=$resarray[0]; + $nbofsubdir=$resarray[1]; + $nboffilesinsubdir=$resarray[2]; + } + } + + //if (file_exists($fullpathselecteddir . $file) && $file != '.' && $file != '..' && is_dir($fullpathselecteddir . $file)) + if ($file != '.' && $file != '..' && ($ecmdir_id >= 0 || dol_is_dir($fullpathselecteddir . $file))) + { + print '
trans("Ref"); ?> trans("Date"); ?>
'; + + /*print '';*/ + + // Nb of docs + print ''; + print ''; + + // Edit link + print ''; + + // Add link + //print ''; + //print ''; + + // Info + print '"; + + print "
'; + print dol_escape_htmltag($file); + print ''; + print $val['cachenbofdoc']; + print ''; + if ($nbofsubdir && $nboffilesinsubdir) print '+'.$nboffilesinsubdir.' '; + print ''.img_view().''.img_edit_add().' '; + $userstatic->id=$val['fk_user_c']; + $userstatic->lastname=$val['login_c']; + $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].'
'; + $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").'
'; + $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1).'
'; + $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.dol_print_date($val['date_c'],"dayhour").'
'; + $htmltooltip.=''.$langs->trans("Description").': '.$val['description'].'
'; + $htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").': '.$val['cachenbofdoc'].'
'; + if ($nbofsubdir) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; + else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").': '.$nbofsubdir.'
'; + print $form->textwithpicto('',$htmltooltip,1,0); + print "
\n"; + print ''; + + print "\n"; + } + } + + // All files + /* + foreach( $files as $file ) + { + if( file_exists($fullpathselecteddir . $file) && $file != '.' && $file != '..' && !is_dir($fullpathselecteddir . $file) ) + { + $ext = preg_replace('/^.*\./', '', $file); + print "
  • "; + print "" . dol_escape_htmltag($file) . ""; + print "
  • \n"; + } + } + */ + + // Enable tooltips + print ''; + + echo "\n"; + + } + } + else print "PermissionDenied"; +} + +// This ajax service is called only when a directory $selecteddir is opened but not closed. +//print ''; + +if (is_object($db)) $db->close(); +?> \ No newline at end of file diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 0ee675434b9..1c8eaf513f0 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2012 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ /** * \file htdocs/core/ajax/box.php - * \brief File to return Ajax response on Box move + * \brief File to return Ajax response on Box move or close */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal @@ -29,7 +29,13 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require('../../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/boxes.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/infobox.class.php"); + +$boxid=GETPOST('boxid','int'); +$boxorder=GETPOST('boxorder'); +$userid=GETPOST('userid'); +$zone=GETPOST('zone','int'); +$userid=GETPOST('userid','int'); /* @@ -45,14 +51,20 @@ top_httphead(); print ''."\n"; -// Registering the location of boxes -if((isset($_GET['boxorder']) && !empty($_GET['boxorder'])) && (isset($_GET['userid']) && !empty($_GET['userid']))) +// Add a box +if ($boxid > 0 && $zone !='' && $userid > 0) +{ + $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list +} + +// Registering the location of boxes after a move +if ($boxorder && $zone != '' && $userid > 0) { // boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B" - dol_syslog("AjaxBox boxorder=".$_GET['boxorder']." userid=".$_GET['userid'], LOG_DEBUG); + dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG); - $infobox=new InfoBox($db); - $result=$infobox->saveboxorder("0",$_GET['boxorder'],$_GET['userid']); + //$infobox=new InfoBox($db); + $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); } ?> diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php new file mode 100644 index 00000000000..025d1dc9dd0 --- /dev/null +++ b/htdocs/core/ajax/contacts.php @@ -0,0 +1,58 @@ + + * + * 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 2 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/core/ajax/contacts.php + * \brief File to load contacts combobox + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +require('../../main.inc.php'); + +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$htmlname = GETPOST('htmlname','alpha'); + +/* + * View + */ + +top_httphead(); + +//print ''."\n"; + +// Load original field value +if (! empty($id) && ! empty($action) && ! empty($htmlname)) +{ + $form = new Form($db); + + $return=array(); + + $return['value'] = $form->selectcontacts($id,'','contactid',0,'','',0,'',true); + $return['num'] = $form->num; + $return['error'] = $form->error; + + echo json_encode($return); +} + +?> diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php new file mode 100644 index 00000000000..7dd1ce04743 --- /dev/null +++ b/htdocs/core/ajax/extraparams.php @@ -0,0 +1,79 @@ + + * + * 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 2 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/core/ajax/extraparams.php + * \brief File to return Ajax response on set extra parameters of elements + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +include("../../main.inc.php"); + +$id = GETPOST('id','int'); +$element = GETPOST('element','alpha'); +$htmlelement = GETPOST('htmlelement','alpha'); +$type = GETPOST('type', 'alpha'); + +/* + * View + */ + +top_httphead(); + +print ''."\n"; + +if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) +{ + $value = GETPOST('value','alpha'); + $params=array(); + + dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); + + $classpath = $subelement = $element; + + // For compatibility + if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } + else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } + else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } + else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } + else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } + else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } + else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } + else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } + + dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); + + if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } + else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } + else $classname = ucfirst($subelement); + + $object = new $classname($db); + $object->fetch($id); + + $params[$htmlelement] = array($type => $value); + $object->extraparams = array_merge($object->extraparams, $params); + + $result=$object->setExtraParameters(); +} + +?> diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index fe577d54347..152ba07288d 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -30,6 +30,11 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); require('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php"); +$field = GETPOST('field','alpha'); +$element = GETPOST('element','alpha'); +$table_element = GETPOST('table_element','alpha'); +$fk_element = GETPOST('fk_element','alpha'); + /* * View */ @@ -39,20 +44,12 @@ top_httphead(); //print ''."\n"; // Load original field value -if((isset($_GET['field']) && ! empty($_GET['field'])) - && (isset($_GET['element']) && ! empty($_GET['element'])) - && (isset($_GET['table_element']) && ! empty($_GET['table_element'])) - && (isset($_GET['fk_element']) && ! empty($_GET['fk_element']))) +if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) { - $element = GETPOST('element'); - $table_element = GETPOST('table_element'); - $fk_element = GETPOST('fk_element'); - $ext_element = GETPOST('ext_element'); - //$ext_table_element = GETPOST('ext_table_element'); - //$ext_fk_element = GETPOST('ext_fk_element'); - $field = substr(GETPOST('field'), 8); // remove prefix val_ - $type = GETPOST('type'); - $loadmethod = (GETPOST('loadmethod') ? GETPOST('loadmethod') : 'getValueFrom'); + $ext_element = GETPOST('ext_element','alpha'); + $field = substr($field, 8); // remove prefix val_ + $type = GETPOST('type','alpha'); + $loadmethod = (GETPOST('loadmethod','alpha') ? GETPOST('loadmethod','alpha') : 'getValueFrom'); if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) { @@ -80,7 +77,7 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) if ($type == 'select') { $methodname = 'load_cache_'.$loadmethod; - $cachename = 'cache_'.GETPOST('loadmethod'); + $cachename = 'cache_'.GETPOST('loadmethod','alpha'); $form = new Form($db); if (method_exists($form, $methodname)) diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index b9c2f7dbfec..9af6a83e54a 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -30,6 +30,11 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); require('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php"); +$field = GETPOST('field','alpha',2); +$element = GETPOST('element','alpha',2); +$table_element = GETPOST('table_element','alpha',2); +$fk_element = GETPOST('fk_element','alpha',2); + /* * View */ @@ -40,21 +45,14 @@ top_httphead(); //print_r($_POST); // Load original field value -if((isset($_POST['field']) && ! empty($_POST['field'])) - && (isset($_POST['element']) && ! empty($_POST['element'])) - && (isset($_POST['table_element']) && ! empty($_POST['table_element'])) - && (isset($_POST['fk_element']) && ! empty($_POST['fk_element']))) +if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) { - $element = GETPOST('element'); - $table_element = GETPOST('table_element'); - $fk_element = GETPOST('fk_element'); - $ext_element = GETPOST('ext_element'); - //$ext_table_element = GETPOST('ext_table_element'); - //$ext_fk_element = GETPOST('ext_fk_element'); - $field = substr(GETPOST('field'), 8); // remove prefix val_ - $value = GETPOST('value'); - $type = GETPOST('type'); - $savemethodname = (GETPOST('savemethod') ? GETPOST('savemethod') : 'setValueFrom'); + $ext_element = GETPOST('ext_element','alpha',2); + $field = substr($field, 8); // remove prefix val_ + $type = GETPOST('type','alpha',2); + $value = ($type == 'ckeditor' ? GETPOST('value','',2) : GETPOST('value','alpha',2)); + $savemethod = GETPOST('savemethod','alpha',2); + $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); $view=''; $format='text'; @@ -100,15 +98,15 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) } else if ($type == 'datepicker') { - $timestamp = GETPOST('timestamp'); + $timestamp = GETPOST('timestamp','int',2); $format = 'date'; $newvalue = ($timestamp / 1000); } else if ($type == 'select') { - $loadmethodname = 'load_cache_'.GETPOST('loadmethod'); - $loadcachename = 'cache_'.GETPOST('loadmethod'); - $loadviewname = 'view_'.GETPOST('loadmethod'); + $loadmethodname = 'load_cache_'.GETPOST('loadmethod','alpha'); + $loadcachename = 'cache_'.GETPOST('loadmethod','alpha'); + $loadviewname = 'view_'.GETPOST('loadmethod','alpha'); $form = new Form($db); if (method_exists($form, $loadmethodname)) @@ -158,7 +156,7 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) if (! $error) { - if (! is_object($object)) $object = new GenericObject($db); + if (! is_object($object) || empty($savemethod)) $object = new GenericObject($db); // Specific for add_object_linked() // TODO add a function for variable treatment diff --git a/htdocs/core/ajax/vatrates.php b/htdocs/core/ajax/vatrates.php new file mode 100644 index 00000000000..c4ecc36ae9b --- /dev/null +++ b/htdocs/core/ajax/vatrates.php @@ -0,0 +1,61 @@ + + * + * 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 2 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/core/ajax/vatrates.php + * \brief File to load vat rates combobox + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +require('../../main.inc.php'); + +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$htmlname = GETPOST('htmlname','alpha'); + +/* + * View + */ + +top_httphead(); + +//print ''."\n"; + +// Load original field value +if (! empty($id) && ! empty($action) && ! empty($htmlname)) +{ + $form = new Form($db); + $soc = new Societe($db); + + $soc->fetch($id); + + $return=array(); + + $return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true); + $return['num'] = $form->num; + $return['error'] = $form->error; + + echo json_encode($return); +} + +?> diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index f95c077999d..c4b10f1bf02 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -50,7 +50,7 @@ class box_actions extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastActions"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastActions"); } /** diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 7af510379f1..bda9ccaeeb1 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -46,7 +46,7 @@ class box_bookmarks extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxMyLastBookmarks"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxMyLastBookmarks"); } /** diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 633440275f9..8b087463e83 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -50,7 +50,7 @@ class box_clients extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastCustomers"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastCustomers"); } /** diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 4104426864b..a54d2eda2ba 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -50,7 +50,7 @@ class box_commandes extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastCustomerOrders"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastCustomerOrders"); } /** diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 55c673225b5..e23f51971c4 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -51,7 +51,7 @@ class box_comptes extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans('BoxCurrentAccounts'); + $this->boxlabel=$langs->transnoentitiesnoconv('BoxCurrentAccounts'); } /** diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index c9e216de25f..3f952eea6f1 100755 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -51,7 +51,7 @@ class box_contacts extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastContacts"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastContacts"); } /** diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 6c4a57b5466..72901e87a18 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -50,7 +50,7 @@ class box_contracts extends ModeleBoxes $langs->load("contracts"); - $this->boxlabel=$langs->trans("BoxLastContracts"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastContracts"); } /** diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 61ec5c75b2f..51f197ec3fd 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -47,7 +47,8 @@ class box_external_rss extends ModeleBoxes /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param string $param More parameters */ function box_external_rss($db,$param) { @@ -57,7 +58,7 @@ class box_external_rss extends ModeleBoxes $this->db=$db; $this->param=$param; - $this->boxlabel=$langs->trans("BoxLastRssInfos"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastRssInfos"); } /** diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 624f633442e..fc18d2ee453 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -49,7 +49,7 @@ class box_factures extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastCustomerBills"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastCustomerBills"); } /** diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 03725161a23..394934438fd 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -49,7 +49,7 @@ class box_factures_fourn extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastSupplierBills"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastSupplierBills"); } /** diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index bf2228d752a..ebbba5def70 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -49,7 +49,7 @@ class box_factures_fourn_imp extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxOldestUnpaidSupplierBills"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxOldestUnpaidSupplierBills"); } /** diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 30f18ad02f0..a98ec274bfc 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -52,7 +52,7 @@ class box_factures_imp extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxOldestUnpaidCustomerBills"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxOldestUnpaidCustomerBills"); } /** diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 8e579f79731..0b275f25e4d 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -49,7 +49,7 @@ class box_fournisseurs extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastSuppliers"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastSuppliers"); } /** diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 7625ab8bc2e..d1fc2b2e78b 100755 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -50,7 +50,7 @@ class box_members extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastMembers"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastMembers"); } /** diff --git a/htdocs/core/boxes/box_osc_client.php b/htdocs/core/boxes/box_osc_client.php index 725a156d9f6..c2a4a0d00ea 100644 --- a/htdocs/core/boxes/box_osc_client.php +++ b/htdocs/core/boxes/box_osc_client.php @@ -49,7 +49,7 @@ class box_osc_clients extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxNbOfCustomers"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxNbOfCustomers"); } /** diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 20b23316952..a45900672b6 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -52,7 +52,7 @@ class box_produits extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastProducts"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastProducts"); } /** diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 3ff01e3cc54..dee694e72f6 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -51,7 +51,7 @@ class box_propales extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastProposals"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastProposals"); } /** diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index f1f6ae393bc..87d2324013e 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -39,23 +39,24 @@ class box_prospect extends ModeleBoxes var $depends = array("societe"); var $db; - var $param; var $info_box_head = array(); var $info_box_contents = array(); + /** * Constructor + * + * @param DoliDB $db Database handler */ - function box_prospect($DB,$param) + function box_prospect($db) { global $langs; $langs->load("boxes"); - $this->db=$DB; - $this->param=$param; + $this->db=$db; - $this->boxlabel=$langs->trans("BoxLastProspects"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastProspects"); } /** diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index c696306a1cf..a706254ee0b 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -50,7 +50,7 @@ class box_services_contracts extends ModeleBoxes global $langs; $langs->load("boxes"); - $this->boxlabel=$langs->trans("BoxLastProductsInContract"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastProductsInContract"); } /** diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index ab648d44ec4..b8a42fe8f03 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -51,7 +51,7 @@ class box_services_expired extends ModeleBoxes $langs->load("contracts"); - $this->boxlabel=$langs->trans("BoxOldestExpiredServices"); + $this->boxlabel=$langs->transnoentitiesnoconv("BoxOldestExpiredServices"); } /** diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 08a4d0cef86..419ac40dd20 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -148,9 +148,10 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty" } if ($conf->use_javascript_ajax) { - print ''; + print ''; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - print img_picto($langs->trans("MoveBox",$this->box_id),'uparrow','class="boxhandle" style="cursor:move;"'); + print img_picto($langs->trans("MoveBox",$this->box_id),'grip','class="boxhandle" style="cursor:move;"'); + print img_picto($langs->trans("Close",$this->box_id),'close','class="boxclose" style="cursor:pointer;" id="imgclose'.$this->box_id.'"'); print ''; } print ''; @@ -226,17 +227,6 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty" print "\n"; } } - - // Complete line to max - /* - while ($i < $this->max) - { - $var=!$var; - print ' '; - $i++; - }*/ - - //print "\n"; } if (! empty($head['text']) || ! empty($head['sublink']) || $nblines) diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index e90c208d32e..7fa522d2037 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -51,8 +51,8 @@ class AntiVir * Scan a file with antivirus. * This function runs the command defined in setup. This antivirus command must return 0 if OK. * - * @param file File to scan - * @return int <0 if KO (-98 if error, -99 if virus), 0 if OK + * @param string $file File to scan + * @return int <0 if KO (-98 if error, -99 if virus), 0 if OK */ function dol_avscan_file($file) { @@ -126,9 +126,10 @@ class AntiVir /** - * \brief get full Command Line to run - * \param file File to scan - * \return string Full command line to run + * Get full Command Line to run + * + * @param string $file File to scan + * @return string Full command line to run */ function getCliCommand($file) { diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 6caf410ee85..73713118b51 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -24,8 +24,7 @@ /** - * \class Canvas - * \brief Class to manage canvas + * Class to manage canvas */ class Canvas { @@ -47,7 +46,7 @@ class Canvas /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler * @param string $actiontype Action type ('create', 'view', 'edit', 'list') */ function __construct($db, $actiontype='view') @@ -126,10 +125,11 @@ class Canvas /** * Return the template to display canvas (if it exists) * + * @param string $action Action code * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ function displayCanvasExists($action) - { + { if (empty($this->template_dir)) return 0; if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->action.'.tpl.php')) return 1; @@ -140,7 +140,8 @@ class Canvas * Display a canvas page. This will include the template for output. * Variables used by templates may have been defined or loaded before into the assign_values function. * - * @return void + * @param string $action Action code + * @return void */ function display_canvas($action) { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ed49e784dad..f906ea3c75e 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -38,8 +38,9 @@ abstract class CommonDocGenerator /** * Define array with couple subtitution key => subtitution value * - * @param $user User - * @param $outputlangs Language object for output + * @param User $user User + * @param Translate $outputlangs Language object for output + * @return array Array of substitution key->code */ function get_substitutionarray_user($user,$outputlangs) { @@ -61,8 +62,9 @@ abstract class CommonDocGenerator /** * Define array with couple subtitution key => subtitution value * - * @param $mysoc - * @param $outputlangs Language object for output + * @param Societe $mysoc Object thirdparty + * @param Translate $outputlangs Language object for output + * @return array Array of substitution key->code */ function get_substitutionarray_mysoc($mysoc,$outputlangs) { @@ -103,8 +105,9 @@ abstract class CommonDocGenerator /** * Define array with couple subtitution key => subtitution value * - * @param $object - * @param $outputlangs Language object for output + * @param Object $object Object + * @param Translate $outputlangs Language object for output + * @return array Array of substitution key->code */ function get_substitutionarray_thirdparty($object,$outputlangs) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 68e9a6d3270..dc62d653afe 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -665,6 +665,8 @@ abstract class CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE ".$field." = '".$key."'"; $sql.= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this).'::fetchObjectFrom sql='.$sql); $resql = $this->db->query($sql); if ($resql) { @@ -690,6 +692,7 @@ abstract class CommonObject $sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE rowid = ".$id; + dol_syslog(get_class($this).'::getValueFrom sql='.$sql); $resql = $this->db->query($sql); if ($resql) { @@ -862,6 +865,112 @@ abstract class CommonObject } } + /** + * Change the payments methods + * + * @param int $id Id of new payment method + * @return int >0 if OK, <0 if KO + */ + function setPaymentMethods($id) + { + dol_syslog(get_class($this).'::setPaymentMethods('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + // TODO uniformize field name + $fieldname = 'fk_mode_reglement'; + if ($this->element == 'societe') $fieldname = 'mode_reglement'; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' WHERE rowid='.$this->id; + + if ($this->db->query($sql)) + { + $this->mode_reglement_id = $id; + $this->mode_reglement = $id; // for compatibility + return 1; + } + else + { + dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } + + /** + * Change the payments terms + * + * @param int $id Id of new payment terms + * @return int >0 if OK, <0 if KO + */ + function setPaymentTerms($id) + { + dol_syslog(get_class($this).'::setPaymentTerms('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + // TODO uniformize field name + $fieldname = 'fk_cond_reglement'; + if ($this->element == 'societe') $fieldname = 'cond_reglement'; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.$id; + $sql .= ' WHERE rowid='.$this->id; + + if ($this->db->query($sql)) + { + $this->cond_reglement_id = $id; + $this->cond_reglement = $id; // for compatibility + return 1; + } + else + { + dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } + + /** + * Define delivery address + * + * @param int $id Address id + * @return int <0 si ko, >0 si ok + */ + function setDeliveryAddress($id) + { + $fieldname = 'fk_adresse_livraison'; + if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + + if ($this->db->query($sql)) + { + $this->fk_delivery_address = $id; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error); + return -1; + } + } /** * Set last model used by doc generator @@ -1224,7 +1333,7 @@ abstract class CommonObject } /** - * Update private note of element + * Update external ref of element * * @param string $ref_ext Update field ref_ext * @return int <0 if KO, >0 if OK @@ -1270,7 +1379,7 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - // TODO uniformize fields note_private + // TODO uniformize fields to note_private if ($this->table_element == 'fichinter' || $this->table_element == 'projet' || $this->table_element == 'projet_task') { $sql.= " SET note_private = '".$this->db->escape($note)."'"; @@ -1284,7 +1393,8 @@ abstract class CommonObject dol_syslog(get_class($this)."::update_note sql=".$sql, LOG_DEBUG); if ($this->db->query($sql)) { - $this->note = $note; + $this->note = $note; // deprecated + $this->note_private = $note; return 1; } else @@ -1468,7 +1578,7 @@ abstract class CommonObject { $origin = (! empty($origin) ? $origin : $this->origin); $origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id); - + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -1709,32 +1819,38 @@ abstract class CommonObject } /** - * Set statut of an object + * Set status of an object * - * @param int $statut Statut to set + * @param int $status Status to set * @param int $elementId Id of element to force (use this->id by default) * @param string $elementType Type of element to force (use ->this->element by default) * @return int <0 if KO, >0 if OK */ - function setStatut($statut,$elementId='',$elementType='') + function setStatut($status,$elementId='',$elementType='') { $elementId = (!empty($elementId)?$elementId:$this->id); $elementTable = (!empty($elementType)?$elementType:$this->table_element); + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; - $sql.= " SET fk_statut = ".$statut; + $sql.= " SET fk_statut = ".$status; $sql.= " WHERE rowid=".$elementId; dol_syslog(get_class($this)."::setStatut sql=".$sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR); - return -1; + if ($this->db->query($sql)) + { + $this->db->commit(); + $this->statut = $status; + return 1; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; } - - return 1; } @@ -2016,6 +2132,36 @@ abstract class CommonObject return $nb; } + /** + * Set extra parameters + * + * @return void + */ + function setExtraParameters() + { + $this->db->begin(); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql.= ' SET extraparams = "'.$this->db->escape(json_encode($this->extraparams)).'"'; + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::setExtraParameters ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + else + { + $this->db->commit(); + return 1; + } + } + + // -------------------- // TODO: All functions here must be redesigned and moved as they are not business functions but output functions // -------------------- @@ -2270,7 +2416,7 @@ abstract class CommonObject } else { - $this->printLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$hookmanager); + $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$hookmanager); } $i++; @@ -2287,8 +2433,8 @@ abstract class CommonObject * * @param string $action GET/POST action * @param array $line Selected object line to output - * @param string $var Is it a an odd line - * @param int $num Number of line + * @param string $var Is it a an odd line (true) + * @param int $num Number of line (0) * @param int $i I * @param int $dateSelector 1=Show also date range input fields * @param string $seller Object of seller third party @@ -2297,7 +2443,7 @@ abstract class CommonObject * @param HookManager $hookmanager Hook manager * @return void */ - function printLine($action,$line,$var=true,$num=0,$i=0,$dateSelector=0,$seller,$buyer,$selected=0,$hookmanager=false) + function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$hookmanager=false) { global $conf,$langs,$user; global $form,$bc,$bcdd; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index c1c30c6826e..e8dc3fbbe80 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -85,12 +85,46 @@ class Conf function Conf() { // Avoid warnings when filling this->xxx - $this->file=(object) array(); - $this->db=(object) array(); - $this->global=(object) array(); - $this->mycompany=(object) array(); - $this->admin=(object) array(); - $this->user=(object) array(); + $this->file = (object) array(); + $this->db = (object) array(); + $this->global = (object) array(); + $this->mycompany = (object) array(); + $this->admin = (object) array(); + $this->user = (object) array(); + $this->syslog = (object) array(); + $this->browser = (object) array(); + $this->multicompany = (object) array(); + + $this->expedition_bon = (object) array(); + $this->livraison_bon = (object) array(); + $this->fournisseur = (object) array(); + $this->fournisseur->commande = (object) array(); + $this->fournisseur->facture = (object) array(); + $this->product = (object) array(); + $this->service = (object) array(); + $this->contrat = (object) array(); + $this->actions = (object) array(); + $this->commande = (object) array(); + $this->commande->client = (object) array(); + $this->commande->fournisseur = (object) array(); + $this->propal = (object) array(); + $this->propal->cloture = (object) array(); + $this->propal->facturation = (object) array(); + $this->facture = (object) array(); + $this->facture->client = (object) array(); + $this->facture->fournisseur = (object) array(); + $this->contrat = (object) array(); + $this->contrat->services = (object) array(); + $this->contrat->services->inactifs = (object) array(); + $this->contrat->services->expires = (object) array(); + $this->adherent = (object) array(); + $this->adherent->cotisation = (object) array(); + $this->bank = (object) array(); + $this->bank->rappro = (object) array(); + $this->bank->cheque = (object) array(); + $this->notification = (object) array(); + $this->mailing = (object) array(); + //! Charset for HTML output and for storing data in memory $this->file->character_set_client='UTF-8'; // UTF-8, ISO-8859-1 } @@ -165,9 +199,9 @@ class Conf $varname = $partname.'_modules'; // TODO deprecated if (! isset($this->$varname) || ! is_array($this->$varname)) { $this->$varname = array(); } // TODO deprecated if (! isset($this->modules_parts[$partname]) || ! is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } - $arrValue = dol_json_decode($value,true); + $arrValue = json_decode($value,true); if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue; - else if (in_array($partname,array('login','menus','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/'; + else if (in_array($partname,array('login','menus','substitutions','triggers'))) $value = '/'.$modulename.'/core/'.$partname.'/'; else if (in_array($partname,array('models'))) $value = '/'.$modulename.'/'; else if ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; $this->$varname = array_merge($this->$varname, array($modulename => $value)); // TODO deprecated @@ -177,6 +211,7 @@ class Conf elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)$/i',$key,$reg)) { $modulename=strtolower($reg[1]); + if ($modulename == 'propale') $modulename='propal'; $this->$modulename=(object) array(); $this->$modulename->enabled=true; $this->modules[]=$modulename; // Add this module in list of enabled modules @@ -185,19 +220,7 @@ class Conf } $i++; } - - // Object $mc - if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) - { - global $mc; - - $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); - if ($ret) - { - $mc = new ActionsMulticompany($db); - $mc->setValues($this); - } - } + $db->free($resql); } //var_dump($this->modules); @@ -221,6 +244,7 @@ class Conf // By default, we repeat info on all tabs if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1; + if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1; $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; @@ -235,7 +259,7 @@ class Conf // For backward compatibility // TODO Replace this->xxx->enabled by this->modulename->enabled to remove this code - if (isset($this->propale->enabled)) $this->propal->enabled=$this->propale->enabled; + if (isset($this->categorie->enabled)) $this->category->enabled=$this->categorie->enabled; // Define default dir_output and dir_temp for directories of modules foreach($this->modules as $module) @@ -255,12 +279,16 @@ class Conf // For user storage $this->user->dir_output=$rootforuser."/users"; $this->user->dir_temp=$rootforuser."/users/temp"; + + // For propal storage + $this->propal->dir_output=$rootforuser."/propale"; + $this->propal->dir_temp=$rootforuser."/propale/temp"; // Exception: Some dir are not the name of module. So we keep exception here // for backward compatibility. // Sous module bons d'expedition - $this->expedition_bon->enabled=defined("MAIN_SUBMODULE_EXPEDITION")?MAIN_SUBMODULE_EXPEDITION:0; + $this->expedition_bon->enabled= defined("MAIN_SUBMODULE_EXPEDITION")?MAIN_SUBMODULE_EXPEDITION:0; // Sous module bons de livraison $this->livraison_bon->enabled=defined("MAIN_SUBMODULE_LIVRAISON")?MAIN_SUBMODULE_LIVRAISON:0; @@ -357,13 +385,13 @@ class Conf // Delay before warnings $this->actions->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60; $this->commande->client->warning_delay=(isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_ORDERS_TO_PROCESS:2)*24*60*60; - $this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60; - $this->propal->cloture->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE)?$this->global->MAIN_DELAY_PROPALS_TO_CLOSE:0)*24*60*60; - $this->propal->facturation->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_BILL)?$this->global->MAIN_DELAY_PROPALS_TO_BILL:0)*24*60*60; + $this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60; + $this->propal->cloture->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE)?$this->global->MAIN_DELAY_PROPALS_TO_CLOSE:0)*24*60*60; + $this->propal->facturation->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_BILL)?$this->global->MAIN_DELAY_PROPALS_TO_BILL:0)*24*60*60; $this->facture->client->warning_delay=(isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED)?$this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED:0)*24*60*60; - $this->facture->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY)?$this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY:0)*24*60*60; - $this->contrat->services->inactifs->warning_delay=(isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES)?$this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES:0)*24*60*60; - $this->contrat->services->expires->warning_delay=(isset($this->global->MAIN_DELAY_RUNNING_SERVICES)?$this->global->MAIN_DELAY_RUNNING_SERVICES:0)*24*60*60; + $this->facture->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY)?$this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY:0)*24*60*60; + $this->contrat->services->inactifs->warning_delay=(isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES)?$this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES:0)*24*60*60; + $this->contrat->services->expires->warning_delay=(isset($this->global->MAIN_DELAY_RUNNING_SERVICES)?$this->global->MAIN_DELAY_RUNNING_SERVICES:0)*24*60*60; $this->adherent->cotisation->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60; $this->bank->rappro->warning_delay=(isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE)?$this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE:0)*24*60*60; $this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60; @@ -386,6 +414,19 @@ class Conf // For backward compatibility if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php'; elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php'; + + // Object $mc + if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) + { + global $mc; + + $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); + if ($ret) + { + $mc = new ActionsMulticompany($db); + $mc->setValues($this); + } + } } } diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 55209c975a5..eb0e02b49b9 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -22,10 +22,9 @@ */ /** - * \class DolEditor - * \brief Class to manage a WYSIWYG editor. - * Usage: $doleditor=new DolEditor('body',$message,320,'toolbar_mailing'); - * $doleditor->Create(); + * Class to manage a WYSIWYG editor. + * Usage: $doleditor=new DolEditor('body',$message,320,'toolbar_mailing'); + * $doleditor->Create(); */ class DolEditor { @@ -66,7 +65,7 @@ class DolEditor { global $conf,$langs; - dol_syslog("DolEditor::DolEditor htmlname=".$htmlname." toolbarname=".$toolbarname); + dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." toolbarname=".$toolbarname); if (! $rows) $rows=round($height/20); if (! $cols) $cols=($width?round($width/6):80); @@ -136,13 +135,14 @@ class DolEditor } /** - * Output edit area inside the HTML stream. - * Output depends on this->tool (fckeditor, ckeditor, texatrea, ...) + * Output edit area inside the HTML stream. + * Output depends on this->tool (fckeditor, ckeditor, texatrea, ...) * - * @param int $noprint 1=Return HTML string instead of printing it to output - * @return void + * @param int $noprint 1=Return HTML string instead of printing it to output + * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });" + * @return void */ - function Create($noprint=0) + function Create($noprint=0,$morejs='') { global $conf; @@ -171,14 +171,15 @@ class DolEditor $skin='kama'; $out.= ''; } } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 8381f4361d7..91b9e8ec78b 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -38,8 +38,7 @@ /** - * \class DolGraph - * \brief Parent class of graph classes + * Parent class of graph classes */ class DolGraph { diff --git a/htdocs/core/class/genericobject.class.php b/htdocs/core/class/genericobject.class.php index 06f8067f2b4..ace19b2a174 100755 --- a/htdocs/core/class/genericobject.class.php +++ b/htdocs/core/class/genericobject.class.php @@ -35,7 +35,7 @@ class GenericObject extends CommonObject /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function __construct($db) { diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index fe9ad22e071..1dc54c041b0 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -37,14 +37,14 @@ class HookManager // Array with instantiated classes var $hooks=array(); - + // Array result var $resArray=array(); /** * Constructor * - * @param DoliDB $DB Handler acces base de donnees + * @param DoliDB $db Handler acces base de donnees */ function __construct($db) { @@ -75,9 +75,8 @@ class HookManager // For backward compatibility if (! is_array($arraycontext)) $arraycontext=array($arraycontext); - $this->contextarray=array_merge($arraycontext,$this->contextarray); // All contexts are concatenated + $this->contextarray=array_unique(array_merge($arraycontext,$this->contextarray)); // All contexts are concatenated - $i=0; foreach($conf->hooks_modules as $module => $hooks) { if ($conf->$module->enabled) @@ -93,29 +92,14 @@ class HookManager $actionfile = 'actions_'.$module.'.class.php'; $pathroot = ''; - $this->hooks[$i]['type']=$context; - // Include actions class overwriting hooks $resaction=dol_include_once($path.$actionfile); if ($resaction) { $controlclassname = 'Actions'.ucfirst($module); $actionInstance = new $controlclassname($this->db); - $this->hooks[$i]['modules'][$module] = $actionInstance; + $this->hooks[$context][$module] = $actionInstance; } - - // Include dataservice class (model) - // TODO storing dao is useless here. It's goal of controller to known which dao to manage - $daofile = 'dao_'.$module.'.class.php'; - $resdao=dol_include_once($path.$daofile); - if ($resdao) - { - // Instantiate dataservice class (model) - $daoInstance = 'Dao'.ucfirst($module); - $this->hooks[$i]['modules'][$module]->object = new $daoInstance($this->db); - } - - $i++; } } } @@ -124,7 +108,7 @@ class HookManager } /** - * Execute hooks (if the were initialized) for the given method + * Execute hooks (if they were initialized) for the given method * * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) * @param array $parameters Array of parameters @@ -143,23 +127,28 @@ class HookManager $parameters['context']=join(':',$this->contextarray); dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); - // Loop on each hook + // Loop on each hook to qualify modules that declared context + $modulealreadyexecuted=array(); $resaction=0; $resprint=''; - foreach($this->hooks as $hook) + foreach($this->hooks as $modules) // this->hooks is an array with context as key and value is an array of modules that handle this context { - if (! empty($hook['modules'])) + if (! empty($modules)) { - foreach($hook['modules'] as $module => $actioninstance) + foreach($modules as $module => $actionclassinstance) { + // test to avoid to run twice a hook, when a module implements several active contexts + if (in_array($module,$modulealreadyexecuted)) continue; + $modulealreadyexecuted[$module]=$module; + $var=!$var; // Hooks that return int - if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actioninstance,$method)) + if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actionclassinstance,$method)) { - $resaction+=$actioninstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) - if ($resaction < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && count($actioninstance->errors) > 0)) + $resaction+=$actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) + if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) { - $this->error=$actioninstance->error; $this->errors=$actioninstance->errors; + $this->error=$actionclassinstance->error; $this->errors=$actionclassinstance->errors; if ($method == 'doActions') { if ($action=='add') $action='create'; // TODO this change must be inside the doActions @@ -168,10 +157,10 @@ class HookManager } } // Generic hooks that return a string (printSearchForm, printLeftBlock, formBuilddocOptions, ...) - else if (method_exists($actioninstance,$method)) + else if (method_exists($actionclassinstance,$method)) { - if (is_array($parameters) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actioninstance->module_number) continue; - $result = $actioninstance->$method($parameters, $object, $action, $this); + if (is_array($parameters) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue; + $result = $actionclassinstance->$method($parameters, $object, $action, $this); if (is_array($result)) $this->resArray = array_merge($this->resArray, $result); else $resprint.=$result; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 576d10b01bd..67d2d96883d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -42,6 +42,7 @@ class Form { var $db; var $error; + var $num; // Cache arrays var $cache_types_paiements=array(); @@ -50,6 +51,7 @@ class Form var $cache_demand_reason=array(); var $cache_type_fees=array(); var $cache_currencies=array(); + var $cache_vatrates=array(); var $tva_taux_value; var $tva_taux_libelle; @@ -73,15 +75,16 @@ class Form * @param string $preselected Name of Value to show/edit (not used in this function) * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select:xxx'...) + * @param string $moreparam More param to add on a href URL * @return string HTML edit field */ - function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string') + function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata='string', $moreparam='') { global $conf,$langs; $ret=''; - + // TODO change for compatibility if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;/',$typeofdata)) { @@ -102,7 +105,7 @@ class Form $ret.=''; - if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; + if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; $ret.='
    '; $ret.=$langs->trans($text); $ret.='id.'">'.img_edit($langs->trans('Edit'),1).'id.$moreparam.'">'.img_edit($langs->trans('Edit'),1).'
    '; } @@ -117,13 +120,14 @@ class Form * @param string $value Value to show/edit * @param object $object Object * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) + * @param string $typeofdata Type of data ('string' by default, '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 * @param object $extObject External object * @param string $success Success message + * @param string $moreparam More param to add on a href URL * @return string HTML edit field */ - function editfieldval($text,$htmlname,$value,$object,$perm,$typeofdata='string',$editvalue='',$extObject=null,$success=null) + function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $success=null, $moreparam='') { global $conf,$langs,$db; @@ -140,7 +144,7 @@ class Form if (GETPOST('action') == 'edit'.$htmlname) { $ret.="\n"; - $ret.='
    '; + $ret.=''; $ret.=''; $ret.=''; $ret.=''; @@ -151,9 +155,10 @@ class Form $tmp=explode(':',$typeofdata); $ret.=''; } - else if ($typeofdata == 'text' || $typeofdata == 'textarea' || $typeofdata == 'note') + else if (preg_match('/^text/',$typeofdata) || preg_match('/^note/',$typeofdata)) { - $ret.=''; + $tmp=explode(':',$typeofdata); + $ret.=''; } else if ($typeofdata == 'day' || $typeofdata == 'datepicker') { @@ -173,7 +178,7 @@ class Form { $tmp=explode(':',$typeofdata); require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true); + $doleditor=new DolEditor($htmlname, ($editvalue?$editvalue:$value), ($tmp[2]?$tmp[2]:''), ($tmp[3]?$tmp[3]:'100'), ($tmp[1]?$tmp[1]:'dolibarr_notes'), 'In', ($tmp[5]?$tmp[5]:0), true, true, ($tmp[6]?$tmp[6]:'20'), ($tmp[7]?$tmp[7]:'100')); $ret.=$doleditor->Create(1); } $ret.=''; @@ -199,9 +204,13 @@ class Form else if (preg_match('/^ckeditor/',$typeofdata)) { $tmpcontent=dol_htmlentitiesbr($value); - $firstline=preg_replace('/
    .*/','',$tmpcontent); - $firstline=preg_replace('/[\n\r].*/','',$firstline); - $ret.=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $firstline=preg_replace('/
    .*/','',$tmpcontent); + $firstline=preg_replace('/[\n\r].*/','',$firstline); + $tmpcontent=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); + } + $ret.=$tmpcontent; } else $ret.=$value; } @@ -216,7 +225,7 @@ class Form * @param string $value Value to show/edit * @param string $htmlname DIV ID (field name) * @param int $condition Condition to edit - * @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx') + * @param string $inputType Type of input ('numeric', 'datepicker', 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:xxx') * @param string $editvalue When in edit mode, use this value as $value instead of value * @param object $extObject External object * @param string $success Success message @@ -242,8 +251,6 @@ class Form $savemethod = false; $ext_element = false; $button_only = false; - //$ext_table_element = false; - //$ext_fk_element = false; if (is_object($object)) { @@ -255,8 +262,6 @@ class Form if (is_object($extObject)) { $ext_element = $extObject->element; - //$ext_table_element = $extObject->table_element; - //$ext_fk_element = $extObject->id; } if (preg_match('/^(string|email|numeric)/',$inputType)) @@ -273,13 +278,20 @@ class Form $out.= ''."\n"; // Use for timestamp format } - else if (preg_match('/^select/',$inputType)) + else if (preg_match('/^(select|autocomplete)/',$inputType)) { $tmp=explode(':',$inputType); $inputType=$tmp[0]; $loadmethod=$tmp[1]; if (! empty($tmp[2])) $savemethod=$tmp[2]; if (! empty($tmp[3])) $button_only=true; } + else if (preg_match('/^textarea/',$inputType)) + { + $tmp=explode(':',$inputType); + $inputType=$tmp[0]; + if (! empty($tmp[1])) $rows=$tmp[1]; + if (! empty($tmp[2])) $cols=$tmp[2]; + } else if (preg_match('/^ckeditor/',$inputType)) { $tmp=explode(':',$inputType); @@ -302,11 +314,9 @@ class Form $out.= ''."\n"; $out.= ''."\n"; $out.= ''."\n"; - $out.= ''."\n"; - $out.= ''."\n"; - if (! empty($success)) $out.= ''."\n"; - //$out.= ''."\n"; - //$out.= ''."\n"; + if (! empty($savemethod)) $out.= ''."\n"; + if (! empty($ext_element)) $out.= ''."\n"; + if (! empty($success)) $out.= ''."\n"; $out.= '
    '.$value.'
    '."\n"; $out.= '
    '.(! empty($editvalue) ? $editvalue : $value).'
    '."\n"; @@ -383,7 +393,7 @@ class Form * Show a text with a picto and a tooltip on picto * * @param string $text Text to show - * @param string $htmltooltip Content of tooltip + * @param string $htmltext Content of tooltip * @param int $direction 1=Icon is after text, -1=Icon is before text, 0=no icon * @param string $type Type of picto (info, help, warning, superadmin...) * @param string $extracss Add a CSS style to td tags @@ -456,7 +466,7 @@ class Form $sql.= " WHERE active = 1"; $sql.= " ORDER BY code ASC"; - dol_syslog("Form::select_country sql=".$sql); + dol_syslog(get_class($this)."::select_country sql=".$sql); $resql=$this->db->query($sql); if ($resql) { @@ -645,9 +655,10 @@ class Form * @param int $showempty Add an empty field * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box + * @param array $event Event options * @return string HTML string with */ - function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) + function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0, $event=array()) { global $conf,$user,$langs; @@ -670,11 +681,11 @@ class Form { //$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); - $out.= ajax_combobox($htmlname); + $out.= ajax_combobox($htmlname, $event); } $out.= ''; - if ($showempty) print ''; + if ($htmlname != 'none' || $options_only) $out.= ''; + $out.= ''; } - return $num; + if ($htmlname != 'none' || $options_only) + { + $out.= ''; + } + + $this->num = $num; + return $out; } else { @@ -879,14 +919,15 @@ class Form /** * Return select list of users * - * @param selected Id user preselected - * @param htmlname Field name in form - * @param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * @param exclude Array list of users id to exclude - * @param disabled If select list must be disabled - * @param include Array list of users id to include - * @param enableonly Array list of users id to be enabled. All other must be disabled - * @param force_entity Possibility to force entity + * @param string $selected Id user preselected + * @param string $htmlname Field name in form + * @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue + * @param array $exclude Array list of users id to exclude + * @param int $disabled If select list must be disabled + * @param array $include Array list of users id to include + * @param int $enableonly Array list of users id to be enabled. All other must be disabled + * @param int $force_entity Possibility to force entity + * @return void */ function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0) { @@ -896,14 +937,15 @@ class Form /** * Return select list of users * - * @param selected User id or user object of user preselected. If -1, we use id of current user. - * @param htmlname Field name in form - * @param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * @param exclude Array list of users id to exclude - * @param disabled If select list must be disabled - * @param include Array list of users id to include - * @param enableonly Array list of users id to be enabled. All other must be disabled - * @param force_entity Possibility to force entity + * @param string $selected User id or user object of user preselected. If -1, we use id of current user. + * @param string $htmlname Field name in form + * @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue + * @param array $exclude Array list of users id to exclude + * @param int $disabled If select list must be disabled + * @param array $include Array list of users id to include + * @param int $enableonly Array list of users id to be enabled. All other must be disabled + * @param int $force_entity Possibility to force entity + * @return string HTML select string */ function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0) { @@ -940,7 +982,7 @@ class Form if (is_array($include) && $includeUsers) $sql.= " AND u.rowid IN ('".$includeUsers."')"; $sql.= " ORDER BY u.name ASC"; - dol_syslog("Form::select_dolusers sql=".$sql); + dol_syslog(get_class($this)."::select_dolusers sql=".$sql); $resql=$this->db->query($sql); if ($resql) { @@ -1017,6 +1059,7 @@ class Form * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell * @param int $finished 2=all, 1=finished, 0=raw material * @param string $selected_input_value Value of preselected input text (with ajax) + * @param int $hidelabel Hide label * @return void */ function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1,$finished=2,$selected_input_value='',$hidelabel=0) @@ -1116,7 +1159,7 @@ class Form $outselect=''; $outjson=array(); - dol_syslog("Form::select_produits_do search product sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::select_produits_do search product sql=".$sql, LOG_DEBUG); $result=$this->db->query($sql); if ($result) { @@ -1177,7 +1220,7 @@ class Form $sql.= " ORDER BY date_price"; $sql.= " DESC LIMIT 1"; - dol_syslog("Form::select_produits_do search price for level '.$price_level.' sql=".$sql); + dol_syslog(get_class($this)."::select_produits_do search price for level '.$price_level.' sql=".$sql); $result2 = $this->db->query($sql); if ($result2) { @@ -1265,16 +1308,16 @@ class Form } /** - * Return list of products for customer in Ajax if Ajax activated or go to select_produits_fournisseurs_do + * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_do) * * @param int $socid Id third party - * @param string $selected Preselected product - * @param string $htmlname Name of HTML Select - * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param string $filtre For a SQL filter + * @param string $selected Preselected product + * @param string $htmlname Name of HTML Select + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param string $filtre For a SQL filter * @return void */ - function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtertype='',$filtre) + function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='') { global $langs,$conf; global $price_level, $status, $finished; @@ -1293,17 +1336,17 @@ class Form } /** - * Retourne la liste des produits de fournisseurs + * Return list of suppliers products * - * @param socid Id societe fournisseur (0 pour aucun filtre) - * @param selected Produit pre-selectionne - * @param htmlname Nom de la zone select - * @param filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param filtre Pour filtre sql - * @param filterkey Filtre des produits - * @param status -1=Return all products, 0=Products not on sell, 1=Products on sell - * @param disableout Disable print output - * @return array Array of keys for json + * @param int $socid Id societe fournisseur (0 pour aucun filtre) + * @param int $selected Produit pre-selectionne + * @param string $htmlname Nom de la zone select + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param string $filtre Pour filtre sql + * @param string $filterkey Filtre des produits + * @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $disableout Disable print output + * @return array Array of keys for json */ function select_produits_fournisseurs_do($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$disableout=0) { @@ -1465,7 +1508,7 @@ class Form $sql.= " AND p.rowid = ".$productid; $sql.= " ORDER BY s.nom, pfp.ref_fourn DESC"; - dol_syslog("Form::select_product_fourn_price sql=".$sql,LOG_DEBUG); + dol_syslog(get_class($this)."::select_product_fourn_price sql=".$sql,LOG_DEBUG); $result=$this->db->query($sql); if ($result) @@ -1538,7 +1581,7 @@ class Form * @param int $showempty Add an empty field * @return void */ - function select_address($selected='', $socid, $htmlname='address_id',$showempty=0) + function select_address($selected, $socid, $htmlname='address_id',$showempty=0) { // On recherche les utilisateurs $sql = "SELECT a.rowid, a.label"; @@ -1546,7 +1589,7 @@ class Form $sql .= " WHERE a.fk_soc = ".$socid; $sql .= " ORDER BY a.label ASC"; - dol_syslog("Form::select_address sql=".$sql); + dol_syslog(get_class($this)."::select_address sql=".$sql); $resql=$this->db->query($sql); if ($resql) { @@ -1596,7 +1639,7 @@ class Form $sql.= " FROM ".MAIN_DB_PREFIX.'c_payment_term'; $sql.= " WHERE active=1"; $sql.= " ORDER BY sortorder"; - dol_syslog('Form::load_cache_conditions_paiements sql='.$sql,LOG_DEBUG); + dol_syslog(get_class($this).'::load_cache_conditions_paiements sql='.$sql,LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1635,7 +1678,7 @@ class Form $sql.= " FROM ".MAIN_DB_PREFIX.'c_availability'; $sql.= " WHERE active=1"; $sql.= " ORDER BY rowid"; - dol_syslog('Form::load_cache_availability sql='.$sql,LOG_DEBUG); + dol_syslog(get_class($this).'::load_cache_availability sql='.$sql,LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1662,10 +1705,11 @@ class Form /** * Retourne la liste des types de delais de livraison possibles * - * @param selected Id du type de delais pre-selectionne - * @param htmlname Nom de la zone select - * @param filtertype To add a filter - * @param addempty Add empty entry + * @param int $selected Id du type de delais pre-selectionne + * @param string $htmlname Nom de la zone select + * @param string $filtertype To add a filter + * @param int $addempty Add empty entry + * @return void */ function select_availability($selected='',$htmlname='availid',$filtertype='',$addempty=0) { @@ -1707,7 +1751,7 @@ class Form $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_reason'; $sql.= " WHERE active=1"; $sql.= " ORDER BY rowid"; - dol_syslog('Form::load_cache_demand_reason sql='.$sql,LOG_DEBUG); + dol_syslog(get_class($this)."::load_cache_demand_reason sql=".$sql,LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1725,7 +1769,7 @@ class Form $tmparray[$obj->rowid]['label']=$label; $i++; } - $this->cache_demand_reason=dol_sort_array($tmparray,'label', $order='asc'); + $this->cache_demand_reason=dol_sort_array($tmparray, 'label', 'asc'); unset($tmparray); return 1; @@ -1739,10 +1783,11 @@ class Form /** * Return list of events that triggered an object creation * - * @param selected Id du type d'origine pre-selectionne - * @param htmlname Nom de la zone select - * @param exclude To exclude a code value (Example: SRC_PROP) - * @param addempty Add an empty entry + * @param int $selected Id du type d'origine pre-selectionne + * @param string $htmlname Nom de la zone select + * @param string $exclude To exclude a code value (Example: SRC_PROP) + * @param int $addempty Add an empty entry + * @return void */ function select_demand_reason($selected='',$htmlname='demandreasonid',$exclude='',$addempty=0) { @@ -1786,7 +1831,7 @@ class Form $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE active > 0"; $sql.= " ORDER BY id"; - dol_syslog('Form::load_cache_types_paiements sql='.$sql,LOG_DEBUG); + dol_syslog(get_class($this)."::load_cache_types_paiements sql=".$sql,LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1816,10 +1861,11 @@ class Form /** * Retourne la liste des types de paiements possibles * - * @param selected Id du type de paiement pre-selectionne - * @param htmlname Nom de la zone select - * @param filtertype Pour filtre - * @param addempty Ajoute entree vide + * @param string $selected Id du type de paiement pre-selectionne + * @param string $htmlname Nom de la zone select + * @param string $filtertype Pour filtre + * @param int $addempty Ajoute entree vide + * @return void */ function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1,$addempty=0) { @@ -1850,19 +1896,20 @@ class Form /** * Return list of payment methods * - * @param selected Id du mode de paiement pre-selectionne - * @param htmlname Nom de la zone select - * @param filtertype To filter on field type in llx_c_paiement (array('code'=>xx,'label'=>zz)) - * @param format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code - * @param empty 1=peut etre vide, 0 sinon - * @param noadmininfo 0=Add admin info, 1=Disable admin info - * @param maxlength Max length of label + * @param string $selected Id du mode de paiement pre-selectionne + * @param string $htmlname Nom de la zone select + * @param string $filtertype To filter on field type in llx_c_paiement (array('code'=>xx,'label'=>zz)) + * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code + * @param int $empty 1=peut etre vide, 0 sinon + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $maxlength Max length of label + * @return void */ function select_types_paiements($selected='',$htmlname='paiementtype',$filtertype='',$format=0, $empty=0, $noadmininfo=0,$maxlength=0) { global $langs,$user; - dol_syslog("Form::select_type_paiements $selected, $htmlname, $filtertype, $format",LOG_DEBUG); + dol_syslog(get_class($this)."::select_type_paiements ".$selected.", ".$htmlname.", ".$filtertype.", ".$format,LOG_DEBUG); $filterarray=array(); if ($filtertype == 'CRDT') $filterarray=array(0,2); @@ -1904,8 +1951,9 @@ class Form /** * Selection HT or TTC * - * @param selected Id pre-selectionne - * @param htmlname Nom de la zone select + * @param string $selected Id pre-selectionne + * @param string $htmlname Nom de la zone select + * @return void */ function select_PriceBaseType($selected='',$htmlname='price_base_type') { @@ -1916,8 +1964,9 @@ class Form /** * Selection HT or TTC * - * @param selected Id pre-selectionne - * @param htmlname Nom de la zone select + * @param string $selected Id pre-selectionne + * @param string $htmlname Nom de la zone select + * @return void */ function load_PriceBaseType($selected='',$htmlname='price_base_type') { @@ -1927,8 +1976,8 @@ class Form $return.= ''; @@ -2682,7 +2737,7 @@ class Form print ''; print ''; print ''; print ''; print '
    '; - print $this->select_company($selected , $htmlname); + print $this->select_company($selected, $htmlname); print '
    '; @@ -2706,34 +2761,34 @@ class Form /** * Retourne la liste des devises, dans la langue de l'utilisateur * - * @param selected code devise pre-selectionne - * @param htmlname nom de la liste deroulante + * @param string $selected preselected currency code + * @param string $htmlname name of HTML select list * @return void */ function select_currency($selected='',$htmlname='currency_id') { print $this->selectcurrency($selected,$htmlname); } - + /** - * Charge dans cache la liste des devises + * Load into the cache all currencies * - * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ function load_cache_currencies() { global $langs; - + $langs->load("dict"); - + if (count($this->cache_currencies)) return 0; // Cache deja charge - - $sql = "SELECT code, code_iso, label"; + + $sql = "SELECT code_iso, label, unicode"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies"; $sql.= " WHERE active = 1"; $sql.= " ORDER BY code_iso ASC"; - - dol_syslog('Form::load_cache_currencies sql='.$sql, LOG_DEBUG); + + dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -2742,16 +2797,16 @@ class Form while ($i < $num) { $obj = $this->db->fetch_object($resql); - - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $this->cache_currencies[$obj->code]['code_iso'] = $obj->code_iso; - $this->cache_currencies[$obj->code]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); - $label[$obj->code] = $this->cache_currencies[$obj->code]['label']; + + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut + $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); + $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true); + $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label']; $i++; } - + array_multisort($label, SORT_ASC, $this->cache_currencies); - + return $num; } else @@ -2762,17 +2817,18 @@ class Form } /** - * Retourne la liste des devises, dans la langue de l'utilisateur + * Retourne la liste des devises, dans la langue de l'utilisateur * - * @param selected code devise pre-selectionne - * @param htmlname nom de la liste deroulante + * @param string $selected preselected currency code + * @param string $htmlname name of HTML select list + * @return void */ function selectcurrency($selected='',$htmlname='currency_id') { global $conf,$langs,$user; $langs->load("dict"); - + $this->load_cache_currencies(); $out=''; @@ -2780,18 +2836,18 @@ class Form if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite $out.= ''; @@ -2800,47 +2856,93 @@ class Form } /** - * Output an HTML select vat rate + * Output an HTML select vat rate * - * @param htmlname Nom champ html - * @param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage. - * @param societe_vendeuse Objet societe vendeuse - * @param societe_acheteuse Objet societe acheteuse - * @param idprod Id product - * @param info_bits Miscellaneous information on line - * @param type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) - * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. - * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. - * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. - * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle. - * Sinon la TVA proposee par defaut=0. Fin de regle. - * @deprecated - * @return void + * @param string $htmlname Nom champ html + * @param float $selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage. + * @param Societe $societe_vendeuse Object societe vendeuse + * @param Societe $societe_acheteuse Object societe acheteuse + * @param int $idprod Id product + * @param int $info_bits Miscellaneous information on line + * @param string $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) + * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. + * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. + * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. + * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle. + * Sinon la TVA proposee par defaut=0. Fin de regle. + * @return void + * @deprecated */ function select_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='') { print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type); } + /** + * Load into the cache vat rates of a country + * + * @param string $country_code Country code + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + */ + function load_cache_vatrates($country_code) + { + if (count($this->cache_vatrates)) return 0; // Cache deja charge + + $sql = "SELECT DISTINCT t.taux, t.recuperableonly"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; + $sql.= " WHERE t.fk_pays = p.rowid"; + $sql.= " AND t.active = 1"; + $sql.= " AND p.code IN (".$country_code.")"; + $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC"; + + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num) + { + for ($i = 0; $i < $num; $i++) + { + $obj = $this->db->fetch_object($resql); + $this->cache_vatrates[$i]['txtva'] = $obj->taux; + $this->cache_vatrates[$i]['libtva'] = $obj->taux.'%'; + $this->cache_vatrates[$i]['nprtva'] = $obj->recuperableonly; + } + + return $num; + } + else + { + $this->error = ''.$langs->trans("ErrorNoVATRateDefinedForSellerCountry",$code_pays).''; + return -1; + } + } + else + { + $this->error = ''.$this->db->error().''; + return -2; + } + } /** - * Output an HTML select vat rate + * Output an HTML select vat rate * - * @param htmlname Nom champ html - * @param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage. - * @param societe_vendeuse Objet societe vendeuse - * @param societe_acheteuse Objet societe acheteuse - * @param idprod Id product - * @param info_bits Miscellaneous information on line (1 for NPR) - * @param type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) - * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. - * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. - * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. - * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle. - * Sinon la TVA proposee par defaut=0. Fin de regle. - * @return void + * @param string $htmlname Nom champ html + * @param float $selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage. + * @param Societe $societe_vendeuse Objet societe vendeuse + * @param Societe $societe_acheteuse Objet societe acheteuse + * @param int $idprod Id product + * @param int $info_bits Miscellaneous information on line (1 for NPR) + * @param int $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined) + * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. + * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. + * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. + * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle. + * Sinon la TVA proposee par defaut=0. Fin de regle. + * @param bool $options_only Return options only (for ajax treatment) + * @return void */ - function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='') + function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false) { global $langs,$conf,$mysoc; @@ -2909,101 +3011,77 @@ class Form } } } - // Now we get list - $sql = "SELECT DISTINCT t.taux, t.recuperableonly"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql.= " WHERE t.fk_pays = p.rowid"; - $sql.= " AND t.active = 1"; - $sql.= " AND p.code in (".$code_pays.")"; - $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC"; - $resql=$this->db->query($sql); - if ($resql) + // Now we get list + $num = $this->load_cache_vatrates($code_pays); + + if ($num > 0) { - $num = $this->db->num_rows($resql); - if ($num) - { - for ($i = 0; $i < $num; $i++) - { - $obj = $this->db->fetch_object($resql); - $txtva[$i] = $obj->taux; - $libtva[$i] = $obj->taux.'%'; - $nprtva[$i] = $obj->recuperableonly; - } - } - else - { - $return.= ''.$langs->trans("ErrorNoVATRateDefinedForSellerCountry",$code_pays).''; - } + // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') + if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) + { + $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); + $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod); + } + + // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. + // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant + if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) + { + $defaulttx = $this->cache_vatrates[$num-1]['txtva']; + } + + if (! $options_only) $return.= ''; } else { - $return.= ''.$this->db->error().''; - } - - // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') - if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) - { - $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); - $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod); - } - - // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. - // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant - if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) - { - $defaulttx = $txtva[count($txtva)-1]; - } - - $nbdetaux = count($txtva); - if ($nbdetaux > 0) - { - $return.= ''; + $return.= $this->error; } + $this->num = $num; return $return; } /** - * Show a HTML widget to input a date or combo list for day, month, years and optionnaly hours and minutes - * Fields are preselected with : + * Show a HTML widget to input a date or combo list for day, month, years and optionnaly hours and minutes + * Fields are preselected with : * - set_time date (Local PHP server timestamps or date format YYYY-MM-DD or YYYY-MM-DD HH:MM) * - local date of PHP server if set_time is '' * - Empty (fields empty) if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param set_time Pre-selected date (must be a local PHP server timestamp) - * @param prefix Prefix for fields name - * @param h 1=Show also hours - * @param m 1=Show also minutes - * @param empty 0=Fields required, 1=Empty input is allowed - * @param form_name Form name. Used by popup dates. - * @param d 1=Show days, month, years - * @param addnowbutton Add a button "Now" - * @param nooutput Do not output html string but return it - * @param disabled Disable input fields - * @param fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 - * @return nothing or string if nooutput is 1 + * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp) + * @param string $prefix Prefix for fields name + * @param int $h 1=Show also hours + * @param int $m 1=Show also minutes + * @param int $empty 0=Fields required, 1=Empty input is allowed + * @param string $form_name Form name. Used by popup dates. + * @param int $d 1=Show days, month, years + * @param int $addnowbutton Add a button "Now" + * @param int $nooutput Do not output html string but return it + * @param int $disabled Disable input fields + * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 + * @return mixed Nothing or string if nooutput is 1 */ function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowbutton=0, $nooutput=0, $disabled=0, $fullday='') { @@ -3296,17 +3374,17 @@ class Form /** * Show a select form from an array * - * @param htmlname Name of html select area - * @param array Array with key+value - * @param id Preselected key - * @param show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon - * @param key_in_label 1 pour afficher la key dans la valeur "[key] value" - * @param value_as_key 1 to use value as key - * @param option Valeur de l'option en fonction du type choisi - * @param translate Translate and encode value - * @param maxlen Length maximum for labels - * @param disabled Html select box is disabled - * @return string HTML select string + * @param string $htmlname Name of html select area + * @param array $array Array with key+value + * @param int $id Preselected key + * @param int $show_empty 1 si il faut ajouter une valeur vide dans la liste, 0 sinon + * @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value" + * @param int $value_as_key 1 to use value as key + * @param string $option Valeur de l'option en fonction du type choisi + * @param int $translate Translate and encode value + * @param int $maxlen Length maximum for labels + * @param int $disabled Html select box is disabled + * @return string HTML select string */ function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0, $disabled=0) { @@ -3331,22 +3409,20 @@ class Form } $out.='>'; - + + $newval=($translate?$langs->trans(ucfirst($value)):$value); if ($key_in_label) { - $newval=($translate?$langs->trans($value):$value); $selectOptionValue = dol_htmlentitiesbr($key.' - '.($maxlen?dol_trunc($newval,$maxlen):$newval)); - $out.=$selectOptionValue; } else { - $newval=($translate?$langs->trans($value):$value); $selectOptionValue = dol_htmlentitiesbr($maxlen?dol_trunc($newval,$maxlen):$newval); if ($value == '' || $value == '-') { $selectOptionValue=' '; } - $out.=$selectOptionValue; } + $out.=$selectOptionValue; $out.="\n"; } } @@ -3355,22 +3431,11 @@ class Form return $out; } - /** - * Show a select form from an array - * - * @deprecated Use selectarray instead - * @return void - */ - function select_array($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0) - { - print $this->selectarray($htmlname, $array, $id, $show_empty, $key_in_label, $value_as_key, $option, $translate, $maxlen); - } - /** * Return an html string with a select combo box to choose yes or no * - * @param string $name Name of html select field + * @param string $htmlname Name of html select field * @param string $value Pre-selected value * @param int $option 0 return yes/no, 1 return 1/0 * @param bool $disabled true or false @@ -3408,12 +3473,12 @@ class Form /** - * Return list of export templates + * Return list of export templates * - * @param selected Id modele pre-selectionne - * @param htmlname Nom de la zone select - * @param type Type des modeles recherches - * @param useempty Affiche valeur vide dans liste + * @param string $selected Id modele pre-selectionne + * @param string $htmlname Name of HTML select + * @param string $type Type of searched templates + * @param int $useempty Affiche valeur vide dans liste * @return void */ function select_export_model($selected='',$htmlname='exportmodelid',$type='',$useempty=0) @@ -3591,7 +3656,7 @@ class Form { global $dolibarr_main_url_root; $ret.=''; - $ret.='Photo found on Gravatar'; + $ret.='Photo found on Gravatar'; } else { @@ -3673,7 +3738,7 @@ class Form if (is_array($include) && $includeGroups) $sql.= " AND ug.rowid IN ('".$includeGroups."')"; $sql.= " ORDER BY ug.nom ASC"; - dol_syslog("Form::select_dolgroups sql=".$sql); + dol_syslog(get_class($this)."::select_dolgroups sql=".$sql); $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 1f81f385944..52c0ce52e5f 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -211,7 +211,7 @@ class FormCompany { global $conf,$langs,$user; - dol_syslog("FormCompany::select_departement selected=$selected, country_codeid=$country_codeid",LOG_DEBUG); + dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid,LOG_DEBUG); $langs->load("dict"); @@ -226,7 +226,7 @@ class FormCompany if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND p.code = '".$country_codeid."'"; $sql .= " ORDER BY p.code, d.code_departement"; - dol_syslog("FormCompany::select_departement sql=".$sql); + dol_syslog(get_class($this)."::select_departement sql=".$sql); $result=$this->db->query($sql); if ($result) { @@ -502,14 +502,18 @@ class FormCompany /** * Return list of third parties * - * @param Object $object Object we try to find contacts - * @param string $var_id Name of id field - * @param string $selected Pre-selected third party - * @param string $htmlname Name of HTML form - * @param string $limitto Disable answers that are not id in this array list + * @param Object $object Object we try to find contacts + * @param string $var_id Name of id field + * @param string $selected Pre-selected third party + * @param string $htmlname Name of HTML form + * @param string $limitto Disable answers that are not id in this array list + * @param int $forceid This is to force antoher object id than object->id * @return void + * TODO obsolete ? + * cette fonction doit utiliser du javascript quoi qu'il en soit ! + * autant utiliser le système combobox sans rechargement de page non ? */ - function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='') + function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0) { global $conf, $langs; @@ -544,7 +548,7 @@ class FormCompany } // We call a page after a small delay when a new input has been selected - $javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;"; + $javaScript = "window.location=\'".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;"; $htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\');"'; // When we select with mouse $htmloption.= 'onKeyUp="if (event.keyCode== 13) { ac_delay(\''.$javaScript.'\',\'500\'); }"'; // When we select with keyboard @@ -570,7 +574,7 @@ class FormCompany } else { - $javaScript = "window.location='./contact.php?".$var_id."=".$object->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; + $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; print ''; + print ''; print ''; print ''; - print ''; + + if (! empty($options)) print ''; + + print ''];for(ab=0;ab0)ae.push('style="'+ag.join('; ')+'" ');ae.push('>',U[ab],'');}ae.push('');return ae.join('');},ad={role:'presentation'};W&&W.align&&(ad.align=W.align);k.dialog.uiElement.call(this,S,W||{type:'hbox'},V,'table',aa,ad,ac);},vbox:function(S,T,U,V,W){if(arguments.length<3)return;this._||(this._={});var X=this._.children=T,Y=W&&W.width||null,Z=W&&W.heights||null,aa=function(){var ab=['
    '; + print '
    '.$options.''; $max=$conf->global->MAIN_UPLOAD_DOC; // En Kb $maxphp=@ini_get('upload_max_filesize'); // En inconnu @@ -779,7 +784,7 @@ class FormFile * @param Object $object Object to use * @return void */ - private function _form_ajaxfileupload($object) + private function _formAjaxFileUpload($object) { global $langs; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 7d95b981b1a..01893919e00 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -71,7 +71,7 @@ class FormMail /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function FormMail($db) { @@ -104,7 +104,7 @@ class FormMail /** * Clear list of attached files in send mail form (stored in session) - * + * * @return void */ function clear_attached_files() @@ -564,6 +564,7 @@ class FormMail elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } + // Complete substitution array if ($conf->paypal->enabled && $conf->global->PAYPAL_ADD_PAYMENT_URL) { require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php"); @@ -573,12 +574,12 @@ class FormMail if ($this->param["models"]=='order_send') { $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); - $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrderWithPaypalLink",$url); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); } if ($this->param["models"]=='facture_send') { $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); - $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceWithPaypalLink",$url); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); } } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index c1640110553..e2d7ed35ea8 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -720,7 +720,7 @@ class FormOther } /** - * Show form to select addresse + * Show form to select address * * @param int $page Page * @param string $selected Id condition pre-selectionne @@ -733,6 +733,8 @@ class FormOther function form_address($page, $selected, $socid, $htmlname='address_id', $origin='', $originid='') { global $langs,$conf; + global $form; + if ($htmlname != "none") { print '
    '; @@ -740,7 +742,7 @@ class FormOther print ''; print ''; print ''; print ' - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>trans('AddNewLine').' - '.$langs->trans("FreeZone"); ?> + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
    trans('AddNewLine').' - '.$langs->trans("FreeZone"); ?>
    diff --git a/htdocs/core/tpl/freeproductline_edit.tpl.php b/htdocs/core/tpl/freeproductline_edit.tpl.php index 91c4824536a..ab4cc989c70 100644 --- a/htdocs/core/tpl/freeproductline_edit.tpl.php +++ b/htdocs/core/tpl/freeproductline_edit.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 2010-2012 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 @@ -34,8 +34,8 @@ > - - '];for(ab=0;ab0)ae.push('style="'+ag.join('; ')+'" ');ae.push('>',U[ab],'');}ae.push('');return ae.join('');},ad={role:'presentation'};W&&W.align&&(ad.align=W.align);k.dialog.uiElement.call(this,S,W||{type:'hbox'},V,'table',aa,ad,ac);},vbox:function(S,T,U,V,W){if(arguments.length<3)return;this._||(this._={});var X=this._.children=T,Y=W&&W.width||null,Z=W&&W.heights||null,aa=function(){var ab=['
    '; - $this->select_address($selected, $socid, $htmlname, 1); + $form->select_address($selected, $socid, $htmlname, 1); print ''; $langs->load("companies"); @@ -763,6 +765,179 @@ class FormOther } } + + + + /** + * Show a HTML Tab with boxes of a particular area including personalized choices of user + * + * @param User $user Object User + * @param String $areacode Code of area for pages (0=value for Home page) + * @return int <0 if KO, Nb of boxes shown of OK (0 to n) + */ + static function printBoxesArea($user,$areacode) + { + global $conf,$langs,$db; + + include_once(DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'); + + //$infobox=new InfoBox($db); + $boxactivated=InfoBox::listboxes($db,'activated',$areacode,$user); + $arrayboxactivatedid=array(); + foreach($boxactivated as $box) $arrayboxactivatedid[$box->id]=$box->id; + + $selectboxlist=''; + if ($conf->use_javascript_ajax) + { + $emptyuser=new User($db); + $boxavailable=InfoBox::listboxes($db,'activated',$areacode,$emptyuser,$arrayboxactivatedid); // Available here is activated for empty user + + $arrayboxtoactivatelabel=array(); + foreach($boxavailable as $box) + { + $arrayboxtoactivatelabel[$box->id]=$box->boxlabel; + } + $form=new Form($db); + + $selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel,'',1); + } + + print ''; + + print load_fiche_titre((count($boxactivated)?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes'); + + if (count($boxactivated)) + { + print ''; + print '"; + print "
    '."\n"; + + print '
    '; + + print "\n\n"; + print '
    '."\n"; + + // Define $box_max_lines + $box_max_lines=5; + if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES; + + $ii=0; + foreach ($boxactivated as $key => $box) + { + if (preg_match('/^A/i',$box->box_order)) // column A + { + $ii++; + //print 'box_id '.$boxactivated[$ii]->box_id.' '; + //print 'box_order '.$boxactivated[$ii]->box_order.'
    '; + // Affichage boite key + $box->loadBox($box_max_lines); + $box->showBox(); + } + } + + $emptybox=new ModeleBoxes($db); + $emptybox->box_id='A'; + $emptybox->info_box_head=array(); + $emptybox->info_box_contents=array(); + $emptybox->showBox(array(),array()); + + print "
    \n"; + print "\n"; + + print '
    '; + + print "\n\n"; + print '\n"; + print "\n"; + + print '
    '; + print "\n"; + + print "
    "; + + if ($conf->use_javascript_ajax) + { + print "\n"; + print ''."\n"; + } + } + + return count($boxactivated); + } + + } ?> diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php new file mode 100644 index 00000000000..622d364efd7 --- /dev/null +++ b/htdocs/core/class/infobox.class.php @@ -0,0 +1,248 @@ + + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2005-2011 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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/core/class/infobox.php + * \brief File of class to manage widget boxes + */ + +/** + * Class to manage boxes on pages + */ +class InfoBox +{ + /** + * Return array of boxes qualified for area and user + * + * @param DoliDB $db Database handler + * @param string $mode 'available' or 'activated' + * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...) + * @param User $user Objet user to filter (used only if $zone >= 0) + * @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude + * @return array Array of boxes + */ + static function listBoxes($db, $mode,$zone,$user,$excludelist=array()) + { + global $conf; + + $boxes=array(); + + $confuserzone='MAIN_BOXES_'.$zone; + if ($mode == 'activated') + { + $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; + $sql.= " d.rowid as box_id, d.file, d.note, d.tms"; + $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; + $sql.= " WHERE b.box_id = d.rowid"; + $sql.= " AND d.entity = ".$conf->entity; + if ($zone >= 0) $sql.= " AND b.position = ".$zone; + if ($user->id && $user->conf->$confuserzone) $sql.= " AND b.fk_user = ".$user->id; + else $sql.= " AND b.fk_user = 0"; + $sql.= " ORDER BY b.box_order"; + } + else + { + $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; + $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; + $sql.= " WHERE entity = ".$conf->entity; + } + + dol_syslog(get_class($this)."::listBoxes get default box list sql=".$sql, LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $j = 0; + while ($j < $num) + { + $obj = $db->fetch_object($resql); + + if (! in_array($obj->box_id, $excludelist)) + { + if (preg_match('/^([^@]+)@([^@]+)$/i',$obj->file,$regs)) + { + $boxname = $regs[1]; + $module = $regs[2]; + $relsourcefile = "/".$module."/core/boxes/".$boxname.".php"; + } + else + { + $boxname=preg_replace('/.php$/i','',$obj->file); + $relsourcefile = "/core/boxes/".$boxname.".php"; + } + + dol_include_once($relsourcefile); + if (class_exists($boxname)) + { + $box=new $boxname($db,$obj->note); + + // box properties + $box->rowid=$obj->rowid; + $box->id=$obj->box_id; + $box->position=$obj->position; + $box->box_order=$obj->box_order; + $box->fk_user=$obj->fk_user; + $box->sourcefile=$relsourcefile; + if ($mode == 'activated' && (! $user->id || ! $user->conf->$confuserzone)) + { + if (is_numeric($box->box_order)) + { + if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order; + elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order; + } + } + // box_def properties + $box->box_id=$obj->box_id; + $box->note=$obj->note; + + $enabled=true; + if ($box->depends && count($box->depends) > 0) + { + foreach($box->depends as $module) + { + //print $boxname.'-'.$module.'
    '; + if (empty($conf->$module->enabled)) $enabled=false; + } + } + if ($enabled) $boxes[]=$box; + } + } + $j++; + } + } + else + { + //dol_print_error($db); + $this->error=$db->error(); + dol_syslog(get_class($this)."::listBoxes Error ".$this->error, LOG_ERR); + return array(); + } + + return $boxes; + } + + + /** + * Save order of boxes for area and user + * + * @param DoliDB $db Database handler + * @param string $zone Name of area (0 for Homepage, ...) + * @param string $boxorder List of boxes with correct order 'A:123,456,...-B:789,321...' + * @param int $userid Id of user + * @return int <0 if KO, >= 0 if OK + */ + static function saveboxorder($db, $zone,$boxorder,$userid=0) + { + global $conf; + + $error=0; + + require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); + + dol_syslog(get_class($this)."::saveboxorder zone=".$zone." userid=".$userid); + + if (! $userid || $userid == 0) return 0; + + $user = new User($db); + $user->id=$userid; + + $db->begin(); + + // Sauve parametre indiquant que le user a une config dediee + $confuserzone='MAIN_BOXES_'.$zone; + $tab[$confuserzone]=1; + if (dol_set_user_param($db, $conf, $user, $tab) < 0) + { + $this->error=$db->lasterror(); + $db->rollback(); + return -3; + } + + // Delete all lines + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; + $sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def"; + $sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid"; + $sql.= " AND ".MAIN_DB_PREFIX."boxes_def.entity = ".$conf->entity; + $sql.= " AND ".MAIN_DB_PREFIX."boxes.fk_user = ".$userid; + $sql.= " AND ".MAIN_DB_PREFIX."boxes.position = ".$zone; + + dol_syslog(get_class($this)."::saveboxorder sql=".$sql); + $result = $db->query($sql); + if ($result) + { + $colonnes=explode('-',$boxorder); + foreach ($colonnes as $collist) + { + $part=explode(':',$collist); + $colonne=$part[0]; + $list=$part[1]; + dol_syslog(get_class($this)."::saveboxorder column=".$colonne.' list='.$list); + + $i=0; + $listarray=explode(',',$list); + foreach ($listarray as $id) + { + if (is_numeric($id)) + { + //dol_syslog("aaaaa".count($listarray)); + $i++; + $ii=sprintf('%02d',$i); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes"; + $sql.= "(box_id, position, box_order, fk_user)"; + $sql.= " values ("; + $sql.= " ".$id.","; + $sql.= " ".$zone.","; + $sql.= " '".$colonne.$ii."',"; + $sql.= " ".$userid; + $sql.= ")"; + + dol_syslog(get_class($this)."::saveboxorder sql=".$sql); + $result = $db->query($sql); + if ($result < 0) + { + $error++; + break; + } + } + } + } + if ($error) + { + $this->error=$db->error(); + $db->rollback(); + return -2; + } + else + { + $db->commit(); + return 1; + } + } + else + { + $this->error=$db->lasterror(); + $db->rollback(); + dol_syslog(get_class($this)."::saveboxorder ".$this->error); + return -1; + } + } + +} + +?> diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index d311c7bee4a..b64dcb58881 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -50,7 +50,7 @@ class Interfaces * @param string $action Trigger event code * @param Object $object Objet concern * @param User $user Objet user - * @param Lang $lang Objet lang + * @param Lang $langs Objet lang * @param Conf $conf Objet conf * @return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise. */ diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 0c9492793f5..8ed2d0cbbb6 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -141,7 +141,8 @@ class Ldap * anonymously, it creates an error code of -1. Returns true if connected, * false if failed. Takes an array of possible servers - if one doesn't work, * it tries the next and so on. - * + * + * @return void * @deprecated Utiliser connect_bind a la place */ function connect() @@ -184,7 +185,7 @@ class Ldap * Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType, this->searchUser, this->searchPassword * After return, this->connection and $this->bind are defined * - * @return int <0 si KO, 1 si bind anonymous, 2 si bind auth + * @return int <0 if KO, 1 if bind anonymous, 2 if bind auth */ function connect_bind() { @@ -285,7 +286,7 @@ class Ldap /** * Simply closes the connection set up earlier. * Returns true if OK, false if there was an error. - * + * * @return boolean true or false */ function close() @@ -303,7 +304,7 @@ class Ldap /** * Anonymously binds to the connection. After this is done, * queries and searches can be done - but read-only. - * + * * @return boolean true or false */ function bind() @@ -328,12 +329,12 @@ class Ldap * like "uid=jbloggs,ou=People,dc=foo,dc=com". * * @param string $bindDn DN - * @param string $pass Password + * @param string $pass Password * @return boolean true or false */ function bindauth($bindDn,$pass) { - if (! $this->result = @ldap_bind( $this->connection,$bindDn,$pass)) + if (! $this->result = @ldap_bind($this->connection, $bindDn, $pass)) { $this->ldapErrorCode = ldap_errno($this->connection); $this->ldapErrorText = ldap_error($this->connection); @@ -348,7 +349,7 @@ class Ldap /** * Unbind du serveur ldap. - * + * * @return boolean true or false */ function unbind() @@ -364,7 +365,7 @@ class Ldap /** * Verification de la version du serveur ldap. - * + * * @return string version */ function getVersion() @@ -376,7 +377,7 @@ class Ldap /** * Change ldap protocol version to use. - * + * * @return string version */ function setVersion() { @@ -387,7 +388,7 @@ class Ldap /** * changement du referrals. - * + * * @return string referrals */ function setReferrals() { @@ -400,7 +401,7 @@ class Ldap /** * Add a LDAP entry * Ldap object connect and bind must have been done - * + * * @param string $dn DN entry key * @param string $info Attributes array * @param User $user Objet user that create @@ -452,7 +453,7 @@ class Ldap /** * Modify a LDAP entry * Ldap object connect and bind must have been done - * + * * @param string $dn DN entry key * @param string $info Attributes array * @param string $user Objet user that modify @@ -504,7 +505,7 @@ class Ldap /** * Modify a LDAP entry (to use if dn != olddn) * Ldap object connect and bind must have been done - * + * * @param string $dn DN entry key * @param string $info Attributes array * @param User $user Objet user that delete @@ -559,7 +560,7 @@ class Ldap /** * Delete a LDAP entry * Ldap object connect and bind must have been done - * + * * @param string $dn DN entry key * @return int <0 if KO, >0 if OK */ @@ -592,7 +593,7 @@ class Ldap /** * Build a LDAP message - * + * * @param string $dn DN entry key * @param string $info Attributes array * @return string Content of file @@ -634,7 +635,7 @@ class Ldap /** * Dump a LDAP message to ldapinput.in file - * + * * @param string $dn DN entry key * @param string $info Attributes array * @return int <0 if KO, >0 if OK @@ -671,7 +672,7 @@ class Ldap /** * Add a LDAP attribute in entry * Ldap object connect and bind must have been done - * + * * @param string $dn DN entry key * @param string $info Attributes array * @param User $user Objet user that create @@ -723,7 +724,7 @@ class Ldap /** * Update a LDAP attribute in entry * Ldap object connect and bind must have been done - * + * * @param string $dn DN entry key * @param string $info Attributes array * @param User $user Objet user that create @@ -775,7 +776,7 @@ class Ldap /** * Delete a LDAP attribute in entry * Ldap object connect and bind must have been done - * + * * @param string $dn DN entry key * @param string $info Attributes array * @param User $user Objet user that create @@ -826,10 +827,10 @@ class Ldap /** * Returns an array containing attributes and values for first record - * + * * @param string $dn DN entry key * @param string $filter Filter - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ function getAttribute($dn,$filter) { @@ -858,7 +859,7 @@ class Ldap } // Get values - if (! $values = ldap_get_attributes( $this->connection, $entry)) + if (! $values = ldap_get_attributes($this->connection, $entry)) { $this->ldapErrorCode = ldap_errno($this->connection); $this->ldapErrorText = ldap_error($this->connection); @@ -871,7 +872,7 @@ class Ldap /** * Returns an array containing values for an attribute and for first record matching filterrecord - * + * * @param string $filterrecord Record * @param string $attribute Attributes * @return void @@ -897,7 +898,7 @@ class Ldap } // Get values - if (! $values = @ldap_get_values( $this->connection, $entry, $attribute)) + if (! $values = @ldap_get_values($this->connection, $entry, $attribute)) { $this->ldapErrorCode = ldap_errno($this->connection); $this->ldapErrorText = ldap_error($this->connection); @@ -911,7 +912,7 @@ class Ldap /** * Returns an array containing a details of elements * ldapsearch -LLLx -hlocalhost -Dcn=admin,dc=parinux,dc=org -w password -b "ou=adherents,ou=people,dc=parinux,dc=org" userPassword - * + * * @param string $search Valeur champ cle recherche, sinon '*' pour tous. * @param string $userDn DN (Ex: ou=adherents,ou=people,dc=parinux,dc=org) * @param string $useridentifier Name of key field (Ex: uid) @@ -1010,9 +1011,10 @@ class Ldap * Converts a little-endian hex-number to one, that 'hexdec' can convert * Required by Active Directory * - * @param string $hex + * @param string $hex Hex value + * @return string Little endian */ - function littleEndian($hex) + function littleEndian($hex) { for ($x=dol_strlen($hex)-2; $x >= 0; $x=$x-2) { $result .= substr($hex,$x,2); @@ -1022,10 +1024,11 @@ class Ldap /** - * Recupere le SID de l'utilisateur + * Recupere le SID de l'utilisateur * Required by Active Directory - * + * * @param string $ldapuser Login de l'utilisateur + * @return string Sid */ function getObjectSid($ldapUser) { @@ -1055,7 +1058,7 @@ class Ldap if (!$entry) { - // Si pas de r�sultat on cherche dans le domaine + // Si pas de resultat on cherche dans le domaine $searchDN = $this->domain; $i++; } @@ -1068,7 +1071,7 @@ class Ldap if ($entry) { - $ldapBinary = ldap_get_values_len ($this->connection, $entry, "objectsid"); + $ldapBinary = ldap_get_values_len($this->connection, $entry, "objectsid"); $SIDText = $this->binSIDtoText($ldapBinary[0]); return $SIDText; } @@ -1082,11 +1085,11 @@ class Ldap /** * Returns the textual SID * Indispensable pour Active Directory - * + * * @param string $binsid Binary SID * @return string Textual SID */ - function binSIDtoText($binsid) + function binSIDtoText($binsid) { $hex_sid=bin2hex($binsid); $rev = hexdec(substr($hex_sid,0,2)); // Get revision-part of SID @@ -1108,9 +1111,9 @@ class Ldap * car conflit majuscule-minuscule. A n'utiliser que pour les pages * 'Fiche LDAP' qui affiche champ lisibles par defaut. * - * @param checkDn DN de recherche (Ex: ou=users,cn=my-domain,cn=com) - * @param filter Filtre de recherche (ex: (sn=nom_personne) ) - * @return array Tableau des reponses (cle en minuscule-valeur) + * @param string $checkDn DN de recherche (Ex: ou=users,cn=my-domain,cn=com) + * @param string $filter Filtre de recherche (ex: (sn=nom_personne) ) + * @return array Tableau des reponses (cle en minuscule-valeur) */ function search($checkDn, $filter) { @@ -1142,7 +1145,7 @@ class Ldap /** * Load all attribute of a LDAP user - * + * * @param User $user User to search for. Not used if a filter is provided. * @param string $filter Filter for search. Must start with &. * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) @@ -1237,10 +1240,10 @@ class Ldap /** * Returns the correct user identifier to use, based on the ldap server type - * - * @return string Login + * + * @return string Login */ - function getUserIdentifier() + function getUserIdentifier() { if ($this->serverType == "activedirectory") { return $this->attr_sambalogin; @@ -1255,7 +1258,7 @@ class Ldap * @param string $uacf UACF * @return void */ - function parseUACF($uacf) + function parseUACF($uacf) { //All flags array $flags = array( "TRUSTED_TO_AUTH_FOR_DELEGATION" => 16777216, @@ -1299,7 +1302,7 @@ class Ldap * @param string $samtype SamType * @return string Sam string */ - function parseSAT($samtype) + function parseSAT($samtype) { $stypes = array( 805306368 => "NORMAL_ACCOUNT", 805306369 => "WORKSTATION_TRUST", diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index e4024f77366..50f906b1118 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2009-2010 Regis Houssin +/* Copyright (C) 2007-2009 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -525,9 +525,9 @@ class Menubase $sql = "SELECT m.rowid, m.type, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu"; $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; $sql.= " WHERE m.entity = ".$conf->entity; - $sql.= " AND m.menu_handler in('".$menu_handler."','all')"; - if ($type_user == 0) $sql.= " AND m.usertype in (0,2)"; - if ($type_user == 1) $sql.= " AND m.usertype in (1,2)"; + $sql.= " AND m.menu_handler IN ('".$menu_handler."','all')"; + if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)"; + if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)"; // If type_user == 2, no test required $sql.= " ORDER BY m.position, m.rowid"; @@ -578,6 +578,13 @@ class Menubase $tab_titre = explode("/",$menu['titre']); $title = $langs->trans($tab_titre[0])."/".$langs->trans($tab_titre[1]); } + else if (preg_match('/\|\|/',$menu['titre'])) // To manage different translation + { + $tab_title = explode("||",$menu['titre']); + $alt_title = explode("@",$tab_title[1]); + $title_enabled = verifCond($alt_title[1]); + $title = ($title_enabled ? $langs->trans($alt_title[0]) : $langs->trans($tab_title[0])); + } else { $title = $langs->trans($menu['titre']); diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index dfa1cb857b4..06d3eb057c4 100755 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -25,18 +25,18 @@ class RssParser var $db; var $error; - protected $_format=''; - protected $_urlRSS; - protected $_language; - protected $_generator; - protected $_copyright; - protected $_lastbuilddate; - protected $_imageurl; - protected $_link; - protected $_title; - protected $_description; - protected $_lastfetchdate; // Last successful fetch - protected $_rssarray=array(); + private $_format=''; + private $_urlRSS; + private $_language; + private $_generator; + private $_copyright; + private $_lastbuilddate; + private $_imageurl; + private $_link; + private $_title; + private $_description; + private $_lastfetchdate; // Last successful fetch + private $_rssarray=array(); /** * getFormat diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 671f67fe964..f9a0ef83b66 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -17,14 +17,13 @@ */ /** - * \file htdocs/core/class/stats.class.php - * \ingroup core - * \brief Common class to manage statistics reports + * \file htdocs/core/class/stats.class.php + * \ingroup core + * \brief Common class to manage statistics reports */ /** - * \class Stats - * \brief Parent class of statistics class + * Parent class of statistics class */ abstract class Stats { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 8b444f5a0a9..2a1f5051611 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -338,11 +338,7 @@ class Translate { global $db; $newstr=$key; - if (preg_match('/^CurrencySing([A-Z][A-Z][A-Z])$/i',$key,$reg)) - { - $newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','labelsing'); - } - else if (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i',$key,$reg)) + if (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i',$key,$reg)) { $newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','label'); } diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index 5b800867298..11a131819b0 100755 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -85,8 +85,7 @@ function dol_quoted_printable_encode($input, $line_max=76) /** - * \class vCard - * \brief Class to buld vCard files + * Class to buld vCard files */ class vCard { diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index dca5f86b829..54f811ef3e8 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -115,8 +115,14 @@ else print ''."\n"; - -function xyzToUnixTimestamp($mysqldate){ +/** + * Convert date to timestamp + * + * @param string $mysqldate Date YYYMMDD + * @return timestamp Timestamp + */ +function xyzToUnixTimestamp($mysqldate) +{ $year=substr($mysqldate,0,4); $month=substr($mysqldate,4,2); $day=substr($mysqldate,6,2); @@ -124,6 +130,14 @@ function xyzToUnixTimestamp($mysqldate){ return $unixtimestamp; } +/** + * Show box + * + * @param string $selectedDate Date YYYMMDD + * @param int $month Month + * @param int $year Year + * @return void + */ function displayBox($selectedDate,$month,$year) { global $langs,$conf; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 55cf0168bf4..3fbda6c3613 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -83,9 +83,10 @@ class DoliDBMysqli function DoliDBMysqli($type, $host, $user, $pass, $name='', $port=0) { global $conf,$langs; - - if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set; - if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; + + // TODO error in strict mode (static property for "$forcecharset" and "$forcecollate") + //if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set; + //if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; $this->database_user=$user; @@ -142,7 +143,7 @@ class DoliDBMysqli $clientmustbe=''; if (preg_match('/UTF-8/i',$conf->file->character_set_client)) $clientmustbe='utf8'; if (preg_match('/ISO-8859-1/i',$conf->file->character_set_client)) $clientmustbe='latin1'; - if (mysqli_client_encoding($this->db) != $clientmustbe) + if (mysqli_character_set_name($this->db) != $clientmustbe) { $this->query("SET NAMES '".$clientmustbe."'", $this->db); //$this->query("SET CHARACTER SET ". $this->forcecharset); @@ -168,7 +169,7 @@ class DoliDBMysqli $clientmustbe=''; if (preg_match('/UTF-8/i',$conf->file->character_set_client)) $clientmustbe='utf8'; if (preg_match('/ISO-8859-1/i',$conf->file->character_set_client)) $clientmustbe='latin1'; - if (mysqli_client_encoding($this->db) != $clientmustbe) + if (mysqli_character_set_name($this->db) != $clientmustbe) { $this->query("SET NAMES '".$clientmustbe."'", $this->db); //$this->query("SET CHARACTER SET ". $this->forcecharset); @@ -232,16 +233,6 @@ class DoliDBMysqli return $this->db; } - /** - * Return label of manager - * - * @return string Label - */ - function getLabel() - { - return $this->label; - } - /** * Return version of database server * diff --git a/htdocs/core/filemanagerdol/browser/default/browser.php b/htdocs/core/filemanagerdol/browser/default/browser.php index bd308aa4eda..497ab68055c 100755 --- a/htdocs/core/filemanagerdol/browser/default/browser.php +++ b/htdocs/core/filemanagerdol/browser/default/browser.php @@ -1,197 +1,197 @@ - - * Copyright (C) 2003-2010 Frederico Caldeira Knabben - * - * Source modified from part of fckeditor (http://www.fckeditor.net) - * retreived as GPL v2 or later - * - * 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 2 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 . - */ - -require('../../../../main.inc.php'); -?> - - - - FCKeditor - Resources Browser - - - - - - - - - - - - - - - - - + + * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * + * Source modified from part of fckeditor (http://www.fckeditor.net) + * retreived as GPL v2 or later + * + * 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 2 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 . + */ + +require('../../../../main.inc.php'); +?> + + + + FCKeditor - Resources Browser + + + + + + + + + + + + + + + + + diff --git a/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php b/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php index 982143e0a28..d51a0043da8 100755 --- a/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php +++ b/htdocs/core/filemanagerdol/browser/default/frmactualfolder.php @@ -1,117 +1,118 @@ - - * Copyright (C) 2003-2010 Frederico Caldeira Knabben - * - * Source modified from part of fckeditor (http://www.fckeditor.net) - * retreived as GPL v2 or later - * - * 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 2 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 . - */ - -require('../../../../main.inc.php'); ?> - - - - - Folder path - - - - - - - - - -
    - -
    - - + + * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * + * Source modified from part of fckeditor (http://www.fckeditor.net) + * retreived as GPL v2 or later + * + * 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 2 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 . + */ + +require('../../../../main.inc.php'); +?> + + + + + Folder path + + + + + + + + + +
    + +
    + + diff --git a/htdocs/core/filemanagerdol/browser/default/frmcreatefolder.php b/htdocs/core/filemanagerdol/browser/default/frmcreatefolder.php index f90a81adc5b..867fecf73b4 100755 --- a/htdocs/core/filemanagerdol/browser/default/frmcreatefolder.php +++ b/htdocs/core/filemanagerdol/browser/default/frmcreatefolder.php @@ -1,136 +1,137 @@ - - * Copyright (C) 2003-2010 Frederico Caldeira Knabben - * - * Source modified from part of fckeditor (http://www.fckeditor.net) - * retreived as GPL v2 or later - * - * 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 2 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 . - */ - -require('../../../../main.inc.php'); ?> - - - - - Create Folder - - - - - - - - - - -
    - -
    - - + + * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * + * Source modified from part of fckeditor (http://www.fckeditor.net) + * retreived as GPL v2 or later + * + * 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 2 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 . + */ + +require('../../../../main.inc.php'); +?> + + + + + Create Folder + + + + + + + + + + +
    + +
    + + diff --git a/htdocs/core/filemanagerdol/browser/default/frmfolders.php b/htdocs/core/filemanagerdol/browser/default/frmfolders.php index 3978fb2d1f3..ccb67f9ecf2 100755 --- a/htdocs/core/filemanagerdol/browser/default/frmfolders.php +++ b/htdocs/core/filemanagerdol/browser/default/frmfolders.php @@ -1,224 +1,225 @@ - - * Copyright (C) 2003-2010 Frederico Caldeira Knabben - * - * Source modified from part of fckeditor (http://www.fckeditor.net) - * retreived as GPL v2 or later - * - * 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 2 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 . - */ - -require('../../../../main.inc.php'); ?> - - - - - - Folders - - - - - - - - - - - -
    - - + + * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * + * Source modified from part of fckeditor (http://www.fckeditor.net) + * retreived as GPL v2 or later + * + * 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 2 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 . + */ + +require('../../../../main.inc.php'); +?> + + + + + + Folders + + + + + + + + + + + +
    + + diff --git a/htdocs/core/filemanagerdol/browser/default/frmresourceslist.php b/htdocs/core/filemanagerdol/browser/default/frmresourceslist.php index e065c4d7107..ff497db02c4 100755 --- a/htdocs/core/filemanagerdol/browser/default/frmresourceslist.php +++ b/htdocs/core/filemanagerdol/browser/default/frmresourceslist.php @@ -1,205 +1,206 @@ - - * Copyright (C) 2003-2010 Frederico Caldeira Knabben - * - * Source modified from part of fckeditor (http://www.fckeditor.net) - * retreived as GPL v2 or later - * - * 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 2 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 . - */ - -require('../../../../main.inc.php'); ?> - - - - - Resources - - - - - - - - + + * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * + * Source modified from part of fckeditor (http://www.fckeditor.net) + * retreived as GPL v2 or later + * + * 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 2 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 . + */ + +require('../../../../main.inc.php'); +?> + + + + + Resources + + + + + + + + diff --git a/htdocs/core/filemanagerdol/browser/default/frmupload.php b/htdocs/core/filemanagerdol/browser/default/frmupload.php index a6ac4ddfa8b..20e30651eb5 100755 --- a/htdocs/core/filemanagerdol/browser/default/frmupload.php +++ b/htdocs/core/filemanagerdol/browser/default/frmupload.php @@ -1,137 +1,138 @@ - - * Copyright (C) 2003-2010 Frederico Caldeira Knabben - * - * Source modified from part of fckeditor (http://www.fckeditor.net) - * retreived as GPL v2 or later - * - * 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 2 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 . - */ - -require('../../../../main.inc.php'); ?> - - - - - File Upload - - - - - - - - - - - -
    - Upload a new file in this folder
    - - - - - -
     
    -
    - - - + + * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * + * Source modified from part of fckeditor (http://www.fckeditor.net) + * retreived as GPL v2 or later + * + * 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 2 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 . + */ + +require('../../../../main.inc.php'); +?> + + + + + File Upload + + + + + + +
    + + + + +
    + Upload a new file in this folder
    + + + + + +
     
    +
    +
    + + diff --git a/htdocs/core/filemanagerdol/connectors/php/basexml.php b/htdocs/core/filemanagerdol/connectors/php/basexml.php index d0f377c34fc..4098375a255 100755 --- a/htdocs/core/filemanagerdol/connectors/php/basexml.php +++ b/htdocs/core/filemanagerdol/connectors/php/basexml.php @@ -1,99 +1,104 @@ -' ; - - // Create the main "Connector" node. - echo '' ; - - // Add the current folder node. - echo '' ; - - $GLOBALS['HeaderSent'] = true ; -} - -function CreateXmlFooter() -{ - echo '' ; -} - -function SendError( $number, $text ) -{ - if ( $_GET['Command'] == 'FileUpload' ) - SendUploadResults( $number, "", "", $text ); - - if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] ) - { - SendErrorNode( $number, $text ); - CreateXmlFooter(); - } - else - { - SetXmlHeaders(); - - // Create the XML document header - echo '' ; - - echo '' ; - - SendErrorNode( $number, $text ); - - echo '' ; - } - exit ; -} - -function SendErrorNode( $number, $text ) -{ - if ($text) - echo '' ; - else - echo '' ; -} -?> +' ; + + // Create the main "Connector" node. + echo '' ; + + // Add the current folder node. + echo '' ; + + $GLOBALS['HeaderSent'] = true ; +} + +function CreateXmlFooter() +{ + echo '' ; +} + +function SendError( $number, $text ) +{ + if ( $_GET['Command'] == 'FileUpload' ) + SendUploadResults( $number, "", "", $text ); + + if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] ) + { + SendErrorNode( $number, $text ); + CreateXmlFooter(); + } + else + { + SetXmlHeaders(); + + // Create the XML document header + echo '' ; + + echo '' ; + + SendErrorNode( $number, $text ); + + echo '' ; + } + exit ; +} + +function SendErrorNode( $number, $text ) +{ + if ($text) + echo '' ; + else + echo '' ; +} +?> diff --git a/htdocs/core/filemanagerdol/connectors/php/commands.php b/htdocs/core/filemanagerdol/connectors/php/commands.php index 1b7946848e8..6c01cb343fe 100755 --- a/htdocs/core/filemanagerdol/connectors/php/commands.php +++ b/htdocs/core/filemanagerdol/connectors/php/commands.php @@ -1,299 +1,300 @@ -' ; - } - closedir( $oCurrentFolder ); - } - - // Open the "Folders" node. - echo "" ; - - natcasesort( $aFolders ); - foreach ( $aFolders as $sFolder ) - echo $sFolder ; - - // Close the "Folders" node. - echo "" ; -} - -function GetFoldersAndFiles( $resourceType, $currentFolder ) -{ - // Map the virtual path to the local server path. - $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFoldersAndFiles' ); - - // Arrays that will hold the folders and files names. - $aFolders = array(); - $aFiles = array(); - - $oCurrentFolder = @opendir( $sServerDir ); - - if ($oCurrentFolder !== false) - { - while ( $sFile = readdir( $oCurrentFolder ) ) - { - if ( $sFile != '.' && $sFile != '..' ) - { - if ( is_dir( $sServerDir . $sFile ) ) - $aFolders[] = '' ; - else - { - $iFileSize = @filesize( $sServerDir . $sFile ); - if ( !$iFileSize ) { - $iFileSize = 0 ; - } - if ( $iFileSize > 0 ) - { - $iFileSize = round( $iFileSize / 1024 ); - if ( $iFileSize < 1 ) - $iFileSize = 1 ; - } - - $aFiles[] = '' ; - } - } - } - closedir( $oCurrentFolder ); - } - - // Send the folders - natcasesort( $aFolders ); - echo '' ; - - foreach ( $aFolders as $sFolder ) - echo $sFolder ; - - echo '' ; - - // Send the files - natcasesort( $aFiles ); - echo '' ; - - foreach ( $aFiles as $sFiles ) - echo $sFiles ; - - echo '' ; -} - -function CreateFolder( $resourceType, $currentFolder ) -{ - if (!isset($_GET)) { - global $_GET; - } - $sErrorNumber = '0' ; - $sErrorMsg = '' ; - - if ( isset( $_GET['NewFolderName'] ) ) - { - $sNewFolderName = $_GET['NewFolderName'] ; - $sNewFolderName = SanitizeFolderName( $sNewFolderName ); - - if ( strpos( $sNewFolderName, '..' ) !== FALSE ) - $sErrorNumber = '102' ; // Invalid folder name. - else - { - // Map the virtual path to the local server path of the current folder. - $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'CreateFolder' ); - - if ( is_writable( $sServerDir ) ) - { - $sServerDir .= $sNewFolderName ; - - $sErrorMsg = CreateServerFolder( $sServerDir ); - - switch ( $sErrorMsg ) - { - case '' : - $sErrorNumber = '0' ; - break ; - case 'Invalid argument' : - case 'No such file or directory' : - $sErrorNumber = '102' ; // Path too long. - break ; - default : - $sErrorNumber = '110' ; - break ; - } - } - else - $sErrorNumber = '103' ; - } - } - else - $sErrorNumber = '102' ; - - // Create the "Error" node. - echo '' ; -} - -// DOL_CHANGE -//function FileUpload( $resourceType, $currentFolder, $sCommand ) -function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') -{ - if (!isset($_FILES)) { - global $_FILES; - } - $sErrorNumber = '0' ; - $sFileName = '' ; - - if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) - # This is for the QuickUpload tab box - or (isset($_FILES['upload']) and !is_null($_FILES['upload']['tmp_name']))) - { - global $Config ; - - $oFile = isset($_FILES['NewFile']) ? $_FILES['NewFile'] : $_FILES['upload']; - - // Map the virtual path to the local server path. - $sServerDir = ServerMapFolder( $resourceType, $currentFolder, $sCommand ); - - // Get the uploaded file name. - $sFileName = $oFile['name'] ; - $sFileName = SanitizeFileName( $sFileName ); - - $sOriginalFileName = $sFileName ; - - // Get the extension. - $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ); - $sExtension = strtolower( $sExtension ); - - if ( isset( $Config['SecureImageUploads'] ) ) - { - if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false ) - { - $sErrorNumber = '202' ; - } - } - - if ( isset( $Config['HtmlExtensions'] ) ) - { - if ( !IsHtmlExtension( $sExtension, $Config['HtmlExtensions'] ) && - ( $detectHtml = DetectHtml( $oFile['tmp_name'] ) ) === true ) - { - $sErrorNumber = '202' ; - } - } - - // Check if it is an allowed extension. - if ( !$sErrorNumber && IsAllowedExt( $sExtension, $resourceType ) ) - { - $iCounter = 0 ; - - while ( true ) - { - $sFilePath = $sServerDir . $sFileName ; - - if ( is_file( $sFilePath ) ) - { - $iCounter++ ; - $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ; - $sErrorNumber = '201' ; - } - else - { - move_uploaded_file( $oFile['tmp_name'], $sFilePath ); - - if ( is_file( $sFilePath ) ) - { - if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] ) - { - break ; - } - - $permissions = 0777; - - if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] ) - { - $permissions = $Config['ChmodOnUpload'] ; - } - - $oldumask = umask(0); - chmod( $sFilePath, $permissions ); - umask( $oldumask ); - } - - break ; - } - } - - if ( file_exists( $sFilePath ) ) - { - //previous checks failed, try once again - if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid( $sFilePath, $sExtension ) === false ) - { - @unlink( $sFilePath ); - $sErrorNumber = '202' ; - } - else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml( $sFilePath ) === true ) - { - @unlink( $sFilePath ); - $sErrorNumber = '202' ; - } - } - } - else - $sErrorNumber = '202' ; - } - else - $sErrorNumber = '202' ; - - - $sFileUrl = CombinePaths( GetResourceTypePath( $resourceType, $sCommand ) , $currentFolder ); - $sFileUrl = CombinePaths( $sFileUrl, $sFileName ); - - - // DOL_CHANGE - //SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ); - if($CKEcallback == '') - { - // this line already exists so wrap the if block around it - SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ); - } - else - { - //issue the CKEditor Callback - SendCKEditorResults ($CKEcallback, $sFileUrl, - ($sErrorNumber != 0 - ? 'Error '. $sErrorNumber. ' upload failed.' - : 'Upload Successful')); - } - - exit ; -} -?> +' ; + } + closedir( $oCurrentFolder ); + } + + // Open the "Folders" node. + echo "" ; + + natcasesort( $aFolders ); + foreach ( $aFolders as $sFolder ) + echo $sFolder ; + + // Close the "Folders" node. + echo "" ; +} + +function GetFoldersAndFiles( $resourceType, $currentFolder ) +{ + // Map the virtual path to the local server path. + $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFoldersAndFiles' ); + + // Arrays that will hold the folders and files names. + $aFolders = array(); + $aFiles = array(); + + $oCurrentFolder = @opendir( $sServerDir ); + + if ($oCurrentFolder !== false) + { + while ( $sFile = readdir( $oCurrentFolder ) ) + { + if ( $sFile != '.' && $sFile != '..' ) + { + if ( is_dir( $sServerDir . $sFile ) ) + $aFolders[] = '' ; + else + { + $iFileSize = @filesize( $sServerDir . $sFile ); + if ( !$iFileSize ) { + $iFileSize = 0 ; + } + if ( $iFileSize > 0 ) + { + $iFileSize = round( $iFileSize / 1024 ); + if ( $iFileSize < 1 ) + $iFileSize = 1 ; + } + + $aFiles[] = '' ; + } + } + } + closedir( $oCurrentFolder ); + } + + // Send the folders + natcasesort( $aFolders ); + echo '' ; + + foreach ( $aFolders as $sFolder ) + echo $sFolder ; + + echo '' ; + + // Send the files + natcasesort( $aFiles ); + echo '' ; + + foreach ( $aFiles as $sFiles ) + echo $sFiles ; + + echo '' ; +} + +function CreateFolder( $resourceType, $currentFolder ) +{ + if (!isset($_GET)) { + global $_GET; + } + $sErrorNumber = '0' ; + $sErrorMsg = '' ; + + if ( isset( $_GET['NewFolderName'] ) ) + { + $sNewFolderName = $_GET['NewFolderName'] ; + $sNewFolderName = SanitizeFolderName( $sNewFolderName ); + + if ( strpos( $sNewFolderName, '..' ) !== FALSE ) + $sErrorNumber = '102' ; // Invalid folder name. + else + { + // Map the virtual path to the local server path of the current folder. + $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'CreateFolder' ); + + if ( is_writable( $sServerDir ) ) + { + $sServerDir .= $sNewFolderName ; + + $sErrorMsg = CreateServerFolder( $sServerDir ); + + switch ( $sErrorMsg ) + { + case '' : + $sErrorNumber = '0' ; + break ; + case 'Invalid argument' : + case 'No such file or directory' : + $sErrorNumber = '102' ; // Path too long. + break ; + default : + $sErrorNumber = '110' ; + break ; + } + } + else + $sErrorNumber = '103' ; + } + } + else + $sErrorNumber = '102' ; + + // Create the "Error" node. + echo '' ; +} + +// DOL_CHANGE +//function FileUpload( $resourceType, $currentFolder, $sCommand ) +function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') +{ + if (!isset($_FILES)) { + global $_FILES; + } + $sErrorNumber = '0' ; + $sFileName = '' ; + + if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) + # This is for the QuickUpload tab box + or (isset($_FILES['upload']) and !is_null($_FILES['upload']['tmp_name']))) + { + global $Config ; + + $oFile = isset($_FILES['NewFile']) ? $_FILES['NewFile'] : $_FILES['upload']; + + // Map the virtual path to the local server path. + $sServerDir = ServerMapFolder( $resourceType, $currentFolder, $sCommand ); + + // Get the uploaded file name. + $sFileName = $oFile['name'] ; + $sFileName = SanitizeFileName( $sFileName ); + + $sOriginalFileName = $sFileName ; + + // Get the extension. + $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ); + $sExtension = strtolower( $sExtension ); + + if ( isset( $Config['SecureImageUploads'] ) ) + { + if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false ) + { + $sErrorNumber = '202' ; + } + } + + if ( isset( $Config['HtmlExtensions'] ) ) + { + if ( !IsHtmlExtension( $sExtension, $Config['HtmlExtensions'] ) && + ( $detectHtml = DetectHtml( $oFile['tmp_name'] ) ) === true ) + { + $sErrorNumber = '202' ; + } + } + + // Check if it is an allowed extension. + if ( !$sErrorNumber && IsAllowedExt( $sExtension, $resourceType ) ) + { + $iCounter = 0 ; + + while ( true ) + { + $sFilePath = $sServerDir . $sFileName ; + + if ( is_file( $sFilePath ) ) + { + $iCounter++ ; + $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ; + $sErrorNumber = '201' ; + } + else + { + move_uploaded_file( $oFile['tmp_name'], $sFilePath ); + + if ( is_file( $sFilePath ) ) + { + if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] ) + { + break ; + } + + $permissions = 0777; + + if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] ) + { + $permissions = $Config['ChmodOnUpload'] ; + } + + $oldumask = umask(0); + chmod( $sFilePath, $permissions ); + umask( $oldumask ); + } + + break ; + } + } + + if ( file_exists( $sFilePath ) ) + { + //previous checks failed, try once again + if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid( $sFilePath, $sExtension ) === false ) + { + @unlink( $sFilePath ); + $sErrorNumber = '202' ; + } + else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml( $sFilePath ) === true ) + { + @unlink( $sFilePath ); + $sErrorNumber = '202' ; + } + } + } + else + $sErrorNumber = '202' ; + } + else + $sErrorNumber = '202' ; + + + $sFileUrl = CombinePaths( GetResourceTypePath( $resourceType, $sCommand ) , $currentFolder ); + $sFileUrl = CombinePaths( $sFileUrl, $sFileName ); + + + // DOL_CHANGE + //SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ); + if($CKEcallback == '') + { + // this line already exists so wrap the if block around it + SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ); + } + else + { + //issue the CKEditor Callback + SendCKEditorResults ( + $CKEcallback, + $sFileUrl, + ($sErrorNumber != 0 ? 'Error '. $sErrorNumber. ' upload failed.' : 'Upload Successful') + ); + } + + exit ; +} +?> diff --git a/htdocs/core/filemanagerdol/connectors/php/config.php b/htdocs/core/filemanagerdol/connectors/php/config.php index 87dc899465c..3248335120c 100755 --- a/htdocs/core/filemanagerdol/connectors/php/config.php +++ b/htdocs/core/filemanagerdol/connectors/php/config.php @@ -1,163 +1,163 @@ - + diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.php b/htdocs/core/filemanagerdol/connectors/php/connector.php index 6f302c6ef53..af720849a79 100755 --- a/htdocs/core/filemanagerdol/connectors/php/connector.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.php @@ -1,87 +1,87 @@ - + diff --git a/htdocs/core/filemanagerdol/connectors/php/io.php b/htdocs/core/filemanagerdol/connectors/php/io.php index aa957e53fc5..ed329ec13a4 100755 --- a/htdocs/core/filemanagerdol/connectors/php/io.php +++ b/htdocs/core/filemanagerdol/connectors/php/io.php @@ -1,320 +1,320 @@ - 0 ) - return $Config['QuickUploadAbsolutePath'][$resourceType] ; - - // Map the "UserFiles" path to a local directory. - return Server_MapPath( $Config['QuickUploadPath'][$resourceType] ); - } - else - { - if ( strlen( $Config['FileTypesAbsolutePath'][$resourceType] ) > 0 ) - return $Config['FileTypesAbsolutePath'][$resourceType] ; - - // Map the "UserFiles" path to a local directory. - return Server_MapPath( $Config['FileTypesPath'][$resourceType] ); - } -} - -function GetUrlFromPath( $resourceType, $folderPath, $sCommand ) -{ - return CombinePaths( GetResourceTypePath( $resourceType, $sCommand ), $folderPath ); -} - -function RemoveExtension( $fileName ) -{ - return substr( $fileName, 0, strrpos( $fileName, '.' ) ); -} - -function ServerMapFolder( $resourceType, $folderPath, $sCommand ) -{ - // Get the resource type directory. - $sResourceTypePath = GetResourceTypeDirectory( $resourceType, $sCommand ); - - // Ensure that the directory exists. - $sErrorMsg = CreateServerFolder( $sResourceTypePath ); - if ( $sErrorMsg != '' ) - SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ); - - // Return the resource type directory combined with the required path. - return CombinePaths( $sResourceTypePath , $folderPath ); -} - -function GetParentFolder( $folderPath ) -{ - $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ; - return preg_replace( $sPattern, '', $folderPath ); -} - -function CreateServerFolder( $folderPath, $lastFolder = null ) -{ - global $Config ; - $sParent = GetParentFolder( $folderPath ); - - // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms - while ( strpos($folderPath, '//') !== false ) - { - $folderPath = str_replace( '//', '/', $folderPath ); - } - - // Check if the parent exists, or create it. - if ( !empty($sParent) && !file_exists( $sParent ) ) - { - //prevents agains infinite loop when we can't create root folder - if ( !is_null( $lastFolder ) && $lastFolder === $sParent) { - return "Can't create $folderPath directory" ; - } - - $sErrorMsg = CreateServerFolder( $sParent, $folderPath ); - if ( $sErrorMsg != '' ) - return $sErrorMsg ; - } - - if ( !file_exists( $folderPath ) ) - { - // Turn off all error reporting. - error_reporting( 0 ); - - $php_errormsg = '' ; - // Enable error tracking to catch the error. - ini_set( 'track_errors', '1' ); - - if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) - { - mkdir( $folderPath ); - } - else - { - $permissions = 0777 ; - if ( isset( $Config['ChmodOnFolderCreate'] ) ) - { - $permissions = $Config['ChmodOnFolderCreate'] ; - } - // To create the folder with 0777 permissions, we need to set umask to zero. - $oldumask = umask(0); - mkdir( $folderPath, $permissions ); - umask( $oldumask ); - } - - $sErrorMsg = $php_errormsg ; - - // Restore the configurations. - ini_restore( 'track_errors' ); - ini_restore( 'error_reporting' ); - - return $sErrorMsg ; - } - else - return '' ; -} - -function GetRootPath() -{ - if (!isset($_SERVER)) { - global $_SERVER; - } - $sRealPath = realpath( './' ); - // #2124 ensure that no slash is at the end - $sRealPath = rtrim($sRealPath,"\\/"); - - $sSelfPath = $_SERVER['PHP_SELF'] ; - $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ); - - $sSelfPath = str_replace( '/', DIRECTORY_SEPARATOR, $sSelfPath ); - - $position = strpos( $sRealPath, $sSelfPath ); - - // This can check only that this script isn't run from a virtual dir - // But it avoids the problems that arise if it isn't checked - if ( $position === false || $position <> strlen( $sRealPath ) - strlen( $sSelfPath ) ) - SendError( 1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ); - - return substr( $sRealPath, 0, $position ); -} - -// Emulate the asp Server.mapPath function. -// given an url path return the physical directory that it corresponds to -function Server_MapPath( $path ) -{ - // This function is available only for Apache - if ( function_exists( 'apache_lookup_uri' ) ) - { - $info = apache_lookup_uri( $path ); - return $info->filename . $info->path_info ; - } - - // This isn't correct but for the moment there's no other solution - // If this script is under a virtual directory or symlink it will detect the problem and stop - return GetRootPath() . $path ; -} - -function IsAllowedExt( $sExtension, $resourceType ) -{ - global $Config ; - // Get the allowed and denied extensions arrays. - $arAllowed = $Config['AllowedExtensions'][$resourceType] ; - $arDenied = $Config['DeniedExtensions'][$resourceType] ; - - if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) - return false ; - - if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) - return false ; - - return true ; -} - -function IsAllowedType( $resourceType ) -{ - global $Config ; - if ( !in_array( $resourceType, $Config['ConfigAllowedTypes'] ) ) - return false ; - - return true ; -} - -function IsAllowedCommand( $sCommand ) -{ - global $Config ; - - if ( !in_array( $sCommand, $Config['ConfigAllowedCommands'] ) ) - return false ; - - return true ; -} - -function GetCurrentFolder() -{ - if (!isset($_GET)) { - global $_GET; - } - $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ; - - // Check the current folder syntax (must begin and start with a slash). - if ( !preg_match( '|/$|', $sCurrentFolder ) ) - $sCurrentFolder .= '/' ; - if ( strpos( $sCurrentFolder, '/' ) !== 0 ) - $sCurrentFolder = '/' . $sCurrentFolder ; - - // Ensure the folder path has no double-slashes - while ( strpos ($sCurrentFolder, '//') !== false ) { - $sCurrentFolder = str_replace ('//', '/', $sCurrentFolder); - } - - // Check for invalid folder paths (..) - if ( strpos( $sCurrentFolder, '..' ) || strpos( $sCurrentFolder, "\\" )) - SendError( 102, '' ); - - if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) - SendError( 102, '' ); - - return $sCurrentFolder ; -} - -// Do a cleanup of the folder name to avoid possible problems -function SanitizeFolderName( $sNewFolderName ) -{ - $sNewFolderName = stripslashes( $sNewFolderName ); - - // Remove . \ / | : ? * " < > - $sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName ); - - return $sNewFolderName ; -} - -// Do a cleanup of the file name to avoid possible problems -function SanitizeFileName( $sNewFileName ) -{ - global $Config ; - - $sNewFileName = stripslashes( $sNewFileName ); - - // Replace dots in the name with underscores (only one dot can be there... security issue). - if ( $Config['ForceSingleExtension'] ) - $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ); - - // Remove \ / | : ? * " < > - $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ); - - return $sNewFileName ; -} - -// This is the function that sends the results of the uploading process. -function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' ) -{ - // Minified version of the document.domain automatic fix script (#1919). - // The original script can be found at _dev/domain_fix_template.js - echo << -(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})(); -EOF; - - if ($errorNumber && $errorNumber != 201) { - $fileUrl = ""; - $fileName = ""; - } - - $rpl = array( '\\' => '\\\\', '"' => '\\"' ); - echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr( $fileUrl, $rpl ) . '","' . strtr( $fileName, $rpl ) . '", "' . strtr( $customMsg, $rpl ) . '");' ; - echo '' ; - exit ; -} - - -// DOL_CHANGE - -// This is the function that sends the results of the uploading process to CKE. -function SendCKEditorResults ($callback, $sFileUrl, $customMsg = '') -{ - echo ''; -} - - -?> + 0 ) + return $Config['QuickUploadAbsolutePath'][$resourceType] ; + + // Map the "UserFiles" path to a local directory. + return Server_MapPath( $Config['QuickUploadPath'][$resourceType] ); + } + else + { + if ( strlen( $Config['FileTypesAbsolutePath'][$resourceType] ) > 0 ) + return $Config['FileTypesAbsolutePath'][$resourceType] ; + + // Map the "UserFiles" path to a local directory. + return Server_MapPath( $Config['FileTypesPath'][$resourceType] ); + } +} + +function GetUrlFromPath( $resourceType, $folderPath, $sCommand ) +{ + return CombinePaths( GetResourceTypePath( $resourceType, $sCommand ), $folderPath ); +} + +function RemoveExtension( $fileName ) +{ + return substr( $fileName, 0, strrpos( $fileName, '.' ) ); +} + +function ServerMapFolder( $resourceType, $folderPath, $sCommand ) +{ + // Get the resource type directory. + $sResourceTypePath = GetResourceTypeDirectory( $resourceType, $sCommand ); + + // Ensure that the directory exists. + $sErrorMsg = CreateServerFolder( $sResourceTypePath ); + if ( $sErrorMsg != '' ) + SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ); + + // Return the resource type directory combined with the required path. + return CombinePaths( $sResourceTypePath , $folderPath ); +} + +function GetParentFolder( $folderPath ) +{ + $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ; + return preg_replace( $sPattern, '', $folderPath ); +} + +function CreateServerFolder( $folderPath, $lastFolder = null ) +{ + global $Config ; + $sParent = GetParentFolder( $folderPath ); + + // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms + while ( strpos($folderPath, '//') !== false ) + { + $folderPath = str_replace( '//', '/', $folderPath ); + } + + // Check if the parent exists, or create it. + if ( !empty($sParent) && !file_exists( $sParent ) ) + { + //prevents agains infinite loop when we can't create root folder + if ( !is_null( $lastFolder ) && $lastFolder === $sParent) { + return "Can't create $folderPath directory" ; + } + + $sErrorMsg = CreateServerFolder( $sParent, $folderPath ); + if ( $sErrorMsg != '' ) + return $sErrorMsg ; + } + + if ( !file_exists( $folderPath ) ) + { + // Turn off all error reporting. + error_reporting( 0 ); + + $php_errormsg = '' ; + // Enable error tracking to catch the error. + ini_set( 'track_errors', '1' ); + + if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) + { + mkdir( $folderPath ); + } + else + { + $permissions = 0777 ; + if ( isset( $Config['ChmodOnFolderCreate'] ) ) + { + $permissions = $Config['ChmodOnFolderCreate'] ; + } + // To create the folder with 0777 permissions, we need to set umask to zero. + $oldumask = umask(0); + mkdir( $folderPath, $permissions ); + umask( $oldumask ); + } + + $sErrorMsg = $php_errormsg ; + + // Restore the configurations. + ini_restore( 'track_errors' ); + ini_restore( 'error_reporting' ); + + return $sErrorMsg ; + } + else + return '' ; +} + +function GetRootPath() +{ + if (!isset($_SERVER)) { + global $_SERVER; + } + $sRealPath = realpath( './' ); + // #2124 ensure that no slash is at the end + $sRealPath = rtrim($sRealPath,"\\/"); + + $sSelfPath = $_SERVER['PHP_SELF'] ; + $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ); + + $sSelfPath = str_replace( '/', DIRECTORY_SEPARATOR, $sSelfPath ); + + $position = strpos( $sRealPath, $sSelfPath ); + + // This can check only that this script isn't run from a virtual dir + // But it avoids the problems that arise if it isn't checked + if ( $position === false || $position <> strlen( $sRealPath ) - strlen( $sSelfPath ) ) + SendError( 1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ); + + return substr( $sRealPath, 0, $position ); +} + +// Emulate the asp Server.mapPath function. +// given an url path return the physical directory that it corresponds to +function Server_MapPath( $path ) +{ + // This function is available only for Apache + if ( function_exists( 'apache_lookup_uri' ) ) + { + $info = apache_lookup_uri( $path ); + return $info->filename . $info->path_info ; + } + + // This isn't correct but for the moment there's no other solution + // If this script is under a virtual directory or symlink it will detect the problem and stop + return GetRootPath() . $path ; +} + +function IsAllowedExt( $sExtension, $resourceType ) +{ + global $Config ; + // Get the allowed and denied extensions arrays. + $arAllowed = $Config['AllowedExtensions'][$resourceType] ; + $arDenied = $Config['DeniedExtensions'][$resourceType] ; + + if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) + return false ; + + if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) + return false ; + + return true ; +} + +function IsAllowedType( $resourceType ) +{ + global $Config ; + if ( !in_array( $resourceType, $Config['ConfigAllowedTypes'] ) ) + return false ; + + return true ; +} + +function IsAllowedCommand( $sCommand ) +{ + global $Config ; + + if ( !in_array( $sCommand, $Config['ConfigAllowedCommands'] ) ) + return false ; + + return true ; +} + +function GetCurrentFolder() +{ + if (!isset($_GET)) { + global $_GET; + } + $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ; + + // Check the current folder syntax (must begin and start with a slash). + if ( !preg_match( '|/$|', $sCurrentFolder ) ) + $sCurrentFolder .= '/' ; + if ( strpos( $sCurrentFolder, '/' ) !== 0 ) + $sCurrentFolder = '/' . $sCurrentFolder ; + + // Ensure the folder path has no double-slashes + while ( strpos ($sCurrentFolder, '//') !== false ) { + $sCurrentFolder = str_replace ('//', '/', $sCurrentFolder); + } + + // Check for invalid folder paths (..) + if ( strpos( $sCurrentFolder, '..' ) || strpos( $sCurrentFolder, "\\" )) + SendError( 102, '' ); + + if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) + SendError( 102, '' ); + + return $sCurrentFolder ; +} + +// Do a cleanup of the folder name to avoid possible problems +function SanitizeFolderName( $sNewFolderName ) +{ + $sNewFolderName = stripslashes( $sNewFolderName ); + + // Remove . \ / | : ? * " < > + $sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName ); + + return $sNewFolderName ; +} + +// Do a cleanup of the file name to avoid possible problems +function SanitizeFileName( $sNewFileName ) +{ + global $Config ; + + $sNewFileName = stripslashes( $sNewFileName ); + + // Replace dots in the name with underscores (only one dot can be there... security issue). + if ( $Config['ForceSingleExtension'] ) + $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ); + + // Remove \ / | : ? * " < > + $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ); + + return $sNewFileName ; +} + +// This is the function that sends the results of the uploading process. +function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' ) +{ + // Minified version of the document.domain automatic fix script (#1919). + // The original script can be found at _dev/domain_fix_template.js + echo << +(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})(); +EOF; + + if ($errorNumber && $errorNumber != 201) { + $fileUrl = ""; + $fileName = ""; + } + + $rpl = array( '\\' => '\\\\', '"' => '\\"' ); + echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr( $fileUrl, $rpl ) . '","' . strtr( $fileName, $rpl ) . '", "' . strtr( $customMsg, $rpl ) . '");' ; + echo '' ; + exit ; +} + + +// DOL_CHANGE + +// This is the function that sends the results of the uploading process to CKE. +function SendCKEditorResults ($callback, $sFileUrl, $customMsg = '') +{ + echo ''; +} + + +?> diff --git a/htdocs/core/filemanagerdol/connectors/php/phpcompat.php b/htdocs/core/filemanagerdol/connectors/php/phpcompat.php index 2c967464297..518d533e260 100755 --- a/htdocs/core/filemanagerdol/connectors/php/phpcompat.php +++ b/htdocs/core/filemanagerdol/connectors/php/phpcompat.php @@ -1,17 +1,16 @@ - + diff --git a/htdocs/core/filemanagerdol/connectors/php/util.php b/htdocs/core/filemanagerdol/connectors/php/util.php index e3c9f5e8ef2..fa2921cde8b 100755 --- a/htdocs/core/filemanagerdol/connectors/php/util.php +++ b/htdocs/core/filemanagerdol/connectors/php/util.php @@ -1,220 +1,220 @@ - $val ) - { - $lcaseHtmlExtensions[$key] = strtolower( $val ); - } - return in_array( $ext, $lcaseHtmlExtensions ); -} - -/** - * Detect HTML in the first KB to prevent against potential security issue with - * IE/Safari/Opera file type auto detection bug. - * Returns true if file contain insecure HTML code at the beginning. - * - * @param string $filePath absolute path to file - * @return boolean - */ -function DetectHtml( $filePath ) -{ - $fp = @fopen( $filePath, 'rb' ); - - //open_basedir restriction, see #1906 - if ( $fp === false || !flock( $fp, LOCK_SH ) ) - { - return -1 ; - } - - $chunk = fread( $fp, 1024 ); - flock( $fp, LOCK_UN ); - fclose( $fp ); - - $chunk = strtolower( $chunk ); - - if (!$chunk) - { - return false ; - } - - $chunk = trim( $chunk ); - - if ( preg_match( "/= 4.0.7 - if ( function_exists( 'version_compare' ) ) { - $sCurrentVersion = phpversion(); - if ( version_compare( $sCurrentVersion, "4.2.0" ) >= 0 ) { - $imageCheckExtensions[] = "tiff"; - $imageCheckExtensions[] = "tif"; - } - if ( version_compare( $sCurrentVersion, "4.3.0" ) >= 0 ) { - $imageCheckExtensions[] = "swc"; - } - if ( version_compare( $sCurrentVersion, "4.3.2" ) >= 0 ) { - $imageCheckExtensions[] = "jpc"; - $imageCheckExtensions[] = "jp2"; - $imageCheckExtensions[] = "jpx"; - $imageCheckExtensions[] = "jb2"; - $imageCheckExtensions[] = "xbm"; - $imageCheckExtensions[] = "wbmp"; - } - } - - if ( !in_array( $extension, $imageCheckExtensions ) ) { - return true; - } - - if ( @getimagesize( $filePath ) === false ) { - return false ; - } - - return true; -} - -?> + $val ) + { + $lcaseHtmlExtensions[$key] = strtolower( $val ); + } + return in_array( $ext, $lcaseHtmlExtensions ); +} + +/** + * Detect HTML in the first KB to prevent against potential security issue with + * IE/Safari/Opera file type auto detection bug. + * Returns true if file contain insecure HTML code at the beginning. + * + * @param string $filePath absolute path to file + * @return boolean + */ +function DetectHtml( $filePath ) +{ + $fp = @fopen( $filePath, 'rb' ); + + //open_basedir restriction, see #1906 + if ( $fp === false || !flock( $fp, LOCK_SH ) ) + { + return -1 ; + } + + $chunk = fread( $fp, 1024 ); + flock( $fp, LOCK_UN ); + fclose( $fp ); + + $chunk = strtolower( $chunk ); + + if (!$chunk) + { + return false ; + } + + $chunk = trim( $chunk ); + + if ( preg_match( "/= 4.0.7 + if ( function_exists( 'version_compare' ) ) { + $sCurrentVersion = phpversion(); + if ( version_compare( $sCurrentVersion, "4.2.0" ) >= 0 ) { + $imageCheckExtensions[] = "tiff"; + $imageCheckExtensions[] = "tif"; + } + if ( version_compare( $sCurrentVersion, "4.3.0" ) >= 0 ) { + $imageCheckExtensions[] = "swc"; + } + if ( version_compare( $sCurrentVersion, "4.3.2" ) >= 0 ) { + $imageCheckExtensions[] = "jpc"; + $imageCheckExtensions[] = "jp2"; + $imageCheckExtensions[] = "jpx"; + $imageCheckExtensions[] = "jb2"; + $imageCheckExtensions[] = "xbm"; + $imageCheckExtensions[] = "wbmp"; + } + } + + if ( !in_array( $extension, $imageCheckExtensions ) ) { + return true; + } + + if ( @getimagesize( $filePath ) === false ) { + return false ; + } + + return true; +} + +?> diff --git a/htdocs/core/js/dst.js b/htdocs/core/js/dst.js new file mode 100644 index 00000000000..b28c500e2c4 --- /dev/null +++ b/htdocs/core/js/dst.js @@ -0,0 +1,156 @@ +// Copyright (C) 2011-2012 Laurent Destailleur +// Copyright (C) 2011-2012 Regis Houssin +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 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/js/dst.js +// \brief File that include javascript functions for detect user tz, dst_observed, dst_first, dst_second +// + +$(document).ready(function () { + // Detect and save TZ and DST + var rightNow = new Date(); + var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); + var temp = jan1.toGMTString(); + var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); + var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60); + var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0); + temp = june1.toGMTString(); + var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); + var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60); + var dst; + if (std_time_offset == daylight_time_offset) { + dst = "0"; // daylight savings time is NOT observed + } else { + dst = "1"; // daylight savings time is observed + } + var dst_first=DisplayDstSwitchDates('first'); + var dst_second=DisplayDstSwitchDates('second'); + //alert(dst); + $('#tz').val(std_time_offset); // returns TZ + $('#dst_observed').val(dst); // returns if DST is observed on summer + $('#dst_first').val(dst_first); // returns DST first switch in year + $('#dst_second').val(dst_second); // returns DST second switch in year + // Detect and save screen resolution + $('#screenwidth').val($(window).width()); // returns width of browser viewport + $('#screenheight').val($(window).height()); // returns width of browser viewport +}); + +function DisplayDstSwitchDates(firstsecond) +{ + var year = new Date().getYear(); + if (year < 1000) year += 1900; + + var firstSwitch = 0; + var secondSwitch = 0; + var lastOffset = 99; + + // Loop through every month of the current year + for (i = 0; i < 12; i++) + { + // Fetch the timezone value for the month + var newDate = new Date(Date.UTC(year, i, 0, 0, 0, 0, 0)); + var tz = -1 * newDate.getTimezoneOffset() / 60; + + // Capture when a timzezone change occurs + if (tz > lastOffset) + firstSwitch = i-1; + else if (tz < lastOffset) + secondSwitch = i-1; + + lastOffset = tz; + } + + // Go figure out date/time occurences a minute before + // a DST adjustment occurs + var secondDstDate = FindDstSwitchDate(year, secondSwitch); + var firstDstDate = FindDstSwitchDate(year, firstSwitch); + + if (firstsecond == 'first') return firstDstDate; + if (firstsecond == 'second') return secondDstDate; + + if (firstDstDate == null && secondDstDate == null) + return 'Daylight Savings is not observed in your timezone.'; + else + return 'Last minute before DST change occurs in ' + + year + ': ' + firstDstDate + ' and ' + secondDstDate; +} + +function FindDstSwitchDate(year, month) +{ + // Set the starting date + var baseDate = new Date(Date.UTC(year, month, 0, 0, 0, 0, 0)); + var changeDay = 0; + var changeMinute = -1; + var baseOffset = -1 * baseDate.getTimezoneOffset() / 60; + var dstDate; + + // Loop to find the exact day a timezone adjust occurs + for (day = 0; day < 50; day++) + { + var tmpDate = new Date(Date.UTC(year, month, day, 0, 0, 0, 0)); + var tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60; + + // Check if the timezone changed from one day to the next + if (tmpOffset != baseOffset) + { + var minutes = 0; + changeDay = day; + + // Back-up one day and grap the offset + tmpDate = new Date(Date.UTC(year, month, day-1, 0, 0, 0, 0)); + tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60; + + // Count the minutes until a timezone chnage occurs + while (changeMinute == -1) + { + tmpDate = new Date(Date.UTC(year, month, day-1, 0, minutes, 0, 0)); + tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60; + + // Determine the exact minute a timezone change + // occurs + if (tmpOffset != baseOffset) + { + // Back-up a minute to get the date/time just + // before a timezone change occurs + tmpOffset = new Date(Date.UTC(year, month, + day-1, 0, minutes-1, 0, 0)); + changeMinute = minutes; + break; + } + else + minutes++; + } + + // Add a month (for display) since JavaScript counts + // months from 0 to 11 + dstDate = tmpOffset.getMonth() + 1; + + // Pad the month as needed + if (dstDate < 10) dstDate = "0" + dstDate; + + // Add the day and year + dstDate = year + '-' + dstDate + '-' + tmpOffset.getDate() + 'T'; + + // Capture the time stamp + tmpDate = new Date(Date.UTC(year, month, + day-1, 0, minutes-1, 0, 0)); + dstDate += tmpDate.toTimeString().split(' ')[0] + 'Z'; + return dstDate; + } + } +} diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index 82ae02ff129..7748b73fce6 100644 --- a/htdocs/core/js/editinplace.js +++ b/htdocs/core/js/editinplace.js @@ -37,19 +37,16 @@ $(document).ready(function() { indicator : indicatorInPlace, loadurl : urlLoadInPlace, loaddata : function(result, settings) { - var htmlname = $(this).attr('id').substr(8); - return getParameters('textarea', htmlname); + return getParameters(this, 'textarea'); }, submitdata : function(result, settings) { - var htmlname = $(this).attr('id').substr(8); - return getParameters('textarea', htmlname); + return getParameters(this, 'textarea'); }, - callback : function(result, settings) { + callback : function(result, settings) { getResult(this, result); }, onreset : function(result, settings) { - $('#editval_' + $('.editval_textarea').attr('id').substr(8)).hide(); - $('#viewval_' + $('.editval_textarea').attr('id').substr(8)).show(); + getDefault(settings); } }); $('.editkey_textarea').hover( @@ -86,15 +83,13 @@ $(document).ready(function() { toolbar: $('#ckeditor_toolbar').val() }, submitdata : function(result, settings) { - var htmlname = $(this).attr('id').substr(8); - return getParameters('ckeditor', htmlname); + return getParameters(this, 'ckeditor'); }, - callback : function(result, settings) { + callback : function(result, settings) { getResult(this, result); }, onreset : function(result, settings) { - $('#editval_' + $('.editval_ckeditor').attr('id').substr(8)).hide(); - $('#viewval_' + $('.editval_ckeditor').attr('id').substr(8)).show(); + getDefault(settings); } }); $('.editkey_ckeditor').hover( @@ -127,15 +122,13 @@ $(document).ready(function() { submit : submitInPlace, indicator : indicatorInPlace, submitdata : function(result, settings) { - var htmlname = $(this).attr('id').substr(8); - return getParameters('string', htmlname); + return getParameters(this, 'string'); }, - callback : function(result, settings) { + callback : function(result, settings) { getResult(this, result); }, onreset : function(result, settings) { - $('#editval_' + $('.editval_string').attr('id').substr(8)).hide(); - $('#viewval_' + $('.editval_string').attr('id').substr(8)).show(); + getDefault(settings); } }); $('.editkey_string').hover( @@ -168,15 +161,13 @@ $(document).ready(function() { submit : submitInPlace, indicator : indicatorInPlace, submitdata : function(result, settings) { - var htmlname = $(this).attr('id').substr(8); - return getParameters('numeric', htmlname); + return getParameters(this, 'numeric'); }, - callback : function(result, settings) { + callback : function(result, settings) { getResult(this, result); }, onreset : function(result, settings) { - $('#editval_' + $('.editval_numeric').attr('id').substr(8)).hide(); - $('#viewval_' + $('.editval_numeric').attr('id').substr(8)).show(); + getDefault(settings); } }); $('.editkey_numeric').hover( @@ -209,15 +200,13 @@ $(document).ready(function() { submit : submitInPlace, indicator : indicatorInPlace, submitdata : function(result, settings) { - var htmlname = $(this).attr('id').substr(8); - return getParameters('datepicker', htmlname); + return getParameters(this, 'datepicker'); }, - callback : function(result, settings) { + callback : function(result, settings) { getResult(this, result); }, onreset : function(result, settings) { - $('#editval_' + $('.editval_datepicker').attr('id').substr(8)).hide(); - $('#viewval_' + $('.editval_datepicker').attr('id').substr(8)).show(); + getDefault(settings); } }); $('.editkey_datepicker').hover( @@ -249,19 +238,16 @@ $(document).ready(function() { indicator : indicatorInPlace, loadurl : urlLoadInPlace, loaddata : function(result, settings) { - var htmlname = $(this).attr('id').substr(8); - return getParameters('select', htmlname); + return getParameters(this, 'select'); }, submitdata : function(result, settings) { - var htmlname = $(this).attr('id').substr(8); - return getParameters('select', htmlname); + return getParameters(this, 'select'); }, callback : function(result, settings) { getResult(this, result); }, onreset : function(result, settings) { - $('#editval_' + $('.editval_select').attr('id').substr(8)).hide(); - $('#viewval_' + $('.editval_select').attr('id').substr(8)).show(); + getDefault(settings); } }); $('.editkey_select').hover( @@ -281,7 +267,52 @@ $(document).ready(function() { $('#editval_' + $(this).attr('id')).show().click(); }); - function getParameters(type, htmlname) { + // for test only (not stable) + $('.editval_autocomplete').editable(urlSaveInPlace, { + type : 'autocomplete', + id : 'field', + width : 300, + onblur : 'ignore', + tooltip : tooltipInPlace, + placeholder : ' ', + cancel : cancelInPlace, + submit : submitInPlace, + indicator : indicatorInPlace, + autocomplete : { + source : urlLoadInPlace, + data : function(result, settings) { + return getParameters(this, 'select'); + } + }, + submitdata : function(result, settings) { + return getParameters(this, 'select'); + }, + callback : function(result, settings) { + getResult(this, result); + }, + onreset : function(result, settings) { + getDefault(settings); + } + }); + $('.editkey_autocomplete').hover( + function () { + $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + }, + function () { + $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + } + ); + $('.viewval_autocomplete.active').click(function() { + $('#viewval_' + $(this).attr('id').substr(8)).hide(); + $('#editval_' + $(this).attr('id').substr(8)).show().click(); + }); + $('.editkey_autocomplete').click(function() { + $('#viewval_' + $(this).attr('id')).hide(); + $('#editval_' + $(this).attr('id')).show().click(); + }); + + function getParameters(obj, type) { + var htmlname = $(obj).attr('id').substr(8); var element = $('#element_' + htmlname).val(); var table_element = $('#table_element_' + htmlname).val(); var fk_element = $('#fk_element_' + htmlname).val(); @@ -289,8 +320,6 @@ $(document).ready(function() { var savemethod = $('#savemethod_' + htmlname).val(); var ext_element = $('#ext_element_' + htmlname).val(); var timestamp = $('#timestamp').val(); - //var ext_table_element = $( '#ext_table_element_' + htmlname ).val(); - //var ext_fk_element = $( '#ext_fk_element_' + htmlname ).val(); return { type: type, @@ -300,9 +329,7 @@ $(document).ready(function() { loadmethod: loadmethod, savemethod: savemethod, timestamp: timestamp, - ext_element: ext_element, - //ext_table_element: ext_table_element, - //ext_fk_element: ext_fk_element + ext_element: ext_element }; } @@ -324,14 +351,9 @@ $(document).ready(function() { } } - $('.edit_autocomplete').editable(urlSaveInPlace, { - type : 'autocomplete', - id : 'field', - onblur : 'submit', - tooltip : tooltipInPlace, - indicator : indicatorInPlace, - autocomplete : { - data : ["Aberdeen", "Ada", "Adamsville", "Addyston", "Adelphi", "Adena", "Adrian", "Akron"] - } - }); + function getDefault(settings) { + var htmlname = $(settings).attr('id').substr(8); + $('#editval_' + htmlname).hide(); + $('#viewval_' + htmlname).show(); + } }); diff --git a/htdocs/core/js/lib_head.js b/htdocs/core/js/lib_head.js index 61a8b99484e..932f131a4d9 100644 --- a/htdocs/core/js/lib_head.js +++ b/htdocs/core/js/lib_head.js @@ -578,13 +578,13 @@ function newpopup(url,title) { * ================================================================= * Purpose: * Clean values of a "Sortable.serialize". Used by drag and drop. - * Works for Scriptaculous and jQuery. * Input: expr * Author: Regis Houssin * Licence: GPL * ================================================================== */ function cleanSerialize(expr) { + if (typeof(expr) != 'string') return ''; var reg = new RegExp("(&)", "g"); var reg2 = new RegExp("[^A-Z0-9,]", "g"); var liste1 = expr.replace(reg, ","); @@ -631,31 +631,31 @@ function hideMessage(fieldId,message) { /* This is to allow to transform all select box into ajax autocomplete box - * with just one line: jQuery(function() { jQuery( "#listmotifcons" ).combobox(); }); + * with just one line: $(function() { $( "#listmotifcons" ).combobox(); }); */ -(function( jQuery ) { - jQuery.widget( "ui.combobox", { +(function( $ ) { + $.widget( "ui.combobox", { _create: function() { var self = this, select = this.element.hide(), selected = select.children( ":selected" ), value = selected.val() ? selected.text() : ""; - var input = this.input = jQuery( "" ) + var input = this.input = $( "" ) .insertAfter( select ) .val( value ) .autocomplete({ delay: 0, minLength: 0, source: function( request, response ) { - var matcher = new RegExp( jQuery.ui.autocomplete.escapeRegex(request.term), "i" ); + var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( select.children( "option" ).map(function() { - var text = jQuery( this ).text(); + var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( "(?![^&;]+;)(?!<[^<>]*)(" + - jQuery.ui.autocomplete.escapeRegex(request.term) + + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi" ), "$1" ), value: text, @@ -671,17 +671,17 @@ function hideMessage(fieldId,message) { }, change: function( event, ui ) { if ( !ui.item ) { - var matcher = new RegExp( "^" + jQuery.ui.autocomplete.escapeRegex( jQuery(this).val() ) + "$", "i" ), + var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), valid = false; select.children( "option" ).each(function() { - if ( jQuery( this ).text().match( matcher ) ) { + if ( $( this ).text().match( matcher ) ) { this.selected = valid = true; return false; } }); if ( !valid ) { // remove invalid value, as it didnt match anything - jQuery( this ).val( "" ); + $( this ).val( "" ); select.val( "" ); input.data( "autocomplete" ).term = ""; return false; @@ -692,13 +692,13 @@ function hideMessage(fieldId,message) { .addClass( "ui-widget ui-widget-content ui-corner-left dolibarrcombobox" ); input.data( "autocomplete" )._renderItem = function( ul, item ) { - return jQuery( "
  • " ) + return $( "
  • " ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; - this.button = jQuery( "" ) + this.button = $( "" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .insertAfter( input ) @@ -727,7 +727,7 @@ function hideMessage(fieldId,message) { this.input.remove(); this.button.remove(); this.element.show(); - jQuery.Widget.prototype.destroy.call( this ); + $.Widget.prototype.destroy.call( this ); } }); })( jQuery ); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 3883ca30144..32ce43f473e 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -813,7 +813,6 @@ function unActivateModule($value, $requiredby=1) // TODO Cannot instantiate abstract class //$genericMod = new DolibarrModul($db); //$genericMod->name=preg_replace('/^mod/i','',$modName); - //$genericMod->style_sheet=1; //$genericMod->rights_class=strtolower(preg_replace('/^mod/i','',$modName)); //$genericMod->const_name='MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',$modName)); dol_syslog("modules::unActivateModule Failed to find module file, we use generic function with name " . $modName); diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 937c187d1e5..f433374f83c 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -202,17 +202,51 @@ function ajax_dialog($title,$message,$w=350,$h=150) * Convert a select html field into an ajax combobox * * @param string $htmlname Name of html field + * @param array $event Event options * @return string Return html string to convert a select field into a combo */ -function ajax_combobox($htmlname) +function ajax_combobox($htmlname, $event=array()) { $msg.= ''; - - $msg.= "\n"; + $("#'.$htmlname.'").combobox({ + selected : function(event,ui) { + var obj = '.json_encode($event).'; + $.each(obj, function(key,values) { + if (values.method.length) { + getMethod(values); + } + }); + } + }); + + function getMethod(obj) { + var id = $("#'.$htmlname.'").val(); + var method = obj.method; + var url = obj.url; + var htmlname = obj.htmlname; + $.getJSON(url, + { + action: method, + id: id, + htmlname: htmlname + }, + function(response) { + $.each(obj.params, function(key,action) { + if (key.length) { + var num = response.num; + if (num > 0) { + $("#" + key).removeAttr(action); + } else { + $("#" + key).attr(action, action); + } + } + }); + $("select#" + htmlname).html(response.value); + }); + } + });'; + $msg.= "\n"; return $msg; } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2f3c70ee723..09fc90fe7c5 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -92,7 +92,7 @@ function societe_prepare_head($object) if ($user->societe_id == 0) { // Notes - $head[$h][0] = DOL_URL_ROOT.'/societe/socnote.php?socid='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/societe/note.php?socid='.$object->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; $h++; @@ -502,12 +502,14 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $buttoncreate=''; if ($user->rights->societe->contact->creer) { - //$buttoncreate=''.$langs->trans("AddContact").''."\n"; - $buttoncreate=''.$langs->trans("AddContact").' '.img_picto($langs->trans("AddContact"),'filenew').''."\n"; + $addcontact = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $buttoncreate=''.$addcontact.' '.img_picto($addcontact,'filenew').''."\n"; } print "\n"; - print_fiche_titre($langs->trans("ContactsForCompany"),$buttoncreate,''); + + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany")); + print_fiche_titre($title,$buttoncreate,''); print "\n".''."\n"; @@ -593,6 +595,100 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') return $i; } +/** + * Show html area for list of addresses + * + * @param Conf $conf Object conf + * @param Translate $langs Object langs + * @param DoliDB $db Database handler + * @param Object $object Third party object + * @param string $backtopage Url to go once address is created + * @return void + */ +function show_addresses($conf,$langs,$db,$object,$backtopage='') +{ + global $user; + global $bc; + + require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php"); + + $addressstatic = new Address($db); + $num = $addressstatic->fetch_lines($object->id); + + $buttoncreate=''; + if ($user->rights->societe->creer) + { + $buttoncreate=''.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').''."\n"; + } + + print "\n"; + print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,''); + + print "\n".'
    '."\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ""; + print ""; + + if ($num > 0) + { + $var=true; + + foreach ($addressstatic->lines as $address) + { + $var = !$var; + + print ""; + + print ''; + + print ''; + + print ''; + + $img=picto_from_langcode($address->country_code); + print ''; + + // Lien click to dial + print ''; + print ''; + + if ($user->rights->societe->creer) + { + print ''; + } + + print "\n"; + } + } + else + { + //print ""; + //print ''; + //print "\n"; + } + print "\n
    '.$langs->trans("Label").''.$langs->trans("CompanyName").''.$langs->trans("Town").''.$langs->trans("Country").''.$langs->trans("Tel").''.$langs->trans("Fax").' 
    '; + $addressstatic->id = $address->id; + $addressstatic->label = $address->label; + print $addressstatic->getNomUrl(1); + print ''.$address->name.''.$address->town.''.($img?$img.' ':'').$address->country.''; + print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL'); + print ''; + print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX'); + print ''; + print ''; + print img_edit(); + print '
    '.$langs->trans("NoAddressYetDefined").'
    \n"; + + print "
    \n"; + + return $num; +} /** * Show html area with actions to do diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 3935101916a..586abb9e719 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2009 Regis Houssin +/* Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,22 +38,28 @@ function contract_prepare_head($object) $head[$h][1] = $langs->trans("ContractCard"); $head[$h][2] = 'card'; $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans("ContractContacts"); - $head[$h][2] = 'contact'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans("ContactsAddresses"); + $head[$h][2] = 'contact'; + $h++; + } // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'contract'); - - $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; - $head[$h][1] = $langs->trans("Note"); - $head[$h][2] = 'note'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; + $head[$h][1] = $langs->trans("Note"); + $head[$h][2] = 'note'; + $h++; + } $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index c52c96e0664..4f0afe66eef 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -755,7 +755,8 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0) /** - * Return array of translated months or selected month + * Return array of translated months or selected month. + * This replace old function monthArrayOrSelected. * * @param Translate $outputlangs Object langs * @return array Month string or array if selected < 0 diff --git a/htdocs/core/lib/doc.lib.php b/htdocs/core/lib/doc.lib.php index 1338bb2e6f3..a96a08f93b2 100644 --- a/htdocs/core/lib/doc.lib.php +++ b/htdocs/core/lib/doc.lib.php @@ -31,7 +31,6 @@ /** * Return line description translated in outputlangs and encoded into UTF8 * - * @param Object $object Object * @param Line $line Current line number (0 = first line, 1 = second line, ...) * @param Translate $outputlangs Object langs for output * @param int $hideref Hide reference diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 4f7c5c660f2..e31b708f09b 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -1,6 +1,7 @@ - * Copyright (C) 2007 Rodolphe Quiedeville +/* Copyright (C) 2006-2007 Laurent Destailleur + * Copyright (C) 2007 Rodolphe Quiedeville + * Copyright (C) 2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,11 +42,14 @@ function fichinter_prepare_head($object) $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('InterventionContact'); - $head[$h][2] = 'contact'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('InterventionContact'); + $head[$h][2] = 'contact'; + $h++; + } if (! empty($conf->global->MAIN_USE_PREVIEW_TABS)) { @@ -60,11 +64,14 @@ function fichinter_prepare_head($object) // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention'); - - $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; + $h++; + } $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 88e71bf78e9..8a26d9f7deb 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -30,7 +30,7 @@ * @param string $types Can be "directories", "files", or "all" * @param int $recursive Determines whether subdirectories are searched * @param string $filter Regex for include filter - * @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.') + * @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.')) * @param string $sortcriteria Sort criteria ("","fullname","name","date","size") * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only @@ -742,16 +742,15 @@ function dol_delete_preview($object) { global $langs,$conf; require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + $element = $object->element; + $dir = $conf->$element->dir_output; - if ($object->element == 'commande') $dir = $conf->commande->dir_output; - elseif ($object->element == 'propal') $dir = $conf->propale->dir_output; - elseif ($object->element == 'ficheinter') $dir = $conf->ficheinter->dir_output; - elseif ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; + if ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture'; elseif ($object->element == 'project') $dir = $conf->projet->dir_output; elseif ($object->element == 'delivery') $dir = $conf->livraison->dir_output; - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output; - elseif ($object->element == 'don') $dir = $conf->don->dir_output; + if (empty($dir)) return 'ErrorObjectNoSupportedByFunction'; $refsan = dol_sanitizeFileName($object->ref); @@ -1047,4 +1046,18 @@ function dol_compress_file($inputfile, $outputfile, $mode="gz") } } + +/** + * Return most recent file + * + * @param string $dir Directory to scan + * @param string $regexfilter Regexfilter + * @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.')) + * @return strnig Full path to most recent file + */ +function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('\.meta$','^\.')) +{ + $tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC); + return $tmparray[0]; +} ?> diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 3ceea772fdf..1cd38ce0c9b 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -1,6 +1,7 @@ - * Copyright (C) 2006 Marc Barilley / Ocebo +/* Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Marc Barilley * * 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 @@ -39,22 +40,28 @@ function facturefourn_prepare_head($object) $head[$h][1] = $langs->trans('CardBill'); $head[$h][2] = 'card'; $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; - $head[$h][1] = $langs->trans('BillContacts'); - $head[$h][2] = 'contact'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; + $h++; + } // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice'); - - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; + $h++; + } $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; /*$filesdir = $conf->fournisseur->dir_output.'/facture/'.get_exdir($fac->id,2).$fac->id; @@ -99,22 +106,28 @@ function ordersupplier_prepare_head($object) $head[$h][2] = 'dispatch'; $h++; } - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('OrderContact'); - $head[$h][2] = 'contact'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; + $h++; + } // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order'); - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; - $head[$h][1] = $langs->trans("Notes"); - $head[$h][2] = 'note'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; + $head[$h][1] = $langs->trans("Notes"); + $head[$h][2] = 'note'; + $h++; + } $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id; /*$filesdir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 25bec4c1ccb..2d9c8b9d029 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -145,32 +145,6 @@ if (! function_exists('json_decode')) } } -/** - * Function that encodes data in json format - * - * @param mixed $elements PHP object to json encode - * @return string Json encoded string - */ -function dol_json_encode($elements) -{ - return json_encode($elements); -} - -/** - * Function that decodes data from json format - * - * @param string $json Json encoded to PHP Object or Array - * @param bool $assoc False return an object, true return an array - * @return mixed Object or Array - */ -function dol_json_decode($json, $assoc=false) -{ - $out=''; - $out = @unserialize($json); // For compatibility, test if serialized - if (empty($out)) $out = json_decode($json, $assoc); - return $out; -} - /** * Function to return value of a static property when class * name is dynamically defined (not hard coded). @@ -456,14 +430,15 @@ function dol_size($size,$type='') * * @param string $str String to clean * @param string $newstr String to replace bad chars with + * @param string $unaccent 1=Remove also accent (default), 0 do not remove them * @return string String cleaned (a-zA-Z_) * * @see dol_string_nospecial, dol_string_unaccent */ -function dol_sanitizeFileName($str,$newstr='_') +function dol_sanitizeFileName($str,$newstr='_',$unaccent=1) { $filesystem_forbidden_chars = array('<','>',':','/','\\','?','*','|','"'); - return dol_string_nospecial(dol_string_unaccent($str), $newstr, $filesystem_forbidden_chars); + return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); } /** @@ -1127,8 +1102,8 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) function dol_now($mode='gmt') { // Note that gmmktime and mktime return same value (GMT) whithout parameters - if ($mode == 'gmt') $ret=gmmktime(); // Time for now at greenwich. - else if ($mode == 'tzserver') // Time for now with PHP server timezone added + if ($mode == 'gmt') $ret=time(); // Time for now at greenwich. + else if ($mode == 'tzserver') // Time for now with PHP server timezone added { require_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); $tzsecond=getServerTimeZoneInt(); // Contains tz+dayling saving time @@ -1457,8 +1432,8 @@ function isValidEmail($address) /** * Return true if phone number syntax is ok * - * @param string $address phone (Ex: "0601010101") - * @return boolean true if phone syntax is OK, false if KO or empty string + * @param string $phone phone (Ex: "0601010101") + * @return boolean true if phone syntax is OK, false if KO or empty string */ function isValidPhone($phone) { @@ -2429,7 +2404,7 @@ function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpat * @param string $titre Title to show * @param string $mesg Added message to show on right * @param string $picto Icon to use before title (should be a 32x32 transparent png file) - * @param int $pictoisfullpath 1=Icon name is a full absolute url of image + * @param int $pictoisfullpath 1=Icon name is a full absolute url of image * @param int $id To force an id on html objects * @return void */ @@ -3178,7 +3153,7 @@ function picto_required() function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8') { $pattern = "/<[^>]+>/"; - $temp = dol_entity_decode($StringHtml,$pagecodeto); + $temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto); $temp = preg_replace($pattern,"",$temp); // Supprime aussi les retours @@ -3283,19 +3258,6 @@ function dol_htmlcleanlastbr($stringtodecode) return $ret; } -/** - * This function is called to decode a string with HTML entities (it decodes entities tags) - * - * @param string $stringhtml stringhtml - * @param string $pagecodeto Encoding of input string - * @return string decodestring - */ -function dol_entity_decode($stringhtml,$pagecodeto='UTF-8') -{ - $ret=dol_html_entity_decode($stringhtml,ENT_COMPAT,$pagecodeto); - return $ret; -} - /** * Replace html_entity_decode functions to manage errors * @@ -3304,7 +3266,7 @@ function dol_entity_decode($stringhtml,$pagecodeto='UTF-8') * @param string $c Operand c * @return string String decoded */ -function dol_html_entity_decode($a,$b,$c) +function dol_html_entity_decode($a,$b,$c='UTF-8') { // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; $ret=@html_entity_decode($a,$b,$c); @@ -3319,7 +3281,7 @@ function dol_html_entity_decode($a,$b,$c) * @param string $c Operand c * @return string String encoded */ -function dol_htmlentities($a,$b,$c) +function dol_htmlentities($a,$b,$c='UTF-8') { // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; $ret=@htmlentities($a,$b,$c); @@ -4087,7 +4049,7 @@ function printCommonFooter($zone='private') { print ' - Zend encoded file: '.(zend_loader_file_encoded()?'yes':'no'); } - print '")'."\n"; + print '");'."\n"; print ''."\n"; // Add Xdebug coverage of code @@ -4112,6 +4074,48 @@ function printCommonFooter($zone='private') } +/** + * Convert unicode + * + * @param string $unicode Unicode + * @param string $encoding Encoding type + * @return string Unicode converted + */ +function unichr($unicode , $encoding = 'UTF-8') +{ + return mb_convert_encoding("&#{$unicode};", $encoding, 'HTML-ENTITIES'); +} + +/** + * Convert a currency code into its symbol + * + * @param string $currency_code Currency code + * @return string Currency symbol encoded into UTF8 + */ +function getCurrencySymbol($currency_code) +{ + global $db, $form; + + $currency_sign = ''; + + if (! is_object($form)) $form = new Form($db); + + $form->load_cache_currencies(); + + if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) + { + foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode) + { + $currency_sign.= unichr($unicode); + } + } + else + { + $currency_sign = $currency_code; + } + + return $currency_sign; +} if (! function_exists('getmypid')) { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 448721dd298..1b482063032 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -39,7 +39,6 @@ function dol_getDefaultFormat() return $selected; } - /** * Output content of a file $filename in version of current language (otherwise may use an alternate language) * @@ -215,7 +214,6 @@ function dol_print_object_info($object) print $langs->trans("DateLastSend")." : " . dol_print_date($object->date_envoi,"dayhourtext") . '
    '; } - /** * Return true if email has a domain name that can't be resolved * @@ -235,7 +233,6 @@ function isValidMailDomain($mail) } } - /** * Url string validation * :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor] @@ -285,7 +282,6 @@ function isValidUrl($url,$http=0,$pass=0,$port=0,$path=0,$query=0,$anchor=0) return $ValidUrl; } - /** * Clean an url string * @@ -325,7 +321,6 @@ function clean_url($url,$http=1) } } - /** * Return lines of an html table from an array * Used by array2table function only @@ -373,7 +368,6 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti return $text ; } - /** * Return next value for a mask * @@ -662,7 +656,6 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m return $numFinal; } - /** * Check value * @@ -753,7 +746,6 @@ function check_value($mask,$value) return $result; } - /** * Convert a binary data to string that represent hexadecimal value * @@ -772,7 +764,6 @@ function binhex($bin, $pad=false, $upper=false) return $x; } - /** * Convert an hexadecimal string into a binary string * @@ -790,7 +781,6 @@ function hexbin($hexa) return $bin; } - /** * Retourne le numero de la semaine par rapport a une date * @@ -872,7 +862,6 @@ function numero_semaine($time) return sprintf("%02d",$numeroSemaine); } - /** * Convertit une masse d'une unite vers une autre unite * @@ -907,7 +896,6 @@ function weight_convert($weight,&$from_unit,$to_unit) return $weight; } - /** * Save personnal parameter * @@ -979,7 +967,6 @@ function dol_set_user_param($db, $conf, &$user, $tab) return 1; } - /** * Returns formated reduction * @@ -1002,7 +989,6 @@ function dol_print_reduction($reduction,$langs) return $string; } - /** * Return OS version. * Note that PHP_OS returns only OS (not version) and OS PHP was built on, not @@ -1046,7 +1032,6 @@ function version_webserver() return $_SERVER["SERVER_SOFTWARE"]; } - /** * Return list of activated modules usable for document generation * @@ -1152,7 +1137,6 @@ function is_ip($ip) return 1; } - /** * Build a login from lastname, firstname * @@ -1169,8 +1153,6 @@ function dol_buildlogin($lastname,$firstname) return $login; } - - /** * Return array to use for SoapClient constructor * diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index dd790a9ca3e..0a251030204 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -397,7 +397,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ break; case IMAGETYPE_JPEG: // 2 $img = imagecreatefromjpeg($fichier); - $extImg = '.jpg'; // Extension de l'image + $extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image break; case IMAGETYPE_PNG: // 3 $img = imagecreatefrompng($fichier); @@ -426,11 +426,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original // Fixe les dimensions de la vignette - if($whFact < $imgWhFact){ + if($whFact < $imgWhFact) + { // Si largeur determinante $thumbWidth = $maxWidth; $thumbHeight = $thumbWidth / $imgWhFact; - } else { + } + else + { // Si hauteur determinante $thumbHeight = $maxHeight; $thumbWidth = $thumbHeight * $imgWhFact; @@ -475,7 +478,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ break; case IMAGETYPE_JPEG: // 2 $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); - $extImgTarget = '.jpg'; + $extImgTarget = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); $newquality=$quality; break; case IMAGETYPE_PNG: // 3 diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 7dbd628e82d..b6dd10249e3 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2005-2012 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,11 +39,14 @@ function facture_prepare_head($object) $head[$h][1] = $langs->trans('CardBill'); $head[$h][2] = 'compta'; $h++; - - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; - $head[$h][1] = $langs->trans('BillContacts'); - $head[$h][2] = 'contact'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; + $h++; + } if (! empty($conf->global->MAIN_USE_PREVIEW_TABS)) { @@ -66,11 +70,14 @@ function facture_prepare_head($object) // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice'); - - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; + $h++; + } $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id; /*$filesdir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($fac->ref); diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 2f8cfe7fd36..8cc3d939a00 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -1,8 +1,8 @@ - * Copyright (C) 2007 Rodolphe Quiedeville - * Copyright (C) 2010 Regis Houssin - * Copyright (C) 2010 Juanjo Menent +/* Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2007 Rodolphe Quiedeville + * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2010 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,11 +67,14 @@ function commande_prepare_head($object) $head[$h][2] = 'preview'; $h++; } - - $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('OrderContact'); - $head[$h][2] = 'contact'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; + $h++; + } // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -87,11 +90,14 @@ function commande_prepare_head($object) $head[$h][1] = $langs->trans('Documents'); $head[$h][2] = 'documents'; $h++; - - $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; + $h++; + } $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id; $head[$h][1] = $langs->trans("Info"); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index db504ad3584..941028ccb61 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -77,7 +77,11 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') { global $conf; - require_once(TCPDF_PATH.'tcpdf.php'); + if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI)) + return "Error MAIN_USE_PDF and MAIN_DISABLE_FPDI can't be set together"; + + // We use by default TCPDF + if (empty($conf->global->MAIN_USE_FPDF)) require_once(TCPDF_PATH.'tcpdf.php'); // We need to instantiate fpdi object (instead of tcpdf) to use merging features. But we can disable it. if (empty($conf->global->MAIN_DISABLE_FPDI)) require_once(FPDI_PATH.'fpdi.php'); @@ -664,11 +668,14 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass /** * Show linked objects for PDF generation * - * @param PDF &$pdf Object PDF - * @param object $object Object - * @param Translate $outputlangs Object lang - * @param int $curx X - * @param int $cury Y + * @param PDF &$pdf Object PDF + * @param object $object Object + * @param Translate $outputlangs Object lang + * @param int $posx X + * @param int $posy Y + * @param int $align Align + * @param string $default_font_size Font size + * @param HookManager $hookmanager Hook manager object * @return void */ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$align,$default_font_size,$hookmanager=false) @@ -682,7 +689,7 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$align,$d $pdf->SetXY($posx,$posy); $pdf->SetFont('','', $default_font_size - 2); $pdf->MultiCell(100, 3, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', $align); - + if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"])) { $posy+=3; @@ -691,7 +698,7 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$align,$d } } } - + return $pdf->getY(); } @@ -1005,13 +1012,13 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanage */ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) + foreach($object->hooks as $modules) { - if (method_exists($hook['modules'][$special_code],'pdf_getlineupwithtax')) return $hook['modules'][$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails); + if (method_exists($modules[$special_code],'pdf_getlineupwithtax')) return $modules[$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails); } } else @@ -1222,13 +1229,13 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) } else { - if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - foreach($object->hooks as $hook) + foreach($object->hooks as $modules) { - if (method_exists($hook['modules'][$special_code],'pdf_getlinetotalwithtax')) return $hook['modules'][$special_code]->pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails); + if (method_exists($modules[$special_code],'pdf_getlinetotalwithtax')) return $modules[$special_code]->pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails); } } else @@ -1291,356 +1298,32 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false) */ function pdf_getCurrencySymbol(&$pdf, $currency_code) { - switch ($currency_code) { - case "ALL": - $currency_sign = " ".$pdf->unichr(76).$pdf->unichr(101).$pdf->unichr(107); - break; - case "AFN": - $currency_sign = " ".$pdf->unichr(1547); - break; - case "ARS": - $currency_sign = " ".$pdf->unichr(36); - break; - case "AWG": - $currency_sign = " ".$pdf->unichr(402); - break; - case "AUD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "AZN": - $currency_sign = " ".$pdf->unichr(1084).$pdf->unichr(1072).$pdf->unichr(1085); - break; - case "BSD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "BBD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "BYR": - $currency_sign = " ".$pdf->unichr(112).$pdf->unichr(46); - break; - case "BZD": - $currency_sign = " ".$pdf->unichr(66).$pdf->unichr(90).$pdf->unichr(36); - break; - case "BMD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "BOB": - $currency_sign = " ".$pdf->unichr(36).$pdf->unichr(98); - break; - case "BAM": - $currency_sign = " ".$pdf->unichr(75).$pdf->unichr(77); - break; - case "BWP": - $currency_sign = " ".$pdf->unichr(80); - break; - case "BGN": - $currency_sign = " ".$pdf->unichr(1083).$pdf->unichr(1074); - break; - case "BRL": - $currency_sign = " ".$pdf->unichr(82).$pdf->unichr(36); - break; - case "BND": - $currency_sign = " ".$pdf->unichr(36); - break; - case "KHR": - $currency_sign = " ".$pdf->unichr(6107); - break; - case "CAD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "KYD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "CLP": - $currency_sign = " ".$pdf->unichr(36); - break; - case "CNY": - $currency_sign = " ".$pdf->unichr(165); - break; - case "COP": - $currency_sign = " ".$pdf->unichr(36); - break; - case "CRC": - $currency_sign = " ".$pdf->unichr(8353); - break; - case "HRK": - $currency_sign = " ".$pdf->unichr(107).$pdf->unichr(110); - break; - case "CUP": - $currency_sign = " ".$pdf->unichr(8369); - break; - case "CZK": - $currency_sign = " ".$pdf->unichr(75).$pdf->unichr(269); - break; - case "DKK": - $currency_sign = " ".$pdf->unichr(107).$pdf->unichr(114); - break; - case "DOP": - $currency_sign = " ".$pdf->unichr(82).$pdf->unichr(68).$pdf->unichr(36); - break; - case "XCD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "EGP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "SVC": - $currency_sign = " ".$pdf->unichr(36); - break; - case "EEK": - $currency_sign = " ".$pdf->unichr(107).$pdf->unichr(114); - break; - case "EUR": - $currency_sign = " ".$pdf->unichr(8364); - break; - case "FKP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "FJD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "GHC": - $currency_sign = " ".$pdf->unichr(162); - break; - case "GIP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "GTQ": - $currency_sign = " ".$pdf->unichr(81); - break; - case "GGP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "GYD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "HNL": - $currency_sign = " ".$pdf->unichr(76); - break; - case "HKD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "HUF": - $currency_sign = " ".$pdf->unichr(70).$pdf->unichr(116); - break; - case "ISK": - $currency_sign = " ".$pdf->unichr(107).$pdf->unichr(114); - break; - case "INR": - $currency_sign = " ".$pdf->unichr(8377); - break; - case "IDR": - $currency_sign = " ".$pdf->unichr(82).$pdf->unichr(112); - break; - case "IRR": - $currency_sign = " ".$pdf->unichr(65020); - break; - case "IMP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "ILS": - $currency_sign = " ".$pdf->unichr(8362); - break; - case "JMD": - $currency_sign = " ".$pdf->unichr(74).$pdf->unichr(36); - break; - case "JPY": - $currency_sign = " ".$pdf->unichr(165); - break; - case "JEP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "KZT": - $currency_sign = " ".$pdf->unichr(1083).$pdf->unichr(1074); - break; - case "KPW": - $currency_sign = " ".$pdf->unichr(8361); - break; - case "KRW": - $currency_sign = " ".$pdf->unichr(8361); - break; - case "KGS": - $currency_sign = " ".$pdf->unichr(1083).$pdf->unichr(1074); - break; - case "LAK": - $currency_sign = " ".$pdf->unichr(8365); - break; - case "LVL": - $currency_sign = " ".$pdf->unichr(76).$pdf->unichr(115); - break; - case "LBP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "LRD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "LTL": - $currency_sign = " ".$pdf->unichr(76).$pdf->unichr(116); - break; - case "MKD": - $currency_sign = " ".$pdf->unichr(1076).$pdf->unichr(1077).$pdf->unichr(1085); - break; - case "MYR": - $currency_sign = " ".$pdf->unichr(82).$pdf->unichr(77); - break; - case "MUR": - $currency_sign = " ".$pdf->unichr(8360); - break; - case "MXN": - $currency_sign = " ".$pdf->unichr(36); - break; - case "MNT": - $currency_sign = " ".$pdf->unichr(8366); - break; - case "MZN": - $currency_sign = " ".$pdf->unichr(77).$pdf->unichr(84); - break; - case "NAD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "NPR": - $currency_sign = " ".$pdf->unichr(8360); - break; - case "ANG": - $currency_sign = " ".$pdf->unichr(402); - break; - case "NZD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "NIO": - $currency_sign = " ".$pdf->unichr(67).$pdf->unichr(36); - break; - case "NGN": - $currency_sign = " ".$pdf->unichr(8358); - break; - case "NOK": - $currency_sign = " ".$pdf->unichr(107).$pdf->unichr(114); - break; - case "OMR": - $currency_sign = " ".$pdf->unichr(65020); - break; - case "PKR": - $currency_sign = " ".$pdf->unichr(8360); - break; - case "PAB": - $currency_sign = " ".$pdf->unichr(66).$pdf->unichr(47).$pdf->unichr(46); - break; - case "PYG": - $currency_sign = " ".$pdf->unichr(71).$pdf->unichr(115); - break; - case "PEN": - $currency_sign = " ".$pdf->unichr(83).$pdf->unichr(47).$pdf->unichr(46); - break; - case "PHP": - $currency_sign = " ".$pdf->unichr(8369); - break; - case "PLN": - $currency_sign = " ".$pdf->unichr(122).$pdf->unichr(322); - break; - case "QAR": - $currency_sign = " ".$pdf->unichr(65020); - break; - case "RON": - $currency_sign = " ".$pdf->unichr(108).$pdf->unichr(101).$pdf->unichr(105); - break; - case "RUB": - $currency_sign = " ".$pdf->unichr(1088).$pdf->unichr(1091).$pdf->unichr(1073); - break; - case "SHP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "SAR": - $currency_sign = " ".$pdf->unichr(65020); - break; - case "RSD": - $currency_sign = " ".$pdf->unichr(1044).$pdf->unichr(1080).$pdf->unichr(1085).$pdf->unichr(46); - break; - case "SCR": - $currency_sign = " ".$pdf->unichr(8360); - break; - case "SGD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "SBD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "SOS": - $currency_sign = " ".$pdf->unichr(83); - break; - case "ZAR": - $currency_sign = " ".$pdf->unichr(82); - break; - case "LKR": - $currency_sign = " ".$pdf->unichr(8360); - break; - case "SEK": - $currency_sign = " ".$pdf->unichr(107).$pdf->unichr(114); - break; - case "CHF": - $currency_sign = " ".$pdf->unichr(67).$pdf->unichr(72).$pdf->unichr(70); - break; - case "SRD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "SYP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "TWD": - $currency_sign = " ".$pdf->unichr(78).$pdf->unichr(84).$pdf->unichr(36); - break; - case "THB": - $currency_sign = " ".$pdf->unichr(3647); - break; - case "TTD": - $currency_sign = " ".$pdf->unichr(84).$pdf->unichr(84).$pdf->unichr(36); - break; - case "TRY": - $currency_sign = " ".$pdf->unichr(84).$pdf->unichr(76); - break; - case "TRL": - $currency_sign = " ".$pdf->unichr(8356); - break; - case "TVD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "UAH": - $currency_sign = " ".$pdf->unichr(8372); - break; - case "GBP": - $currency_sign = " ".$pdf->unichr(163); - break; - case "USD": - $currency_sign = " ".$pdf->unichr(36); - break; - case "UYU": - $currency_sign = " ".$pdf->unichr(36).$pdf->unichr(85); - break; - case "UZS": - $currency_sign = " ".$pdf->unichr(1083).$pdf->unichr(1074); - break; - case "VEF": - $currency_sign = " ".$pdf->unichr(66).$pdf->unichr(115); - break; - case "VND": - $currency_sign = " ".$pdf->unichr(8363); - break; - case "YER": - $currency_sign = " ".$pdf->unichr(65020); - break; - case "ZWD": - $currency_sign = " ".$pdf->unichr(90).$pdf->unichr(36); - break; - default: - $currency_sign = " ".$currency_code; - break; - } + global $db, $form; + + $currency_sign = ''; + + if (! is_object($form)) $form = new Form($db); + + $form->load_cache_currencies(); + + if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) + { + foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode) + { + $currency_sign.= $pdf->unichr($unicode); + } + } + else + { + $currency_sign = $currency_code; + } + return $currency_sign; } /** * Return linked objects - * + * * @param object $object Object * @param Translate $outputlangs Object lang for output * @param HookManager $hookmanager Hook manager instance @@ -1649,7 +1332,7 @@ function pdf_getCurrencySymbol(&$pdf, $currency_code) function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false) { $linkedobjects=array(); - + $object->fetchObjectLinked(); foreach($object->linkedObjects as $objecttype => $objects) @@ -1679,7 +1362,7 @@ function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false) } } } - + // For add external linked objects if (is_object($hookmanager)) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 52e14a638d9..f025a34e045 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -139,6 +139,7 @@ function product_prepare_head($object, $user) * Return array head with list of tabs to view object informations. * * @param Object $object Product +* @param string $tab Tab id * @return array head array with tabs */ function product_admin_prepare_head($object, $tab) @@ -171,10 +172,11 @@ function product_admin_prepare_head($object, $tab) /** + * Show stats for company * - * Enter description here ... - * @param unknown_type $product - * @param unknown_type $socid + * @param Product $product Product object + * @param int $socid Thirdparty id + * @return void */ function show_stats_for_company($product,$socid) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index c99bc19d97a..dedd9f320a1 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -74,7 +74,7 @@ function project_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; + $head[$h][2] = 'notes'; $h++; // Then tab for sub level of projet, i mean tasks @@ -113,17 +113,17 @@ function task_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; $head[$h][1] = $langs->trans("Card"); - $head[$h][2] = 'task'; + $head[$h][2] = 'task_task'; $h++; $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; $head[$h][1] = $langs->trans("TaskRessourceLinks"); - $head[$h][2] = 'contact'; + $head[$h][2] = 'task_contact'; $h++; $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; $head[$h][1] = $langs->trans("TimeSpent"); - $head[$h][2] = 'time'; + $head[$h][2] = 'task_time'; $h++; // Show more tabs from modules @@ -138,12 +138,12 @@ function task_prepare_head($object) $listoffiles=dol_dir_list($filesdir,'files',1); $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ $head[$h][1] = $langs->trans('Documents'); - $head[$h][2] = 'document'; + $head[$h][2] = 'task_document'; $h++; $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');; $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; + $head[$h][2] = 'task_notes'; $h++; return $head; @@ -266,6 +266,7 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlen * @param int $showproject Show project columns * @param int &$taskrole Array of roles of user for each tasks * @param int $projectsListId List of id of project allowed to user (separated with comma) + * @return void */ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='') { diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 21990a8f3f3..de7470c07f0 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,11 +62,14 @@ function propal_prepare_head($object) $head[$h][2] = 'preview'; $h++; } - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('ProposalContact'); - $head[$h][2] = 'contact'; - $h++; + + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; + $h++; + } // Show more tabs from modules // Entries must be declared in modules descriptor with line @@ -74,13 +77,16 @@ function propal_prepare_head($object) // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'propal'); - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; - $h++; + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; + $h++; + } $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; - /*$filesdir = $conf->propale->dir_output . "/" . dol_sanitizeFileName($propal->ref); + /*$filesdir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($propal->ref); include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $listoffiles=dol_dir_list($filesdir,'files',1); $head[$h][1] = (count($listoffiles)?$langs->trans('DocumentsNb',count($listoffiles)):$langs->trans('Documents'));*/ diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5418334e559..561f2e2b88f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -171,7 +171,7 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature // Check write permission from module $createok=1; - if (GETPOST("action") && GETPOST("action") == 'create') + if (GETPOST("action") == 'create') { foreach ($features as $feature) { @@ -218,7 +218,7 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature // Check create user permission $createuserok=1; - if ( GETPOST("action") && (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes') ) + if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes') { if (! $user->rights->user->user->creer) $createuserok=0; @@ -228,7 +228,7 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature // Check delete permission from module $deleteok=1; - if ( GETPOST("action") && ( (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") && GETPOST("confirm") == 'yes') || GETPOST("action") == 'delete') ) + if ((GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes') || GETPOST("action") == 'delete') { foreach ($features as $feature) { diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 1055c494987..1a14077c8b6 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -53,6 +53,11 @@ function shipping_prepare_head($object) $h++; } + $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; + $head[$h][1] = $langs->trans("ContactsAddresses"); + $head[$h][2] = 'contact'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab @@ -133,7 +138,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='') $sql.= " AND obj.rowid = ed.fk_origin_line"; $sql.= " AND ed.fk_expedition = e.rowid"; if ($filter) $sql.= $filter; - + $sql.= " ORDER BY obj.fk_product"; dol_syslog("show_list_sending_receive sql=".$sql, LOG_DEBUG); diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index a3cd4e95ec8..fe66d16f2a4 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -72,68 +72,70 @@ function is_in_subtree($fulltree,$parentid,$childid) /** - * Show picto of a tree view - * + * Show indent and picto of a tree line. Return array with information of line. + * * @param array &$fulltree Array of entries in correct order * @param string $key Key of value to show picto - * @param int $selected Selected value - * @return array (0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after) + * @param int $silent Do not output indent and picto, returns only value + * @return array array(0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after, nbofdirinsub, nbofdocinsub) */ -function tree_showpad(&$fulltree,$key,$selected=0) +function tree_showpad(&$fulltree,$key,$silent=0) { $pos=1; // Loop on each pos, because we will output an img for each pos while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) { - // Process picto for column $pos + // Process for column $pos - $atleastonofthislevelafter=0; - $nbofhigherlevelafter=0; + $atleastoneofthislevelafter=0; $nbofdirinsub=0; $nbofdocinsub=0; $found=0; //print 'x'.$key; foreach($fulltree as $key2 => $val2) { + //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; if ($found == 1) // We are after the entry to show { if ($fulltree[$key2]['level'] > $pos) { $nbofdirinsub++; $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; - $nbofhigherlevelafter++; } if ($fulltree[$key2]['level'] == $pos) { - $atleastonofthislevelafter=1; + $atleastoneofthislevelafter=1; } if ($fulltree[$key2]['level'] <= $pos) { break; } } - if ($key2 == $key) + if ($key2 == $key) // We found ourself, so now every lower level will be counted { $found=1; } } - //print $atleastonofthislevelafter; + //print $atleastoneofthislevelafter; - if ($atleastonofthislevelafter) + if (! $silent) { - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); - else print img_picto_common('','treemenu/line.gif'); - } - else - { - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); - else print img_picto_common('','treemenu/linebottom.gif'); + if ($atleastoneofthislevelafter) + { + if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); + else print img_picto_common('','treemenu/line.gif'); + } + else + { + if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); + else print img_picto_common('','treemenu/linebottom.gif'); + } } $pos++; } - return array($atleastonofthislevelafter,$nbofhigherlevelafter,$nbofdirinsub,$nbofdocinsub); + return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); } @@ -142,7 +144,7 @@ function tree_showpad(&$fulltree,$key,$selected=0) /** * Show an element with correct offset - * + * * @param array $tab Array of all elements * @param int $rang Level of offset * @return void @@ -215,7 +217,7 @@ function tree_showline($tab,$rang) /** * Recursive function to output menu tree - * + * * @param array $tab Array of elements * @param int $pere Id of parent * @param int $rang Level of element diff --git a/htdocs/core/lib/ws.lib.php b/htdocs/core/lib/ws.lib.php index 7145f0c2aff..babe8609f6b 100755 --- a/htdocs/core/lib/ws.lib.php +++ b/htdocs/core/lib/ws.lib.php @@ -65,6 +65,12 @@ function check_authentication($authentication,&$error,&$errorcode,&$errorlabel) $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password'; } + if (! $error && $fuser->statut == 0) + { + $error++; + $errorcode='ERROR_USER_DISABLED'; $errorlabel='This user has been locked or disabled'; + } + // Validation of login if (! $error) { diff --git a/htdocs/core/login/functions_myopenid.php b/htdocs/core/login/functions_myopenid.php index c8c5e28cecb..958e4a63a88 100644 --- a/htdocs/core/login/functions_myopenid.php +++ b/htdocs/core/login/functions_myopenid.php @@ -137,26 +137,56 @@ class SimpleOpenID } } + /** + * SetOpenIDServer + * + * @param string $a Server + * @return void + */ function SetOpenIDServer($a) { $this->URLs['openid_server'] = $a; } + /** + * SetOpenIDServer + * + * @param string $a Server + * @return void + */ function SetTrustRoot($a) { $this->URLs['trust_root'] = $a; } + /** + * SetOpenIDServer + * + * @param string $a Server + * @return void + */ function SetCancelURL($a) { $this->URLs['cancel'] = $a; } + /** + * SetApprovedURL + * + * @param string $a Server + * @return void + */ function SetApprovedURL($a) { $this->URLs['approved'] = $a; } + /** + * SetRequiredFields + * + * @param string $a Server + * @return void + */ function SetRequiredFields($a) { if (is_array($a)){ @@ -166,6 +196,12 @@ class SimpleOpenID } } + /** + * SetOptionalFields + * + * @param string $a Server + * @return void + */ function SetOptionalFields($a) { if (is_array($a)){ @@ -175,6 +211,12 @@ class SimpleOpenID } } + /** + * SetIdentity + * + * @param string $a Server + * @return void + */ function SetIdentity($a) { // Set Identity URL if ((stripos($a, 'http://') === false) @@ -197,17 +239,34 @@ class SimpleOpenID $this->openid_url_identity = $a; } + /** + * GetIdentity + * + * @return void + */ function GetIdentity() { // Get Identity return $this->openid_url_identity; } + /** + * SetOpenIDServer + * + * @return void + */ function GetError() { $e = $this->error; return array('code'=>$e[0],'description'=>$e[1]); } + /** + * ErrorStore + * + * @param string $code Code + * @param string $desc Description + * @return void + */ function ErrorStore($code, $desc = null) { $errs['OPENID_NOSERVERSFOUND'] = 'Cannot find OpenID Server TAG on Identity page.'; @@ -217,15 +276,29 @@ class SimpleOpenID $this->error = array($code,$desc); } + /** + * IsError + * + * @return void + */ function IsError() { - if (count($this->error) > 0){ + if (count($this->error) > 0) + { return true; - }else{ + } + else + { return false; } } + /** + * splitResponse + * + * @param string $response Server + * @return void + */ function splitResponse($response) { $r = array(); @@ -240,6 +313,12 @@ class SimpleOpenID return $r; } + /** + * OpenID_Standarize + * + * @param string $openid_identity Server + * @return void + */ function OpenID_Standarize($openid_identity = null) { if ($openid_identity === null) @@ -353,6 +432,11 @@ class SimpleOpenID return $servers[0]; } + /** + * GetRedirectURL + * + * @return void + */ function GetRedirectURL() { $params = array(); @@ -372,18 +456,31 @@ class SimpleOpenID return $this->URLs['openid_server'] . "?". $this->array2url($params); } + /** + * Redirect + * + * @return void + */ function Redirect() { $redirect_to = $this->GetRedirectURL(); - if (headers_sent()){ // Use JavaScript to redirect if content has been previously sent (not recommended, but safe) + if (headers_sent()) + { // Use JavaScript to redirect if content has been previously sent (not recommended, but safe) echo ''; - }else{ // Default Header Redirect + } + else + { // Default Header Redirect header('Location: ' . $redirect_to); } } + /** + * ValidateWithServer + * + * @return void + */ function ValidateWithServer() { $params = array( @@ -405,14 +502,18 @@ class SimpleOpenID $params['openid.mode'] = "check_authentication"; $openid_server = $this->GetOpenIDServer(); - if ($openid_server == false){ + if ($openid_server == false) + { return false; } $response = $this->CURL_Request($openid_server,'POST',$params); $data = $this->splitResponse($response); - if ($data['is_valid'] == "true") { + if ($data['is_valid'] == "true") + { return true; - }else{ + } + else + { return false; } } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 721b3dd4549..cbd5b5da82e 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -70,8 +70,8 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 509__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/comm/list.php?leftmenu=customers', 'ListCustomersShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 4, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 510__+MAX_llx_menu__, 'companies', '', 509__+MAX_llx_menu__, '/societe/soc.php?leftmenu=customers&action=create&type=c', 'MenuNewCustomer', 2, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); -- Third parties - Contacts -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 600__+MAX_llx_menu__, 'companies', 'contacts', 2__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts', 'ContactsAddresses', 0, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 601__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/fiche.php?leftmenu=contacts&action=create', 'NewContact', 1, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 600__+MAX_llx_menu__, 'companies', 'contacts', 2__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts', 'ContactsAddresses||Contacts@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT', 0, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 601__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/fiche.php?leftmenu=contacts&action=create', 'NewContactAddress||NewContact@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT', 1, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 602__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 604__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts&type=p', 'Prospects', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 605__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts&type=c', 'Customers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 2, __ENTITY__); diff --git a/htdocs/core/menus/init_menu_smartphone.sql b/htdocs/core/menus/init_menu_smartphone.sql index 482cb3cc6ff..1e8a17911be 100755 --- a/htdocs/core/menus/init_menu_smartphone.sql +++ b/htdocs/core/menus/init_menu_smartphone.sql @@ -67,8 +67,8 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 509__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/comm/list.php?leftmenu=customers', 'ListCustomersShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 4, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 510__+MAX_llx_menu__, 'companies', '', 509__+MAX_llx_menu__, '/societe/soc.php?leftmenu=customers&action=create&type=c', 'MenuNewCustomer', 2, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); -- Third parties - Contacts -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 600__+MAX_llx_menu__, 'companies', '', 2__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts', 'ContactsAddresses', 0, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 601__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/fiche.php?leftmenu=contacts&action=create', 'NewContact', 1, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 600__+MAX_llx_menu__, 'companies', '', 2__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts', 'ContactsAddresses||Contacts@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT', 0, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 601__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/fiche.php?leftmenu=contacts&action=create', 'NewContactAddress||NewContact@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT', 1, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 602__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 604__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts&type=p', 'Prospects', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 605__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts&type=c', 'Customers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 2, __ENTITY__); @@ -125,7 +125,7 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 803__+MAX_llx_menu__, 'commercial', '', 800__+MAX_llx_menu__, '/contact/list.php?leftmenu=customers&type=c', 'Contacts', 1, 'companies', '$user->rights->societe->lire', '', 0, 2, __ENTITY__); -- Commercial - Contacts insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 900__+MAX_llx_menu__, 'commercial', '', 5__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts', 'Contacts', 0, 'companies', '$user->rights->societe->lire', '', 0, 3, __ENTITY__); -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 901__+MAX_llx_menu__, 'commercial', '', 900__+MAX_llx_menu__, '/contact/fiche.php?leftmenu=contacts&action=create', 'NewContact', 1, 'companies', '$user->rights->societe->creer', '', 0, 0, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 901__+MAX_llx_menu__, 'commercial', '', 900__+MAX_llx_menu__, '/contact/fiche.php?leftmenu=contacts&action=create', 'NewContactAddress||NewContact@$conf->global->SOCIETE_ADDRESSES_MANAGEMENT', 1, 'companies', '$user->rights->societe->creer', '', 0, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', __HANDLER__, 'left', 902__+MAX_llx_menu__, 'commercial', '', 900__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts&action=create', 'List', 1, 'companies', '$user->rights->societe->lire', '', 0, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled && $leftmenu=="prospects"', __HANDLER__, 'left', 910__+MAX_llx_menu__, 'commercial', '', 902__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts&type=p', 'Prospects', 1, 'companies', '$user->rights->societe->lire', '', 0, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled && $leftmenu=="prospects"', __HANDLER__, 'left', 911__+MAX_llx_menu__, 'commercial', '', 902__+MAX_llx_menu__, '/contact/list.php?leftmenu=contacts&type=c', 'Customers', 1, 'companies', '$user->rights->societe->lire', '', 0, 1, __ENTITY__); diff --git a/htdocs/core/menus/smartphone/smartphone.lib.php b/htdocs/core/menus/smartphone/smartphone.lib.php index 5750f883c9d..6895867cbd8 100755 --- a/htdocs/core/menus/smartphone/smartphone.lib.php +++ b/htdocs/core/menus/smartphone/smartphone.lib.php @@ -26,10 +26,11 @@ /** * Core function to output top menu smartphone * - * @param $db - * @param $atarget - * @param $type_user 0=Internal,1=External,2=All - * @param $limitmenuto To limit menu to a top or left menu value + * @param DoliDB $db Database handler + * @param string $atarget Target + * @param int $type_user 0=Internal,1=External,2=All + * @param string $limitmenuto To limit menu to a top or left menu value + * @return void */ function print_smartphone_menu($db,$atarget,$type_user,$limitmenuto) { @@ -141,34 +142,66 @@ function print_smartphone_menu($db,$atarget,$type_user,$limitmenuto) print "\n"; } +/** + * Output menu entry + * + * @param string $theme Theme + * @return void + */ function print_start_menu_array($theme='c') { print '
      '; print "\n"; } +/** + * Output start submenu entry + * + * @return void + */ function print_start_submenu_array() { print '
        '; print "\n"; } +/** + * Output start menu entry + * + * @return void + */ function print_start_menu_entry() { print '
      • '; } +/** + * Output menu entry + * + * @param string $text Text + * @return void + */ function print_text_menu_entry($text) { print $text; } +/** + * Output end menu entry + * + * @return void + */ function print_end_menu_entry() { print '
      • '; print "\n"; } +/** + * Output end menu + * + * @return void + */ function print_end_menu() { print '
      '; diff --git a/htdocs/core/menus/smartphone/smartphone_backoffice.php b/htdocs/core/menus/smartphone/smartphone_backoffice.php index d1cb1feb89b..f19ac45351a 100755 --- a/htdocs/core/menus/smartphone/smartphone_backoffice.php +++ b/htdocs/core/menus/smartphone/smartphone_backoffice.php @@ -25,8 +25,8 @@ /** * Class to manage smartphone menu smartphone (for internal users) */ -class MenuSmart { - +class MenuSmart +{ var $db; var $require_left=array("smartphone_backoffice"); // Si doit etre en phase avec un gestionnaire de menu particulier var $hideifnotallowed=0; // Put 0 for back office menu, 1 for front office menu @@ -46,7 +46,7 @@ class MenuSmart { /** * Show menu - * + * * @param string $limitmenuto To limit menu to a top or left menu value * @return void */ diff --git a/htdocs/core/menus/smartphone/smartphone_frontoffice.php b/htdocs/core/menus/smartphone/smartphone_frontoffice.php index 4be38b571c8..0739e894db3 100755 --- a/htdocs/core/menus/smartphone/smartphone_frontoffice.php +++ b/htdocs/core/menus/smartphone/smartphone_frontoffice.php @@ -23,10 +23,10 @@ /** - * \class MenuSmart - * \brief Class to manage smartphone menu smartphone (for external users) + * Class to manage smartphone menu smartphone (for external users) */ -class MenuSmart { +class MenuSmart +{ var $require_left=array("smartphone_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu particulier var $hideifnotallowed=1; // Put 0 for back office menu, 1 for front office menu @@ -36,7 +36,7 @@ class MenuSmart { /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function MenuSmart($db) { @@ -47,7 +47,7 @@ class MenuSmart { /** * Show menu * - * @param limitmenuto To limit menu to a top or left menu value + * @param string $limitmenuto To limit menu to a top or left menu value */ function showmenu($limitmenuto) { diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 336e35461c0..de947d7edc3 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010 Regis Houssin +/* Copyright (C) 2010 Laurent Destailleur + * Copyright (C) 2010-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -108,7 +108,11 @@ function print_auguria_menu($db,$atarget,$type_user) } - +/** + * Output start menu entry + * + * @return void + */ function print_start_menu_array_auguria() { global $conf; @@ -116,6 +120,12 @@ function print_start_menu_array_auguria() else print '
        '; } +/** + * Output menu entry + * + * @param string $idsel Text + * @return void + */ function print_start_menu_entry_auguria($idsel) { global $conf; @@ -123,6 +133,12 @@ function print_start_menu_entry_auguria($idsel) else print '
    trans('VAT'); ?> trans('PriceUHT'); ?> trans('Qty'); ?>
    - + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> +
    global->MAIN_VIEW_LINE_NUMBER)) { ?>
    +
    info_bits & 2) == 2) { ?> '."\n"; if (constant('JS_JQUERY_UI')) print ''."\n"; // JQuery else print ''."\n"; // JQuery // JQuery. Must be before other includes +$ext='.js'; +if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) $ext='.jgz'; print ''."\n"; if (constant('JS_JQUERY')) print ''."\n"; else print ''."\n"; +print ''."\n"; print ' ');else h.push('');}return h.join('');},htmlEncode:function(f){var g=function(k){var l=new d.element('span');l.setText(k);return l.getHtml();},h=g('\n').toLowerCase()=='
    '?function(k){return g(k).replace(/
    /gi,'\n');}:g,i=g('>')=='>'?function(k){return h(k).replace(/>/g,'>');}:h,j=g(' ')=='  '?function(k){return i(k).replace(/ /g,' ');}:i;this.htmlEncode=j;return this.htmlEncode(f);},htmlEncodeAttr:function(f){return f.replace(/"/g,'"').replace(//g,'>');},getNextNumber:(function(){var f=0;return function(){return++f;};})(),getNextId:function(){return 'cke_'+this.getNextNumber();},override:function(f,g){return g(f);},setTimeout:function(f,g,h,i,j){if(!j)j=window;if(!h)h=j;return j.setTimeout(function(){if(i)f.apply(h,[].concat(i));else f.apply(h);},g||0);},trim:(function(){var f=/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g;return function(g){return g.replace(f,'');};})(),ltrim:(function(){var f=/^[ \t\n\r]+/g;return function(g){return g.replace(f,'');};})(),rtrim:(function(){var f=/[ \t\n\r]+$/g;return function(g){return g.replace(f,'');};})(),indexOf:Array.prototype.indexOf?function(f,g){return f.indexOf(g);}:function(f,g){for(var h=0,i=f.length;h',a.document);a.document.getBody().append(f);}if(!/%$/.test(g)){f.setStyle('width',g);return f.$.clientWidth;}return g;};})(),repeat:function(f,g){return new Array(g+1).join(f);},tryThese:function(){var f;for(var g=0,h=arguments.length;g8))&&i)h=i+':'+h;return new d.nodeList(this.$.getElementsByTagName(h));},getHead:function(){var h=this.$.getElementsByTagName('head')[0];if(!h)h=this.getDocumentElement().append(new d.element('head'),true);else h=new d.element(h);return(this.getHead=function(){return h;})();},getBody:function(){var h=new d.element(this.$.body);return(this.getBody=function(){return h;})();},getDocumentElement:function(){var h=new d.element(this.$.documentElement);return(this.getDocumentElement=function(){return h;})();},getWindow:function(){var h=new d.window(this.$.parentWindow||this.$.defaultView);return(this.getWindow=function(){return h;})();},write:function(h){var i=this;i.$.open('text/html','replace');b.isCustomDomain()&&(i.$.domain=document.domain);i.$.write(h);i.$.close();}});d.node=function(h){if(h){switch(h.nodeType){case 9:return new g(h);case 1:return new d.element(h);case 3:return new d.text(h);}d.domObject.call(this,h);}return this;};d.node.prototype=new d.domObject();a.NODE_ELEMENT=1;a.NODE_DOCUMENT=9;a.NODE_TEXT=3;a.NODE_COMMENT=8;a.NODE_DOCUMENT_FRAGMENT=11;a.POSITION_IDENTICAL=0;a.POSITION_DISCONNECTED=1;a.POSITION_FOLLOWING=2; a.POSITION_PRECEDING=4;a.POSITION_IS_CONTAINED=8;a.POSITION_CONTAINS=16;e.extend(d.node.prototype,{appendTo:function(h,i){h.append(this,i);return h;},clone:function(h,i){var j=this.$.cloneNode(h),k=function(l){if(l.nodeType!=1)return;if(!i)l.removeAttribute('id',false);l.removeAttribute('data-cke-expando',false);if(h){var m=l.childNodes;for(var n=0;n]*>/g,''):i; -},getOuterHtml:function(){var j=this;if(j.$.outerHTML)return j.$.outerHTML.replace(/<\?[^>]*>/,'');var i=j.$.ownerDocument.createElement('div');i.appendChild(j.$.cloneNode(true));return i.innerHTML;},setHtml:function(i){return this.$.innerHTML=i;},setText:function(i){h.prototype.setText=this.$.innerText!=undefined?function(j){return this.$.innerText=j;}:function(j){return this.$.textContent=j;};return this.setText(i);},getAttribute:(function(){var i=function(j){return this.$.getAttribute(j,2);};if(c&&(b.ie7Compat||b.ie6Compat))return function(j){var n=this;switch(j){case 'class':j='className';break;case 'http-equiv':j='httpEquiv';break;case 'name':return n.$.name;case 'tabindex':var k=i.call(n,j);if(k!==0&&n.$.tabIndex===0)k=null;return k;break;case 'checked':var l=n.$.attributes.getNamedItem(j),m=l.specified?l.nodeValue:n.$.checked;return m?'checked':null;case 'hspace':case 'value':return n.$[j];case 'style':return n.$.style.cssText;}return i.call(n,j);};else return i;})(),getChildren:function(){return new d.nodeList(this.$.childNodes);},getComputedStyle:c?function(i){return this.$.currentStyle[e.cssStyleToDomStyle(i)];}:function(i){return this.getWindow().$.getComputedStyle(this.$,'').getPropertyValue(i);},getDtd:function(){var i=f[this.getName()];this.getDtd=function(){return i;};return i;},getElementsByTag:g.prototype.getElementsByTag,getTabIndex:c?function(){var i=this.$.tabIndex;if(i===0&&!f.$tabIndex[this.getName()]&&parseInt(this.getAttribute('tabindex'),10)!==0)i=-1;return i;}:b.webkit?function(){var i=this.$.tabIndex;if(i==undefined){i=parseInt(this.getAttribute('tabindex'),10);if(isNaN(i))i=-1;}return i;}:function(){return this.$.tabIndex;},getText:function(){return this.$.textContent||this.$.innerText||'';},getWindow:function(){return this.getDocument().getWindow();},getId:function(){return this.$.id||null;},getNameAtt:function(){return this.$.name||null;},getName:function(){var i=this.$.nodeName.toLowerCase();if(c&&!(document.documentMode>8)){var j=this.$.scopeName;if(j!='HTML')i=j.toLowerCase()+':'+i;}return(this.getName=function(){return i;})();},getValue:function(){return this.$.value;},getFirst:function(i){var j=this.$.firstChild,k=j&&new d.node(j);if(k&&i&&!i(k))k=k.getNext(i);return k;},getLast:function(i){var j=this.$.lastChild,k=j&&new d.node(j);if(k&&i&&!i(k))k=k.getPrevious(i);return k;},getStyle:function(i){return this.$.style[e.cssStyleToDomStyle(i)];},is:function(){var i=this.getName();for(var j=0;j0&&(j>2||!k[i[0].nodeName]||j==2&&!k[i[1].nodeName]);},hasAttribute:(function(){function i(j){var k=this.$.attributes.getNamedItem(j);return!!(k&&k.specified);};return c&&b.version<8?function(j){if(j=='name')return!!this.$.name;return i.call(this,j);}:i;})(),hide:function(){this.setStyle('display','none');},moveChildren:function(i,j){var k=this.$;i=i.$;if(k==i)return;var l;if(j)while(l=k.lastChild)i.insertBefore(k.removeChild(l),i.firstChild);else while(l=k.firstChild)i.appendChild(k.removeChild(l));},mergeSiblings:(function(){function i(j,k,l){if(k&&k.type==1){var m=[];while(k.data('cke-bookmark')||k.isEmptyInlineRemoveable()){m.push(k);k=l?k.getNext():k.getPrevious();if(!k||k.type!=1)return;}if(j.isIdentical(k)){var n=l?j.getLast():j.getFirst();while(m.length)m.shift().move(j,!l);k.moveChildren(j,!l);k.remove();if(n&&n.type==1)n.mergeSiblings();}}};return function(j){var k=this;if(!(j===false||f.$removeEmpty[k.getName()]||k.is('a')))return;i(k,k.getNext(),true); -i(k,k.getPrevious());};})(),show:function(){this.setStyles({display:'',visibility:''});},setAttribute:(function(){var i=function(j,k){this.$.setAttribute(j,k);return this;};if(c&&(b.ie7Compat||b.ie6Compat))return function(j,k){var l=this;if(j=='class')l.$.className=k;else if(j=='style')l.$.style.cssText=k;else if(j=='tabindex')l.$.tabIndex=k;else if(j=='checked')l.$.checked=k;else i.apply(l,arguments);return l;};else if(b.ie8Compat&&b.secure)return function(j,k){if(j=='src'&&k.match(/^http:\/\//))try{i.apply(this,arguments);}catch(l){}else i.apply(this,arguments);return this;};else return i;})(),setAttributes:function(i){for(var j in i)this.setAttribute(j,i[j]);return this;},setValue:function(i){this.$.value=i;return this;},removeAttribute:(function(){var i=function(j){this.$.removeAttribute(j);};if(c&&(b.ie7Compat||b.ie6Compat))return function(j){if(j=='class')j='className';else if(j=='tabindex')j='tabIndex';i.call(this,j);};else return i;})(),removeAttributes:function(i){if(e.isArray(i))for(var j=0;j=100?'':'progid:DXImageTransform.Microsoft.Alpha(opacity='+i+')');}else this.setStyle('opacity',i);},unselectable:b.gecko?function(){this.$.style.MozUserSelect='none';this.on('dragstart',function(i){i.data.preventDefault();});}:b.webkit?function(){this.$.style.KhtmlUserSelect='none';this.on('dragstart',function(i){i.data.preventDefault();});}:function(){if(c||b.opera){var i=this.$,j,k=0;i.unselectable='on';while(j=i.all[k++])switch(j.tagName.toLowerCase()){case 'iframe':case 'textarea':case 'input':case 'select':break;default:j.unselectable='on';}}},getPositionedAncestor:function(){var i=this;while(i.getName()!='html'){if(i.getComputedStyle('position')!='static')return i;i=i.getParent();}return null;},getDocumentPosition:function(i){var D=this;var j=0,k=0,l=D.getDocument().getBody(),m=D.getDocument().$.compatMode=='BackCompat',n=D.getDocument();if(document.documentElement.getBoundingClientRect){var o=D.$.getBoundingClientRect(),p=n.$,q=p.documentElement,r=q.clientTop||l.$.clientTop||0,s=q.clientLeft||l.$.clientLeft||0,t=true; -if(c){var u=n.getDocumentElement().contains(D),v=n.getBody().contains(D);t=m&&v||!m&&u;}if(t){j=o.left+(!m&&q.scrollLeft||l.$.scrollLeft);j-=s;k=o.top+(!m&&q.scrollTop||l.$.scrollTop);k-=r;}}else{var w=D,x=null,y;while(w&&!(w.getName()=='body'||w.getName()=='html')){j+=w.$.offsetLeft-w.$.scrollLeft;k+=w.$.offsetTop-w.$.scrollTop;if(!w.equals(D)){j+=w.$.clientLeft||0;k+=w.$.clientTop||0;}var z=x;while(z&&!z.equals(w)){j-=z.$.scrollLeft;k-=z.$.scrollTop;z=z.getParent();}x=w;w=(y=w.$.offsetParent)?new h(y):null;}}if(i){var A=D.getWindow(),B=i.getWindow();if(!A.equals(B)&&A.$.frameElement){var C=new h(A.$.frameElement).getDocumentPosition(i);j+=C.x;k+=C.y;}}if(!document.documentElement.getBoundingClientRect)if(b.gecko&&!m){j+=D.$.clientLeft?1:0;k+=D.$.clientTop?1:0;}return{x:j,y:k};},scrollIntoView:function(i){var o=this;var j=o.getWindow(),k=j.getViewPaneSize().height,l=k*-1;if(i)l+=k;else{l+=o.$.offsetHeight||0;l+=parseInt(o.getComputedStyle('marginBottom')||0,10)||0;}var m=o.getDocumentPosition();l+=m.y;l=l<0?0:l;var n=j.getScrollPosition().y;if(l>n||lwindow.setTimeout(function(){window.close();},50);")');}return i&&new g(i.contentWindow.document);},copyAttributes:function(i,j){var p=this;var k=p.$.attributes;j=j||{};for(var l=0;l0&&j)j=j.childNodes[i.shift()];return j?new d.node(j):null;},getChildCount:function(){return this.$.childNodes.length; -},disableContextMenu:function(){this.on('contextmenu',function(i){if(!i.data.getTarget().hasClass('cke_enable_context_menu'))i.data.preventDefault();});},getDirection:function(i){var j=this;return i?j.getComputedStyle('direction')||j.getDirection()||j.getDocument().$.dir||j.getDocument().getBody().getDirection(1):j.getStyle('direction')||j.getAttribute('dir');},data:function(i,j){i='data-'+i;if(j===undefined)return this.getAttribute(i);else if(j===false)this.removeAttribute(i);else this.setAttribute(i,j);return null;}});(function(){var i={width:['border-left-width','border-right-width','padding-left','padding-right'],height:['border-top-width','border-bottom-width','padding-top','padding-bottom']};function j(k){var l=0;for(var m=0,n=i[k].length;m',bodyId:'',bodyClass:'',fullPage:false,height:200,plugins:'about,a11yhelp,basicstyles,bidi,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,dialogadvtab,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,iframe,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',extraPlugins:'',removePlugins:'',protectedSource:[],tabIndex:0,theme:'default',skin:'kama',width:'',baseFloatZIndex:10000}; -var i=a.config;a.focusManager=function(j){if(j.focusManager)return j.focusManager;this.hasFocus=false;this._={editor:j};return this;};a.focusManager.prototype={focus:function(){var k=this;if(k._.timer)clearTimeout(k._.timer);if(!k.hasFocus){if(a.currentInstance)a.currentInstance.focusManager.forceBlur();var j=k._.editor;j.container.getChild(1).addClass('cke_focus');k.hasFocus=true;j.fire('focus');}},blur:function(){var j=this;if(j._.timer)clearTimeout(j._.timer);j._.timer=setTimeout(function(){delete j._.timer;j.forceBlur();},100);},forceBlur:function(){if(this.hasFocus){var j=this._.editor;j.container.getChild(1).removeClass('cke_focus');this.hasFocus=false;j.fire('blur');}}};(function(){var j={};a.lang={languages:{af:1,ar:1,bg:1,bn:1,bs:1,ca:1,cs:1,cy:1,da:1,de:1,el:1,'en-au':1,'en-ca':1,'en-gb':1,en:1,eo:1,es:1,et:1,eu:1,fa:1,fi:1,fo:1,'fr-ca':1,fr:1,gl:1,gu:1,he:1,hi:1,hr:1,hu:1,is:1,it:1,ja:1,ka:1,km:1,ko:1,lt:1,lv:1,mn:1,ms:1,nb:1,nl:1,no:1,pl:1,'pt-br':1,pt:1,ro:1,ru:1,sk:1,sl:1,'sr-latn':1,sr:1,sv:1,th:1,tr:1,uk:1,vi:1,'zh-cn':1,zh:1},load:function(k,l,m){if(!k||!a.lang.languages[k])k=this.detect(l,k);if(!this[k])a.scriptLoader.load(a.getUrl('lang/'+k+'.js'),function(){m(k,this[k]);},this);else m(k,this[k]);},detect:function(k,l){var m=this.languages;l=l||navigator.userLanguage||navigator.language;var n=l.toLowerCase().match(/([a-z]+)(?:-([a-z]+))?/),o=n[1],p=n[2];if(m[o+'-'+p])o=o+'-'+p;else if(!m[o])o=null;a.lang.detect=o?function(){return o;}:function(q){return q;};return o||k;}};})();a.scriptLoader=(function(){var j={},k={};return{load:function(l,m,n,o){var p=typeof l=='string';if(p)l=[l];if(!n)n=a;var q=l.length,r=[],s=[],t=function(y){if(m)if(p)m.call(n,y);else m.call(n,r,s);};if(q===0){t(true);return;}var u=function(y,z){(z?r:s).push(y);if(--q<=0){o&&a.document.getDocumentElement().removeStyle('cursor');t(z);}},v=function(y,z){j[y]=1;var A=k[y];delete k[y];for(var B=0;B1)return;var A=new h('script');A.setAttributes({type:'text/javascript',src:y});if(m)if(c)A.$.onreadystatechange=function(){if(A.$.readyState=='loaded'||A.$.readyState=='complete'){A.$.onreadystatechange=null;v(y,true);}};else{A.$.onload=function(){setTimeout(function(){v(y,true);},0);};A.$.onerror=function(){v(y,false);};}A.appendTo(a.document.getHead());};o&&a.document.getDocumentElement().setStyle('cursor','wait');for(var x=0;x]*>/g,''):i;},getOuterHtml:function(){var j=this;if(j.$.outerHTML)return j.$.outerHTML.replace(/<\?[^>]*>/,'');var i=j.$.ownerDocument.createElement('div');i.appendChild(j.$.cloneNode(true));return i.innerHTML;},setHtml:function(i){return this.$.innerHTML=i;},setText:function(i){h.prototype.setText=this.$.innerText!=undefined?function(j){return this.$.innerText=j;}:function(j){return this.$.textContent=j;};return this.setText(i);},getAttribute:(function(){var i=function(j){return this.$.getAttribute(j,2);};if(c&&(b.ie7Compat||b.ie6Compat))return function(j){var n=this;switch(j){case 'class':j='className';break;case 'http-equiv':j='httpEquiv';break;case 'name':return n.$.name;case 'tabindex':var k=i.call(n,j);if(k!==0&&n.$.tabIndex===0)k=null;return k;break;case 'checked':var l=n.$.attributes.getNamedItem(j),m=l.specified?l.nodeValue:n.$.checked;return m?'checked':null;case 'hspace':case 'value':return n.$[j];case 'style':return n.$.style.cssText;}return i.call(n,j);};else return i;})(),getChildren:function(){return new d.nodeList(this.$.childNodes);},getComputedStyle:c?function(i){return this.$.currentStyle[e.cssStyleToDomStyle(i)];}:function(i){return this.getWindow().$.getComputedStyle(this.$,'').getPropertyValue(i);},getDtd:function(){var i=f[this.getName()];this.getDtd=function(){return i;};return i;},getElementsByTag:g.prototype.getElementsByTag,getTabIndex:c?function(){var i=this.$.tabIndex;if(i===0&&!f.$tabIndex[this.getName()]&&parseInt(this.getAttribute('tabindex'),10)!==0)i=-1;return i;}:b.webkit?function(){var i=this.$.tabIndex;if(i==undefined){i=parseInt(this.getAttribute('tabindex'),10);if(isNaN(i))i=-1;}return i;}:function(){return this.$.tabIndex;},getText:function(){return this.$.textContent||this.$.innerText||'';},getWindow:function(){return this.getDocument().getWindow();},getId:function(){return this.$.id||null;},getNameAtt:function(){return this.$.name||null;},getName:function(){var i=this.$.nodeName.toLowerCase();if(c&&!(document.documentMode>8)){var j=this.$.scopeName;if(j!='HTML')i=j.toLowerCase()+':'+i;}return(this.getName=function(){return i;})();},getValue:function(){return this.$.value;},getFirst:function(i){var j=this.$.firstChild,k=j&&new d.node(j);if(k&&i&&!i(k))k=k.getNext(i);return k;},getLast:function(i){var j=this.$.lastChild,k=j&&new d.node(j);if(k&&i&&!i(k))k=k.getPrevious(i);return k;},getStyle:function(i){return this.$.style[e.cssStyleToDomStyle(i)]; +},is:function(){var i=this.getName();for(var j=0;j0&&(j>2||!k[i[0].nodeName]||j==2&&!k[i[1].nodeName]);},hasAttribute:(function(){function i(j){var k=this.$.attributes.getNamedItem(j);return!!(k&&k.specified);};return c&&b.version<8?function(j){if(j=='name')return!!this.$.name;return i.call(this,j);}:i;})(),hide:function(){this.setStyle('display','none');},moveChildren:function(i,j){var k=this.$;i=i.$;if(k==i)return;var l;if(j)while(l=k.lastChild)i.insertBefore(k.removeChild(l),i.firstChild);else while(l=k.firstChild)i.appendChild(k.removeChild(l));},mergeSiblings:(function(){function i(j,k,l){if(k&&k.type==1){var m=[];while(k.data('cke-bookmark')||k.isEmptyInlineRemoveable()){m.push(k);k=l?k.getNext():k.getPrevious();if(!k||k.type!=1)return;}if(j.isIdentical(k)){var n=l?j.getLast():j.getFirst(); +while(m.length)m.shift().move(j,!l);k.moveChildren(j,!l);k.remove();if(n&&n.type==1)n.mergeSiblings();}}};return function(j){var k=this;if(!(j===false||f.$removeEmpty[k.getName()]||k.is('a')))return;i(k,k.getNext(),true);i(k,k.getPrevious());};})(),show:function(){this.setStyles({display:'',visibility:''});},setAttribute:(function(){var i=function(j,k){this.$.setAttribute(j,k);return this;};if(c&&(b.ie7Compat||b.ie6Compat))return function(j,k){var l=this;if(j=='class')l.$.className=k;else if(j=='style')l.$.style.cssText=k;else if(j=='tabindex')l.$.tabIndex=k;else if(j=='checked')l.$.checked=k;else i.apply(l,arguments);return l;};else if(b.ie8Compat&&b.secure)return function(j,k){if(j=='src'&&k.match(/^http:\/\//))try{i.apply(this,arguments);}catch(l){}else i.apply(this,arguments);return this;};else return i;})(),setAttributes:function(i){for(var j in i)this.setAttribute(j,i[j]);return this;},setValue:function(i){this.$.value=i;return this;},removeAttribute:(function(){var i=function(j){this.$.removeAttribute(j);};if(c&&(b.ie7Compat||b.ie6Compat))return function(j){if(j=='class')j='className';else if(j=='tabindex')j='tabIndex';i.call(this,j);};else return i;})(),removeAttributes:function(i){if(e.isArray(i))for(var j=0;j=100?'':'progid:DXImageTransform.Microsoft.Alpha(opacity='+i+')');}else this.setStyle('opacity',i);},unselectable:b.gecko?function(){this.$.style.MozUserSelect='none';this.on('dragstart',function(i){i.data.preventDefault();});}:b.webkit?function(){this.$.style.KhtmlUserSelect='none';this.on('dragstart',function(i){i.data.preventDefault();});}:function(){if(c||b.opera){var i=this.$,j,k=0;i.unselectable='on';while(j=i.all[k++])switch(j.tagName.toLowerCase()){case 'iframe':case 'textarea':case 'input':case 'select':break;default:j.unselectable='on';}}},getPositionedAncestor:function(){var i=this;while(i.getName()!='html'){if(i.getComputedStyle('position')!='static')return i;i=i.getParent();}return null;},getDocumentPosition:function(i){var D=this; +var j=0,k=0,l=D.getDocument(),m=l.getBody(),n=l.$.compatMode=='BackCompat';if(document.documentElement.getBoundingClientRect){var o=D.$.getBoundingClientRect(),p=l.$,q=p.documentElement,r=q.clientTop||m.$.clientTop||0,s=q.clientLeft||m.$.clientLeft||0,t=true;if(c){var u=l.getDocumentElement().contains(D),v=l.getBody().contains(D);t=n&&v||!n&&u;}if(t){j=o.left+(!n&&q.scrollLeft||m.$.scrollLeft);j-=s;k=o.top+(!n&&q.scrollTop||m.$.scrollTop);k-=r;}}else{var w=D,x=null,y;while(w&&!(w.getName()=='body'||w.getName()=='html')){j+=w.$.offsetLeft-w.$.scrollLeft;k+=w.$.offsetTop-w.$.scrollTop;if(!w.equals(D)){j+=w.$.clientLeft||0;k+=w.$.clientTop||0;}var z=x;while(z&&!z.equals(w)){j-=z.$.scrollLeft;k-=z.$.scrollTop;z=z.getParent();}x=w;w=(y=w.$.offsetParent)?new h(y):null;}}if(i){var A=D.getWindow(),B=i.getWindow();if(!A.equals(B)&&A.$.frameElement){var C=new h(A.$.frameElement).getDocumentPosition(i);j+=C.x;k+=C.y;}}if(!document.documentElement.getBoundingClientRect)if(b.gecko&&!n){j+=D.$.clientLeft?1:0;k+=D.$.clientTop?1:0;}return{x:j,y:k};},scrollIntoView:function(i){var o=this;var j=o.getWindow(),k=j.getViewPaneSize().height,l=k*-1;if(i)l+=k;else{l+=o.$.offsetHeight||0;l+=parseInt(o.getComputedStyle('marginBottom')||0,10)||0;}var m=o.getDocumentPosition();l+=m.y;l=l<0?0:l;var n=j.getScrollPosition().y;if(l>n||lwindow.setTimeout(function(){window.close();},50);")');}return i&&new g(i.contentWindow.document);},copyAttributes:function(i,j){var p=this;var k=p.$.attributes;j=j||{};for(var l=0;l0&&j)j=j.childNodes[i.shift()];return j?new d.node(j):null;},getChildCount:function(){return this.$.childNodes.length;},disableContextMenu:function(){this.on('contextmenu',function(i){if(!i.data.getTarget().hasClass('cke_enable_context_menu'))i.data.preventDefault();});},getDirection:function(i){var j=this;return i?j.getComputedStyle('direction')||j.getDirection()||j.getDocument().$.dir||j.getDocument().getBody().getDirection(1):j.getStyle('direction')||j.getAttribute('dir');},data:function(i,j){i='data-'+i;if(j===undefined)return this.getAttribute(i);else if(j===false)this.removeAttribute(i);else this.setAttribute(i,j);return null;}});(function(){var i={width:['border-left-width','border-right-width','padding-left','padding-right'],height:['border-top-width','border-bottom-width','padding-top','padding-bottom']};function j(k){var l=0;for(var m=0,n=i[k].length;m',bodyId:'',bodyClass:'',fullPage:false,height:200,plugins:'about,a11yhelp,basicstyles,bidi,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,dialogadvtab,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,iframe,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',extraPlugins:'',removePlugins:'',protectedSource:[],tabIndex:0,theme:'default',skin:'kama',width:'',baseFloatZIndex:10000}; +var i=a.config;a.focusManager=function(j){if(j.focusManager)return j.focusManager;this.hasFocus=false;this._={editor:j};return this;};a.focusManager.prototype={focus:function(){var k=this;if(k._.timer)clearTimeout(k._.timer);if(!k.hasFocus){if(a.currentInstance)a.currentInstance.focusManager.forceBlur();var j=k._.editor;j.container.getChild(1).addClass('cke_focus');k.hasFocus=true;j.fire('focus');}},blur:function(){var j=this;if(j._.timer)clearTimeout(j._.timer);j._.timer=setTimeout(function(){delete j._.timer;j.forceBlur();},100);},forceBlur:function(){if(this.hasFocus){var j=this._.editor;j.container.getChild(1).removeClass('cke_focus');this.hasFocus=false;j.fire('blur');}}};(function(){var j={};a.lang={languages:{af:1,ar:1,bg:1,bn:1,bs:1,ca:1,cs:1,cy:1,da:1,de:1,el:1,'en-au':1,'en-ca':1,'en-gb':1,en:1,eo:1,es:1,et:1,eu:1,fa:1,fi:1,fo:1,'fr-ca':1,fr:1,gl:1,gu:1,he:1,hi:1,hr:1,hu:1,is:1,it:1,ja:1,ka:1,km:1,ko:1,lt:1,lv:1,mn:1,ms:1,nb:1,nl:1,no:1,pl:1,'pt-br':1,pt:1,ro:1,ru:1,sk:1,sl:1,'sr-latn':1,sr:1,sv:1,th:1,tr:1,uk:1,vi:1,'zh-cn':1,zh:1},load:function(k,l,m){if(!k||!a.lang.languages[k])k=this.detect(l,k);if(!this[k])a.scriptLoader.load(a.getUrl('lang/'+k+'.js'),function(){m(k,this[k]);},this);else m(k,this[k]);},detect:function(k,l){var m=this.languages;l=l||navigator.userLanguage||navigator.language||k;var n=l.toLowerCase().match(/([a-z]+)(?:-([a-z]+))?/),o=n[1],p=n[2];if(m[o+'-'+p])o=o+'-'+p;else if(!m[o])o=null;a.lang.detect=o?function(){return o;}:function(q){return q;};return o||k;}};})();a.scriptLoader=(function(){var j={},k={};return{load:function(l,m,n,o){var p=typeof l=='string';if(p)l=[l];if(!n)n=a;var q=l.length,r=[],s=[],t=function(y){if(m)if(p)m.call(n,y);else m.call(n,r,s);};if(q===0){t(true);return;}var u=function(y,z){(z?r:s).push(y);if(--q<=0){o&&a.document.getDocumentElement().removeStyle('cursor');t(z);}},v=function(y,z){j[y]=1;var A=k[y];delete k[y];for(var B=0;B1)return;var A=new h('script');A.setAttributes({type:'text/javascript',src:y});if(m)if(c)A.$.onreadystatechange=function(){if(A.$.readyState=='loaded'||A.$.readyState=='complete'){A.$.onreadystatechange=null;v(y,true);}};else{A.$.onload=function(){setTimeout(function(){v(y,true);},0);};A.$.onerror=function(){v(y,false);};}A.appendTo(a.document.getHead());};o&&a.document.getDocumentElement().setStyle('cursor','wait');for(var x=0;x1)return;var w=!p.css||!p.css.length,x=!p.js||!p.js.length,y=function(){if(w&&x){p._isLoaded=1;for(var B=0;B=0?x.langCode:J[0];if(!I.langEntries||!I.langEntries[L])G.push(a.getUrl(K+'lang/'+L+'.js'));else{e.extend(x.lang,I.langEntries[L]);L=null;}}F.push(L);E.push(I);}a.scriptLoader.load(G,function(){var M=['beforeInit','init','afterInit'];for(var N=0;N]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:\"[^\"]*\")|(?:'[^']*')|[^\"'>])*)\\/?>))",'g')};};(function(){var l=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,m={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};a.htmlParser.prototype={onTagOpen:function(){},onTagClose:function(){},onText:function(){},onCDATA:function(){},onComment:function(){},parse:function(n){var A=this;var o,p,q=0,r;while(o=A._.htmlPartsRegex.exec(n)){var s=o.index;if(s>q){var t=n.substring(q,s);if(r)r.push(t);else A.onText(t);}q=A._.htmlPartsRegex.lastIndex;if(p=o[1]){p=p.toLowerCase();if(r&&f.$cdata[p]){A.onCDATA(r.join(''));r=null;}if(!r){A.onTagClose(p);continue;}}if(r){r.push(o[0]);continue;}if(p=o[3]){p=p.toLowerCase();if(/="/.test(p))continue; -var u={},v,w=o[4],x=!!(w&&w.charAt(w.length-1)=='/');if(w)while(v=l.exec(w)){var y=v[1].toLowerCase(),z=v[2]||v[3]||v[4]||'';if(!z&&m[y])u[y]=y;else u[y]=z;}A.onTagOpen(p,u,x);if(!r&&f.$cdata[p])r=[];continue;}if(p=o[2])A.onComment(p);}if(n.length>q)A.onText(n.substring(q,n.length));}};})();a.htmlParser.comment=function(l){this.value=l;this._={isBlockLike:false};};a.htmlParser.comment.prototype={type:8,writeHtml:function(l,m){var n=this.value;if(m){if(!(n=m.onComment(n,this)))return;if(typeof n!='string'){n.parent=this.parent;n.writeHtml(l,m);return;}}l.comment(n);}};(function(){var l=/[\t\r\n ]{2,}|[\t\r\n]/g;a.htmlParser.text=function(m){this.value=m;this._={isBlockLike:false};};a.htmlParser.text.prototype={type:3,writeHtml:function(m,n){var o=this.value;if(n&&!(o=n.onText(o,this)))return;m.text(o);}};})();(function(){a.htmlParser.cdata=function(l){this.value=l;};a.htmlParser.cdata.prototype={type:3,writeHtml:function(l){l.write(this.value);}};})();a.htmlParser.fragment=function(){this.children=[];this.parent=null;this._={isBlockLike:true,hasInlineStarted:false};};(function(){var l=e.extend({table:1,ul:1,ol:1,dl:1},f.table,f.ul,f.ol,f.dl),m=c&&b.version<8?{dd:1,dt:1}:{},n={ol:1,ul:1},o=e.extend({},{html:1},f.html,f.body,f.head,{style:1,script:1});a.htmlParser.fragment.fromHtml=function(p,q,r){var s=new a.htmlParser(),t=r||new a.htmlParser.fragment(),u=[],v=[],w=t,x=false;function y(B){var C;if(u.length>0)for(var D=0;D=0;C--){if(B==u[C].name){u.splice(C,1);return;}}var D=[],E=[],F=w;while(F!=t&&F.name!=B){if(!F._.isBlockLike)E.unshift(F);D.push(F);F=F.returnPoint||F.parent;}if(F!=t){for(C=0;C0?s.children[q-1]:null;if(r){if(p._.isBlockLike&&r.type==3){r.value=e.rtrim(r.value);if(r.value.length===0){s.children.pop();s.add(p);return;}}r.next=p;}p.previous=r;p.parent=s;s.children.splice(q,0,p);s._.hasInlineStarted=p.type==3||p.type==1&&!p._.isBlockLike;},writeHtml:function(p,q){var r;this.filterChildren=function(){var s=new a.htmlParser.basicWriter();this.writeChildrenHtml.call(this,s,q,true);var t=s.getHtml();this.children=new a.htmlParser.fragment.fromHtml(t).children;r=1;};!this.name&&q&&q.onFragment(this);this.writeChildrenHtml(p,r?null:q);},writeChildrenHtml:function(p,q){for(var r=0;rn?1:0;};a.htmlParser.element.prototype={type:1,add:a.htmlParser.fragment.prototype.add,clone:function(){return new a.htmlParser.element(this.name,this.attributes);},writeHtml:function(m,n){var o=this.attributes,p=this,q=p.name,r,s,t,u;p.filterChildren=function(){if(!u){var B=new a.htmlParser.basicWriter();a.htmlParser.fragment.prototype.writeChildrenHtml.call(p,B,n);p.children=new a.htmlParser.fragment.fromHtml(B.getHtml(),0,p.clone()).children;u=1;}};if(n){for(;;){if(!(q=n.onElementName(q)))return;p.name=q;if(!(p=n.onElement(p)))return;p.parent=this.parent;if(p.name==q)break;if(p.type!=1){p.writeHtml(m,n);return;}q=p.name;if(!q){for(var v=0,w=this.children.length;v=0;u--){var x=r[u];if(x){x.pri=s;q.splice(t,0,x);}}}};function n(q,r,s){if(r)for(var t in r){var u=q[t];q[t]=o(u,r[t],s);if(!u)q.$length++;}};function o(q,r,s){if(r){r.pri=s;if(q){if(!q.splice){if(q.pri>s)q=[r,q];else q=[q,r];q.filter=p;}else m(q,r,s);return q;}else{r.filter=r;return r;}}};function p(q){var r=q.type||q instanceof a.htmlParser.fragment;for(var s=0;s');else this._.output.push('>');},attribute:function(l,m){if(typeof m=='string')m=e.htmlEncodeAttr(m);this._.output.push(' ',l,'="',m,'"');},closeTag:function(l){this._.output.push('');},text:function(l){this._.output.push(l);},comment:function(l){this._.output.push('');},write:function(l){this._.output.push(l);},reset:function(){this._.output=[];this._.indent=false;},getHtml:function(l){var m=this._.output.join('');if(l)this.reset();return m;}}});delete a.loadFullCore;a.instances={};a.document=new g(document);a.add=function(l){a.instances[l.name]=l;l.on('focus',function(){if(a.currentInstance!=l){a.currentInstance=l;a.fire('currentInstance'); -}});l.on('blur',function(){if(a.currentInstance==l){a.currentInstance=null;a.fire('currentInstance');}});};a.remove=function(l){delete a.instances[l.name];};a.on('instanceDestroyed',function(){if(e.isEmpty(this.instances))a.fire('reset');});a.TRISTATE_ON=1;a.TRISTATE_OFF=2;a.TRISTATE_DISABLED=0;d.comment=e.createClass({base:d.node,$:function(l,m){if(typeof l=='string')l=(m?m.$:document).createComment(l);this.base(l);},proto:{type:8,getOuterHtml:function(){return '';}}});(function(){var l={address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1,legend:1,caption:1},m={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,form:1,fieldset:1},n=function(o){var p=o.getChildren();for(var q=0,r=p.count();q0&&C.getChild(v.startOffset-1);this._.guardRTL=function(F,G){return(!G||!C.equals(F))&&(!D||!F.equals(D))&&(F.type!=1||!G||F.getName()!='body');};}var E=s?this._.guardRTL:this._.guardLTR;if(x)w=function(F,G){if(E(F,G)===false)return false;return x(F,G);};else w=E;if(this.current)u=this.current[z](false,y,w);else if(s){u=v.endContainer;if(v.endOffset>0){u=u.getChild(v.endOffset-1);if(w(u)===false)u=null;}else u=w(u,true)===false?null:u.getPreviousSourceNode(true,y,w);}else{u=v.startContainer;u=u.getChild(v.startOffset);if(u){if(w(u)===false)u=null;}else u=w(v.startContainer,true)===false?null:v.startContainer.getNextSourceNode(true,y,w);}while(u&&!this._.end){this.current=u;if(!this.evaluator||this.evaluator(u)!==false){if(!t)return u;}else if(t&&this.evaluator)return false;u=u[z](false,y,w);}this.end();return this.current=null;};function m(s){var t,u=null;while(t=l.call(this,s))u=t;return u;};d.walker=e.createClass({$:function(s){this.range=s;this._={};},proto:{end:function(){this._.end=1;},next:function(){return l.call(this);},previous:function(){return l.call(this,1);},checkForward:function(){return l.call(this,0,1)!==false;},checkBackward:function(){return l.call(this,1,1)!==false;},lastForward:function(){return m.call(this);},lastBackward:function(){return m.call(this,1);},reset:function(){delete this.current;this._={};}}});var n={block:1,'list-item':1,table:1,'table-row-group':1,'table-header-group':1,'table-footer-group':1,'table-row':1,'table-column-group':1,'table-column':1,'table-cell':1,'table-caption':1};h.prototype.isBlockBoundary=function(s){var t=s?e.extend({},f.$block,s||{}):f.$block;return this.getComputedStyle('float')=='none'&&n[this.getComputedStyle('display')]||t[this.getName()];};d.walker.blockBoundary=function(s){return function(t,u){return!(t.type==1&&t.isBlockBoundary(s));};};d.walker.listItemBoundary=function(){return this.blockBoundary({br:1});};d.walker.bookmark=function(s,t){function u(v){return v&&v.getName&&v.getName()=='span'&&v.data('cke-bookmark');};return function(v){var w,x; -w=v&&!v.getName&&(x=v.getParent())&&u(x);w=s?w:w||u(v);return!!(t^w);};};d.walker.whitespaces=function(s){return function(t){var u=t&&t.type==3&&!e.trim(t.getText());return!!(s^u);};};d.walker.invisible=function(s){var t=d.walker.whitespaces();return function(u){var v=t(u)||u.is&&!u.$.offsetHeight;return!!(s^v);};};d.walker.nodeType=function(s,t){return function(u){return!!(t^u.type==s);};};var o=/^[\t\r\n ]*(?: |\xa0)$/,p=d.walker.whitespaces(),q=d.walker.bookmark(),r=function(s){return q(s)||p(s)||s.type==1&&s.getName() in f.$inline&&!(s.getName() in f.$empty);};h.prototype.getBogus=function(){var s=this;do s=s.getPreviousSourceNode();while(r(s));if(s&&(!c?s.is&&s.is('br'):s.getText&&o.test(s.getText())))return s;return false;};})();d.range=function(l){var m=this;m.startContainer=null;m.startOffset=null;m.endContainer=null;m.endOffset=null;m.collapsed=true;m.document=l;};(function(){var l=function(t){t.collapsed=t.startContainer&&t.endContainer&&t.startContainer.equals(t.endContainer)&&t.startOffset==t.endOffset;},m=function(t,u,v,w){t.optimizeBookmark();var x=t.startContainer,y=t.endContainer,z=t.startOffset,A=t.endOffset,B,C;if(y.type==3)y=y.split(A);else if(y.getChildCount()>0)if(A>=y.getChildCount()){y=y.append(t.document.createText(''));C=true;}else y=y.getChild(A);if(x.type==3){x.split(z);if(x.equals(y))y=x.getNext();}else if(!z){x=x.getFirst().insertBeforeMe(t.document.createText(''));B=true;}else if(z>=x.getChildCount()){x=x.append(t.document.createText(''));B=true;}else x=x.getChild(z).getPrevious();var D=x.getParents(),E=y.getParents(),F,G,H;for(F=0;F0&&!J.equals(y))K=I.append(J.clone());if(!D[O]||J.$.parentNode!=D[O].$.parentNode){L=J.getPrevious();while(L){if(L.equals(D[O])||L.equals(x))break;M=L.getPrevious();if(u==2)I.$.insertBefore(L.$.cloneNode(true),I.$.firstChild);else{L.remove();if(u==1)I.$.insertBefore(L.$,I.$.firstChild);}L=M;}}if(I)I=K;}if(u==2){var P=t.startContainer;if(P.type==3){P.$.data+=P.$.nextSibling.data;P.$.parentNode.removeChild(P.$.nextSibling);}var Q=t.endContainer;if(Q.type==3&&Q.$.nextSibling){Q.$.data+=Q.$.nextSibling.data;Q.$.parentNode.removeChild(Q.$.nextSibling);}}else{if(G&&H&&(x.$.parentNode!=G.$.parentNode||y.$.parentNode!=H.$.parentNode)){var R=H.getIndex(); -if(B&&H.$.parentNode==x.$.parentNode)R--;if(w&&G.type==1){var S=h.createFromHtml(' ',t.document);S.insertAfter(G);G.mergeSiblings(false);t.moveToBookmark({startNode:S});}else t.setStart(H.getParent(),R);}t.collapse(true);}if(B)x.remove();if(C&&y.$.parentNode)y.remove();},n={abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1};function o(t){var u=false,v=d.walker.bookmark(true);return function(w){if(v(w))return true;if(w.type==3){if(w.hasAscendant('pre')||e.trim(w.getText()).length)return false;}else if(w.type==1)if(!n[w.getName()])if(!t&&!c&&w.getName()=='br'&&!u)u=true;else return false;return true;};};function p(t){return t.type!=3&&t.getName() in f.$removeEmpty||!e.trim(t.getText())||!!t.getParent().data('cke-bookmark');};var q=new d.walker.whitespaces(),r=new d.walker.bookmark();function s(t){return!q(t)&&!r(t);};d.range.prototype={clone:function(){var u=this;var t=new d.range(u.document);t.startContainer=u.startContainer;t.startOffset=u.startOffset;t.endContainer=u.endContainer;t.endOffset=u.endOffset;t.collapsed=u.collapsed;return t;},collapse:function(t){var u=this;if(t){u.endContainer=u.startContainer;u.endOffset=u.startOffset;}else{u.startContainer=u.endContainer;u.startOffset=u.endOffset;}u.collapsed=true;},cloneContents:function(){var t=new d.documentFragment(this.document);if(!this.collapsed)m(this,2,t);return t;},deleteContents:function(t){if(this.collapsed)return;m(this,0,null,t);},extractContents:function(t){var u=new d.documentFragment(this.document);if(!this.collapsed)m(this,1,u,t);return u;},createBookmark:function(t){var z=this;var u,v,w,x,y=z.collapsed;u=z.document.createElement('span');u.data('cke-bookmark',1);u.setStyle('display','none');u.setHtml(' ');if(t){w='cke_bm_'+e.getNextNumber();u.setAttribute('id',w+'S');}if(!y){v=u.clone();v.setHtml(' ');if(t)v.setAttribute('id',w+'E');x=z.clone();x.collapse();x.insertNode(v);}x=z.clone();x.collapse(true);x.insertNode(u);if(v){z.setStartAfter(u);z.setEndBefore(v);}else z.moveToPosition(u,4);return{startNode:t?w+'S':u,endNode:t?w+'E':v,serializable:t,collapsed:y};},createBookmark2:function(t){var B=this;var u=B.startContainer,v=B.endContainer,w=B.startOffset,x=B.endOffset,y=B.collapsed,z,A;if(!u||!v)return{start:0,end:0};if(t){if(u.type==1){z=u.getChild(w);if(z&&z.type==3&&w>0&&z.getPrevious().type==3){u=z;w=0; -}if(z&&z.type==1)w=z.getIndex(1);}while(u.type==3&&(A=u.getPrevious())&&A.type==3){u=A;w+=A.getLength();}if(!y){if(v.type==1){z=v.getChild(x);if(z&&z.type==3&&x>0&&z.getPrevious().type==3){v=z;x=0;}if(z&&z.type==1)x=z.getIndex(1);}while(v.type==3&&(A=v.getPrevious())&&A.type==3){v=A;x+=A.getLength();}}}return{start:u.getAddress(t),end:y?null:v.getAddress(t),startOffset:w,endOffset:x,normalized:t,collapsed:y,is2:true};},moveToBookmark:function(t){var B=this;if(t.is2){var u=B.document.getByAddress(t.start,t.normalized),v=t.startOffset,w=t.end&&B.document.getByAddress(t.end,t.normalized),x=t.endOffset;B.setStart(u,v);if(w)B.setEnd(w,x);else B.collapse(true);}else{var y=t.serializable,z=y?B.document.getById(t.startNode):t.startNode,A=y?B.document.getById(t.endNode):t.endNode;B.setStartBefore(z);z.remove();if(A){B.setEndBefore(A);A.remove();}else B.collapse(true);}},getBoundaryNodes:function(){var y=this;var t=y.startContainer,u=y.endContainer,v=y.startOffset,w=y.endOffset,x;if(t.type==1){x=t.getChildCount();if(x>v)t=t.getChild(v);else if(x<1)t=t.getPreviousSourceNode();else{t=t.$;while(t.lastChild)t=t.lastChild;t=new d.node(t);t=t.getNextSourceNode()||t;}}if(u.type==1){x=u.getChildCount();if(x>w)u=u.getChild(w).getPreviousSourceNode(true);else if(x<1)u=u.getPreviousSourceNode();else{u=u.$;while(u.lastChild)u=u.lastChild;u=new d.node(u);}}if(t.getPosition(u)&2)t=u;return{startNode:t,endNode:u};},getCommonAncestor:function(t,u){var y=this;var v=y.startContainer,w=y.endContainer,x;if(v.equals(w)){if(t&&v.type==1&&y.startOffset==y.endOffset-1)x=v.getChild(y.startOffset);else x=v;}else x=v.getCommonAncestor(w);return u&&!x.is?x.getParent():x;},optimize:function(){var v=this;var t=v.startContainer,u=v.startOffset;if(t.type!=1)if(!u)v.setStartBefore(t);else if(u>=t.getLength())v.setStartAfter(t);t=v.endContainer;u=v.endOffset;if(t.type!=1)if(!u)v.setEndBefore(t);else if(u>=t.getLength())v.setEndAfter(t);},optimizeBookmark:function(){var v=this;var t=v.startContainer,u=v.endContainer;if(t.is&&t.is('span')&&t.data('cke-bookmark'))v.setStartAt(t,3);if(u&&u.is&&u.is('span')&&u.data('cke-bookmark'))v.setEndAt(u,4);},trim:function(t,u){var B=this;var v=B.startContainer,w=B.startOffset,x=B.collapsed;if((!t||x)&&v&&v.type==3){if(!w){w=v.getIndex();v=v.getParent();}else if(w>=v.getLength()){w=v.getIndex()+1;v=v.getParent();}else{var y=v.split(w);w=v.getIndex()+1;v=v.getParent();if(B.startContainer.equals(B.endContainer))B.setEnd(y,B.endOffset-B.startOffset);else if(v.equals(B.endContainer))B.endOffset+=1; -}B.setStart(v,w);if(x){B.collapse(true);return;}}var z=B.endContainer,A=B.endOffset;if(!(u||x)&&z&&z.type==3){if(!A){A=z.getIndex();z=z.getParent();}else if(A>=z.getLength()){A=z.getIndex()+1;z=z.getParent();}else{z.split(A);A=z.getIndex()+1;z=z.getParent();}B.setEnd(z,A);}},enlarge:function(t,u){switch(t){case 1:if(this.collapsed)return;var v=this.getCommonAncestor(),w=this.document.getBody(),x,y,z,A,B,C=false,D,E,F=this.startContainer,G=this.startOffset;if(F.type==3){if(G){F=!e.trim(F.substring(0,G)).length&&F;C=!!F;}if(F)if(!(A=F.getPrevious()))z=F.getParent();}else{if(G)A=F.getChild(G-1)||F.getLast();if(!A)z=F;}while(z||A){if(z&&!A){if(!B&&z.equals(v))B=true;if(!w.contains(z))break;if(!C||z.getComputedStyle('display')!='inline'){C=false;if(B)x=z;else this.setStartBefore(z);}A=z.getPrevious();}while(A){D=false;if(A.type==3){E=A.getText();if(/[^\s\ufeff]/.test(E))A=null;D=/[\s\ufeff]$/.test(E);}else if((A.$.offsetWidth>0||u&&A.is('br'))&&!A.data('cke-bookmark'))if(C&&f.$removeEmpty[A.getName()]){E=A.getText();if(/[^\s\ufeff]/.test(E))A=null;else{var H=A.$.all||A.$.getElementsByTagName('*');for(var I=0,J;J=H[I++];){if(!f.$removeEmpty[J.nodeName.toLowerCase()]){A=null;break;}}}if(A)D=!!E.length;}else A=null;if(D)if(C){if(B)x=z;else if(z)this.setStartBefore(z);}else C=true;if(A){var K=A.getPrevious();if(!z&&!K){z=A;A=null;break;}A=K;}else z=null;}if(z)z=z.getParent();}F=this.endContainer;G=this.endOffset;z=A=null;B=C=false;if(F.type==3){F=!e.trim(F.substring(G)).length&&F;C=!(F&&F.getLength());if(F)if(!(A=F.getNext()))z=F.getParent();}else{A=F.getChild(G);if(!A)z=F;}while(z||A){if(z&&!A){if(!B&&z.equals(v))B=true;if(!w.contains(z))break;if(!C||z.getComputedStyle('display')!='inline'){C=false;if(B)y=z;else if(z)this.setEndAfter(z);}A=z.getNext();}while(A){D=false;if(A.type==3){E=A.getText();if(/[^\s\ufeff]/.test(E))A=null;D=/^[\s\ufeff]/.test(E);}else if((A.$.offsetWidth>0||u&&A.is('br'))&&!A.data('cke-bookmark'))if(C&&f.$removeEmpty[A.getName()]){E=A.getText();if(/[^\s\ufeff]/.test(E))A=null;else{H=A.$.all||A.$.getElementsByTagName('*');for(I=0;J=H[I++];){if(!f.$removeEmpty[J.nodeName.toLowerCase()]){A=null;break;}}}if(A)D=!!E.length;}else A=null;if(D)if(C)if(B)y=z;else this.setEndAfter(z);if(A){K=A.getNext();if(!z&&!K){z=A;A=null;break;}A=K;}else z=null;}if(z)z=z.getParent();}if(x&&y){v=x.contains(y)?y:x;this.setStartBefore(v);this.setEndAfter(v);}break;case 2:case 3:var L=new d.range(this.document);w=this.document.getBody();L.setStartAt(w,1);L.setEnd(this.startContainer,this.startOffset); -var M=new d.walker(L),N,O,P=d.walker.blockBoundary(t==3?{br:1}:null),Q=function(S){var T=P(S);if(!T)N=S;return T;},R=function(S){var T=Q(S);if(!T&&S.is&&S.is('br'))O=S;return T;};M.guard=Q;z=M.lastBackward();N=N||w;this.setStartAt(N,!N.is('br')&&(!z&&this.checkStartOfBlock()||z&&N.contains(z))?1:4);L=this.clone();L.collapse();L.setEndAt(w,2);M=new d.walker(L);M.guard=t==3?R:Q;N=null;z=M.lastForward();N=N||w;this.setEndAt(N,!z&&this.checkEndOfBlock()||z&&N.contains(z)?2:3);if(O)this.setEndAfter(O);}},shrink:function(t,u){if(!this.collapsed){t=t||2;var v=this.clone(),w=this.startContainer,x=this.endContainer,y=this.startOffset,z=this.endOffset,A=this.collapsed,B=1,C=1;if(w&&w.type==3)if(!y)v.setStartBefore(w);else if(y>=w.getLength())v.setStartAfter(w);else{v.setStartBefore(w);B=0;}if(x&&x.type==3)if(!z)v.setEndBefore(x);else if(z>=x.getLength())v.setEndAfter(x);else{v.setEndAfter(x);C=0;}var D=new d.walker(v),E=d.walker.bookmark();D.evaluator=function(I){return I.type==(t==1?1:3);};var F;D.guard=function(I,J){if(E(I))return true;if(t==1&&I.type==3)return false;if(J&&I.equals(F))return false;if(!J&&I.type==1)F=I;return true;};if(B){var G=D[t==1?'lastForward':'next']();G&&this.setStartAt(G,u?1:3);}if(C){D.reset();var H=D[t==1?'lastBackward':'previous']();H&&this.setEndAt(H,u?2:4);}return!!(B||C);}},insertNode:function(t){var x=this;x.optimizeBookmark();x.trim(false,true);var u=x.startContainer,v=x.startOffset,w=u.getChild(v);if(w)t.insertBefore(w);else u.append(t);if(t.getParent().equals(x.endContainer))x.endOffset++;x.setStartBefore(t);},moveToPosition:function(t,u){this.setStartAt(t,u);this.collapse(true);},selectNodeContents:function(t){this.setStart(t,0);this.setEnd(t,t.type==3?t.getLength():t.getChildCount());},setStart:function(t,u){var v=this;if(t.type==1&&f.$empty[t.getName()])u=t.getIndex(),t=t.getParent();v.startContainer=t;v.startOffset=u;if(!v.endContainer){v.endContainer=t;v.endOffset=u;}l(v);},setEnd:function(t,u){var v=this;if(t.type==1&&f.$empty[t.getName()])u=t.getIndex()+1,t=t.getParent();v.endContainer=t;v.endOffset=u;if(!v.startContainer){v.startContainer=t;v.startOffset=u;}l(v);},setStartAfter:function(t){this.setStart(t.getParent(),t.getIndex()+1);},setStartBefore:function(t){this.setStart(t.getParent(),t.getIndex());},setEndAfter:function(t){this.setEnd(t.getParent(),t.getIndex()+1);},setEndBefore:function(t){this.setEnd(t.getParent(),t.getIndex());},setStartAt:function(t,u){var v=this;switch(u){case 1:v.setStart(t,0);break;case 2:if(t.type==3)v.setStart(t,t.getLength()); -else v.setStart(t,t.getChildCount());break;case 3:v.setStartBefore(t);break;case 4:v.setStartAfter(t);}l(v);},setEndAt:function(t,u){var v=this;switch(u){case 1:v.setEnd(t,0);break;case 2:if(t.type==3)v.setEnd(t,t.getLength());else v.setEnd(t,t.getChildCount());break;case 3:v.setEndBefore(t);break;case 4:v.setEndAfter(t);}l(v);},fixBlock:function(t,u){var x=this;var v=x.createBookmark(),w=x.document.createElement(u);x.collapse(t);x.enlarge(2);x.extractContents().appendTo(w);w.trim();if(!c)w.appendBogus();x.insertNode(w);x.moveToBookmark(v);return w;},splitBlock:function(t){var D=this;var u=new d.elementPath(D.startContainer),v=new d.elementPath(D.endContainer),w=u.blockLimit,x=v.blockLimit,y=u.block,z=v.block,A=null;if(!w.equals(x))return null;if(t!='br'){if(!y){y=D.fixBlock(true,t);z=new d.elementPath(D.endContainer).block;}if(!z)z=D.fixBlock(false,t);}var B=y&&D.checkStartOfBlock(),C=z&&D.checkEndOfBlock();D.deleteContents();if(y&&y.equals(z))if(C){A=new d.elementPath(D.startContainer);D.moveToPosition(z,4);z=null;}else if(B){A=new d.elementPath(D.startContainer);D.moveToPosition(y,3);y=null;}else{z=D.splitElement(y);if(!c&&!y.is('ul','ol'))y.appendBogus();}return{previousBlock:y,nextBlock:z,wasStartOfBlock:B,wasEndOfBlock:C,elementPath:A};},splitElement:function(t){var w=this;if(!w.collapsed)return null;w.setEndAt(t,2);var u=w.extractContents(),v=t.clone(false);u.appendTo(v);v.insertAfter(t);w.moveToPosition(t,4);return v;},checkBoundaryOfElement:function(t,u){var v=u==1,w=this.clone();w.collapse(v);w[v?'setStartAt':'setEndAt'](t,v?1:2);var x=new d.walker(w);x.evaluator=p;return x[v?'checkBackward':'checkForward']();},checkStartOfBlock:function(){var z=this;var t=z.startContainer,u=z.startOffset;if(u&&t.type==3){var v=e.ltrim(t.substring(0,u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.startContainer),x=z.clone();x.collapse(true);x.setStartAt(w.block||w.blockLimit,1);var y=new d.walker(x);y.evaluator=o(true);return y.checkBackward();},checkEndOfBlock:function(){var z=this;var t=z.endContainer,u=z.endOffset;if(t.type==3){var v=e.rtrim(t.substring(u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.endContainer),x=z.clone();x.collapse(false);x.setEndAt(w.block||w.blockLimit,2);var y=new d.walker(x);y.evaluator=o(false);return y.checkForward();},checkReadOnly:(function(){function t(u,v){while(u){if(u.type==1)if(u.getAttribute('contentEditable')=='false'&&!u.data('cke-editable'))return 0;else if(u.is('html')||u.getAttribute('contentEditable')=='true'&&(u.contains(v)||u.equals(v)))break; -u=u.getParent();}return 1;};return function(){var u=this.startContainer,v=this.endContainer;return!(t(u,v)&&t(v,u));};})(),moveToElementEditablePosition:function(t,u){var v;if(f.$empty[t.getName()])return false;while(t&&t.type==1){v=t.isEditable();if(v)this.moveToPosition(t,u?2:1);else if(f.$inline[t.getName()]){this.moveToPosition(t,u?4:3);return true;}if(f.$empty[t.getName()])t=t[u?'getPrevious':'getNext'](s);else t=t[u?'getLast':'getFirst'](s);if(t&&t.type==3){this.moveToPosition(t,u?4:3);return true;}}return v;},moveToElementEditStart:function(t){return this.moveToElementEditablePosition(t);},moveToElementEditEnd:function(t){return this.moveToElementEditablePosition(t,true);},getEnclosedNode:function(){var t=this.clone();t.optimize();if(t.startContainer.type!=1||t.endContainer.type!=1)return null;var u=new d.walker(t),v=d.walker.bookmark(true),w=d.walker.whitespaces(true),x=function(z){return w(z)&&v(z);};t.evaluator=x;var y=u.next();u.reset();return y&&y.equals(u.previous())?y:null;},getTouchedStartNode:function(){var t=this.startContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.startOffset)||t;},getTouchedEndNode:function(){var t=this.endContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.endOffset-1)||t;}};})();a.POSITION_AFTER_START=1;a.POSITION_BEFORE_END=2;a.POSITION_BEFORE_START=3;a.POSITION_AFTER_END=4;a.ENLARGE_ELEMENT=1;a.ENLARGE_BLOCK_CONTENTS=2;a.ENLARGE_LIST_ITEM_CONTENTS=3;a.START=1;a.END=2;a.STARTEND=3;a.SHRINK_ELEMENT=1;a.SHRINK_TEXT=2;(function(){d.rangeList=function(n){if(n instanceof d.rangeList)return n;if(!n)n=[];else if(n instanceof d.range)n=[n];return e.extend(n,l);};var l={createIterator:function(){var n=this,o=d.walker.bookmark(),p=function(s){return!(s.is&&s.is('tr'));},q=[],r;return{getNextRange:function(s){r=r==undefined?0:r+1;var t=n[r];if(t&&n.length>1){if(!r)for(var u=n.length-1;u>=0;u--)q.unshift(n[u].createBookmark(true));if(s){var v=0;while(n[r+v+1]){var w=t.document,x=0,y=w.getById(q[v].endNode),z=w.getById(q[v+1].startNode),A;while(1){A=y.getNextSourceNode(false);if(!z.equals(A)){if(o(A)||A.type==1&&A.isBlockBoundary()){y=A;continue;}}else x=1;break;}if(!x)break;v++;}}t.moveToBookmark(q.shift());while(v--){A=n[++r];A.moveToBookmark(q.shift());t.setEnd(A.endContainer,A.endOffset);}}return t;}};},createBookmarks:function(n){var s=this;var o=[],p;for(var q=0;q',a.document);l.appendTo(a.document.getHead());try{b.hc=l.getComputedStyle('border-top-color')==l.getComputedStyle('border-right-color');}catch(m){b.hc=false;}if(b.hc)b.cssClass+=' cke_hc';l.remove();})();j.load(i.corePlugins.split(','),function(){a.status='loaded';a.fire('loaded');var l=a._.pending;if(l){delete a._.pending;for(var m=0;mq)A.onText(n.substring(q,n.length));}};})();a.htmlParser.comment=function(l){this.value=l;this._={isBlockLike:false};};a.htmlParser.comment.prototype={type:8,writeHtml:function(l,m){var n=this.value;if(m){if(!(n=m.onComment(n,this)))return;if(typeof n!='string'){n.parent=this.parent;n.writeHtml(l,m);return;}}l.comment(n);}};(function(){a.htmlParser.text=function(l){this.value=l;this._={isBlockLike:false};};a.htmlParser.text.prototype={type:3,writeHtml:function(l,m){var n=this.value;if(m&&!(n=m.onText(n,this)))return;l.text(n);}};})();(function(){a.htmlParser.cdata=function(l){this.value=l;};a.htmlParser.cdata.prototype={type:3,writeHtml:function(l){l.write(this.value);}};})();a.htmlParser.fragment=function(){this.children=[];this.parent=null;this._={isBlockLike:true,hasInlineStarted:false};};(function(){var l=e.extend({table:1,ul:1,ol:1,dl:1},f.table,f.ul,f.ol,f.dl),m=c&&b.version<8?{dd:1,dt:1}:{},n={ol:1,ul:1},o=e.extend({},{html:1},f.html,f.body,f.head,{style:1,script:1});function p(q){return q.name=='a'&&q.attributes.href||f.$removeEmpty[q.name];};a.htmlParser.fragment.fromHtml=function(q,r,s){var t=new a.htmlParser(),u=s||new a.htmlParser.fragment(),v=[],w=[],x=u,y=false,z=false;function A(D){var E;if(v.length>0)for(var F=0;F=0;E--){if(D==v[E].name){v.splice(E,1);return;}}var F=[],G=[],H=x;while(H!=u&&H.name!=D){if(!H._.isBlockLike)G.unshift(H);F.push(H);H=H.returnPoint||H.parent;}if(H!=u){for(E=0;E0?t.children[r-1]:null;if(s){if(q._.isBlockLike&&s.type==3){s.value=e.rtrim(s.value);if(s.value.length===0){t.children.pop();t.add(q);return;}}s.next=q;}q.previous=s;q.parent=t;t.children.splice(r,0,q);t._.hasInlineStarted=q.type==3||q.type==1&&!q._.isBlockLike;},writeHtml:function(q,r){var s;this.filterChildren=function(){var t=new a.htmlParser.basicWriter();this.writeChildrenHtml.call(this,t,r,true);var u=t.getHtml();this.children=new a.htmlParser.fragment.fromHtml(u).children;s=1;};!this.name&&r&&r.onFragment(this);this.writeChildrenHtml(q,s?null:r);},writeChildrenHtml:function(q,r){for(var s=0;sn?1:0;};a.htmlParser.element.prototype={type:1,add:a.htmlParser.fragment.prototype.add,clone:function(){return new a.htmlParser.element(this.name,this.attributes);},writeHtml:function(m,n){var o=this.attributes,p=this,q=p.name,r,s,t,u;p.filterChildren=function(){if(!u){var B=new a.htmlParser.basicWriter();a.htmlParser.fragment.prototype.writeChildrenHtml.call(p,B,n);p.children=new a.htmlParser.fragment.fromHtml(B.getHtml(),0,p.clone()).children;u=1;}};if(n){for(;;){if(!(q=n.onElementName(q)))return;p.name=q;if(!(p=n.onElement(p)))return;p.parent=this.parent;if(p.name==q)break;if(p.type!=1){p.writeHtml(m,n);return;}q=p.name;if(!q){for(var v=0,w=this.children.length;v=0;u--){var x=r[u];if(x){x.pri=s;q.splice(t,0,x);}}}};function n(q,r,s){if(r)for(var t in r){var u=q[t];q[t]=o(u,r[t],s);if(!u)q.$length++;}};function o(q,r,s){if(r){r.pri=s;if(q){if(!q.splice){if(q.pri>s)q=[r,q];else q=[q,r];q.filter=p;}else m(q,r,s);return q;}else{r.filter=r;return r;}}};function p(q){var r=q.type||q instanceof a.htmlParser.fragment;for(var s=0;s');else this._.output.push('>');},attribute:function(l,m){if(typeof m=='string')m=e.htmlEncodeAttr(m);this._.output.push(' ',l,'="',m,'"');},closeTag:function(l){this._.output.push('');},text:function(l){this._.output.push(l);},comment:function(l){this._.output.push('');},write:function(l){this._.output.push(l);},reset:function(){this._.output=[];this._.indent=false;},getHtml:function(l){var m=this._.output.join('');if(l)this.reset();return m;}}});delete a.loadFullCore;a.instances={};a.document=new g(document);a.add=function(l){a.instances[l.name]=l; +l.on('focus',function(){if(a.currentInstance!=l){a.currentInstance=l;a.fire('currentInstance');}});l.on('blur',function(){if(a.currentInstance==l){a.currentInstance=null;a.fire('currentInstance');}});};a.remove=function(l){delete a.instances[l.name];};a.on('instanceDestroyed',function(){if(e.isEmpty(this.instances))a.fire('reset');});a.TRISTATE_ON=1;a.TRISTATE_OFF=2;a.TRISTATE_DISABLED=0;d.comment=e.createClass({base:d.node,$:function(l,m){if(typeof l=='string')l=(m?m.$:document).createComment(l);this.base(l);},proto:{type:8,getOuterHtml:function(){return '';}}});(function(){var l={address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1,legend:1,caption:1},m={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,form:1,fieldset:1},n=function(o){var p=o.getChildren();for(var q=0,r=p.count();q0&&C.getChild(v.startOffset-1);this._.guardRTL=function(F,G){return(!G||!C.equals(F))&&(!D||!F.equals(D))&&(F.type!=1||!G||F.getName()!='body');};}var E=s?this._.guardRTL:this._.guardLTR;if(x)w=function(F,G){if(E(F,G)===false)return false;return x(F,G);};else w=E;if(this.current)u=this.current[z](false,y,w);else if(s){u=v.endContainer;if(v.endOffset>0){u=u.getChild(v.endOffset-1);if(w(u)===false)u=null;}else u=w(u,true)===false?null:u.getPreviousSourceNode(true,y,w);}else{u=v.startContainer;u=u.getChild(v.startOffset);if(u){if(w(u)===false)u=null;}else u=w(v.startContainer,true)===false?null:v.startContainer.getNextSourceNode(true,y,w);}while(u&&!this._.end){this.current=u;if(!this.evaluator||this.evaluator(u)!==false){if(!t)return u;}else if(t&&this.evaluator)return false;u=u[z](false,y,w);}this.end();return this.current=null;};function m(s){var t,u=null;while(t=l.call(this,s))u=t;return u;};d.walker=e.createClass({$:function(s){this.range=s;this._={};},proto:{end:function(){this._.end=1;},next:function(){return l.call(this);},previous:function(){return l.call(this,1);},checkForward:function(){return l.call(this,0,1)!==false;},checkBackward:function(){return l.call(this,1,1)!==false;},lastForward:function(){return m.call(this);},lastBackward:function(){return m.call(this,1);},reset:function(){delete this.current;this._={};}}});var n={block:1,'list-item':1,table:1,'table-row-group':1,'table-header-group':1,'table-footer-group':1,'table-row':1,'table-column-group':1,'table-column':1,'table-cell':1,'table-caption':1};h.prototype.isBlockBoundary=function(s){var t=s?e.extend({},f.$block,s||{}):f.$block;return this.getComputedStyle('float')=='none'&&n[this.getComputedStyle('display')]||t[this.getName()];};d.walker.blockBoundary=function(s){return function(t,u){return!(t.type==1&&t.isBlockBoundary(s)); +};};d.walker.listItemBoundary=function(){return this.blockBoundary({br:1});};d.walker.bookmark=function(s,t){function u(v){return v&&v.getName&&v.getName()=='span'&&v.data('cke-bookmark');};return function(v){var w,x;w=v&&!v.getName&&(x=v.getParent())&&u(x);w=s?w:w||u(v);return!!(t^w);};};d.walker.whitespaces=function(s){return function(t){var u=t&&t.type==3&&!e.trim(t.getText());return!!(s^u);};};d.walker.invisible=function(s){var t=d.walker.whitespaces();return function(u){var v=t(u)||u.is&&!u.$.offsetHeight;return!!(s^v);};};d.walker.nodeType=function(s,t){return function(u){return!!(t^u.type==s);};};var o=/^[\t\r\n ]*(?: |\xa0)$/,p=d.walker.whitespaces(),q=d.walker.bookmark(),r=function(s){return q(s)||p(s)||s.type==1&&s.getName() in f.$inline&&!(s.getName() in f.$empty);};h.prototype.getBogus=function(){var s=this;do s=s.getPreviousSourceNode();while(r(s));if(s&&(!c?s.is&&s.is('br'):s.getText&&o.test(s.getText())))return s;return false;};})();d.range=function(l){var m=this;m.startContainer=null;m.startOffset=null;m.endContainer=null;m.endOffset=null;m.collapsed=true;m.document=l;};(function(){var l=function(t){t.collapsed=t.startContainer&&t.endContainer&&t.startContainer.equals(t.endContainer)&&t.startOffset==t.endOffset;},m=function(t,u,v,w){t.optimizeBookmark();var x=t.startContainer,y=t.endContainer,z=t.startOffset,A=t.endOffset,B,C;if(y.type==3)y=y.split(A);else if(y.getChildCount()>0)if(A>=y.getChildCount()){y=y.append(t.document.createText(''));C=true;}else y=y.getChild(A);if(x.type==3){x.split(z);if(x.equals(y))y=x.getNext();}else if(!z){x=x.getFirst().insertBeforeMe(t.document.createText(''));B=true;}else if(z>=x.getChildCount()){x=x.append(t.document.createText(''));B=true;}else x=x.getChild(z).getPrevious();var D=x.getParents(),E=y.getParents(),F,G,H;for(F=0;F0&&!J.equals(y))K=I.append(J.clone());if(!D[O]||J.$.parentNode!=D[O].$.parentNode){L=J.getPrevious();while(L){if(L.equals(D[O])||L.equals(x))break;M=L.getPrevious();if(u==2)I.$.insertBefore(L.$.cloneNode(true),I.$.firstChild);else{L.remove();if(u==1)I.$.insertBefore(L.$,I.$.firstChild);}L=M;}}if(I)I=K;}if(u==2){var P=t.startContainer;if(P.type==3){P.$.data+=P.$.nextSibling.data; +P.$.parentNode.removeChild(P.$.nextSibling);}var Q=t.endContainer;if(Q.type==3&&Q.$.nextSibling){Q.$.data+=Q.$.nextSibling.data;Q.$.parentNode.removeChild(Q.$.nextSibling);}}else{if(G&&H&&(x.$.parentNode!=G.$.parentNode||y.$.parentNode!=H.$.parentNode)){var R=H.getIndex();if(B&&H.$.parentNode==x.$.parentNode)R--;if(w&&G.type==1){var S=h.createFromHtml(' ',t.document);S.insertAfter(G);G.mergeSiblings(false);t.moveToBookmark({startNode:S});}else t.setStart(H.getParent(),R);}t.collapse(true);}if(B)x.remove();if(C&&y.$.parentNode)y.remove();},n={abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1};function o(t){var u=false,v=d.walker.bookmark(true);return function(w){if(v(w))return true;if(w.type==3){if(w.hasAscendant('pre')||e.trim(w.getText()).length)return false;}else if(w.type==1)if(!n[w.getName()])if(!t&&!c&&w.getName()=='br'&&!u)u=true;else return false;return true;};};function p(t){return t.type!=3&&t.getName() in f.$removeEmpty||!e.trim(t.getText())||!!t.getParent().data('cke-bookmark');};var q=new d.walker.whitespaces(),r=new d.walker.bookmark();function s(t){return!q(t)&&!r(t);};d.range.prototype={clone:function(){var u=this;var t=new d.range(u.document);t.startContainer=u.startContainer;t.startOffset=u.startOffset;t.endContainer=u.endContainer;t.endOffset=u.endOffset;t.collapsed=u.collapsed;return t;},collapse:function(t){var u=this;if(t){u.endContainer=u.startContainer;u.endOffset=u.startOffset;}else{u.startContainer=u.endContainer;u.startOffset=u.endOffset;}u.collapsed=true;},cloneContents:function(){var t=new d.documentFragment(this.document);if(!this.collapsed)m(this,2,t);return t;},deleteContents:function(t){if(this.collapsed)return;m(this,0,null,t);},extractContents:function(t){var u=new d.documentFragment(this.document);if(!this.collapsed)m(this,1,u,t);return u;},createBookmark:function(t){var z=this;var u,v,w,x,y=z.collapsed;u=z.document.createElement('span');u.data('cke-bookmark',1);u.setStyle('display','none');u.setHtml(' ');if(t){w='cke_bm_'+e.getNextNumber();u.setAttribute('id',w+'S');}if(!y){v=u.clone();v.setHtml(' ');if(t)v.setAttribute('id',w+'E');x=z.clone();x.collapse();x.insertNode(v);}x=z.clone();x.collapse(true);x.insertNode(u);if(v){z.setStartAfter(u);z.setEndBefore(v);}else z.moveToPosition(u,4);return{startNode:t?w+'S':u,endNode:t?w+'E':v,serializable:t,collapsed:y}; +},createBookmark2:function(t){var B=this;var u=B.startContainer,v=B.endContainer,w=B.startOffset,x=B.endOffset,y=B.collapsed,z,A;if(!u||!v)return{start:0,end:0};if(t){if(u.type==1){z=u.getChild(w);if(z&&z.type==3&&w>0&&z.getPrevious().type==3){u=z;w=0;}if(z&&z.type==1)w=z.getIndex(1);}while(u.type==3&&(A=u.getPrevious())&&A.type==3){u=A;w+=A.getLength();}if(!y){if(v.type==1){z=v.getChild(x);if(z&&z.type==3&&x>0&&z.getPrevious().type==3){v=z;x=0;}if(z&&z.type==1)x=z.getIndex(1);}while(v.type==3&&(A=v.getPrevious())&&A.type==3){v=A;x+=A.getLength();}}}return{start:u.getAddress(t),end:y?null:v.getAddress(t),startOffset:w,endOffset:x,normalized:t,collapsed:y,is2:true};},moveToBookmark:function(t){var B=this;if(t.is2){var u=B.document.getByAddress(t.start,t.normalized),v=t.startOffset,w=t.end&&B.document.getByAddress(t.end,t.normalized),x=t.endOffset;B.setStart(u,v);if(w)B.setEnd(w,x);else B.collapse(true);}else{var y=t.serializable,z=y?B.document.getById(t.startNode):t.startNode,A=y?B.document.getById(t.endNode):t.endNode;B.setStartBefore(z);z.remove();if(A){B.setEndBefore(A);A.remove();}else B.collapse(true);}},getBoundaryNodes:function(){var y=this;var t=y.startContainer,u=y.endContainer,v=y.startOffset,w=y.endOffset,x;if(t.type==1){x=t.getChildCount();if(x>v)t=t.getChild(v);else if(x<1)t=t.getPreviousSourceNode();else{t=t.$;while(t.lastChild)t=t.lastChild;t=new d.node(t);t=t.getNextSourceNode()||t;}}if(u.type==1){x=u.getChildCount();if(x>w)u=u.getChild(w).getPreviousSourceNode(true);else if(x<1)u=u.getPreviousSourceNode();else{u=u.$;while(u.lastChild)u=u.lastChild;u=new d.node(u);}}if(t.getPosition(u)&2)t=u;return{startNode:t,endNode:u};},getCommonAncestor:function(t,u){var y=this;var v=y.startContainer,w=y.endContainer,x;if(v.equals(w)){if(t&&v.type==1&&y.startOffset==y.endOffset-1)x=v.getChild(y.startOffset);else x=v;}else x=v.getCommonAncestor(w);return u&&!x.is?x.getParent():x;},optimize:function(){var v=this;var t=v.startContainer,u=v.startOffset;if(t.type!=1)if(!u)v.setStartBefore(t);else if(u>=t.getLength())v.setStartAfter(t);t=v.endContainer;u=v.endOffset;if(t.type!=1)if(!u)v.setEndBefore(t);else if(u>=t.getLength())v.setEndAfter(t);},optimizeBookmark:function(){var v=this;var t=v.startContainer,u=v.endContainer;if(t.is&&t.is('span')&&t.data('cke-bookmark'))v.setStartAt(t,3);if(u&&u.is&&u.is('span')&&u.data('cke-bookmark'))v.setEndAt(u,4);},trim:function(t,u){var B=this;var v=B.startContainer,w=B.startOffset,x=B.collapsed;if((!t||x)&&v&&v.type==3){if(!w){w=v.getIndex(); +v=v.getParent();}else if(w>=v.getLength()){w=v.getIndex()+1;v=v.getParent();}else{var y=v.split(w);w=v.getIndex()+1;v=v.getParent();if(B.startContainer.equals(B.endContainer))B.setEnd(y,B.endOffset-B.startOffset);else if(v.equals(B.endContainer))B.endOffset+=1;}B.setStart(v,w);if(x){B.collapse(true);return;}}var z=B.endContainer,A=B.endOffset;if(!(u||x)&&z&&z.type==3){if(!A){A=z.getIndex();z=z.getParent();}else if(A>=z.getLength()){A=z.getIndex()+1;z=z.getParent();}else{z.split(A);A=z.getIndex()+1;z=z.getParent();}B.setEnd(z,A);}},enlarge:function(t,u){switch(t){case 1:if(this.collapsed)return;var v=this.getCommonAncestor(),w=this.document.getBody(),x,y,z,A,B,C=false,D,E,F=this.startContainer,G=this.startOffset;if(F.type==3){if(G){F=!e.trim(F.substring(0,G)).length&&F;C=!!F;}if(F)if(!(A=F.getPrevious()))z=F.getParent();}else{if(G)A=F.getChild(G-1)||F.getLast();if(!A)z=F;}while(z||A){if(z&&!A){if(!B&&z.equals(v))B=true;if(!w.contains(z))break;if(!C||z.getComputedStyle('display')!='inline'){C=false;if(B)x=z;else this.setStartBefore(z);}A=z.getPrevious();}while(A){D=false;if(A.type==3){E=A.getText();if(/[^\s\ufeff]/.test(E))A=null;D=/[\s\ufeff]$/.test(E);}else if((A.$.offsetWidth>0||u&&A.is('br'))&&!A.data('cke-bookmark'))if(C&&f.$removeEmpty[A.getName()]){E=A.getText();if(/[^\s\ufeff]/.test(E))A=null;else{var H=A.$.all||A.$.getElementsByTagName('*');for(var I=0,J;J=H[I++];){if(!f.$removeEmpty[J.nodeName.toLowerCase()]){A=null;break;}}}if(A)D=!!E.length;}else A=null;if(D)if(C){if(B)x=z;else if(z)this.setStartBefore(z);}else C=true;if(A){var K=A.getPrevious();if(!z&&!K){z=A;A=null;break;}A=K;}else z=null;}if(z)z=z.getParent();}F=this.endContainer;G=this.endOffset;z=A=null;B=C=false;if(F.type==3){F=!e.trim(F.substring(G)).length&&F;C=!(F&&F.getLength());if(F)if(!(A=F.getNext()))z=F.getParent();}else{A=F.getChild(G);if(!A)z=F;}while(z||A){if(z&&!A){if(!B&&z.equals(v))B=true;if(!w.contains(z))break;if(!C||z.getComputedStyle('display')!='inline'){C=false;if(B)y=z;else if(z)this.setEndAfter(z);}A=z.getNext();}while(A){D=false;if(A.type==3){E=A.getText();if(/[^\s\ufeff]/.test(E))A=null;D=/^[\s\ufeff]/.test(E);}else if((A.$.offsetWidth>0||u&&A.is('br'))&&!A.data('cke-bookmark'))if(C&&f.$removeEmpty[A.getName()]){E=A.getText();if(/[^\s\ufeff]/.test(E))A=null;else{H=A.$.all||A.$.getElementsByTagName('*');for(I=0;J=H[I++];){if(!f.$removeEmpty[J.nodeName.toLowerCase()]){A=null;break;}}}if(A)D=!!E.length;}else A=null;if(D)if(C)if(B)y=z;else this.setEndAfter(z);if(A){K=A.getNext(); +if(!z&&!K){z=A;A=null;break;}A=K;}else z=null;}if(z)z=z.getParent();}if(x&&y){v=x.contains(y)?y:x;this.setStartBefore(v);this.setEndAfter(v);}break;case 2:case 3:var L=new d.range(this.document);w=this.document.getBody();L.setStartAt(w,1);L.setEnd(this.startContainer,this.startOffset);var M=new d.walker(L),N,O,P=d.walker.blockBoundary(t==3?{br:1}:null),Q=function(W){var X=P(W);if(!X)N=W;return X;},R=function(W){var X=Q(W);if(!X&&W.is&&W.is('br'))O=W;return X;};M.guard=Q;z=M.lastBackward();N=N||w;this.setStartAt(N,!N.is('br')&&(!z&&this.checkStartOfBlock()||z&&N.contains(z))?1:4);if(t==3){var S=this.clone();M=new d.walker(S);var T=d.walker.whitespaces(),U=d.walker.bookmark();M.evaluator=function(W){return!T(W)&&!U(W);};var V=M.previous();if(V&&V.type==1&&V.is('br'))return;}L=this.clone();L.collapse();L.setEndAt(w,2);M=new d.walker(L);M.guard=t==3?R:Q;N=null;z=M.lastForward();N=N||w;this.setEndAt(N,!z&&this.checkEndOfBlock()||z&&N.contains(z)?2:3);if(O)this.setEndAfter(O);}},shrink:function(t,u){if(!this.collapsed){t=t||2;var v=this.clone(),w=this.startContainer,x=this.endContainer,y=this.startOffset,z=this.endOffset,A=this.collapsed,B=1,C=1;if(w&&w.type==3)if(!y)v.setStartBefore(w);else if(y>=w.getLength())v.setStartAfter(w);else{v.setStartBefore(w);B=0;}if(x&&x.type==3)if(!z)v.setEndBefore(x);else if(z>=x.getLength())v.setEndAfter(x);else{v.setEndAfter(x);C=0;}var D=new d.walker(v),E=d.walker.bookmark();D.evaluator=function(I){return I.type==(t==1?1:3);};var F;D.guard=function(I,J){if(E(I))return true;if(t==1&&I.type==3)return false;if(J&&I.equals(F))return false;if(!J&&I.type==1)F=I;return true;};if(B){var G=D[t==1?'lastForward':'next']();G&&this.setStartAt(G,u?1:3);}if(C){D.reset();var H=D[t==1?'lastBackward':'previous']();H&&this.setEndAt(H,u?2:4);}return!!(B||C);}},insertNode:function(t){var x=this;x.optimizeBookmark();x.trim(false,true);var u=x.startContainer,v=x.startOffset,w=u.getChild(v);if(w)t.insertBefore(w);else u.append(t);if(t.getParent().equals(x.endContainer))x.endOffset++;x.setStartBefore(t);},moveToPosition:function(t,u){this.setStartAt(t,u);this.collapse(true);},selectNodeContents:function(t){this.setStart(t,0);this.setEnd(t,t.type==3?t.getLength():t.getChildCount());},setStart:function(t,u){var v=this;if(t.type==1&&f.$empty[t.getName()])u=t.getIndex(),t=t.getParent();v.startContainer=t;v.startOffset=u;if(!v.endContainer){v.endContainer=t;v.endOffset=u;}l(v);},setEnd:function(t,u){var v=this;if(t.type==1&&f.$empty[t.getName()])u=t.getIndex()+1,t=t.getParent(); +v.endContainer=t;v.endOffset=u;if(!v.startContainer){v.startContainer=t;v.startOffset=u;}l(v);},setStartAfter:function(t){this.setStart(t.getParent(),t.getIndex()+1);},setStartBefore:function(t){this.setStart(t.getParent(),t.getIndex());},setEndAfter:function(t){this.setEnd(t.getParent(),t.getIndex()+1);},setEndBefore:function(t){this.setEnd(t.getParent(),t.getIndex());},setStartAt:function(t,u){var v=this;switch(u){case 1:v.setStart(t,0);break;case 2:if(t.type==3)v.setStart(t,t.getLength());else v.setStart(t,t.getChildCount());break;case 3:v.setStartBefore(t);break;case 4:v.setStartAfter(t);}l(v);},setEndAt:function(t,u){var v=this;switch(u){case 1:v.setEnd(t,0);break;case 2:if(t.type==3)v.setEnd(t,t.getLength());else v.setEnd(t,t.getChildCount());break;case 3:v.setEndBefore(t);break;case 4:v.setEndAfter(t);}l(v);},fixBlock:function(t,u){var x=this;var v=x.createBookmark(),w=x.document.createElement(u);x.collapse(t);x.enlarge(2);x.extractContents().appendTo(w);w.trim();if(!c)w.appendBogus();x.insertNode(w);x.moveToBookmark(v);return w;},splitBlock:function(t){var D=this;var u=new d.elementPath(D.startContainer),v=new d.elementPath(D.endContainer),w=u.blockLimit,x=v.blockLimit,y=u.block,z=v.block,A=null;if(!w.equals(x))return null;if(t!='br'){if(!y){y=D.fixBlock(true,t);z=new d.elementPath(D.endContainer).block;}if(!z)z=D.fixBlock(false,t);}var B=y&&D.checkStartOfBlock(),C=z&&D.checkEndOfBlock();D.deleteContents();if(y&&y.equals(z))if(C){A=new d.elementPath(D.startContainer);D.moveToPosition(z,4);z=null;}else if(B){A=new d.elementPath(D.startContainer);D.moveToPosition(y,3);y=null;}else{z=D.splitElement(y);if(!c&&!y.is('ul','ol'))y.appendBogus();}return{previousBlock:y,nextBlock:z,wasStartOfBlock:B,wasEndOfBlock:C,elementPath:A};},splitElement:function(t){var w=this;if(!w.collapsed)return null;w.setEndAt(t,2);var u=w.extractContents(),v=t.clone(false);u.appendTo(v);v.insertAfter(t);w.moveToPosition(t,4);return v;},checkBoundaryOfElement:function(t,u){var v=u==1,w=this.clone();w.collapse(v);w[v?'setStartAt':'setEndAt'](t,v?1:2);var x=new d.walker(w);x.evaluator=p;return x[v?'checkBackward':'checkForward']();},checkStartOfBlock:function(){var z=this;var t=z.startContainer,u=z.startOffset;if(u&&t.type==3){var v=e.ltrim(t.substring(0,u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.startContainer),x=z.clone();x.collapse(true);x.setStartAt(w.block||w.blockLimit,1);var y=new d.walker(x);y.evaluator=o(true);return y.checkBackward();},checkEndOfBlock:function(){var z=this; +var t=z.endContainer,u=z.endOffset;if(t.type==3){var v=e.rtrim(t.substring(u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.endContainer),x=z.clone();x.collapse(false);x.setEndAt(w.block||w.blockLimit,2);var y=new d.walker(x);y.evaluator=o(false);return y.checkForward();},checkReadOnly:(function(){function t(u,v){while(u){if(u.type==1)if(u.getAttribute('contentEditable')=='false'&&!u.data('cke-editable'))return 0;else if(u.is('html')||u.getAttribute('contentEditable')=='true'&&(u.contains(v)||u.equals(v)))break;u=u.getParent();}return 1;};return function(){var u=this.startContainer,v=this.endContainer;return!(t(u,v)&&t(v,u));};})(),moveToElementEditablePosition:function(t,u){function v(x,y){var z;if(x.type==1&&x.isEditable(false)&&!f.$nonEditable[x.getName()])z=x[u?'getLast':'getFirst'](s);if(!y&&!z)z=x[u?'getPrevious':'getNext'](s);return z;};var w=0;while(t){if(t.type==3){this.moveToPosition(t,u?4:3);w=1;break;}if(t.type==1)if(t.isEditable()){this.moveToPosition(t,u?2:1);w=1;}t=v(t,w);}return!!w;},moveToElementEditStart:function(t){return this.moveToElementEditablePosition(t);},moveToElementEditEnd:function(t){return this.moveToElementEditablePosition(t,true);},getEnclosedNode:function(){var t=this.clone();t.optimize();if(t.startContainer.type!=1||t.endContainer.type!=1)return null;var u=new d.walker(t),v=d.walker.bookmark(true),w=d.walker.whitespaces(true),x=function(z){return w(z)&&v(z);};t.evaluator=x;var y=u.next();u.reset();return y&&y.equals(u.previous())?y:null;},getTouchedStartNode:function(){var t=this.startContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.startOffset)||t;},getTouchedEndNode:function(){var t=this.endContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.endOffset-1)||t;}};})();a.POSITION_AFTER_START=1;a.POSITION_BEFORE_END=2;a.POSITION_BEFORE_START=3;a.POSITION_AFTER_END=4;a.ENLARGE_ELEMENT=1;a.ENLARGE_BLOCK_CONTENTS=2;a.ENLARGE_LIST_ITEM_CONTENTS=3;a.START=1;a.END=2;a.STARTEND=3;a.SHRINK_ELEMENT=1;a.SHRINK_TEXT=2;(function(){d.rangeList=function(n){if(n instanceof d.rangeList)return n;if(!n)n=[];else if(n instanceof d.range)n=[n];return e.extend(n,l);};var l={createIterator:function(){var n=this,o=d.walker.bookmark(),p=function(s){return!(s.is&&s.is('tr'));},q=[],r;return{getNextRange:function(s){r=r==undefined?0:r+1;var t=n[r];if(t&&n.length>1){if(!r)for(var u=n.length-1;u>=0;u--)q.unshift(n[u].createBookmark(true));if(s){var v=0;while(n[r+v+1]){var w=t.document,x=0,y=w.getById(q[v].endNode),z=w.getById(q[v+1].startNode),A; +while(1){A=y.getNextSourceNode(false);if(!z.equals(A)){if(o(A)||A.type==1&&A.isBlockBoundary()){y=A;continue;}}else x=1;break;}if(!x)break;v++;}}t.moveToBookmark(q.shift());while(v--){A=n[++r];A.moveToBookmark(q.shift());t.setEnd(A.endContainer,A.endOffset);}}return t;}};},createBookmarks:function(n){var s=this;var o=[],p;for(var q=0;q',a.document);l.appendTo(a.document.getHead());try{b.hc=l.getComputedStyle('border-top-color')==l.getComputedStyle('border-right-color');}catch(m){b.hc=false;}if(b.hc)b.cssClass+=' cke_hc';l.remove();})();j.load(i.corePlugins.split(','),function(){a.status='loaded';a.fire('loaded');var l=a._.pending;if(l){delete a._.pending;for(var m=0;m','
    =10900&&!o.hc?'':'" href="javascript:void(\''+(this.title||'').replace("'",'')+"')\"",' title="',this.title,'" tabindex="-1" hidefocus="true" role="button" aria-labelledby="'+p+'_label"'+(this.hasArrow?' aria-haspopup="true"':''));if(o.opera||o.gecko&&o.mac)n.push(' onkeypress="return false;"');if(o.gecko)n.push(' onblur="this.style.cssText = this.style.cssText;"');n.push(' onkeydown="return CKEDITOR.tools.callFunction(',u,', event);" onfocus="return CKEDITOR.tools.callFunction(',v,', event);" '+(c?'onclick="return false;" onmouseup':'onclick')+'="CKEDITOR.tools.callFunction(',s,', this); return false;"> ',this.label,'');if(this.hasArrow)n.push(''+(b.hc?'▼':' ')+'');n.push('','');if(this.onRender)this.onRender();return t;},setState:function(m){if(this._.state==m)return false;this._.state=m;var n=a.document.getById(this._.id);if(n){n.setState(m); m==0?n.setAttribute('aria-disabled',true):n.removeAttribute('aria-disabled');m==1?n.setAttribute('aria-pressed',true):n.removeAttribute('aria-pressed');return true;}else return false;}};})();k.prototype.addButton=function(m,n){this.add(m,'button',n);};(function(){var m=function(y,z){var A=y.document,B=A.getBody(),C=0,D=function(){C=1;};B.on(z,D);(b.version>7?A.$:A.$.selection.createRange()).execCommand(z);B.removeListener(z,D);return C;},n=c?function(y,z){return m(y,z);}:function(y,z){try{return y.document.$.execCommand(z,false,null);}catch(A){return false;}},o=function(y){var z=this;z.type=y;z.canUndo=z.type=='cut';z.startDisabled=true;};o.prototype={exec:function(y,z){this.type=='cut'&&t(y);var A=n(y,this.type);if(!A)alert(y.lang.clipboard[this.type+'Error']);return A;}};var p={canUndo:false,exec:c?function(y){y.focus();if(!y.document.getBody().fire('beforepaste')&&!m(y,'paste')){y.fire('pasteDialog');return false;}}:function(y){try{if(!y.document.getBody().fire('beforepaste')&&!y.document.$.execCommand('Paste',false,null))throw 0;}catch(z){setTimeout(function(){y.fire('pasteDialog');},0);return false;}}},q=function(y){if(this.mode!='wysiwyg')return;switch(y.data.keyCode){case 1114112+86:case 2228224+45:var z=this.document.getBody();if(!c&&z.fire('beforepaste'))y.cancel();else if(b.opera||b.gecko&&b.version<10900)z.fire('paste');return;case 1114112+88:case 2228224+46:var A=this;this.fire('saveSnapshot');setTimeout(function(){A.fire('saveSnapshot');},0);}};function r(y){y.cancel();};function s(y,z,A){var B=this.document;if(B.getById('cke_pastebin'))return;if(z=='text'&&y.data&&y.data.$.clipboardData){var C=y.data.$.clipboardData.getData('text/plain');if(C){y.data.preventDefault();A(C);return;}}var D=this.getSelection(),E=new d.range(B),F=new h(z=='text'?'textarea':b.webkit?'body':'div',B);F.setAttribute('id','cke_pastebin');b.webkit&&F.append(B.createText('\xa0'));B.getBody().append(F);F.setStyles({position:'absolute',top:D.getStartElement().getDocumentPosition().y+'px',width:'1px',height:'1px',overflow:'hidden'});F.setStyle(this.config.contentsLangDirection=='ltr'?'left':'right','-1000px');var G=D.createBookmarks();this.on('selectionChange',r,null,null,0);if(z=='text')F.$.focus();else{E.setStartAt(F,1);E.setEndAt(F,2);E.select(true);}var H=this;window.setTimeout(function(){z=='text'&&b.gecko&&H.focusGrabber.focus();F.remove();H.removeListener('selectionChange',r);var I;F=b.webkit&&(I=F.getFirst())&&I.is&&I.hasClass('Apple-style-span')?I:F;D.selectBookmarks(G); A(F['get'+(z=='text'?'Value':'Html')]());},0);};function t(y){if(!c||b.quirks)return;var z=y.getSelection(),A;if(z.getType()==3&&(A=z.getSelectedElement())){var B=z.getRanges()[0],C=y.document.createText('');C.insertBefore(A);B.setStartBefore(C);B.setEndAfter(A);z.selectRanges([B]);setTimeout(function(){if(A.getParent()){C.remove();z.selectElement(A);}},0);}};var u;function v(y,z){c&&(u=1);var A=2;try{A=z.document.$.queryCommandEnabled(y)?2:0;}catch(B){}u=0;return A;};var w;function x(){var z=this;if(z.mode!='wysiwyg')return;z.getCommand('cut').setState(w?0:v('Cut',z));z.getCommand('copy').setState(v('Copy',z));var y=w?0:b.webkit?2:v('Paste',z);z.fire('pasteState',y);};j.add('clipboard',{requires:['dialog','htmldataprocessor'],init:function(y){y.on('paste',function(A){var B=A.data;if(B.html)y.insertHtml(B.html);else if(B.text)y.insertText(B.text);setTimeout(function(){y.fire('afterPaste');},0);},null,null,1000);y.on('pasteDialog',function(A){setTimeout(function(){y.openDialog('paste');},0);});y.on('pasteState',function(A){y.getCommand('paste').setState(A.data);});function z(A,B,C,D){var E=y.lang[B];y.addCommand(B,C);y.ui.addButton(A,{label:E,command:B});if(y.addMenuItems)y.addMenuItem(B,{label:E,command:B,group:'clipboard',order:D});};z('Cut','cut',new o('cut'),1);z('Copy','copy',new o('copy'),4);z('Paste','paste',p,8);a.dialog.add('paste',a.getUrl(this.path+'dialogs/paste.js'));y.on('key',q,y);y.on('contentDom',function(){var A=y.document.getBody();A.on(b.webkit?'paste':'beforepaste',function(B){if(u)return;var C={mode:'html'};y.fire('beforePaste',C);s.call(y,B,C.mode,function(D){if(!(D=e.trim(D.replace(/]+data-cke-bookmark[^<]*?<\/span>/ig,''))))return;var E={};E[C.mode]=D;y.fire('paste',E);});});A.on('contextmenu',function(){u=1;setTimeout(function(){u=0;},10);});A.on('beforecut',function(){!u&&t(y);});A.on('mouseup',function(){setTimeout(function(){x.call(y);},0);},y);A.on('keyup',x,y);});y.on('selectionChange',function(A){w=A.data.selection.getRanges()[0].checkReadOnly();x.call(y);});if(y.contextMenu)y.contextMenu.addListener(function(A,B){var C=B.getRanges()[0].checkReadOnly();return{cut:!C&&v('Cut',y),copy:v('Copy',y),paste:!C&&(b.webkit?2:v('Paste',y))};});}});})();j.add('colorbutton',{requires:['panelbutton','floatpanel','styles'],init:function(m){var n=m.config,o=m.lang.colorButton,p;if(!b.hc){q('TextColor','fore',o.textColorTitle);q('BGColor','back',o.bgColorTitle);}function q(t,u,v){var w=e.getNextId()+'_colorBox';m.ui.add(t,'panelbutton',{label:v,title:v,className:'cke_button_'+t.toLowerCase(),modes:{wysiwyg:1},panel:{css:m.skin.editor.css,attributes:{role:'listbox','aria-label':o.panelTitle}},onBlock:function(x,y){y.autoSize=true; -y.element.addClass('cke_colorblock');y.element.setHtml(r(x,u,w));y.element.getDocument().getBody().setStyle('overflow','hidden');k.fire('ready',this);var z=y.keys,A=m.lang.dir=='rtl';z[A?37:39]='next';z[40]='next';z[9]='next';z[A?39:37]='prev';z[38]='prev';z[2228224+9]='prev';z[32]='click';},onOpen:function(){var x=m.getSelection(),y=x&&x.getStartElement(),z=new d.elementPath(y),A;y=z.block||z.blockLimit||m.document.getBody();do A=y&&y.getComputedStyle(u=='back'?'background-color':'color')||'transparent';while(u=='back'&&A=='transparent'&&y&&(y=y.getParent()));if(!A||A=='transparent')A='#ffffff';this._.panel._.iframe.getFrameDocument().getById(w).setStyle('background-color',A);}});};function r(t,u,v){var w=[],x=n.colorButton_colors.split(','),y=x.length+(n.colorButton_enableMore?2:1),z=e.addFunction(function(F,G){if(F=='?'){var H=arguments.callee;function I(K){this.removeListener('ok',I);this.removeListener('cancel',I);K.name=='ok'&&H(this.getContentElement('picker','selectedColor').getValue(),G);};m.openDialog('colordialog',function(){this.on('ok',I);this.on('cancel',I);});return;}m.focus();t.hide(false);m.fire('saveSnapshot');new a.style(n['colorButton_'+G+'Style'],{color:'inherit'}).remove(m.document);if(F){var J=n['colorButton_'+G+'Style'];J.childRule=G=='back'?function(K){return s(K);}:function(K){return K.getName()!='a'||s(K);};new a.style(J,{color:F}).apply(m.document);}m.fire('saveSnapshot');});w.push('
    ',o.auto,'
    ');for(var A=0;A');var B=x[A].split('/'),C=B[0],D=B[1]||C;if(!B[1])C='#'+C.replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3');var E=m.lang.colors[D]||D;w.push('');}if(n.colorButton_enableMore===undefined||n.colorButton_enableMore)w.push(''); -w.push('
    ',o.more,'
    ');return w.join('');};function s(t){return t.getAttribute('contentEditable')=='false'||t.getAttribute('data-nostyle');};}});i.colorButton_colors='000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF';i.colorButton_foreStyle={element:'span',styles:{color:'#(color)'},overrides:[{element:'font',attributes:{color:null}}]};i.colorButton_backStyle={element:'span',styles:{'background-color':'#(color)'}};j.colordialog={init:function(m){m.addCommand('colordialog',new a.dialogCommand('colordialog'));a.dialog.add('colordialog',this.path+'dialogs/colordialog.js');}};j.add('colordialog',j.colordialog);j.add('contextmenu',{requires:['menu'],onLoad:function(){j.contextMenu=e.createClass({base:a.menu,$:function(m){this.base.call(this,m,{panel:{className:m.skinClass+' cke_contextmenu',attributes:{'aria-label':m.lang.contextmenu.options}}});},proto:{addTarget:function(m,n){if(b.opera&&!('oncontextmenu' in document.body)){var o;m.on('mousedown',function(s){s=s.data;if(s.$.button!=2){if(s.getKeystroke()==1114112+1)m.fire('contextmenu',s);return;}if(n&&(b.mac?s.$.metaKey:s.$.ctrlKey))return;var t=s.getTarget();if(!o){var u=t.getDocument();o=u.createElement('input');o.$.type='button';u.getBody().append(o);}o.setAttribute('style','position:absolute;top:'+(s.$.clientY-2)+'px;left:'+(s.$.clientX-2)+'px;width:5px;height:5px;opacity:0.01');});m.on('mouseup',function(s){if(o){o.remove();o=undefined;m.fire('contextmenu',s.data);}});}m.on('contextmenu',function(s){var t=s.data;if(n&&(b.webkit?p:b.mac?t.$.metaKey:t.$.ctrlKey))return;t.preventDefault();var u=t.getTarget().getDocument().getDocumentElement(),v=t.$.clientX,w=t.$.clientY;e.setTimeout(function(){this.open(u,null,v,w);},0,this);},this);if(b.opera)m.on('keypress',function(s){var t=s.data;if(t.$.keyCode===0)t.preventDefault();});if(b.webkit){var p,q=function(s){p=b.mac?s.data.$.metaKey:s.data.$.ctrlKey;},r=function(){p=0;};m.on('keydown',q);m.on('keyup',r);m.on('contextmenu',r);}},open:function(m,n,o,p){this.editor.focus();m=m||a.document.getDocumentElement();this.show(m,n,o,p);}}});},beforeInit:function(m){m.contextMenu=new j.contextMenu(m);m.addCommand('contextMenu',{exec:function(){m.contextMenu.open(m.document.getBody());}});}});(function(){function m(o){var p=this.att,q=o&&o.hasAttribute(p)&&o.getAttribute(p)||''; -if(q!==undefined)this.setValue(q);};function n(){var o;for(var p=0;p ';j.add('elementspath',{requires:['selection'],init:function(o){var p='cke_path_'+o.name,q,r=function(){if(!q)q=a.document.getById(p);return q;},s='cke_elementspath_'+e.getNextNumber()+'_';o._.elementsPath={idBase:s,filters:[]};o.on('themeSpace',function(x){if(x.data.space=='bottom')x.data.html+=''+o.lang.elementsPath.eleLabel+''+'
    '+n+'
    ';});function t(x){o.focus();var y=o._.elementsPath.list[x];if(y.is('body')){var z=new d.range(o.document);z.selectNodeContents(y);z.select();}else o.getSelection().selectElement(y);};var u=e.addFunction(t),v=e.addFunction(function(x,y){var z=o._.elementsPath.idBase,A;y=new d.event(y);var B=o.lang.dir=='rtl';switch(y.getKeystroke()){case B?39:37:case 9:A=a.document.getById(z+(x+1));if(!A)A=a.document.getById(z+'0');A.focus();return false;case B?37:39:case 2228224+9:A=a.document.getById(z+(x-1));if(!A)A=a.document.getById(z+(o._.elementsPath.list.length-1));A.focus();return false;case 27:o.focus();return false;case 13:case 32:t(x);return false;}return true;});o.on('selectionChange',function(x){var y=b,z=x.data.selection,A=z.getStartElement(),B=[],C=x.editor,D=C._.elementsPath.list=[],E=C._.elementsPath.filters;while(A){var F=0,G;if(A.data('cke-display-name'))G=A.data('cke-display-name');else if(A.data('cke-real-element-type'))G=A.data('cke-real-element-type');else G=A.getName();for(var H=0;H',G,''+L+'',''); -}if(G=='body')break;A=A.getParent();}var M=r();M.setHtml(B.join('')+n);C.fire('elementsPathUpdate',{space:M});});function w(){q&&q.setHtml(n);delete o._.elementsPath.list;};o.on('readOnly',w);o.on('contentDomUnload',w);o.addCommand('elementsPathFocus',m.toolbarFocus);}});})();(function(){j.add('enterkey',{requires:['keystrokes','indent'],init:function(t){t.addCommand('enter',{modes:{wysiwyg:1},editorFocus:false,exec:function(v){r(v);}});t.addCommand('shiftEnter',{modes:{wysiwyg:1},editorFocus:false,exec:function(v){q(v);}});var u=t.keystrokeHandler.keystrokes;u[13]='enter';u[2228224+13]='shiftEnter';}});j.enterkey={enterBlock:function(t,u,v,w){v=v||s(t);if(!v)return;var x=v.document,y=v.checkStartOfBlock(),z=v.checkEndOfBlock(),A=new d.elementPath(v.startContainer),B=A.block;if(y&&z){if(B&&(B.is('li')||B.getParent().is('li'))){t.execCommand('outdent');return;}}else if(B&&B.is('pre')){if(!z){n(t,u,v,w);return;}}else if(B&&f.$captionBlock[B.getName()]){n(t,u,v,w);return;}var C=u==3?'div':'p',D=v.splitBlock(C);if(!D)return;var E=D.previousBlock,F=D.nextBlock,G=D.wasStartOfBlock,H=D.wasEndOfBlock,I;if(F){I=F.getParent();if(I.is('li')){F.breakParent(I);F.move(F.getNext(),1);}}else if(E&&(I=E.getParent())&&I.is('li')){E.breakParent(I);I=E.getNext();v.moveToElementEditStart(I);E.move(E.getPrevious());}if(!G&&!H){if(F.is('li')&&(I=F.getFirst(d.walker.invisible(true)))&&I.is&&I.is('ul','ol'))(c?x.createText('\xa0'):x.createElement('br')).insertBefore(I);if(F)v.moveToElementEditStart(F);}else{var J,K;if(E){if(E.is('li')||!(p.test(E.getName())||E.is('pre')))J=E.clone();}else if(F)J=F.clone();if(!J){if(I&&I.is('li'))J=I;else{J=x.createElement(C);if(E&&(K=E.getDirection()))J.setAttribute('dir',K);}}else if(w&&!J.is('li'))J.renameNode(C);var L=D.elementPath;if(L)for(var M=0,N=L.elements.length;M0;v--)u[v].deleteContents();return u[0];};})();(function(){var m='nbsp,gt,lt,amp',n='quot,iexcl,cent,pound,curren,yen,brvbar,sect,uml,copy,ordf,laquo,not,shy,reg,macr,deg,plusmn,sup2,sup3,acute,micro,para,middot,cedil,sup1,ordm,raquo,frac14,frac12,frac34,iquest,times,divide,fnof,bull,hellip,prime,Prime,oline,frasl,weierp,image,real,trade,alefsym,larr,uarr,rarr,darr,harr,crarr,lArr,uArr,rArr,dArr,hArr,forall,part,exist,empty,nabla,isin,notin,ni,prod,sum,minus,lowast,radic,prop,infin,ang,and,or,cap,cup,int,there4,sim,cong,asymp,ne,equiv,le,ge,sub,sup,nsub,sube,supe,oplus,otimes,perp,sdot,lceil,rceil,lfloor,rfloor,lang,rang,loz,spades,clubs,hearts,diams,circ,tilde,ensp,emsp,thinsp,zwnj,zwj,lrm,rlm,ndash,mdash,lsquo,rsquo,sbquo,ldquo,rdquo,bdquo,dagger,Dagger,permil,lsaquo,rsaquo,euro',o='Agrave,Aacute,Acirc,Atilde,Auml,Aring,AElig,Ccedil,Egrave,Eacute,Ecirc,Euml,Igrave,Iacute,Icirc,Iuml,ETH,Ntilde,Ograve,Oacute,Ocirc,Otilde,Ouml,Oslash,Ugrave,Uacute,Ucirc,Uuml,Yacute,THORN,szlig,agrave,aacute,acirc,atilde,auml,aring,aelig,ccedil,egrave,eacute,ecirc,euml,igrave,iacute,icirc,iuml,eth,ntilde,ograve,oacute,ocirc,otilde,ouml,oslash,ugrave,uacute,ucirc,uuml,yacute,thorn,yuml,OElig,oelig,Scaron,scaron,Yuml',p='Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,mu,nu,xi,omicron,pi,rho,sigmaf,sigma,tau,upsilon,phi,chi,psi,omega,thetasym,upsih,piv'; -function q(r,s){var t={},u=[],v={nbsp:'\xa0',shy:'­',gt:'>',lt:'<',amp:'&'};r=r.replace(/\b(nbsp|shy|gt|lt|amp)(?:,|$)/g,function(A,B){var C=s?'&'+B+';':v[B],D=s?v[B]:'&'+B+';';t[C]=D;u.push(C);return '';});if(!s&&r){r=r.split(',');var w=document.createElement('div'),x;w.innerHTML='&'+r.join(';&')+';';x=w.innerHTML;w=null;for(var y=0;y0;case 'checked':return!!q.$.checked;case 'value':var p=q.getAttribute('type');return p=='checkbox'||p=='radio'?q.$.value!='on':q.$.value;}return m.apply(q,arguments);};});(function(){var m={canUndo:false,exec:function(o){var p=o.document.createElement('hr'),q=new d.range(o.document);o.insertElement(p);q.moveToPosition(p,4);var r=p.getNext();if(!r||r.type==1&&!r.isEditable())q.fixBlock(true,o.config.enterMode==3?'div':'p');q.select();}},n='horizontalrule';j.add(n,{init:function(o){o.addCommand(n,m);o.ui.addButton('HorizontalRule',{label:o.lang.horizontalrule,command:n});}});})();(function(){var m=/^[\t\r\n ]*(?: |\xa0)$/,n='{cke_protected}';function o(T){var U=T.children.length,V=T.children[U-1];while(V&&V.type==3&&!e.trim(V.value))V=T.children[--U];return V;};function p(T,U){var V=T.children,W=o(T);if(W){if((U||!c)&&W.type==1&&W.name=='br')V.pop();if(W.type==3&&m.test(W.value))V.pop();}};function q(T,U,V){if(!U&&(!V||typeof V=='function'&&V(T)===false))return false;if(U&&c&&(document.documentMode>7||T.name in f.tr||T.name in f.$listItem))return false;var W=o(T);return!W||W&&(W.type==1&&W.name=='br'||T.name=='form'&&W.name=='input');};function r(T,U){return function(V){p(V,!T);if(q(V,!T,U))if(T||c)V.add(new a.htmlParser.text('\xa0'));else V.add(new a.htmlParser.element('br',{}));};};var s=f,t=['caption','colgroup','col','thead','tfoot','tbody'],u=e.extend({},s.$block,s.$listItem,s.$tableContent);for(var v in u){if(!('br' in s[v]))delete u[v];}delete u.pre;var w={elements:{},attributeNames:[[/^on/,'data-cke-pa-on']]},x={elements:{}};for(v in u)x.elements[v]=r();var y={elementNames:[[/^cke:/,''],[/^\?xml:namespace$/,'']],attributeNames:[[/^data-cke-(saved|pa)-/,''],[/^data-cke-.*/,''],['hidefocus','']],elements:{$:function(T){var U=T.attributes;if(U){if(U['data-cke-temp'])return false;var V=['name','href','src'],W;for(var X=0;Xe.indexOf(t,W.name)?1:-1:0; -});},embed:function(T){var U=T.parent;if(U&&U.name=='object'){var V=U.attributes.width,W=U.attributes.height;V&&(T.attributes.width=V);W&&(T.attributes.height=W);}},param:function(T){T.children=[];T.isEmpty=true;return T;},a:function(T){if(!(T.children.length||T.attributes.name||T.attributes['data-cke-saved-name']))return false;},span:function(T){if(T.attributes['class']=='Apple-style-span')delete T.name;},pre:function(T){c&&p(T);},html:function(T){delete T.attributes.contenteditable;delete T.attributes['class'];},body:function(T){delete T.attributes.spellcheck;delete T.attributes.contenteditable;},style:function(T){var U=T.children[0];U&&U.value&&(U.value=e.trim(U.value));if(!T.attributes.type)T.attributes.type='text/css';},title:function(T){var U=T.children[0];U&&(U.value=T.attributes['data-cke-title']||'');}},attributes:{'class':function(T,U){return e.ltrim(T.replace(/(?:^|\s+)cke_[^\s]*/g,''))||false;}}};if(c)y.attributes.style=function(T,U){return T.replace(/(^|;)([^\:]+)/g,function(V){return V.toLowerCase();});};function z(T){var U=T.attributes;if(U.contenteditable!='false')U['data-cke-editable']=U.contenteditable?'true':1;U.contenteditable='false';};function A(T){var U=T.attributes;switch(U['data-cke-editable']){case 'true':U.contenteditable='true';break;case '1':delete U.contenteditable;break;}};for(v in {input:1,textarea:1}){w.elements[v]=z;y.elements[v]=A;}var B=/<(a|area|img|input)\b([^>]*)>/gi,C=/\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,D=/(?:])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,E=/([^<]*)<\/cke:encoded>/gi,F=/(<\/?)((?:object|embed|param|html|body|head|title)[^>]*>)/gi,G=/(<\/?)cke:((?:html|body|head|title)[^>]*>)/gi,H=/]*?)\/?>(?!\s*<\/cke:\1)/gi;function I(T){return T.replace(B,function(U,V,W){return '<'+V+W.replace(C,function(X,Y){if(W.indexOf('data-cke-saved-'+Y)==-1)return ' data-cke-saved-'+X+' '+X;return X;})+'>';});};function J(T){return T.replace(D,function(U){return ''+encodeURIComponent(U)+'';});};function K(T){return T.replace(E,function(U,V){return decodeURIComponent(V);});};function L(T){return T.replace(F,'$1cke:$2');};function M(T){return T.replace(G,'$1$2');};function N(T){return T.replace(H,'');};function O(T){return T.replace(/(]*>)(\r\n|\n)/g,'$1$2$2');};function P(T){return T.replace(//g,function(U){return ''; -});};function Q(T){return T.replace(//g,function(U,V){return decodeURIComponent(V);});};function R(T,U){var V=U._.dataStore;return T.replace(//g,function(W,X){return decodeURIComponent(X);}).replace(/\{cke_protected_(\d+)\}/g,function(W,X){return V&&V[X]||'';});};function S(T,U){var V=[],W=U.config.protectedSource,X=U._.dataStore||(U._.dataStore={id:1}),Y=/<\!--\{cke_temp(comment)?\}(\d*?)-->/g,Z=[//gi,//gi].concat(W);T=T.replace(//g,function(ab){return '';});for(var aa=0;aa';});T=T.replace(Y,function(ab,ac,ad){return '';});return T.replace(/(['"]).*?\1/g,function(ab){return ab.replace(//g,function(ac,ad){X[X.id]=decodeURIComponent(ad);return '{cke_protected_'+X.id++ +'}';});});};j.add('htmldataprocessor',{requires:['htmlwriter'],init:function(T){var U=T.dataProcessor=new a.htmlDataProcessor(T);U.writer.forceSimpleAmpersand=T.config.forceSimpleAmpersand;U.dataFilter.addRules(w);U.dataFilter.addRules(x);U.htmlFilter.addRules(y);var V={elements:{}};for(v in u)V.elements[v]=r(true,T.config.fillEmptyBlocks);U.htmlFilter.addRules(V);},onLoad:function(){!('fillEmptyBlocks' in i)&&(i.fillEmptyBlocks=1);}});a.htmlDataProcessor=function(T){var U=this;U.editor=T;U.writer=new a.htmlWriter();U.dataFilter=new a.htmlParser.filter();U.htmlFilter=new a.htmlParser.filter();};a.htmlDataProcessor.prototype={toHtml:function(T,U){T=S(T,this.editor);T=I(T);T=J(T);T=L(T);T=N(T);T=O(T);var V=new h('div');V.setHtml('a'+T);T=V.getHtml().substr(1);T=M(T);T=K(T);T=Q(T);var W=a.htmlParser.fragment.fromHtml(T,U),X=new a.htmlParser.basicWriter();W.writeHtml(X,this.dataFilter);T=X.getHtml(true);T=P(T);return T;},toDataFormat:function(T,U){var V=this.writer,W=a.htmlParser.fragment.fromHtml(T,U);V.reset();W.writeHtml(V,this.htmlFilter);var X=V.getHtml(true);X=Q(X);X=R(X,this.editor);return X;}};})();(function(){j.add('iframe',{requires:['dialog','fakeobjects'],init:function(m){var n='iframe',o=m.lang.iframe;a.dialog.add(n,this.path+'dialogs/iframe.js');m.addCommand(n,new a.dialogCommand(n));m.addCss('img.cke_iframe{background-image: url('+a.getUrl(this.path+'images/placeholder.png')+');'+'background-position: center center;'+'background-repeat: no-repeat;'+'border: 1px solid #a9a9a9;'+'width: 80px;'+'height: 80px;'+'}'); -m.ui.addButton('Iframe',{label:o.toolbar,command:n});m.on('doubleclick',function(p){var q=p.data.element;if(q.is('img')&&q.data('cke-real-element-type')=='iframe')p.data.dialog='iframe';});if(m.addMenuItems)m.addMenuItems({iframe:{label:o.title,command:'iframe',group:'image'}});if(m.contextMenu)m.contextMenu.addListener(function(p,q){if(p&&p.is('img')&&p.data('cke-real-element-type')=='iframe')return{iframe:2};});},afterInit:function(m){var n=m.dataProcessor,o=n&&n.dataFilter;if(o)o.addRules({elements:{iframe:function(p){return m.createFakeParserElement(p,'cke_iframe','iframe',true);}}});}});})();j.add('image',{init:function(m){var n='image';a.dialog.add(n,this.path+'dialogs/image.js');m.addCommand(n,new a.dialogCommand(n));m.ui.addButton('Image',{label:m.lang.common.image,command:n});m.on('doubleclick',function(o){var p=o.data.element;if(p.is('img')&&!p.data('cke-realelement')&&!p.isReadOnly())o.data.dialog='image';});if(m.addMenuItems)m.addMenuItems({image:{label:m.lang.image.menu,command:'image',group:'image'}});if(m.contextMenu)m.contextMenu.addListener(function(o,p){if(!o||!o.is('img')||o.data('cke-realelement')||o.isReadOnly())return null;return{image:2};});}});i.image_removeLinkByEmptyURL=true;(function(){var m={ol:1,ul:1},n=d.walker.whitespaces(true),o=d.walker.bookmark(false,true);function p(t){var B=this;if(t.editor.readOnly)return null;var u=t.editor,v=t.data.path,w=v&&v.contains(m),x=v.block||v.blockLimit;if(w)return B.setState(2);if(!B.useIndentClasses&&B.name=='indent')return B.setState(2);if(!x)return B.setState(0);if(B.useIndentClasses){var y=x.$.className.match(B.classNameRegex),z=0;if(y){y=y[1];z=B.indentClassMap[y];}if(B.name=='outdent'&&!z||B.name=='indent'&&z==u.config.indentClasses.length)return B.setState(0);return B.setState(2);}else{var A=parseInt(x.getStyle(r(x)),10);if(isNaN(A))A=0;if(A<=0)return B.setState(0);return B.setState(2);}};function q(t,u){var w=this;w.name=u;w.useIndentClasses=t.config.indentClasses&&t.config.indentClasses.length>0;if(w.useIndentClasses){w.classNameRegex=new RegExp('(?:^|\\s+)('+t.config.indentClasses.join('|')+')(?=$|\\s)');w.indentClassMap={};for(var v=0;vY;T++)X[T].indent+=U;var aa=j.list.arrayToList(X,v,null,t.config.enterMode,M.getDirection());if(u.name=='outdent'){var ab;if((ab=M.getParent())&&ab.is('li')){var ac=aa.listNode.getChildren(),ad=[],ae=ac.count(),af;for(T=ae-1;T>=0;T--){if((af=ac.getItem(T))&&af.is&&af.is('li'))ad.push(af);}}}if(aa)aa.listNode.replace(M);if(ad&&ad.length)for(T=0;T0)M.addClass(t.config.indentClasses[P-1]);}else{var Q=r(M,N),R=parseInt(M.getStyle(Q),10);if(isNaN(R))R=0;var S=t.config.indentOffset||40;R+=(u.name=='indent'?1:-1)*S;if(R<0)return false;R=Math.max(R,0);R=Math.ceil(R/S)*S;M.setStyle(Q,R?R+(t.config.indentUnit||'px'):'');if(M.getAttribute('style')==='')M.removeAttribute('style');}h.setMarker(v,M,'indent_processed',1);return true;};var z=t.getSelection(),A=z.createBookmarks(1),B=z&&z.getRanges(1),C,D=B.createIterator();while(C=D.getNextRange()){var E=C.getCommonAncestor(),F=E;while(F&&!(F.type==1&&m[F.getName()]))F=F.getParent();if(!F){var G=C.getEnclosedNode();if(G&&G.type==1&&G.getName() in m){C.setStartAt(G,1);C.setEndAt(G,2);F=G;}}if(F&&C.startContainer.type==1&&C.startContainer.getName() in m){var H=new d.walker(C); -H.evaluator=s;C.startContainer=H.next();}if(F&&C.endContainer.type==1&&C.endContainer.getName() in m){H=new d.walker(C);H.evaluator=s;C.endContainer=H.previous();}if(F){var I=F.getFirst(s),J=!!I.getNext(s),K=C.startContainer,L=I.equals(K)||I.contains(K);if(!(L&&(u.name=='indent'||u.useIndentClasses||parseInt(F.getStyle(r(F)),10))&&y(F,!J&&I.getDirection())))w(F);}else x();}h.clearAllMarkers(v);t.forceNextSelectionCheck();z.selectBookmarks(A);}};j.add('indent',{init:function(t){var u=t.addCommand('indent',new q(t,'indent')),v=t.addCommand('outdent',new q(t,'outdent'));t.ui.addButton('Indent',{label:t.lang.indent,command:'indent'});t.ui.addButton('Outdent',{label:t.lang.outdent,command:'outdent'});t.on('selectionChange',e.bind(p,u));t.on('selectionChange',e.bind(p,v));if(b.ie6Compat||b.ie7Compat)t.addCss('ul,ol{\tmargin-left: 0px;\tpadding-left: 40px;}');t.on('dirChanged',function(w){var x=new d.range(t.document);x.setStartBefore(w.data.node);x.setEndAfter(w.data.node);var y=new d.walker(x),z;while(z=y.next()){if(z.type==1){if(!z.equals(w.data.node)&&z.getDirection()){x.setStartAfter(z);y=new d.walker(x);continue;}var A=t.config.indentClasses;if(A){var B=w.data.dir=='ltr'?['_rtl','']:['','_rtl'];for(var C=0;C=0;A--){x=v[A].createIterator();x.enlargeBr=t!=2;while(y=x.getNextParagraph(t==1?'p':'div')){y.removeAttribute('align');y.removeStyle('text-align');var B=w&&(y.$.className=e.ltrim(y.$.className.replace(D.cssClassRegex,''))),C=D.state==2&&(!z||n(y,true)!=D.value);if(w){if(C)y.addClass(w);else if(!B)y.removeAttribute('class');}else if(C)y.setStyle('text-align',D.value);}}r.focus();r.forceNextSelectionCheck();s.selectBookmarks(u);}};j.add('justify',{init:function(r){var s=new p(r,'justifyleft','left'),t=new p(r,'justifycenter','center'),u=new p(r,'justifyright','right'),v=new p(r,'justifyblock','justify');r.addCommand('justifyleft',s);r.addCommand('justifycenter',t);r.addCommand('justifyright',u);r.addCommand('justifyblock',v);r.ui.addButton('JustifyLeft',{label:r.lang.justify.left,command:'justifyleft'});r.ui.addButton('JustifyCenter',{label:r.lang.justify.center,command:'justifycenter'});r.ui.addButton('JustifyRight',{label:r.lang.justify.right,command:'justifyright'});r.ui.addButton('JustifyBlock',{label:r.lang.justify.block,command:'justifyblock'});r.on('selectionChange',e.bind(o,s));r.on('selectionChange',e.bind(o,u));r.on('selectionChange',e.bind(o,t));r.on('selectionChange',e.bind(o,v));r.on('dirChanged',q);},requires:['domiterator']});})();j.add('keystrokes',{beforeInit:function(m){m.keystrokeHandler=new a.keystrokeHandler(m);m.specialKeys={};},init:function(m){var n=m.config.keystrokes,o=m.config.blockedKeystrokes,p=m.keystrokeHandler.keystrokes,q=m.keystrokeHandler.blockedKeystrokes;for(var r=0;r7))O.append(J.createText('\xa0'));O.append(U.listNode);M=U.nextIndex;}else if(R.indent==-1&&!G&&R.grandparent){if(m[R.grandparent.getName()])O=R.element.clone(false,true);else if(I||R.element.hasAttributes()||H!=2){O=J.createElement(Q);R.element.copyAttributes(O,{type:1,value:1});if(!I&&H==2&&!O.hasAttributes())O=new d.documentFragment(J);}else O=new d.documentFragment(J);if(O.type==1)if(R.grandparent.getDirection(1)!=P)O.setAttribute('dir',P);else O.removeAttribute('dir');for(S=0;SH[J-1].indent+1){var N=H[J-1].indent+1-H[J].indent,O=H[J].indent;while(H[J]&&H[J].indent>=O){H[J].indent+=N;J++;}J--;}}var P=j.list.arrayToList(H,G,null,E.config.enterMode,F.root.getAttribute('dir')),Q=P.listNode,R,S;function T(U){if((R=Q[U?'getFirst':'getLast']())&&!(R.is&&R.isBlockBoundary())&&(S=F.root[U?'getPrevious':'getNext'](d.walker.whitespaces(true)))&&!(S.is&&S.isBlockBoundary({br:1})))E.document.createElement('br')[U?'insertBefore':'insertAfter'](R);};T(true);T();Q.replace(F.root);};function w(E,F){this.name=E;this.type=F;};w.prototype={exec:function(E){var F=E.document,G=E.config,H=E.getSelection(),I=H&&H.getRanges(true);if(!I||I.length<1)return;if(this.state==2){var J=F.getBody();if(!J.getFirst(q)){G.enterMode==2?J.appendBogus():I[0].fixBlock(1,G.enterMode==1?'p':'div');H.selectRanges(I);}else{var K=I.length==1&&I[0],L=K&&K.getEnclosedNode();if(L&&L.is&&this.type==L.getName())this.setState(1);}}var M=H.createBookmarks(true),N=[],O={},P=I.createIterator(),Q=0;while((K=P.getNextRange())&&++Q){var R=K.getBoundaryNodes(),S=R.startNode,T=R.endNode;if(S.type==1&&S.getName()=='td')K.setStartAt(R.startNode,1);if(T.type==1&&T.getName()=='td')K.setEndAt(R.endNode,2);var U=K.createIterator(),V;U.forceBrBreak=this.state==2;while(V=U.getNextParagraph()){if(V.getCustomData('list_block'))continue;else h.setMarker(O,V,'list_block',1);var W=new d.elementPath(V),X=W.elements,Y=X.length,Z=null,aa=0,ab=W.blockLimit,ac;for(var ad=Y-1;ad>=0&&(ac=X[ad]);ad--){if(m[ac.getName()]&&ab.contains(ac)){ab.removeCustomData('list_group_object_'+Q);var ae=ac.getCustomData('list_group_object');if(ae)ae.contents.push(V);else{ae={root:ac,contents:[V]};N.push(ae);h.setMarker(O,ac,'list_group_object',ae);}aa=1;break;}}if(aa)continue;var af=ab;if(af.getCustomData('list_group_object_'+Q))af.getCustomData('list_group_object_'+Q).contents.push(V);else{ae={root:af,contents:[V]};h.setMarker(O,af,'list_group_object_'+Q,ae);N.push(ae);}}}var ag=[];while(N.length>0){ae=N.shift();if(this.state==2){if(m[ae.root.getName()])s.call(this,E,ae,O,ag);else u.call(this,E,ae,ag);}else if(this.state==1&&m[ae.root.getName()])v.call(this,E,ae,O);}for(ad=0;ad0)for(var u=t.length-1;u>=0;u--){var v=t[u][0],w=t[u][1];if(w)v.insertBefore(w);else v.appendTo(s);}};function o(s,t){var u=m(s),v={},w=s.$;if(!t){v['class']=w.className||'';w.className='';}v.inline=w.style.cssText||'';if(!t)w.style.cssText='position: static; overflow: visible';n(u);return v;};function p(s,t){var u=m(s),v=s.$;if('class' in t)v.className=t['class'];if('inline' in t)v.style.cssText=t.inline;n(u);};function q(s){var t=a.instances;for(var u in t){var v=t[u];if(v.mode=='wysiwyg'&&!v.readOnly){var w=v.document.getBody();w.setAttribute('contentEditable',false);w.setAttribute('contentEditable',true);}}if(s.focusManager.hasFocus){s.toolbox.focus();s.focus();}};function r(s){if(!c||b.version>6)return null;var t=h.createFromHtml('');return s.append(t,true);};j.add('maximize',{init:function(s){var t=s.lang,u=a.document,v=u.getWindow(),w,x,y,z;function A(){var C=v.getViewPaneSize();z&&z.setStyles({width:C.width+'px',height:C.height+'px'});s.resize(C.width,C.height,null,true);};var B=2;s.addCommand('maximize',{modes:{wysiwyg:1,source:1},readOnly:1,editorFocus:false,exec:function(){var C=s.container.getChild(1),D=s.getThemeSpace('contents');if(s.mode=='wysiwyg'){var E=s.getSelection();w=E&&E.getRanges();x=v.getScrollPosition();}else{var F=s.textarea.$;w=!c&&[F.selectionStart,F.selectionEnd];x=[F.scrollLeft,F.scrollTop];}if(this.state==2){v.on('resize',A);y=v.getScrollPosition();var G=s.container;while(G=G.getParent()){G.setCustomData('maximize_saved_styles',o(G));G.setStyle('z-index',s.config.baseFloatZIndex-1);}D.setCustomData('maximize_saved_styles',o(D,true));C.setCustomData('maximize_saved_styles',o(C,true));var H={overflow:b.webkit?'':'hidden',width:0,height:0};u.getDocumentElement().setStyles(H);!b.gecko&&u.getDocumentElement().setStyle('position','fixed');!(b.gecko&&b.quirks)&&u.getBody().setStyles(H);c?setTimeout(function(){v.$.scrollTo(0,0);},0):v.$.scrollTo(0,0);C.setStyle('position',b.gecko&&b.quirks?'fixed':'absolute');C.$.offsetLeft;C.setStyles({'z-index':s.config.baseFloatZIndex-1,left:'0px',top:'0px'});z=r(C);C.addClass('cke_maximized');A();var I=C.getDocumentPosition();C.setStyles({left:-1*I.x+'px',top:-1*I.y+'px'});b.gecko&&q(s); -}else if(this.state==1){v.removeListener('resize',A);var J=[D,C];for(var K=0;K '); -s.children.length=0;s.add(u);var v=s.attributes;delete v['aria-label'];delete v.contenteditable;delete v.title;}return t;}}},5);if(p)p.addRules({elements:{div:function(r){var s=r.attributes,t=s&&s.style,u=t&&r.children.length==1&&r.children[0],v=u&&u.name=='span'&&u.attributes.style;if(v&&/page-break-after\s*:\s*always/i.test(t)&&/display\s*:\s*none/i.test(v)){s.contenteditable='false';s['class']='cke_pagebreak';s['data-cke-display-name']='pagebreak';s['aria-label']=n;s.title=n;r.children.length=0;}}}});},requires:['fakeobjects']});j.pagebreakCmd={exec:function(m){var n=m.lang.pagebreakAlt,o=h.createFromHtml('
    '+'
    ',m.document),p=m.getSelection().getRanges(true);m.fire('saveSnapshot');for(var q,r=p.length-1;r>=0;r--){q=p[r];if(r1&&n.substr(n.length-1,1)=='%')n=parseInt(window.screen.width*parseInt(n,10)/100,10);if(typeof o=='string'&&o.length>1&&o.substr(o.length-1,1)=='%')o=parseInt(window.screen.height*parseInt(o,10)/100,10);if(n<640)n=640;if(o<420)o=420;var q=parseInt((window.screen.height-o)/2,10),r=parseInt((window.screen.width-n)/2,10);p=(p||'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes')+',width='+n+',height='+o+',top='+q+',left='+r;var s=window.open('',null,p,true);if(!s)return false;try{s.moveTo(r,q);s.resizeTo(n,o);s.focus();s.location.href=m;}catch(t){s=window.open(m,null,p,true);}return true;}});(function(){var m={modes:{wysiwyg:1,source:1},canUndo:false,readOnly:1,exec:function(o){var p,q=o.config,r=q.baseHref?'':'',s=b.isCustomDomain();if(q.fullPage)p=o.getData().replace(//,'$&'+r).replace(/[^>]*(?=<\/title>)/,'$& — '+o.lang.preview);else{var t=''+''+r+''+o.lang.preview+''+e.buildStyleHtml(o.config.contentsCss)+''+t+o.getData()+'';}var v=640,w=420,x=80;try{var y=window.screen;v=Math.round(y.width*0.8);w=Math.round(y.height*0.7);x=Math.round(y.width*0.1);}catch(B){}var z='';if(s){window._cke_htmlToLoad=p;z='javascript:void( (function(){document.open();document.domain="'+document.domain+'";'+'document.write( window.opener._cke_htmlToLoad );'+'document.close();'+'window.opener._cke_htmlToLoad = null;'+'})() )';}var A=window.open(z,null,'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+v+',height='+w+',left='+x); -if(!s){A.document.open();A.document.write(p);A.document.close();}}},n='preview';j.add(n,{init:function(o){o.addCommand(n,m);o.ui.addButton('Preview',{label:o.lang.preview,command:n});}});})();j.add('print',{init:function(m){var n='print',o=m.addCommand(n,j.print);m.ui.addButton('Print',{label:m.lang.print,command:n});}});j.print={exec:function(m){if(b.opera)return;else if(b.gecko)m.window.$.print();else m.document.$.execCommand('Print');},canUndo:false,readOnly:1,modes:{wysiwyg:!b.opera}};j.add('removeformat',{requires:['selection'],init:function(m){m.addCommand('removeFormat',j.removeformat.commands.removeformat);m.ui.addButton('RemoveFormat',{label:m.lang.removeFormat,command:'removeFormat'});m._.removeFormat={filters:[]};}});j.removeformat={commands:{removeformat:{exec:function(m){var n=m._.removeFormatRegex||(m._.removeFormatRegex=new RegExp('^(?:'+m.config.removeFormatTags.replace(/,/g,'|')+')$','i')),o=m._.removeAttributes||(m._.removeAttributes=m.config.removeFormatAttributes.split(',')),p=j.removeformat.filter,q=m.getSelection().getRanges(1),r=q.createIterator(),s;while(s=r.getNextRange()){if(!s.collapsed)s.enlarge(1);var t=s.createBookmark(),u=t.startNode,v=t.endNode,w,x=function(z){var A=new d.elementPath(z),B=A.elements;for(var C=1,D;D=B[C];C++){if(D.equals(A.block)||D.equals(A.blockLimit))break;if(n.test(D.getName())&&p(m,D))z.breakParent(D);}};x(u);if(v){x(v);w=u.getNextSourceNode(true,1);while(w){if(w.equals(v))break;var y=w.getNextSourceNode(false,1);if(!(w.getName()=='img'&&w.data('cke-realelement'))&&p(m,w))if(n.test(w.getName()))w.remove(1);else{w.removeAttributes(o);m.fire('removeFormatCleanup',w);}w=y;}}s.moveToBookmark(t);}m.getSelection().selectRanges(q);}}},filter:function(m,n){var o=m._.removeFormat.filters;for(var p=0;pr.width&&(n.resize_minWidth=r.width);n.resize_minHeight>r.height&&(n.resize_minHeight=r.height);a.document.on('mousemove',u);a.document.on('mouseup',v);if(m.document){m.document.on('mousemove',u);m.document.on('mouseup',v);}});m.on('destroy',function(){e.removeFunction(w);});m.on('themeSpace',function(x){if(x.data.space=='bottom'){var y='';if(s&&!t)y=' cke_resizer_horizontal';if(!s&&t)y=' cke_resizer_vertical';var z='
    ';o=='ltr'&&y=='ltr'?x.data.html+=z:x.data.html=z+x.data.html;}},m,null,100);}}});(function(){var m={modes:{wysiwyg:1,source:1},readOnly:1,exec:function(o){var p=o.element.$.form;if(p)try{p.submit();}catch(q){if(p.submit.click)p.submit.click();}}},n='save';j.add(n,{init:function(o){var p=o.addCommand(n,m);p.modes={wysiwyg:!!o.element.$.form};o.ui.addButton('Save',{label:o.lang.save,command:n});}});})();(function(){var m='scaytcheck',n='';function o(t,u){var v=0,w;for(w in u){if(u[w]==t){v=1;break;}}return v;};var p=function(){var t=this,u=function(){var y=t.config,z={};z.srcNodeRef=t.document.getWindow().$.frameElement;z.assocApp='CKEDITOR.'+a.version+'@'+a.revision;z.customerid=y.scayt_customerid||'1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2';z.customDictionaryIds=y.scayt_customDictionaryIds||'';z.userDictionaryName=y.scayt_userDictionaryName||'';z.sLang=y.scayt_sLang||'en_US';z.onLoad=function(){if(!(c&&b.version<8))this.addStyle(this.selectorCss(),'padding-bottom: 2px !important;');if(t.focusManager.hasFocus&&!q.isControlRestored(t))this.focus();};z.onBeforeChange=function(){if(q.getScayt(t)&&!t.checkDirty())setTimeout(function(){t.resetDirty();},0);};var A=window.scayt_custom_params;if(typeof A=='object')for(var B in A)z[B]=A[B];if(q.getControlId(t))z.id=q.getControlId(t); -var C=new window.scayt(z);C.afterMarkupRemove.push(function(E){new h(E,C.document).mergeSiblings();});var D=q.instances[t.name];if(D){C.sLang=D.sLang;C.option(D.option());C.paused=D.paused;}q.instances[t.name]=C;try{C.setDisabled(q.isPaused(t)===false);}catch(E){}t.fire('showScaytState');};t.on('contentDom',u);t.on('contentDomUnload',function(){var y=a.document.getElementsByTag('script'),z=/^dojoIoScript(\d+)$/i,A=/^https?:\/\/svc\.spellchecker\.net\/spellcheck\/script\/ssrv\.cgi/i;for(var B=0;B=0){this.setState(0);q.loadEngine(t);}}};j.add('scayt',{requires:['menubutton'],beforeInit:function(t){var u=t.config.scayt_contextMenuItemsOrder||'suggest|moresuggest|control',v=''; -u=u.split('|');if(u&&u.length)for(var w=0;w tr > td, .%1 table.%2 > tr > th,','.%1 table.%2 > tbody > tr > td, .%1 table.%2 > tbody > tr > th,','.%1 table.%2 > thead > tr > td, .%1 table.%2 > thead > tr > th,','.%1 table.%2 > tfoot > tr > td, .%1 table.%2 > tfoot > tr > th','{','border : #d3d3d3 1px dotted','}']).join('');n=o.replace(/%2/g,m).replace(/%1/g,'cke_show_borders ');var p={preserveState:true,editorFocus:false,readOnly:1,exec:function(q){this.toggleState();this.refresh(q);},refresh:function(q){if(q.document){var r=this.state==1?'addClass':'removeClass';q.document.getBody()[r]('cke_show_borders');}}};j.add('showborders',{requires:['wysiwygarea'],modes:{wysiwyg:1},init:function(q){var r=q.addCommand('showborders',p);r.canUndo=false;if(q.config.startupShowBorders!==false)r.setState(1);q.addCss(n);q.on('mode',function(){if(r.state!=0)r.refresh(q);},null,null,100);q.on('contentDom',function(){if(r.state!=0)r.refresh(q);});q.on('removeFormatCleanup',function(s){var t=s.data;if(q.getCommand('showborders').state==1&&t.is('table')&&(!t.hasAttribute('border')||parseInt(t.getAttribute('border'),10)<=0))t.addClass(m);});},afterInit:function(q){var r=q.dataProcessor,s=r&&r.dataFilter,t=r&&r.htmlFilter;if(s)s.addRules({elements:{table:function(u){var v=u.attributes,w=v['class'],x=parseInt(v.border,10);if(!x||x<=0)v['class']=(w||'')+' '+m;}}});if(t)t.addRules({elements:{table:function(u){var v=u.attributes,w=v['class'];w&&(v['class']=w.replace(m,'').replace(/\s{2}/,' ').replace(/^\s+|\s+$/,''));}}});}});a.on('dialogDefinition',function(q){var r=q.data.name;if(r=='table'||r=='tableProperties'){var s=q.data.definition,t=s.getContents('info'),u=t.get('txtBorder'),v=u.commit;u.commit=e.override(v,function(y){return function(z,A){y.apply(this,arguments); -var B=parseInt(this.getValue(),10);A[!B||B<=0?'addClass':'removeClass'](m);};});var w=s.getContents('advanced'),x=w&&w.get('advCSSClasses');if(x){x.setup=e.override(x.setup,function(y){return function(){y.apply(this,arguments);this.setValue(this.getValue().replace(/cke_show_border/,''));};});x.commit=e.override(x.commit,function(y){return function(z,A){y.apply(this,arguments);if(!parseInt(A.getAttribute('border'),10))A.addClass('cke_show_border');};});}}});})();j.add('sourcearea',{requires:['editingblock'],init:function(m){var n=j.sourcearea,o=a.document.getWindow();m.on('editingBlockReady',function(){var p,q;m.addMode('source',{load:function(r,s){if(c&&b.version<8)r.setStyle('position','relative');m.textarea=p=new h('textarea');p.setAttributes({dir:'ltr',tabIndex:b.webkit?-1:m.tabIndex,role:'textbox','aria-label':m.lang.editorTitle.replace('%1',m.name)});p.addClass('cke_source');p.addClass('cke_enable_context_menu');m.readOnly&&p.setAttribute('readOnly','readonly');var t={width:b.ie7Compat?'99%':'100%',height:'100%',resize:'none',outline:'none','text-align':'left'};if(c){q=function(){p.hide();p.setStyle('height',r.$.clientHeight+'px');p.setStyle('width',r.$.clientWidth+'px');p.show();};m.on('resize',q);o.on('resize',q);setTimeout(q,0);}r.setHtml('');r.append(p);p.setStyles(t);m.fire('ariaWidget',p);p.on('blur',function(){m.focusManager.blur();});p.on('focus',function(){m.focusManager.focus();});m.mayBeDirty=true;this.loadData(s);var u=m.keystrokeHandler;if(u)u.attach(p);setTimeout(function(){m.mode='source';m.fire('mode');},b.gecko||b.webkit?100:0);},loadData:function(r){p.setValue(r);m.fire('dataReady');},getData:function(){return p.getValue();},getSnapshotData:function(){return p.getValue();},unload:function(r){p.clearCustomData();m.textarea=p=null;if(q){m.removeListener('resize',q);o.removeListener('resize',q);}if(c&&b.version<8)r.removeStyle('position');},focus:function(){p.focus();}});});m.on('readOnly',function(){if(m.mode=='source')if(m.readOnly)m.textarea.setAttribute('readOnly','readonly');else m.textarea.removeAttribute('readOnly');});m.addCommand('source',n.commands.source);if(m.ui.addButton)m.ui.addButton('Source',{label:m.lang.source,command:'source'});m.on('mode',function(){m.getCommand('source').setState(m.mode=='source'?1:2);});}});j.sourcearea={commands:{source:{modes:{wysiwyg:1,source:1},editorFocus:false,readOnly:1,exec:function(m){if(m.mode=='wysiwyg')m.fire('saveSnapshot');m.getCommand('source').setState(0);m.setMode(m.mode=='source'?'wysiwyg':'source'); -},canUndo:false}}};(function(){j.add('stylescombo',{requires:['richcombo','styles'],init:function(n){var o=n.config,p=n.lang.stylesCombo,q={},r=[],s;function t(u){n.getStylesSet(function(v){if(!r.length){var w,x;for(var y=0,z=v.length;y0)return;if(T.type==1&&m.test(T.getName())&&!T.getCustomData('selected_cell')){h.setMarker(K,T,'selected_cell',true);J.push(T);}};for(var M=0;M1&&V&&U[Y]==V[Y]){Z=U[Y];Z.rowSpan+=1;}else{Z=new h(U[Y]).clone();Z.removeAttribute('rowSpan');!c&&Z.appendBogus();X.append(Z);Z=Z.$;}Y+=Z.colSpan-1;}H?X.insertBefore(S):X.insertAfter(S);};function q(G){if(G instanceof d.selection){var H=n(G),I=H[0],J=I.getAscendant('table'),K=e.buildTableMap(J),L=H[0].getParent(),M=L.$.rowIndex,N=H[H.length-1],O=N.getParent().$.rowIndex+N.$.rowSpan-1,P=[];for(var Q=M;Q<=O;Q++){var R=K[Q],S=new h(J.$.rows[Q]);for(var T=0;T0?X[M-1]:null)||J.$.parentNode);for(Q=P.length;Q>=0;Q--)q(P[Q]);return Y;}else if(G instanceof h){J=G.getAscendant('table');if(J.$.rows.length==1)J.remove(); -else G.remove();}return null;};function r(G,H){var I=G.getParent(),J=I.$.cells,K=0;for(var L=0;LI)I=K;}return I;};function t(G,H){var I=n(G),J=I[0],K=J.getAscendant('table'),L=s(I,1),M=s(I),N=H?L:M,O=e.buildTableMap(K),P=[],Q=[],R=O.length;for(var S=0;S1&&Q.length&&Q[S]==P[S]){U=P[S];U.colSpan+=1;}else{U=new h(P[S]).clone();U.removeAttribute('colSpan');!c&&U.appendBogus();U[H?'insertBefore':'insertAfter'].call(U,new h(P[S]));U=U.$;}S+=U.rowSpan-1;}};function u(G){var H=n(G),I=H[0],J=H[H.length-1],K=I.getAscendant('table'),L=e.buildTableMap(K),M,N,O=[];for(var P=0,Q=L.length;P1){L=H[J-1]+1;break;}}if(!L)L=H[0]>0?H[0]-1:H[H.length-1]+1;var N=I.$.rows;for(J=0,K=N.length;J=0;K--)x(H[K]);if(J)z(J,true);else if(I)I.remove();}else if(G instanceof h){var L=G.getParent();if(L.getChildCount()==1)L.remove();else G.remove();}};function y(G){var H=G.getBogus();H&&H.remove();G.trim();};function z(G,H){var I=new d.range(G.getDocument());if(!I['moveToElementEdit'+(H?'End':'Start')](G)){I.selectNodeContents(G);I.collapse(H?false:true);}I.select(true);};function A(G,H,I){var J=G[H];if(typeof I=='undefined')return J;for(var K=0;J&&K=Q)M.removeAttribute('rowSpan');else M.$.rowSpan=Y;if(Y>=P)M.removeAttribute('colSpan');else M.$.colSpan=Z;var ak=new d.nodeList(N.$.rows),al=ak.count();for(ac=al-1;ac>=0;ac--){var am=ak.getItem(ac);if(!am.$.cells.length){am.remove();al++;continue;}}return M;}else return Y*Z==ab;};function D(G,H){var I=n(G);if(I.length>1)return false;else if(H)return true;var J=I[0],K=J.getParent(),L=K.getAscendant('table'),M=e.buildTableMap(L),N=K.$.rowIndex,O=A(M,N,J),P=J.$.rowSpan,Q,R,S,T;if(P>1){R=Math.ceil(P/2);S=Math.floor(P/2);T=N+R;var U=new h(L.$.rows[T]),V=A(M,T),W;Q=J.clone();for(var X=0;XO){Q.insertBefore(new h(W));break;}else W=null;}if(!W)U.append(Q,true);}else{S=R=1;U=K.clone();U.insertAfter(K);U.append(Q=J.clone());var Y=A(M,N);for(var Z=0;Z1)return false;else if(H)return true;var J=I[0],K=J.getParent(),L=K.getAscendant('table'),M=e.buildTableMap(L),N=K.$.rowIndex,O=A(M,N,J),P=J.$.colSpan,Q,R,S;if(P>1){R=Math.ceil(P/2);S=Math.floor(P/2);}else{S=R=1;var T=B(M,O);for(var U=0;U0?2:0};}},tablecell_insertBefore:{label:H.cell.insertBefore,group:'tablecell',command:'cellInsertBefore',order:5},tablecell_insertAfter:{label:H.cell.insertAfter,group:'tablecell',command:'cellInsertAfter',order:10},tablecell_delete:{label:H.cell.deleteCell,group:'tablecell',command:'cellDelete',order:15},tablecell_merge:{label:H.cell.merge,group:'tablecell',command:'cellMerge',order:16},tablecell_merge_right:{label:H.cell.mergeRight,group:'tablecell',command:'cellMergeRight',order:17},tablecell_merge_down:{label:H.cell.mergeDown,group:'tablecell',command:'cellMergeDown',order:18},tablecell_split_horizontal:{label:H.cell.splitHorizontal,group:'tablecell',command:'cellHorizontalSplit',order:19},tablecell_split_vertical:{label:H.cell.splitVertical,group:'tablecell',command:'cellVerticalSplit',order:20},tablecell_properties:{label:H.cell.title,group:'tablecellproperties',command:'cellProperties',order:21},tablerow:{label:H.row.menu,group:'tablerow',order:1,getItems:function(){return{tablerow_insertBefore:2,tablerow_insertAfter:2,tablerow_delete:2}; -}},tablerow_insertBefore:{label:H.row.insertBefore,group:'tablerow',command:'rowInsertBefore',order:5},tablerow_insertAfter:{label:H.row.insertAfter,group:'tablerow',command:'rowInsertAfter',order:10},tablerow_delete:{label:H.row.deleteRow,group:'tablerow',command:'rowDelete',order:15},tablecolumn:{label:H.column.menu,group:'tablecolumn',order:1,getItems:function(){return{tablecolumn_insertBefore:2,tablecolumn_insertAfter:2,tablecolumn_delete:2};}},tablecolumn_insertBefore:{label:H.column.insertBefore,group:'tablecolumn',command:'columnInsertBefore',order:5},tablecolumn_insertAfter:{label:H.column.insertAfter,group:'tablecolumn',command:'columnInsertAfter',order:10},tablecolumn_delete:{label:H.column.deleteColumn,group:'tablecolumn',command:'columnDelete',order:15}});if(G.contextMenu)G.contextMenu.addListener(function(I,J){if(!I||I.isReadOnly())return null;while(I){if(I.getName() in F)return{tablecell:2,tablerow:2,tablecolumn:2};I=I.getParent();}return null;});},getSelectedCells:n};j.add('tabletools',j.tabletools);})();e.buildTableMap=function(m){var n=m.$.rows,o=-1,p=[];for(var q=0;q
    ',o.auto,'
    ');for(var A=0;A');var B=x[A].split('/'),C=B[0],D=B[1]||C;if(!B[1])C='#'+C.replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3');var E=m.lang.colors[D]||D;w.push('');}if(n.colorButton_enableMore===undefined||n.colorButton_enableMore)w.push(''); +w.push('
    ',o.more,'
    ');return w.join('');};function s(t){return t.getAttribute('contentEditable')=='false'||t.getAttribute('data-nostyle');};}});i.colorButton_colors='000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF';i.colorButton_foreStyle={element:'span',styles:{color:'#(color)'},overrides:[{element:'font',attributes:{color:null}}]};i.colorButton_backStyle={element:'span',styles:{'background-color':'#(color)'}};j.colordialog={init:function(m){m.addCommand('colordialog',new a.dialogCommand('colordialog'));a.dialog.add('colordialog',this.path+'dialogs/colordialog.js');}};j.add('colordialog',j.colordialog);j.add('contextmenu',{requires:['menu'],onLoad:function(){j.contextMenu=e.createClass({base:a.menu,$:function(m){this.base.call(this,m,{panel:{className:m.skinClass+' cke_contextmenu',attributes:{'aria-label':m.lang.contextmenu.options}}});},proto:{addTarget:function(m,n){if(b.opera&&!('oncontextmenu' in document.body)){var o;m.on('mousedown',function(s){s=s.data;if(s.$.button!=2){if(s.getKeystroke()==1114112+1)m.fire('contextmenu',s);return;}if(n&&(b.mac?s.$.metaKey:s.$.ctrlKey))return;var t=s.getTarget();if(!o){var u=t.getDocument();o=u.createElement('input');o.$.type='button';u.getBody().append(o);}o.setAttribute('style','position:absolute;top:'+(s.$.clientY-2)+'px;left:'+(s.$.clientX-2)+'px;width:5px;height:5px;opacity:0.01');});m.on('mouseup',function(s){if(o){o.remove();o=undefined;m.fire('contextmenu',s.data);}});}m.on('contextmenu',function(s){var t=s.data;if(n&&(b.webkit?p:b.mac?t.$.metaKey:t.$.ctrlKey))return;t.preventDefault();var u=t.getTarget().getDocument().getDocumentElement(),v=t.$.clientX,w=t.$.clientY;e.setTimeout(function(){this.open(u,null,v,w);},c?200:0,this);},this);if(b.opera)m.on('keypress',function(s){var t=s.data;if(t.$.keyCode===0)t.preventDefault();});if(b.webkit){var p,q=function(s){p=b.mac?s.data.$.metaKey:s.data.$.ctrlKey;},r=function(){p=0;};m.on('keydown',q);m.on('keyup',r);m.on('contextmenu',r);}},open:function(m,n,o,p){this.editor.focus();m=m||a.document.getDocumentElement();this.show(m,n,o,p);}}});},beforeInit:function(m){m.contextMenu=new j.contextMenu(m);m.addCommand('contextMenu',{exec:function(){m.contextMenu.open(m.document.getBody());}});}});(function(){function m(o){var p=this.att,q=o&&o.hasAttribute(p)&&o.getAttribute(p)||''; +if(q!==undefined)this.setValue(q);};function n(){var o;for(var p=0;p ';j.add('elementspath',{requires:['selection'],init:function(o){var p='cke_path_'+o.name,q,r=function(){if(!q)q=a.document.getById(p);return q;},s='cke_elementspath_'+e.getNextNumber()+'_';o._.elementsPath={idBase:s,filters:[]};o.on('themeSpace',function(x){if(x.data.space=='bottom')x.data.html+=''+o.lang.elementsPath.eleLabel+''+'
    '+n+'
    ';});function t(x){o.focus();var y=o._.elementsPath.list[x];if(y.is('body')){var z=new d.range(o.document);z.selectNodeContents(y);z.select();}else o.getSelection().selectElement(y);};var u=e.addFunction(t),v=e.addFunction(function(x,y){var z=o._.elementsPath.idBase,A;y=new d.event(y);var B=o.lang.dir=='rtl';switch(y.getKeystroke()){case B?39:37:case 9:A=a.document.getById(z+(x+1));if(!A)A=a.document.getById(z+'0');A.focus();return false;case B?37:39:case 2228224+9:A=a.document.getById(z+(x-1));if(!A)A=a.document.getById(z+(o._.elementsPath.list.length-1));A.focus();return false;case 27:o.focus();return false;case 13:case 32:t(x);return false;}return true;});o.on('selectionChange',function(x){var y=b,z=x.data.selection,A=z.getStartElement(),B=[],C=x.editor,D=C._.elementsPath.list=[],E=C._.elementsPath.filters;while(A){var F=0,G;if(A.data('cke-display-name'))G=A.data('cke-display-name');else if(A.data('cke-real-element-type'))G=A.data('cke-real-element-type');else G=A.getName();for(var H=0;H',G,''+L+'',''); +}if(G=='body')break;A=A.getParent();}var M=r();M.setHtml(B.join('')+n);C.fire('elementsPathUpdate',{space:M});});function w(){q&&q.setHtml(n);delete o._.elementsPath.list;};o.on('readOnly',w);o.on('contentDomUnload',w);o.addCommand('elementsPathFocus',m.toolbarFocus);}});})();(function(){j.add('enterkey',{requires:['keystrokes','indent'],init:function(t){t.addCommand('enter',{modes:{wysiwyg:1},editorFocus:false,exec:function(v){r(v);}});t.addCommand('shiftEnter',{modes:{wysiwyg:1},editorFocus:false,exec:function(v){q(v);}});var u=t.keystrokeHandler.keystrokes;u[13]='enter';u[2228224+13]='shiftEnter';}});j.enterkey={enterBlock:function(t,u,v,w){v=v||s(t);if(!v)return;var x=v.document,y=v.checkStartOfBlock(),z=v.checkEndOfBlock(),A=new d.elementPath(v.startContainer),B=A.block;if(y&&z){if(B&&(B.is('li')||B.getParent().is('li'))){t.execCommand('outdent');return;}if(B&&B.getParent().is('blockquote')){B.breakParent(B.getParent());if(!B.getPrevious().getFirst(d.walker.invisible(1)))B.getPrevious().remove();if(!B.getNext().getFirst(d.walker.invisible(1)))B.getNext().remove();v.moveToElementEditStart(B);v.select();return;}}else if(B&&B.is('pre')){if(!z){n(t,u,v,w);return;}}else if(B&&f.$captionBlock[B.getName()]){n(t,u,v,w);return;}var C=u==3?'div':'p',D=v.splitBlock(C);if(!D)return;var E=D.previousBlock,F=D.nextBlock,G=D.wasStartOfBlock,H=D.wasEndOfBlock,I;if(F){I=F.getParent();if(I.is('li')){F.breakParent(I);F.move(F.getNext(),1);}}else if(E&&(I=E.getParent())&&I.is('li')){E.breakParent(I);I=E.getNext();v.moveToElementEditStart(I);E.move(E.getPrevious());}if(!G&&!H){if(F.is('li')&&(I=F.getFirst(d.walker.invisible(true)))&&I.is&&I.is('ul','ol'))(c?x.createText('\xa0'):x.createElement('br')).insertBefore(I);if(F)v.moveToElementEditStart(F);}else{var J,K;if(E){if(E.is('li')||!(p.test(E.getName())||E.is('pre')))J=E.clone();}else if(F)J=F.clone();if(!J){if(I&&I.is('li'))J=I;else{J=x.createElement(C);if(E&&(K=E.getDirection()))J.setAttribute('dir',K);}}else if(w&&!J.is('li'))J.renameNode(C);var L=D.elementPath;if(L)for(var M=0,N=L.elements.length;M0;v--)u[v].deleteContents();return u[0];};})();(function(){var m='nbsp,gt,lt,amp',n='quot,iexcl,cent,pound,curren,yen,brvbar,sect,uml,copy,ordf,laquo,not,shy,reg,macr,deg,plusmn,sup2,sup3,acute,micro,para,middot,cedil,sup1,ordm,raquo,frac14,frac12,frac34,iquest,times,divide,fnof,bull,hellip,prime,Prime,oline,frasl,weierp,image,real,trade,alefsym,larr,uarr,rarr,darr,harr,crarr,lArr,uArr,rArr,dArr,hArr,forall,part,exist,empty,nabla,isin,notin,ni,prod,sum,minus,lowast,radic,prop,infin,ang,and,or,cap,cup,int,there4,sim,cong,asymp,ne,equiv,le,ge,sub,sup,nsub,sube,supe,oplus,otimes,perp,sdot,lceil,rceil,lfloor,rfloor,lang,rang,loz,spades,clubs,hearts,diams,circ,tilde,ensp,emsp,thinsp,zwnj,zwj,lrm,rlm,ndash,mdash,lsquo,rsquo,sbquo,ldquo,rdquo,bdquo,dagger,Dagger,permil,lsaquo,rsaquo,euro',o='Agrave,Aacute,Acirc,Atilde,Auml,Aring,AElig,Ccedil,Egrave,Eacute,Ecirc,Euml,Igrave,Iacute,Icirc,Iuml,ETH,Ntilde,Ograve,Oacute,Ocirc,Otilde,Ouml,Oslash,Ugrave,Uacute,Ucirc,Uuml,Yacute,THORN,szlig,agrave,aacute,acirc,atilde,auml,aring,aelig,ccedil,egrave,eacute,ecirc,euml,igrave,iacute,icirc,iuml,eth,ntilde,ograve,oacute,ocirc,otilde,ouml,oslash,ugrave,uacute,ucirc,uuml,yacute,thorn,yuml,OElig,oelig,Scaron,scaron,Yuml',p='Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,mu,nu,xi,omicron,pi,rho,sigmaf,sigma,tau,upsilon,phi,chi,psi,omega,thetasym,upsih,piv'; +function q(r,s){var t={},u=[],v={nbsp:'\xa0',shy:'­',gt:'>',lt:'<',amp:'&'};r=r.replace(/\b(nbsp|shy|gt|lt|amp)(?:,|$)/g,function(A,B){var C=s?'&'+B+';':v[B],D=s?v[B]:'&'+B+';';t[C]=D;u.push(C);return '';});if(!s&&r){r=r.split(',');var w=document.createElement('div'),x;w.innerHTML='&'+r.join(';&')+';';x=w.innerHTML;w=null;for(var y=0;y0;case 'checked':return!!q.$.checked;case 'value':var p=q.getAttribute('type');return p=='checkbox'||p=='radio'?q.$.value!='on':q.$.value;}return m.apply(q,arguments);};});(function(){var m={canUndo:false,exec:function(o){var p=o.document.createElement('hr'),q=new d.range(o.document);o.insertElement(p);q.moveToPosition(p,4);var r=p.getNext();if(!r||r.type==1&&!r.isEditable())q.fixBlock(true,o.config.enterMode==3?'div':'p');q.select();}},n='horizontalrule';j.add(n,{init:function(o){o.addCommand(n,m);o.ui.addButton('HorizontalRule',{label:o.lang.horizontalrule,command:n});}});})();(function(){var m=/^[\t\r\n ]*(?: |\xa0)$/,n='{cke_protected}';function o(T){var U=T.children.length,V=T.children[U-1];while(V&&V.type==3&&!e.trim(V.value))V=T.children[--U];return V;};function p(T,U){var V=T.children,W=o(T);if(W){if((U||!c)&&W.type==1&&W.name=='br')V.pop();if(W.type==3&&m.test(W.value))V.pop();}};function q(T,U,V){if(!U&&(!V||typeof V=='function'&&V(T)===false))return false;if(U&&c&&(document.documentMode>7||T.name in f.tr||T.name in f.$listItem))return false;var W=o(T);return!W||W&&(W.type==1&&W.name=='br'||T.name=='form'&&W.name=='input');};function r(T,U){return function(V){p(V,!T);if(q(V,!T,U))if(T||c)V.add(new a.htmlParser.text('\xa0'));else V.add(new a.htmlParser.element('br',{}));};};var s=f,t=['caption','colgroup','col','thead','tfoot','tbody'],u=e.extend({},s.$block,s.$listItem,s.$tableContent);for(var v in u){if(!('br' in s[v]))delete u[v];}delete u.pre;var w={elements:{},attributeNames:[[/^on/,'data-cke-pa-on']]},x={elements:{}};for(v in u)x.elements[v]=r();var y={elementNames:[[/^cke:/,''],[/^\?xml:namespace$/,'']],attributeNames:[[/^data-cke-(saved|pa)-/,''],[/^data-cke-.*/,''],['hidefocus','']],elements:{$:function(T){var U=T.attributes; +if(U){if(U['data-cke-temp'])return false;var V=['name','href','src'],W;for(var X=0;Xe.indexOf(t,W.name)?1:-1:0;});},embed:function(T){var U=T.parent;if(U&&U.name=='object'){var V=U.attributes.width,W=U.attributes.height;V&&(T.attributes.width=V);W&&(T.attributes.height=W);}},param:function(T){T.children=[];T.isEmpty=true;return T;},a:function(T){if(!(T.children.length||T.attributes.name||T.attributes['data-cke-saved-name']))return false;},span:function(T){if(T.attributes['class']=='Apple-style-span')delete T.name;},pre:function(T){c&&p(T);},html:function(T){delete T.attributes.contenteditable;delete T.attributes['class'];},body:function(T){delete T.attributes.spellcheck;delete T.attributes.contenteditable;},style:function(T){var U=T.children[0];U&&U.value&&(U.value=e.trim(U.value));if(!T.attributes.type)T.attributes.type='text/css';},title:function(T){var U=T.children[0];U&&(U.value=T.attributes['data-cke-title']||'');}},attributes:{'class':function(T,U){return e.ltrim(T.replace(/(?:^|\s+)cke_[^\s]*/g,''))||false;}}};if(c)y.attributes.style=function(T,U){return T.replace(/(^|;)([^\:]+)/g,function(V){return V.toLowerCase();});};function z(T){var U=T.attributes;if(U.contenteditable!='false')U['data-cke-editable']=U.contenteditable?'true':1;U.contenteditable='false';};function A(T){var U=T.attributes;switch(U['data-cke-editable']){case 'true':U.contenteditable='true';break;case '1':delete U.contenteditable;break;}};for(v in {input:1,textarea:1}){w.elements[v]=z;y.elements[v]=A;}var B=/<(a|area|img|input)\b([^>]*)>/gi,C=/\b(on\w+|href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,D=/(?:])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,E=/([^<]*)<\/cke:encoded>/gi,F=/(<\/?)((?:object|embed|param|html|body|head|title)[^>]*>)/gi,G=/(<\/?)cke:((?:html|body|head|title)[^>]*>)/gi,H=/]*?)\/?>(?!\s*<\/cke:\1)/gi;function I(T){return T.replace(B,function(U,V,W){return '<'+V+W.replace(C,function(X,Y){if(!/^on/.test(Y)&&W.indexOf('data-cke-saved-'+Y)==-1)return ' data-cke-saved-'+X+' '+X;return X;})+'>';});};function J(T){return T.replace(D,function(U){return ''+encodeURIComponent(U)+'';});};function K(T){return T.replace(E,function(U,V){return decodeURIComponent(V);});};function L(T){return T.replace(F,'$1cke:$2'); +};function M(T){return T.replace(G,'$1$2');};function N(T){return T.replace(H,'');};function O(T){return T.replace(/(]*>)(\r\n|\n)/g,'$1$2$2');};function P(T){return T.replace(//g,function(U){return '';});};function Q(T){return T.replace(//g,function(U,V){return decodeURIComponent(V);});};function R(T,U){var V=U._.dataStore;return T.replace(//g,function(W,X){return decodeURIComponent(X);}).replace(/\{cke_protected_(\d+)\}/g,function(W,X){return V&&V[X]||'';});};function S(T,U){var V=[],W=U.config.protectedSource,X=U._.dataStore||(U._.dataStore={id:1}),Y=/<\!--\{cke_temp(comment)?\}(\d*?)-->/g,Z=[//gi,//gi].concat(W);T=T.replace(//g,function(ab){return '';});for(var aa=0;aa';});T=T.replace(Y,function(ab,ac,ad){return '';});return T.replace(/(['"]).*?\1/g,function(ab){return ab.replace(//g,function(ac,ad){X[X.id]=decodeURIComponent(ad);return '{cke_protected_'+X.id++ +'}';});});};j.add('htmldataprocessor',{requires:['htmlwriter'],init:function(T){var U=T.dataProcessor=new a.htmlDataProcessor(T);U.writer.forceSimpleAmpersand=T.config.forceSimpleAmpersand;U.dataFilter.addRules(w);U.dataFilter.addRules(x);U.htmlFilter.addRules(y);var V={elements:{}};for(v in u)V.elements[v]=r(true,T.config.fillEmptyBlocks);U.htmlFilter.addRules(V);},onLoad:function(){!('fillEmptyBlocks' in i)&&(i.fillEmptyBlocks=1);}});a.htmlDataProcessor=function(T){var U=this;U.editor=T;U.writer=new a.htmlWriter();U.dataFilter=new a.htmlParser.filter();U.htmlFilter=new a.htmlParser.filter();};a.htmlDataProcessor.prototype={toHtml:function(T,U){T=S(T,this.editor);T=I(T);T=J(T);T=L(T);T=N(T);T=O(T);var V=new h('div');V.setHtml('a'+T);T=V.getHtml().substr(1);T=M(T);T=K(T);T=Q(T);var W=a.htmlParser.fragment.fromHtml(T,U),X=new a.htmlParser.basicWriter();W.writeHtml(X,this.dataFilter);T=X.getHtml(true);T=P(T);return T;},toDataFormat:function(T,U){var V=this.writer,W=a.htmlParser.fragment.fromHtml(T,U);V.reset();W.writeHtml(V,this.htmlFilter); +var X=V.getHtml(true);X=Q(X);X=R(X,this.editor);return X;}};})();(function(){j.add('iframe',{requires:['dialog','fakeobjects'],init:function(m){var n='iframe',o=m.lang.iframe;a.dialog.add(n,this.path+'dialogs/iframe.js');m.addCommand(n,new a.dialogCommand(n));m.addCss('img.cke_iframe{background-image: url('+a.getUrl(this.path+'images/placeholder.png')+');'+'background-position: center center;'+'background-repeat: no-repeat;'+'border: 1px solid #a9a9a9;'+'width: 80px;'+'height: 80px;'+'}');m.ui.addButton('Iframe',{label:o.toolbar,command:n});m.on('doubleclick',function(p){var q=p.data.element;if(q.is('img')&&q.data('cke-real-element-type')=='iframe')p.data.dialog='iframe';});if(m.addMenuItems)m.addMenuItems({iframe:{label:o.title,command:'iframe',group:'image'}});if(m.contextMenu)m.contextMenu.addListener(function(p,q){if(p&&p.is('img')&&p.data('cke-real-element-type')=='iframe')return{iframe:2};});},afterInit:function(m){var n=m.dataProcessor,o=n&&n.dataFilter;if(o)o.addRules({elements:{iframe:function(p){return m.createFakeParserElement(p,'cke_iframe','iframe',true);}}});}});})();j.add('image',{init:function(m){var n='image';a.dialog.add(n,this.path+'dialogs/image.js');m.addCommand(n,new a.dialogCommand(n));m.ui.addButton('Image',{label:m.lang.common.image,command:n});m.on('doubleclick',function(o){var p=o.data.element;if(p.is('img')&&!p.data('cke-realelement')&&!p.isReadOnly())o.data.dialog='image';});if(m.addMenuItems)m.addMenuItems({image:{label:m.lang.image.menu,command:'image',group:'image'}});if(m.contextMenu)m.contextMenu.addListener(function(o,p){if(!o||!o.is('img')||o.data('cke-realelement')||o.isReadOnly())return null;return{image:2};});}});i.image_removeLinkByEmptyURL=true;(function(){var m={ol:1,ul:1},n=d.walker.whitespaces(true),o=d.walker.bookmark(false,true);function p(t){var B=this;if(t.editor.readOnly)return null;var u=t.editor,v=t.data.path,w=v&&v.contains(m),x=v.block||v.blockLimit;if(w)return B.setState(2);if(!B.useIndentClasses&&B.name=='indent')return B.setState(2);if(!x)return B.setState(0);if(B.useIndentClasses){var y=x.$.className.match(B.classNameRegex),z=0;if(y){y=y[1];z=B.indentClassMap[y];}if(B.name=='outdent'&&!z||B.name=='indent'&&z==u.config.indentClasses.length)return B.setState(0);return B.setState(2);}else{var A=parseInt(x.getStyle(r(x)),10);if(isNaN(A))A=0;if(A<=0)return B.setState(0);return B.setState(2);}};function q(t,u){var w=this;w.name=u;w.useIndentClasses=t.config.indentClasses&&t.config.indentClasses.length>0;if(w.useIndentClasses){w.classNameRegex=new RegExp('(?:^|\\s+)('+t.config.indentClasses.join('|')+')(?=$|\\s)'); +w.indentClassMap={};for(var v=0;vY;T++)X[T].indent+=U;var aa=j.list.arrayToList(X,v,null,t.config.enterMode,M.getDirection());if(u.name=='outdent'){var ab;if((ab=M.getParent())&&ab.is('li')){var ac=aa.listNode.getChildren(),ad=[],ae=ac.count(),af;for(T=ae-1;T>=0;T--){if((af=ac.getItem(T))&&af.is&&af.is('li'))ad.push(af);}}}if(aa)aa.listNode.replace(M);if(ad&&ad.length)for(T=0;T0)M.addClass(t.config.indentClasses[P-1]);}else{var Q=r(M,N),R=parseInt(M.getStyle(Q),10);if(isNaN(R))R=0;var S=t.config.indentOffset||40;R+=(u.name=='indent'?1:-1)*S;if(R<0)return false;R=Math.max(R,0);R=Math.ceil(R/S)*S;M.setStyle(Q,R?R+(t.config.indentUnit||'px'):'');if(M.getAttribute('style')==='')M.removeAttribute('style');}h.setMarker(v,M,'indent_processed',1); +return true;};var z=t.getSelection(),A=z.createBookmarks(1),B=z&&z.getRanges(1),C,D=B.createIterator();while(C=D.getNextRange()){var E=C.getCommonAncestor(),F=E;while(F&&!(F.type==1&&m[F.getName()]))F=F.getParent();if(!F){var G=C.getEnclosedNode();if(G&&G.type==1&&G.getName() in m){C.setStartAt(G,1);C.setEndAt(G,2);F=G;}}if(F&&C.startContainer.type==1&&C.startContainer.getName() in m){var H=new d.walker(C);H.evaluator=s;C.startContainer=H.next();}if(F&&C.endContainer.type==1&&C.endContainer.getName() in m){H=new d.walker(C);H.evaluator=s;C.endContainer=H.previous();}if(F){var I=F.getFirst(s),J=!!I.getNext(s),K=C.startContainer,L=I.equals(K)||I.contains(K);if(!(L&&(u.name=='indent'||u.useIndentClasses||parseInt(F.getStyle(r(F)),10))&&y(F,!J&&I.getDirection())))w(F);}else x();}h.clearAllMarkers(v);t.forceNextSelectionCheck();z.selectBookmarks(A);}};j.add('indent',{init:function(t){var u=t.addCommand('indent',new q(t,'indent')),v=t.addCommand('outdent',new q(t,'outdent'));t.ui.addButton('Indent',{label:t.lang.indent,command:'indent'});t.ui.addButton('Outdent',{label:t.lang.outdent,command:'outdent'});t.on('selectionChange',e.bind(p,u));t.on('selectionChange',e.bind(p,v));if(b.ie6Compat||b.ie7Compat)t.addCss('ul,ol{\tmargin-left: 0px;\tpadding-left: 40px;}');t.on('dirChanged',function(w){var x=new d.range(t.document);x.setStartBefore(w.data.node);x.setEndAfter(w.data.node);var y=new d.walker(x),z;while(z=y.next()){if(z.type==1){if(!z.equals(w.data.node)&&z.getDirection()){x.setStartAfter(z);y=new d.walker(x);continue;}var A=t.config.indentClasses;if(A){var B=w.data.dir=='ltr'?['_rtl','']:['','_rtl'];for(var C=0;C=0;A--){x=v[A].createIterator();x.enlargeBr=t!=2;while(y=x.getNextParagraph(t==1?'p':'div')){y.removeAttribute('align');y.removeStyle('text-align');var B=w&&(y.$.className=e.ltrim(y.$.className.replace(D.cssClassRegex,''))),C=D.state==2&&(!z||n(y,true)!=D.value);if(w){if(C)y.addClass(w);else if(!B)y.removeAttribute('class');}else if(C)y.setStyle('text-align',D.value);}}r.focus();r.forceNextSelectionCheck();s.selectBookmarks(u);}};j.add('justify',{init:function(r){var s=new p(r,'justifyleft','left'),t=new p(r,'justifycenter','center'),u=new p(r,'justifyright','right'),v=new p(r,'justifyblock','justify');r.addCommand('justifyleft',s);r.addCommand('justifycenter',t);r.addCommand('justifyright',u);r.addCommand('justifyblock',v);r.ui.addButton('JustifyLeft',{label:r.lang.justify.left,command:'justifyleft'});r.ui.addButton('JustifyCenter',{label:r.lang.justify.center,command:'justifycenter'});r.ui.addButton('JustifyRight',{label:r.lang.justify.right,command:'justifyright'});r.ui.addButton('JustifyBlock',{label:r.lang.justify.block,command:'justifyblock'});r.on('selectionChange',e.bind(o,s));r.on('selectionChange',e.bind(o,u));r.on('selectionChange',e.bind(o,t));r.on('selectionChange',e.bind(o,v));r.on('dirChanged',q);},requires:['domiterator']});})();j.add('keystrokes',{beforeInit:function(m){m.keystrokeHandler=new a.keystrokeHandler(m); +m.specialKeys={};},init:function(m){var n=m.config.keystrokes,o=m.config.blockedKeystrokes,p=m.keystrokeHandler.keystrokes,q=m.keystrokeHandler.blockedKeystrokes;for(var r=0;r7))Q.append(L.createText('\xa0'));Q.append(W.listNode);O=W.nextIndex;}else if(T.indent==-1&&!I&&T.grandparent){if(m[T.grandparent.getName()])Q=T.element.clone(false,true); +else if(K||T.element.hasAttributes()||J!=2){Q=L.createElement(S);T.element.copyAttributes(Q,{type:1,value:1});if(!K&&J==2&&!Q.hasAttributes())Q=new d.documentFragment(L);}else Q=new d.documentFragment(L);if(Q.type==1)if(T.grandparent.getDirection(1)!=R)Q.setAttribute('dir',R);for(U=0;UJ[L-1].indent+1){var P=J[L-1].indent+1-J[L].indent,Q=J[L].indent;while(J[L]&&J[L].indent>=Q){J[L].indent+=P;L++;}L--;}}var R=j.list.arrayToList(J,I,null,G.config.enterMode,H.root.getAttribute('dir')),S=R.listNode,T,U;function V(W){if((T=S[W?'getFirst':'getLast']())&&!(T.is&&T.isBlockBoundary())&&(U=H.root[W?'getPrevious':'getNext'](d.walker.whitespaces(true)))&&!(U.is&&U.isBlockBoundary({br:1})))G.document.createElement('br')[W?'insertBefore':'insertAfter'](T);};V(true);V();S.replace(H.root);};function x(G,H){this.name=G;this.type=H;};function y(G){var H=G.getDirection();if(H){for(var I=0,J=G.getChildren(),K;K=J.getItem(I),I=0&&(ae=Z[af]); +af--){if(m[ae.getName()]&&ad.contains(ae)){ad.removeCustomData('list_group_object_'+S);var ag=ae.getCustomData('list_group_object');if(ag)ag.contents.push(X);else{ag={root:ae,contents:[X]};P.push(ag);h.setMarker(Q,ae,'list_group_object',ag);}ac=1;break;}}if(ac)continue;var ah=ad;if(ah.getCustomData('list_group_object_'+S))ah.getCustomData('list_group_object_'+S).contents.push(X);else{ag={root:ah,contents:[X]};h.setMarker(Q,ah,'list_group_object_'+S,ag);P.push(ag);}}}var ai=[];while(P.length>0){ag=P.shift();if(this.state==2){if(m[ag.root.getName()])t.call(this,G,ag,Q,ai);else v.call(this,G,ag,ai);}else if(this.state==1&&m[ag.root.getName()])w.call(this,G,ag,Q);}for(af=0;af0)for(var u=t.length-1;u>=0;u--){var v=t[u][0],w=t[u][1];if(w)v.insertBefore(w);else v.appendTo(s);}};function o(s,t){var u=m(s),v={},w=s.$;if(!t){v['class']=w.className||'';w.className='';}v.inline=w.style.cssText||'';if(!t)w.style.cssText='position: static; overflow: visible';n(u);return v;};function p(s,t){var u=m(s),v=s.$;if('class' in t)v.className=t['class'];if('inline' in t)v.style.cssText=t.inline;n(u);};function q(s){var t=a.instances;for(var u in t){var v=t[u];if(v.mode=='wysiwyg'&&!v.readOnly){var w=v.document.getBody();w.setAttribute('contentEditable',false);w.setAttribute('contentEditable',true);}}if(s.focusManager.hasFocus){s.toolbox.focus();s.focus();}};function r(s){if(!c||b.version>6)return null;var t=h.createFromHtml('');return s.append(t,true);};j.add('maximize',{init:function(s){var t=s.lang,u=a.document,v=u.getWindow(),w,x,y,z;function A(){var C=v.getViewPaneSize();z&&z.setStyles({width:C.width+'px',height:C.height+'px'});s.resize(C.width,C.height,null,true);};var B=2;s.addCommand('maximize',{modes:{wysiwyg:!b.iOS,source:!b.iOS},readOnly:1,editorFocus:false,exec:function(){var C=s.container.getChild(1),D=s.getThemeSpace('contents');if(s.mode=='wysiwyg'){var E=s.getSelection();w=E&&E.getRanges();x=v.getScrollPosition();}else{var F=s.textarea.$;w=!c&&[F.selectionStart,F.selectionEnd];x=[F.scrollLeft,F.scrollTop];}if(this.state==2){v.on('resize',A); +y=v.getScrollPosition();var G=s.container;while(G=G.getParent()){G.setCustomData('maximize_saved_styles',o(G));G.setStyle('z-index',s.config.baseFloatZIndex-1);}D.setCustomData('maximize_saved_styles',o(D,true));C.setCustomData('maximize_saved_styles',o(C,true));var H={overflow:b.webkit?'':'hidden',width:0,height:0};u.getDocumentElement().setStyles(H);!b.gecko&&u.getDocumentElement().setStyle('position','fixed');!(b.gecko&&b.quirks)&&u.getBody().setStyles(H);c?setTimeout(function(){v.$.scrollTo(0,0);},0):v.$.scrollTo(0,0);C.setStyle('position',b.gecko&&b.quirks?'fixed':'absolute');C.$.offsetLeft;C.setStyles({'z-index':s.config.baseFloatZIndex-1,left:'0px',top:'0px'});z=r(C);C.addClass('cke_maximized');A();var I=C.getDocumentPosition();C.setStyles({left:-1*I.x+'px',top:-1*I.y+'px'});b.gecko&&q(s);}else if(this.state==1){v.removeListener('resize',A);var J=[D,C];for(var K=0;K ');s.children.length=0;s.add(u);var v=s.attributes;delete v['aria-label'];delete v.contenteditable;delete v.title;}return t;}}},5);if(p)p.addRules({elements:{div:function(r){var s=r.attributes,t=s&&s.style,u=t&&r.children.length==1&&r.children[0],v=u&&u.name=='span'&&u.attributes.style;if(v&&/page-break-after\s*:\s*always/i.test(t)&&/display\s*:\s*none/i.test(v)){s.contenteditable='false';s['class']='cke_pagebreak';s['data-cke-display-name']='pagebreak';s['aria-label']=n;s.title=n;r.children.length=0;}}}});},requires:['fakeobjects']});j.pagebreakCmd={exec:function(m){var n=m.lang.pagebreakAlt,o=h.createFromHtml('
    '+'
    ',m.document),p=m.getSelection().getRanges(true);m.fire('saveSnapshot');for(var q,r=p.length-1;r>=0;r--){q=p[r];if(r1&&n.substr(n.length-1,1)=='%')n=parseInt(window.screen.width*parseInt(n,10)/100,10);if(typeof o=='string'&&o.length>1&&o.substr(o.length-1,1)=='%')o=parseInt(window.screen.height*parseInt(o,10)/100,10);if(n<640)n=640;if(o<420)o=420;var q=parseInt((window.screen.height-o)/2,10),r=parseInt((window.screen.width-n)/2,10);p=(p||'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes')+',width='+n+',height='+o+',top='+q+',left='+r;var s=window.open('',null,p,true);if(!s)return false;try{s.moveTo(r,q);s.resizeTo(n,o);s.focus();s.location.href=m;}catch(t){s=window.open(m,null,p,true);}return true;}});(function(){var m={modes:{wysiwyg:1,source:1},canUndo:false,readOnly:1,exec:function(o){var p,q=o.config,r=q.baseHref?'':'',s=b.isCustomDomain();if(q.fullPage)p=o.getData().replace(//,'$&'+r).replace(/[^>]*(?=<\/title>)/,'$& — '+o.lang.preview); +else{var t=''+''+r+''+o.lang.preview+''+e.buildStyleHtml(o.config.contentsCss)+''+t+o.getData()+'';}var v=640,w=420,x=80;try{var y=window.screen;v=Math.round(y.width*0.8);w=Math.round(y.height*0.7);x=Math.round(y.width*0.1);}catch(C){}var z='';if(s){window._cke_htmlToLoad=p;z='javascript:void( (function(){document.open();document.domain="'+document.domain+'";'+'document.write( window.opener._cke_htmlToLoad );'+'document.close();'+'window.opener._cke_htmlToLoad = null;'+'})() )';}var A=window.open(z,null,'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+v+',height='+w+',left='+x);if(!s){var B=A.document;B.open();B.write(p);B.close();b.webkit&&setTimeout(function(){B.body.innerHTML+='';},0);}}},n='preview';j.add(n,{init:function(o){o.addCommand(n,m);o.ui.addButton('Preview',{label:o.lang.preview,command:n});}});})();j.add('print',{init:function(m){var n='print',o=m.addCommand(n,j.print);m.ui.addButton('Print',{label:m.lang.print,command:n});}});j.print={exec:function(m){if(b.opera)return;else if(b.gecko)m.window.$.print();else m.document.$.execCommand('Print');},canUndo:false,readOnly:1,modes:{wysiwyg:!b.opera}};j.add('removeformat',{requires:['selection'],init:function(m){m.addCommand('removeFormat',j.removeformat.commands.removeformat);m.ui.addButton('RemoveFormat',{label:m.lang.removeFormat,command:'removeFormat'});m._.removeFormat={filters:[]};}});j.removeformat={commands:{removeformat:{exec:function(m){var n=m._.removeFormatRegex||(m._.removeFormatRegex=new RegExp('^(?:'+m.config.removeFormatTags.replace(/,/g,'|')+')$','i')),o=m._.removeAttributes||(m._.removeAttributes=m.config.removeFormatAttributes.split(',')),p=j.removeformat.filter,q=m.getSelection().getRanges(1),r=q.createIterator(),s;while(s=r.getNextRange()){if(!s.collapsed)s.enlarge(1);var t=s.createBookmark(),u=t.startNode,v=t.endNode,w,x=function(z){var A=new d.elementPath(z),B=A.elements;for(var C=1,D;D=B[C];C++){if(D.equals(A.block)||D.equals(A.blockLimit))break;if(n.test(D.getName())&&p(m,D))z.breakParent(D);}};x(u);if(v){x(v);w=u.getNextSourceNode(true,1);while(w){if(w.equals(v))break;var y=w.getNextSourceNode(false,1);if(!(w.getName()=='img'&&w.data('cke-realelement'))&&p(m,w))if(n.test(w.getName()))w.remove(1); +else{w.removeAttributes(o);m.fire('removeFormatCleanup',w);}w=y;}}s.moveToBookmark(t);}m.getSelection().selectRanges(q);}}},filter:function(m,n){var o=m._.removeFormat.filters;for(var p=0;pr.width&&(n.resize_minWidth=r.width);n.resize_minHeight>r.height&&(n.resize_minHeight=r.height);a.document.on('mousemove',u);a.document.on('mouseup',v);if(m.document){m.document.on('mousemove',u);m.document.on('mouseup',v);}});m.on('destroy',function(){e.removeFunction(w);});m.on('themeSpace',function(x){if(x.data.space=='bottom'){var y='';if(s&&!t)y=' cke_resizer_horizontal';if(!s&&t)y=' cke_resizer_vertical';var z='
    ';o=='ltr'&&y=='ltr'?x.data.html+=z:x.data.html=z+x.data.html;}},m,null,100);}}});(function(){var m={modes:{wysiwyg:1,source:1},readOnly:1,exec:function(o){var p=o.element.$.form;if(p)try{p.submit();}catch(q){if(p.submit.click)p.submit.click(); +}}},n='save';j.add(n,{init:function(o){var p=o.addCommand(n,m);p.modes={wysiwyg:!!o.element.$.form};o.ui.addButton('Save',{label:o.lang.save,command:n});}});})();(function(){var m='scaytcheck',n='';function o(t,u){var v=0,w;for(w in u){if(u[w]==t){v=1;break;}}return v;};var p=function(){var t=this,u=function(){var y=t.config,z={};z.srcNodeRef=t.document.getWindow().$.frameElement;z.assocApp='CKEDITOR.'+a.version+'@'+a.revision;z.customerid=y.scayt_customerid||'1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2';z.customDictionaryIds=y.scayt_customDictionaryIds||'';z.userDictionaryName=y.scayt_userDictionaryName||'';z.sLang=y.scayt_sLang||'en_US';z.onLoad=function(){if(!(c&&b.version<8))this.addStyle(this.selectorCss(),'padding-bottom: 2px !important;');if(t.focusManager.hasFocus&&!q.isControlRestored(t))this.focus();};z.onBeforeChange=function(){if(q.getScayt(t)&&!t.checkDirty())setTimeout(function(){t.resetDirty();},0);};var A=window.scayt_custom_params;if(typeof A=='object')for(var B in A)z[B]=A[B];if(q.getControlId(t))z.id=q.getControlId(t);var C=new window.scayt(z);C.afterMarkupRemove.push(function(E){new h(E,C.document).mergeSiblings();});var D=q.instances[t.name];if(D){C.sLang=D.sLang;C.option(D.option());C.paused=D.paused;}q.instances[t.name]=C;try{C.setDisabled(q.isPaused(t)===false);}catch(E){}t.fire('showScaytState');};t.on('contentDom',u);t.on('contentDomUnload',function(){var y=a.document.getElementsByTag('script'),z=/^dojoIoScript(\d+)$/i,A=/^https?:\/\/svc\.webspellchecker\.net\/spellcheck\/script\/ssrv\.cgi/i;for(var B=0;B=0){this.setState(0);q.loadEngine(t);}}};j.add('scayt',{requires:['menubutton'],beforeInit:function(t){var u=t.config.scayt_contextMenuItemsOrder||'suggest|moresuggest|control',v='';u=u.split('|');if(u&&u.length)for(var w=0;w tr > td, .%1 table.%2 > tr > th,','.%1 table.%2 > tbody > tr > td, .%1 table.%2 > tbody > tr > th,','.%1 table.%2 > thead > tr > td, .%1 table.%2 > thead > tr > th,','.%1 table.%2 > tfoot > tr > td, .%1 table.%2 > tfoot > tr > th','{','border : #d3d3d3 1px dotted','}']).join('');n=o.replace(/%2/g,m).replace(/%1/g,'cke_show_borders ');var p={preserveState:true,editorFocus:false,readOnly:1,exec:function(q){this.toggleState();this.refresh(q); +},refresh:function(q){if(q.document){var r=this.state==1?'addClass':'removeClass';q.document.getBody()[r]('cke_show_borders');}}};j.add('showborders',{requires:['wysiwygarea'],modes:{wysiwyg:1},init:function(q){var r=q.addCommand('showborders',p);r.canUndo=false;if(q.config.startupShowBorders!==false)r.setState(1);q.addCss(n);q.on('mode',function(){if(r.state!=0)r.refresh(q);},null,null,100);q.on('contentDom',function(){if(r.state!=0)r.refresh(q);});q.on('removeFormatCleanup',function(s){var t=s.data;if(q.getCommand('showborders').state==1&&t.is('table')&&(!t.hasAttribute('border')||parseInt(t.getAttribute('border'),10)<=0))t.addClass(m);});},afterInit:function(q){var r=q.dataProcessor,s=r&&r.dataFilter,t=r&&r.htmlFilter;if(s)s.addRules({elements:{table:function(u){var v=u.attributes,w=v['class'],x=parseInt(v.border,10);if((!x||x<=0)&&(!w||w.indexOf(m)==-1))v['class']=(w||'')+' '+m;}}});if(t)t.addRules({elements:{table:function(u){var v=u.attributes,w=v['class'];w&&(v['class']=w.replace(m,'').replace(/\s{2}/,' ').replace(/^\s+|\s+$/,''));}}});}});a.on('dialogDefinition',function(q){var r=q.data.name;if(r=='table'||r=='tableProperties'){var s=q.data.definition,t=s.getContents('info'),u=t.get('txtBorder'),v=u.commit;u.commit=e.override(v,function(y){return function(z,A){y.apply(this,arguments);var B=parseInt(this.getValue(),10);A[!B||B<=0?'addClass':'removeClass'](m);};});var w=s.getContents('advanced'),x=w&&w.get('advCSSClasses');if(x){x.setup=e.override(x.setup,function(y){return function(){y.apply(this,arguments);this.setValue(this.getValue().replace(/cke_show_border/,''));};});x.commit=e.override(x.commit,function(y){return function(z,A){y.apply(this,arguments);if(!parseInt(A.getAttribute('border'),10))A.addClass('cke_show_border');};});}}});})();j.add('sourcearea',{requires:['editingblock'],init:function(m){var n=j.sourcearea,o=a.document.getWindow();m.on('editingBlockReady',function(){var p,q;m.addMode('source',{load:function(r,s){if(c&&b.version<8)r.setStyle('position','relative');m.textarea=p=new h('textarea');p.setAttributes({dir:'ltr',tabIndex:b.webkit?-1:m.tabIndex,role:'textbox','aria-label':m.lang.editorTitle.replace('%1',m.name)});p.addClass('cke_source');p.addClass('cke_enable_context_menu');m.readOnly&&p.setAttribute('readOnly','readonly');var t={width:b.ie7Compat?'99%':'100%',height:'100%',resize:'none',outline:'none','text-align':'left'};if(c){q=function(){p.hide();p.setStyle('height',r.$.clientHeight+'px');p.setStyle('width',r.$.clientWidth+'px'); +p.show();};m.on('resize',q);o.on('resize',q);setTimeout(q,0);}r.setHtml('');r.append(p);p.setStyles(t);m.fire('ariaWidget',p);p.on('blur',function(){m.focusManager.blur();});p.on('focus',function(){m.focusManager.focus();});m.mayBeDirty=true;this.loadData(s);var u=m.keystrokeHandler;if(u)u.attach(p);setTimeout(function(){m.mode='source';m.fire('mode',{previousMode:m._.previousMode});},b.gecko||b.webkit?100:0);},loadData:function(r){p.setValue(r);m.fire('dataReady');},getData:function(){return p.getValue();},getSnapshotData:function(){return p.getValue();},unload:function(r){p.clearCustomData();m.textarea=p=null;if(q){m.removeListener('resize',q);o.removeListener('resize',q);}if(c&&b.version<8)r.removeStyle('position');},focus:function(){p.focus();}});});m.on('readOnly',function(){if(m.mode=='source')if(m.readOnly)m.textarea.setAttribute('readOnly','readonly');else m.textarea.removeAttribute('readOnly');});m.addCommand('source',n.commands.source);if(m.ui.addButton)m.ui.addButton('Source',{label:m.lang.source,command:'source'});m.on('mode',function(){m.getCommand('source').setState(m.mode=='source'?1:2);});}});j.sourcearea={commands:{source:{modes:{wysiwyg:1,source:1},editorFocus:false,readOnly:1,exec:function(m){if(m.mode=='wysiwyg')m.fire('saveSnapshot');m.getCommand('source').setState(0);m.setMode(m.mode=='source'?'wysiwyg':'source');},canUndo:false}}};(function(){j.add('stylescombo',{requires:['richcombo','styles'],init:function(n){var o=n.config,p=n.lang.stylesCombo,q={},r=[],s;function t(u){n.getStylesSet(function(v){if(!r.length){var w,x;for(var y=0,z=v.length;y0)return;if(T.type==1&&m.test(T.getName())&&!T.getCustomData('selected_cell')){h.setMarker(K,T,'selected_cell',true);J.push(T);}};for(var M=0;M1&&V&&U[Y]==V[Y]){Z=U[Y];Z.rowSpan+=1;}else{Z=new h(U[Y]).clone();Z.removeAttribute('rowSpan');!c&&Z.appendBogus();X.append(Z);Z=Z.$;}Y+=Z.colSpan-1;}H?X.insertBefore(S):X.insertAfter(S);};function q(G){if(G instanceof d.selection){var H=n(G),I=H[0],J=I.getAscendant('table'),K=e.buildTableMap(J),L=H[0].getParent(),M=L.$.rowIndex,N=H[H.length-1],O=N.getParent().$.rowIndex+N.$.rowSpan-1,P=[];for(var Q=M;Q<=O;Q++){var R=K[Q],S=new h(J.$.rows[Q]);for(var T=0;T0?X[M-1]:null)||J.$.parentNode);for(Q=P.length;Q>=0;Q--)q(P[Q]);return Y;}else if(G instanceof h){J=G.getAscendant('table');if(J.$.rows.length==1)J.remove();else G.remove();}return null;};function r(G,H){var I=G.getParent(),J=I.$.cells,K=0;for(var L=0;LI)I=K;}return I;};function t(G,H){var I=n(G),J=I[0],K=J.getAscendant('table'),L=s(I,1),M=s(I),N=H?L:M,O=e.buildTableMap(K),P=[],Q=[],R=O.length;for(var S=0;S1&&Q.length&&Q[S]==P[S]){U=P[S];U.colSpan+=1;}else{U=new h(P[S]).clone();U.removeAttribute('colSpan');!c&&U.appendBogus();U[H?'insertBefore':'insertAfter'].call(U,new h(P[S]));U=U.$;}S+=U.rowSpan-1;}};function u(G){var H=n(G),I=H[0],J=H[H.length-1],K=I.getAscendant('table'),L=e.buildTableMap(K),M,N,O=[];for(var P=0,Q=L.length;P1){L=H[J-1]+1;break;}}if(!L)L=H[0]>0?H[0]-1:H[H.length-1]+1;var N=I.$.rows;for(J=0,K=N.length;J=0;K--)x(H[K]);if(J)z(J,true);else if(I)I.remove();}else if(G instanceof h){var L=G.getParent();if(L.getChildCount()==1)L.remove();else G.remove();}};function y(G){var H=G.getBogus();H&&H.remove();G.trim();};function z(G,H){var I=new d.range(G.getDocument());if(!I['moveToElementEdit'+(H?'End':'Start')](G)){I.selectNodeContents(G);I.collapse(H?false:true);}I.select(true);};function A(G,H,I){var J=G[H];if(typeof I=='undefined')return J;for(var K=0;J&&K=Q)M.removeAttribute('rowSpan');else M.$.rowSpan=Y;if(Y>=P)M.removeAttribute('colSpan');else M.$.colSpan=Z;var ak=new d.nodeList(N.$.rows),al=ak.count();for(ac=al-1;ac>=0;ac--){var am=ak.getItem(ac);if(!am.$.cells.length){am.remove();al++;continue;}}return M;}else return Y*Z==ab;};function D(G,H){var I=n(G);if(I.length>1)return false;else if(H)return true;var J=I[0],K=J.getParent(),L=K.getAscendant('table'),M=e.buildTableMap(L),N=K.$.rowIndex,O=A(M,N,J),P=J.$.rowSpan,Q,R,S,T;if(P>1){R=Math.ceil(P/2);S=Math.floor(P/2);T=N+R;var U=new h(L.$.rows[T]),V=A(M,T),W;Q=J.clone();for(var X=0;XO){Q.insertBefore(new h(W));break;}else W=null;}if(!W)U.append(Q,true);}else{S=R=1;U=K.clone();U.insertAfter(K);U.append(Q=J.clone());var Y=A(M,N);for(var Z=0;Z1)return false;else if(H)return true;var J=I[0],K=J.getParent(),L=K.getAscendant('table'),M=e.buildTableMap(L),N=K.$.rowIndex,O=A(M,N,J),P=J.$.colSpan,Q,R,S;if(P>1){R=Math.ceil(P/2);S=Math.floor(P/2);}else{S=R=1;var T=B(M,O);for(var U=0;U0?2:0};}},tablecell_insertBefore:{label:H.cell.insertBefore,group:'tablecell',command:'cellInsertBefore',order:5},tablecell_insertAfter:{label:H.cell.insertAfter,group:'tablecell',command:'cellInsertAfter',order:10},tablecell_delete:{label:H.cell.deleteCell,group:'tablecell',command:'cellDelete',order:15},tablecell_merge:{label:H.cell.merge,group:'tablecell',command:'cellMerge',order:16},tablecell_merge_right:{label:H.cell.mergeRight,group:'tablecell',command:'cellMergeRight',order:17},tablecell_merge_down:{label:H.cell.mergeDown,group:'tablecell',command:'cellMergeDown',order:18},tablecell_split_horizontal:{label:H.cell.splitHorizontal,group:'tablecell',command:'cellHorizontalSplit',order:19},tablecell_split_vertical:{label:H.cell.splitVertical,group:'tablecell',command:'cellVerticalSplit',order:20},tablecell_properties:{label:H.cell.title,group:'tablecellproperties',command:'cellProperties',order:21},tablerow:{label:H.row.menu,group:'tablerow',order:1,getItems:function(){return{tablerow_insertBefore:2,tablerow_insertAfter:2,tablerow_delete:2};}},tablerow_insertBefore:{label:H.row.insertBefore,group:'tablerow',command:'rowInsertBefore',order:5},tablerow_insertAfter:{label:H.row.insertAfter,group:'tablerow',command:'rowInsertAfter',order:10},tablerow_delete:{label:H.row.deleteRow,group:'tablerow',command:'rowDelete',order:15},tablecolumn:{label:H.column.menu,group:'tablecolumn',order:1,getItems:function(){return{tablecolumn_insertBefore:2,tablecolumn_insertAfter:2,tablecolumn_delete:2}; +}},tablecolumn_insertBefore:{label:H.column.insertBefore,group:'tablecolumn',command:'columnInsertBefore',order:5},tablecolumn_insertAfter:{label:H.column.insertAfter,group:'tablecolumn',command:'columnInsertAfter',order:10},tablecolumn_delete:{label:H.column.deleteColumn,group:'tablecolumn',command:'columnDelete',order:15}});if(G.contextMenu)G.contextMenu.addListener(function(I,J){if(!I||I.isReadOnly())return null;while(I){if(I.getName() in F)return{tablecell:2,tablerow:2,tablecolumn:2};I=I.getParent();}return null;});},getSelectedCells:n};j.add('tabletools',j.tabletools);})();e.buildTableMap=function(m){var n=m.$.rows,o=-1,p=[];for(var q=0;qp&&(!s||!t||vt){s=v;t=u;}}else{if(q&&u==p){s=v;break;}if(ut)){s=v;t=u;}}}if(s)s.focus();};(function(){j.add('templates',{requires:['dialog'],init:function(o){a.dialog.add('templates',a.getUrl(this.path+'dialogs/templates.js'));o.addCommand('templates',new a.dialogCommand('templates'));o.ui.addButton('Templates',{label:o.lang.templates.button,command:'templates'});}});var m={},n={};a.addTemplates=function(o,p){m[o]=p;};a.getTemplates=function(o){return m[o];};a.loadTemplates=function(o,p){var q=[];for(var r=0,s=o.length;r':' style="display:none">');t.push('',o.lang.toolbars,'');var w=o.toolbox.toolbars,x=o.config.toolbar instanceof Array?o.config.toolbar:o.config['toolbar_'+o.config.toolbar];for(var y=0;y');v=0;}if(C==='/'){t.push('
    ');continue;}D=C.items||C;for(var E=0;E');B&&t.push('',B,'');t.push('');var I=w.push(A)-1;if(I>0){A.previous=w[I-1];A.previous.next=A;}}if(H){if(!v){t.push('');v=1;}}else if(v){t.push('');v=0;}var J=F.render(o,t);I=A.items.push(J)-1;if(I>0){J.previous=A.items[I-1];J.previous.next=J;}J.toolbar=A;J.onkey=q;J.onfocus=function(){if(!o.toolbox.focusCommandExecuted)o.focus();};}}if(v){t.push('');v=0;}if(A)t.push('');}t.push('');if(o.config.toolbarCanCollapse){var K=e.addFunction(function(){o.execCommand('toolbarCollapse');});o.on('destroy',function(){e.removeFunction(K);});var L=e.getNextId();o.addCommand('toolbarCollapse',{readOnly:1,exec:function(M){var N=a.document.getById(L),O=N.getPrevious(),P=M.getThemeSpace('contents'),Q=O.getParent(),R=parseInt(P.$.style.height,10),S=Q.$.offsetHeight,T=!O.isVisible();if(!T){O.hide();N.addClass('cke_toolbox_collapser_min');N.setAttribute('title',M.lang.toolbarExpand);}else{O.show();N.removeClass('cke_toolbox_collapser_min');N.setAttribute('title',M.lang.toolbarCollapse);}N.getFirst().setText(T?'â–²':'â—€');var U=Q.$.offsetHeight-S;P.setStyle('height',R-U+'px');M.fire('resize');},modes:{wysiwyg:1,source:1}});t.push('','','');}r.data.html+=t.join('');}});o.on('destroy',function(){var r,s=0,t,u,v;r=this.toolbox.toolbars;for(;s');return{};}};}});}});})();a.UI_SEPARATOR='separator';i.toolbarLocation='top';i.toolbar_Basic=[['Bold','Italic','-','NumberedList','BulletedList','-','Link','Unlink','-','About']];i.toolbar_Full=[{name:'document',items:['Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates']},{name:'clipboard',items:['Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo']},{name:'editing',items:['Find','Replace','-','SelectAll','-','SpellChecker','Scayt']},{name:'forms',items:['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField']},'/',{name:'basicstyles',items:['Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat']},{name:'paragraph',items:['NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl']},{name:'links',items:['Link','Unlink','Anchor']},{name:'insert',items:['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe']},'/',{name:'styles',items:['Styles','Format','Font','FontSize']},{name:'colors',items:['TextColor','BGColor']},{name:'tools',items:['Maximize','ShowBlocks','-','About']}];i.toolbar='Full';i.toolbarCanCollapse=true;(function(){j.add('undo',{requires:['selection','wysiwygarea'],init:function(s){var t=new o(s),u=s.addCommand('undo',{exec:function(){if(t.undo()){s.selectionChange();this.fire('afterUndo');}},state:0,canUndo:false}),v=s.addCommand('redo',{exec:function(){if(t.redo()){s.selectionChange();this.fire('afterRedo');}},state:0,canUndo:false});t.onChange=function(){u.setState(t.undoable()?2:0);v.setState(t.redoable()?2:0);};function w(x){if(t.enabled&&x.data.command.canUndo!==false)t.save();};s.on('beforeCommandExec',w);s.on('afterCommandExec',w);s.on('saveSnapshot',function(){t.save();});s.on('contentDom',function(){s.document.on('keydown',function(x){if(!x.data.$.ctrlKey&&!x.data.$.metaKey)t.type(x);});});s.on('beforeModeUnload',function(){s.mode=='wysiwyg'&&t.save(true);});s.on('mode',function(){t.enabled=s.readOnly?false:s.mode=='wysiwyg';t.onChange();});s.ui.addButton('Undo',{label:s.lang.undo,command:'undo'});s.ui.addButton('Redo',{label:s.lang.redo,command:'redo'});s.resetUndo=function(){t.reset(); -s.fire('saveSnapshot');};s.on('updateSnapshot',function(){if(t.currentImage&&new m(s).equals(t.currentImage))setTimeout(function(){t.update();},0);});}});j.undo={};var m=j.undo.Image=function(s){this.editor=s;s.fire('beforeUndoImage');var t=s.getSnapshot(),u=t&&s.getSelection();c&&t&&(t=t.replace(/\s+data-cke-expando=".*?"/g,''));this.contents=t;this.bookmarks=u&&u.createBookmarks2(true);s.fire('afterUndoImage');},n=/\b(?:href|src|name)="[^"]*?"/gi;m.prototype={equals:function(s,t){var u=this.contents,v=s.contents;if(c&&(b.ie7Compat||b.ie6Compat)){u=u.replace(n,'');v=v.replace(n,'');}if(u!=v)return false;if(t)return true;var w=this.bookmarks,x=s.bookmarks;if(w||x){if(!w||!x||w.length!=x.length)return false;for(var y=0;y25){this.save(false,null,false);this.modifiersCount=1;}}else if(!y){this.modifiersCount=0;this.typesCount++;if(this.typesCount>25){this.save(false,null,false);this.typesCount=1;}}},reset:function(){var s=this;s.lastKeystroke=0;s.snapshots=[];s.index=-1;s.limit=s.editor.config.undoStackSize||20;s.currentImage=null;s.hasUndo=false;s.hasRedo=false;s.resetType();},resetType:function(){var s=this;s.typing=false;delete s.lastKeystroke;s.typesCount=0;s.modifiersCount=0;},fireChange:function(){var s=this;s.hasUndo=!!s.getNextImage(true);s.hasRedo=!!s.getNextImage(false);s.resetType();s.onChange();},save:function(s,t,u){var w=this;var v=w.snapshots;if(!t)t=new m(w.editor);if(t.contents===false)return false;if(w.currentImage&&t.equals(w.currentImage,s))return false;v.splice(w.index+1,v.length-w.index-1);if(v.length==w.limit)v.shift(); -w.index=v.push(t)-1;w.currentImage=t;if(u!==false)w.fireChange();return true;},restoreImage:function(s){var u=this;u.editor.loadSnapshot(s.contents);if(s.bookmarks)u.editor.getSelection().selectBookmarks(s.bookmarks);else if(c){var t=u.editor.document.getBody().$.createTextRange();t.collapse(true);t.select();}u.index=s.index;u.update();u.fireChange();},getNextImage:function(s){var x=this;var t=x.snapshots,u=x.currentImage,v,w;if(u)if(s)for(w=x.index-1;w>=0;w--){v=t[w];if(!u.equals(v,true)){v.index=w;return v;}}else for(w=x.index+1;w]*>)\s*<(p|div|address|h\d|center|pre)[^>]*>\s*(?:]*>| |\u00A0| )?\s*(:?<\/\2>)?\s*(?=$|<\/body>)/gi,n=d.walker.whitespaces(true);function o(C){return C.isBlockBoundary()&&f.$empty[C.getName()];};function p(C){return function(D){if(this.mode=='wysiwyg'){this.focus();this.fire('saveSnapshot');C.call(this,D.data);e.setTimeout(function(){this.fire('saveSnapshot');},0,this);}};};function q(C){var M=this;if(M.dataProcessor)C=M.dataProcessor.toHtml(C);if(!C)return;var D=M.getSelection(),E=D.getRanges()[0];if(E.checkReadOnly())return;if(b.opera){var F=new d.elementPath(E.startContainer);if(F.block){var G=a.htmlParser.fragment.fromHtml(C,false).children;for(var H=0,I=G.length;H');return{};}};}});}});})();a.UI_SEPARATOR='separator';i.toolbarLocation='top';i.toolbar_Basic=[['Bold','Italic','-','NumberedList','BulletedList','-','Link','Unlink','-','About']];i.toolbar_Full=[{name:'document',items:['Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates']},{name:'clipboard',items:['Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo']},{name:'editing',items:['Find','Replace','-','SelectAll','-','SpellChecker','Scayt']},{name:'forms',items:['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField']},'/',{name:'basicstyles',items:['Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat']},{name:'paragraph',items:['NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl']},{name:'links',items:['Link','Unlink','Anchor']},{name:'insert',items:['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe']},'/',{name:'styles',items:['Styles','Format','Font','FontSize']},{name:'colors',items:['TextColor','BGColor']},{name:'tools',items:['Maximize','ShowBlocks','-','About']}];i.toolbar='Full';i.toolbarCanCollapse=true;(function(){j.add('undo',{requires:['selection','wysiwygarea'],init:function(s){var t=new o(s),u=s.addCommand('undo',{exec:function(){if(t.undo()){s.selectionChange();this.fire('afterUndo');}},state:0,canUndo:false}),v=s.addCommand('redo',{exec:function(){if(t.redo()){s.selectionChange();this.fire('afterRedo');}},state:0,canUndo:false});t.onChange=function(){u.setState(t.undoable()?2:0);v.setState(t.redoable()?2:0);};function w(x){if(t.enabled&&x.data.command.canUndo!==false)t.save();};s.on('beforeCommandExec',w);s.on('afterCommandExec',w);s.on('saveSnapshot',function(x){t.save(x.data&&x.data.contentOnly);});s.on('contentDom',function(){s.document.on('keydown',function(x){if(!x.data.$.ctrlKey&&!x.data.$.metaKey)t.type(x);});});s.on('beforeModeUnload',function(){s.mode=='wysiwyg'&&t.save(true);});s.on('mode',function(){t.enabled=s.readOnly?false:s.mode=='wysiwyg';t.onChange();});s.ui.addButton('Undo',{label:s.lang.undo,command:'undo'});s.ui.addButton('Redo',{label:s.lang.redo,command:'redo'}); +s.resetUndo=function(){t.reset();s.fire('saveSnapshot');};s.on('updateSnapshot',function(){if(t.currentImage)t.update();});}});j.undo={};var m=j.undo.Image=function(s){this.editor=s;s.fire('beforeUndoImage');var t=s.getSnapshot(),u=t&&s.getSelection();c&&t&&(t=t.replace(/\s+data-cke-expando=".*?"/g,''));this.contents=t;this.bookmarks=u&&u.createBookmarks2(true);s.fire('afterUndoImage');},n=/\b(?:href|src|name)="[^"]*?"/gi;m.prototype={equals:function(s,t){var u=this.contents,v=s.contents;if(c&&(b.ie7Compat||b.ie6Compat)){u=u.replace(n,'');v=v.replace(n,'');}if(u!=v)return false;if(t)return true;var w=this.bookmarks,x=s.bookmarks;if(w||x){if(!w||!x||w.length!=x.length)return false;for(var y=0;y25){this.save(false,null,false);this.modifiersCount=1;}}else if(!y){this.modifiersCount=0;this.typesCount++;if(this.typesCount>25){this.save(false,null,false);this.typesCount=1;}}},reset:function(){var s=this;s.lastKeystroke=0;s.snapshots=[];s.index=-1;s.limit=s.editor.config.undoStackSize||20;s.currentImage=null;s.hasUndo=false;s.hasRedo=false;s.resetType();},resetType:function(){var s=this;s.typing=false;delete s.lastKeystroke;s.typesCount=0;s.modifiersCount=0;},fireChange:function(){var s=this;s.hasUndo=!!s.getNextImage(true);s.hasRedo=!!s.getNextImage(false);s.resetType();s.onChange();},save:function(s,t,u){var w=this;var v=w.snapshots;if(!t)t=new m(w.editor);if(t.contents===false)return false;if(w.currentImage&&t.equals(w.currentImage,s))return false;v.splice(w.index+1,v.length-w.index-1);if(v.length==w.limit)v.shift();w.index=v.push(t)-1;w.currentImage=t; +if(u!==false)w.fireChange();return true;},restoreImage:function(s){var u=this;u.editor.loadSnapshot(s.contents);if(s.bookmarks)u.editor.getSelection().selectBookmarks(s.bookmarks);else if(c){var t=u.editor.document.getBody().$.createTextRange();t.collapse(true);t.select();}u.index=s.index;u.update();u.fireChange();},getNextImage:function(s){var x=this;var t=x.snapshots,u=x.currentImage,v,w;if(u)if(s)for(w=x.index-1;w>=0;w--){v=t[w];if(!u.equals(v,true)){v.index=w;return v;}}else for(w=x.index+1;w]*>)\s*<(p|div|address|h\d|center|pre)[^>]*>\s*(?:]*>| |\u00A0| )?\s*(:?<\/\2>)?\s*(?=$|<\/body>)/gi,n=d.walker.whitespaces(true);function o(C){return C.isBlockBoundary()&&f.$empty[C.getName()];};function p(C){return function(D){if(this.mode=='wysiwyg'){this.focus();this.fire('saveSnapshot');C.call(this,D.data);e.setTimeout(function(){this.fire('saveSnapshot');},0,this);}};};function q(C){var M=this;if(M.dataProcessor)C=M.dataProcessor.toHtml(C);if(!C)return;var D=M.getSelection(),E=D.getRanges()[0];if(E.checkReadOnly())return;if(b.opera){var F=new d.elementPath(E.startContainer);if(F.block){var G=a.htmlParser.fragment.fromHtml(C,false).children;for(var H=0,I=G.length;H'+O+'';});G=G.replace(/\n/g,'
    ');if(!(F||c))G=G.replace(new RegExp('
    (?=)'),function(M){return e.repeat(M,2);});if(b.gecko||b.webkit){var I=new d.elementPath(D.getStartElement()),J=[];for(var K=0;K/));else if(L in f.$block)break;}G=J.join('')+G;}q.call(this,G);};function s(C){var D=this.getSelection(),E=D.getRanges(),F=C.getName(),G=f.$block[F],H=D.isLocked;if(H)D.unlock();var I,J,K,L;for(var M=E.length-1;M>=0;M--){I=E[M];if(!I.checkReadOnly()){I.deleteContents(1);J=!M&&C||C.clone(1);var N,O;if(G)while((N=I.getCommonAncestor(0,1))&&(O=f[N.getName()])&&!(O&&O[F])){if(N.getName() in f.span)I.splitElement(N);else if(I.checkStartOfBlock()&&I.checkEndOfBlock()){I.setStartBefore(N);I.collapse(true);N.remove();}else I.splitBlock();}I.insertNode(J);if(!K)K=J;}}if(K){I.moveToPosition(K,4);if(G){var P=K.getNext(n),Q=P&&P.type==1&&P.getName();if(Q&&f.$block[Q]&&f[Q]['#'])I.moveToElementEditStart(P);}}D.selectRanges([I]);if(H)this.getSelection().lock();};function t(C){if(!C.checkDirty())setTimeout(function(){C.resetDirty();},0);};var u=d.walker.whitespaces(true),v=d.walker.bookmark(false,true);function w(C){return u(C)&&v(C);};function x(C){return C.type==3&&e.trim(C.getText()).match(/^(?: |\xa0)$/);};function y(C){if(C.isLocked){C.unlock();setTimeout(function(){C.lock();},0);}};function z(C){return C.getOuterHtml().match(m);};u=d.walker.whitespaces(true);function A(C){var D=C.window,E=C.document,F=C.document.getBody(),G=F.getFirst(),H=F.getChildren().count();if(!H||H==1&&G.type==1&&G.hasAttribute('_moz_editor_bogus_node')){t(C);var I=C.element.getDocument(),J=I.getDocumentElement(),K=J.$.scrollTop,L=J.$.scrollLeft,M=E.$.createEvent('KeyEvents');M.initKeyEvent('keypress',true,true,D.$,false,false,false,false,0,32);E.$.dispatchEvent(M);if(K!=J.$.scrollTop||L!=J.$.scrollLeft)I.getWindow().$.scrollTo(L,K);H&&F.getFirst().remove();E.getBody().appendBogus();var N=new d.range(E);N.setStartAt(F,1);N.select();}};function B(C){var D=C.editor,E=C.data.path,F=E.blockLimit,G=C.data.selection,H=G.getRanges()[0],I=D.document.getBody(),J=D.config.enterMode; -if(b.gecko){A(D);var K=E.block||E.blockLimit,L=K&&K.getLast(w);if(K&&K.isBlockBoundary()&&!(L&&L.type==1&&L.isBlockBoundary())&&!K.is('pre')&&!K.getBogus()){D.fire('updateSnapshot');t(D);K.appendBogus();}}if(D.config.autoParagraph!==false&&J!=2&&H.collapsed&&F.getName()=='body'&&!E.block){D.fire('updateSnapshot');t(D);c&&y(G);var M=H.fixBlock(true,D.config.enterMode==3?'div':'p');if(c){var N=M.getFirst(w);N&&x(N)&&N.remove();}if(z(M)){var O=M.getNext(u);if(O&&O.type==1&&!o(O)){H.moveToElementEditStart(O);M.remove();}else{O=M.getPrevious(u);if(O&&O.type==1&&!o(O)){H.moveToElementEditEnd(O);M.remove();}}}H.select();C.cancel();}var P=new d.range(D.document);P.moveToElementEditEnd(D.document.getBody());var Q=new d.elementPath(P.startContainer);if(!Q.blockLimit.is('body')){D.fire('updateSnapshot');t(D);c&&y(G);var R;if(J!=2)R=I.append(D.document.createElement(J==1?'p':'div'));else R=I;if(!c)R.appendBogus();}};j.add('wysiwygarea',{requires:['editingblock'],init:function(C){var D=C.config.enterMode!=2&&C.config.autoParagraph!==false?C.config.enterMode==3?'div':'p':false,E=C.lang.editorTitle.replace('%1',C.name),F;C.on('editingBlockReady',function(){var L,M,N,O,P,Q,R=b.isCustomDomain(),S=function(V){if(M)M.remove();var W='document.open();'+(R?'document.domain="'+document.domain+'";':'')+'document.close();';W=b.air?'javascript:void(0)':c?'javascript:void(function(){'+encodeURIComponent(W)+'}())':'';M=h.createFromHtml('');if(document.location.protocol=='chrome:')a.event.useCapture=true;M.on('load',function(X){P=1;X.removeListener();var Y=M.getFrameDocument();Y.write(V);b.air&&U(Y.getWindow().$);});if(document.location.protocol=='chrome:')a.event.useCapture=false;L.append(M);};F=e.addFunction(U);var T='';function U(V){if(!P)return;P=0;C.fire('ariaWidget',M);var W=V.document,X=W.body,Y=W.getElementById('cke_actscrpt');Y&&Y.parentNode.removeChild(Y);X.spellcheck=!C.config.disableNativeSpellChecker;var Z=!C.readOnly;if(c){X.hideFocus=true;X.disabled=true;X.contentEditable=Z;X.removeAttribute('disabled');}else setTimeout(function(){if(b.gecko&&b.version>=10900||b.opera)W.$.body.contentEditable=Z;else if(b.webkit)W.$.body.parentNode.contentEditable=Z; -else W.$.designMode=Z?'off':'on';},0);Z&&b.gecko&&e.setTimeout(A,0,null,C);V=C.window=new d.window(V);W=C.document=new g(W);Z&&W.on('dblclick',function(af){var ag=af.data.getTarget(),ah={element:ag,dialog:''};C.fire('doubleclick',ah);ah.dialog&&C.openDialog(ah.dialog);});c&&W.on('click',function(af){var ag=af.data.getTarget();if(ag.is('input')){var ah=ag.getAttribute('type');if(ah=='submit'||ah=='reset')af.data.preventDefault();}});if(!(c||b.opera))W.on('mousedown',function(af){var ag=af.data.getTarget();if(ag.is('img','hr','input','textarea','select'))C.getSelection().selectElement(ag);});if(b.gecko)W.on('mouseup',function(af){if(af.data.$.button==2){var ag=af.data.getTarget();if(!ag.getOuterHtml().replace(m,'')){var ah=new d.range(W);ah.moveToElementEditStart(ag);ah.select(true);}}});W.on('click',function(af){af=af.data;if(af.getTarget().is('a')&&af.$.button!=2)af.preventDefault();});if(b.webkit){W.on('mousedown',function(){ac=1;});W.on('click',function(af){if(af.data.getTarget().is('input','select'))af.data.preventDefault();});W.on('mouseup',function(af){if(af.data.getTarget().is('input','textarea'))af.data.preventDefault();});}if(Z&&c&&W.$.compatMode=='CSS1Compat'||b.gecko||b.opera){var aa=W.getDocumentElement();aa.on('mousedown',function(af){if(af.data.getTarget().equals(aa)){if(b.gecko&&b.version>=10900)J();K.focus();}});}var ab=c?M:V;ab.on('blur',function(){C.focusManager.blur();});var ac;ab.on('focus',function(){var af=C.document;if(Z&&b.gecko&&b.version>=10900)J();else if(b.opera)af.getBody().focus();else if(b.webkit)if(!ac){C.document.getDocumentElement().focus();ac=1;}C.focusManager.focus();});var ad=C.keystrokeHandler;ad.blockedKeystrokes[8]=!Z;ad.attach(W);if(c){W.getDocumentElement().addClass(W.$.compatMode);Z&&W.on('keydown',function(af){var ag=af.data.getKeystroke();if(ag in {8:1,46:1}){var ah=C.getSelection(),ai=ah.getSelectedElement();if(ai){C.fire('saveSnapshot');var aj=ah.getRanges()[0].createBookmark();ai.remove();ah.selectBookmarks([aj]);C.fire('saveSnapshot');af.data.preventDefault();}}});if(W.$.compatMode=='CSS1Compat'){var ae={33:1,34:1};W.on('keydown',function(af){if(af.data.getKeystroke() in ae)setTimeout(function(){C.getSelection().scrollIntoView();},0);});}C.config.enterMode!=1&&W.on('selectionchange',function(){var af=W.getBody(),ag=C.getSelection().getRanges()[0];if(af.getHtml().match(/^

     <\/p>$/i)&&ag.startContainer.equals(af))setTimeout(function(){ag=C.getSelection().getRanges()[0];if(!ag.startContainer.equals('body')){af.getFirst().remove(1); -ag.moveToElementEditEnd(af);ag.select(1);}},0);});}if(C.contextMenu)C.contextMenu.addTarget(W,C.config.browserContextMenuOnCtrl!==false);setTimeout(function(){C.fire('contentDom');if(Q){C.mode='wysiwyg';C.fire('mode');Q=false;}N=false;if(O){C.focus();O=false;}setTimeout(function(){C.fire('dataReady');},0);try{C.document.$.execCommand('enableInlineTableEditing',false,!C.config.disableNativeTableHandles);}catch(af){}if(C.config.disableObjectResizing)try{C.document.$.execCommand('enableObjectResizing',false,false);}catch(ag){C.document.getBody().on(c?'resizestart':'resize',function(ah){ah.data.preventDefault();});}if(c)setTimeout(function(){if(C.document){var ah=C.document.$.body;ah.runtimeStyle.marginBottom='0px';ah.runtimeStyle.marginBottom='';}},1000);},0);};C.addMode('wysiwyg',{load:function(V,W,X){L=V;if(c&&b.quirks)V.setStyle('position','relative');C.mayBeDirty=true;Q=true;if(X)this.loadSnapshotData(W);else this.loadData(W);},loadData:function(V){N=true;C._.dataStore={id:1};var W=C.config,X=W.fullPage,Y=W.docType,Z='';!X&&(Z=e.buildStyleHtml(C.config.contentsCss)+Z);var aa=W.baseHref?'':'';if(X)V=V.replace(/]*>/i,function(ab){C.docType=Y=ab;return '';}).replace(/<\?xml\s[^\?]*\?>/i,function(ab){C.xmlDeclaration=ab;return '';});if(C.dataProcessor)V=C.dataProcessor.toHtml(V,D);if(X){if(!/]/.test(V))V=''+V;if(!/]/.test(V))V=''+V+'';if(!/]/.test(V))V=V.replace(/]*>/,'$&');else if(!/]/.test(V))V=V.replace(/]*>/,'$&');aa&&(V=V.replace(//,'$&'+aa));V=V.replace(/<\/head\s*>/,Z+'$&');V=Y+V;}else V=W.docType+''+''+''+E+''+aa+Z+''+''+V+'';if(b.gecko)V=V.replace(/
    (?=\s*<\/(:?html|body)>)/,'$&
    ');V+=T;this.onDispose();S(V);},getData:function(){var V=C.config,W=V.fullPage,X=W&&C.docType,Y=W&&C.xmlDeclaration,Z=M.getFrameDocument(),aa=W?Z.getDocumentElement().getOuterHtml():Z.getBody().getHtml();if(b.gecko)aa=aa.replace(/
    (?=\s*(:?$|<\/body>))/,'');if(C.dataProcessor)aa=C.dataProcessor.toDataFormat(aa,D);if(V.ignoreEmptyParagraph)aa=aa.replace(m,function(ab,ac){return ac;});if(Y)aa=Y+'\n'+aa; -if(X)aa=X+'\n'+aa;return aa;},getSnapshotData:function(){return M.getFrameDocument().getBody().getHtml();},loadSnapshotData:function(V){M.getFrameDocument().getBody().setHtml(V);},onDispose:function(){if(!C.document)return;C.document.getDocumentElement().clearCustomData();C.document.getBody().clearCustomData();C.window.clearCustomData();C.document.clearCustomData();M.clearCustomData();M.remove();},unload:function(V){this.onDispose();C.window=C.document=M=L=O=null;C.fire('contentDomUnload');},focus:function(){var V=C.window;if(N)O=true;else if(b.opera&&C.document){var W=C.window.$.frameElement;W.blur(),W.focus();C.document.getBody().focus();C.selectionChange();}else if(!b.opera&&V){b.air?setTimeout(function(){V.focus();},0):V.focus();C.selectionChange();}}});C.on('insertHtml',p(q),null,null,20);C.on('insertElement',p(s),null,null,20);C.on('insertText',p(r),null,null,20);C.on('selectionChange',B,null,null,1);});var G;C.on('contentDom',function(){var L=C.document.getElementsByTag('title').getItem(0);L.data('cke-title',C.document.$.title);C.document.$.title=E;});C.on('readOnly',function(){if(C.mode=='wysiwyg'){var L=C.getMode();L.loadData(L.getData());}});if(a.document.$.documentMode>=8){C.addCss('html.CSS1Compat [contenteditable=false]{ min-height:0 !important;}');var H=[];for(var I in f.$removeEmpty)H.push('html.CSS1Compat '+I+'[contenteditable=false]');C.addCss(H.join(',')+'{ display:inline-block;}');}else if(b.gecko){C.addCss('html { height: 100% !important; }');C.addCss('img:-moz-broken { -moz-force-broken-image-icon : 1;\twidth : 24px; height : 24px; }');}C.addCss('html {\t_overflow-y: scroll; cursor: text;\t*cursor:auto;}');C.addCss('img, input, textarea { cursor: default;}');function J(L){if(C.readOnly)return;e.tryThese(function(){C.document.$.designMode='on';setTimeout(function(){C.document.$.designMode='off';if(a.currentInstance==C)C.document.getBody().focus();},50);},function(){C.document.$.designMode='off';var M=C.document.getBody();M.setAttribute('contentEditable',false);M.setAttribute('contentEditable',true);!L&&J(1);});};if(b.gecko||c||b.opera){var K;C.on('uiReady',function(){K=C.container.append(h.createFromHtml(''));K.on('focus',function(){C.focus();});C.focusGrabber=K;});C.on('destroy',function(){e.removeFunction(F);K.clearCustomData();delete C.focusGrabber;});}C.on('insertElement',function(L){var M=L.data;if(M.type==1&&(M.is('input')||M.is('textarea'))){if(!M.isReadOnly())M.data('cke-editable',M.hasAttribute('contenteditable')?'true':'1'); -M.setAttribute('contentEditable',false);}});}});if(b.gecko)(function(){var C=document.body;if(!C)window.addEventListener('load',arguments.callee,false);else{var D=C.getAttribute('onpageshow');C.setAttribute('onpageshow',(D?D+';':'')+'event.persisted && (function(){'+'var allInstances = CKEDITOR.instances, editor, doc;'+'for ( var i in allInstances )'+'{'+'\teditor = allInstances[ i ];'+'\tdoc = editor.document;'+'\tif ( doc )'+'\t{'+'\t\tdoc.$.designMode = "off";'+'\t\tdoc.$.designMode = "on";'+'\t}'+'}'+'})();');}})();})();i.disableObjectResizing=false;i.disableNativeTableHandles=true;i.disableNativeSpellChecker=true;i.ignoreEmptyParagraph=true;j.add('wsc',{requires:['dialog'],init:function(m){var n='checkspell',o=m.addCommand(n,new a.dialogCommand(n));o.modes={wysiwyg:!b.opera&&!b.air&&document.domain==window.location.hostname};m.ui.addButton('SpellChecker',{label:m.lang.spellCheck.toolbar,command:n});a.dialog.add(n,this.path+'dialogs/wsc.js');}});i.wsc_customerId=i.wsc_customerId||'1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk';i.wsc_customLoaderScript=i.wsc_customLoaderScript||null;a.DIALOG_RESIZE_NONE=0;a.DIALOG_RESIZE_WIDTH=1;a.DIALOG_RESIZE_HEIGHT=2;a.DIALOG_RESIZE_BOTH=3;(function(){var m=e.cssLength;function n(S){return!!this._.tabs[S][0].$.offsetHeight;};function o(){var W=this;var S=W._.currentTabId,T=W._.tabIdList.length,U=e.indexOf(W._.tabIdList,S)+T;for(var V=U-1;V>U-T;V--){if(n.call(W,W._.tabIdList[V%T]))return W._.tabIdList[V%T];}return null;};function p(){var W=this;var S=W._.currentTabId,T=W._.tabIdList.length,U=e.indexOf(W._.tabIdList,S);for(var V=U+1;V');if(document.location.protocol=='chrome:')a.event.useCapture=true;M.on('load',function(X){P=1;X.removeListener();var Y=M.getFrameDocument();Y.write(V);b.air&&U(Y.getWindow().$);});if(document.location.protocol=='chrome:')a.event.useCapture=false;L.append(M);};F=e.addFunction(U);var T='';function U(V){if(!P)return;P=0;C.fire('ariaWidget',M);var W=V.document,X=W.body,Y=W.getElementById('cke_actscrpt');Y&&Y.parentNode.removeChild(Y);X.spellcheck=!C.config.disableNativeSpellChecker;var Z=!C.readOnly;if(c){X.hideFocus=true;X.disabled=true;X.contentEditable=Z;X.removeAttribute('disabled');}else setTimeout(function(){if(b.gecko&&b.version>=10900||b.opera)W.$.body.contentEditable=Z;else if(b.webkit)W.$.body.parentNode.contentEditable=Z;else W.$.designMode=Z?'off':'on';},0);Z&&b.gecko&&e.setTimeout(A,0,null,C);V=C.window=new d.window(V); +W=C.document=new g(W);Z&&W.on('dblclick',function(af){var ag=af.data.getTarget(),ah={element:ag,dialog:''};C.fire('doubleclick',ah);ah.dialog&&C.openDialog(ah.dialog);});c&&W.on('click',function(af){var ag=af.data.getTarget();if(ag.is('input')){var ah=ag.getAttribute('type');if(ah=='submit'||ah=='reset')af.data.preventDefault();}});if(!(c||b.opera))W.on('mousedown',function(af){var ag=af.data.getTarget();if(ag.is('img','hr','input','textarea','select'))C.getSelection().selectElement(ag);});if(b.gecko)W.on('mouseup',function(af){if(af.data.$.button==2){var ag=af.data.getTarget();if(!ag.getOuterHtml().replace(m,'')){var ah=new d.range(W);ah.moveToElementEditStart(ag);ah.select(true);}}});W.on('click',function(af){af=af.data;if(af.getTarget().is('a')&&af.$.button!=2)af.preventDefault();});if(b.webkit){W.on('mousedown',function(){ac=1;});W.on('click',function(af){if(af.data.getTarget().is('input','select'))af.data.preventDefault();});W.on('mouseup',function(af){if(af.data.getTarget().is('input','textarea'))af.data.preventDefault();});}if(Z&&c&&W.$.compatMode=='CSS1Compat'||b.gecko||b.opera){var aa=W.getDocumentElement();aa.on('mousedown',function(af){if(af.data.getTarget().equals(aa)){if(b.gecko&&b.version>=10900)J();K.focus();}});}var ab=c?M:V;ab.on('blur',function(){C.focusManager.blur();});var ac;ab.on('focus',function(){var af=C.document;if(Z&&b.gecko&&b.version>=10900)J();else if(b.opera)af.getBody().focus();else if(b.webkit)if(!ac){C.document.getDocumentElement().focus();ac=1;}C.focusManager.focus();});var ad=C.keystrokeHandler;ad.blockedKeystrokes[8]=!Z;ad.attach(W);W.getDocumentElement().addClass(W.$.compatMode);Z&&W.on('keydown',function(af){var ag=af.data.getKeystroke();if(ag in {8:1,46:1}){var ah=C.getSelection(),ai=ah.getSelectedElement(),aj=ah.getRanges()[0];if(ai){C.fire('saveSnapshot');aj.moveToPosition(ai,3);ai.remove();aj.select();C.fire('saveSnapshot');af.data.preventDefault();return;}}});if(c&&W.$.compatMode=='CSS1Compat'){var ae={33:1,34:1};W.on('keydown',function(af){if(af.data.getKeystroke() in ae)setTimeout(function(){C.getSelection().scrollIntoView();},0);});}if(c&&C.config.enterMode!=1)W.on('selectionchange',function(){var af=W.getBody(),ag=C.getSelection().getRanges()[0];if(af.getHtml().match(/^

     <\/p>$/i)&&ag.startContainer.equals(af))setTimeout(function(){ag=C.getSelection().getRanges()[0];if(!ag.startContainer.equals('body')){af.getFirst().remove(1);ag.moveToElementEditEnd(af);ag.select(1);}},0);});if(C.contextMenu)C.contextMenu.addTarget(W,C.config.browserContextMenuOnCtrl!==false); +setTimeout(function(){C.fire('contentDom');if(Q){C.mode='wysiwyg';C.fire('mode',{previousMode:C._.previousMode});Q=false;}N=false;if(O){C.focus();O=false;}setTimeout(function(){C.fire('dataReady');},0);try{C.document.$.execCommand('enableInlineTableEditing',false,!C.config.disableNativeTableHandles);}catch(af){}if(C.config.disableObjectResizing)try{C.document.$.execCommand('enableObjectResizing',false,false);}catch(ag){C.document.getBody().on(c?'resizestart':'resize',function(ah){ah.data.preventDefault();});}if(c)setTimeout(function(){if(C.document){var ah=C.document.$.body;ah.runtimeStyle.marginBottom='0px';ah.runtimeStyle.marginBottom='';}},1000);},0);};C.addMode('wysiwyg',{load:function(V,W,X){L=V;if(c&&b.quirks)V.setStyle('position','relative');C.mayBeDirty=true;Q=true;if(X)this.loadSnapshotData(W);else this.loadData(W);},loadData:function(V){N=true;C._.dataStore={id:1};var W=C.config,X=W.fullPage,Y=W.docType,Z='';!X&&(Z=e.buildStyleHtml(C.config.contentsCss)+Z);var aa=W.baseHref?'':'';if(X)V=V.replace(/]*>/i,function(ab){C.docType=Y=ab;return '';}).replace(/<\?xml\s[^\?]*\?>/i,function(ab){C.xmlDeclaration=ab;return '';});if(C.dataProcessor)V=C.dataProcessor.toHtml(V,D);if(X){if(!/]/.test(V))V=''+V;if(!/]/.test(V))V=''+V+'';if(!/]/.test(V))V=V.replace(/]*>/,'$&');else if(!/]/.test(V))V=V.replace(/]*>/,'$&');aa&&(V=V.replace(//,'$&'+aa));V=V.replace(/<\/head\s*>/,Z+'$&');V=Y+V;}else V=W.docType+''+''+''+E+''+aa+Z+''+''+V+'';if(b.gecko)V=V.replace(/
    (?=\s*<\/(:?html|body)>)/,'$&
    ');V+=T;this.onDispose();S(V);},getData:function(){var V=C.config,W=V.fullPage,X=W&&C.docType,Y=W&&C.xmlDeclaration,Z=M.getFrameDocument(),aa=W?Z.getDocumentElement().getOuterHtml():Z.getBody().getHtml();if(b.gecko)aa=aa.replace(/
    (?=\s*(:?$|<\/body>))/,'');if(C.dataProcessor)aa=C.dataProcessor.toDataFormat(aa,D);if(V.ignoreEmptyParagraph)aa=aa.replace(m,function(ab,ac){return ac;});if(Y)aa=Y+'\n'+aa;if(X)aa=X+'\n'+aa;return aa;},getSnapshotData:function(){return M.getFrameDocument().getBody().getHtml(); +},loadSnapshotData:function(V){M.getFrameDocument().getBody().setHtml(V);},onDispose:function(){if(!C.document)return;C.document.getDocumentElement().clearCustomData();C.document.getBody().clearCustomData();C.window.clearCustomData();C.document.clearCustomData();M.clearCustomData();M.remove();},unload:function(V){this.onDispose();C.window=C.document=M=L=O=null;C.fire('contentDomUnload');},focus:function(){var V=C.window;if(N)O=true;else if(V){b.air?setTimeout(function(){V.focus();},0):V.focus();C.selectionChange();}}});C.on('insertHtml',p(q),null,null,20);C.on('insertElement',p(s),null,null,20);C.on('insertText',p(r),null,null,20);C.on('selectionChange',function(V){if(C.readOnly)return;var W=C.getSelection();if(W&&!W.isLocked){var X=C.checkDirty();C.fire('saveSnapshot',{contentOnly:1});B.call(this,V);C.fire('updateSnapshot');!X&&C.resetDirty();}},null,null,1);});var G;C.on('contentDom',function(){var L=C.document.getElementsByTag('title').getItem(0);L.data('cke-title',C.document.$.title);C.document.$.title=E;});C.on('readOnly',function(){if(C.mode=='wysiwyg'){var L=C.getMode();L.loadData(L.getData());}});if(a.document.$.documentMode>=8){C.addCss('html.CSS1Compat [contenteditable=false]{ min-height:0 !important;}');var H=[];for(var I in f.$removeEmpty)H.push('html.CSS1Compat '+I+'[contenteditable=false]');C.addCss(H.join(',')+'{ display:inline-block;}');}else if(b.gecko){C.addCss('html { height: 100% !important; }');C.addCss('img:-moz-broken { -moz-force-broken-image-icon : 1;\twidth : 24px; height : 24px; }');}C.addCss('html {\t_overflow-y: scroll; cursor: text;\t*cursor:auto;}');C.addCss('img, input, textarea { cursor: default;}');function J(L){if(C.readOnly)return;e.tryThese(function(){C.document.$.designMode='on';setTimeout(function(){C.document.$.designMode='off';if(a.currentInstance==C)C.document.getBody().focus();},50);},function(){C.document.$.designMode='off';var M=C.document.getBody();M.setAttribute('contentEditable',false);M.setAttribute('contentEditable',true);!L&&J(1);});};if(b.gecko||c||b.opera){var K;C.on('uiReady',function(){K=C.container.append(h.createFromHtml(''));K.on('focus',function(){C.focus();});C.focusGrabber=K;});C.on('destroy',function(){e.removeFunction(F);K.clearCustomData();delete C.focusGrabber;});}C.on('insertElement',function(L){var M=L.data;if(M.type==1&&(M.is('input')||M.is('textarea'))){var N=M.getAttribute('contenteditable')=='false';if(!N){M.data('cke-editable',M.hasAttribute('contenteditable')?'true':'1'); +M.setAttribute('contenteditable',false);}}});}});if(b.gecko)(function(){var C=document.body;if(!C)window.addEventListener('load',arguments.callee,false);else{var D=C.getAttribute('onpageshow');C.setAttribute('onpageshow',(D?D+';':'')+'event.persisted && (function(){'+'var allInstances = CKEDITOR.instances, editor, doc;'+'for ( var i in allInstances )'+'{'+'\teditor = allInstances[ i ];'+'\tdoc = editor.document;'+'\tif ( doc )'+'\t{'+'\t\tdoc.$.designMode = "off";'+'\t\tdoc.$.designMode = "on";'+'\t}'+'}'+'})();');}})();})();i.disableObjectResizing=false;i.disableNativeTableHandles=true;i.disableNativeSpellChecker=true;i.ignoreEmptyParagraph=true;j.add('wsc',{requires:['dialog'],init:function(m){var n='checkspell',o=m.addCommand(n,new a.dialogCommand(n));o.modes={wysiwyg:!b.opera&&!b.air&&document.domain==window.location.hostname};m.ui.addButton('SpellChecker',{label:m.lang.spellCheck.toolbar,command:n});a.dialog.add(n,this.path+'dialogs/wsc.js');}});i.wsc_customerId=i.wsc_customerId||'1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk';i.wsc_customLoaderScript=i.wsc_customLoaderScript||null;a.DIALOG_RESIZE_NONE=0;a.DIALOG_RESIZE_WIDTH=1;a.DIALOG_RESIZE_HEIGHT=2;a.DIALOG_RESIZE_BOTH=3;(function(){var m=e.cssLength;function n(S){return!!this._.tabs[S][0].$.offsetHeight;};function o(){var W=this;var S=W._.currentTabId,T=W._.tabIdList.length,U=e.indexOf(W._.tabIdList,S)+T;for(var V=U-1;V>U-T;V--){if(n.call(W,W._.tabIdList[V%T]))return W._.tabIdList[V%T];}return null;};function p(){var W=this;var S=W._.currentTabId,T=W._.tabIdList.length,U=e.indexOf(W._.tabIdList,S);for(var V=U+1;V1){af._.tabBarMode=true;af._.tabs[af._.currentTabId][0].focus();aj=1;}else if((as==37||as==39)&&af._.tabBarMode){av=as==(at?39:37)?o.call(af):p.call(af);af.selectPage(av);af._.tabs[av][0].focus();aj=1;}else if((as==13||as==32)&&af._.tabBarMode){aw.selectPage(aw._.currentTabId);aw._.tabBarMode=false;aw._.currentFocusIndex=-1;ai(true);aj=1;}if(aj){ar.stop();ar.data.preventDefault();}};function al(ar){aj&&ar.data.preventDefault();};var am=this._.element;this.on('show',function(){am.on('keydown',ak,this,null,0);if(b.opera||b.gecko&&b.mac)am.on('keypress',al,this);});this.on('hide',function(){am.removeListener('keydown',ak);if(b.opera||b.gecko&&b.mac)am.removeListener('keypress',al);ag(function(ar){s.apply(ar);});});this.on('iframeAdded',function(ar){var as=new g(ar.data.iframe.$.contentWindow.document);as.on('keydown',ak,this,null,0);});this.on('show',function(){var av=this;ah();if(S.config.dialog_startupFocusTab&&af._.pageCount>1){af._.tabBarMode=true;af._.tabs[af._.currentTabId][0].focus();}else if(!av._.hasFocus){av._.currentFocusIndex=-1;if(U.onFocus){var ar=U.onFocus.call(av);ar&&ar.focus();}else ai(true);if(av._.editor.mode=='wysiwyg'&&c){var as=S.document.$.selection,at=as.createRange();if(at)if(at.parentElement&&at.parentElement().ownerDocument==S.document.$||at.item&&at.item(0).ownerDocument==S.document.$){var au=document.body.createTextRange();au.moveToElementText(av.getElement().getFirst().$);au.collapse(true);au.select();}}}},this,null,4294967295);if(b.ie6Compat)this.on('load',function(ar){var as=this.getElement(),at=as.getFirst();at.remove();at.appendTo(as);},this);A(this);B(this);new d.text(U.title,a.document).appendTo(this.parts.title);for(var an=0;an0?U:0)+'px'};ab[X?'right':'left']=(T>0?T:0)+'px';W.setStyles(ab);V&&(ac._.moved=1);};})(),getPosition:function(){return e.extend({},this._.position);},show:function(){var S=this._.element,T=this.definition;if(!(S.getParent()&&S.getParent().equals(a.document.getBody())))S.appendTo(a.document.getBody());else S.setStyle('display','block');if(b.gecko&&b.version<10900){var U=this.parts.dialog;U.setStyle('position','absolute');setTimeout(function(){U.setStyle('position','fixed');},0);}this.resize(this._.contentSize&&this._.contentSize.width||T.width||T.minWidth,this._.contentSize&&this._.contentSize.height||T.height||T.minHeight);this.reset(); @@ -108,40 +109,41 @@ W&&W.unlock(true);}}else a.dialog._.currentZIndex-=10;delete this._.parentDialog var U=T.contents;for(var V=0,W;W=U[V];V++)U[V]=W&&new z(S,W);e.extend(this,T);};y.prototype={getContents:function(S){return v(this.contents,S);},getButton:function(S){return v(this.buttons,S);},addContents:function(S,T){return w(this.contents,S,T);},addButton:function(S,T){return w(this.buttons,S,T);},removeContents:function(S){x(this.contents,S);},removeButton:function(S){x(this.buttons,S);}};function z(S,T){this._={dialog:S};e.extend(this,T);};z.prototype={get:function(S){return v(this.elements,S,'children');},add:function(S,T){return w(this.elements,S,T,'children');},remove:function(S){x(this.elements,S,'children');}};function A(S){var T=null,U=null,V=S.getElement().getFirst(),W=S.getParentEditor(),X=W.config.dialog_magnetDistance,Y=W.skin.margins||[0,0,0,0];if(typeof X=='undefined')X=20;function Z(ab){var ac=S.getSize(),ad=a.document.getWindow().getViewPaneSize(),ae=ab.data.$.screenX,af=ab.data.$.screenY,ag=ae-T.x,ah=af-T.y,ai,aj;T={x:ae,y:af};U.x+=ag;U.y+=ah;if(U.x+Y[3]ad.width-ac.width-X)ai=ad.width-ac.width+(W.lang.dir=='rtl'?0:Y[1]);else ai=U.x;if(U.y+Y[0]ad.height-ac.height-X)aj=ad.height-ac.height+Y[2];else aj=U.y;S.move(ai,aj,1);ab.data.preventDefault();};function aa(ab){a.document.removeListener('mousemove',Z);a.document.removeListener('mouseup',aa);if(b.ie6Compat){var ac=E.getChild(0).getFrameDocument();ac.removeListener('mousemove',Z);ac.removeListener('mouseup',aa);}};S.parts.title.on('mousedown',function(ab){T={x:ab.data.$.screenX,y:ab.data.$.screenY};a.document.on('mousemove',Z);a.document.on('mouseup',aa);U=S.getPosition();if(b.ie6Compat){var ac=E.getChild(0).getFrameDocument();ac.on('mousemove',Z);ac.on('mouseup',aa);}ab.data.preventDefault();},S);};function B(S){var T=S.definition,U=T.resizable;if(U==0)return;var V=S.getParentEditor(),W,X,Y,Z,aa,ab,ac=e.addFunction(function(af){aa=S.getSize();var ag=S.parts.contents,ah=ag.$.getElementsByTagName('iframe').length;if(ah){ab=h.createFromHtml('

    ');ag.append(ab);}X=aa.height-S.parts.contents.getSize('height',!(b.gecko||b.opera||c&&b.quirks));W=aa.width-S.parts.contents.getSize('width',1);Z={x:af.screenX,y:af.screenY};Y=a.document.getWindow().getViewPaneSize();a.document.on('mousemove',ad);a.document.on('mouseup',ae);if(b.ie6Compat){var ai=E.getChild(0).getFrameDocument();ai.on('mousemove',ad);ai.on('mouseup',ae);}af.preventDefault&&af.preventDefault(); });S.on('load',function(){var af='';if(U==1)af=' cke_resizer_horizontal';else if(U==2)af=' cke_resizer_vertical';var ag=h.createFromHtml('
    ');S.parts.footer.append(ag,1);});V.on('destroy',function(){e.removeFunction(ac);});function ad(af){var ag=V.lang.dir=='rtl',ah=(af.data.$.screenX-Z.x)*(ag?-1:1),ai=af.data.$.screenY-Z.y,aj=aa.width,ak=aa.height,al=aj+ah*(S._.moved?1:2),am=ak+ai*(S._.moved?1:2),an=S._.element.getFirst(),ao=ag&&an.getComputedStyle('right'),ap=S.getPosition();if(ap.y+am>Y.height)am=Y.height-ap.y;if((ag?ao:ap.x)+al>Y.width)al=Y.width-(ag?ao:ap.x);if(U==1||U==3)aj=Math.max(T.minWidth||0,al-W);if(U==2||U==3)ak=Math.max(T.minHeight||0,am-X);S.resize(aj,ak);if(!S._.moved)S.layout();af.data.preventDefault();};function ae(){a.document.removeListener('mouseup',ae);a.document.removeListener('mousemove',ad);if(ab){ab.remove();ab=null;}if(b.ie6Compat){var af=E.getChild(0).getFrameDocument();af.removeListener('mouseup',ae);af.removeListener('mousemove',ad);}};};var C,D={},E;function F(S){S.data.preventDefault(1);};function G(S){var T=a.document.getWindow(),U=S.config,V=U.dialog_backgroundCoverColor||'white',W=U.dialog_backgroundCoverOpacity,X=U.baseFloatZIndex,Y=e.genKey(V,W,X),Z=D[Y];if(!Z){var aa=['
    '];if(b.ie6Compat){var ab=b.isCustomDomain(),ac="";aa.push('');}aa.push('
    ');Z=h.createFromHtml(aa.join(''));Z.setOpacity(W!=undefined?W:0.5);Z.on('keydown',F);Z.on('keypress',F);Z.on('keyup',F);Z.appendTo(a.document.getBody());D[Y]=Z;}else Z.show();E=Z;var ad=function(){var ag=T.getViewPaneSize();Z.setStyles({width:ag.width+'px',height:ag.height+'px'});},ae=function(){var ag=T.getScrollPosition(),ah=a.dialog._.currentTop;Z.setStyles({left:ag.x+'px',top:ag.y+'px'});if(ah)do{var ai=ah.getPosition(); ah.move(ai.x,ai.y);}while(ah=ah._.parentDialog)};C=ad;T.on('resize',ad);ad();if(!(b.mac&&b.webkit))Z.focus();if(b.ie6Compat){var af=function(){ae();arguments.callee.prevScrollHandler.apply(this,arguments);};T.$.setTimeout(function(){af.prevScrollHandler=window.onscroll||(function(){});window.onscroll=af;},0);ae();}};function H(){if(!E)return;var S=a.document.getWindow();E.hide();S.removeListener('resize',C);if(b.ie6Compat)S.$.setTimeout(function(){var T=window.onscroll&&window.onscroll.prevScrollHandler;window.onscroll=T||null;},0);C=null;};function I(){for(var S in D)D[S].remove();D={};};var J={},K=function(S){var T=S.data.$.ctrlKey||S.data.$.metaKey,U=S.data.$.altKey,V=S.data.$.shiftKey,W=String.fromCharCode(S.data.$.keyCode),X=J[(T?'CTRL+':'')+(U?'ALT+':'')+(V?'SHIFT+':'')+W];if(!X||!X.length)return;X=X[X.length-1];X.keydown&&X.keydown.call(X.uiElement,X.dialog,X.key);S.data.preventDefault();},L=function(S){var T=S.data.$.ctrlKey||S.data.$.metaKey,U=S.data.$.altKey,V=S.data.$.shiftKey,W=String.fromCharCode(S.data.$.keyCode),X=J[(T?'CTRL+':'')+(U?'ALT+':'')+(V?'SHIFT+':'')+W];if(!X||!X.length)return;X=X[X.length-1];if(X.keyup){X.keyup.call(X.uiElement,X.dialog,X.key);S.data.preventDefault();}},M=function(S,T,U,V,W){var X=J[U]||(J[U]=[]);X.push({uiElement:S,dialog:T,key:U,keyup:W||S.accessKeyUp,keydown:V||S.accessKeyDown});},N=function(S){for(var T in J){var U=J[T];for(var V=U.length-1;V>=0;V--){if(U[V].dialog==S||U[V].uiElement==S)U.splice(V,1);}if(U.length===0)delete J[T];}},O=function(S,T){if(S._.accessKeyMap[T])S.selectPage(S._.accessKeyMap[T]);},P=function(S,T){},Q={27:1,13:1},R=function(S){if(S.data.getKeystroke() in Q)S.data.stopPropagation();};(function(){k.dialog={uiElement:function(S,T,U,V,W,X,Y){if(arguments.length<4)return;var Z=(V.call?V(T):V)||'div',aa=['<',Z,' '],ab=(W&&W.call?W(T):W)||{},ac=(X&&X.call?X(T):X)||{},ad=(Y&&Y.call?Y.call(this,S,T):Y)||'',ae=this.domId=ac.id||e.getNextId()+'_uiElement',af=this.id=T.id,ag;ac.id=ae;var ah={};if(T.type)ah['cke_dialog_ui_'+T.type]=1;if(T.className)ah[T.className]=1;if(T.disabled)ah.cke_disabled=1;var ai=ac['class']&&ac['class'].split?ac['class'].split(' '):[];for(ag=0;ag=0;ag--){if(ak[ag]==='')ak.splice(ag,1);}if(ak.length>0)ac.style=(ac.style?ac.style+'; ':'')+ak.join('; ');for(ag in ac)aa.push(ag+'="'+e.htmlEncode(ac[ag])+'" ');aa.push('>',ad,'');U.push(aa.join(''));(this._||(this._={})).dialog=S;if(typeof T.isChanged=='boolean')this.isChanged=function(){return T.isChanged;};if(typeof T.isChanged=='function')this.isChanged=T.isChanged;if(typeof T.setValue=='function')this.setValue=e.override(this.setValue,function(an){return function(ao){an.call(this,T.setValue.call(this,ao));};});if(typeof T.getValue=='function')this.getValue=e.override(this.getValue,function(an){return function(){return T.getValue.call(this,an.call(this));};});a.event.implementOn(this);this.registerEvents(T);if(this.accessKeyUp&&this.accessKeyDown&&T.accessKey)M(this,S,'CTRL+'+T.accessKey);var am=this;S.on('load',function(){if(am.getInputElement())am.getInputElement().on('focus',function(){S._.tabBarMode=false;S._.hasFocus=true;am.fire('focus');},am);});if(this.keyboardFocusable){this.tabIndex=T.tabIndex||0;this.focusIndex=S._.focusList.push(this)-1;this.on('focus',function(){S._.currentFocusIndex=am.focusIndex;});}e.extend(this,T);},hbox:function(S,T,U,V,W){if(arguments.length<4)return;this._||(this._={});var X=this._.children=T,Y=W&&W.widths||null,Z=W&&W.height||null,aa={},ab,ac=function(){var ae=['
    ');for(var ac=0;ac');}ab.push('
    0)ab.push('style="',ad.join('; '),'" ');ab.push(' class="cke_dialog_ui_vbox_child">',U[ac],'
    ');return ab.join('');};k.dialog.uiElement.call(this,S,W||{type:'vbox'},V,'div',null,{role:'presentation'},aa);}};})();k.dialog.uiElement.prototype={getElement:function(){return a.document.getById(this.domId);},getInputElement:function(){return this.getElement();},getDialog:function(){return this._.dialog;},setValue:function(S,T){this.getInputElement().setValue(S);!T&&this.fire('change',{value:S});return this;},getValue:function(){return this.getInputElement().getValue();},isChanged:function(){return false;},selectParentTab:function(){var V=this;var S=V.getInputElement(),T=S,U;while((T=T.getParent())&&T.$.className.search('cke_dialog_page_contents')==-1){}if(!T)return V;U=T.getAttribute('name');if(V._.dialog._.currentTabId!=U)V._.dialog.selectPage(U);return V;},focus:function(){this.selectParentTab().getInputElement().focus();return this;},registerEvents:function(S){var T=/^on([A-Z]\w+)/,U,V=function(X,Y,Z,aa){Y.on('load',function(){X.getInputElement().on(Z,aa,X);});};for(var W in S){if(!(U=W.match(T)))continue;if(this.eventProcessors[W])this.eventProcessors[W].call(this,this._.dialog,S[W]);else V(this,this._.dialog,U[1].toLowerCase(),S[W]);}return this;},eventProcessors:{onLoad:function(S,T){S.on('load',T,this);},onShow:function(S,T){S.on('show',T,this);},onHide:function(S,T){S.on('hide',T,this);}},accessKeyDown:function(S,T){this.focus();},accessKeyUp:function(S,T){},disable:function(){var S=this.getElement(),T=this.getInputElement();T.setAttribute('disabled','true');S.addClass('cke_disabled');},enable:function(){var S=this.getElement(),T=this.getInputElement();T.removeAttribute('disabled');S.removeClass('cke_disabled');},isEnabled:function(){return!this.getElement().hasClass('cke_disabled');},isVisible:function(){return this.getInputElement().isVisible();},isFocusable:function(){if(!this.isEnabled()||!this.isVisible())return false;return true;}};k.dialog.hbox.prototype=e.extend(new k.dialog.uiElement(),{getChild:function(S){var T=this;if(arguments.length<1)return T._.children.concat(); -if(!S.splice)S=[S];if(S.length<2)return T._.children[S[0]];else return T._.children[S[0]]&&T._.children[S[0]].getChild?T._.children[S[0]].getChild(S.slice(1,S.length)):null;}},true);k.dialog.vbox.prototype=new k.dialog.hbox();(function(){var S={build:function(T,U,V){var W=U.children,X,Y=[],Z=[];for(var aa=0;aa',T||U.name,'');return V.join('');}};a.style.getStyleText=function(T){var U=T._ST;if(U)return U;U=T.styles;var V=T.attributes&&T.attributes.style||'',W='';if(V.length)V=V.replace(o,';');for(var X in U){var Y=U[X],Z=(X+':'+Y).replace(o,';');if(Y=='inherit')W+=Z;else V+=Z;}if(V.length)V=P(V);V+=W;return T._ST=V;};function s(T){var U,V;while(T=T.getParent()){if(T.getName()=='body')break;if(T.getAttribute('data-nostyle'))U=T;else if(!V){var W=T.getAttribute('contentEditable');if(W=='false')U=T;else if(W=='true')V=1;}}return U;};function t(T){var ax=this;var U=T.document;if(T.collapsed){var V=J(ax,U);T.insertNode(V);T.moveToPosition(V,2);return;}var W=ax.element,X=ax._.definition,Y,Z=X.includeReadonly;if(Z==undefined)Z=U.getCustomData('cke_includeReadonly');var aa=f[W]||(Y=true,f.span);T.enlarge(1,1);T.trim();var ab=T.createBookmark(),ac=ab.startNode,ad=ab.endNode,ae=ac,af,ag=s(ac),ah=s(ad);if(ag)ae=ag.getNextSourceNode(true);if(ah)ad=ah;if(ae.getPosition(ad)==2)ae=0;while(ae){var ai=false;if(ae.equals(ad)){ae=null;ai=true;}else{var aj=ae.type,ak=aj==1?ae.getName():null,al=ak&&ae.getAttribute('contentEditable')=='false',am=ak&&ae.getAttribute('data-nostyle');if(ak&&ae.data('cke-bookmark')){ae=ae.getNextSourceNode(true);continue;}if(!ak||aa[ak]&&!am&&(!al||Z)&&(ae.getPosition(ad)|4|0|8)==4+0+8&&(!X.childRule||X.childRule(ae))){var an=ae.getParent();if(an&&((an.getDtd()||f.span)[W]||Y)&&(!X.parentRule||X.parentRule(an))){if(!af&&(!ak||!f.$removeEmpty[ak]||(ae.getPosition(ad)|4|0|8)==4+0+8)){af=new d.range(U); -af.setStartBefore(ae);}if(aj==3||al||aj==1&&!ae.getChildCount()){var ao=ae,ap;while((ai=!ao.getNext(q))&&(ap=ao.getParent(),aa[ap.getName()])&&(ap.getPosition(ac)|2|0|8)==2+0+8&&(!X.childRule||X.childRule(ap)))ao=ap;af.setEndAfter(ao);}}else ai=true;}else ai=true;ae=ae.getNextSourceNode(am||al);}if(ai&&af&&!af.collapsed){var aq=J(ax,U),ar=aq.hasAttributes(),as=af.getCommonAncestor(),at={styles:{},attrs:{},blockedStyles:{},blockedAttrs:{}},au,av,aw;while(aq&&as){if(as.getName()==W){for(au in X.attributes){if(at.blockedAttrs[au]||!(aw=as.getAttribute(av)))continue;if(aq.getAttribute(au)==aw)at.attrs[au]=1;else at.blockedAttrs[au]=1;}for(av in X.styles){if(at.blockedStyles[av]||!(aw=as.getStyle(av)))continue;if(aq.getStyle(av)==aw)at.styles[av]=1;else at.blockedStyles[av]=1;}}as=as.getParent();}for(au in at.attrs)aq.removeAttribute(au);for(av in at.styles)aq.removeStyle(av);if(ar&&!aq.hasAttributes())aq=null;if(aq){af.extractContents().appendTo(aq);G(ax,aq);af.insertNode(aq);aq.mergeSiblings();if(!c)aq.$.normalize();}else{aq=new h('span');af.extractContents().appendTo(aq);af.insertNode(aq);G(ax,aq);aq.remove(true);}af=null;}}T.moveToBookmark(ab);T.shrink(2);};function u(T){T.enlarge(1,1);var U=T.createBookmark(),V=U.startNode;if(T.collapsed){var W=new d.elementPath(V.getParent()),X;for(var Y=0,Z;Y'+V+'';else T.setHtml(V);U.remove();};function B(T){var U=/(\S\s*)\n(?:\s|(]+data-cke-bookmark.*?\/span>))*\n(?!$)/gi,V=T.getName(),W=C(T.getOuterHtml(),U,function(Y,Z,aa){return Z+''+aa+'
    ';}),X=[];W.replace(/([\s\S]*?)<\/pre>/gi,function(Y,Z){X.push(Z);});return X;};function C(T,U,V){var W='',X='';T=T.replace(/(^]+data-cke-bookmark.*?\/span>)|(]+data-cke-bookmark.*?\/span>$)/gi,function(Y,Z,aa){Z&&(W=Z);aa&&(X=aa);return '';});return W+T.replace(U,V)+X;};function D(T,U){var V;if(T.length>1)V=new d.documentFragment(U.getDocument());for(var W=0;W');X=X.replace(/[ \t]{2,}/g,function(Z){return e.repeat(' ',Z.length-1)+' ';
    -});if(V){var Y=U.clone();Y.setHtml(X);V.append(Y);}else U.setHtml(X);}return V||U;};function E(T,U){var V=T.getBogus();V&&V.remove();var W=T.getHtml();W=C(W,/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,'');W=W.replace(/[ \t\r\n]*(]*>)[ \t\r\n]*/gi,'$1');W=W.replace(/([ \t\n\r]+| )/g,' ');W=W.replace(/]*>/gi,'\n');if(c){var X=T.getDocument().createElement('div');X.append(U);U.$.outerHTML='
    '+W+'
    ';U.copyAttributes(X.getFirst());U=X.getFirst().remove();}else U.setHtml(W);return U;};function F(T,U){var V=T._.definition,W=e.extend({},V.attributes,N(T)[U.getName()]),X=V.styles,Y=e.isEmpty(W)&&e.isEmpty(X);for(var Z in W){if((Z=='class'||T._.definition.fullMatch)&&U.getAttribute(Z)!=O(Z,W[Z]))continue;Y=U.hasAttribute(Z);U.removeAttribute(Z);}for(var aa in X){if(T._.definition.fullMatch&&U.getStyle(aa)!=O(aa,X[aa],true))continue;Y=Y||!!U.getStyle(aa);U.removeStyle(aa);}if(Y)!f.$block[U.getName()]||T._.enterMode==2&&!U.hasAttributes()?I(U):U.renameNode(T._.enterMode==1?'p':'div');};function G(T,U){var V=T._.definition,W=V.attributes,X=V.styles,Y=N(T),Z=U.getElementsByTag(T.element);for(var aa=Z.count();--aa>=0;)F(T,Z.getItem(aa));for(var ab in Y){if(ab!=T.element){Z=U.getElementsByTag(ab);for(aa=Z.count()-1;aa>=0;aa--){var ac=Z.getItem(aa);H(ac,Y[ab]);}}}};function H(T,U){var V=U&&U.attributes;if(V)for(var W=0;W0)H+=(F.$.offsetWidth||0)-(F.$.clientWidth||0)+3;H+=4;F.setStyle('width',H+'px');v.element.addClass('cke_frameLoaded');var I=v.element.$.scrollHeight;if(c&&b.quirks&&I>0)I+=(F.$.offsetHeight||0)-(F.$.clientHeight||0)+3;F.setStyle('height',I+'px');u._.currentBlock.element.setStyle('display','none').removeStyle('display');}else F.removeStyle('height');var J=u.element,K=J.getWindow(),L=K.getScrollPosition(),M=K.getViewPaneSize(),N={height:J.$.offsetHeight,width:J.$.offsetWidth};if(A?B<0:B+N.width>M.width+L.x)B+=N.width*(A?1:-1);if(C+N.height>M.height+L.y)C-=N.height;if(c){var O=new h(w.$.offsetParent),P=O;if(P.getName()=='html')P=P.getDocument().getBody();if(P.getComputedStyle('direction')=='rtl')if(b.ie8Compat)B-=w.getDocument().getDocumentElement().$.scrollLeft*2;else B-=O.$.scrollWidth-O.$.clientWidth;}var Q=w.getFirst(),R;if(R=Q.getCustomData('activePanel'))R.onHide&&R.onHide.call(this,1);Q.setCustomData('activePanel',this); -w.setStyles({top:C+'px',left:B+'px'});w.setOpacity(1);},this);u.isLoaded?E():u.onLoad=E;e.setTimeout(function(){x.$.contentWindow.focus();this.allowBlur(true);},0,this);},b.air?200:0,this);this.visible=1;if(this.onShow)this.onShow.call(this);n=0;},hide:function(p){var r=this;if(r.visible&&(!r.onHide||r.onHide.call(r)!==true)){r.hideChild();b.gecko&&r._.iframe.getFrameDocument().$.activeElement.blur();r.element.setStyle('display','none');r.visible=0;r.element.getFirst().removeCustomData('activePanel');var q=p!==false&&r._.returnFocus;if(q){if(b.webkit&&q.type)q.getWindow().$.focus();q.focus();}}},allowBlur:function(p){var q=this._.panel;if(p!=undefined)q.allowBlur=p;return q.allowBlur;},showAsChild:function(p,q,r,s,t,u){if(this._.activeChild==p&&p._.panel._.offsetParentId==r.getId())return;this.hideChild();p.onHide=e.bind(function(){e.setTimeout(function(){if(!this._.focused)this.hide();},0,this);},this);this._.activeChild=p;this._.focused=false;p.showBlock(q,r,s,t,u);if(b.ie7Compat||b.ie8&&b.ie6Compat)setTimeout(function(){p.element.getChild(0).$.style.cssText+='';},100);},hideChild:function(){var p=this._.activeChild;if(p){delete p.onHide;delete p._.returnFocus;delete this._.activeChild;p.hide();}}}});a.on('instanceDestroyed',function(){var p=e.isEmpty(a.instances);for(var q in m){var r=m[q];if(p)r.destroy();else r.element.hide();}p&&(m={});});})();j.add('menu',{beforeInit:function(m){var n=m.config.menu_groups.split(','),o=m._.menuGroups={},p=m._.menuItems={};for(var q=0;q'],B=r.length,C=B&&r[0].group;for(var D=0;D'); -C=E.group;}E.render(this,D,A);}A.push('');u.setHtml(A.join(''));k.fire('ready',this);if(this.parent)this.parent._.panel.showAsChild(t,this.id,n,o,p,q);else t.showBlock(this.id,n,o,p,q);s.fire('menuShow',[t]);},addListener:function(n){this._.listeners.push(n);},hide:function(n){var o=this;o._.onHide&&o._.onHide();o._.panel&&o._.panel.hide(n);}}});function m(n){n.sort(function(o,p){if(o.groupp.group)return 1;return o.orderp.order?1:0;});};a.menuItem=e.createClass({$:function(n,o,p){var q=this;e.extend(q,p,{order:0,className:'cke_button_'+o});q.group=n._.menuGroups[q.group];q.editor=n;q.name=o;},proto:{render:function(n,o,p){var w=this;var q=n.id+String(o),r=typeof w.state=='undefined'?2:w.state,s=' cke_'+(r==1?'on':r==0?'disabled':'off'),t=w.label;if(w.className)s+=' '+w.className;var u=w.getItems;p.push(''+''+'');if(u)p.push('','&#',w.editor.lang.dir=='rtl'?'9668':'9658',';','');p.push(t,'');}}});})();i.menu_groups='clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea,div';(function(){var m;j.add('editingblock',{init:function(n){if(!n.config.editingBlock)return;n.on('themeSpace',function(o){if(o.data.space=='contents')o.data.html+='
    ';});n.on('themeLoaded',function(){n.fireOnce('editingBlockReady');});n.on('uiReady',function(){n.setMode(n.config.startupMode); -});n.on('afterSetData',function(){if(!m){function o(){m=true;n.getMode().loadData(n.getData());m=false;};if(n.mode)o();else n.on('mode',function(){if(n.mode){o();n.removeListener('mode',arguments.callee);}});}});n.on('beforeGetData',function(){if(!m&&n.mode){m=true;n.setData(n.getMode().getData(),null,1);m=false;}});n.on('getSnapshot',function(o){if(n.mode)o.data=n.getMode().getSnapshotData();});n.on('loadSnapshot',function(o){if(n.mode)n.getMode().loadSnapshotData(o.data);});n.on('mode',function(o){o.removeListener();b.webkit&&n.container.on('focus',function(){n.focus();});if(n.config.startupFocus)n.focus();setTimeout(function(){n.fireOnce('instanceReady');a.fire('instanceReady',null,n);},0);});n.on('destroy',function(){var o=this;if(o.mode)o._.modes[o.mode].unload(o.getThemeSpace('contents'));});}});a.editor.prototype.mode='';a.editor.prototype.addMode=function(n,o){o.name=n;(this._.modes||(this._.modes={}))[n]=o;};a.editor.prototype.setMode=function(n){this.fire('beforeSetMode',{newMode:n});var o,p=this.getThemeSpace('contents'),q=this.checkDirty();if(this.mode){if(n==this.mode)return;this.fire('beforeModeUnload');var r=this.getMode();o=r.getData();r.unload(p);this.mode='';}p.setHtml('');var s=this.getMode(n);if(!s)throw '[CKEDITOR.editor.setMode] Unknown mode "'+n+'".';if(!q)this.on('mode',function(){this.resetDirty();this.removeListener('mode',arguments.callee);});s.load(p,typeof o!='string'?this.getData():o);};a.editor.prototype.getMode=function(n){return this._.modes&&this._.modes[n||this.mode];};a.editor.prototype.focus=function(){this.forceNextSelectionCheck();var n=this.getMode();if(n)n.focus();};})();i.startupMode='wysiwyg';i.editingBlock=true;(function(){function m(){var B=this;try{var y=B.getSelection();if(!y||!y.document.getWindow().$)return;var z=y.getStartElement(),A=new d.elementPath(z);if(!A.compare(B._.selectionPreviousPath)){B._.selectionPreviousPath=A;B.fire('selectionChange',{selection:y,path:A,element:z});}}catch(C){}};var n,o;function p(){o=true;if(n)return;q.call(this);n=e.setTimeout(q,200,this);};function q(){n=null;if(o){e.setTimeout(m,0,this);o=false;}};function r(y){function z(D){return D&&D.type==1&&D.getName() in f.$removeEmpty;};function A(D){var E=y.document.getBody();return!D.is('body')&&E.getChildCount()==1;};var B=y.startContainer,C=y.startOffset;if(B.type==3)return false;return!e.trim(B.getHtml())?z(B)||A(B):z(B.getChild(C-1))||z(B.getChild(C));};var s={modes:{wysiwyg:1,source:1},readOnly:c||b.webkit,exec:function(y){switch(y.mode){case 'wysiwyg':y.document.$.execCommand('SelectAll',false,null); -y.forceNextSelectionCheck();y.selectionChange();break;case 'source':var z=y.textarea.$;if(c)z.createTextRange().execCommand('SelectAll');else{z.selectionStart=0;z.selectionEnd=z.value.length;}z.focus();}},canUndo:false};function t(y){w(y);var z=y.createText('​');y.setCustomData('cke-fillingChar',z);return z;};function u(y){return y&&y.getCustomData('cke-fillingChar');};function v(y){var z=y&&u(y);if(z)if(z.getCustomData('ready'))w(y);else z.setCustomData('ready',1);};function w(y){var z=y&&y.removeCustomData('cke-fillingChar');if(z){z.setText(z.getText().replace(/\u200B/g,''));z=0;}};j.add('selection',{init:function(y){if(b.webkit){y.on('selectionChange',function(){v(y.document);});y.on('beforeSetMode',function(){w(y.document);});y.on('key',function(D){switch(D.data.keyCode){case 13:case 2228224+13:case 37:case 39:case 8:w(y.document);}},null,null,10);var z,A;function B(){var D=y.document,E=u(D);if(E){var F=D.$.defaultView.getSelection();if(F.type=='Caret'&&F.anchorNode==E.$)A=1;z=E.getText();E.setText(z.replace(/\u200B/g,''));}};function C(){var D=y.document,E=u(D);if(E){E.setText(z);if(A){D.$.defaultView.getSelection().setPosition(E.$,E.getLength());A=0;}}};y.on('beforeUndoImage',B);y.on('afterUndoImage',C);y.on('beforeGetData',B,null,null,0);y.on('getData',C);}y.on('contentDom',function(){var D=y.document,E=D.getBody(),F=D.getDocumentElement();if(c){var G,H,I=1;E.on('focusin',function(M){if(M.data.$.srcElement.nodeName!='BODY')return;if(G){if(I){try{G.select();}catch(O){}var N=D.getCustomData('cke_locked_selection');if(N){N.unlock();N.lock();}}G=null;}});E.on('focus',function(){H=1;L();});E.on('beforedeactivate',function(M){if(M.data.$.toElement)return;H=0;I=1;});if(c&&b.version<8)y.on('blur',function(M){try{y.document&&y.document.$.selection.empty();}catch(N){}});F.on('mousedown',function(){I=0;});F.on('mouseup',function(){I=1;});if(c&&(b.ie7Compat||b.version<8||b.quirks))F.on('click',function(M){if(M.data.getTarget().getName()=='html')y.getSelection().getRanges()[0].select();});var J;E.on('mousedown',function(M){if(M.data.$.button==2){var N=y.document.$.selection;if(N.type=='None')J=y.window.getScrollPosition();}K();});E.on('mouseup',function(M){if(M.data.$.button==2&&J){y.document.$.documentElement.scrollLeft=J.x;y.document.$.documentElement.scrollTop=J.y;}J=null;H=1;setTimeout(function(){L(true);},0);});E.on('keydown',K);E.on('keyup',function(){H=1;L();});D.on('selectionchange',L);function K(){H=0;};function L(M){if(H){var N=y.document,O=y.getSelection(),P=O&&O.getNative(); -if(M&&P&&P.type=='None')if(!N.$.queryCommandEnabled('InsertImage')){e.setTimeout(L,50,this,true);return;}var Q;if(P&&P.type&&P.type!='Control'&&(Q=P.createRange())&&(Q=Q.parentElement())&&(Q=Q.nodeName)&&Q.toLowerCase() in {input:1,textarea:1})return;G=P&&O.getRanges()[0];p.call(y);}};}else{D.on('mouseup',p,y);D.on('keyup',p,y);}});y.on('contentDomUnload',y.forceNextSelectionCheck,y);y.addCommand('selectAll',s);y.ui.addButton('SelectAll',{label:y.lang.selectAll,command:'selectAll'});y.selectionChange=p;b.ie9Compat&&y.on('destroy',function(){var D=y.getSelection();D&&D.getNative().clear();},null,null,9);}});a.editor.prototype.getSelection=function(){return this.document&&this.document.getSelection();};a.editor.prototype.forceNextSelectionCheck=function(){delete this._.selectionPreviousPath;};g.prototype.getSelection=function(){var y=new d.selection(this);return!y||y.isInvalid?null:y;};a.SELECTION_NONE=1;a.SELECTION_TEXT=2;a.SELECTION_ELEMENT=3;d.selection=function(y){var B=this;var z=y.getCustomData('cke_locked_selection');if(z)return z;B.document=y;B.isLocked=0;B._={cache:{}};if(c){var A=B.getNative().createRange();if(!A||A.item&&A.item(0).ownerDocument!=B.document.$||A.parentElement&&A.parentElement().ownerDocument!=B.document.$)B.isInvalid=true;}return B;};var x={img:1,hr:1,li:1,table:1,tr:1,td:1,th:1,embed:1,object:1,ol:1,ul:1,a:1,input:1,form:1,select:1,textarea:1,button:1,fieldset:1,thead:1,tfoot:1};d.selection.prototype={getNative:c?function(){return this._.cache.nativeSel||(this._.cache.nativeSel=this.document.$.selection);}:function(){return this._.cache.nativeSel||(this._.cache.nativeSel=this.document.getWindow().$.getSelection());},getType:c?function(){var y=this._.cache;if(y.type)return y.type;var z=1;try{var A=this.getNative(),B=A.type;if(B=='Text')z=2;if(B=='Control')z=3;if(A.createRange().parentElement)z=2;}catch(C){}return y.type=z;}:function(){var y=this._.cache;if(y.type)return y.type;var z=2,A=this.getNative();if(!A)z=1;else if(A.rangeCount==1){var B=A.getRangeAt(0),C=B.startContainer;if(C==B.endContainer&&C.nodeType==1&&B.endOffset-B.startOffset==1&&x[C.childNodes[B.startOffset].nodeName.toLowerCase()])z=3;}return y.type=z;},getRanges:(function(){var y=c?(function(){function z(B){return new d.node(B).getIndex();};var A=function(B,C){B=B.duplicate();B.collapse(C);var D=B.parentElement(),E=D.ownerDocument;if(!D.hasChildNodes())return{container:D,offset:0};var F=D.children,G,H,I=B.duplicate(),J=0,K=F.length-1,L=-1,M,N;while(J<=K){L=Math.floor((J+K)/2); -G=F[L];I.moveToElementText(G);M=I.compareEndPoints('StartToStart',B);if(M>0)K=L-1;else if(M<0)J=L+1;else if(b.ie9Compat&&G.tagName=='BR'){var O='cke_range_marker';B.execCommand('CreateBookmark',false,O);G=E.getElementsByName(O)[0];var P=z(G);D.removeChild(G);return{container:D,offset:P};}else return{container:D,offset:z(G)};}if(L==-1||L==F.length-1&&M<0){I.moveToElementText(D);I.setEndPoint('StartToStart',B);N=I.text.replace(/(\r\n|\r)/g,'\n').length;F=D.childNodes;if(!N){G=F[F.length-1];if(G.nodeType==1)return{container:D,offset:F.length};else return{container:G,offset:G.nodeValue.length};}var Q=F.length;while(N>0)N-=F[--Q].nodeValue.length;return{container:F[Q],offset:-N};}else{I.collapse(M>0?true:false);I.setEndPoint(M>0?'StartToStart':'EndToStart',B);N=I.text.replace(/(\r\n|\r)/g,'\n').length;if(!N)return{container:D,offset:z(G)+(M>0?0:1)};while(N>0)try{H=G[M>0?'previousSibling':'nextSibling'];N-=H.nodeValue.length;G=H;}catch(R){return{container:D,offset:z(G)};}return{container:G,offset:M>0?-N:G.nodeValue.length+N};}};return function(){var L=this;var B=L.getNative(),C=B&&B.createRange(),D=L.getType(),E;if(!B)return[];if(D==2){E=new d.range(L.document);var F=A(C,true);E.setStart(new d.node(F.container),F.offset);F=A(C);E.setEnd(new d.node(F.container),F.offset);if(E.endContainer.getPosition(E.startContainer)&4&&E.endOffset<=E.startContainer.getIndex())E.collapse();return[E];}else if(D==3){var G=[];for(var H=0;H=F.getLength())J.setStartAfter(F);else J.setStartBefore(F);if(G&&G.type==3)if(!I)J.setEndBefore(G); -else J.setEndAfter(G);var L=new d.walker(J);L.evaluator=function(M){if(M.type==1&&M.isReadOnly()){var N=D.clone();D.setEndBefore(M);if(D.collapsed)B.splice(C--,1);if(!(M.getPosition(J.endContainer)&16)){N.setStartAfter(M);if(!N.collapsed)B.splice(C+1,0,N);}return true;}return false;};L.next();}}return A.ranges;};})(),getStartElement:function(){var F=this;var y=F._.cache;if(y.startElement!==undefined)return y.startElement;var z,A=F.getNative();switch(F.getType()){case 3:return F.getSelectedElement();case 2:var B=F.getRanges()[0];if(B){if(!B.collapsed){B.optimize();while(1){var C=B.startContainer,D=B.startOffset;if(D==(C.getChildCount?C.getChildCount():C.getLength())&&!C.isBlockBoundary())B.setStartAfter(C);else break;}z=B.startContainer;if(z.type!=1)return z.getParent();z=z.getChild(B.startOffset);if(!z||z.type!=1)z=B.startContainer;else{var E=z.getFirst();while(E&&E.type==1){z=E;E=E.getFirst();}}}else{z=B.startContainer;if(z.type!=1)z=z.getParent();}z=z.$;}}return y.startElement=z?new h(z):null;},getSelectedElement:function(){var y=this._.cache;if(y.selectedElement!==undefined)return y.selectedElement;var z=this,A=e.tryThese(function(){return z.getNative().createRange().item(0);},function(){var B=z.getRanges()[0],C,D;for(var E=2;E&&!((C=B.getEnclosedNode())&&C.type==1&&x[C.getName()]&&(D=C));E--)B.shrink(1);return D.$;});return y.selectedElement=A?new h(A):null;},getSelectedText:function(){var y=this._.cache;if(y.selectedText!==undefined)return y.selectedText;var z='',A=this.getNative();if(this.getType()==2)z=c?A.createRange().text:A.toString();return y.selectedText=z;},lock:function(){var y=this;y.getRanges();y.getStartElement();y.getSelectedElement();y.getSelectedText();y._.cache.nativeSel={};y.isLocked=1;y.document.setCustomData('cke_locked_selection',y);},unlock:function(y){var D=this;var z=D.document,A=z.getCustomData('cke_locked_selection');if(A){z.setCustomData('cke_locked_selection',null);if(y){var B=A.getSelectedElement(),C=!B&&A.getRanges();D.isLocked=0;D.reset();z.getBody().focus();if(B)D.selectElement(B);else D.selectRanges(C);}}if(!A||!y){D.isLocked=0;D.reset();}},reset:function(){this._.cache={};},selectElement:function(y){var A=this;if(A.isLocked){var z=new d.range(A.document);z.setStartBefore(y);z.setEndAfter(y);A._.cache.selectedElement=y;A._.cache.startElement=y;A._.cache.ranges=new d.rangeList(z);A._.cache.type=3;return;}z=new d.range(y.getDocument());z.setStartBefore(y);z.setEndAfter(y);z.select();A.document.fire('selectionchange');A.reset(); -},selectRanges:function(y){var M=this;if(M.isLocked){M._.cache.selectedElement=null;M._.cache.startElement=y[0]&&y[0].getTouchedStartNode();M._.cache.ranges=new d.rangeList(y);M._.cache.type=2;return;}if(c){if(y.length>1){var z=y[y.length-1];y[0].setEnd(z.endContainer,z.endOffset);y.length=1;}if(y[0])y[0].select();M.reset();}else{var A=M.getNative();if(!A)return;if(y.length){A.removeAllRanges();b.webkit&&w(M.document);}for(var B=0;B=0){H.collapse(1);I.setEnd(H.endContainer.$,H.endOffset);}else throw N;}A.addRange(I);}M.reset();}},createBookmarks:function(y){return this.getRanges().createBookmarks(y);},createBookmarks2:function(y){return this.getRanges().createBookmarks2(y);},selectBookmarks:function(y){var z=[];for(var A=0;A','','',this.label,'','=10900&&!o.hc?'':" href=\"javascript:void('"+this.label+"')\"",' role="button" aria-labelledby="',p,'_label" aria-describedby="',p,'_text" aria-haspopup="true"');if(b.opera||b.gecko&&b.mac)n.push(' onkeypress="return false;"');if(b.gecko)n.push(' onblur="this.style.cssText = this.style.cssText;"');n.push(' onkeydown="CKEDITOR.tools.callFunction( ',t,', event, this );" onfocus="return CKEDITOR.tools.callFunction(',u,', event);" '+(c?'onclick="return false;" onmouseup':'onclick')+'="CKEDITOR.tools.callFunction(',q,', this); return false;">'+this.label+''+''+''+(b.hc?'▼':b.air?' ':'')+''+''+''+''); -if(this.onRender)this.onRender();return r;},createPanel:function(m){if(this._.panel)return;var n=this._.panelDefinition,o=this._.panelDefinition.block,p=n.parent||a.document.getBody(),q=new k.floatPanel(m,p,n),r=q.addListBlock(this.id,o),s=this;q.onShow=function(){if(s.className)this.element.getFirst().addClass(s.className+'_panel');s.setState(1);r.focus(!s.multiSelect&&s.getValue());s._.on=1;if(s.onOpen)s.onOpen();};q.onHide=function(t){if(s.className)this.element.getFirst().removeClass(s.className+'_panel');s.setState(s.modes&&s.modes[m.mode]?2:0);s._.on=0;if(!t&&s.onClose)s.onClose();};q.onEscape=function(){q.hide();};r.onClick=function(t,u){s.document.getWindow().focus();if(s.onClick)s.onClick.call(s,t,u);if(u)s.setValue(t,s._.items[t]);else s.setValue('');q.hide(false);};this._.panel=q;this._.list=r;q.getBlock(this.id).onHide=function(){s._.on=0;s.setState(2);};if(this.init)this.init();},setValue:function(m,n){var p=this;p._.value=m;var o=p.document.getById('cke_'+p.id+'_text');if(o){if(!(m||n)){n=p.label;o.addClass('cke_inline_label');}else o.removeClass('cke_inline_label');o.setHtml(typeof n!='undefined'?n:m);}},getValue:function(){return this._.value||'';},unmarkAll:function(){this._.list.unmarkAll();},mark:function(m){this._.list.mark(m);},hideItem:function(m){this._.list.hideItem(m);},hideGroup:function(m){this._.list.hideGroup(m);},showAll:function(){this._.list.showAll();},add:function(m,n,o){this._.items[m]=o||m;this._.list.add(m,n,o);},startGroup:function(m){this._.list.startGroup(m);},commit:function(){var m=this;if(!m._.committed){m._.list.commit();m._.committed=1;k.fire('ready',m);}m._.committed=1;},setState:function(m){var n=this;if(n._.state==m)return;n.document.getById('cke_'+n.id).setState(m);n._.state=m;}}});k.prototype.addRichCombo=function(m,n){this.add(m,'richcombo',n);};j.add('htmlwriter');a.htmlWriter=e.createClass({base:a.htmlParser.basicWriter,$:function(){var o=this;o.base();o.indentationChars='\t';o.selfClosingEnd=' />';o.lineBreakChars='\n';o.forceSimpleAmpersand=0;o.sortAttributes=1;o._.indent=0;o._.indentation='';o._.inPre=0;o._.rules={};var m=f;for(var n in e.extend({},m.$nonBodyContent,m.$block,m.$listItem,m.$tableContent))o.setRules(n,{indent:1,breakBeforeOpen:1,breakAfterOpen:1,breakBeforeClose:!m[n]['#'],breakAfterClose:1});o.setRules('br',{breakAfterOpen:1});o.setRules('title',{indent:0,breakAfterOpen:0});o.setRules('style',{indent:0,breakBeforeClose:1});o.setRules('pre',{indent:0});},proto:{openTag:function(m,n){var p=this; -var o=p._.rules[m];if(p._.indent)p.indentation();else if(o&&o.breakBeforeOpen){p.lineBreak();p.indentation();}p._.output.push('<',m);},openTagClose:function(m,n){var p=this;var o=p._.rules[m];if(n)p._.output.push(p.selfClosingEnd);else{p._.output.push('>');if(o&&o.indent)p._.indentation+=p.indentationChars;}if(o&&o.breakAfterOpen)p.lineBreak();m=='pre'&&(p._.inPre=1);},attribute:function(m,n){if(typeof n=='string'){this.forceSimpleAmpersand&&(n=n.replace(/&/g,'&'));n=e.htmlEncodeAttr(n);}this._.output.push(' ',m,'="',n,'"');},closeTag:function(m){var o=this;var n=o._.rules[m];if(n&&n.indent)o._.indentation=o._.indentation.substr(o.indentationChars.length);if(o._.indent)o.indentation();else if(n&&n.breakBeforeClose){o.lineBreak();o.indentation();}o._.output.push('');m=='pre'&&(o._.inPre=0);if(n&&n.breakAfterClose)o.lineBreak();},text:function(m){var n=this;if(n._.indent){n.indentation();!n._.inPre&&(m=e.ltrim(m));}n._.output.push(m);},comment:function(m){if(this._.indent)this.indentation();this._.output.push('');},lineBreak:function(){var m=this;if(!m._.inPre&&m._.output.length>0)m._.output.push(m.lineBreakChars);m._.indent=1;},indentation:function(){var m=this;if(!m._.inPre)m._.output.push(m._.indentation);m._.indent=0;},setRules:function(m,n){var o=this._.rules[m];if(o)e.extend(o,n,true);else this._.rules[m]=n;}}});j.add('menubutton',{requires:['button','menu'],beforeInit:function(m){m.ui.addHandler('menubutton',k.menuButton.handler);}});a.UI_MENUBUTTON='menubutton';(function(){var m=function(n){var o=this._;if(o.state===0)return;o.previousState=o.state;var p=o.menu;if(!p){p=o.menu=new a.menu(n,{panel:{className:n.skinClass+' cke_contextmenu',attributes:{'aria-label':n.lang.common.options}}});p.onHide=e.bind(function(){this.setState(this.modes&&this.modes[n.mode]?o.previousState:0);},this);if(this.onMenu)p.addListener(this.onMenu);}if(o.on){p.hide();return;}this.setState(1);p.show(a.document.getById(this._.id),4);};k.menuButton=e.createClass({base:k.button,$:function(n){var o=n.panel;delete n.panel;this.base(n);this.hasArrow=true;this.click=m;},statics:{handler:{create:function(n){return new k.menuButton(n);}}}});})();j.add('dialogui');(function(){var m=function(u){var x=this;x._||(x._={});x._['default']=x._.initValue=u['default']||'';x._.required=u.required||false;var v=[x._];for(var w=1;w',v.label,'','');else{var D={type:'hbox',widths:v.widths,padding:0,children:[{type:'html',html:'
    ');for(var ac=0;ac');}ab.push('
    0)ab.push('style="',ad.join('; '),'" ');ab.push(' class="cke_dialog_ui_vbox_child">',U[ac],'
    ');return ab.join('');};k.dialog.uiElement.call(this,S,W||{type:'vbox'},V,'div',null,{role:'presentation'},aa);}};})();k.dialog.uiElement.prototype={getElement:function(){return a.document.getById(this.domId);},getInputElement:function(){return this.getElement();},getDialog:function(){return this._.dialog;},setValue:function(S,T){this.getInputElement().setValue(S);!T&&this.fire('change',{value:S});return this;},getValue:function(){return this.getInputElement().getValue();},isChanged:function(){return false;},selectParentTab:function(){var V=this;var S=V.getInputElement(),T=S,U;while((T=T.getParent())&&T.$.className.search('cke_dialog_page_contents')==-1){}if(!T)return V;U=T.getAttribute('name');if(V._.dialog._.currentTabId!=U)V._.dialog.selectPage(U);return V;},focus:function(){this.selectParentTab().getInputElement().focus();return this;},registerEvents:function(S){var T=/^on([A-Z]\w+)/,U,V=function(X,Y,Z,aa){Y.on('load',function(){X.getInputElement().on(Z,aa,X);});};for(var W in S){if(!(U=W.match(T)))continue;if(this.eventProcessors[W])this.eventProcessors[W].call(this,this._.dialog,S[W]);else V(this,this._.dialog,U[1].toLowerCase(),S[W]);}return this;},eventProcessors:{onLoad:function(S,T){S.on('load',T,this);},onShow:function(S,T){S.on('show',T,this);},onHide:function(S,T){S.on('hide',T,this);}},accessKeyDown:function(S,T){this.focus();},accessKeyUp:function(S,T){},disable:function(){var S=this.getElement(),T=this.getInputElement();T.setAttribute('disabled','true');S.addClass('cke_disabled');},enable:function(){var S=this.getElement(),T=this.getInputElement();T.removeAttribute('disabled');S.removeClass('cke_disabled');},isEnabled:function(){return!this.getElement().hasClass('cke_disabled');},isVisible:function(){return this.getInputElement().isVisible();},isFocusable:function(){if(!this.isEnabled()||!this.isVisible())return false; +return true;}};k.dialog.hbox.prototype=e.extend(new k.dialog.uiElement(),{getChild:function(S){var T=this;if(arguments.length<1)return T._.children.concat();if(!S.splice)S=[S];if(S.length<2)return T._.children[S[0]];else return T._.children[S[0]]&&T._.children[S[0]].getChild?T._.children[S[0]].getChild(S.slice(1,S.length)):null;}},true);k.dialog.vbox.prototype=new k.dialog.hbox();(function(){var S={build:function(T,U,V){var W=U.children,X,Y=[],Z=[];for(var aa=0;aa',T||U.name,'');return V.join('');}};a.style.getStyleText=function(T){var U=T._ST;if(U)return U;U=T.styles;var V=T.attributes&&T.attributes.style||'',W='';if(V.length)V=V.replace(o,';');for(var X in U){var Y=U[X],Z=(X+':'+Y).replace(o,';');if(Y=='inherit')W+=Z;else V+=Z;}if(V.length)V=P(V);V+=W;return T._ST=V;};function s(T){var U,V;while(T=T.getParent()){if(T.getName()=='body')break;if(T.getAttribute('data-nostyle'))U=T;else if(!V){var W=T.getAttribute('contentEditable');if(W=='false')U=T;else if(W=='true')V=1;}}return U;};function t(T){var ay=this;var U=T.document;if(T.collapsed){var V=J(ay,U);T.insertNode(V);T.moveToPosition(V,2);return;}var W=ay.element,X=ay._.definition,Y,Z=X.ignoreReadonly,aa=Z||X.includeReadonly;if(aa==undefined)aa=U.getCustomData('cke_includeReadonly');var ab=f[W]||(Y=true,f.span);T.enlarge(1,1);T.trim();var ac=T.createBookmark(),ad=ac.startNode,ae=ac.endNode,af=ad,ag;if(!Z){var ah=s(ad),ai=s(ae);if(ah)af=ah.getNextSourceNode(true);if(ai)ae=ai;}if(af.getPosition(ae)==2)af=0;while(af){var aj=false;if(af.equals(ae)){af=null;aj=true;}else{var ak=af.type,al=ak==1?af.getName():null,am=al&&af.getAttribute('contentEditable')=='false',an=al&&af.getAttribute('data-nostyle'); +if(al&&af.data('cke-bookmark')){af=af.getNextSourceNode(true);continue;}if(!al||ab[al]&&!an&&(!am||aa)&&(af.getPosition(ae)|4|0|8)==4+0+8&&(!X.childRule||X.childRule(af))){var ao=af.getParent();if(ao&&((ao.getDtd()||f.span)[W]||Y)&&(!X.parentRule||X.parentRule(ao))){if(!ag&&(!al||!f.$removeEmpty[al]||(af.getPosition(ae)|4|0|8)==4+0+8)){ag=new d.range(U);ag.setStartBefore(af);}if(ak==3||am||ak==1&&!af.getChildCount()){var ap=af,aq;while((aj=!ap.getNext(q))&&(aq=ap.getParent(),ab[aq.getName()])&&(aq.getPosition(ad)|2|0|8)==2+0+8&&(!X.childRule||X.childRule(aq)))ap=aq;ag.setEndAfter(ap);}}else aj=true;}else aj=true;af=af.getNextSourceNode(an||am);}if(aj&&ag&&!ag.collapsed){var ar=J(ay,U),as=ar.hasAttributes(),at=ag.getCommonAncestor(),au={styles:{},attrs:{},blockedStyles:{},blockedAttrs:{}},av,aw,ax;while(ar&&at){if(at.getName()==W){for(av in X.attributes){if(au.blockedAttrs[av]||!(ax=at.getAttribute(aw)))continue;if(ar.getAttribute(av)==ax)au.attrs[av]=1;else au.blockedAttrs[av]=1;}for(aw in X.styles){if(au.blockedStyles[aw]||!(ax=at.getStyle(aw)))continue;if(ar.getStyle(aw)==ax)au.styles[aw]=1;else au.blockedStyles[aw]=1;}}at=at.getParent();}for(av in au.attrs)ar.removeAttribute(av);for(aw in au.styles)ar.removeStyle(aw);if(as&&!ar.hasAttributes())ar=null;if(ar){ag.extractContents().appendTo(ar);G(ay,ar);ag.insertNode(ar);ar.mergeSiblings();if(!c)ar.$.normalize();}else{ar=new h('span');ag.extractContents().appendTo(ar);ag.insertNode(ar);G(ay,ar);ar.remove(true);}ag=null;}}T.moveToBookmark(ac);T.shrink(2);};function u(T){T.enlarge(1,1);var U=T.createBookmark(),V=U.startNode;if(T.collapsed){var W=new d.elementPath(V.getParent()),X;for(var Y=0,Z;Y'+V+'';else T.setHtml(V);U.remove();};function B(T){var U=/(\S\s*)\n(?:\s|(]+data-cke-bookmark.*?\/span>))*\n(?!$)/gi,V=T.getName(),W=C(T.getOuterHtml(),U,function(Y,Z,aa){return Z+''+aa+'
    ';}),X=[];W.replace(/([\s\S]*?)<\/pre>/gi,function(Y,Z){X.push(Z);});return X;};function C(T,U,V){var W='',X='';T=T.replace(/(^]+data-cke-bookmark.*?\/span>)|(]+data-cke-bookmark.*?\/span>$)/gi,function(Y,Z,aa){Z&&(W=Z);aa&&(X=aa);return '';});return W+T.replace(U,V)+X;};function D(T,U){var V;if(T.length>1)V=new d.documentFragment(U.getDocument());for(var W=0;W');X=X.replace(/[ \t]{2,}/g,function(Z){return e.repeat(' ',Z.length-1)+' ';});if(V){var Y=U.clone();Y.setHtml(X);V.append(Y);}else U.setHtml(X);}return V||U;};function E(T,U){var V=T.getBogus();V&&V.remove();var W=T.getHtml();W=C(W,/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g,'');W=W.replace(/[ \t\r\n]*(]*>)[ \t\r\n]*/gi,'$1');W=W.replace(/([ \t\n\r]+| )/g,' ');W=W.replace(/]*>/gi,'\n');if(c){var X=T.getDocument().createElement('div');X.append(U);U.$.outerHTML='
    '+W+'
    ';U.copyAttributes(X.getFirst());U=X.getFirst().remove();}else U.setHtml(W);return U;};function F(T,U){var V=T._.definition,W=e.extend({},V.attributes,N(T)[U.getName()]),X=V.styles,Y=e.isEmpty(W)&&e.isEmpty(X);for(var Z in W){if((Z=='class'||T._.definition.fullMatch)&&U.getAttribute(Z)!=O(Z,W[Z]))continue;Y=U.hasAttribute(Z);U.removeAttribute(Z);}for(var aa in X){if(T._.definition.fullMatch&&U.getStyle(aa)!=O(aa,X[aa],true))continue;Y=Y||!!U.getStyle(aa);U.removeStyle(aa);}if(Y)!f.$block[U.getName()]||T._.enterMode==2&&!U.hasAttributes()?I(U):U.renameNode(T._.enterMode==1?'p':'div');};function G(T,U){var V=T._.definition,W=V.attributes,X=V.styles,Y=N(T),Z=U.getElementsByTag(T.element);for(var aa=Z.count();--aa>=0;)F(T,Z.getItem(aa));for(var ab in Y){if(ab!=T.element){Z=U.getElementsByTag(ab);for(aa=Z.count()-1;aa>=0;aa--){var ac=Z.getItem(aa);H(ac,Y[ab]);}}}};function H(T,U){var V=U&&U.attributes;if(V)for(var W=0;W0)H+=(F.$.offsetWidth||0)-(F.$.clientWidth||0)+3;H+=4;F.setStyle('width',H+'px');v.element.addClass('cke_frameLoaded');var I=v.element.$.scrollHeight;if(c&&b.quirks&&I>0)I+=(F.$.offsetHeight||0)-(F.$.clientHeight||0)+3;F.setStyle('height',I+'px');u._.currentBlock.element.setStyle('display','none').removeStyle('display');}else F.removeStyle('height');var J=u.element,K=J.getWindow(),L=K.getScrollPosition(),M=K.getViewPaneSize(),N={height:J.$.offsetHeight,width:J.$.offsetWidth};if(A?B<0:B+N.width>M.width+L.x)B+=N.width*(A?1:-1); +if(C+N.height>M.height+L.y)C-=N.height;if(c){var O=new h(w.$.offsetParent),P=O;if(P.getName()=='html')P=P.getDocument().getBody();if(P.getComputedStyle('direction')=='rtl')if(b.ie8Compat)B-=w.getDocument().getDocumentElement().$.scrollLeft*2;else B-=O.$.scrollWidth-O.$.clientWidth;}var Q=w.getFirst(),R;if(R=Q.getCustomData('activePanel'))R.onHide&&R.onHide.call(this,1);Q.setCustomData('activePanel',this);w.setStyles({top:C+'px',left:B+'px'});w.setOpacity(1);},this);u.isLoaded?E():u.onLoad=E;e.setTimeout(function(){x.$.contentWindow.focus();this.allowBlur(true);},0,this);},b.air?200:0,this);this.visible=1;if(this.onShow)this.onShow.call(this);n=0;},hide:function(p){var r=this;if(r.visible&&(!r.onHide||r.onHide.call(r)!==true)){r.hideChild();b.gecko&&r._.iframe.getFrameDocument().$.activeElement.blur();r.element.setStyle('display','none');r.visible=0;r.element.getFirst().removeCustomData('activePanel');var q=p!==false&&r._.returnFocus;if(q){if(b.webkit&&q.type)q.getWindow().$.focus();q.focus();}}},allowBlur:function(p){var q=this._.panel;if(p!=undefined)q.allowBlur=p;return q.allowBlur;},showAsChild:function(p,q,r,s,t,u){if(this._.activeChild==p&&p._.panel._.offsetParentId==r.getId())return;this.hideChild();p.onHide=e.bind(function(){e.setTimeout(function(){if(!this._.focused)this.hide();},0,this);},this);this._.activeChild=p;this._.focused=false;p.showBlock(q,r,s,t,u);if(b.ie7Compat||b.ie8&&b.ie6Compat)setTimeout(function(){p.element.getChild(0).$.style.cssText+='';},100);},hideChild:function(){var p=this._.activeChild;if(p){delete p.onHide;delete p._.returnFocus;delete this._.activeChild;p.hide();}}}});a.on('instanceDestroyed',function(){var p=e.isEmpty(a.instances);for(var q in m){var r=m[q];if(p)r.destroy();else r.element.hide();}p&&(m={});});})();j.add('menu',{beforeInit:function(m){var n=m.config.menu_groups.split(','),o=m._.menuGroups={},p=m._.menuItems={};for(var q=0;q'],B=r.length,C=B&&r[0].group;for(var D=0;D');C=E.group;}E.render(this,D,A);}A.push('');u.setHtml(A.join(''));k.fire('ready',this);if(this.parent)this.parent._.panel.showAsChild(t,this.id,n,o,p,q);else t.showBlock(this.id,n,o,p,q);s.fire('menuShow',[t]);},addListener:function(n){this._.listeners.push(n);},hide:function(n){var o=this;o._.onHide&&o._.onHide();o._.panel&&o._.panel.hide(n);}}});function m(n){n.sort(function(o,p){if(o.groupp.group)return 1;return o.orderp.order?1:0;});};a.menuItem=e.createClass({$:function(n,o,p){var q=this;e.extend(q,p,{order:0,className:'cke_button_'+o});q.group=n._.menuGroups[q.group];q.editor=n;q.name=o;},proto:{render:function(n,o,p){var w=this;var q=n.id+String(o),r=typeof w.state=='undefined'?2:w.state,s=' cke_'+(r==1?'on':r==0?'disabled':'off'),t=w.label;if(w.className)s+=' '+w.className;var u=w.getItems;p.push(''+''+'');if(u)p.push('','&#',w.editor.lang.dir=='rtl'?'9668':'9658',';','');p.push(t,'');}}});})();i.menu_groups='clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea,div'; +(function(){var m;j.add('editingblock',{init:function(n){if(!n.config.editingBlock)return;n.on('themeSpace',function(o){if(o.data.space=='contents')o.data.html+='
    ';});n.on('themeLoaded',function(){n.fireOnce('editingBlockReady');});n.on('uiReady',function(){n.setMode(n.config.startupMode);});n.on('afterSetData',function(){if(!m){function o(){m=true;n.getMode().loadData(n.getData());m=false;};if(n.mode)o();else n.on('mode',function(){if(n.mode){o();n.removeListener('mode',arguments.callee);}});}});n.on('beforeGetData',function(){if(!m&&n.mode){m=true;n.setData(n.getMode().getData(),null,1);m=false;}});n.on('getSnapshot',function(o){if(n.mode)o.data=n.getMode().getSnapshotData();});n.on('loadSnapshot',function(o){if(n.mode)n.getMode().loadSnapshotData(o.data);});n.on('mode',function(o){o.removeListener();b.webkit&&n.container.on('focus',function(){n.focus();});if(n.config.startupFocus)n.focus();setTimeout(function(){n.fireOnce('instanceReady');a.fire('instanceReady',null,n);},0);});n.on('destroy',function(){var o=this;if(o.mode)o._.modes[o.mode].unload(o.getThemeSpace('contents'));});}});a.editor.prototype.mode='';a.editor.prototype.addMode=function(n,o){o.name=n;(this._.modes||(this._.modes={}))[n]=o;};a.editor.prototype.setMode=function(n){this.fire('beforeSetMode',{newMode:n});var o,p=this.getThemeSpace('contents'),q=this.checkDirty();if(this.mode){if(n==this.mode)return;this._.previousMode=this.mode;this.fire('beforeModeUnload');var r=this.getMode();o=r.getData();r.unload(p);this.mode='';}p.setHtml('');var s=this.getMode(n);if(!s)throw '[CKEDITOR.editor.setMode] Unknown mode "'+n+'".';if(!q)this.on('mode',function(){this.resetDirty();this.removeListener('mode',arguments.callee);});s.load(p,typeof o!='string'?this.getData():o);};a.editor.prototype.getMode=function(n){return this._.modes&&this._.modes[n||this.mode];};a.editor.prototype.focus=function(){this.forceNextSelectionCheck();var n=this.getMode();if(n)n.focus();};})();i.startupMode='wysiwyg';i.editingBlock=true;(function(){function m(){var B=this;try{var y=B.getSelection();if(!y||!y.document.getWindow().$)return;var z=y.getStartElement(),A=new d.elementPath(z);if(!A.compare(B._.selectionPreviousPath)){B._.selectionPreviousPath=A;B.fire('selectionChange',{selection:y,path:A,element:z});}}catch(C){}};var n,o;function p(){o=true;if(n)return;q.call(this);n=e.setTimeout(q,200,this);};function q(){n=null;if(o){e.setTimeout(m,0,this);o=false;}};function r(y){function z(D){return D&&D.type==1&&D.getName() in f.$removeEmpty; +};function A(D){var E=y.document.getBody();return!D.is('body')&&E.getChildCount()==1;};var B=y.startContainer,C=y.startOffset;if(B.type==3)return false;return!e.trim(B.getHtml())?z(B)||A(B):z(B.getChild(C-1))||z(B.getChild(C));};var s={modes:{wysiwyg:1,source:1},readOnly:c||b.webkit,exec:function(y){switch(y.mode){case 'wysiwyg':y.document.$.execCommand('SelectAll',false,null);y.forceNextSelectionCheck();y.selectionChange();break;case 'source':var z=y.textarea.$;if(c)z.createTextRange().execCommand('SelectAll');else{z.selectionStart=0;z.selectionEnd=z.value.length;}z.focus();}},canUndo:false};function t(y){w(y);var z=y.createText('​');y.setCustomData('cke-fillingChar',z);return z;};function u(y){return y&&y.getCustomData('cke-fillingChar');};function v(y){var z=y&&u(y);if(z)if(z.getCustomData('ready'))w(y);else z.setCustomData('ready',1);};function w(y){var z=y&&y.removeCustomData('cke-fillingChar');if(z){z.setText(z.getText().replace(/\u200B/g,''));z=0;}};j.add('selection',{init:function(y){if(b.webkit){y.on('selectionChange',function(){v(y.document);});y.on('beforeSetMode',function(){w(y.document);});y.on('key',function(D){switch(D.data.keyCode){case 13:case 2228224+13:case 37:case 39:case 8:w(y.document);}},null,null,10);var z,A;function B(){var D=y.document,E=u(D);if(E){var F=D.$.defaultView.getSelection();if(F.type=='Caret'&&F.anchorNode==E.$)A=1;z=E.getText();E.setText(z.replace(/\u200B/g,''));}};function C(){var D=y.document,E=u(D);if(E){E.setText(z);if(A){D.$.defaultView.getSelection().setPosition(E.$,E.getLength());A=0;}}};y.on('beforeUndoImage',B);y.on('afterUndoImage',C);y.on('beforeGetData',B,null,null,0);y.on('getData',C);}y.on('contentDom',function(){var D=y.document,E=D.getBody(),F=D.getDocumentElement();if(c){var G,H,I=1;E.on('focusin',function(M){if(M.data.$.srcElement.nodeName!='BODY')return;if(G){if(I){try{G.select();}catch(O){}var N=D.getCustomData('cke_locked_selection');if(N){N.unlock();N.lock();}}G=null;}});E.on('focus',function(){H=1;L();});E.on('beforedeactivate',function(M){if(M.data.$.toElement)return;H=0;I=1;});if(c&&b.version<8)y.on('blur',function(M){try{y.document&&y.document.$.selection.empty();}catch(N){}});F.on('mousedown',function(){I=0;});F.on('mouseup',function(){I=1;});if(c&&(b.ie7Compat||b.version<8||b.quirks))F.on('click',function(M){if(M.data.getTarget().getName()=='html')y.getSelection().getRanges()[0].select();});var J;E.on('mousedown',function(M){if(M.data.$.button==2){var N=y.document.$.selection;if(N.type=='None')J=y.window.getScrollPosition(); +}K();});E.on('mouseup',function(M){if(M.data.$.button==2&&J){y.document.$.documentElement.scrollLeft=J.x;y.document.$.documentElement.scrollTop=J.y;}J=null;H=1;setTimeout(function(){L(true);},0);});E.on('keydown',K);E.on('keyup',function(){H=1;L();});D.on('selectionchange',L);function K(){H=0;};function L(M){if(H){var N=y.document,O=y.getSelection(),P=O&&O.getNative();if(M&&P&&P.type=='None')if(!N.$.queryCommandEnabled('InsertImage')){e.setTimeout(L,50,this,true);return;}var Q;if(P&&P.type&&P.type!='Control'&&(Q=P.createRange())&&(Q=Q.parentElement())&&(Q=Q.nodeName)&&Q.toLowerCase() in {input:1,textarea:1})return;G=P&&O.getRanges()[0];p.call(y);}};}else{D.on('mouseup',p,y);D.on('keyup',p,y);D.on('selectionchange',p,y);}});y.on('contentDomUnload',y.forceNextSelectionCheck,y);y.addCommand('selectAll',s);y.ui.addButton('SelectAll',{label:y.lang.selectAll,command:'selectAll'});y.selectionChange=p;b.ie9Compat&&y.on('destroy',function(){var D=y.getSelection();D&&D.getNative().clear();},null,null,9);}});a.editor.prototype.getSelection=function(){return this.document&&this.document.getSelection();};a.editor.prototype.forceNextSelectionCheck=function(){delete this._.selectionPreviousPath;};g.prototype.getSelection=function(){var y=new d.selection(this);return!y||y.isInvalid?null:y;};a.SELECTION_NONE=1;a.SELECTION_TEXT=2;a.SELECTION_ELEMENT=3;d.selection=function(y){var B=this;var z=y.getCustomData('cke_locked_selection');if(z)return z;B.document=y;B.isLocked=0;B._={cache:{}};if(c){var A=B.getNative().createRange();if(!A||A.item&&A.item(0).ownerDocument!=B.document.$||A.parentElement&&A.parentElement().ownerDocument!=B.document.$)B.isInvalid=true;}return B;};var x={img:1,hr:1,li:1,table:1,tr:1,td:1,th:1,embed:1,object:1,ol:1,ul:1,a:1,input:1,form:1,select:1,textarea:1,button:1,fieldset:1,thead:1,tfoot:1};d.selection.prototype={getNative:c?function(){return this._.cache.nativeSel||(this._.cache.nativeSel=this.document.$.selection);}:function(){return this._.cache.nativeSel||(this._.cache.nativeSel=this.document.getWindow().$.getSelection());},getType:c?function(){var y=this._.cache;if(y.type)return y.type;var z=1;try{var A=this.getNative(),B=A.type;if(B=='Text')z=2;if(B=='Control')z=3;if(A.createRange().parentElement)z=2;}catch(C){}return y.type=z;}:function(){var y=this._.cache;if(y.type)return y.type;var z=2,A=this.getNative();if(!A)z=1;else if(A.rangeCount==1){var B=A.getRangeAt(0),C=B.startContainer;if(C==B.endContainer&&C.nodeType==1&&B.endOffset-B.startOffset==1&&x[C.childNodes[B.startOffset].nodeName.toLowerCase()])z=3; +}return y.type=z;},getRanges:(function(){var y=c?(function(){function z(B){return new d.node(B).getIndex();};var A=function(B,C){B=B.duplicate();B.collapse(C);var D=B.parentElement(),E=D.ownerDocument;if(!D.hasChildNodes())return{container:D,offset:0};var F=D.children,G,H,I=B.duplicate(),J=0,K=F.length-1,L=-1,M,N;while(J<=K){L=Math.floor((J+K)/2);G=F[L];I.moveToElementText(G);M=I.compareEndPoints('StartToStart',B);if(M>0)K=L-1;else if(M<0)J=L+1;else if(b.ie9Compat&&G.tagName=='BR'){var O='cke_range_marker';B.execCommand('CreateBookmark',false,O);G=E.getElementsByName(O)[0];var P=z(G);D.removeChild(G);return{container:D,offset:P};}else return{container:D,offset:z(G)};}if(L==-1||L==F.length-1&&M<0){I.moveToElementText(D);I.setEndPoint('StartToStart',B);N=I.text.replace(/(\r\n|\r)/g,'\n').length;F=D.childNodes;if(!N){G=F[F.length-1];if(G.nodeType==1)return{container:D,offset:F.length};else return{container:G,offset:G.nodeValue.length};}var Q=F.length;while(N>0)N-=F[--Q].nodeValue.length;return{container:F[Q],offset:-N};}else{I.collapse(M>0?true:false);I.setEndPoint(M>0?'StartToStart':'EndToStart',B);N=I.text.replace(/(\r\n|\r)/g,'\n').length;if(!N)return{container:D,offset:z(G)+(M>0?0:1)};while(N>0)try{H=G[M>0?'previousSibling':'nextSibling'];N-=H.nodeValue.length;G=H;}catch(R){return{container:D,offset:z(G)};}return{container:G,offset:M>0?-N:G.nodeValue.length+N};}};return function(){var L=this;var B=L.getNative(),C=B&&B.createRange(),D=L.getType(),E;if(!B)return[];if(D==2){E=new d.range(L.document);var F=A(C,true);E.setStart(new d.node(F.container),F.offset);F=A(C);E.setEnd(new d.node(F.container),F.offset);if(E.endContainer.getPosition(E.startContainer)&4&&E.endOffset<=E.startContainer.getIndex())E.collapse();return[E];}else if(D==3){var G=[];for(var H=0;H=G.getLength())K.setStartAfter(G);else K.setStartBefore(G);if(H&&H.type==3)if(!J)K.setEndBefore(H);else K.setEndAfter(H);var L=new d.walker(K);L.evaluator=function(M){if(M.type==1&&M.isReadOnly()){var N=D.clone();D.setEndBefore(M);if(D.collapsed)B.splice(C--,1);if(!(M.getPosition(K.endContainer)&16)){N.setStartAfter(M);if(!N.collapsed)B.splice(C+1,0,N);}return true;}return false;};L.next();}}return A.ranges;};})(),getStartElement:function(){var F=this;var y=F._.cache;if(y.startElement!==undefined)return y.startElement;var z,A=F.getNative();switch(F.getType()){case 3:return F.getSelectedElement();case 2:var B=F.getRanges()[0];if(B){if(!B.collapsed){B.optimize();while(1){var C=B.startContainer,D=B.startOffset;if(D==(C.getChildCount?C.getChildCount():C.getLength())&&!C.isBlockBoundary())B.setStartAfter(C);else break;}z=B.startContainer;if(z.type!=1)return z.getParent();z=z.getChild(B.startOffset);if(!z||z.type!=1)z=B.startContainer;else{var E=z.getFirst();while(E&&E.type==1){z=E;E=E.getFirst();}}}else{z=B.startContainer;if(z.type!=1)z=z.getParent();}z=z.$;}}return y.startElement=z?new h(z):null;},getSelectedElement:function(){var y=this._.cache;if(y.selectedElement!==undefined)return y.selectedElement;var z=this,A=e.tryThese(function(){return z.getNative().createRange().item(0);},function(){var B,C,D=z.getRanges()[0],E=D.getCommonAncestor(1,1),F={table:1,ul:1,ol:1,dl:1};for(var G in F){if(B=E.getAscendant(G,1))break;}if(B){var H=new d.range(this.document);H.setStartAt(B,1);H.setEnd(D.startContainer,D.startOffset);var I=e.extend(F,f.$listItem,f.$tableContent),J=new d.walker(H),K=function(L,M){return function(N,O){if(N.type==3&&(!e.trim(N.getText())||N.getParent().data('cke-bookmark')))return true;var P;if(N.type==1){P=N.getName();if(P=='br'&&M&&N.equals(N.getParent().getBogus()))return true;if(O&&P in I||P in f.$removeEmpty)return true;}L.halted=1;return false;};};J.guard=K(J);if(J.checkBackward()&&!J.halted){J=new d.walker(H);H.setStart(D.endContainer,D.endOffset);H.setEndAt(B,2);J.guard=K(J,1);if(J.checkForward()&&!J.halted)C=B.$;}}if(!C)throw 0; +return C;},function(){var B=z.getRanges()[0],C,D;for(var E=2;E&&!((C=B.getEnclosedNode())&&C.type==1&&x[C.getName()]&&(D=C));E--)B.shrink(1);return D.$;});return y.selectedElement=A?new h(A):null;},getSelectedText:function(){var y=this._.cache;if(y.selectedText!==undefined)return y.selectedText;var z='',A=this.getNative();if(this.getType()==2)z=c?A.createRange().text:A.toString();return y.selectedText=z;},lock:function(){var y=this;y.getRanges();y.getStartElement();y.getSelectedElement();y.getSelectedText();y._.cache.nativeSel={};y.isLocked=1;y.document.setCustomData('cke_locked_selection',y);},unlock:function(y){var D=this;var z=D.document,A=z.getCustomData('cke_locked_selection');if(A){z.setCustomData('cke_locked_selection',null);if(y){var B=A.getSelectedElement(),C=!B&&A.getRanges();D.isLocked=0;D.reset();z.getBody().focus();if(B)D.selectElement(B);else D.selectRanges(C);}}if(!A||!y){D.isLocked=0;D.reset();}},reset:function(){this._.cache={};},selectElement:function(y){var A=this;if(A.isLocked){var z=new d.range(A.document);z.setStartBefore(y);z.setEndAfter(y);A._.cache.selectedElement=y;A._.cache.startElement=y;A._.cache.ranges=new d.rangeList(z);A._.cache.type=3;return;}z=new d.range(y.getDocument());z.setStartBefore(y);z.setEndAfter(y);z.select();A.document.fire('selectionchange');A.reset();},selectRanges:function(y){var M=this;if(M.isLocked){M._.cache.selectedElement=null;M._.cache.startElement=y[0]&&y[0].getTouchedStartNode();M._.cache.ranges=new d.rangeList(y);M._.cache.type=2;return;}if(c){if(y.length>1){var z=y[y.length-1];y[0].setEnd(z.endContainer,z.endOffset);y.length=1;}if(y[0])y[0].select();M.reset();}else{var A=M.getNative();if(!A)return;if(y.length){A.removeAllRanges();b.webkit&&w(M.document);}for(var B=0;B=0){H.collapse(1);I.setEnd(H.endContainer.$,H.endOffset);}else throw N;}A.addRange(I);}M.document.fire('selectionchange');M.reset();}},createBookmarks:function(y){return this.getRanges().createBookmarks(y);},createBookmarks2:function(y){return this.getRanges().createBookmarks2(y);},selectBookmarks:function(y){var z=[];for(var A=0;A','','',this.label,'','=10900&&!o.hc?'':" href=\"javascript:void('"+this.label+"')\"",' role="button" aria-labelledby="',p,'_label" aria-describedby="',p,'_text" aria-haspopup="true"');if(b.opera||b.gecko&&b.mac)n.push(' onkeypress="return false;"');if(b.gecko)n.push(' onblur="this.style.cssText = this.style.cssText;"');n.push(' onkeydown="CKEDITOR.tools.callFunction( ',t,', event, this );" onfocus="return CKEDITOR.tools.callFunction(',u,', event);" '+(c?'onclick="return false;" onmouseup':'onclick')+'="CKEDITOR.tools.callFunction(',q,', this); return false;">'+this.label+''+''+''+(b.hc?'▼':b.air?' ':'')+''+''+''+'');if(this.onRender)this.onRender();return r;},createPanel:function(m){if(this._.panel)return;var n=this._.panelDefinition,o=this._.panelDefinition.block,p=n.parent||a.document.getBody(),q=new k.floatPanel(m,p,n),r=q.addListBlock(this.id,o),s=this;q.onShow=function(){if(s.className)this.element.getFirst().addClass(s.className+'_panel');s.setState(1);r.focus(!s.multiSelect&&s.getValue());s._.on=1;if(s.onOpen)s.onOpen();};q.onHide=function(t){if(s.className)this.element.getFirst().removeClass(s.className+'_panel');s.setState(s.modes&&s.modes[m.mode]?2:0);s._.on=0;if(!t&&s.onClose)s.onClose();};q.onEscape=function(){q.hide();};r.onClick=function(t,u){s.document.getWindow().focus();if(s.onClick)s.onClick.call(s,t,u);if(u)s.setValue(t,s._.items[t]);else s.setValue(''); +q.hide(false);};this._.panel=q;this._.list=r;q.getBlock(this.id).onHide=function(){s._.on=0;s.setState(2);};if(this.init)this.init();},setValue:function(m,n){var p=this;p._.value=m;var o=p.document.getById('cke_'+p.id+'_text');if(o){if(!(m||n)){n=p.label;o.addClass('cke_inline_label');}else o.removeClass('cke_inline_label');o.setHtml(typeof n!='undefined'?n:m);}},getValue:function(){return this._.value||'';},unmarkAll:function(){this._.list.unmarkAll();},mark:function(m){this._.list.mark(m);},hideItem:function(m){this._.list.hideItem(m);},hideGroup:function(m){this._.list.hideGroup(m);},showAll:function(){this._.list.showAll();},add:function(m,n,o){this._.items[m]=o||m;this._.list.add(m,n,o);},startGroup:function(m){this._.list.startGroup(m);},commit:function(){var m=this;if(!m._.committed){m._.list.commit();m._.committed=1;k.fire('ready',m);}m._.committed=1;},setState:function(m){var n=this;if(n._.state==m)return;n.document.getById('cke_'+n.id).setState(m);n._.state=m;}}});k.prototype.addRichCombo=function(m,n){this.add(m,'richcombo',n);};j.add('htmlwriter');a.htmlWriter=e.createClass({base:a.htmlParser.basicWriter,$:function(){var o=this;o.base();o.indentationChars='\t';o.selfClosingEnd=' />';o.lineBreakChars='\n';o.forceSimpleAmpersand=0;o.sortAttributes=1;o._.indent=0;o._.indentation='';o._.inPre=0;o._.rules={};var m=f;for(var n in e.extend({},m.$nonBodyContent,m.$block,m.$listItem,m.$tableContent))o.setRules(n,{indent:1,breakBeforeOpen:1,breakAfterOpen:1,breakBeforeClose:!m[n]['#'],breakAfterClose:1});o.setRules('br',{breakAfterOpen:1});o.setRules('title',{indent:0,breakAfterOpen:0});o.setRules('style',{indent:0,breakBeforeClose:1});o.setRules('pre',{indent:0});},proto:{openTag:function(m,n){var p=this;var o=p._.rules[m];if(p._.indent)p.indentation();else if(o&&o.breakBeforeOpen){p.lineBreak();p.indentation();}p._.output.push('<',m);},openTagClose:function(m,n){var p=this;var o=p._.rules[m];if(n)p._.output.push(p.selfClosingEnd);else{p._.output.push('>');if(o&&o.indent)p._.indentation+=p.indentationChars;}if(o&&o.breakAfterOpen)p.lineBreak();m=='pre'&&(p._.inPre=1);},attribute:function(m,n){if(typeof n=='string'){this.forceSimpleAmpersand&&(n=n.replace(/&/g,'&'));n=e.htmlEncodeAttr(n);}this._.output.push(' ',m,'="',n,'"');},closeTag:function(m){var o=this;var n=o._.rules[m];if(n&&n.indent)o._.indentation=o._.indentation.substr(o.indentationChars.length);if(o._.indent)o.indentation();else if(n&&n.breakBeforeClose){o.lineBreak();o.indentation();}o._.output.push(''); +m=='pre'&&(o._.inPre=0);if(n&&n.breakAfterClose)o.lineBreak();},text:function(m){var n=this;if(n._.indent){n.indentation();!n._.inPre&&(m=e.ltrim(m));}n._.output.push(m);},comment:function(m){if(this._.indent)this.indentation();this._.output.push('');},lineBreak:function(){var m=this;if(!m._.inPre&&m._.output.length>0)m._.output.push(m.lineBreakChars);m._.indent=1;},indentation:function(){var m=this;if(!m._.inPre)m._.output.push(m._.indentation);m._.indent=0;},setRules:function(m,n){var o=this._.rules[m];if(o)e.extend(o,n,true);else this._.rules[m]=n;}}});j.add('menubutton',{requires:['button','menu'],beforeInit:function(m){m.ui.addHandler('menubutton',k.menuButton.handler);}});a.UI_MENUBUTTON='menubutton';(function(){var m=function(n){var o=this._;if(o.state===0)return;o.previousState=o.state;var p=o.menu;if(!p){p=o.menu=new a.menu(n,{panel:{className:n.skinClass+' cke_contextmenu',attributes:{'aria-label':n.lang.common.options}}});p.onHide=e.bind(function(){this.setState(this.modes&&this.modes[n.mode]?o.previousState:0);},this);if(this.onMenu)p.addListener(this.onMenu);}if(o.on){p.hide();return;}this.setState(1);p.show(a.document.getById(this._.id),4);};k.menuButton=e.createClass({base:k.button,$:function(n){var o=n.panel;delete n.panel;this.base(n);this.hasArrow=true;this.click=m;},statics:{handler:{create:function(n){return new k.menuButton(n);}}}});})();j.add('dialogui');(function(){var m=function(u){var x=this;x._||(x._={});x._['default']=x._.initValue=u['default']||'';x._.required=u.required||false;var v=[x._];for(var w=1;w',v.label,'','');else{var D={type:'hbox',widths:v.widths,padding:0,children:[{type:'html',html:'