From 1a71e9b4a0377f2c42ebdccd65aa73c5bd73a6cb Mon Sep 17 00:00:00 2001 From: arnaud Date: Wed, 5 Jul 2017 16:57:03 +0200 Subject: [PATCH 01/90] FIX add supplierproposaldet without price (new product) --- htdocs/supplier_proposal/card.php | 5 +++-- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 9ed38461180..e2bfb502028 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -526,7 +526,8 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; + $predef=''; + $ref_fourn = GETPOST('fourn_ref'); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -614,7 +615,7 @@ if (empty($reshook)) $price_base_type = $productsupplier->fourn_price_base_type; $type = $productsupplier->type; $label = $productsupplier->label; - $desc = $productsupplier->description; + $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 8cbc3882fc4..6f973f4ce08 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2738,6 +2738,7 @@ class SupplierProposalLine extends CommonObject if (empty($this->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; + if (empty($this->subprice)) $this->subprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; @@ -2920,6 +2921,7 @@ class SupplierProposalLine extends CommonObject if (empty($this->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; + if (empty($this->subprice)) $this->subprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; From 3d18c71201bc22c5ff5377418812e66caf774362 Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Wed, 5 Jul 2017 17:21:37 +0200 Subject: [PATCH 02/90] FIX invoice situation VAT total rounding into PDF crabe --- .../modules/facture/doc/pdf_crabe.modules.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 52971f76770..57c8d55c983 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1120,7 +1120,26 @@ class pdf_crabe extends ModelePDFFactures } //} + // VAT + // Situations totals migth be wrong on huge amounts + if ($object->situation_cycle_ref && $object->situation_counter > 1) { + + $sum_pdf_tva = 0; + foreach($this->tva as $tvakey => $tvaval){ + $sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object + } + + if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one) + $coef_fix_tva = $object->total_tva / $sum_pdf_tva; + + foreach($this->tva as $tvakey => $tvaval) { + $this->tva[$tvakey]=$tvaval * $coef_fix_tva; + } + } + + } + foreach($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 From 13d6664ab499ac66f036388fd8f6a7924e9876ca Mon Sep 17 00:00:00 2001 From: fappels Date: Sun, 9 Jul 2017 12:47:51 +0200 Subject: [PATCH 03/90] Fix delete product from product card --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 3266d02f2f4..0a6c9052b91 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -561,7 +561,7 @@ if (empty($reshook)) { if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) { - $result = $object->delete(DolibarrApiAccess::$user); + $result = $object->delete($user); } if ($result > 0) From f166c96ed5a5065c1fffedaefadee8b5eb972c8f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 9 Jul 2017 13:09:17 +0200 Subject: [PATCH 04/90] Fix : script to migrate photo path --- scripts/product/migrate_picture_path.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index f8624ebc040..98a5c4d51bc 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -104,7 +104,7 @@ function migrate_product_photospath($product) global $conf; $dir = $conf->product->multidir_output[$product->entity]; - $origin = $dir .'/'. get_exdir($product->id,2) . $product->id ."/photos"; + $origin = $dir .'/'. get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos"; $destin = $dir.'/'.dol_sanitizeFileName($product->ref); $error = 0; From 10cb7b2524c1e08ae6c9d16218dac3277c8a0f68 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jul 2017 20:31:27 +0200 Subject: [PATCH 05/90] Fix remove warnings --- htdocs/admin/notification.php | 8 +++--- htdocs/bookmarks/bookmarks.lib.php | 8 +++--- htdocs/comm/action/index.php | 18 ++++++++----- htdocs/comm/action/listactions.php | 11 +++++--- htdocs/core/actions_setmoduleoptions.inc.php | 17 +++++++----- htdocs/install/step1.php | 11 +++++--- htdocs/main.inc.php | 10 +++++--- htdocs/projet/activity/perday.php | 27 +++++++++++--------- htdocs/theme/eldy/ckeditor/config.js | 5 +++- htdocs/theme/md/ckeditor/config.js | 5 +++- 10 files changed, 74 insertions(+), 46 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 73fb3d91587..04427f636cd 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -55,7 +55,7 @@ if ($action == 'setvalue' && $user->admin) $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", $_POST["email_from"], 'chaine', 0, '', $conf->entity); if ($result < 0) $error++; - if (! $error) + if (! $error && is_array($_POST)) { //var_dump($_POST); foreach($_POST as $key => $val) @@ -172,7 +172,7 @@ $var=true; $i=0; foreach($listofnotifiedevents as $notifiedevent) { - + $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); @@ -183,7 +183,7 @@ foreach($listofnotifiedevents as $notifiedevent) if ($i) print ', '; print $label; - + $i++; } print ''; @@ -213,7 +213,7 @@ $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); $var=true; foreach($listofnotifiedevents as $notifiedevent) { - + $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 8f8295f0e53..eca126697cc 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -53,11 +53,13 @@ function printBookmarksList($aDb, $aLangs) // No urlencode, all param $url will be urlencoded later if ($sortfield) $tmpurl.=($tmpurl?'&':'').'sortfield='.$sortfield; if ($sortorder) $tmpurl.=($tmpurl?'&':'').'sortorder='.$sortorder; - foreach($_POST as $key => $val) + if (is_array($_POST)) { - if (preg_match('/^search_/', $key) && $val != '') $tmpurl.=($tmpurl?'&':'').$key.'='.$val; + foreach($_POST as $key => $val) + { + if (preg_match('/^search_/', $key) && $val != '') $tmpurl.=($tmpurl?'&':'').$key.'='.$val; + } } - $url.=($tmpurl?'?'.$tmpurl:''); } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 76a53924ad5..9e293e09799 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -129,10 +129,13 @@ $hookmanager->initHooks(array('agenda')); if (GETPOST("viewlist") || $action == 'show_list') { $param=''; - foreach($_POST as $key => $val) + if (is_array($_POST)) { - if ($key=='token') continue; - $param.='&'.$key.'='.urlencode($val); + foreach($_POST as $key => $val) + { + if ($key=='token') continue; + $param.='&'.$key.'='.urlencode($val); + } } //print $param; header("Location: ".DOL_URL_ROOT.'/comm/action/listactions.php?'.$param); @@ -142,10 +145,13 @@ if (GETPOST("viewlist") || $action == 'show_list') if (GETPOST("viewperuser") || $action == 'show_peruser') { $param=''; - foreach($_POST as $key => $val) + if (is_array($_POST)) { - if ($key=='token') continue; - $param.='&'.$key.'='.urlencode($val); + foreach($_POST as $key => $val) + { + if ($key=='token') continue; + $param.='&'.$key.'='.urlencode($val); + } } //print $param; header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param); diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 9cb14454cd5..9e0d1530e85 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -120,10 +120,13 @@ $hookmanager->initHooks(array('agendalist')); if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { $param=''; - foreach($_POST as $key => $val) - { - $param.='&'.$key.'='.urlencode($val); - } + if (is_array($_POST)) + { + foreach($_POST as $key => $val) + { + $param.='&'.$key.'='.urlencode($val); + } + } //print $param; header("Location: ".DOL_URL_ROOT.'/comm/action/index.php?'.$param); exit; diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 03b33b19eb1..b8ae96cb920 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -32,16 +32,19 @@ if ($action == 'setModuleOptions') $db->begin(); // Process common param fields - foreach($_POST as $key => $val) + if (is_array($_POST)) { - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... + foreach($_POST as $key => $val) { - $param=GETPOST("param".$reg[1],'alpha'); - $value=GETPOST("value".$reg[1],'alpha'); - if ($param) + if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... { - $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; + $param=GETPOST("param".$reg[1],'alpha'); + $value=GETPOST("value".$reg[1],'alpha'); + if ($param) + { + $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } } } } diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index a0fdc22a015..a8d17388d41 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -345,11 +345,14 @@ if (! $error && $db->connected) if (! $error && $db->connected && $action == "set") { umask(0); - foreach($_POST as $key => $value) + if (is_array($_POST)) { - if (! preg_match('/^db_pass/i', $key)) { - dolibarr_install_syslog("step1: choice for " . $key . " = " . $value); - } + foreach($_POST as $key => $value) + { + if (! preg_match('/^db_pass/i', $key)) { + dolibarr_install_syslog("step1: choice for " . $key . " = " . $value); + } + } } // Show title of step diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b5f88def445..1edc67d582f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1498,10 +1498,12 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a { $qs=dol_escape_htmltag($_SERVER["QUERY_STRING"]); - foreach($_POST as $key=>$value) { - if ($key!=='action' && !is_array($value)) $qs.='&'.$key.'='.urlencode($value); - } - + if (is_array($_POST)) + { + foreach($_POST as $key=>$value) { + if ($key!=='action' && !is_array($value)) $qs.='&'.$key.'='.urlencode($value); + } + } $qs.=(($qs && $morequerystring)?'&':'').$morequerystring; $text =''; //$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"'); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9cda69560d5..908767afe32 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -200,22 +200,25 @@ if ($action == 'addtime' && $user->rights->projet->lire) { $timespent_duration=array(); - foreach($_POST as $key => $time) + if (is_array($_POST)) { - if (intval($time) > 0) + foreach($_POST as $key => $time) { - // Hours or minutes of duration - if (preg_match("/([0-9]+)duration(hour|min)/",$key,$matches)) + if (intval($time) > 0) { - $id = $matches[1]; - if ($id > 0) - { - // We store HOURS in seconds - if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60; + // Hours or minutes of duration + if (preg_match("/([0-9]+)duration(hour|min)/",$key,$matches)) + { + $id = $matches[1]; + if ($id > 0) + { + // We store HOURS in seconds + if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60; - // We store MINUTES in seconds - if($matches[2]=='min') $timespent_duration[$id] += $time*60; - } + // We store MINUTES in seconds + if($matches[2]=='min') $timespent_duration[$id] += $time*60; + } + } } } } diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js index eabd0c58bd3..e4a86a37293 100644 --- a/htdocs/theme/eldy/ckeditor/config.js +++ b/htdocs/theme/eldy/ckeditor/config.js @@ -25,7 +25,10 @@ CKEDITOR.editorConfig = function( config ) config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; //config.contentsCss = '/css/mysitestyles.css'; config.image_previewText=' '; // Must no be empty - + //config.autoParagraph = false; + //config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd'; // See also rules on this.dataProcessor.writer.setRules + //config.forcePasteAsPlainText = true; + config.toolbar_Full = [ ['Templates','NewPage'], diff --git a/htdocs/theme/md/ckeditor/config.js b/htdocs/theme/md/ckeditor/config.js index 6f1bbe7fb30..a6508e62a88 100644 --- a/htdocs/theme/md/ckeditor/config.js +++ b/htdocs/theme/md/ckeditor/config.js @@ -25,7 +25,10 @@ CKEDITOR.editorConfig = function( config ) config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; //config.contentsCss = '/css/mysitestyles.css'; config.image_previewText=' '; // Must no be empty - + //config.autoParagraph = false; + //config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd'; // See also rules on this.dataProcessor.writer.setRules + //config.forcePasteAsPlainText = true; + config.toolbar_Full = [ ['Templates','NewPage'], From 3c576dcf21e5bfeaa610a8bdb06457e33a0a214b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jul 2017 20:57:45 +0200 Subject: [PATCH 06/90] Fix bad name of tables --- htdocs/admin/websites.php | 28 +++++++++---------- .../install/mysql/migration/5.0.0-6.0.0.sql | 25 +++++++++++++++++ .../mysql/tables/llx_website_pages.key.sql | 4 +-- .../mysql/tables/llx_website_pages.sql | 2 +- htdocs/websites/index.php | 3 +- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 0336a2533c0..3b894536d04 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2017 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 @@ -48,15 +48,15 @@ $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"),'switch_off'); $actl[1] = img_picto($langs->trans("Activated"),'switch_on'); -$listoffset=GETPOST('listoffset'); -$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; $status = 1; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); -if ($page == -1 || $page == null) { $page = 0 ; } -$offset = $listlimit * $page ; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -118,7 +118,7 @@ $elementList = array(); $sourceList=array(); // Actions add or modify an entry into a dictionary -if (GETPOST('actionadd') || GETPOST('actionmodify')) +if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) { $listfield=explode(',',$tabfield[$id]); $listfieldinsert=explode(',',$tabfieldinsert[$id]); @@ -138,7 +138,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd')) + if ($ok && GETPOST('actionadd','alpha')) { if ($tabrowid[$id]) { @@ -200,7 +200,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify')) + if ($ok && GETPOST('actionmodify','alpha')) { if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } @@ -252,7 +252,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } -if (GETPOST('actioncancel')) +if (GETPOST('actioncancel','alpha')) { //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } @@ -412,11 +412,11 @@ if ($id) $obj = new stdClass(); // If data was already input, we define them in obj to populate input fields. - if (GETPOST('actionadd')) + if (GETPOST('actionadd','alpha')) { foreach ($fieldlist as $key=>$val) { - if (GETPOST($val)) + if (GETPOST($val,'alpha')) $obj->$val=GETPOST($val); } } diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 8e4785ab4d9..ec3a945bb09 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -495,6 +495,31 @@ ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup; ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id); ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid); +-- For new module website + +CREATE TABLE llx_website_pages +( + rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, + fk_website integer NOT NULL, + pageurl varchar(16) NOT NULL, + title varchar(255), + description varchar(255), + keywords varchar(255), + content mediumtext, -- text is not enough in size + status integer, + fk_user_create integer, + fk_user_modif integer, + date_creation datetime, + tms timestamp +) ENGINE=innodb; + +ALTER TABLE llx_website_pages ADD UNIQUE INDEX uk_website_pages_url (fk_website,pageurl); + +ALTER TABLE llx_website_pages ADD CONSTRAINT fk_website_pages_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); + + +-- For new module blockedlog + CREATE TABLE llx_blockedlog ( rowid integer AUTO_INCREMENT PRIMARY KEY, diff --git a/htdocs/install/mysql/tables/llx_website_pages.key.sql b/htdocs/install/mysql/tables/llx_website_pages.key.sql index 095dffabc95..00b9439d18b 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.key.sql +++ b/htdocs/install/mysql/tables/llx_website_pages.key.sql @@ -16,7 +16,7 @@ -- -- =========================================================================== -ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pageurl); +ALTER TABLE llx_website_pages ADD UNIQUE INDEX uk_website_pages_url (fk_website,pageurl); -ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); +ALTER TABLE llx_website_pages ADD CONSTRAINT fk_website_pages_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_pages.sql index 69b6c417528..d45d8f06f56 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.sql +++ b/htdocs/install/mysql/tables/llx_website_pages.sql @@ -17,7 +17,7 @@ -- ======================================================================== -CREATE TABLE llx_website_page +CREATE TABLE llx_website_pages ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, fk_website integer NOT NULL, diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index a5c2ae4e046..d27737dd3b2 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -458,7 +458,8 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage if (! is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - symlink($pathtomedias, $pathtomediasinwebsite); + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + $result = symlink($pathtomedias, $pathtomediasinwebsite); } /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) From a92effa6221b7e5f92d4764e06c7318801ad3586 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jul 2017 21:16:09 +0200 Subject: [PATCH 07/90] Fix clean test --- test/phpunit/RestAPIDocumentTest.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index b60a7e9e833..7eb485ffbab 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -144,11 +144,11 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase echo __METHOD__.' Request POST url='.$url."\n"; - + // Send to non existant directory - + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit'); - + //$data = '{ "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "" }'; $data = array( 'filename'=>"mynewfile.txt", @@ -158,7 +158,7 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase 'filecontent'=>"content text", 'fileencoding'=>"" ); - + $result = getURLContent($url, 'POST', $data, 1); echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; @@ -166,11 +166,11 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase $this->assertNotNull($object, 'Parsing of json result must no be null'); $this->assertEquals('401', $object['error']['code']); - + // Send to existant directory - + dol_mkdir(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit2'); - + $data = array( 'filename'=>"mynewfile.txt", 'modulepart'=>"medias", @@ -187,5 +187,7 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase $this->assertNotNull($object2, 'Parsing of json result must no be null'); $this->assertEquals($result2['curl_error_no'], ''); $this->assertEquals($result2['content'], 'true'); + + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit'); } } From fd89535037c041038fd4b70c7bede6685e215e46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Jul 2017 22:30:19 +0200 Subject: [PATCH 08/90] Debug module website --- htdocs/admin/websites.php | 16 ++-------------- htdocs/theme/eldy/ckeditor/config.js | 1 + htdocs/theme/md/ckeditor/config.js | 1 + htdocs/websites/index.php | 5 ++++- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 3b894536d04..9a12441fbb3 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -63,9 +63,6 @@ $pagenext = $page + 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admin')); -// This page is a generic page to edit dictionaries -// Put here declaration of dictionaries properties - // Name of SQL tables of dictionaries $tabname=array(); $tabname[1] = MAIN_DB_PREFIX."website"; @@ -341,7 +338,7 @@ if ($action == 'delete') //var_dump($elementList); /* - * Show a dictionary + * Show website list */ if ($id) { @@ -447,8 +444,7 @@ if ($id) - // List of available values in database - dol_syslog("htdocs/admin/dict", LOG_DEBUG); + // List of websites in database $resql=$db->query($sql); if ($resql) { @@ -465,14 +461,6 @@ if ($id) print ''; - // There is several pages - if ($num > $listlimit) - { - print ''; - } - // Title of lines print ''; foreach ($fieldlist as $field => $value) diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js index e4a86a37293..cddbef17dd1 100644 --- a/htdocs/theme/eldy/ckeditor/config.js +++ b/htdocs/theme/eldy/ckeditor/config.js @@ -15,6 +15,7 @@ CKEDITOR.editorConfig = function( config ) //config.height = '300px'; //config.resize_dir = 'vertical'; // horizontal, vertical, both config.removePlugins = 'elementspath,save'; // config.removePlugins = 'elementspath,save,font'; + //config.extraPlugins = 'docprops,scayt,showprotected'; config.removeDialogTabs = 'flash:advanced'; // config.removeDialogTabs = 'flash:advanced;image:Link'; config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // Prevent PHP Code to be formatted //config.menu_groups = 'clipboard,table,anchor,link,image'; // for context menu 'clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea' diff --git a/htdocs/theme/md/ckeditor/config.js b/htdocs/theme/md/ckeditor/config.js index a6508e62a88..e0374f6b271 100644 --- a/htdocs/theme/md/ckeditor/config.js +++ b/htdocs/theme/md/ckeditor/config.js @@ -15,6 +15,7 @@ CKEDITOR.editorConfig = function( config ) //config.height = '300px'; //config.resize_dir = 'vertical'; // horizontal, vertical, both config.removePlugins = 'elementspath,save'; // config.removePlugins = 'elementspath,save,font'; + //config.extraPlugins = 'docprops,scayt,showprotected'; config.removeDialogTabs = 'flash:advanced'; // config.removeDialogTabs = 'flash:advanced;image:Link'; config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // Prevent PHP Code to be formatted //config.menu_groups = 'clipboard,table,anchor,link,image'; // for context menu 'clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea' diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index d27737dd3b2..b2b8662fe08 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -1090,7 +1090,10 @@ if ($action == 'preview') $out.=$csscontent; $out.=''."\n"; - $out.=$objectpage->content."\n"; + // Replace php code + $content = preg_replace('/<\?php.*\?>/ims', '...php...', $objectpage->content); + + $out.=$content."\n"; $out.=''; From 253f7e252d9b16ef6d720466192a3bc795184924 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Mon, 10 Jul 2017 13:15:14 +1100 Subject: [PATCH 09/90] Fixes local taxes repports by rate --- htdocs/compta/localtax/quadri_detail.php | 16 ++++++------ htdocs/core/lib/tax.lib.php | 31 ++++++++++++++++-------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 175ff6cf98f..b7d8b1d6bad 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -54,8 +54,9 @@ if (empty($year)) $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); + +$date_start = dol_mktime( 0, 0, 0, GETPOST( "date_startmonth" ), GETPOST( "date_startday" ), GETPOST( "date_startyear" ) ); +$date_end = dol_mktime( 23, 59, 59, GETPOST( "date_endmonth" ), GETPOST( "date_endday" ), GETPOST( "date_endyear" ) ); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { @@ -92,12 +93,9 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); - - -/* +/** * View */ - $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); foreach($listofparams as $param) @@ -118,6 +116,7 @@ $paymentfourn_static=new PaiementFourn($db); $fsearch.=' '; $fsearch.=' '; +$fsearch.=' '; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; @@ -196,9 +195,8 @@ $total = 0; $i=0; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); - +$x_coll = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); echo '
'; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], '', ($num > $listlimit), ''); - print '
'; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 0fc401f0280..38ff0ed73f7 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -186,6 +186,7 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction * to report the amounts for different VAT rates as different lines. * This function also accounts recurrent invoices. * + * @param string $type Tax type, either vat, 'localtax1' or 'localtax2'. Default to 'vat' * @param DoliDB $db Database handler object * @param int $y Year * @param int $q Quarter @@ -196,7 +197,7 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction * @param int $m Month * @return array List of quarters with vat */ -function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) +function tax_by_date($type='vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) { global $conf; @@ -210,8 +211,6 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $fk_facture2='fk_facture'; $fk_payment='fk_paiement'; $total_tva='total_tva'; - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; $paymenttable='paiement'; $paymentfacturetable='paiement_facture'; $invoicefieldref='facnumber'; @@ -224,13 +223,20 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $fk_facture2='fk_facturefourn'; $fk_payment='fk_paiementfourn'; $total_tva='tva'; - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; $paymenttable='paiementfourn'; $paymentfacturetable='paiementfourn_facturefourn'; $invoicefieldref='ref'; } + if ( strpos( $type, 'localtax' ) === 0 ) { + $f_rate = $type . '_tx'; + } else { + $f_rate = 'tva_tx'; + } + + $total_localtax1='total_localtax1'; + $total_localtax2='total_localtax2'; + // CAS DES BIENS // Define sql request @@ -238,7 +244,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services { // Count on delivery date (use invoice date as delivery is unknown) - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql.= " d.date_start as date_start, d.date_end as date_end,"; $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; @@ -273,7 +279,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, else // Option vat on delivery for goods (payments) and payments for services { // Count on delivery date (use invoice date as delivery is unknown) - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql.= " d.date_start as date_start, d.date_end as date_end,"; $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef as date_f, s.nom as company_name, s.rowid as company_id,"; @@ -378,7 +384,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services { // Count on invoice date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql.= " d.date_start as date_start, d.date_end as date_end,"; $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; @@ -413,7 +419,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, else // Option vat on delivery for goods (payments) and payments for services { // Count on payments date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql.= " d.date_start as date_start, d.date_end as date_end,"; $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; @@ -522,7 +528,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $sql=''; // Count on payments date - $sql = "SELECT e.rowid, d.product_type as dtype, e.rowid as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; + $sql = "SELECT e.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; $sql.= " e.date_debut as date_start, e.date_fin as date_end,"; $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, s.nom as company_name, s.rowid as company_id, d.fk_c_type_fees as type,"; @@ -622,3 +628,8 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, return $list; } +function vat_by_date ($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) +{ + return tax_by_date('vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m); +} + From 244574f8e6d576f5e22c7d33b13730a4e1217f54 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Mon, 10 Jul 2017 13:19:59 +1100 Subject: [PATCH 10/90] Fixes functions comments --- htdocs/core/lib/tax.lib.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 38ff0ed73f7..802919af619 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -181,9 +181,9 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction } /** - * Gets VAT to collect for the given year (and given quarter or month) - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines. + * Gets Tax to collect for the given year (and given quarter or month) + * The function gets the Tax in split results, as the Tax declaration asks + * to report the amounts for different Tax rates as different lines. * This function also accounts recurrent invoices. * * @param string $type Tax type, either vat, 'localtax1' or 'localtax2'. Default to 'vat' @@ -628,6 +628,22 @@ function tax_by_date($type='vat', $db, $y, $q, $date_start, $date_end, $modetax, return $list; } +/** + * Gets VAT to collect for the given year (and given quarter or month) + * The function gets the VAT in split results, as the VAT declaration asks + * to report the amounts for different VAT rates as different lines. + * This function also accounts recurrent invoices. + * + * @param DoliDB $db Database handler object + * @param int $y Year + * @param int $q Quarter + * @param string $date_start Start date + * @param string $date_end End date + * @param int $modetax 0 or 1 (option vat on debit) + * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) + * @param int $m Month + * @return array List of quarters with vat + */ function vat_by_date ($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) { return tax_by_date('vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m); From 64a5be3e0092fccfc1fd43bef9d9f4d5fb045737 Mon Sep 17 00:00:00 2001 From: Laurent Dinclaux Date: Mon, 10 Jul 2017 14:14:21 +1100 Subject: [PATCH 11/90] Fixes travis error: Arguments with default values must be at the end of the argument list --- htdocs/core/lib/tax.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 802919af619..805adb9d796 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -186,7 +186,7 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction * to report the amounts for different Tax rates as different lines. * This function also accounts recurrent invoices. * - * @param string $type Tax type, either vat, 'localtax1' or 'localtax2'. Default to 'vat' + * @param string $type Tax type, either 'vat', 'localtax1' or 'localtax2' * @param DoliDB $db Database handler object * @param int $y Year * @param int $q Quarter @@ -197,7 +197,7 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction * @param int $m Month * @return array List of quarters with vat */ -function tax_by_date($type='vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) +function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) { global $conf; From bb2dc59c56163a35027408818e64bde4fa851302 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Jul 2017 11:29:09 +0200 Subject: [PATCH 12/90] More complete request to clean --- htdocs/install/mysql/migration/repair.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index f67869f67ba..f2e5066a066 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -330,7 +330,7 @@ drop table tmp_c_shipment_mode; -- Restore id of user on link for payment of expense report drop table tmp_bank_url_expense_user; create table tmp_bank_url_expense_user (select e.fk_user_author, bu2.fk_bank from llx_expensereport as e, llx_bank_url as bu2 where bu2.url_id = e.rowid and bu2.type = 'payment_expensereport'); -update llx_bank_url as bu set url_id = (select e.fk_user_author from tmp_bank_url_expense_user as e where e.fk_bank = bu.fk_bank) where bu.url_id = 0 and bu.type ='user'; +update llx_bank_url as bu set url_id = (select e.fk_user_author from tmp_bank_url_expense_user as e where e.fk_bank = bu.fk_bank) where (bu.url_id = 0 OR bu.url_id IS NULL) and bu.type ='user'; drop table tmp_bank_url_expense_user; From f85fcbd2161dedf23cfa75d710c4872418b9019b Mon Sep 17 00:00:00 2001 From: fappels Date: Mon, 10 Jul 2017 12:47:21 +0200 Subject: [PATCH 13/90] Fix categorie navigation --- htdocs/categories/class/categorie.class.php | 2 +- htdocs/categories/viewcat.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index db3364ff04d..1b292b9e470 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -133,7 +133,7 @@ class Categorie extends CommonObject ); public $element='category'; - public $table_element='categories'; + public $table_element='categorie'; public $fk_parent; public $label; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 11aff01dc99..1c6186d5df4 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -35,14 +35,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("categories"); $id=GETPOST('id','int'); -$ref=GETPOST('ref'); +$label=GETPOST('label'); $type=GETPOST('type'); $action=GETPOST('action','aZ09'); $confirm=GETPOST('confirm'); $removeelem = GETPOST('removeelem','int'); $elemid=GETPOST('elemid'); -if ($id == "") +if ($id == "" && $label == "") { dol_print_error('','Missing parameter id'); exit(); @@ -52,7 +52,7 @@ if ($id == "") $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -$result=$object->fetch($id); +$result=$object->fetch($id, $label); $object->fetch_optionals($id,$extralabels); if ($result <= 0) { @@ -195,7 +195,7 @@ $head = categories_prepare_head($object,$type); dol_fiche_head($head, 'card', $title, -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; - +$object->next_prev_filter=" type = ".$object->type; $object->ref = $object->label; $morehtmlref='
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); @@ -205,7 +205,7 @@ foreach ($ways as $way) } $morehtmlref.='
'; -dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); +dol_banner_tab($object, 'label', $linkback, ($user->societe_id?0:1), 'label', 'label', $morehtmlref, '', 0, '', '', 1); /* From 1ab3e0c3fa03bfbfb7e998e30c43981ba11feee9 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 10 Jul 2017 14:00:32 +0200 Subject: [PATCH 14/90] if no suppliers selected, no subprice yet --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 0c8410213af..1d27e7c4986 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2841,7 +2841,7 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " ".price2num($this->localtax2_tx).","; $sql.= " '".$this->localtax1_type."',"; $sql.= " '".$this->localtax2_type."',"; - $sql.= " ".price2num($this->subprice).","; + $sql.= " ".(!empty($this->subprice)?price2num($this->subprice):"null").","; $sql.= " ".price2num($this->remise_percent).","; $sql.= " ".(isset($this->info_bits)?"'".$this->info_bits."'":"null").","; $sql.= " ".price2num($this->total_ht).","; From 8c287c02ca2fb9d70f778ba302eda278310f9e9f Mon Sep 17 00:00:00 2001 From: AlainRnet Date: Mon, 10 Jul 2017 15:41:26 +0200 Subject: [PATCH 15/90] Update card.php Limitation of the number of characters that is not limited in the third card as described here: https://www.dolibarr.fr/forum/5-bugs-sur-la-version-cvs-ou-demo/59229-taille-limitee-de-l-adesse-mail-des-contacts --- htdocs/contact/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index fbd27b0d841..d5854297f43 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -625,7 +625,7 @@ else // EMail if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party print '
'; - print ''; + print ''; if (! empty($conf->mailing->enabled)) { print ''; @@ -860,7 +860,7 @@ else // EMail print ''; - print ''; + print ''; if (! empty($conf->mailing->enabled)) { $langs->load("mails"); From be09c911ce5a904d376b961623f7f65ab8a7a4a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Jul 2017 23:44:46 +0200 Subject: [PATCH 16/90] Debug module websites --- htdocs/admin/websites.php | 2 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 6 +- ...pages.key.sql => llx_website_page.key.sql} | 4 +- ...website_pages.sql => llx_website_page.sql} | 2 +- htdocs/langs/en_US/website.lang | 1 + htdocs/websites/class/websitepage.class.php | 2 +- htdocs/websites/index.php | 62 +++++++++++++------ 7 files changed, 53 insertions(+), 26 deletions(-) rename htdocs/install/mysql/tables/{llx_website_pages.key.sql => llx_website_page.key.sql} (80%) rename htdocs/install/mysql/tables/{llx_website_pages.sql => llx_website_page.sql} (97%) diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 9a12441fbb3..66776220d32 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -259,7 +259,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - $sql = "DELETE from ".MAIN_DB_PREFIX."website_pages WHERE fk_website ='".$rowid."'"; + $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'"; $result = $db->query($sql); $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'"; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index ec3a945bb09..0137353f714 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -497,7 +497,7 @@ ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup -- For new module website -CREATE TABLE llx_website_pages +CREATE TABLE llx_website_page ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, fk_website integer NOT NULL, @@ -513,9 +513,9 @@ CREATE TABLE llx_website_pages tms timestamp ) ENGINE=innodb; -ALTER TABLE llx_website_pages ADD UNIQUE INDEX uk_website_pages_url (fk_website,pageurl); +ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pageurl); -ALTER TABLE llx_website_pages ADD CONSTRAINT fk_website_pages_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); +ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); -- For new module blockedlog diff --git a/htdocs/install/mysql/tables/llx_website_pages.key.sql b/htdocs/install/mysql/tables/llx_website_page.key.sql similarity index 80% rename from htdocs/install/mysql/tables/llx_website_pages.key.sql rename to htdocs/install/mysql/tables/llx_website_page.key.sql index 00b9439d18b..14488e588dc 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.key.sql +++ b/htdocs/install/mysql/tables/llx_website_page.key.sql @@ -16,7 +16,7 @@ -- -- =========================================================================== -ALTER TABLE llx_website_pages ADD UNIQUE INDEX uk_website_pages_url (fk_website,pageurl); +ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website, pageurl); -ALTER TABLE llx_website_pages ADD CONSTRAINT fk_website_pages_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); +ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_page.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_website_pages.sql rename to htdocs/install/mysql/tables/llx_website_page.sql index d45d8f06f56..69b6c417528 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -17,7 +17,7 @@ -- ======================================================================== -CREATE TABLE llx_website_pages +CREATE TABLE llx_website_page ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, fk_website integer NOT NULL, diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index abb7f7e56d3..cc2f31143ce 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -4,6 +4,7 @@ WebsiteSetupDesc=Create here as much entry as number of different websites you n DeleteWebsite=Delete website ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. WEBSITE_PAGENAME=Page name/alias +WEBSITE_HTML_HEADER=HTML Header WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS content PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is read from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 99fd4d64603..4f9dc58c615 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -129,7 +129,7 @@ class WebsitePage extends CommonObject $sql.= 'content,'; $sql.= 'status,'; $sql.= 'date_creation,'; - $sql.= 'date_modification'; + $sql.= 'tms'; $sql .= ') VALUES ('; $sql .= ' '.(! isset($this->fk_website)?'NULL':$this->fk_website).','; $sql .= ' '.(! isset($this->pageurl)?'NULL':"'".$this->db->escape($this->pageurl)."'").','; diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index b2b8662fe08..2c9c364edac 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -129,6 +129,7 @@ if ($pageid > 0 && $action != 'add') global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website; +$filehtmlheader=$pathofwebsite.'/header.html'; $filecss=$pathofwebsite.'/styles.css.php'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; @@ -240,25 +241,30 @@ if ($action == 'delete') // Update css if ($action == 'updatecss') { - //$db->begin(); - $res = $object->fetch(0, $website); - /* - $res = $object->update($user); - if ($res > 0) - { - $db->commit(); - $action=''; - } - else + // Html header file + $htmlheadercontent = ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER'); + + dol_syslog("Save file css into ".$filehtmlheader); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($filehtmlheader, $htmlheadercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); + + if (! $result) { $error++; - $db->rollback(); - }*/ + setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); + } + // Css file $csscontent = ''."\n"; - $csscontent.= ''."\n"; + $csscontent.= ''."\n"; $csscontent.= '"."\n"; @@ -278,6 +284,7 @@ if ($action == 'updatecss') setEventMessages('Failed to write file '.$filecss, null, 'errors'); } + if (! $error) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -310,7 +317,7 @@ if ($action == 'setashome') dol_delete_file($fileindex); $indexcontent = ''."\n"; $result = file_put_contents($fileindex, $indexcontent); @@ -406,6 +413,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -414,8 +422,10 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= 'ref.'/header.html"); ?>'."\n"; $tplcontent.= '
'."\n"; $tplcontent.= ''."\n"; @@ -561,6 +571,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= "// END PHP ?>\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -568,8 +579,10 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= 'ref.'/header.html"); ?>'."\n"; $tplcontent.= '
'."\n"; $tplcontent.= ''."\n"; @@ -940,6 +953,11 @@ if ($action == 'editcss') print '
'; + $htmlheader = @file_get_contents($filehtmlheader); + // Clean the php css file to remove php code and get only html part + $htmlheader = preg_replace('//s', '', $htmlheader); + + $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part $csscontent = preg_replace('//s', '', $csscontent); @@ -958,11 +976,19 @@ if ($action == 'editcss') print '
'; + print ''; + /*print ''; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; print ''; print ''; print ''; @@ -986,9 +1010,11 @@ elseif (! empty($module)) print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; print ''; print ''; - print ''; - print ''; - print ''; + /*print '';*/ + print ''; print ''; } -/*if (! empty($arrayfields['u.statut']['checked'])) +/*if (! empty($arrayfields['t.statut']['checked'])) { // Status print ''; diff --git a/htdocs/modulebuilder/template/sql/llx_myobject.key.sql b/htdocs/modulebuilder/template/sql/llx_myobject.key.sql index 812a98090af..4822d7c3ac4 100644 --- a/htdocs/modulebuilder/template/sql/llx_myobject.key.sql +++ b/htdocs/modulebuilder/template/sql/llx_myobject.key.sql @@ -14,6 +14,9 @@ -- along with this program. If not, see . -ALTER TABLE llx_myobject ADD UNIQUE INDEX uk_fk_othertable (fk_othertable); ---ALTER TABLE llx_myobject ADD CONSTRAINT llx_mytable_field_id FOREIGN KEY (fk_field) REFERENCES llx_myOthertable(rowid); +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_myobject ADD UNIQUE INDEX idx_fieldobject (fieldobject); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_myobject ADD CONSTRAINT llx_myobject_field_id FOREIGN KEY (fk_field) REFERENCES llx_myotherobject(rowid); diff --git a/htdocs/modulebuilder/template/sql/llx_myobject.sql b/htdocs/modulebuilder/template/sql/llx_myobject.sql index 8cba239766f..b5810f0f227 100644 --- a/htdocs/modulebuilder/template/sql/llx_myobject.sql +++ b/htdocs/modulebuilder/template/sql/llx_myobject.sql @@ -13,9 +13,14 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . + CREATE TABLE llx_myobject( rowid INTEGER AUTO_INCREMENT PRIMARY KEY, + -- BEGIN MODULEBUILDER FIELDS entity INTEGER DEFAULT 1 NOT NULL, - fk_othertable INTEGER NOT NULL, - name VARCHAR(189) -); + label VARCHAR(255), + datec DATETIME NOT NULL, + tms TIMESTAMP NOT NULL, + status INTEGER + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; \ No newline at end of file From 94309525616d60647ba137f449ada6527777bca5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 12 Jul 2017 11:00:18 +0200 Subject: [PATCH 29/90] Fix: missing entity filter (multicompany) --- htdocs/comm/card.php | 121 +++++++------- htdocs/societe/class/societe.class.php | 221 +++++++++++++------------ 2 files changed, 178 insertions(+), 164 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a51ef902eb6..dfdc9183886 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Alexandre Spangaro @@ -534,74 +534,73 @@ if ($id > 0) $boxstat.='
email).'">email).'">
email).'">email).'">
'; print $langs->trans('WEBSITE_CSS_INLINE'); print ''; - print ''; print '
'; + print $langs->trans('WEBSITE_HTML_HEADER'); + print ''; + print ''; + print '
'; print $langs->trans('WEBSITE_CSS_URL'); print ''; From c75db29ff2a67345b78bf4cad4e01cf8a661253f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Jul 2017 12:54:03 +0200 Subject: [PATCH 17/90] Fix warning when module position is not correct --- htdocs/core/class/menubase.class.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 137a5517231..431c5d19eeb 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -402,7 +402,8 @@ class Menubase } /** - * Load entries found from database in this->newmenu array. + * Load entries found from database (and stored into $tabMenu) in $this->newmenu array. + * Warning: Entries in $tabMenu must have child after parent * * @param Menu $newmenu Menu array to complete (in most cases, it's empty, may be already initialized with some menu manager like eldy) * @param string $mymainmenu Value for mainmenu to filter menu to load (often $_SESSION["mainmenu"]) @@ -435,10 +436,10 @@ class Menubase // We initialize newmenu with first already found menu entries $this->newmenu = $newmenu; - // Now edit this->newmenu->list to add entries found into tabMenu that are childs of mainmenu claimed, using the fk_menu link (old method) + // Now complete $this->newmenu->list to add entries found into $tabMenu that are childs of mainmenu=$menutopid, using the fk_menu link that is int (old method) $this->recur($tabMenu, $menutopid, 1); - // Now update this->newmenu->list when fk_menu value is -1 (left menu added by modules with no top menu) + // Now complete $this->newmenu->list when fk_menu value is -1 (left menu added by modules with no top menu) foreach($tabMenu as $key => $val) { //var_dump($tabMenu); @@ -479,6 +480,10 @@ class Menubase } //print 'We must insert menu entry between entry '.$lastid.' and '.$nextid.'
'; if ($found) $this->newmenu->insert($lastid, $val['url'], $val['titre'], $searchlastsub, $val['perms'], $val['target'], $val['mainmenu'], $val['leftmenu'], $val['position']); + else { + dol_syslog("Error. Modules ".$val['module']." has defined a menu entry with a parent='fk_mainmenu=".$val['fk_leftmenu'].",fk_leftmenu=".$val['fk_leftmenu']."' and position=".$val['position'].'. The parent was not found. May be you forget it into your definition of menu, or may be the parent has a "position" that is after the child (fix field "position" of parent or child in this case).', LOG_WARNING); + //print "Parent menu not found !!
"; + } } } } @@ -494,7 +499,7 @@ class Menubase * @param string $myleftmenu Value for left that defined leftmenu * @param int $type_user Looks for menu entry for 0=Internal users, 1=External users * @param string $menu_handler Name of menu_handler used ('auguria', 'eldy'...) - * @param array $tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled) + * @param array $tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled) * @return int >0 if OK, <0 if KO */ function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) @@ -610,6 +615,11 @@ class Menubase $a++; } $this->db->free($resql); + + // Currently $tabMenu is sorted on position. + // If a child have a position lower that its parent, we can make a loop to fix this here, but we prefer to show a warning + // into the leftMenuCharger later to avoid useless operations. + return 1; } else @@ -622,7 +632,7 @@ class Menubase /** * Complete this->newmenu with menu entry found in $tab * - * @param array $tab Tab array + * @param array $tab Tab array with all menu entries * @param int $pere Id of parent * @param int $level Level * @return void From 90dcd3d30db51398ccfc594ff2ee3f79b829ed4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Jul 2017 13:25:41 +0200 Subject: [PATCH 18/90] Look and feel v6 --- htdocs/societe/price.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 5146e3ad6a5..d7b683f92e7 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -187,7 +187,7 @@ if (! empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); -dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), 0, 'company'); +dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -200,11 +200,11 @@ print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print ''; + print ''; } if ($object->client) { - print '
' . $langs->trans('Prefix') . '' . $object->prefix_comm . '
' . $langs->trans('Prefix') . '' . $object->prefix_comm . '
'; + print '
'; print $langs->trans('CustomerCode') . ''; print $object->code_client; if ($object->check_codeclient() != 0) @@ -213,7 +213,7 @@ if ($object->client) { } if ($object->fournisseur) { - print '
'; + print '
'; print $langs->trans('SupplierCode') . ''; print $object->code_fournisseur; if ($object->check_codefournisseur() != 0) From c85bf18f0e20042739366d6d5df58a8a866ab292 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 11 Jul 2017 14:47:37 +0200 Subject: [PATCH 19/90] Fix AdvtargetEmailing --- htdocs/comm/mailing/advtargetemailing.php | 10 ++-- .../html.formadvtargetemailing.class.php | 51 ++----------------- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 + .../mysql/tables/llx_mailing_cibles.sql | 2 +- 4 files changed, 11 insertions(+), 54 deletions(-) diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 81c29f687ce..e0a3e5cea79 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -22,6 +22,8 @@ * \brief Page to define emailing targets */ +if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php'; @@ -404,14 +406,8 @@ if ($_POST["button_removefilter"]) { * View */ -$extrajs = array ( - '/includes/jquery/plugins/multiselect/js/ui.multiselect.js' -); -$extracss = array ( - '/includes/jquery/plugins/multiselect/css/ui.multiselect.css', -); -llxHeader('', $langs->trans("MailAdvTargetRecipients"), '', '', '', '', $extrajs, $extracss); +llxHeader('', $langs->trans("MailAdvTargetRecipients")); print ''; - $return .= ''; - - if ($showempty) - $return .= ''; - - // Find if keys is in selected array value - if (is_array($selected_array) && count($selected_array)>0) { - $intersect_array = array_intersect_key($options_array, array_flip($selected_array)); - } else { - $intersect_array=array(); - } - - if (count($options_array) > 0) { - foreach ($options_array as $keyoption => $valoption) { - // If key is in intersect table then it have to e selected - $selected = ''; - if (count ( $intersect_array ) > 0) { - if (array_key_exists ( $keyoption, $intersect_array )) { - $selected = ' selected="selected"'; - } - } - $return .= '' . $valoption . ''; - } - } - - $return .= ''; - + $form=new Form($this->db); + $return = $form->multiselectarray($htmlname, $options_array, $selected_array,0,0,'',0,295); return $return; } @@ -448,7 +407,7 @@ class FormAdvTargetEmailing extends Form dol_print_error($this->db); } - return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + return $this->advMultiselectarray( $htmlname, $options_array, $selected_array ); } /** diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 8e4785ab4d9..5836cb740dc 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -534,3 +534,5 @@ ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature); UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur'; UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client'; + +ALTER TABLE llx_mailing_cibles MODIFY COLUMN source_url varchar(1000); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_mailing_cibles.sql b/htdocs/install/mysql/tables/llx_mailing_cibles.sql index f3031069220..eec4a655da2 100644 --- a/htdocs/install/mysql/tables/llx_mailing_cibles.sql +++ b/htdocs/install/mysql/tables/llx_mailing_cibles.sql @@ -30,7 +30,7 @@ create table llx_mailing_cibles other varchar(255) NULL, tag varchar(128) NULL, statut smallint NOT NULL DEFAULT 0, -- -1 = error, 0 = not sent, ... - source_url varchar(160), + source_url varchar(1000), source_id integer, source_type varchar(16), date_envoi datetime, From e1d9dfc862c21ca279eb592db8472f0ae3ce31de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Jul 2017 15:12:01 +0200 Subject: [PATCH 20/90] Complete example of template --- .../template/core/modules/modMyModule.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 33c52d58bea..fbfffba07ed 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -288,6 +288,12 @@ class modMyModule extends DolibarrModules $this->_load_tables('/mymodule/sql/'); + // Create extrafields + include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'string', 1, 10, 'project'); + return $this->_init($sql, $options); } From cbde99b4197aa6cbec5d7dae01586cd35d0cf946 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Jul 2017 15:50:20 +0200 Subject: [PATCH 21/90] More complete exemple --- .../modulebuilder/template/core/modules/modMyModule.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index fbfffba07ed..cd3fb22be80 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -99,7 +99,7 @@ class modMyModule extends DolibarrModules ); // Data directories to create when module is enabled. - // Example: this->dirs = array("/mymodule/temp"); + // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); $this->dirs = array(); // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. From 017b654acd8c2a956d13c162b39ba2f58accc1f7 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 11 Jul 2017 17:45:16 +0200 Subject: [PATCH 22/90] FIX PgSQL --- .../install/mysql/migration/4.0.0-5.0.0.sql | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 5f62c766a01..76c8f6df672 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -134,7 +134,7 @@ CREATE TABLE llx_product_lot_extrafields ALTER TABLE llx_product_lot_extrafields ADD INDEX idx_product_lot_extrafields (fk_object); -ALTER TABLE llx_website_page MODIFY content MEDIUMTEXT; +ALTER TABLE llx_website_page MODIFY COLUMN content MEDIUMTEXT; CREATE TABLE llx_product_warehouse_properties ( @@ -160,7 +160,7 @@ ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (accou ALTER TABLE llx_expensereport_det ADD COLUMN fk_code_ventilation integer DEFAULT 0; -ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; +ALTER TABLE llx_c_payment_term CHANGE COLUMN fdm type_cdr tinyint; ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; @@ -173,11 +173,10 @@ ALTER TABLE llx_supplier_proposaldet ADD COLUMN vat_src_code varchar(10) DEFAULT ALTER TABLE llx_supplier_proposaldet ADD COLUMN fk_unit integer DEFAULT NULL; ALTER TABLE llx_contratdet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; -ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; +ALTER TABLE llx_c_payment_term CHANGE COLUMN fdm type_cdr TINYINT; ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT 0; - create table llx_resource_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -206,6 +205,8 @@ ALTER TABLE llx_overwrite_trans ADD COLUMN entity integer DEFAULT 1 NOT NULL AFT ALTER TABLE llx_mailing_cibles ADD COLUMN error_text varchar(255); ALTER TABLE llx_c_actioncomm MODIFY COLUMN type varchar(50) DEFAULT 'system' NOT NULL; +-- VPGSQL8.2 ALTER TABLE llx_c_actioncomm ALTER COLUMN type SET DEFAULT 'system'; +-- VPGSQL8.2 ALTER TABLE llx_c_actioncomm ALTER COLUMN type SET NOT NULL; create table llx_user_employment ( @@ -240,12 +241,12 @@ ALTER TABLE llx_expensereport ADD INDEX idx_expensereport_fk_refuse (fk_user_app DELETE FROM llx_actioncomm_resources WHERE fk_actioncomm not in (select id from llx_actioncomm); -- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate. -drop table tmp_links_double; +DROP TABLE tmp_links_double; --select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2; -create table tmp_links_double as (select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2); +CREATE TABLE tmp_links_double AS (SELECT objectid, label, MAX(rowid) AS max_rowid, COUNT(rowid) AS count_rowid FROM llx_links WHERE label IS NOT NULL GROUP BY objectid, label HAVING COUNT(rowid) >= 2); --select * from tmp_links_double; -delete from llx_links where (rowid, label) in (select max_rowid, label from tmp_links_double); --update to avoid duplicate, delete to delete -drop table tmp_links_double; +DELETE FROM llx_links WHERE (rowid, label) IN (SELECT max_rowid, label FROM tmp_links_double); --update to avoid duplicate, delete to delete +DROP TABLE tmp_links_double; ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label); @@ -256,8 +257,7 @@ ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity); ALTER TABLE llx_contrat ADD COLUMN fk_user_modif integer; - -update llx_accounting_account set account_parent = 0 where account_parent = ''; +UPDATE llx_accounting_account SET account_parent = 0 WHERE account_parent = ''; -- VMYSQL4.3 ALTER TABLE llx_product_price MODIFY COLUMN date_price DATETIME NULL; -- VPGSQL8.2 ALTER TABLE llx_product_price ALTER COLUMN date_price DROP NOT NULL; @@ -268,10 +268,8 @@ ALTER TABLE llx_product_customer_price ADD COLUMN default_vat_code varchar(10) a ALTER TABLE llx_product_customer_price_log ADD COLUMN default_vat_code varchar(10) after tva_tx; ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) after tva_tx; - ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); - UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur'; UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client'; From be837a22da2bd7e37cad22761e6d1abeeb05179e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 11 Jul 2017 18:43:36 +0200 Subject: [PATCH 23/90] Fix: error during upgrade process --- htdocs/core/modules/modProduct.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index dae39fc00d4..5a80643c387 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -83,14 +83,14 @@ class modProduct extends DolibarrModules $this->const[$r][3] = 'Module to control product codes'; $this->const[$r][4] = 0; $r++; - + /*$this->const[$r][0] = "PRODUCT_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "standard"; $this->const[$r][3] = 'Default module for document generation'; $this->const[$r][4] = 0; $r++;*/ - + // Boxes $this->boxes = array( 0=>array('file'=>'box_produits.php','enabledbydefaulton'=>'Home'), @@ -133,7 +133,7 @@ class modProduct extends DolibarrModules // Menus //------- - + $this->menu = 1; // This module add menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert $r=0; @@ -159,7 +159,7 @@ class modProduct extends DolibarrModules $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("produit","export")); $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); - if ($mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'SuppliersPrices')); @@ -189,7 +189,7 @@ class modProduct extends DolibarrModules if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" - + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice @@ -203,7 +203,7 @@ class modProduct extends DolibarrModules 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); - if ($mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", @@ -246,7 +246,7 @@ class modProduct extends DolibarrModules $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; - } + } // Imports //-------- @@ -262,7 +262,7 @@ class modProduct extends DolibarrModules $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); - if ($mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); // Add extra fields $import_extrafield_sample=array(); @@ -331,7 +331,7 @@ class modProduct extends DolibarrModules 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation*'); - if ($mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1", 'pr.price_base_type'=>"HT",'pr.price_level'=>"1", From ceeb9d7f1b93046d84d6477a84b4ffad08eff68b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Jul 2017 20:47:49 +0200 Subject: [PATCH 24/90] Debug modulebuilder --- htdocs/langs/en_US/modulebuilder.lang | 2 + htdocs/modulebuilder/index.php | 231 +++++++++++++----- .../template/class/myobject.class.php | 20 +- .../modulebuilder/template/myobject_list.php | 24 +- 4 files changed, 198 insertions(+), 79 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 8fab0a7b07f..5a3470aebce 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -38,3 +38,5 @@ PathToModulePackage=Path to zip of module/application package PathToModuleDocumentation=Path to file of module/application documentation SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. FileNotYetGenerated=File not yet generated +SpecificationFile=File with business rules +ConfirmDeleteProperty=Are you sure you want to delete the property %s ? This will change code in PHP class but also remove column from table definition of object. \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 2547b893055..a1c30b7c94a 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -37,9 +37,10 @@ $cancel=GETPOST('cancel','alpha'); $module=GETPOST('module','alpha'); $tab=GETPOST('tab','aZ09'); $tabobj=GETPOST('tabobj','alpha'); +$propertykey=GETPOST('propertykey','alpha'); if (empty($module)) $module='initmodule'; if (empty($tab)) $tab='description'; -if (empty($tabobj)) $tabobj='newobject'; +if (empty($tabobj)) $tabobj='newobjectifnoobj'; $file=GETPOST('file','alpha'); $modulename=dol_sanitizeFileName(GETPOST('modulename','alpha')); @@ -58,6 +59,7 @@ $FILEFLAG='modulebuilder.txt'; $now=dol_now(); + /* * Actions */ @@ -320,6 +322,29 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) $tabobj = 'deleteobject'; } +if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) +{ + if (! $error) + { + $modulelowercase=strtolower($module); + $objectlowercase=strtolower($objectname); + + // File of class + $fileforclass = $dirins.'/'.$modulelowercase.'/class/'.$objectlowercase.'.class.php'; + + // TODO + + // File of sql + $fileforsql = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.sql'; + $fileforsqlkey = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.key.sql'; + + + // TODO + } +} + + + if ($dirins && $action == 'generatepackage') { $modulelowercase=strtolower($module); @@ -838,9 +863,11 @@ elseif (! empty($module)) $h++; $listofobject = dol_dir_list($dir, 'files', 0, '\.txt$'); + $firstobjectname=''; foreach($listofobject as $fileobj) { $objectname = preg_replace('/\.txt$/', '', $fileobj['name']); + if (empty($firstobjectname)) $firstobjectname = $objectname; $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj='.$objectname; $head3[$h][1] = $objectname; @@ -853,6 +880,12 @@ elseif (! empty($module)) $head3[$h][2] = 'deleteobject'; $h++; + // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. + if ($tabobj == 'newobjectifnoobj') + { + if ($firstobjectname) $tabobj=$firstobjectname; + else $tabobj = 'newobject'; + } dol_fiche_head($head3, $tabobj, '', -1, ''); @@ -888,92 +921,168 @@ elseif (! empty($module)) } else { - try { - $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; - $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; - $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.class.php'; - $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.class.php'; - print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.'
'; - print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.'
'; - print ' '.$langs->trans("PageForList").' : '.$pathtolist.'
'; - print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.'
'; + if ($action == 'deleteproperty') + { + $formconfirm = $form->formconfirm( + $_SERVER["PHP_SELF"].'?propertykey='.urlencode(GETPOST('propertykey','alpha')).'&objectname='.urlencode($objectname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj), + $langs->trans('Delete'), $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey','alpha')), 'confirm_deleteproperty', '', 0, 1 + ); - $result = dol_include_once($pathtoclass); - $tmpobjet = new $tabobj($db); + // Print form confirm + print $formconfirm; + } - $reflector = new ReflectionClass($tabobj); - $properties = $reflector->getProperties(); // Can also use get_object_vars - $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars - //$propstat = $reflector->getStaticProperties(); + if ($action != 'editfile' || empty($file)) + { + try { + $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; + $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; + $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; + $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; + print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForList").' : '.$pathtolist.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print load_fiche_titre($langs->trans("Properties"), '', ''); + $result = dol_include_once($pathtoclass); + $tmpobjet = new $tabobj($db); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + $reflector = new ReflectionClass($tabobj); + $properties = $reflector->getProperties(); // Can also use get_object_vars + $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars + //$propstat = $reflector->getStaticProperties(); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - foreach($properties as $propkey => $propval) - { - if ($propval->class == $tabobj) + print load_fiche_titre($langs->trans("Properties"), '', ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Property"); - print ' ('.$langs->trans("Example").')'; - print ''.$langs->trans("Comment").''.$langs->trans("Type").''.$langs->trans("DefaultValue").'
'; - print ''; - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $properties = $tmpobjet->fields; + + foreach($properties as $propkey => $propval) { - $propname=$propval->getName(); + /* If from Reflection + if ($propval->class == $tabobj) + { + $propname=$propval->getName(); + $comment=$propval->getDocComment(); + $type=gettype($tmpobjet->$propname); + $default=$propdefault[$propname]; + // Discard generic properties + if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; - // Discard generic properties - if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; + // Keep or not lines + if (in_array($propname, array('fk_element', 'lines'))) continue; + }*/ - // Keep or not lines - if (in_array($propname, array('fk_element', 'lines'))) continue; + $propname=$propkey; + $proplabel=$propval['label']; + $proptype=$propval['type']; + $propposition=$propval['position']; + $propdefault=$propval['default']; + $propindex=$propval['index']; + $propcomment=$propval['comment']; + print ''; - print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } + print '
'.$langs->trans("Property"); + print ' ('.$langs->trans("Example").')'; + print ''.$langs->trans("Label").''.$langs->trans("Type").''.$langs->trans("Position").''.$langs->trans("DefaultValue").''.$langs->trans("Index").''.$langs->trans("Comment").'
'; + print ''; + print '
'; + print ''; print $propname; print ''; - print $propval->getDocComment(); + print $proplabel; print ''; - print gettype($tmpobjet->$propname); + print $proptype; print ''; - print $propdefault[$propname]; + print $propposition; print ''; - + print $propdefault; print ''; + print yn($propindex); + print ''; + print $propcomment; + print ''; + print ''.img_delete().''; + print '
'; + + print '
'; } - print '
'; + catch(Exception $e) + { + print $e->getMessage(); + } + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '600', 'Full', 'In', true, false, false, 0, '99%'); + print $doleditor->Create(1, '', false); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; print '
'; } - catch(Exception $e) - { - print $e->getMessage(); - } } } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 9ef593367c9..4c85a6e5a86 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -52,22 +52,24 @@ class MyObject extends CommonObject * @var array Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ protected $ismultientitymanaged = 1; - - /** - * @var string String with name of icon for myobject - */ + * @var string String with name of icon for myobject + */ public $picto = 'myobject'; - /** - * @var int Entity Id - */ - public $entity; + /* BEGIN PROPERTY FIELDS - Do not remove this comment */ /** * @var array Array with all fields and their property */ - public $fields; + public $fields=array( + 'ref'=>array('type'=>'string','label'=>'Ref','position'=>10,'index'=>true,'comment'=>'Reference of object'), + 'entity'=>array('type'=>'integer','label'=>'Entity','index'=>true), + 'status'=>array('type'=>'integer','label'=>'Status','index'=>true), + 'date'=>array('type'=>'date','label'=>'Date','default'=>'__NOW__'), + 'title'=>array('type'=>'string','label'=>'Title'), + ); + /* END PROPERTY FIELDS - Do not remove this comment */ diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 28624dc9fc2..7e67c04ecc2 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -68,13 +68,7 @@ $toselect = GETPOST('toselect', 'array'); $id = GETPOST('id','int'); $backtopage = GETPOST('backtopage'); -$myparam = GETPOST('myparam','alpha'); - -$search_all=trim(GETPOST("sall")); -$search_field1=GETPOST("search_field1"); -$search_field2=GETPOST("search_field2"); -$search_myfield=GETPOST('search_myfield'); -$optioncss = GETPOST('optioncss','alpha'); +$optioncss = GETPOST('optioncss','alpha'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; @@ -85,6 +79,7 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; + if (! $sortfield) $sortfield="t.rowid"; // Set here default search field if (! $sortorder) $sortorder="ASC"; @@ -96,6 +91,19 @@ if ($user->societe_id > 0) //accessforbidden(); } +// Initialize array of search criterias +$object=new MyModule($db); +$search_all=trim(GETPOST("search_all")); +$search=array(); +foreach($object->fields as $key) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} +/*$search_field1=GETPOST("search_field1"); +$search_field2=GETPOST("search_field2"); +$search_myfield=GETPOST('search_myfield'); +*/ + // Initialize technical object to manage context to save list fields $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; @@ -133,8 +141,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } -$object=new Skeleton_Class($db); - From f745c8739405c6e4e1bbcb1cb50833cbf6cfab33 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 11 Jul 2017 21:27:51 +0200 Subject: [PATCH 25/90] Fix: error during upgrade process --- htdocs/core/modules/modProduct.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index dae39fc00d4..5a80643c387 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -83,14 +83,14 @@ class modProduct extends DolibarrModules $this->const[$r][3] = 'Module to control product codes'; $this->const[$r][4] = 0; $r++; - + /*$this->const[$r][0] = "PRODUCT_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "standard"; $this->const[$r][3] = 'Default module for document generation'; $this->const[$r][4] = 0; $r++;*/ - + // Boxes $this->boxes = array( 0=>array('file'=>'box_produits.php','enabledbydefaulton'=>'Home'), @@ -133,7 +133,7 @@ class modProduct extends DolibarrModules // Menus //------- - + $this->menu = 1; // This module add menu entries. They are coded into menu manager. /* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert $r=0; @@ -159,7 +159,7 @@ class modProduct extends DolibarrModules $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("produit","export")); $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); - if ($mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'SuppliersPrices')); @@ -189,7 +189,7 @@ class modProduct extends DolibarrModules if (! empty($conf->fournisseur->enabled)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc'; $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_sql_order[$r] =' GROUP BY p.rowid'; // FIXME The group by used a generic value to say "all fields in select except function fields" - + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { // Exports product multiprice @@ -203,7 +203,7 @@ class modProduct extends DolibarrModules 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation'); - if ($mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; + if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly']='NPR'; //$this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product", 'pr.price_base_type'=>"product",'pr.price_level'=>"product",'pr.price'=>"product", @@ -246,7 +246,7 @@ class modProduct extends DolibarrModules $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; - } + } // Imports //-------- @@ -262,7 +262,7 @@ class modProduct extends DolibarrModules $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); - if ($mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); // Add extra fields $import_extrafield_sample=array(); @@ -331,7 +331,7 @@ class modProduct extends DolibarrModules 'pr.price_min'=>"MinPriceLevelUnitPriceHT",'pr.price_min_ttc'=>"MinPriceLevelUnitPriceTTC", 'pr.tva_tx'=>'PriceLevelVATRate', 'pr.date_price'=>'DateCreation*'); - if ($mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('pr.recuperableonly'=>'NPR')); $this->import_regex_array[$r]=array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','pr.recuperableonly'=>'^[0|1]$'); $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"1", 'pr.price_base_type'=>"HT",'pr.price_level'=>"1", From f1d451eb12b9aa0f4199c438bea4d087900eda3d Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 11 Jul 2017 23:06:33 +0200 Subject: [PATCH 26/90] FIX empty thirdparty getNomUrl() call without thirdparty --- htdocs/projet/tasks/task.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index f85b5071de1..f936cddd4e9 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -458,9 +458,11 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'; // Third party - $morehtmlref.=$langs->trans("ThirdParty").': '; - $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); - $morehtmlref.=''; + if(!empty($projectstatic->thirdparty)) { + $morehtmlref.=$langs->trans("ThirdParty").': '; + $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + $morehtmlref.=''; + } } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); From b016b1ca5f46549a3748c670e2c2bdc999d6a56c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Jul 2017 23:19:47 +0200 Subject: [PATCH 27/90] Fix typo --- htdocs/langs/en_US/accountancy.lang | 2 +- htdocs/langs/en_US/main.lang | 3 ++- htdocs/modulebuilder/template/myobject_list.php | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 859fe1cca12..a4e7d72bc2c 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -103,7 +103,7 @@ LineOfExpenseReport=Line of expense report NoAccountSelected=No accounting account selected VentilatedinAccount=Binded successfully to the accounting account NotVentilatedinAccount=Not bound to the accounting account -XLineSuccessfullyBinded=%s products/services successfuly bound to an accounting account +XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account XLineFailedToBeBinded=%s products/services were not bound to any accounting account ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended : 50) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 58028423a35..a58d177061a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -75,7 +75,8 @@ FileRenamed=The file was successfully renamed FileGenerated=The file was successfully generated FileSaved=The file was successfully saved FileUploaded=The file was successfully uploaded -FileTransferComplete=File(s) was uploaded successfuly +FileTransferComplete=File(s) was uploaded successfully +FilesDeleted=File(s) successfully deleted FileWasNotUploaded=A file is selected for attachment but was not yet uploaded. Click on "Attach file" for this. NbOfEntries=Nb of entries GoToWikiHelpPage=Read online help (Internet access needed) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 7e67c04ecc2..1d7fad81473 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -174,11 +174,11 @@ if (empty($reshook)) } // Mass actions - $objectclass='Skeleton'; - $objectlabel='Skeleton'; - $permtoread = $user->rights->skeleton->read; - $permtodelete = $user->rights->skeleton->delete; - $uploaddir = $conf->skeleton->dir_output; + $objectclass='MyModule'; + $objectlabel='MyModule'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -290,7 +290,7 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1); if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2); -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields foreach ($search_array_options as $key => $val) { From 11cc1f04c4c129a30784b06c2dff69ef48bb3c9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Jul 2017 01:55:07 +0200 Subject: [PATCH 28/90] Work on modulebuilder --- htdocs/core/lib/modulebuilder.lib.php | 93 +++++++++++++++ htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/modulebuilder.lang | 9 +- htdocs/modulebuilder/index.php | 112 ++++++++++++------ .../template/class/myobject.class.php | 17 +-- .../modulebuilder/template/myobject_list.php | 94 +++++++-------- .../template/sql/llx_myobject.key.sql | 7 +- .../template/sql/llx_myobject.sql | 11 +- 8 files changed, 240 insertions(+), 104 deletions(-) create mode 100644 htdocs/core/lib/modulebuilder.lib.php diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php new file mode 100644 index 00000000000..f5f37ae91b1 --- /dev/null +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -0,0 +1,93 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/lib/memory.lib.php + * \brief Set of function for memory/cache management + */ + + +/** + * Save data into a memory area shared by all users, all sessions on server + * + * @param string $destdir Directory + * @param string $module Module name + * @param string $objectname Name of object + * @param string $newmask New mask + * @return int <0 if KO, >0 if OK + */ +function rebuildobjectsql($destdir, $module, $objectname, $newmask) +{ + global $db; + + if (empty($objectname)) return -1; + + dol_include_once(strtolower($module).'/class/'.strtolower($objectname).'.class.php'); + $object=new $objectname($db); + + // Edit sql files + $pathoffiletoedit=dol_osencode($destdir.'/sql/llx_'.strtolower($objectname).'.sql'); + + $contentsql = file_get_contents($pathoffiletoedit, 'r'); + + $i=0; + $texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n"; + foreach($object->fields as $key => $val) + { + $i++; + $texttoinsert.= "\t".$key." ".$val['type']; + if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; + if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; + $texttoinsert.= ($val['notnull']?' NOT NULL':''); + if ($i < count($object->fields)) $texttoinsert.=", "; + $texttoinsert.= "\n"; + } + $texttoinsert.= "\t".'-- END MODULEBUILDER FIELDS'; + + $contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql); + + file_put_contents($pathoffiletoedit, $contentsql); + @chmod($pathoffiletoedit, octdec($newmask)); + + + + // Edit sql files + $pathoffiletoedit=dol_osencode($destdir.'/sql/llx_'.strtolower($objectname).'.key.sql'); + + $contentsql = file_get_contents($pathoffiletoedit, 'r'); + + $i=0; + $texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n"; + foreach($object->fields as $key => $val) + { + $i++; + if ($val['index']) + { + $texttoinsert.= "ALTER TABLE llx_".strtolower($objectname)." ADD INDEX idx_".strtolower($objectname)."_".$key." (".$key.");"; + $texttoinsert.= "\n"; + } + } + $texttoinsert.= '-- END MODULEBUILDER INDEXES'; + + $contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql); + + file_put_contents($pathoffiletoedit, $contentsql); + @chmod($pathoffiletoedit, octdec($newmask)); + + return 1; +} diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a58d177061a..9251db5311f 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -736,6 +736,7 @@ ShowTransaction=Show entry on bank account GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide. Deny=Deny Denied=Denied +ListOf=List of %s ListOfTemplates=List of templates Gender=Gender Genderman=Man diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 5a3470aebce..f73aa4a1eb8 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -9,7 +9,8 @@ NewObject=New object ModuleKey=Module key ObjectKey=Object key ModuleInitialized=Module initialized -FilesForObjectInitialized=Files for new object initialized +FilesForObjectInitialized=Files for new object '%s' initialized +FilesForObjectUpdated=Files for object '%s' updated ModuleBuilderDescdescription=Enter here all general information that describe your module ModuleBuilderDescspecifications=You can enter here a long text to describe the specifications of your module that is not already structured into other tabs. So you have on hand the rules to develop. Also this text content will be included into the generated documentation (see last tab). ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A sql file, a page to list them, to create/edit/view a card and an API will be generated. @@ -39,4 +40,8 @@ PathToModuleDocumentation=Path to file of module/application documentation SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. FileNotYetGenerated=File not yet generated SpecificationFile=File with business rules -ConfirmDeleteProperty=Are you sure you want to delete the property %s ? This will change code in PHP class but also remove column from table definition of object. \ No newline at end of file +ConfirmDeleteProperty=Are you sure you want to delete the property %s ? This will change code in PHP class but also remove column from table definition of object. +NotNull=Not NULL +SearchAll=Used for 'search all' +DatabaseIndex=Database index +FileAlreadyExists=File %s already exists \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index a1c30b7c94a..18d66187f16 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -24,6 +24,7 @@ if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/modulebuilder.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("admin"); @@ -58,6 +59,12 @@ $dirins = $tmp[0]; $FILEFLAG='modulebuilder.txt'; $now=dol_now(); +$newmask = 0; +if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; +if (empty($newmask)) // This should no happen +{ + $newmask='0664'; +} /* @@ -158,14 +165,6 @@ if ($dirins && $action == 'initobject' && $module && $objectname) $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $destdir = $dirins.'/'.strtolower($module); - $arrayreplacement=array( - 'mymodule'=>strtolower($module), - 'MyModule'=>$module, - 'myobject'=>strtolower($objectname), - 'MyObject'=>$objectname - ); - - // Delete some files $filetogenerate = array( 'myobject_card.php'=>strtolower($objectname).'_card.php', @@ -182,7 +181,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) foreach($filetogenerate as $srcfile => $destfile) { - $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile); + $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); if ($result <= 0) { if ($result < 0) @@ -193,7 +192,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } else // $result == 0 { - setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings'); + setEventMessages($langs->trans("FileAlreadyExists", $destfile), null, 'warnings'); } } else @@ -212,10 +211,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname) //var_dump($phpfileval['fullname']); $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename, - 'MYMODULE'=>strtoupper($modulename), - 'My module'=>$modulename, + 'mymodule'=>strtolower($module), + 'MyModule'=>$module, + 'MYMODULE'=>strtoupper($module), + 'My module'=>$module, 'htdocs/modulebuilder/template/'=>'', 'myobject'=>strtolower($objectname), 'MyObject'=>$objectname @@ -232,7 +231,32 @@ if ($dirins && $action == 'initobject' && $module && $objectname) if (! $error) { - setEventMessages('FilesForObjectInitialized', null); + // Edit sql with new properties + rebuildobjectsql($destdir, $module, $objectname, $newmask); + + // Edit the class file to write properties + + + } + + if (! $error) + { + setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); + } +} + +if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj)) +{ + $objectname = $tabobj; + + $destdir = $dirins.'/'.strtolower($module); + + // Edit sql with new properties + rebuildobjectsql($destdir, $module, $objectname, $newmask); + + if (! $error) + { + setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); } } @@ -426,15 +450,7 @@ if ($action == 'savefile' && empty($cancel)) $content = GETPOST('editfilecontent'); // Save file on disk - $newmask = 0; - file_put_contents($pathoffile, $content); - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; - if (empty($newmask)) // This should no happen - { - $newmask='0664'; - } - @chmod($pathoffile, octdec($newmask)); setEventMessages($langs->trans("FileSaved"), null); @@ -939,18 +955,22 @@ elseif (! empty($module)) $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; + print '
'; print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print '
'; + print '
'; print ' '.$langs->trans("PageForList").' : '.$pathtolist.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print '
'; + + print '


'; $result = dol_include_once($pathtoclass); $tmpobjet = new $tabobj($db); @@ -964,7 +984,7 @@ elseif (! empty($module)) print '
'; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -974,11 +994,15 @@ elseif (! empty($module)) print '
'.$langs->trans("Property"); print ' ('.$langs->trans("Example").')'; print ''.$langs->trans("Label").''; + print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); + print ''.$langs->trans("Type").''.$langs->trans("Position").''.$langs->trans("DefaultValue").''.$langs->trans("Index").''.$langs->trans("Position").''.$langs->trans("NotNull").''.$langs->trans("SearchAll").''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("Comment").'
'; print ''; @@ -1016,7 +1042,9 @@ elseif (! empty($module)) $proplabel=$propval['label']; $proptype=$propval['type']; $propposition=$propval['position']; - $propdefault=$propval['default']; + $propnotnull=$propval['notnull']; + $propsearchall=$propval['searchall']; + //$propdefault=$propval['default']; $propindex=$propval['index']; $propcomment=$propval['comment']; @@ -1031,14 +1059,20 @@ elseif (! empty($module)) print ''; print $proptype; print ''; + print ''; print $propposition; print ''; - print $propdefault; + print ''; + print $propnotnull?'X':''; print ''; - print yn($propindex); + print ''; + print $propsearchall?'X':''; + print ''; + print $propdefault; + print ''; + print $propindex?'X':''; print ''; print $propcomment; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 4c85a6e5a86..7b0d83dfff0 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -47,7 +47,7 @@ class MyObject extends CommonObject /** * @var array Does this field is linked to a thirdparty ? */ - protected $isnolinkedbythird=1; + protected $isnolinkedbythird = 1; /** * @var array Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ @@ -58,18 +58,19 @@ class MyObject extends CommonObject public $picto = 'myobject'; - /* BEGIN PROPERTY FIELDS - Do not remove this comment */ + // BEGIN MODULEBUILDER PROPERTIES - Do not remove this comment /** * @var array Array with all fields and their property */ public $fields=array( - 'ref'=>array('type'=>'string','label'=>'Ref','position'=>10,'index'=>true,'comment'=>'Reference of object'), - 'entity'=>array('type'=>'integer','label'=>'Entity','index'=>true), - 'status'=>array('type'=>'integer','label'=>'Status','index'=>true), - 'date'=>array('type'=>'date','label'=>'Date','default'=>'__NOW__'), - 'title'=>array('type'=>'string','label'=>'Title'), + 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'position'=>10, 'notnull'=>true, 'index'=>true, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity'=>array('type'=>'integer', 'label'=>'Entity', 'notnull'=>true, 'index'=>true), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'searchall'=>1), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'notnull'=>true, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'notnull'=>true, 'position'=>500), + 'status'=>array('type'=>'integer', 'label'=>'Status', 'index'=>true, 'position'=>1000), ); - /* END PROPERTY FIELDS - Do not remove this comment */ + // Do not remove this comment - END MODULEBUILDER PROPERTIES diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 1d7fad81473..72fec670cb1 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -65,6 +65,7 @@ $massaction = GETPOST('massaction','alpha'); $show_files = GETPOST('show_files','int'); $confirm = GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search $id = GETPOST('id','int'); $backtopage = GETPOST('backtopage'); @@ -80,32 +81,27 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="t.rowid"; // Set here default search field +$object=new MyObject($db); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. if (! $sortorder) $sortorder="ASC"; // Protection if external user $socid=0; if ($user->societe_id > 0) { - $socid = $user->societe_id; - //accessforbidden(); + //$socid = $user->societe_id; + accessforbidden(); } // Initialize array of search criterias -$object=new MyModule($db); -$search_all=trim(GETPOST("search_all")); +$search_all=trim(GETPOST("search_all",'alpha')); $search=array(); -foreach($object->fields as $key) +foreach($object->fields as $key => $val) { if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); } -/*$search_field1=GETPOST("search_field1"); -$search_field2=GETPOST("search_field2"); -$search_myfield=GETPOST('search_myfield'); -*/ - -// Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('myobjectlist')); @@ -116,21 +112,18 @@ $extralabels = $extrafields->fetch_name_optionals_label('myobject'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // List of fields to search into when doing a "search in all" -$fieldstosearchall = array( - 't.ref'=>'Ref', - 't.note_public'=>'NotePublic', -); -if (empty($user->socid)) $fieldstosearchall["t.note_private"]="NotePrivate"; +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} // Definition of fields for list -$arrayfields=array( - 't.field1'=>array('label'=>"Field1", 'checked'=>1), - 't.field2'=>array('label'=>"Field2", 'checked'=>1), - //'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), - 't.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), - 't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - //'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), -); +$arrayfields=array(); +foreach($object->fields as $key => $val) +{ + $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>1); +} // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -143,11 +136,10 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab - /* * ACTIONS * - * Put here all code to do according to value of "action" parameter + * Put here all code to do according to value of "$action" parameter */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } @@ -165,17 +157,17 @@ if (empty($reshook)) // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { - $search_field1=''; - $search_field2=''; - $search_date_creation=''; - $search_date_update=''; + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } $toselect=''; $search_array_options=array(); } // Mass actions - $objectclass='MyModule'; - $objectlabel='MyModule'; + $objectclass='MyObject'; + $objectlabel='MyObject'; $permtoread = $user->rights->mymodule->read; $permtodelete = $user->rights->mymodule->delete; $uploaddir = $conf->mymodule->dir_output; @@ -196,7 +188,7 @@ $form=new Form($db); //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; $help_url=''; -$title = $langs->trans('MyModuleListTitle'); +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects")); // Put here content of your page @@ -215,24 +207,26 @@ jQuery(document).ready(function() { }); '; - -$sql = "SELECT"; -$sql.= " t.rowid,"; -$sql.= " t.field1,"; -$sql.= " t.field2"; +$sql = 'SELECT '; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (t.rowid = ef.fk_object)"; -$sql.= " WHERE 1 = 1"; -//$sql.= " WHERE u.entity IN (".getEntity('mytable').")"; -if ($search_field1) $sql.= natural_search("field1",$search_field1); -if ($search_field2) $sql.= natural_search("field2",$search_field2); -if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +$sql=preg_replace('/, $/','', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX."myobject as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; +$sql.= " WHERE t.entity IN (".getEntity('myobject').")"; +foreach($search as $key => $val) +{ + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0))); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields foreach ($search_array_options as $key => $val) { @@ -394,7 +388,7 @@ if (! empty($arrayfields['t.tms']['checked'])) print ''; print ''; @@ -507,7 +501,7 @@ while ($i < min($num, $limit)) } // Status /* - if (! empty($arrayfields['u.statut']['checked'])) + if (! empty($arrayfields['t.statut']['checked'])) { $userstatic->statut=$obj->statut; print ''.$userstatic->getLibStatut(3).'
'; $boxstat.=''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1605e7281b8..2bd764c92ed 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2005-2016 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Florian Henry @@ -3346,31 +3346,36 @@ class Societe extends CommonObject */ function getOutstandingProposals($mode='customer') { - $table='propal'; - if ($mode == 'supplier') $table = 'supplier_proposal'; + $table='propal'; + if ($mode == 'supplier') $table = 'supplier_proposal'; - $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('supplier_proposal').")"; + } else { + $sql .= " AND entity IN (".getEntity('propal').")"; + } - dol_syslog("getOutstandingProposals", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - if ($obj->fk_statut != 0) // Not a draft - { - $outstandingOpened+=$obj->total_ttc; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - return array(); + dol_syslog("getOutstandingProposals", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + while($obj=$this->db->fetch_object($resql)) { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + if ($obj->fk_statut != 0) // Not a draft + { + $outstandingOpened+=$obj->total_ttc; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + return array(); } /** @@ -3381,31 +3386,36 @@ class Societe extends CommonObject */ function getOutstandingOrders($mode='customer') { - $table='commande'; - if ($mode == 'supplier') $table = 'commande_fournisseur'; + $table='commande'; + if ($mode == 'supplier') $table = 'commande_fournisseur'; - $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('supplier_order').")"; + } else { + $sql .= " AND entity IN (".getEntity('commande').")"; + } - dol_syslog("getOutstandingOrders", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - if ($obj->fk_statut != 0) // Not a draft - { - $outstandingOpened+=$obj->total_ttc; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - return array(); + dol_syslog("getOutstandingOrders", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + while($obj=$this->db->fetch_object($resql)) { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + if ($obj->fk_statut != 0) // Not a draft + { + $outstandingOpened+=$obj->total_ttc; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + return array(); } /** @@ -3416,64 +3426,69 @@ class Societe extends CommonObject */ function getOutstandingBills($mode='customer') { - $table='facture'; - if ($mode == 'supplier') $table = 'facture_fourn'; + $table='facture'; + if ($mode == 'supplier') $table = 'facture_fourn'; - /* Accurate value of remain to pay is to sum remaintopay for each invoice - $paiement = $invoice->getSommePaiement(); - $creditnotes=$invoice->getSumCreditNotesUsed(); - $deposits=$invoice->getSumDepositsUsed(); - $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); - $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); - */ - if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + /* Accurate value of remain to pay is to sum remaintopay for each invoice + $paiement = $invoice->getSommePaiement(); + $creditnotes=$invoice->getSumCreditNotesUsed(); + $deposits=$invoice->getSumDepositsUsed(); + $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); + $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); + */ + if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('facture_fourn').")"; + } else { + $sql .= " AND entity IN (".getEntity('facture').")"; + } - dol_syslog("getOutstandingBills", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - if ($mode == 'supplier') - { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $tmpobject=new FactureFournisseur($this->db); - } - else - { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $tmpobject=new Facture($this->db); - } - while($obj=$this->db->fetch_object($resql)) { - $tmpobject->id=$obj->rowid; - if ($obj->fk_statut != 0 // Not a draft - && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice - ) - { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - } - if ($obj->paye == 0 - && $obj->fk_statut != 0 // Not a draft - && $obj->fk_statut != 3 // Not abandonned - && $obj->fk_statut != 2) // Not classified as paid - //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason - { - $paiement = $tmpobject->getSommePaiement(); - $creditnotes = $tmpobject->getSumCreditNotesUsed(); - $deposits = $tmpobject->getSumDepositsUsed(); - $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - { - return array(); - } + dol_syslog("getOutstandingBills", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + if ($mode == 'supplier') + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $tmpobject=new FactureFournisseur($this->db); + } + else + { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $tmpobject=new Facture($this->db); + } + while($obj=$this->db->fetch_object($resql)) { + $tmpobject->id=$obj->rowid; + if ($obj->fk_statut != 0 // Not a draft + && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice + ) + { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + } + if ($obj->paye == 0 + && $obj->fk_statut != 0 // Not a draft + && $obj->fk_statut != 3 // Not abandonned + && $obj->fk_statut != 2) // Not classified as paid + //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason + { + $paiement = $tmpobject->getSommePaiement(); + $creditnotes = $tmpobject->getSumCreditNotesUsed(); + $deposits = $tmpobject->getSumDepositsUsed(); + $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + { + return array(); + } } /** From 40b3ae2a1528340ec00d033233f513264d53c9f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Jul 2017 11:52:07 +0200 Subject: [PATCH 30/90] Debug modulebuilder --- htdocs/core/class/html.formfile.class.php | 6 +- htdocs/core/lib/modulebuilder.lib.php | 164 ++++++++++++--- htdocs/langs/en_US/modulebuilder.lang | 2 +- htdocs/modulebuilder/index.php | 16 +- .../template/class/myobject.class.php | 4 +- .../modulebuilder/template/myobject_list.php | 192 ++++++++++-------- 6 files changed, 259 insertions(+), 125 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index a5ccb33f084..040ae1ba96e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -314,7 +314,7 @@ class FormFile if (preg_match('/massfilesarea_/', $modulepart)) { - $out.='

'; + $out.='

'."\n"; $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; $title.=''; +// Build and execute select +// -------------------------------------------------------------------- $sql = 'SELECT '; foreach($object->fields as $key => $val) { @@ -275,15 +261,36 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } + +// Output page +// -------------------------------------------------------------------- + llxHeader('', $title, $help_url); +// Example : Adding jquery code +print ''; + $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1); -if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2); +foreach($search as $key => $val) +{ + $param.= '&search_'.$key.'='.urlencode($search[$key]); +} if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields foreach ($search_array_options as $key => $val) @@ -345,10 +352,16 @@ print '
'; - if ($conf->propal->enabled) + if (! empty($conf->propal->enabled)) { - // Box proposals - $tmp = $object->getOutstandingProposals(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; - $text=$langs->trans("OverAllProposals"); - $link=''; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
'; - $boxstat.=''.img_object("",$icon).' '.$text.'
'; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
'; - if ($link) $boxstat.='
'; + // Box proposals + $tmp = $object->getOutstandingProposals(); + $outstandingOpened=$tmp['opened']; + $outstandingTotal=$tmp['total_ht']; + $outstandingTotalIncTax=$tmp['total_ttc']; + $text=$langs->trans("OverAllProposals"); + $link=''; + $icon='bill'; + if ($link) $boxstat.=''; + $boxstat.='
'; + $boxstat.=''.img_object("",$icon).' '.$text.'
'; + $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat.='
'; + if ($link) $boxstat.='
'; } - if ($conf->commande->enabled) + if (! empty($conf->commande->enabled)) { - // Box proposals - $tmp = $object->getOutstandingOrders(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; - $text=$langs->trans("OverAllOrders"); - $link=''; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
'; - $boxstat.=''.img_object("",$icon).' '.$text.'
'; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
'; - if ($link) $boxstat.='
'; + // Box proposals + $tmp = $object->getOutstandingOrders(); + $outstandingOpened=$tmp['opened']; + $outstandingTotal=$tmp['total_ht']; + $outstandingTotalIncTax=$tmp['total_ttc']; + $text=$langs->trans("OverAllOrders"); + $link=''; + $icon='bill'; + if ($link) $boxstat.=''; + $boxstat.='
'; + $boxstat.=''.img_object("",$icon).' '.$text.'
'; + $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat.='
'; + if ($link) $boxstat.='
'; } - if ($conf->facture->enabled) + if (! empty($conf->facture->enabled)) { - $tmp = $object->getOutstandingBills(); - $outstandingOpened=$tmp['opened']; - $outstandingTotal=$tmp['total_ht']; - $outstandingTotalIncTax=$tmp['total_ttc']; + $tmp = $object->getOutstandingBills(); + $outstandingOpened=$tmp['opened']; + $outstandingTotal=$tmp['total_ht']; + $outstandingTotalIncTax=$tmp['total_ttc']; + $text=$langs->trans("OverAllInvoices"); + $link=''; + $icon='bill'; + if ($link) $boxstat.=''; + $boxstat.='
'; + $boxstat.=''.img_object("",$icon).' '.$text.'
'; + $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; + $boxstat.='
'; + if ($link) $boxstat.='
'; - $text=$langs->trans("OverAllInvoices"); - $link=''; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
'; - $boxstat.=''.img_object("",$icon).' '.$text.'
'; - $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; - $boxstat.='
'; - if ($link) $boxstat.='
'; - - // Box outstanding bill - $warn = ''; - if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) - { - $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); - } - $text=$langs->trans("CurrentOutstandingBill"); - $link=DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; - $icon='bill'; - if ($link) $boxstat.=''; - $boxstat.='
'; - $boxstat.=''.img_object("",$icon).' '.$text.'
'; - $boxstat.=''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; - $boxstat.='
'; - if ($link) $boxstat.='
'; + // Box outstanding bill + $warn = ''; + if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) + { + $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); + } + $text=$langs->trans("CurrentOutstandingBill"); + $link=DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; + $icon='bill'; + if ($link) $boxstat.=''; + $boxstat.='
'; + $boxstat.=''.img_object("",$icon).' '.$text.'
'; + $boxstat.=''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; + $boxstat.='
'; + if ($link) $boxstat.='
'; } $boxstat.='
'; -// LIST_OF_TD_TITLE_SEARCH -//if (! empty($arrayfields['t.field1']['checked'])) print ''; -//if (! empty($arrayfields['t.field2']['checked'])) print ''; +foreach($object->fields as $key => $val) +{ + if (in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; +} // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -376,25 +389,15 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) +// Rest of fields search +foreach($object->fields as $key => $val) { - // Date creation - print ''; + if (! in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; } -if (! empty($arrayfields['t.tms']['checked'])) -{ - // Date modification - print ''; -} -/*if (! empty($arrayfields['t.statut']['checked'])) - { - // Status - print ''; - }*/ // Action column print ''; print ''."\n"; -// Fields title + +// Fields title label +// -------------------------------------------------------------------- print ''; -// LIST_OF_TD_TITLE_FIELDS -//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder); -//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder); +foreach($object->fields as $key => $val) +{ + if (in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; +} // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -417,7 +427,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $sortonfield = "ef.".$key; if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; } } } @@ -425,10 +435,16 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder); -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); +// Rest of fields title +foreach($object->fields as $key => $val) +{ + if (! in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; +} +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print ''."\n"; @@ -440,6 +456,8 @@ foreach ($extrafields->attribute_computed as $key => $val) } +// Loop on record +// -------------------------------------------------------------------- $i=0; $totalarray=array(); while ($i < min($num, $limit)) @@ -449,18 +467,22 @@ while ($i < min($num, $limit)) { // Show here line of result print ''; - // LIST_OF_TD_FIELDS_LIST - /* - if (! empty($arrayfields['t.field1']['checked'])) + foreach($object->fields as $key => $val) { - print ''; - if (! $i) $totalarray['nbfield']++; + if (in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); + elseif ($key == 'status') print ''; + else print $obj->$key; + print ''; + if (! $i) $totalarray['nbfield']++; + } } - if (! empty($arrayfields['t.field2']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - }*/ // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -483,30 +505,23 @@ while ($i < min($num, $limit)) $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['t.datec']['checked'])) + // Rest of fields + foreach($object->fields as $key => $val) { - print ''; - if (! $i) $totalarray['nbfield']++; + if (! in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); + elseif ($key == 'status') print ''; + else print $obj->$key; + print ''; + if (! $i) $totalarray['nbfield']++; + } } - // Date modification - if (! empty($arrayfields['t.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - /* - if (! empty($arrayfields['t.statut']['checked'])) - { - $userstatic->statut=$obj->statut; - print ''; - }*/ - // Action column print ''; else print ''; } - elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalhtfield'] == $i) print ''; elseif ($totalarray['totalvatfield'] == $i) print ''; elseif ($totalarray['totalttcfield'] == $i) print ''; else print ''; @@ -567,13 +582,16 @@ print ''."\n"; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); + // Show list of available documents $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->lire; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->read; print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } From 25f9d782dc9218fa1a206c0e98414800844db4e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Jul 2017 12:30:07 +0200 Subject: [PATCH 31/90] NEW Add non intrusive js library to make syntaxic coloring of textarea --- COPYRIGHT | 1 + htdocs/includes/codepress/codepress.css | 21 + htdocs/includes/codepress/codepress.html | 35 ++ htdocs/includes/codepress/codepress.js | 138 ++++++ htdocs/includes/codepress/engines/gecko.js | 293 +++++++++++ htdocs/includes/codepress/engines/khtml.js | 0 htdocs/includes/codepress/engines/msie.js | 304 ++++++++++++ htdocs/includes/codepress/engines/older.js | 0 htdocs/includes/codepress/engines/opera.js | 260 ++++++++++ .../codepress/images/line-numbers.png | Bin 0 -> 16556 bytes htdocs/includes/codepress/index.html | 443 +++++++++++++++++ htdocs/includes/codepress/languages/asp.css | 71 +++ htdocs/includes/codepress/languages/asp.js | 117 +++++ .../includes/codepress/languages/autoit.css | 13 + htdocs/includes/codepress/languages/autoit.js | 32 ++ .../includes/codepress/languages/csharp.css | 9 + htdocs/includes/codepress/languages/csharp.js | 25 + htdocs/includes/codepress/languages/css.css | 10 + htdocs/includes/codepress/languages/css.js | 23 + .../includes/codepress/languages/generic.css | 9 + .../includes/codepress/languages/generic.js | 25 + htdocs/includes/codepress/languages/html.css | 13 + htdocs/includes/codepress/languages/html.js | 59 +++ htdocs/includes/codepress/languages/java.css | 7 + htdocs/includes/codepress/languages/java.js | 24 + .../codepress/languages/javascript.css | 8 + .../codepress/languages/javascript.js | 30 ++ htdocs/includes/codepress/languages/perl.css | 11 + htdocs/includes/codepress/languages/perl.js | 27 ++ htdocs/includes/codepress/languages/php.css | 12 + htdocs/includes/codepress/languages/php.js | 61 +++ htdocs/includes/codepress/languages/ruby.css | 10 + htdocs/includes/codepress/languages/ruby.js | 26 + htdocs/includes/codepress/languages/sql.css | 10 + htdocs/includes/codepress/languages/sql.js | 30 ++ htdocs/includes/codepress/languages/text.css | 5 + htdocs/includes/codepress/languages/text.js | 9 + .../includes/codepress/languages/vbscript.css | 71 +++ .../includes/codepress/languages/vbscript.js | 117 +++++ htdocs/includes/codepress/languages/xsl.css | 15 + htdocs/includes/codepress/languages/xsl.js | 103 ++++ htdocs/includes/codepress/license.txt | 458 ++++++++++++++++++ 42 files changed, 2935 insertions(+) create mode 100644 htdocs/includes/codepress/codepress.css create mode 100644 htdocs/includes/codepress/codepress.html create mode 100644 htdocs/includes/codepress/codepress.js create mode 100644 htdocs/includes/codepress/engines/gecko.js create mode 100644 htdocs/includes/codepress/engines/khtml.js create mode 100644 htdocs/includes/codepress/engines/msie.js create mode 100644 htdocs/includes/codepress/engines/older.js create mode 100644 htdocs/includes/codepress/engines/opera.js create mode 100644 htdocs/includes/codepress/images/line-numbers.png create mode 100644 htdocs/includes/codepress/index.html create mode 100644 htdocs/includes/codepress/languages/asp.css create mode 100644 htdocs/includes/codepress/languages/asp.js create mode 100644 htdocs/includes/codepress/languages/autoit.css create mode 100644 htdocs/includes/codepress/languages/autoit.js create mode 100644 htdocs/includes/codepress/languages/csharp.css create mode 100644 htdocs/includes/codepress/languages/csharp.js create mode 100644 htdocs/includes/codepress/languages/css.css create mode 100644 htdocs/includes/codepress/languages/css.js create mode 100644 htdocs/includes/codepress/languages/generic.css create mode 100644 htdocs/includes/codepress/languages/generic.js create mode 100644 htdocs/includes/codepress/languages/html.css create mode 100644 htdocs/includes/codepress/languages/html.js create mode 100644 htdocs/includes/codepress/languages/java.css create mode 100644 htdocs/includes/codepress/languages/java.js create mode 100644 htdocs/includes/codepress/languages/javascript.css create mode 100644 htdocs/includes/codepress/languages/javascript.js create mode 100644 htdocs/includes/codepress/languages/perl.css create mode 100644 htdocs/includes/codepress/languages/perl.js create mode 100644 htdocs/includes/codepress/languages/php.css create mode 100644 htdocs/includes/codepress/languages/php.js create mode 100644 htdocs/includes/codepress/languages/ruby.css create mode 100644 htdocs/includes/codepress/languages/ruby.js create mode 100644 htdocs/includes/codepress/languages/sql.css create mode 100644 htdocs/includes/codepress/languages/sql.js create mode 100644 htdocs/includes/codepress/languages/text.css create mode 100644 htdocs/includes/codepress/languages/text.js create mode 100644 htdocs/includes/codepress/languages/vbscript.css create mode 100644 htdocs/includes/codepress/languages/vbscript.js create mode 100644 htdocs/includes/codepress/languages/xsl.css create mode 100644 htdocs/includes/codepress/languages/xsl.js create mode 100644 htdocs/includes/codepress/license.txt diff --git a/COPYRIGHT b/COPYRIGHT index 04f0358a655..4275779fe2b 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -53,6 +53,7 @@ jQuery Tiptip 1.3 GPL and MIT License Yes jsGanttImproved 1.7.5.2 BSD License Yes JS library (to build Gantt reports) JsTimezoneDetect 1.0.6 MIT License Yes JS library to detect user timezone SwaggerUI 2.0.24 GPL-2+ Yes JS library to offer the REST API explorer +CodePress 0.9.6 LGPL Yes JS library to get code syntaxique coloration in a textarea. For licenses compatibility informations: http://www.gnu.org/licenses/licenses.en.html diff --git a/htdocs/includes/codepress/codepress.css b/htdocs/includes/codepress/codepress.css new file mode 100644 index 00000000000..3a4a00a7414 --- /dev/null +++ b/htdocs/includes/codepress/codepress.css @@ -0,0 +1,21 @@ +body { + margin-top:13px; + _margin-top:14px; + background:white; + margin-left:32px; + font-family:monospace; + font-size:13px; + white-space:pre; + background-image:url("images/line-numbers.png"); + background-repeat:repeat-y; + background-position:0 3px; + line-height:16px; + height:100%; +} +pre {margin:0;} +html>body{background-position:0 2px;} +P {margin:0;padding:0;border:0;outline:0;display:block;white-space:pre;} +b, i, s, u, a, em, tt, ins, big, cite, strong, var, dfn {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;} + +body.hide-line-numbers {background:white;margin-left:16px;} +body.show-line-numbers {background-image:url("images/line-numbers.png");margin-left:32px;} \ No newline at end of file diff --git a/htdocs/includes/codepress/codepress.html b/htdocs/includes/codepress/codepress.html new file mode 100644 index 00000000000..d9711d69766 --- /dev/null +++ b/htdocs/includes/codepress/codepress.html @@ -0,0 +1,35 @@ + + + + CodePress - Real Time Syntax Highlighting Editor written in JavaScript + + + + + + + + + diff --git a/htdocs/includes/codepress/codepress.js b/htdocs/includes/codepress/codepress.js new file mode 100644 index 00000000000..b3f563ad411 --- /dev/null +++ b/htdocs/includes/codepress/codepress.js @@ -0,0 +1,138 @@ +/* + * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ + * + * Copyright (C) 2006 Fernando M.A.d.S. + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + +CodePress = function(obj) { + var self = document.createElement('iframe'); + self.textarea = obj; + self.textarea.disabled = true; + self.textarea.style.overflow = 'hidden'; + self.style.height = self.textarea.clientHeight +'px'; + self.style.width = self.textarea.clientWidth +'px'; + self.textarea.style.overflow = 'auto'; + self.style.border = '1px solid gray'; + self.frameBorder = 0; // remove IE internal iframe border + self.style.visibility = 'hidden'; + self.style.position = 'absolute'; + self.options = self.textarea.className; + + self.initialize = function() { + self.editor = self.contentWindow.CodePress; + self.editor.body = self.contentWindow.document.getElementsByTagName('body')[0]; + self.editor.setCode(self.textarea.value); + self.setOptions(); + self.editor.syntaxHighlight('init'); + self.textarea.style.display = 'none'; + self.style.position = 'static'; + self.style.visibility = 'visible'; + self.style.display = 'inline'; + } + + // obj can by a textarea id or a string (code) + self.edit = function(obj,language) { + if(obj) self.textarea.value = document.getElementById(obj) ? document.getElementById(obj).value : obj; + if(!self.textarea.disabled) return; + self.language = language ? language : self.getLanguage(); + self.src = CodePress.path+'codepress.html?language='+self.language+'&ts='+(new Date).getTime(); + if(self.attachEvent) self.attachEvent('onload',self.initialize); + else self.addEventListener('load',self.initialize,false); + } + + self.getLanguage = function() { + for (language in CodePress.languages) + if(self.options.match('\\b'+language+'\\b')) + return CodePress.languages[language] ? language : 'generic'; + } + + self.setOptions = function() { + if(self.options.match('autocomplete-off')) self.toggleAutoComplete(); + if(self.options.match('readonly-on')) self.toggleReadOnly(); + if(self.options.match('linenumbers-off')) self.toggleLineNumbers(); + } + + self.getCode = function() { + return self.textarea.disabled ? self.editor.getCode() : self.textarea.value; + } + + self.setCode = function(code) { + self.textarea.disabled ? self.editor.setCode(code) : self.textarea.value = code; + } + + self.toggleAutoComplete = function() { + self.editor.autocomplete = (self.editor.autocomplete) ? false : true; + } + + self.toggleReadOnly = function() { + self.textarea.readOnly = (self.textarea.readOnly) ? false : true; + if(self.style.display != 'none') // prevent exception on FF + iframe with display:none + self.editor.readOnly(self.textarea.readOnly ? true : false); + } + + self.toggleLineNumbers = function() { + var cn = self.editor.body.className; + self.editor.body.className = (cn==''||cn=='show-line-numbers') ? 'hide-line-numbers' : 'show-line-numbers'; + } + + self.toggleEditor = function() { + if(self.textarea.disabled) { + self.textarea.value = self.getCode(); + self.textarea.disabled = false; + self.style.display = 'none'; + self.textarea.style.display = 'inline'; + } + else { + self.textarea.disabled = true; + self.setCode(self.textarea.value); + self.editor.syntaxHighlight('init'); + self.style.display = 'inline'; + self.textarea.style.display = 'none'; + } + } + + self.edit(); + return self; +} + +CodePress.languages = { + csharp : 'C#', + css : 'CSS', + generic : 'Generic', + html : 'HTML', + java : 'Java', + javascript : 'JavaScript', + perl : 'Perl', + ruby : 'Ruby', + php : 'PHP', + text : 'Text', + sql : 'SQL', + vbscript : 'VBScript' +} + + +CodePress.run = function() { + s = document.getElementsByTagName('script'); + for(var i=0,n=s.length;i + * + * Developers: + * Fernando M.A.d.S. + * Michael Hurni + * Contributors: + * Martin D. Kirk + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + +CodePress = { + scrolling : false, + autocomplete : true, + + // set initial vars and start sh + initialize : function() { + if(typeof(editor)=='undefined' && !arguments[0]) return; + body = document.getElementsByTagName('body')[0]; + body.innerHTML = body.innerHTML.replace(/\n/g,""); + chars = '|32|46|62|8|'; // charcodes that trigger syntax highlighting + cc = '\u2009'; // carret char + editor = document.getElementsByTagName('pre')[0]; + document.designMode = 'on'; + document.addEventListener('keypress', this.keyHandler, true); + window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false); + completeChars = this.getCompleteChars(); + completeEndingChars = this.getCompleteEndingChars(); + }, + + // treat key bindings + keyHandler : function(evt) { + keyCode = evt.keyCode; + charCode = evt.charCode; + fromChar = String.fromCharCode(charCode); + + if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) + CodePress.shortcuts(charCode?charCode:keyCode); + } + else if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1) && CodePress.autocomplete) { // auto complete + if(!CodePress.completeEnding(fromChar)) + CodePress.complete(fromChar); + } + else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting + top.setTimeout(function(){CodePress.syntaxHighlight('generic');},100); + } + else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) + CodePress.snippets(evt); + } + else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed + CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; + } + else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo + (charCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); + evt.preventDefault(); + } + else if(charCode==118 && evt.ctrlKey) { // handle paste + top.setTimeout(function(){CodePress.syntaxHighlight('generic');},100); + } + else if(charCode==99 && evt.ctrlKey) { // handle cut + //alert(window.getSelection().getRangeAt(0).toString().replace(/\t/g,'FFF')); + } + + }, + + // put cursor back to its original position after every parsing + findString : function() { + if(self.find(cc)) + window.getSelection().getRangeAt(0).deleteContents(); + }, + + // split big files, highlighting parts of it + split : function(code,flag) { + if(flag=='scroll') { + this.scrolling = true; + return code; + } + else { + this.scrolling = false; + mid = code.indexOf(cc); + if(mid-2000<0) {ini=0;end=4000;} + else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} + else {ini=mid-2000;end=mid+2000;} + code = code.substring(ini,end); + return code; + } + }, + + getEditor : function() { + if(!document.getElementsByTagName('pre')[0]) { + body = document.getElementsByTagName('body')[0]; + if(!body.innerHTML) return body; + if(body.innerHTML=="
") body.innerHTML = "
 
"; + else body.innerHTML = "
"+body.innerHTML+"
"; + } + return document.getElementsByTagName('pre')[0]; + }, + + // syntax highlighting parser + syntaxHighlight : function(flag) { + //if(document.designMode=='off') document.designMode='on' + if(flag != 'init') { window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));} + editor = CodePress.getEditor(); + o = editor.innerHTML; + o = o.replace(/
/g,'\n'); + o = o.replace(/<.*?>/g,''); + x = z = this.split(o,flag); + x = x.replace(/\n/g,'
'); + + if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); + + for(i=0;i/g,'>'); + if(content.indexOf('$0')<0) content += cc; + else content = content.replace(/\$0/,cc); + content = content.replace(/\n/g,'
'); + var pattern = new RegExp(trigger+cc,'gi'); + evt.preventDefault(); // prevent the tab key from being added + this.syntaxHighlight('snippets',pattern,content); + } + } + }, + + readOnly : function() { + document.designMode = (arguments[0]) ? 'off' : 'on'; + }, + + complete : function(trigger) { + window.getSelection().getRangeAt(0).deleteContents(); + var complete = Language.complete; + for (var i=0; i/g,'\n'); + code = code.replace(/\u2009/g,''); + code = code.replace(/<.*?>/g,''); + code = code.replace(/</g,'<'); + code = code.replace(/>/g,'>'); + code = code.replace(/&/gi,'&'); + return code; + }, + + // put code inside editor + setCode : function() { + var code = arguments[0]; + code = code.replace(/\u2009/gi,''); + code = code.replace(/&/gi,'&'); + code = code.replace(//g,'>'); + editor.innerHTML = code; + if (code == '') + document.getElementsByTagName('body')[0].innerHTML = ''; + }, + + // undo and redo methods + actions : { + pos : -1, // actual history position + history : [], // history vector + + undo : function() { + editor = CodePress.getEditor(); + if(editor.innerHTML.indexOf(cc)==-1){ + if(editor.innerHTML != " ") + window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc)); + this.history[this.pos] = editor.innerHTML; + } + this.pos --; + if(typeof(this.history[this.pos])=='undefined') this.pos ++; + editor.innerHTML = this.history[this.pos]; + if(editor.innerHTML.indexOf(cc)>-1) editor.innerHTML+=cc; + CodePress.findString(); + }, + + redo : function() { + // editor = CodePress.getEditor(); + this.pos++; + if(typeof(this.history[this.pos])=='undefined') this.pos--; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + next : function() { // get next vector position and clean old ones + if(this.pos>20) this.history[this.pos-21] = undefined; + return ++this.pos; + } + } +} + +Language={}; +window.addEventListener('load', function() { CodePress.initialize('new'); }, true); \ No newline at end of file diff --git a/htdocs/includes/codepress/engines/khtml.js b/htdocs/includes/codepress/engines/khtml.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/includes/codepress/engines/msie.js b/htdocs/includes/codepress/engines/msie.js new file mode 100644 index 00000000000..2558c395d39 --- /dev/null +++ b/htdocs/includes/codepress/engines/msie.js @@ -0,0 +1,304 @@ +/* + * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ + * + * Copyright (C) 2007 Fernando M.A.d.S. + * + * Developers: + * Fernando M.A.d.S. + * Michael Hurni + * Contributors: + * Martin D. Kirk + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + +CodePress = { + scrolling : false, + autocomplete : true, + + // set initial vars and start sh + initialize : function() { + if(typeof(editor)=='undefined' && !arguments[0]) return; + chars = '|32|46|62|'; // charcodes that trigger syntax highlighting + cc = '\u2009'; // carret char + editor = document.getElementsByTagName('pre')[0]; + editor.contentEditable = 'true'; + document.getElementsByTagName('body')[0].onfocus = function() {editor.focus();} + document.attachEvent('onkeydown', this.metaHandler); + document.attachEvent('onkeypress', this.keyHandler); + window.attachEvent('onscroll', function() { if(!CodePress.scrolling) setTimeout(function(){CodePress.syntaxHighlight('scroll')},1)}); + completeChars = this.getCompleteChars(); + completeEndingChars = this.getCompleteEndingChars(); + setTimeout(function() { window.scroll(0,0) },50); // scroll IE to top + }, + + // treat key bindings + keyHandler : function(evt) { + charCode = evt.keyCode; + fromChar = String.fromCharCode(charCode); + + if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1 )&& CodePress.autocomplete) { // auto complete + if(!CodePress.completeEnding(fromChar)) + CodePress.complete(fromChar); + } + else if(chars.indexOf('|'+charCode+'|')!=-1||charCode==13) { // syntax highlighting + CodePress.syntaxHighlight('generic'); + } + }, + + metaHandler : function(evt) { + keyCode = evt.keyCode; + + if(keyCode==9 || evt.tabKey) { + CodePress.snippets(); + } + else if((keyCode==122||keyCode==121||keyCode==90) && evt.ctrlKey) { // undo and redo + (keyCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); + evt.returnValue = false; + } + else if(keyCode==34||keyCode==33) { // handle page up/down for IE + self.scrollBy(0, (keyCode==34) ? 200 : -200); + evt.returnValue = false; + } + else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed + CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; + } + else if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && keyCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) + CodePress.shortcuts(keyCode); + evt.returnValue = false; + } + else if(keyCode==86 && evt.ctrlKey) { // handle paste + window.clipboardData.setData('Text',window.clipboardData.getData('Text').replace(/\t/g,'\u2008')); + top.setTimeout(function(){CodePress.syntaxHighlight('paste');},10); + } + else if(keyCode==67 && evt.ctrlKey) { // handle cut + // window.clipboardData.setData('Text',x[0]); + // code = window.clipboardData.getData('Text'); + } + }, + + // put cursor back to its original position after every parsing + + + findString : function() { + range = self.document.body.createTextRange(); + if(range.findText(cc)){ + range.select(); + range.text = ''; + } + }, + + // split big files, highlighting parts of it + split : function(code,flag) { + if(flag=='scroll') { + this.scrolling = true; + return code; + } + else { + this.scrolling = false; + mid = code.indexOf(cc); + if(mid-2000<0) {ini=0;end=4000;} + else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} + else {ini=mid-2000;end=mid+2000;} + code = code.substring(ini,end); + return code.substring(code.indexOf('

'),code.lastIndexOf('

')+4); + } + }, + + // syntax highlighting parser + syntaxHighlight : function(flag) { + if(flag!='init') document.selection.createRange().text = cc; + o = editor.innerHTML; + if(flag=='paste') { // fix pasted text + o = o.replace(/
/g,'\r\n'); + o = o.replace(/\u2008/g,'\t'); + } + o = o.replace(/

/g,'\n'); + o = o.replace(/<\/P>/g,'\r'); + o = o.replace(/<.*?>/g,''); + o = o.replace(/ /g,''); + o = '

'+o+'

'; + o = o.replace(/\n\r/g,'

'); + o = o.replace(/\n/g,'

'); + o = o.replace(/\r/g,'<\/P>'); + o = o.replace(/

(

)+/,'

'); + o = o.replace(/<\/P>(<\/P>)+/,'

'); + o = o.replace(/

<\/P>/g,'


'); + x = z = this.split(o,flag); + + if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); + + for(i=0;i/g,'>'); + if(content.indexOf('$0')<0) content += cc; + else content = content.replace(/\$0/,cc); + content = content.replace(/\n/g,'

'); + var pattern = new RegExp(trigger+cc,"gi"); + this.syntaxHighlight('snippets',pattern,content); + } + } + }, + + readOnly : function() { + editor.contentEditable = (arguments[0]) ? 'false' : 'true'; + }, + + complete : function(trigger) { + var complete = Language.complete; + for (var i=0; i/g,'\n'); + code = code.replace(/<\/p>/gi,'\r'); + code = code.replace(/

/i,''); // IE first line fix + code = code.replace(/

/gi,'\n'); + code = code.replace(/ /gi,''); + code = code.replace(/\u2009/g,''); + code = code.replace(/<.*?>/g,''); + code = code.replace(/</g,'<'); + code = code.replace(/>/g,'>'); + code = code.replace(/&/gi,'&'); + return code; + }, + + // put code inside editor + setCode : function() { + var code = arguments[0]; + code = code.replace(/\u2009/gi,''); + code = code.replace(/&/gi,'&'); + code = code.replace(//g,'>'); + editor.innerHTML = '

'+code+'
'; + }, + + + // undo and redo methods + actions : { + pos : -1, // actual history position + history : [], // history vector + + undo : function() { + if(editor.innerHTML.indexOf(cc)==-1){ + document.selection.createRange().text = cc; + this.history[this.pos] = editor.innerHTML; + } + this.pos--; + if(typeof(this.history[this.pos])=='undefined') this.pos++; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + redo : function() { + this.pos++; + if(typeof(this.history[this.pos])=='undefined') this.pos--; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + next : function() { // get next vector position and clean old ones + if(this.pos>20) this.history[this.pos-21] = undefined; + return ++this.pos; + } + } +} + +Language={}; +window.attachEvent('onload', function() { CodePress.initialize('new');}); \ No newline at end of file diff --git a/htdocs/includes/codepress/engines/older.js b/htdocs/includes/codepress/engines/older.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/includes/codepress/engines/opera.js b/htdocs/includes/codepress/engines/opera.js new file mode 100644 index 00000000000..155bf098a32 --- /dev/null +++ b/htdocs/includes/codepress/engines/opera.js @@ -0,0 +1,260 @@ +/* + * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ + * + * Copyright (C) 2007 Fernando M.A.d.S. + * + * Contributors : + * + * Michael Hurni + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + + +CodePress = { + scrolling : false, + autocomplete : true, + + // set initial vars and start sh + initialize : function() { + if(typeof(editor)=='undefined' && !arguments[0]) return; + chars = '|32|46|62|'; // charcodes that trigger syntax highlighting + cc = '\u2009'; // control char + editor = document.getElementsByTagName('body')[0]; + document.designMode = 'on'; + document.addEventListener('keyup', this.keyHandler, true); + window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false); + completeChars = this.getCompleteChars(); +// CodePress.syntaxHighlight('init'); + }, + + // treat key bindings + keyHandler : function(evt) { + keyCode = evt.keyCode; + charCode = evt.charCode; + + if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) + CodePress.shortcuts(charCode?charCode:keyCode); + } + else if(completeChars.indexOf('|'+String.fromCharCode(charCode)+'|')!=-1 && CodePress.autocomplete) { // auto complete + CodePress.complete(String.fromCharCode(charCode)); + } + else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting + CodePress.syntaxHighlight('generic'); + } + else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) + CodePress.snippets(evt); + } + else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed + CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; + } + else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo + (charCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); + evt.preventDefault(); + } + else if(keyCode==86 && evt.ctrlKey) { // paste + // TODO: pasted text should be parsed and highlighted + } + }, + + // put cursor back to its original position after every parsing + findString : function() { + var sel = window.getSelection(); + var range = window.document.createRange(); + var span = window.document.getElementsByTagName('span')[0]; + + range.selectNode(span); + sel.removeAllRanges(); + sel.addRange(range); + span.parentNode.removeChild(span); + //if(self.find(cc)) + //window.getSelection().getRangeAt(0).deleteContents(); + }, + + // split big files, highlighting parts of it + split : function(code,flag) { + if(flag=='scroll') { + this.scrolling = true; + return code; + } + else { + this.scrolling = false; + mid = code.indexOf(''); + if(mid-2000<0) {ini=0;end=4000;} + else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} + else {ini=mid-2000;end=mid+2000;} + code = code.substring(ini,end); + return code; + } + }, + + // syntax highlighting parser + syntaxHighlight : function(flag) { + //if(document.designMode=='off') document.designMode='on' + if(flag!='init') { + var span = document.createElement('span'); + window.getSelection().getRangeAt(0).insertNode(span); + } + + o = editor.innerHTML; +// o = o.replace(/
/g,'\r\n'); +// o = o.replace(/<(b|i|s|u|a|em|tt|ins|big|cite|strong)?>/g,''); + //alert(o) + o = o.replace(/<(?!span|\/span|br).*?>/gi,''); +// alert(o) +// x = o; + x = z = this.split(o,flag); + //alert(z) +// x = x.replace(/\r\n/g,'
'); + x = x.replace(/\t/g, ' '); + + + if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); + + for(i=0;i/g,'>'); + if(content.indexOf('$0')<0) content += cc; + else content = content.replace(/\$0/,cc); + content = content.replace(/\n/g,'
'); + var pattern = new RegExp(trigger+cc,'gi'); + evt.preventDefault(); // prevent the tab key from being added + this.syntaxHighlight('snippets',pattern,content); + } + } + }, + + readOnly : function() { + document.designMode = (arguments[0]) ? 'off' : 'on'; + }, + + complete : function(trigger) { + window.getSelection().getRangeAt(0).deleteContents(); + var complete = Language.complete; + for (var i=0; i/g,'\n'); + code = code.replace(/\u2009/g,''); + code = code.replace(/<.*?>/g,''); + code = code.replace(/</g,'<'); + code = code.replace(/>/g,'>'); + code = code.replace(/&/gi,'&'); + return code; + }, + + // put code inside editor + setCode : function() { + var code = arguments[0]; + code = code.replace(/\u2009/gi,''); + code = code.replace(/&/gi,'&'); + code = code.replace(//g,'>'); + editor.innerHTML = code; + }, + + // undo and redo methods + actions : { + pos : -1, // actual history position + history : [], // history vector + + undo : function() { + if(editor.innerHTML.indexOf(cc)==-1){ + window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc)); + this.history[this.pos] = editor.innerHTML; + } + this.pos--; + if(typeof(this.history[this.pos])=='undefined') this.pos++; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + redo : function() { + this.pos++; + if(typeof(this.history[this.pos])=='undefined') this.pos--; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + next : function() { // get next vector position and clean old ones + if(this.pos>20) this.history[this.pos-21] = undefined; + return ++this.pos; + } + } +} + +Language={}; +window.addEventListener('load', function() { CodePress.initialize('new'); }, true); diff --git a/htdocs/includes/codepress/images/line-numbers.png b/htdocs/includes/codepress/images/line-numbers.png new file mode 100644 index 0000000000000000000000000000000000000000..ffea4e6aa163ba2cf184e2970ef11724bce4ef72 GIT binary patch literal 16556 zcmdUXcU+TK-?y!|)~bjoNHq#o3W6&_#V9gbWhkf!sEA^sA`TEE3X&j6oXke5B9UD{ z6a@*OAV|n10#OLFfApU?aLWvMjdoa=ml-*p}@bf|+t9?FB z=wm*9htIlC`S~dNi2L{3ybd3CcXU5|6zg5)ZVGq zru<~E&GP5nn8ty)rn3VZGAs?p#>3--at}WHeyN%|!r($&aMWwHMFlIL#QyN>G`-6D zaY;318u z@10*2Jz3nyq~NxtxMW_Zo`+{Wu{L{XJ7Vl(md-Z9_*#_vaUCn~g@rm6-Z0yY(qUbs zF6i`SceT~CUv)OEb$VaZJkq~}Jp&o^XlVfK*uz`Gua6O-VS!Cge=gPZ#ueez8eU*; z(u-k4AlIlejF%bXJb=DqKq#g%y$;`+C#9tvVk6EI3PYXqtl#ou_~%o8BfIbphiLK+ zTfpr`H1^JUl0geiTsjQuL) zICys`Nqldg2ITt`#*m<1L(9m&A8+vw^dkA%(s`ftB9T`D4 zNw-JIHO#fn`h+)I#KbtNI=p^tUn0sH<HO>~!f!)2W}jROdA}jG>sH-Q#S3m~3ZwUGM`9ebN4emWc`W9)$E3e1=}AR^-5N!C zPrXh>Ho)m(6->)Wa$VD_6jz;;dN&CH)D(5Ml>|wKRS`R4FkMM!Ra8^H(pYL}Of%;JnIUga~G)_?lq?BI-5# zN2r!gkLmXEpv=aZm8P)+Y%7_mW-pi+TiL6(q0{N~d1_f&=9yZ#vGxxHut13Y8+Cux z{W_uhh;hF8Dt40jKzF^rc}f?0qz*O)+aiJ!cKY{to`!ybYPtIMItJIMeRE?Rsg?HT z<`nUYLT>xL>7KLIRit$3X4d1G&mlrJd|ozSQ0s3a@LcoPth7q z&KS@U3$iHtyAiJ4VaV~#U5Kt8x|zu2j)3UQmM>SsI;hPAHF9?R2);uNXIzQSt4af( zZ$7T_q4F(^tI@8ca}{XH1KIB|M(7pjRi*vymC58%F){3s3c)Q4FPIJ&6Q{{O&6{Fh zF|l7Vi{Pe9=m1;1znuA-c>oEz!9x2e7Y5;i{*CO%qmRK@HhN6jOD7ZRmUFMkekD4X zY3Po;`CewvC1H)jCL-9qr@0&*G4cKgYrlbk`Z?aK&gCV{?K*zee(D&yVJ%ak^F0gI0542?rl$60Eqe6_!2)TJ7kFZUj|Yw0#iuEquiI(Zs`Q z0<~ql^u88S>w>Hs6578XO+!v|IgNEcZbB%!RTb-n}lIIF*ojqq0t2JqiO_fW_1$t2R#?xIM{4d$jnX~a#a zNMdk~SKo&|Lnwbi$+K`D_HXbZ*p@NhNh413??)(*qf;8OjS~Id-ar6rPRKqrUMevF zFGgebw7G|9Yv?8Hv)Q`afZ26?#SElL;p?L}+tx2^TC~N|PLR~6CiJK$U04v!-%agV zUJ@+z{GR-hW96dS@nO|GDm3?mOP>K4ya6Q&S$4=C&;7W4?N+#kYWh4}h?r=50&7!v z2{L>#?!OkLj;kCb9pGBE8IPEw2>wr|TJ&8Ks4xUcj5lUn*tro_JZ?#an3jeygbXoe zr=po>;^6-I3ZRYd0tmAQiN75}JvOmY(cOp)`o=CqYn|+OJcaIEh{$#@ylcU*p_RS~ zgtGQQ0arAow98;oHT&C4q%@xN8kBVt@-CZ&Tg^i6(x%dxuQ&)3+NL+kfNj`bbwE5!GJIIAA9~`Vk{98CE#gmLoWs!9|zN3IYRI8yd=yl2@_@} zkaUG6n#cAIBm5OZn34aL4GKO;3I}W;8Z$_B6EdaWoig3XeQl6d!|1t@?|(EyYcN~y zT@GT-&iG>c`M!7u?L*y`{+4T^@u|eBY8(?!WS}dTL&=o zH1Y?tbG1Qz&gQ1 ztQtTNc3G6071UXCLz8w7bP9*CA(kYl5@3oO6xQ;dl&o*J$(g4H!22{VM+9?dWeB#F zOkSG?BZ&PrWv0lv2W`1DDTp_hkZcOE_n_DD!P+ zRvF<@@f!ie8WTyncy+ErzW^3lG4+hOd!cOd1DsG01ZNH+V-#L>Kb?hk9o~!z6Ts?% z-g6MEqL}Xj%A+NuXmFCr{iKZvznAv+OK9BnfG$WY;ouqon7gj{J{sL%Vrh=j`vPWChJ+5Gq&zqN@oo>+HNx0; zfV+(enAnQ6dS-Ck%r1oVHg&&*82{dB7%`pu1x7+%i}Dd|A%41pGr3kV@VMi6w_fQa zKGMWJWJh`RKJL5{HS%Rp1%Tu*vN^#BoWN%mDV;KOc_MPMRdAfMgz_Jdl>l7CDns@z zx#R892taN+&?CdyCE=mB?6Ymoy9%{lJr$I_3?gA;Tl1Ou?P3)cx@2k65HY%~(PL~WquYv{-KZzVX5h9Vml3uwUwRkK!tF@=NJRk3ytfYt4INS}8}ATR zUl`p4f7%uH!m|fQJ#7S^Hh!j29M~V=a0`380$ouLrr1U<4Bk;HroH23p2QdXQhQiZ z@RN?vLk2L;*wRUF0jNk`m8NkNyj)DnmQ3KTn*s7IHffyVK9X}2@QjUD5rysO?Smxr z@C)X?U*-Gm`jVN~3JoLnau90(H%Jky^cDLFU@lT?CH#eUgCjFb1fazo6V;_lSRwN3 zwclzseib_W3>8^`%ysUw52nWVkkFjQdYH@m-&QWem{kH0&C<$fLpL`;qtZZK!W5Bx zFvNZWd4~bwLsJl+!;Q?IM+!=NX>ko>lZbVce3fBLZkgN2royoCuU>F1MNJ7qahuDl z*7VwsX=3xKIA4Zk9IEb{hT4ScjB`0+rUp8=SydEEb?v7=c6#!2VO!hVQHihP7)%H2 za<(sumq{Y!Y47bq@4EweqsIXr%w@IBZ$}So+5RuMx5cT5?la&MO=jEe_=e${{;cQ= z8LiKm-!&4hNv8|_-JsZ`dx|`N)n+w@+hV6Vta#gEVp7W@b3J024eyWeMXc}3jS4)s zFaIrxe3{xPA%6dUWx)l9=C*q?xhBlHb2nYK_Hrq_v(HBGoeL zl$hn*FAgk-Wp0%a{T0(^p6u;WP;7I`9P&cSDt7Xn@cq@y%%fTtxd#0_I*GC&A^Uqd zUgv@7kVEh`cVA8DxC~agLb=LiVn9CL3_x{a@Ja`v3PHpgBU5_3`Y`%Y4KqTA)L?pReq%I~F zQSLCmqkMS33bbhw!21f#7U?dXNxTh^ojQaLP(KqoqYHuG0ab{t;c#^ImDTKJkYA(3 zK$mbu=iE$libl@cS(8mBio{#+aGl$dTd7TWOfc3A`AP zEXDMB77q=3{V$wtFA}FF1O#9nj8qlh*5llp4i34iWIr`k96beREE`|q{D4~fU^NNj zCuBG)EL)4#pIFA*wfq)Iu3N^`gpL$TX&^ORwqKKD?=Wr_qGdFL`Q%@vpbhV&!EHbPdQ0ppF4agH$L5K6XGasU~fB5!c}Lk z0%-(EK(RDU;vl!Rol^Dgsn>9@^#{9N%@r|!-qA3RH5iF~=U{4R83z+ZHiC4#k| zKk19{?OXYv!U-u%iyS-swU|hF{`oU@fuLiYcfLO{86GAfE+M2tZx< z*+H8Wicf?s{^=aPKnr7Bg&z2&BoOanH^NlpYm7^~jiGi*rb+*O7B!_&RMlPToTqwO2f}Id{-X}WyNg%<+pV}gA;{k(G|=F zobkNSSM@-<7Ad&xRQZ_zuOJ2H$5z4?Ghqi<%o0I_ZTwVW^ns5n*&bl4OGr*upmM1I z*3*AYl5LXkHMsyE(XPSF61~meufUNJ#Hq9w7oF3f8+X2|K#Qm1a)dB5=6#^$y5!Sz zLORKXy#ewtwP!SF(Wk;#qbsa6?{>Aeaz24qiN;3>h)85>{5J>Mt?=(<%tAVyf4`z0 zybsVbv$%j!6!jl|twfl6EeVc&0N6W)zlxmn*dA0RBLTyie;>TqLPBy7;D5XC)Owhx z>yA}V6|A=qj13z_wVqs2HavW~n0x!UGqfDF+g!eKkKlwgsFC?cEXR$1Ww;5F(u3F^ z*tv06Sh)?s6%|T)#jN3b%h=-Uz7GbOT_?InH;~#W9>&(iD~rzLCvryy+tJ#mcg~!(G_L{WdW5YrjdI|Kr{j~ zD!vCA->k%vXT2H(H{{<^HO{6$E(4>h1Ff#@wcKl87M^^l_0VVj(Nk zxn>*ov235;+7E8sNHO90GMU47)wlH#D~}h;4H3XYCe5k~gyMMwH%QAw=m^}1l3!C1 zr)7LSJB0A zVY9T(a{(Kv-q9E;vpHWeXE+RzfXi7(RR=$eHB#G6gJylIO2L_`mZo4H*d3yOQO)FN z-{t@@tEzUx?c=VX5U*q4WC1#0qAr0%7580POiZdKUB*`Q(3$n-oOk zc2J1GY2aEG)UlGobg}sxc8$s*r5ZN7TNTWvg1JJOOR}NcDZbX(G3q|09qZtN4!|!! zcF0`JH^tw)nQ$xYV(o881H*c1Ei&Mx;D-mD8-F9`e{{eA=>0N)99x>EBR zqec|aauhjJ+V({5lIU?)L^1EA0r_;c3xT8o9VY`y83n1OE9|6tnb%6@gifAc@ywdr z@i7&e?szvqzm#5dmO6RBw3aaEJK_E^V1O)6a#0f#^CcV=C*!hi+XkyXJUOJi_0x_{~@D-g+p2<=BkDs{8t>&|!dq z?UYq&YW;0sM&Y>51D?AdffT~7?t}5gnEwGWILq$_QTO(Mjd+HUEM8&G zo{8>i(cAMdCNSPVBH#t|$`idfR$N?J&p6It!}g6imBCM4hzQs`Ql9~5*m`@Pe2IewOeir9_fxQr-3$cLe&y-@)Ob zV&+S)j?^$_O0u76gQFqVXWYAmuzuj$l~NM2h7jxAA*QL`zFYQep_zXae34AMoR@hW zw<+WeGT&5|J){Rs@=d{@+3#cfwag0-sE1WrZ4yTBSI%b{+h7P_Q6Up-1HY+J6Sulm zp>TnrB-Zare#1qq${O03kPYTQ8E{FJ8wL)vvj`X;Z-4~FBm(bTAweT&p9H2zrPQtx zpbUct%+}s^9uI%5<@njwduL_Bg_55$xMB-ta0S*`W^MqR^METNU6pY`SGb}_PAH$L zt8tUSKAxGNP7|Xa_!@U1H85L4NgEOz%g+6TI`=VClEcJ=DNoLm*;xamdVxBog$FFt z6Vs2udK=4UjSm|l-$vcgNBQ`bb529CdBVTOHFmoH5f#wer-_sn)x?tyQkVa*%Q5qo zeXc=e>v!|^lq+lw+xHbWXY-@#y_P1W$d9@Qc67xK_1{W_-ReN*%f7J(t&Qy=gf42l5+*Z3_J=AZ`S65q=!s;jU13 z>*aE$uo=3;#8{$s$VkNsI8<(ldOX2p0MU5%`?*_x5G}r!=HXU%pVJYggt7915x9&yzN8kt|_KNVM)23+M-v&J2bv8{oZZ<-syO^vFx zi&nn#J*!&LvD1V9YK}#Y_LXOX6Bb(o@K+&r1l2W6pXHu`S<+8b1rFgyCVTaWJhUu? zyiNBVK5OPP;+_S0UroAu+|e>}&Fvn~ogZy9_mqyoq@)4`DHGs&6UjLuRtNH1vYtY! zyokX{&fIGHHuOS=4tG=dJKx~e4OC+FT#8lrDh|RlziN*~qh!1Zh?K|R<7_PyaP=Q( zJ8xfVCMIT4wsVh|4aoezgqSB9@Rft88<2O%JVHmR+$W{x!f!3h_IY55IybSlkv%KZ zN7A!WdomQjfk%PtW$=Sc@iIxFT-LwcVRrX;+6r4AK|f_tHv%u!+;&UDY-Z9bzI{^d z^`70cz_A1TVg`qLdAZCv{je^F>0(+p!Jz@#Owg&)Y~%4DJU89_yY2xAf4ST@!_ ziC`A={kJ9ymLVX`>GDx2^9*GA zNbdbPQeFhqF6mqUDK)&74Cw`Jo=-@=uXvs&QU!l3_JY=_5KTd$%-N6yDMrp9wgtLn zRRwS~rjvtqC@s+_V5L3)yK$?3%aDCkNt!_Eh|ot-%?TV3QHY6J$jC7VZ_YN()}RKT z&ZdDhOH8kTxS^~joUh0HR&DT=<{s4i-#}iKe>@Ru&k7rIn%ia^JfT+f6Yt2j*LO4C> zf!N|s%~qUj*zc(U{w|9!C1ZR_-KWWINzf}#vRP1t zc9p)!wJC#Jq6UQ=%Q+6Wvqj|L8)d+zo$PX)yOsMPX$b;Z;=pCiiIql1r&bmtwEt|QX~Dt;TG8>94}BUr6b z;j;-hE{0O~^XiAt|H7g+Asq@6=as$V=})9llM(4{7Vy(6iWa~p+GN{wOss(T z803)N<|#M3FH*bSd?1yiMK4!({!cU{W^w%l4N=R=20FM6P@V1n!0kw(E@U73UjUEN zyn{=QIF&zr+tN3Sd=%gD(K9_EmLu*LEz_$T`M`{v}Jj#vUS~MW9xcGlA%!snM%5h@Pl_4TBRZ5-K(wyv{#3>s^R1o%ME; zrLWJU+DvQxPGY#KhnyF_@N_OKXxF_t8#v%VbF44H>4rnKY2>>`_Sh)TEA(lT+0VrM zmiwDJ0ayRRVc$Riv@{d7x7+ERFC+XW5cB-}px-fNn$osnO7@RB4i4-8XGBCZSTv!+%garRBbJMLk zW7;_OduG>iZEfU=!XLL8nU=V`blRiEr{_!v4o{rmoFFM-u8xp=iK0cEH zms7U0UV`4rJvL|s95MGW19owL{9jI5fBiQ}>z56S@JZm&>u6aKX2OLPe}O9iAJe8b zx##bfG8l)a)8yShrH_es^fBuK?&S{|=E|0+bv55WwvqDw(nJqLF2qAYr|Vh4oD||` z@Ig&2OROpRfcF1245?cxD0#Le$yO1Mg#Ny1hu*^dbC0(yShl}h)6C+s^A6OI%ZXN} zKR}4Gtp@bQh(#tq9l5N4|*B3|Gt+Y z*rO+m-ZNp0{h5t9E278KkkE0&vzWOr9Yrky&#y9mTSDmY9|yC)jF|_9eI!RQ?2mpZ z@l6``tlGAu&PR(!{ob5vO_Yqh>SkQ{?ge&Ojgl1h=peh%$I%9PfY7mS9k1cDvZ%O2 zO2Z%{gM%kk32!xy!Tff$qf0>Rn{k|IQV-L!I@;?PLhYJlbatg>aix0$TkxA@eu2Wb@C8l>VVxL%srKF`*S!Ru7b3%In{^pdJfZk3lL?i;q}7dIQ5PxVCz2oU56M?z88f zPv^HpF~<_;{c<1}FW9GLO*v9L?(=XO(imju&gFDhb|}?;qwdWj&wu?vc&vlet_H`; z%IF+1&AIUKy;1VjN#{atf_CJ+DCtR8aG=xKt$^P3k%~dxva$oPDz3vUA?%(AXoyt} za1;k*tjdNTFstjOphub`CdyJDLxs=`JW061H3%C;DYIK;*=ssQdf|$p(!z+z&8=1~ zrmKo}JYPAgFfe?Zgfp~?((cOXNUvjwE2wMBy1}1DVQpgTV`t*DidObP>zyb`ttZTO zU!N>LK(P(fP(KS?&zgc&6@kFjH}=xT`1Difzhq_Mm<9yXrg3& zEPtwf5qRG}@h}EejX{H8QcwvB9mX5gqsP8bKmQLKp(c6>i*H57C{V@e=i!;JH`$jp zcuNC0i0rwwj?@#wGmyFyF2cDn$yCS?BT+oAcVu@Y~Bo9V<+nz)1DB~~%?TS5-HPW_tDQPL04h5VX| z|4H?9p3_E45h+8JZ)N2-!CsVAS5}MPSHm8x98vcYaz`a4x1gnW?e23MN;Em4+Fn(! zXq4*-!_~r|T#G$awyNKbIy~M@b>L8+|Hv#d*f5sofYxB~&o$2Xl?9KUuW_Y3+E4;8 ztUgpc+z2a=l*pQWo#?CjeEL!;4T%Z`KMXj{ZTj?c0;5%=ejPK;u~AfD!O{7Rj2NXS zg2R%CkMOiu!SemZF^jv%zukAI&m|H9^gR5sL=ui+IY(VpqXHc}e^=X{*WfOUcZFys zG5uG0NUSV+PwI_rxE37Gm_VP}W_U9Bfzmz$#yXMf=g1d-)*D+a0+n?ds4RsFQhDGG zOV?LG-~6@sr2_q>_@x6218v9d5UO4A8FO0>$LY`zNc=)2(J z$w3@(P5||>lz&hkdlBI9Be;$8zX3r%Bs3VVbBSBdvEe4;IqWvy@=jIEgO82VZkyqU zy?|f4Y z+XAN_tiGvYDEsjtidyFBj4mnMvR7?lTIU7IYMzZESfu!?0SjB`@oUC{$Wk(U|YE6W}8_{HU7m04WGkSu*s zOEL`r3lNh3NP7J(o7fu`lxCOmdR4cS^lrX!pYv#*B%`a}s_8bF5T9 zilNVXr!>K)2N$Fhw&}OB_b30~*rs2$QrOCB2Q%gH25nuefc?`#iYZn5&0TPF<$n`C zvLrG5W5}_fa5kvCyw_aPX@i4%?vPraIIuTayRfoUZ^BPE%FL*0|Ss4A-`yJqxjE4~_LO^sE z0jo;h)ulO7vbmPySkTGRCFs!4ZD<(@g$xV-mOfe;uejvIMubvww`E>HHvQ0`15ev< zsj0J7^rjG29ssWQHqg`oEL+r_7_4OTA1=e77U{@t zZGa&>PghEFkW-WZFO&o5SWLPg;F2V(mA!@3LH+zQi#7-t9)UuK3`uGP>AK^$Tt{;z zsmQY$T!kq{tZEL`tCcdoO&b6B8w*Rq_ zI)iFl!1~;-Ro>PebEvR+)D1#g)#ri;o-ADg361iS0+7Ou5MVBmknCaw2>az1pfZo* zfjsgYMS0)>SY@EP0&F$O2XA9y71j0=i1X(bKfFN^V}6?rZpLLLY@UrV?nV#Xo2#SG z2m0t9oKF)ITby-1tm$V8NnUK<8U8LsR!l9n{X6$yfaP*5hBWV>$GI|jQ6v#!OUf^c zQ@!$PK&t-ndfngGNW?X9(8z!Pf}QVH^S9*vCaUXaWc8Lk6$sLYv%fFozOrMX^$9w& z)dtIy=F7h;ka2Y|AzXts@9o*0=GQ+fG=_*(a0J_3yGN9T?aw+RzPGRjV?nRwUH0gT zw4->p4B0i0C?;khfQ#uMyOuXk;e5Hz?JO&lQOZ|NN+r^;vRgB$e++!ftL97isQ(ni z+* + + + + CodePress - Real Time Syntax Highlighting Editor written in JavaScript + + + + + + +
'; - print ''; - print ''; - print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); - print ''; $searchpicto=$form->showFilterButtons(); @@ -402,11 +405,18 @@ print $searchpicto; print '
'.$obj->field1.''.$object->getLibStatut(3).''.$obj->field2.''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ''.$object->getLibStatut(3).''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ''.$userstatic->getLibStatut(3).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined @@ -536,7 +551,7 @@ if (isset($totalarray['totalhtfield'])) if ($num < $limit) print ''.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
+ + + + + + + + +

+ CodePress is web-based source code editor with syntax highlighting written in JavaScript that colors text in real time while it's being typed in the browser. +

+ +

+ Go to http://codepress.org/ for updates. +

+ +

Demo

+
+ choose example in: + + + + + + + +
+ + + +

+ + + +

+ + + + + +

+ + + +

Installation

+
    +
  1. +

    + Download and uncompress CodePress under a directory inside your webserver.
    + Example: http://yourserver/codepress/
    + Since CodePress is pure JavaScript and HTML, you can also test it without a webserver. +

    +
  2. +
  3. +

    + Insert CodePress script somewhere in your page inside the <head> or above the </body> tag. +

    + +

    + <script src="/codepress/codepress.js" type="text/javascript"></script> +

    +
  4. + +
  5. +

    + Add the <textarea> tag to the place on your page you want CodePress to appear. CodePress will inherit the width and height of your textarea. + When the page loads, it will automatically replace your textarea with a CodePress window. +

    +

    + <textarea id="myCpWindow" class="codepress javascript linenumbers-off">
    +    // your code here
    + </textarea> +

    +
      +
    • + The javascript portion of the class="" means that the language being edited is JavaScript. +
    • +
    • + The codepress portion of the class="" is mandatory and indicates a textarea to be replaced for a CodePress window. +
    • +
    • + Other class options are linenumbers-off, autocomplete-off and readonly-on. +
    • +
    • + Careful not to use the same id for two different CodePress windows (<textarea id="xx"...>) +
    • +
    + +
  6. +
+ +

You also can...

+
    +
  1. + Open/edit code from a different textarea.
    + Example: textarea_id.edit('other_textarea_id','language')
    +
  2. +
  3. + Get code from CodePress window.
    + Example: textarea_id.getCode()
    +
  4. +
  5. + Turn on/off CodePress editor and return to the regular textarea.
    + Example: textarea_id.toggleEditor()
    +
  6. +
  7. + Turn on/off line numbers.
    + Example: textarea_id.toggleLineNumbers()
    +
  8. +
  9. + Turn on/off read only.
    + Example: textarea_id.toggleReadOnly()
    +
  10. +
  11. + Turn on/off auto-complete.
    + Example: textarea_id.toggleAutoComplete()
    +
  12. + +
+ + + +

License

+

+ CodePress is distributed under the LGPL. If your software is compatible with this licence or it is under Creative Commons, you can use it as you want. Just keep the credits somewhere around. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/htdocs/includes/codepress/languages/asp.css b/htdocs/includes/codepress/languages/asp.css new file mode 100644 index 00000000000..9a4c505c330 --- /dev/null +++ b/htdocs/includes/codepress/languages/asp.css @@ -0,0 +1,71 @@ +/* + * CodePress color styles for ASP-VB syntax highlighting + * By Martin D. Kirk + */ +/* tags */ + +b { + color:#000080; +} +/* comments */ +big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u { + color:gray; + font-weight:normal; +} +/* ASP comments */ +strong dfn, strong dfn a,strong dfn var, strong dfn a u, strong dfn u{ + color:gray; + font-weight:normal; +} + /* attributes */ +s, s b, span s u, span s cite, strong span s { + color:#5656fa ; + font-weight:normal; +} + /* strings */ +strong s,strong s b, strong s u, strong s cite { + color:#009900; + font-weight:normal; +} +strong ins{ + color:#000000; + font-weight:bold; +} + /* Syntax */ +strong a, strong a u { + color:#0000FF; + font-weight:; +} + /* Native Keywords */ +strong u { + color:#990099; + font-weight:bold; +} +/* Numbers */ +strong var{ + color:#FF0000; +} +/* ASP Language */ +span{ + color:#990000; + font-weight:bold; +} +strong i,strong a i, strong u i { + color:#009999; +} +/* style */ +em { + color:#800080; + font-style:normal; +} + /* script */ +ins { + color:#800000; + font-weight:bold; +} + +/* */ +cite, s cite { + color:red; + font-weight:bold; +} \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/asp.js b/htdocs/includes/codepress/languages/asp.js new file mode 100644 index 00000000000..21e78dd887c --- /dev/null +++ b/htdocs/includes/codepress/languages/asp.js @@ -0,0 +1,117 @@ +/* + * CodePress regular expressions for ASP-vbscript syntax highlighting + */ + +// ASP VBScript +Language.syntax = [ +// all tags + { input : /(<[^!%|!%@]*?>)/g, output : '$1' }, +// style tags + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, +// script tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, +// strings "" and attributes + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, +// ASP Comment + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2'}, +// <%.* + { input : /(<%)/g, output : '$1' }, +// .*%> + { input : /(%>)/g, output : '$1' }, +// <%@...%> + { input : /(<%@)(.+?)(%>)/gi, output : '$1$2$3' }, +//Numbers + { input : /\b([\d]+)\b/g, output : '$1' }, +// Reserved Words 1 (Blue) + { input : /\b(And|As|ByRef|ByVal|Call|Case|Class|Const|Dim|Do|Each|Else|ElseIf|Empty|End|Eqv|Exit|False|For|Function)\b/gi, output : '$1' }, + { input : /\b(Get|GoTo|If|Imp|In|Is|Let|Loop|Me|Mod|Enum|New|Next|Not|Nothing|Null|On|Option|Or|Private|Public|ReDim|Rem)\b/gi, output : '$1' }, + { input : /\b(Resume|Select|Set|Stop|Sub|Then|To|True|Until|Wend|While|With|Xor|Execute|Randomize|Erase|ExecuteGlobal|Explicit|step)\b/gi, output : '$1' }, +// Reserved Words 2 (Purple) + { input : /\b(Abandon|Abs|AbsolutePage|AbsolutePosition|ActiveCommand|ActiveConnection|ActualSize|AddHeader|AddNew|AppendChunk)\b/gi, output : '$1' }, + { input : /\b(AppendToLog|Application|Array|Asc|Atn|Attributes|BeginTrans|BinaryRead|BinaryWrite|BOF|Bookmark|Boolean|Buffer|Byte)\b/gi, output : '$1' }, + { input : /\b(CacheControl|CacheSize|Cancel|CancelBatch|CancelUpdate|CBool|CByte|CCur|CDate|CDbl|Charset|Chr|CInt|Clear)\b/gi, output : '$1' }, + { input : /\b(ClientCertificate|CLng|Clone|Close|CodePage|CommandText|CommandType|CommandTimeout|CommitTrans|CompareBookmarks|ConnectionString|ConnectionTimeout)\b/gi, output : '$1' }, + { input : /\b(Contents|ContentType|Cookies|Cos|CreateObject|CreateParameter|CSng|CStr|CursorLocation|CursorType|DataMember|DataSource|Date|DateAdd|DateDiff)\b/gi, output : '$1' }, + { input : /\b(DatePart|DateSerial|DateValue|Day|DefaultDatabase|DefinedSize|Delete|Description|Double|EditMode|Eof|EOF|err|Error)\b/gi, output : '$1' }, + { input : /\b(Exp|Expires|ExpiresAbsolute|Filter|Find|Fix|Flush|Form|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent)\b/gi, output : '$1' }, + { input : /\b(GetChunk|GetLastError|GetRows|GetString|Global|HelpContext|HelpFile|Hex|Hour|HTMLEncode|IgnoreCase|Index|InStr|InStrRev)\b/gi, output : '$1' }, + { input : /\b(Int|Integer|IsArray|IsClientConnected|IsDate|IsolationLevel|Join|LBound|LCase|LCID|Left|Len|Lock|LockType|Log|Long|LTrim)\b/gi, output : '$1' }, + { input : /\b(MapPath|MarshalOptions|MaxRecords|Mid|Minute|Mode|Month|MonthName|Move|MoveFirst|MoveLast|MoveNext|MovePrevious|Name|NextRecordset)\b/gi, output : '$1' }, + { input : /\b(Now|Number|NumericScale|ObjectContext|Oct|Open|OpenSchema|OriginalValue|PageCount|PageSize|Pattern|PICS|Precision|Prepared|Property)\b/gi, output : '$1' }, + { input : /\b(Provider|QueryString|RecordCount|Redirect|RegExp|Remove|RemoveAll|Replace|Requery|Request|Response|Resync|Right|Rnd)\b/gi, output : '$1' }, + { input : /\b(RollbackTrans|RTrim|Save|ScriptTimeout|Second|Seek|Server|ServerVariables|Session|SessionID|SetAbort|SetComplete|Sgn)\b/gi, output : '$1' }, + { input : /\b(Sin|Size|Sort|Source|Space|Split|Sqr|State|StaticObjects|Status|StayInSync|StrComp|String|StrReverse|Supports|Tan|Time)\b/gi, output : '$1' }, + { input : /\b(Timeout|Timer|TimeSerial|TimeValue|TotalBytes|Transfer|Trim|Type|Type|UBound|UCase|UnderlyingValue|UnLock|Update|UpdateBatch)\b/gi, output : '$1' }, + { input : /\b(URLEncode|Value|Value|Version|Weekday|WeekdayName|Write|Year)\b/gi, output : '$1' }, +// Reserved Words 3 (Turquis) + { input : /\b(vbBlack|vbRed|vbGreen|vbYellow|vbBlue|vbMagenta|vbCyan|vbWhite|vbBinaryCompare|vbTextCompare)\b/gi, output : '$1' }, + { input : /\b(vbSunday|vbMonday|vbTuesday|vbWednesday|vbThursday|vbFriday|vbSaturday|vbUseSystemDayOfWeek)\b/gi, output : '$1' }, + { input : /\b(vbFirstJan1|vbFirstFourDays|vbFirstFullWeek|vbGeneralDate|vbLongDate|vbShortDate|vbLongTime|vbShortTime)\b/gi, output : '$1' }, + { input : /\b(vbObjectError|vbCr|VbCrLf|vbFormFeed|vbLf|vbNewLine|vbNullChar|vbNullString|vbTab|vbVerticalTab|vbUseDefault|vbTrue)\b/gi, output : '$1' }, + { input : /\b(vbFalse|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant)\b/gi, output : '$1' }, + { input : /\b(vbDataObject|vbDecimal|vbByte|vbArray)\b/gi, output : '$1' }, +// html comments + { input : /(<!--.*?-->.)/g, output : '$1' } +] + +Language.Functions = [ + // Output at index 0, must be the desired tagname surrounding a $1 + // Name is the index from the regex that marks the functionname + {input : /(function|sub)([ ]*?)(\w+)([ ]*?\()/gi , output : '$1', name : '$3'} +] + +Language.snippets = [ +//Conditional + { input : 'if', output : 'If $0 Then\n\t\nEnd If' }, + { input : 'ifelse', output : 'If $0 Then\n\t\n\nElse\n\t\nEnd If' }, + { input : 'case', output : 'Select Case $0\n\tCase ?\n\tCase Else\nEnd Select'}, +//Response + { input : 'rw', output : 'Response.Write( $0 )' }, + { input : 'resc', output : 'Response.Cookies( $0 )' }, + { input : 'resb', output : 'Response.Buffer'}, + { input : 'resflu', output : 'Response.Flush()'}, + { input : 'resend', output : 'Response.End'}, +//Request + { input : 'reqc', output : 'Request.Cookies( $0 )' }, + { input : 'rq', output : 'Request.Querystring("$0")' }, + { input : 'rf', output : 'Request.Form("$0")' }, +//FSO + { input : 'fso', output : 'Set fso = Server.CreateObject("Scripting.FileSystemObject")\n$0' }, + { input : 'setfo', output : 'Set fo = fso.getFolder($0)' }, + { input : 'setfi', output : 'Set fi = fso.getFile($0)' }, + { input : 'twr', output : 'Set f = fso.CreateTextFile($0,true)\'overwrite\nf.WriteLine()\nf.Close'}, + { input : 'tre', output : 'Set f = fso.OpenTextFile($0, 1)\nf.ReadAll\nf.Close'}, +//Server + { input : 'mapp', output : 'Server.Mappath($0)' }, +//Loops + { input : 'foreach', output : 'For Each $0 in ?\n\t\nNext' }, + { input : 'for', output : 'For $0 to ? step ?\n\t\nNext' }, + { input : 'do', output : 'Do While($0)\n\t\nLoop' }, + { input : 'untilrs', output : 'do until rs.eof\n\t\nrs.movenext\nloop' }, +//ADO + { input : 'adorec', output : 'Set rs = Server.CreateObject("ADODB.Recordset")' }, + { input : 'adocon', output : 'Set Conn = Server.CreateObject("ADODB.Connection")' }, + { input : 'adostr', output : 'Set oStr = Server.CreateObject("ADODB.Stream")' }, +//Http Request + { input : 'xmlhttp', output : 'Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")\nxmlHttp.open("GET", $0, false)\nxmlHttp.send()\n?=xmlHttp.responseText' }, + { input : 'xmldoc', output : 'Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")\nxmldoc.async=false\nxmldoc.load(request)'}, +//Functions + { input : 'func', output : 'Function $0()\n\t\n\nEnd Function'}, + { input : 'sub', output : 'Sub $0()\n\t\nEnd Sub'} + +] + +Language.complete = [ + //{ input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [ + { input : '[space]', output : ' ' }, + { input : '[enter]', output : '
' } , + { input : '[j]', output : 'testing' }, + { input : '[7]', output : '&' } +] \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/autoit.css b/htdocs/includes/codepress/languages/autoit.css new file mode 100644 index 00000000000..eb2b43b6e4a --- /dev/null +++ b/htdocs/includes/codepress/languages/autoit.css @@ -0,0 +1,13 @@ +/** + * CodePress color styles for AutoIt syntax highlighting + */ + +u {font-style:normal;color:#000090;font-weight:bold;font-family:Monospace;} +var {color:#AA0000;font-weight:bold;font-style:normal;} +em {color:#FF33FF;} +ins {color:#AC00A9;} +i {color:#F000FF;} +b {color:#FF0000;} +a {color:#0080FF;font-weight:bold;} +s, s u, s b {color:#9999CC;font-weight:normal;} +cite, cite *{color:#009933;font-weight:normal;} \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/autoit.js b/htdocs/includes/codepress/languages/autoit.js new file mode 100644 index 00000000000..6f5c19d0ba2 --- /dev/null +++ b/htdocs/includes/codepress/languages/autoit.js @@ -0,0 +1,32 @@ +/** + * CodePress regular expressions for AutoIt syntax highlighting + * @author: James Brooks, Michael HURNI + */ + +// AutoIt +Language.syntax = [ + { input : /({|}|\(|\))/g, output : '$1' }, // Brackets + { input : /(\*|\+|-)/g, output : '$1' }, // Operator + { input : /\"(.*?)(\"|
|<\/P>)/g, output : "\"$1$2" }, // strings double + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single + { input : /\b([\d]+)\b/g, output : '$1' }, // Numbers + { input : /#(.*?)(
|<\/P>)/g, output : '#$1$2' }, // Directives and Includes + { input : /(\$[\w\.]*)/g, output : '$1' }, // vars + { input : /(_[\w\.]*)/g, output : '$1' }, // underscored word + { input : /(\@[\w\.]*)/g, output : '$1' }, // Macros + { input : /\b(Abs|ACos|AdlibDisable|AdlibEnable|Asc|AscW|ASin|Assign|ATan|AutoItSetOption|AutoItWinGetTitle|AutoItWinSetTitle|Beep|Binary|BinaryLen|BinaryMid|BinaryToString|BitAND|BitNOT|BitOR|BitSHIFT|BitXOR|BlockInput|Break|Call|CDTray|Ceiling|Chr|ChrW|ClipGet|ClipPut|ConsoleRead|ConsoleWrite|ConsoleWriteError|ControlClick|ControlCommand|ControlDisable|ControlEnable|ControlFocus|ControlGetFocus|ControlGetHandle|ControlGetPos|ControlGetText|ControlHide|ControlListView|ControlMove|ControlSend|ControlSetText|ControlShow|Cos|Dec|DirCopy|DirCreate|DirGetSize|DirMove|DirRemove|DllCall|DllCall|DllClose|DllOpen|DllStructCreate|DllStructGetData|DllStructGetPtr|DllStructGetSize|DllStructSetData|DriveGetDrive|DriveGetFileSystem|DriveGetLabel|DriveGetSerial|DriveGetType|DriveMapAdd|DriveMapDel|DriveMapGet|DriveSetLabel|DriveSpaceFree|DriveSpaceTotal|DriveStatus|EnvGet|EnvSet|EnvUpdate|Eval|Execute|Exp|FileChangeDir|FileClose|FileCopy|FileCreateNTFS|FileCreateShortcut|FileDelete|FileExists|FileFindFirstFile|FileFindNextFile|FileGetAttrib|FileGetLongName|FileGetShortcut|FileGetShortName|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileOpen|FileOpenDialog|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileSaveDialog|FileSelectFolder|FileSetAttrib|FileSetTime|FileWrite|FileWriteLine|Floor|FtpSetProxy|GuiCreate|GuiCtrlCreateAvi|GuiCtrlCreateButton|GuiCtrlCreateCheckbox|GuiCtrlCreateCombo|GuiCtrlCreateContextMenu|GuiCtrlCreateDate|GuiCtrlCreateDummy|GuiCtrlCreateEdit|GuiCtrlCreateGraphic|GuiCtrlCreateGroup|GuiCtrlCreateIcon|GuiCtrlCreateInput|GuiCtrlCreateLabel|GuiCtrlCreateList|GuiCtrlCreateListView|GuiCtrlCreateListViewItem|GuiCtrlCreateMenu|GuiCtrlCreateMenuItem|GuiCtrlCreateMonthCal|GuiCtrlCreateObj|GuiCtrlCreatePic|GuiCtrlCreateProgress|GuiCtrlCreateRadio|GuiCtrlCreateSlider|GuiCtrlCreateTab|GuiCtrlCreateTabItem|GuiCtrlCreateUpdown|GuiCtrlDelete|GuiCtrlGetHandle|GuiCtrlGetState|GuiCtrlRead|GuiCtrlRecvMsg|GuiCtrlSentMsg|GuiCtrlSendToDummy|GuiCtrlSetBkColor|GuiCtrlSetColor|GuiCtrlSetCursor|GuiCtrlSetData|GuiCtrlSetFont|GuiCtrlSetGraphic|GuiCtrlSetImage|GuiCtrlSetLimit|GuiCtrlSetOnEvent|GuiCtrlSetPos|GuiCtrlResizing|GuiCtrlSetState|GuiCtrlSetTip|GuiDelete|GuiGetCursorInfo|GuiGetMsg|GuiGetStyle|GuiRegisterMsg|GuiSetBkColor|GuiSetCoord|GuiSetCursor|GuiSetFont|GuiSetHelp|GuiSetIcon|GuiSetOnEvent|GuiSetStat|GuiSetStyle|GuiStartGroup|GuiSwitch|Hex|HotKeySet|HttpSetProxy|HWnd|InetGet|InetGetSize|IniDelete|IniRead|IniReadSection|IniReadSectionNames|IniRenameSection|IniWrite|IniWriteSection|InputBox|Int|IsAdmin|IsArray|IsBinary|IsBool|IsDeclared|IsDllStruct|IsFloat|IsHWnd|IsInt|IsKeyword|IsNumber|IsObj|IsString|Log|MemGetStats|Mod|MouseClick|MouseClickDrag|MouseDown|MouseGetCursor|MouseGetPos|MouseMove|MouseUp|MouseWheel|MsgBox|Number|ObjCreate|ObjEvent|ObjGet|ObjName|Ping|PixelCheckSum|PixelGetColor|PixelSearch|ProcessClose|ProcessExists|ProcessList|ProcessSetPriority|ProcessWait|ProcessWaitClose|ProgressOff|ProcessOn|ProgressSet|Random|RegDelete|RegEnumKey|RegEnumVal|RegRead|RegWrite|Round|Run|RunAsSet|RunWait|Send|SetError|SetExtended|ShellExecute|ShellExecuteWait|Shutdown|Sin|Sleep|SoundPlay|SoundSetWaveVolume|SplashImageOn|SplashOff|SplashTextOn|Sqrt|SRandom|StatusbarGetText|StderrRead|StdinWrite|StdoutRead|String|StringAddCR|StringCompare|StringFormat|StringInStr|StringIsAlNum|StringIsAlpha|StringIsASCII|StringIsDigit|StringIsFloat|StringIsInt|StringIsLower|StringIsSpace|StringIsUpper|StringIsXDigit|StringLeft|StringLen|StringLower|StringMid|StringRegExp|StringRegExpReplace|StringReplace|StringRight|StringSplit|StringStripCR|StringStripWS|StringToBinary|StringTrimLeft|StringTrimRight|StringUpper|Tan|TCPAccept|TCPCloseSocket|TCPConnect|TCPListen|TCPNameToIP|TCPrecv|TCPSend|TCPShutdown|TCPStartup|TimerDiff|TimerInit|ToolTip|TrayCreateItem|TrayCreateMenu|TrayGetMenu|TrayGetMsg|TrayItemDelete|TrayItemGetHandle|TrayItemGetState|TrayItemGetText|TrayItemSetOnEvent|TrayItemSetState|TrayItemSetText|TraySetClick|TraySetIcon|TraySetOnEvent|TraySetPauseIcon|TraySetState|TraySetToolTip|TrayTip|UBound|UDPBind|UDPCloseSocket|UDPOpen|UDPRecv|UDPSend|WinActivate|WinActive|WinClose|WinExists|WinFlash|WinGetCaretPos|WinGetClassList|WinGetClientSize|WinGetHandle|WinGetPos|WinGetProcess|WinGetState|WinGetText|WinGetTitle|WinKill|WinList|WinMenuSelectItem|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinSetOnTop|WinSetState|WinSetTitle|WinSetTrans|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/g, output : '$1' } ,// reserved words + { input : /\B;(.*?)(
|<\/P>)/g, output : ';$1$2' }, // comments + { input : /#CS(.*?)#CE/g, output : '#CS$1#CE' } // Block Comments +] + +Language.snippets = [] + +Language.complete = [ +{ input : '\'',output : '\'$0\'' }, +{ input : '"', output : '"$0"' }, +{ input : '(', output : '\($0\)' }, +{ input : '[', output : '\[$0\]' }, +{ input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/csharp.css b/htdocs/includes/codepress/languages/csharp.css new file mode 100644 index 00000000000..8464c5ddb0d --- /dev/null +++ b/htdocs/includes/codepress/languages/csharp.css @@ -0,0 +1,9 @@ +/* + * CodePress color styles for Java syntax highlighting + * By Edwin de Jonge + */ + +b {color:#7F0055;font-weight:bold;font-style:normal;} /* reserved words */ +a {color:#2A0088;font-weight:bold;font-style:normal;} /* types */ +i, i b, i s {color:#3F7F5F;font-weight:bold;} /* comments */ +s, s b {color:#2A00FF;font-weight:normal;} /* strings */ \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/csharp.js b/htdocs/includes/codepress/languages/csharp.js new file mode 100644 index 00000000000..0a61fd52a92 --- /dev/null +++ b/htdocs/includes/codepress/languages/csharp.js @@ -0,0 +1,25 @@ +/* + * CodePress regular expressions for C# syntax highlighting + * By Edwin de Jonge + */ + +Language.syntax = [ // C# + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /\b(abstract|as|base|break|case|catch|checked|continue|default|delegate|do|else|event|explicit|extern|false|finally|fixed|for|foreach|get|goto|if|implicit|in|interface|internal|is|lock|namespace|new|null|object|operator|out|override|params|partial|private|protected|public|readonly|ref|return|set|sealed|sizeof|static|stackalloc|switch|this|throw|true|try|typeof|unchecked|unsafe|using|value|virtual|while)\b/g, output : '$1' }, // reserved words + { input : /\b(bool|byte|char|class|double|float|int|interface|long|string|struct|void)\b/g, output : '$1' }, // types + { input : /([^:]|^)\/\/(.*?)(//$2$3' }, // comments // + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' } // comments /* */ +]; + +Language.snippets = []; + +Language.complete = [ // Auto complete only for 1 character + {input : '\'',output : '\'$0\'' }, + {input : '"', output : '"$0"' }, + {input : '(', output : '\($0\)' }, + {input : '[', output : '\[$0\]' }, + {input : '{', output : '{\n\t$0\n}' } +]; + +Language.shortcuts = []; \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/css.css b/htdocs/includes/codepress/languages/css.css new file mode 100644 index 00000000000..49ba5843d73 --- /dev/null +++ b/htdocs/includes/codepress/languages/css.css @@ -0,0 +1,10 @@ +/* + * CodePress color styles for CSS syntax highlighting + */ + +b, b a, b u {color:#000080;} /* tags, ids, classes */ +i, i b, i s, i a, i u {color:gray;} /* comments */ +s, s b {color:#a0a0dd;} /* parameters */ +a {color:#0000ff;} /* keys */ +u {color:red;} /* values */ + diff --git a/htdocs/includes/codepress/languages/css.js b/htdocs/includes/codepress/languages/css.js new file mode 100644 index 00000000000..c29059b76e3 --- /dev/null +++ b/htdocs/includes/codepress/languages/css.js @@ -0,0 +1,23 @@ +/* + * CodePress regular expressions for CSS syntax highlighting + */ + +// CSS +Language.syntax = [ + { input : /(.*?){(.*?)}/g,output : '$1{$2}' }, // tags, ids, classes, values + { input : /([\w-]*?):([^\/])/g,output : '$1:$2' }, // keys + { input : /\((.*?)\)/g,output : '($1)' }, // parameters + { input : /\/\*(.*?)\*\//g,output : '/*$1*/'} // comments +] + +Language.snippets = [] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/generic.css b/htdocs/includes/codepress/languages/generic.css new file mode 100644 index 00000000000..712942f45af --- /dev/null +++ b/htdocs/includes/codepress/languages/generic.css @@ -0,0 +1,9 @@ +/* + * CodePress color styles for generic syntax highlighting + */ + +b {color:#7F0055;font-weight:bold;} /* reserved words */ +u {color:darkblue;font-weight:bold;} /* special words */ +i, i b, i s, i u, i em {color:green;font-weight:normal;} /* comments */ +s, s b, s em {color:#2A00FF;font-weight:normal;} /* strings */ +em {font-weight:bold;} /* special chars */ \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/generic.js b/htdocs/includes/codepress/languages/generic.js new file mode 100644 index 00000000000..4c866de9995 --- /dev/null +++ b/htdocs/includes/codepress/languages/generic.js @@ -0,0 +1,25 @@ +/* + * CodePress regular expressions for generic syntax highlighting + */ + +// generic languages +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /\b(abstract|continue|for|new|switch|default|goto|boolean|do|if|private|this|break|double|protected|throw|byte|else|import|public|throws|case|return|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|const|float|while|function|label)\b/g, output : '$1' }, // reserved words + { input : /([\(\){}])/g, output : '$1' }, // special chars; + { input : /([^:]|^)\/\/(.*?)(//$2$3' }, // comments // + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' } // comments /* */ +] + +Language.snippets = [] + +Language.complete = [ + { input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/html.css b/htdocs/includes/codepress/languages/html.css new file mode 100644 index 00000000000..14882e553ef --- /dev/null +++ b/htdocs/includes/codepress/languages/html.css @@ -0,0 +1,13 @@ +/* + * CodePress color styles for HTML syntax highlighting + */ + +b {color:#000080;} /* tags */ +ins, ins b, ins s, ins em {color:gray;} /* comments */ +s, s b {color:#7777e4;} /* attribute values */ +a {color:green;} /* links */ +u {color:#E67300;} /* forms */ +big {color:#db0000;} /* images */ +em, em b {color:#800080;} /* style */ +strong {color:#800000;} /* script */ +tt i {color:darkblue;font-weight:bold;} /* script reserved words */ diff --git a/htdocs/includes/codepress/languages/html.js b/htdocs/includes/codepress/languages/html.js new file mode 100644 index 00000000000..4ead0b086ba --- /dev/null +++ b/htdocs/includes/codepress/languages/html.js @@ -0,0 +1,59 @@ +/* + * CodePress regular expressions for HTML syntax highlighting + */ + +// HTML +Language.syntax = [ + { input : /(<[^!]*?>)/g, output : '$1' }, // all tags + { input : /(<a .*?>|<\/a>)/g, output : '$1' }, // links + { input : /(<img .*?>)/g, output : '$1' }, // images + { input : /(<\/?(button|textarea|form|input|select|option|label).*?>)/g, output : '$1' }, // forms + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, // style tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, // script tags + { input : /=(".*?")/g, output : '=$1' }, // atributes double quote + { input : /=('.*?')/g, output : '=$1' }, // atributes single quote + { input : /(<!--.*?-->.)/g, output : '$1' }, // comments + { input : /\b(alert|window|document|break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, output : '$1' } // script reserved words +] + +Language.snippets = [ + { input : 'aref', output : '' }, + { input : 'h1', output : '

$0

' }, + { input : 'h2', output : '

$0

' }, + { input : 'h3', output : '

$0

' }, + { input : 'h4', output : '

$0

' }, + { input : 'h5', output : '
$0
' }, + { input : 'h6', output : '
$0
' }, + { input : 'html', output : '\n\t$0\n' }, + { input : 'head', output : '\n\t\n\t$0\n\t\n' }, + { input : 'img', output : '' }, + { input : 'input', output : '' }, + { input : 'label', output : '' }, + { input : 'legend', output : '\n\t$0\n' }, + { input : 'link', output : '' }, + { input : 'base', output : '' }, + { input : 'body', output : '\n\t$0\n' }, + { input : 'css', output : '' }, + { input : 'div', output : '
\n\t$0\n
' }, + { input : 'divid', output : '
\n\t\n
' }, + { input : 'dl', output : '
\n\t
\n\t\t$0\n\t
\n\t
\n
' }, + { input : 'fieldset', output : '
\n\t$0\n
' }, + { input : 'form', output : '
\n\t\n
' }, + { input : 'meta', output : '' }, + { input : 'p', output : '

$0

' }, + { input : 'script', output : '' }, + { input : 'scriptsrc', output : '' }, + { input : 'span', output : '$0' }, + { input : 'table', output : '\n\t\n\t\n
' }, + { input : 'style', output : '' } +] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/java.css b/htdocs/includes/codepress/languages/java.css new file mode 100644 index 00000000000..b9c44416836 --- /dev/null +++ b/htdocs/includes/codepress/languages/java.css @@ -0,0 +1,7 @@ +/* + * CodePress color styles for Java syntax highlighting + */ + +b {color:#7F0055;font-weight:bold;font-style:normal;} /* reserved words */ +i, i b, i s {color:#3F7F5F;font-weight:bold;} /* comments */ +s, s b {color:#2A00FF;font-weight:normal;} /* strings */ diff --git a/htdocs/includes/codepress/languages/java.js b/htdocs/includes/codepress/languages/java.js new file mode 100644 index 00000000000..f0d620d6898 --- /dev/null +++ b/htdocs/includes/codepress/languages/java.js @@ -0,0 +1,24 @@ +/* + * CodePress regular expressions for Java syntax highlighting + */ + +// Java +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2'}, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2'}, // strings single quote + { input : /\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/g, output : '$1'}, // reserved words + { input : /([^:]|^)\/\/(.*?)(//$2$3'}, // comments // + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' }// comments /* */ +] + +Language.snippets = [] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/javascript.css b/htdocs/includes/codepress/languages/javascript.css new file mode 100644 index 00000000000..acbf49a916f --- /dev/null +++ b/htdocs/includes/codepress/languages/javascript.css @@ -0,0 +1,8 @@ +/* + * CodePress color styles for JavaScript syntax highlighting + */ + +b {color:#7F0055;font-weight:bold;} /* reserved words */ +u {color:darkblue;font-weight:bold;} /* special words */ +i, i b, i s, i u {color:green;font-weight:normal;} /* comments */ +s, s b, s u {color:#2A00FF;font-weight:normal;} /* strings */ diff --git a/htdocs/includes/codepress/languages/javascript.js b/htdocs/includes/codepress/languages/javascript.js new file mode 100644 index 00000000000..66d0fc02409 --- /dev/null +++ b/htdocs/includes/codepress/languages/javascript.js @@ -0,0 +1,30 @@ +/* + * CodePress regular expressions for JavaScript syntax highlighting + */ + +// JavaScript +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /\b(break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, output : '$1' }, // reserved words + { input : /\b(alert|isNaN|parent|Array|parseFloat|parseInt|blur|clearTimeout|prompt|prototype|close|confirm|length|Date|location|Math|document|element|name|self|elements|setTimeout|navigator|status|String|escape|Number|submit|eval|Object|event|onblur|focus|onerror|onfocus|onclick|top|onload|toString|onunload|unescape|open|valueOf|window|onmouseover)\b/g, output : '$1' }, // special words + { input : /([^:]|^)\/\/(.*?)(//$2$3' }, // comments // + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' } // comments /* */ +] + +Language.snippets = [ + { input : 'dw', output : 'document.write(\'$0\');' }, + { input : 'getid', output : 'document.getElementById(\'$0\')' }, + { input : 'fun', output : 'function $0(){\n\t\n}' }, + { input : 'func', output : 'function $0(){\n\t\n}' } +] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/perl.css b/htdocs/includes/codepress/languages/perl.css new file mode 100644 index 00000000000..c2d6d56d730 --- /dev/null +++ b/htdocs/includes/codepress/languages/perl.css @@ -0,0 +1,11 @@ +/* + * CodePress color styles for Perl syntax highlighting + * By J. Nick Koston + */ + +b {color:#7F0055;font-weight:bold;} /* reserved words */ +i, i b, i s, i em, i a, i u {color:gray;font-weight:normal;} /* comments */ +s, s b, s a, s em, s u {color:#2A00FF;font-weight:normal;} /* strings */ +a {color:#006700;font-weight:bold;} /* variables */ +em {color:darkblue;font-weight:bold;} /* functions */ +u {font-weight:bold;} /* special chars */ \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/perl.js b/htdocs/includes/codepress/languages/perl.js new file mode 100644 index 00000000000..06c380d654a --- /dev/null +++ b/htdocs/includes/codepress/languages/perl.js @@ -0,0 +1,27 @@ +/* + * CodePress regular expressions for Perl syntax highlighting + * By J. Nick Koston + */ + +// Perl +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /([\$\@\%][\w\.]*)/g, output : '$1' }, // vars + { input : /(sub\s+)([\w\.]*)/g, output : '$1$2' }, // functions + { input : /\b(abs|accept|alarm|atan2|bind|binmode|bless|caller|chdir|chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|continue|cos|crypt|dbmclose|dbmopen|defined|delete|die|do|dump|each|else|elsif|endgrent|endhostent|endnetent|endprotoent|endpwent|eof|eval|exec|exists|exit|fcntl|fileno|find|flock|for|foreach|fork|format|formlinegetc|getgrent|getgrgid|getgrnam|gethostbyaddr|gethostbyname|gethostent|getlogin|getnetbyaddr|getnetbyname|getnetent|getpeername|getpgrp|getppid|getpriority|getprotobyname|getprotobynumber|getprotoent|getpwent|getpwnam|getpwuid|getservbyaddr|getservbyname|getservbyport|getservent|getsockname|getsockopt|glob|gmtime|goto|grep|hex|hostname|if|import|index|int|ioctl|join|keys|kill|last|lc|lcfirst|length|link|listen|LoadExternals|local|localtime|log|lstat|map|mkdir|msgctl|msgget|msgrcv|msgsnd|my|next|no|oct|open|opendir|ordpack|package|pipe|pop|pos|print|printf|push|pwd|qq|quotemeta|qw|rand|read|readdir|readlink|recv|redo|ref|rename|require|reset|return|reverse|rewinddir|rindex|rmdir|scalar|seek|seekdir|select|semctl|semget|semop|send|setgrent|sethostent|setnetent|setpgrp|setpriority|setprotoent|setpwent|setservent|setsockopt|shift|shmctl|shmget|shmread|shmwrite|shutdown|sin|sleep|socket|socketpair|sort|splice|split|sprintf|sqrt|srand|stat|stty|study|sub|substr|symlink|syscall|sysopen|sysread|system|syswritetell|telldir|tie|tied|time|times|tr|truncate|uc|ucfirst|umask|undef|unless|unlink|until|unpack|unshift|untie|use|utime|values|vec|waitpid|wantarray|warn|while|write)\b/g, output : '$1' }, // reserved words + { input : /([\(\){}])/g, output : '$1' }, // special chars + { input : /#(.*?)(
|<\/P>)/g, output : '#$1$2' } // comments +] + +Language.snippets = [] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/php.css b/htdocs/includes/codepress/languages/php.css new file mode 100644 index 00000000000..23fca5c7f23 --- /dev/null +++ b/htdocs/includes/codepress/languages/php.css @@ -0,0 +1,12 @@ +/* + * CodePress color styles for PHP syntax highlighting + */ + +b {color:#000080;} /* tags */ +big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {color:gray;font-weight:normal;} /* comments */ +s, s b, strong s u, strong s cite {color:#5656fa;font-weight:normal;} /* attributes and strings */ +strong a, strong a u {color:#006700;font-weight:bold;} /* variables */ +em {color:#800080;font-style:normal;} /* style */ +ins {color:#800000;} /* script */ +strong u {color:#7F0055;font-weight:bold;} /* reserved words */ +cite, s cite {color:red;font-weight:bold;} /* */ diff --git a/htdocs/includes/codepress/languages/php.js b/htdocs/includes/codepress/languages/php.js new file mode 100644 index 00000000000..1689fbae44e --- /dev/null +++ b/htdocs/includes/codepress/languages/php.js @@ -0,0 +1,61 @@ +/* + * CodePress regular expressions for PHP syntax highlighting + */ + +// PHP +Language.syntax = [ + { input : /(<[^!\?]*?>)/g, output : '$1' }, // all tags + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, // style tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, // script tags + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2'}, // strings single quote + { input : /(<\?)/g, output : '$1' }, // ' }, // .*?> + { input : /(<\?php|<\?=|<\?|\?>)/g, output : '$1' }, // php tags + { input : /(\$[\w\.]*)/g, output : '$1' }, // vars + { input : /\b(false|true|and|or|xor|__FILE__|exception|__LINE__|array|as|break|case|class|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|for|foreach|function|global|if|include|include_once|isset|list|new|print|require|require_once|return|static|switch|unset|use|while|__FUNCTION__|__CLASS__|__METHOD__|final|php_user_filter|interface|implements|extends|public|private|protected|abstract|clone|try|catch|throw|this)\b/g, output : '$1' }, // reserved words + { input : /([^:])\/\/(.*?)(//$2$3' }, // php comments // + { input : /([^:])#(.*?)(#$2$3' }, // php comments # + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' }, // php comments /* */ + { input : /(<!--.*?-->.)/g, output : '$1' } // html comments +] + +Language.snippets = [ + { input : 'if', output : 'if($0){\n\t\n}' }, + { input : 'ifelse', output : 'if($0){\n\t\n}\nelse{\n\t\n}' }, + { input : 'else', output : '}\nelse {\n\t' }, + { input : 'elseif', output : '}\nelseif($0) {\n\t' }, + { input : 'do', output : 'do{\n\t$0\n}\nwhile();' }, + { input : 'inc', output : 'include_once("$0");' }, + { input : 'fun', output : 'function $0(){\n\t\n}' }, + { input : 'func', output : 'function $0(){\n\t\n}' }, + { input : 'while', output : 'while($0){\n\t\n}' }, + { input : 'for', output : 'for($0,,){\n\t\n}' }, + { input : 'fore', output : 'foreach($0 as ){\n\t\n}' }, + { input : 'foreach', output : 'foreach($0 as ){\n\t\n}' }, + { input : 'echo', output : 'echo \'$0\';' }, + { input : 'switch', output : 'switch($0) {\n\tcase "": break;\n\tdefault: ;\n}' }, + { input : 'case', output : 'case "$0" : break;' }, + { input : 'ret0', output : 'return false;' }, + { input : 'retf', output : 'return false;' }, + { input : 'ret1', output : 'return true;' }, + { input : 'rett', output : 'return true;' }, + { input : 'ret', output : 'return $0;' }, + { input : 'def', output : 'define(\'$0\',\'\');' }, + { input : '' } +] + +Language.complete = [ + { input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [ + { input : '[space]', output : ' ' }, + { input : '[enter]', output : '
' } , + { input : '[j]', output : 'testing' }, + { input : '[7]', output : '&' } +] \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/ruby.css b/htdocs/includes/codepress/languages/ruby.css new file mode 100644 index 00000000000..edb9028dbbf --- /dev/null +++ b/htdocs/includes/codepress/languages/ruby.css @@ -0,0 +1,10 @@ +/* + * CodePress color styles for Ruby syntax highlighting + */ + +b {color:#7F0055;font-weight:bold;} /* reserved words */ +i, i b, i s, i em, i a, i u {color:gray;font-weight:normal;} /* comments */ +s, s b, s a, s em, s u {color:#2A00FF;font-weight:normal;} /* strings */ +a {color:#006700;font-weight:bold;} /* variables */ +em {color:darkblue;font-weight:bold;} /* functions */ +u {font-weight:bold;} /* special chars */ \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/ruby.js b/htdocs/includes/codepress/languages/ruby.js new file mode 100644 index 00000000000..207f23b0043 --- /dev/null +++ b/htdocs/includes/codepress/languages/ruby.js @@ -0,0 +1,26 @@ +/* + * CodePress regular expressions for Perl syntax highlighting + */ + +// Ruby +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /([\$\@\%]+)([\w\.]*)/g, output : '$1$2' }, // vars + { input : /(def\s+)([\w\.]*)/g, output : '$1$2' }, // functions + { input : /\b(alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\b/g, output : '$1' }, // reserved words + { input : /([\(\){}])/g, output : '$1' }, // special chars + { input : /#(.*?)(
|<\/P>)/g, output : '#$1$2' } // comments +]; + +Language.snippets = [] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/sql.css b/htdocs/includes/codepress/languages/sql.css new file mode 100644 index 00000000000..92c4b96dc77 --- /dev/null +++ b/htdocs/includes/codepress/languages/sql.css @@ -0,0 +1,10 @@ +/* + * CodePress color styles for SQL syntax highlighting + * By Merlin Moncure + */ + +b {color:#0000FF;font-style:normal;font-weight:bold;} /* reserved words */ +u {color:#FF0000;font-style:normal;} /* types */ +a {color:#CD6600;font-style:normal;font-weight:bold;} /* commands */ +i, i b, i u, i a, i s {color:#A9A9A9;font-weight:normal;font-style:italic;} /* comments */ +s, s b, s u, s a, s i {color:#2A00FF;font-weight:normal;} /* strings */ diff --git a/htdocs/includes/codepress/languages/sql.js b/htdocs/includes/codepress/languages/sql.js new file mode 100644 index 00000000000..1d4a21f82f9 --- /dev/null +++ b/htdocs/includes/codepress/languages/sql.js @@ -0,0 +1,30 @@ +/* + * CodePress regular expressions for SQL syntax highlighting + * By Merlin Moncure + */ + +// SQL +Language.syntax = [ + { input : /\'(.*?)(\')/g, output : '\'$1$2' }, // strings single quote + { input : /\b(add|after|aggregate|alias|all|and|as|authorization|between|by|cascade|cache|cache|called|case|check|column|comment|constraint|createdb|createuser|cycle|database|default|deferrable|deferred|diagnostics|distinct|domain|each|else|elseif|elsif|encrypted|except|exception|for|foreign|from|from|full|function|get|group|having|if|immediate|immutable|in|increment|initially|increment|index|inherits|inner|input|intersect|into|invoker|is|join|key|language|left|like|limit|local|loop|match|maxvalue|minvalue|natural|nextval|no|nocreatedb|nocreateuser|not|null|of|offset|oids|on|only|operator|or|order|outer|owner|partial|password|perform|plpgsql|primary|record|references|replace|restrict|return|returns|right|row|rule|schema|security|sequence|session|sql|stable|statistics|table|temp|temporary|then|time|to|transaction|trigger|type|unencrypted|union|unique|user|using|valid|value|values|view|volatile|when|where|with|without|zone)\b/gi, output : '$1' }, // reserved words + { input : /\b(bigint|bigserial|bit|boolean|box|bytea|char|character|cidr|circle|date|decimal|double|float4|float8|inet|int2|int4|int8|integer|interval|line|lseg|macaddr|money|numeric|oid|path|point|polygon|precision|real|refcursor|serial|serial4|serial8|smallint|text|timestamp|varbit|varchar)\b/gi, output : '$1' }, // types + { input : /\b(abort|alter|analyze|begin|checkpoint|close|cluster|comment|commit|copy|create|deallocate|declare|delete|drop|end|execute|explain|fetch|grant|insert|listen|load|lock|move|notify|prepare|reindex|reset|restart|revoke|rollback|select|set|show|start|truncate|unlisten|update)\b/gi, output : '$1' }, // commands + { input : /([^:]|^)\-\-(.*?)(--$2$3' } // comments // +] + +Language.snippets = [ + { input : 'select', output : 'select $0 from where ' } +] + +Language.complete = [ + { input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] + + + diff --git a/htdocs/includes/codepress/languages/text.css b/htdocs/includes/codepress/languages/text.css new file mode 100644 index 00000000000..474fe60c097 --- /dev/null +++ b/htdocs/includes/codepress/languages/text.css @@ -0,0 +1,5 @@ +/* + * CodePress color styles for Text syntax highlighting + */ + +/* do nothing as expected */ diff --git a/htdocs/includes/codepress/languages/text.js b/htdocs/includes/codepress/languages/text.js new file mode 100644 index 00000000000..6534aafa588 --- /dev/null +++ b/htdocs/includes/codepress/languages/text.js @@ -0,0 +1,9 @@ +/* + * CodePress regular expressions for Text syntax highlighting + */ + +// plain text +Language.syntax = [] +Language.snippets = [] +Language.complete = [] +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/vbscript.css b/htdocs/includes/codepress/languages/vbscript.css new file mode 100644 index 00000000000..e1465e90fea --- /dev/null +++ b/htdocs/includes/codepress/languages/vbscript.css @@ -0,0 +1,71 @@ +/* + * CodePress color styles for ASP-VB syntax highlighting + * By Martin D. Kirk + */ + +/* tags */ +b { + color:#000080; +} +/* comments */ +big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u { + color:gray; + font-weight:normal; +} +/* ASP comments */ +strong dfn, strong dfn a,strong dfn var, strong dfn a u, strong dfn u{ + color:gray; + font-weight:normal; +} + /* attributes */ +s, s b, span s u, span s cite, strong span s { + color:#5656fa ; + font-weight:normal; +} + /* strings */ +strong s,strong s b, strong s u, strong s cite { + color:#009900; + font-weight:normal; +} +strong ins{ + color:#000000; + font-weight:bold; +} + /* Syntax */ +strong a, strong a u { + color:#0000FF; + font-weight:; +} + /* Native Keywords */ +strong u { + color:#990099; + font-weight:bold; +} +/* Numbers */ +strong var{ + color:#FF0000; +} +/* ASP Language */ +span{ + color:#990000; + font-weight:bold; +} +strong i,strong a i, strong u i { + color:#009999; +} +/* style */ +em { + color:#800080; + font-style:normal; +} + /* script */ +ins { + color:#800000; + font-weight:bold; +} + +/* */ +cite, s cite { + color:red; + font-weight:bold; +} \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/vbscript.js b/htdocs/includes/codepress/languages/vbscript.js new file mode 100644 index 00000000000..21e78dd887c --- /dev/null +++ b/htdocs/includes/codepress/languages/vbscript.js @@ -0,0 +1,117 @@ +/* + * CodePress regular expressions for ASP-vbscript syntax highlighting + */ + +// ASP VBScript +Language.syntax = [ +// all tags + { input : /(<[^!%|!%@]*?>)/g, output : '$1' }, +// style tags + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, +// script tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, +// strings "" and attributes + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, +// ASP Comment + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2'}, +// <%.* + { input : /(<%)/g, output : '$1' }, +// .*%> + { input : /(%>)/g, output : '$1' }, +// <%@...%> + { input : /(<%@)(.+?)(%>)/gi, output : '$1$2$3' }, +//Numbers + { input : /\b([\d]+)\b/g, output : '$1' }, +// Reserved Words 1 (Blue) + { input : /\b(And|As|ByRef|ByVal|Call|Case|Class|Const|Dim|Do|Each|Else|ElseIf|Empty|End|Eqv|Exit|False|For|Function)\b/gi, output : '$1' }, + { input : /\b(Get|GoTo|If|Imp|In|Is|Let|Loop|Me|Mod|Enum|New|Next|Not|Nothing|Null|On|Option|Or|Private|Public|ReDim|Rem)\b/gi, output : '$1' }, + { input : /\b(Resume|Select|Set|Stop|Sub|Then|To|True|Until|Wend|While|With|Xor|Execute|Randomize|Erase|ExecuteGlobal|Explicit|step)\b/gi, output : '$1' }, +// Reserved Words 2 (Purple) + { input : /\b(Abandon|Abs|AbsolutePage|AbsolutePosition|ActiveCommand|ActiveConnection|ActualSize|AddHeader|AddNew|AppendChunk)\b/gi, output : '$1' }, + { input : /\b(AppendToLog|Application|Array|Asc|Atn|Attributes|BeginTrans|BinaryRead|BinaryWrite|BOF|Bookmark|Boolean|Buffer|Byte)\b/gi, output : '$1' }, + { input : /\b(CacheControl|CacheSize|Cancel|CancelBatch|CancelUpdate|CBool|CByte|CCur|CDate|CDbl|Charset|Chr|CInt|Clear)\b/gi, output : '$1' }, + { input : /\b(ClientCertificate|CLng|Clone|Close|CodePage|CommandText|CommandType|CommandTimeout|CommitTrans|CompareBookmarks|ConnectionString|ConnectionTimeout)\b/gi, output : '$1' }, + { input : /\b(Contents|ContentType|Cookies|Cos|CreateObject|CreateParameter|CSng|CStr|CursorLocation|CursorType|DataMember|DataSource|Date|DateAdd|DateDiff)\b/gi, output : '$1' }, + { input : /\b(DatePart|DateSerial|DateValue|Day|DefaultDatabase|DefinedSize|Delete|Description|Double|EditMode|Eof|EOF|err|Error)\b/gi, output : '$1' }, + { input : /\b(Exp|Expires|ExpiresAbsolute|Filter|Find|Fix|Flush|Form|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent)\b/gi, output : '$1' }, + { input : /\b(GetChunk|GetLastError|GetRows|GetString|Global|HelpContext|HelpFile|Hex|Hour|HTMLEncode|IgnoreCase|Index|InStr|InStrRev)\b/gi, output : '$1' }, + { input : /\b(Int|Integer|IsArray|IsClientConnected|IsDate|IsolationLevel|Join|LBound|LCase|LCID|Left|Len|Lock|LockType|Log|Long|LTrim)\b/gi, output : '$1' }, + { input : /\b(MapPath|MarshalOptions|MaxRecords|Mid|Minute|Mode|Month|MonthName|Move|MoveFirst|MoveLast|MoveNext|MovePrevious|Name|NextRecordset)\b/gi, output : '$1' }, + { input : /\b(Now|Number|NumericScale|ObjectContext|Oct|Open|OpenSchema|OriginalValue|PageCount|PageSize|Pattern|PICS|Precision|Prepared|Property)\b/gi, output : '$1' }, + { input : /\b(Provider|QueryString|RecordCount|Redirect|RegExp|Remove|RemoveAll|Replace|Requery|Request|Response|Resync|Right|Rnd)\b/gi, output : '$1' }, + { input : /\b(RollbackTrans|RTrim|Save|ScriptTimeout|Second|Seek|Server|ServerVariables|Session|SessionID|SetAbort|SetComplete|Sgn)\b/gi, output : '$1' }, + { input : /\b(Sin|Size|Sort|Source|Space|Split|Sqr|State|StaticObjects|Status|StayInSync|StrComp|String|StrReverse|Supports|Tan|Time)\b/gi, output : '$1' }, + { input : /\b(Timeout|Timer|TimeSerial|TimeValue|TotalBytes|Transfer|Trim|Type|Type|UBound|UCase|UnderlyingValue|UnLock|Update|UpdateBatch)\b/gi, output : '$1' }, + { input : /\b(URLEncode|Value|Value|Version|Weekday|WeekdayName|Write|Year)\b/gi, output : '$1' }, +// Reserved Words 3 (Turquis) + { input : /\b(vbBlack|vbRed|vbGreen|vbYellow|vbBlue|vbMagenta|vbCyan|vbWhite|vbBinaryCompare|vbTextCompare)\b/gi, output : '$1' }, + { input : /\b(vbSunday|vbMonday|vbTuesday|vbWednesday|vbThursday|vbFriday|vbSaturday|vbUseSystemDayOfWeek)\b/gi, output : '$1' }, + { input : /\b(vbFirstJan1|vbFirstFourDays|vbFirstFullWeek|vbGeneralDate|vbLongDate|vbShortDate|vbLongTime|vbShortTime)\b/gi, output : '$1' }, + { input : /\b(vbObjectError|vbCr|VbCrLf|vbFormFeed|vbLf|vbNewLine|vbNullChar|vbNullString|vbTab|vbVerticalTab|vbUseDefault|vbTrue)\b/gi, output : '$1' }, + { input : /\b(vbFalse|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant)\b/gi, output : '$1' }, + { input : /\b(vbDataObject|vbDecimal|vbByte|vbArray)\b/gi, output : '$1' }, +// html comments + { input : /(<!--.*?-->.)/g, output : '$1' } +] + +Language.Functions = [ + // Output at index 0, must be the desired tagname surrounding a $1 + // Name is the index from the regex that marks the functionname + {input : /(function|sub)([ ]*?)(\w+)([ ]*?\()/gi , output : '$1', name : '$3'} +] + +Language.snippets = [ +//Conditional + { input : 'if', output : 'If $0 Then\n\t\nEnd If' }, + { input : 'ifelse', output : 'If $0 Then\n\t\n\nElse\n\t\nEnd If' }, + { input : 'case', output : 'Select Case $0\n\tCase ?\n\tCase Else\nEnd Select'}, +//Response + { input : 'rw', output : 'Response.Write( $0 )' }, + { input : 'resc', output : 'Response.Cookies( $0 )' }, + { input : 'resb', output : 'Response.Buffer'}, + { input : 'resflu', output : 'Response.Flush()'}, + { input : 'resend', output : 'Response.End'}, +//Request + { input : 'reqc', output : 'Request.Cookies( $0 )' }, + { input : 'rq', output : 'Request.Querystring("$0")' }, + { input : 'rf', output : 'Request.Form("$0")' }, +//FSO + { input : 'fso', output : 'Set fso = Server.CreateObject("Scripting.FileSystemObject")\n$0' }, + { input : 'setfo', output : 'Set fo = fso.getFolder($0)' }, + { input : 'setfi', output : 'Set fi = fso.getFile($0)' }, + { input : 'twr', output : 'Set f = fso.CreateTextFile($0,true)\'overwrite\nf.WriteLine()\nf.Close'}, + { input : 'tre', output : 'Set f = fso.OpenTextFile($0, 1)\nf.ReadAll\nf.Close'}, +//Server + { input : 'mapp', output : 'Server.Mappath($0)' }, +//Loops + { input : 'foreach', output : 'For Each $0 in ?\n\t\nNext' }, + { input : 'for', output : 'For $0 to ? step ?\n\t\nNext' }, + { input : 'do', output : 'Do While($0)\n\t\nLoop' }, + { input : 'untilrs', output : 'do until rs.eof\n\t\nrs.movenext\nloop' }, +//ADO + { input : 'adorec', output : 'Set rs = Server.CreateObject("ADODB.Recordset")' }, + { input : 'adocon', output : 'Set Conn = Server.CreateObject("ADODB.Connection")' }, + { input : 'adostr', output : 'Set oStr = Server.CreateObject("ADODB.Stream")' }, +//Http Request + { input : 'xmlhttp', output : 'Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")\nxmlHttp.open("GET", $0, false)\nxmlHttp.send()\n?=xmlHttp.responseText' }, + { input : 'xmldoc', output : 'Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")\nxmldoc.async=false\nxmldoc.load(request)'}, +//Functions + { input : 'func', output : 'Function $0()\n\t\n\nEnd Function'}, + { input : 'sub', output : 'Sub $0()\n\t\nEnd Sub'} + +] + +Language.complete = [ + //{ input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [ + { input : '[space]', output : ' ' }, + { input : '[enter]', output : '
' } , + { input : '[j]', output : 'testing' }, + { input : '[7]', output : '&' } +] \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/xsl.css b/htdocs/includes/codepress/languages/xsl.css new file mode 100644 index 00000000000..385eaaba1f9 --- /dev/null +++ b/htdocs/includes/codepress/languages/xsl.css @@ -0,0 +1,15 @@ +/* + * CodePress color styles for HTML syntax highlighting + * By RJ Bruneel + */ + +b {color:#000080;} /* tags */ +ins, ins b, ins s, ins em {color:gray;} /* comments */ +s, s b {color:#7777e4;} /* attribute values */ +a {color:#E67300;} /* links */ +u {color:#CC66CC;} /* forms */ +big {color:#db0000;} /* images */ +em, em b {color:#800080;} /* style */ +strong {color:#800000;} /* script */ +tt i {color:darkblue;font-weight:bold;} /* script reserved words */ +xsl {color:green;} /* xsl */ diff --git a/htdocs/includes/codepress/languages/xsl.js b/htdocs/includes/codepress/languages/xsl.js new file mode 100644 index 00000000000..e93932a6325 --- /dev/null +++ b/htdocs/includes/codepress/languages/xsl.js @@ -0,0 +1,103 @@ +/* + * CodePress regular expressions for XSL syntax highlighting + * By RJ Bruneel + */ + +Language.syntax = [ // XSL + { + input : /(<[^!]*?>)/g, + output : '$1' // all tags + },{ + input : /(<a.*?>|<\/a>)/g, + output : '$1' // links + },{ + input : /(<img .*?>)/g, + output : '$1' // images + },{ + input : /(<\/?(button|textarea|form|input|select|option|label).*?>)/g, + output : '$1' // forms + },{ + input : /(<style.*?>)(.*?)(<\/style>)/g, + output : '$1$2$3' // style tags + },{ + input : /(<script.*?>)(.*?)(<\/script>)/g, + output : '$1$2$3' // script tags + },{ + input : /(<xsl.*?>|<\/xsl.*?>)/g, + output : '$1' // xsl + },{ + input : /=(".*?")/g, + output : '=$1' // atributes double quote + },{ + input : /=('.*?')/g, + output : '=$1' // atributes single quote + },{ + input : /(<!--.*?-->.)/g, + output : '$1' // comments + },{ + input : /\b(alert|window|document|break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, + output : '$1' // script reserved words + } +]; + +Language.snippets = [ + {input : 'aref', output : '' }, + {input : 'h1', output : '

$0

' }, + {input : 'h2', output : '

$0

' }, + {input : 'h3', output : '

$0

' }, + {input : 'h4', output : '

$0

' }, + {input : 'h5', output : '
$0
' }, + {input : 'h6', output : '
$0
' }, + {input : 'html', output : '\n\t$0\n' }, + {input : 'head', output : '\n\t\n\t$0\n\t\n' }, + {input : 'img', output : '' }, + {input : 'input', output : '' }, + {input : 'label', output : '' }, + {input : 'legend', output : '\n\t$0\n' }, + {input : 'link', output : '' }, + {input : 'base', output : '' }, + {input : 'body', output : '\n\t$0\n' }, + {input : 'css', output : '' }, + {input : 'div', output : '
\n\t$0\n
' }, + {input : 'divid', output : '
\n\t\n
' }, + {input : 'dl', output : '
\n\t
\n\t\t$0\n\t
\n\t
\n
' }, + {input : 'fieldset', output : '
\n\t$0\n
' }, + {input : 'form', output : '
\n\t\n
' }, + {input : 'meta', output : '' }, + {input : 'p', output : '

$0

' }, + {input : 'b', output : '$0' }, + {input : 'li', output : '
  • $0
  • ' }, + {input : 'ul', output : '
      $0
    ' }, + {input : 'ol', output : '
      $0
    ' }, + {input : 'strong', output : '$0' }, + {input : 'br', output : '
    ' }, + {input : 'script', output : '' }, + {input : 'scriptsrc', output : '' }, + {input : 'span', output : '$0' }, + {input : 'table', output : '\n\t\n\t\n
    ' }, + {input : 'style', output : '' }, + {input : 'xsl:stylesheet', output : '' }, + {input : 'xsl:template', output : '$0' }, + {input : 'xsl:for-each', output : '' }, + {input : 'xsl:choose', output : '$0<\xsl:choose>' }, + {input : 'xsl:param', output : '' }, + {input : 'xsl:variable', output : '' }, + {input : 'xsl:if', output : '' }, + {input : 'xsl:when', output : '' }, + {input : 'xsl:otherwise', output : '$0' }, + {input : 'xsl:attribute', output : '' }, + {input : 'xsl:value-of', output : '' }, + {input : 'xsl:with-param', output : '' }, + {input : 'xsl:call-template', output : '' } + +]; + +Language.complete = [ // Auto complete only for 1 character + {input : '\'',output : '\'$0\'' }, + {input : '"', output : '"$0"' }, + {input : '(', output : '\($0\)' }, + {input : '[', output : '\[$0\]' }, + {input : '{', output : '{\n\t$0\n}' } +]; + +Language.shortcuts = []; \ No newline at end of file diff --git a/htdocs/includes/codepress/license.txt b/htdocs/includes/codepress/license.txt new file mode 100644 index 00000000000..e80ac68d8fa --- /dev/null +++ b/htdocs/includes/codepress/license.txt @@ -0,0 +1,458 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS From 379a5b9e1694e8a5fee2153cd6641d6f82f7ce5a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 12 Jul 2017 12:35:30 +0200 Subject: [PATCH 32/90] fix : SQL migration in capital letters --- .../install/mysql/migration/5.0.0-6.0.0.sql | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 0137353f714..f6af95892d8 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -74,7 +74,7 @@ ALTER TABLE llx_holiday ADD COLUMN ref varchar(30) NULL; ALTER TABLE llx_holiday ADD COLUMN ref_ext varchar(255); -create table llx_notify_def_object +CREATE TABLE llx_notify_def_object ( id integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id @@ -129,14 +129,15 @@ ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); -- VMYSQL4.1 ALTER TABLE llx_adherent MODIFY COLUMN country integer DEFAULT NULL; -- VPGSQL8.2 ALTER TABLE llx_adherent MODIFY COLUMN country integer USING country::integer; -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expense_report',201); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expense_report',202); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expense_report',203); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expense_report',204); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expense_report',201); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expense_report',201); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expense_report',202); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expense_report',203); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expense_report',204); ALTER TABLE llx_c_email_templates ADD COLUMN content_lines text; @@ -196,7 +197,7 @@ CREATE TABLE llx_product_attribute_combination ); -ALTER TABLE llx_bank_account drop foreign key bank_fk_accountancy_journal; +ALTER TABLE llx_bank_account DROP FOREIGN KEY bank_fk_accountancy_journal; -- Fix missing entity column after init demo ALTER TABLE llx_accounting_journal ADD COLUMN entity integer DEFAULT 1; @@ -209,18 +210,18 @@ INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES ( INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Has new journal', 9, 1); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (6,'ER', 'Expense report journal', 5, 1); -- Fix old entries -UPDATE llx_accounting_journal SET nature = 1 where code = 'OD' and nature = 0; -UPDATE llx_accounting_journal SET nature = 2 where code = 'VT' and nature = 1; -UPDATE llx_accounting_journal SET nature = 3 where code = 'AC' and nature = 2; -UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') and nature = 3; +UPDATE llx_accounting_journal SET nature = 1 WHERE code = 'OD' AND nature = 0; +UPDATE llx_accounting_journal SET nature = 2 WHERE code = 'VT' AND nature = 1; +UPDATE llx_accounting_journal SET nature = 3 WHERE code = 'AC' AND nature = 2; +UPDATE llx_accounting_journal SET nature = 4 WHERE (code = 'BK' OR code = 'BQ') AND nature = 3; -UPDATE llx_bank_account as ba set accountancy_journal = 'BQ' where accountancy_journal = 'BK'; -UPDATE llx_bank_account as ba set accountancy_journal = 'OD' where accountancy_journal IS NULL; +UPDATE llx_bank_account SET accountancy_journal = 'BQ' WHERE accountancy_journal = 'BK'; +UPDATE llx_bank_account SET accountancy_journal = 'OD' WHERE accountancy_journal IS NULL; ALTER TABLE llx_bank_account ADD COLUMN fk_accountancy_journal integer; ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal); -UPDATE llx_bank_account as ba set fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal as aj where ba.accountancy_journal = aj.code) where accountancy_journal not in ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); +UPDATE llx_bank_account AS ba SET fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal AS aj WHERE ba.accountancy_journal = aj.code) WHERE accountancy_journal NOT IN ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); --Update general ledger for FEC format & harmonization @@ -233,7 +234,7 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN subledger_account varchar(32); ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN thirdparty_label subledger_label varchar(255); -- If field was already created, rename it ALTER TABLE llx_accounting_bookkeeping ADD COLUMN subledger_label varchar(255) AFTER subledger_account; -- If field dod not exists yet -update llx_accounting_bookkeeping set subledger_account = numero_compte where subledger_account IS NULL; +UPDATE llx_accounting_bookkeeping SET subledger_account = numero_compte WHERE subledger_account IS NULL; ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN label_compte varchar(255); ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_journal varchar(32); @@ -358,9 +359,9 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL; -UPDATE llx_contrat set ref = rowid where ref is null or ref = ''; +UPDATE llx_contrat SET ref = rowid WHERE ref IS NULL OR ref = ''; -create table llx_payment_various +CREATE TABLE llx_payment_various ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -381,7 +382,7 @@ create table llx_payment_various )ENGINE=innodb; -create table llx_default_values +CREATE TABLE llx_default_values ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id @@ -441,27 +442,27 @@ ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_tms (tms); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_datec (datec); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); +INSERT INTO llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) VALUES (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); +INSERT INTO llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) VALUES (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); +INSERT INTO llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) VALUES (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); +INSERT INTO llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) VALUES (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); ALTER TABLE llx_facture ADD COLUMN fk_fac_rec_source integer; -DELETE from llx_c_actioncomm where code in ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm); +DELETE FROM llx_c_actioncomm WHERE code IN ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm); -- Fix: delete orphelin category. -delete from llx_categorie_product where fk_categorie not in (select rowid from llx_categorie where type = 0); -delete from llx_categorie_societe where fk_categorie not in (select rowid from llx_categorie where type in (1, 2)); -delete from llx_categorie_member where fk_categorie not in (select rowid from llx_categorie where type = 3); -delete from llx_categorie_contact where fk_categorie not in (select rowid from llx_categorie where type = 4); -delete from llx_categorie_project where fk_categorie not in (select rowid from llx_categorie where type = 5); +DELETE FROM llx_categorie_product WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type = 0); +DELETE FROM llx_categorie_societe WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type IN (1, 2)); +DELETE FROM llx_categorie_member WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type = 3); +DELETE FROM llx_categorie_contact WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type = 4); +DELETE FROM llx_categorie_project WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type = 5); ALTER TABLE llx_inventory ADD COLUMN ref varchar(48); -create table llx_loan_schedule +CREATE TABLE llx_loan_schedule ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_loan integer, From 33ceb22b8b814aca7a43616bb801f29692bf0f98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Jul 2017 13:25:18 +0200 Subject: [PATCH 33/90] Fix error management into modulebuilder --- htdocs/core/class/commonobject.class.php | 357 +++++++++++------ htdocs/core/lib/modulebuilder.lib.php | 114 +++--- htdocs/langs/en_US/main.lang | 1 + .../template/class/myobject.class.php | 364 +----------------- .../modulebuilder/template/myobject_card.php | 84 ++-- .../modulebuilder/template/myobject_list.php | 46 +-- 6 files changed, 372 insertions(+), 594 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 96de26be956..7917234158e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -599,7 +599,7 @@ abstract class CommonObject } $datecreate = dol_now(); - + // Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error $TListeContacts=$this->liste_contact(-1, $source); $already_added=false; @@ -611,11 +611,11 @@ abstract class CommonObject } } } - + if(!$already_added) { - + $this->db->begin(); - + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; @@ -623,7 +623,7 @@ abstract class CommonObject $sql.= "'".$this->db->idate($datecreate)."'"; $sql.= ", 4, ". $id_type_contact; $sql.= ")"; - + $resql=$this->db->query($sql); if ($resql) { @@ -636,7 +636,7 @@ abstract class CommonObject return -1; } } - + $this->db->commit(); return 1; } @@ -4726,6 +4726,9 @@ abstract class CommonObject return $buyPrice; } + + + /** * Function test if type is date * @@ -4734,7 +4737,7 @@ abstract class CommonObject */ protected function isDate($info) { - if(isset($info['type']) && $info['type']=='date') return true; + if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; else return false; } @@ -4880,40 +4883,6 @@ abstract class CommonObject return $query; } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, Id of created object if OK - */ - public function createCommon(User $user, $notrigger = false) - { - - $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); - - foreach ($fields as $k => $v) { - - $keys[] = $k; - $values[] = $this->quote($v); - - } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' - ( '.implode( ",", $keys ).' ) - VALUES ( '.implode( ",", $values ).' ) '; - $res = $this->db->query( $sql ); - if($res===false) { - - return false; - } - - // TODO Add triggers - - return true; - - } - /** * Function to load data into current object this * @@ -4921,39 +4890,39 @@ abstract class CommonObject */ private function set_vars_by_db(&$obj) { - foreach ($this->fields as $field => $info) - { - if($this->isDate($info)) - { - if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; - else $this->{$field} = strtotime($obj->{$field}); - } - elseif($this->isArray($info)) - { - $this->{$field} = @unserialize($obj->{$field}); - // Hack for data not in UTF8 - if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); - } - elseif($this->isInt($info)) - { - $this->{$field} = (int) $obj->{$field}; - } - elseif($this->isFloat($info)) - { - $this->{$field} = (double) $obj->{$field}; - } - elseif($this->isNull($info)) - { - $val = $obj->{$field}; - // zero is not null - $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); - } - else - { - $this->{$field} = $obj->{$field}; - } + foreach ($this->fields as $field => $info) + { + if($this->isDate($info)) + { + if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; + else $this->{$field} = strtotime($obj->{$field}); + } + elseif($this->isArray($info)) + { + $this->{$field} = @unserialize($obj->{$field}); + // Hack for data not in UTF8 + if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); + } + elseif($this->isInt($info)) + { + $this->{$field} = (int) $obj->{$field}; + } + elseif($this->isFloat($info)) + { + $this->{$field} = (double) $obj->{$field}; + } + elseif($this->isNull($info)) + { + $val = $obj->{$field}; + // zero is not null + $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); + } + else + { + $this->{$field} = $obj->{$field}; + } - } + } } /** @@ -4963,21 +4932,134 @@ abstract class CommonObject */ private function get_field_list() { - $keys = array_keys($this->fields); - return implode(',', $keys); + $keys = array_keys($this->fields); + return implode(',', $keys); + } + + /** + * Add quote to field value if necessary + * + * @param string|int $value value to protect + * @return string|int + */ + protected function quote($value) { + + if(is_null($value)) return 'NULL'; + else if(is_numeric($value)) return $value; + else return "'".$this->db->escape( $value )."'"; + + } + + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function createCommon(User $user, $notrigger = false) + { + $error = 0; + + $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); + + foreach ($fields as $k => $v) { + $keys[] = $k; + $values[] = $this->quote($v); + } + + $this->db->begin(); + + if (! $error) + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' + ( '.implode( ",", $keys ).' ) + VALUES ( '.implode( ",", $values ).' ) '; + $res = $this->db->query( $sql ); + if ($res===false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + if (! $error && ! $notrigger) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromCloneCommon(User $user, $fromid) + { + global $user; + + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->createCommon($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + return $object->id; + } else { + $this->db->rollback(); + return -1; + } } /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetchCommon($id, $ref = null) { - if (empty($id) && empty($ref)) return false; $sql = 'SELECT '.$this->get_field_list().', datec, tms'; @@ -4991,13 +5073,20 @@ abstract class CommonObject { if ($obj = $this->db->fetch_object($res)) { - $this->id = $id; - $this->set_vars_by_db($obj); + if ($obj) + { + $this->id = $id; + $this->set_vars_by_db($obj); - $this->datec = $this->db->idate($obj->datec); - $this->tms = $this->db->idate($obj->tms); + $this->datec = $this->db->idate($obj->datec); + $this->tms = $this->db->idate($obj->tms); - return $this->id; + return $this->id; + } + else + { + return 0; + } } else { @@ -5019,15 +5108,15 @@ abstract class CommonObject * * @param User $user User that modifies * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function updateCommon(User $user, $notrigger = false) { + $error = 0; + $fields = $this->set_save_query(); foreach ($fields as $k => $v) { - if (is_array($key)){ $i=array_search($k, $key); if ( $i !== false) { @@ -5040,57 +5129,93 @@ abstract class CommonObject continue; } } - $tmp[] = $k.'='.$this->quote($v); } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ; - $res = $this->db->query( $sql ); - if($res===false) { - //error - return false; + $this->db->begin(); + + if (! $error) + { + $res = $this->db->query($sql); + if ($res===false) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } } - // TODO Add triggers + if (! $error && ! $notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_MODIFY',$user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } - return true; + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } } /** * Delete object in database * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK */ public function deleteCommon(User $user, $notrigger = false) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + $error=0; - $res = $this->db->query( $sql ); - if($res===false) { - return false; + $this->db->begin(); + + if (! $error) { + if (! $notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } + + if (! $error) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + + $res = $this->db->query($sql); + if($res===false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; } - - // TODO Add triggers - - return true; } /** - * Add quote to field value if necessary + * Initialise object with example values + * Id must be 0 if object instance is a specimen * - * @param string|int $value value to protect - * @return string|int + * @return void */ - protected function quote($value) { - - if(is_null($value)) return 'NULL'; - else if(is_numeric($value)) return $value; - else return "'".$this->db->escape( $value )."'"; + public function initAsSpecimenCommon() + { + $this->id = 0; + // TODO... } } - diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 7c14f139c59..cb5d143cff9 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -55,67 +55,69 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask) { include_once $pathoffiletoeditsrc; if (class_exists($objectname)) $object=new $objectname($db); + + // Backup old file + dol_copy($pathoffiletoeditsrc, $pathoffiletoeditsrc.'.back', $newmask, 1); + + // Edit class files + $contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r'); + + $i=0; + $texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n"; + $texttoinsert.= "\t".'/**'."\n"; + $texttoinsert.= "\t".' * @var array Array with all fields and their property'."\n"; + $texttoinsert.= "\t".' */'."\n"; + $texttoinsert.= "\t".'public $fields=array('."\n"; + + if (count($object->fields)) + { + foreach($object->fields as $key => $val) + { + $i++; + $typephp=''; + $texttoinsert.= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; + if ($val['position']) $texttoinsert.= " 'position'=>".$val['position'].","; + if ($val['notnull']) $texttoinsert.= " 'notnull'=>".$val['notnull'].","; + if ($val['index']) $texttoinsert.= " 'index'=>".$val['index'].","; + if ($val['searchall']) $texttoinsert.= " 'searchall'=>".$val['searchall'].","; + if ($val['comment']) $texttoinsert.= " 'comment'=>'".$val['comment']."',"; + $texttoinsert.= "),\n"; + } + } + $texttoinsert.= "\t".');'."\n"; + + $texttoinsert.= "\n"; + + if (count($object->fields)) + { + foreach($object->fields as $key => $val) + { + $i++; + $typephp=''; + $texttoinsert.= "\t".'public $'.$key.$typephp.";"; + //if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; + //if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; + //$texttoinsert.= ($val['notnull']?' NOT NULL':''); + //if ($i < count($object->fields)) $texttoinsert.=";"; + $texttoinsert.= "\n"; + } + } + + $texttoinsert.= "\t".'// END MODULEBUILDER PROPERTIES'; + + $contentclass = preg_replace('/\/\/ BEGIN MODULEBUILDER PROPERTIES.*END MODULEBUILDER PROPERTIES/ims', $texttoinsert, $contentclass); + + //file_put_contents($pathoffiletoedittmp, $contentclass); + file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass); + @chmod($pathoffiletoedit, octdec($newmask)); + + return 1; } catch(Exception $e) { print $e->getMessage(); + return -1; } - - // Edit class files - - $contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r'); - - $i=0; - $texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n"; - $texttoinsert.= "\t".'/**'."\n"; - $texttoinsert.= "\t".' * @var array Array with all fields and their property'."\n"; - $texttoinsert.= "\t".' */'."\n"; - $texttoinsert.= "\t".'public $fields=array('."\n"; - - if (count($object->fields)) - { - foreach($object->fields as $key => $val) - { - $i++; - $typephp=''; - $texttoinsert.= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; - if ($val['position']) $texttoinsert.= " 'position'=>".$val['position'].","; - if ($val['notnull']) $texttoinsert.= " 'notnull'=>".$val['notnull'].","; - if ($val['index']) $texttoinsert.= " 'index'=>".$val['index'].","; - if ($val['searchall']) $texttoinsert.= " 'searchall'=>".$val['searchall'].","; - if ($val['comment']) $texttoinsert.= " 'comment'=>'".$val['comment']."',"; - $texttoinsert.= "),\n"; - } - } - $texttoinsert.= "\t".');'."\n"; - - $texttoinsert.= "\n"; - - if (count($object->fields)) - { - foreach($object->fields as $key => $val) - { - $i++; - $typephp=''; - $texttoinsert.= "\t".'public $'.$key.$typephp.";"; - //if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; - //if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; - //$texttoinsert.= ($val['notnull']?' NOT NULL':''); - //if ($i < count($object->fields)) $texttoinsert.=";"; - $texttoinsert.= "\n"; - } - } - - $texttoinsert.= "\t".'// END MODULEBUILDER PROPERTIES'; - - $contentclass = preg_replace('/\/\/ BEGIN MODULEBUILDER PROPERTIES.*END MODULEBUILDER PROPERTIES/ims', $texttoinsert, $contentclass); - - //file_put_contents($pathoffiletoedittmp, $contentclass); - file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass); - @chmod($pathoffiletoedit, octdec($newmask)); - - - return 1; } /** diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 9251db5311f..88b9d2a3fb0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -197,6 +197,7 @@ Parameter=Parameter Parameters=Parameters Value=Value PersonalValue=Personal value +NewObject=New %s NewValue=New value CurrentValue=Current value Code=Code diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 6f55f2c9ef6..f8882b68c56 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -109,366 +109,6 @@ class MyObject extends CommonObject $this->db = $db; } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - // Clean parameters - if (isset($this->prop1)) { - $this->prop1 = trim($this->prop1); - } - if (isset($this->prop2)) { - $this->prop2 = trim($this->prop2); - } - //... - - // Check parameters - // Put here code to add control on parameters values - - // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql .= ' field1,'; - $sql .= ' field2'; - //... - $sql .= ') VALUES ('; - $sql .= ' \'' . $this->prop1 . '\','; - $sql .= ' \'' . $this->prop2 . '\''; - //... - $sql .= ')'; - - $this->db->begin(); - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action to call a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) $error++; - //// End call triggers - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return $this->id; - } - } - - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= ' t.field1,'; - $sql .= ' t.field2'; - //... - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - $sql.= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity('mymoduleobject') . ")"; - } - if (null !== $ref) { - $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; - } else { - $sql .= ' AND t.rowid = ' . $id; - } - - $resql = $this->db->query($sql); - if ($resql) { - $numrows = $this->db->num_rows($resql); - if ($numrows) { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->prop1 = $obj->field1; - $this->prop2 = $obj->field2; - //... - } - - $this->db->free($resql); - - $this->fetch_optionals(); - - // $this->fetch_lines(); - - if ($numrows) { - return 1; - } else { - return 0; - } - } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - return - 1; - } - } - - /** - * Load object in memory from the database - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * - * @return int <0 if KO, >0 if OK - */ - public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= ' t.field1,'; - $sql .= ' t.field2'; - //... - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; - } - } - $sql.= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity('mymoduleobject') . ")"; - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); - } - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield,$sortorder); - } - if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - - while ($obj = $this->db->fetch_object($resql)) { - $line = new self($this->db); - - $line->id = $obj->rowid; - $line->prop1 = $obj->field1; - $line->prop2 = $obj->field2; - //... - } - $this->db->free($resql); - - return $num; - } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - - return - 1; - } - } - - /** - * Update object into database - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - // Clean parameters - if (isset($this->prop1)) { - $this->prop1 = trim($this->prop1); - } - if (isset($this->prop2)) { - $this->prop2 = trim($this->prop2); - } - //... - - // Check parameters - // Put here code to add a control on parameters values - - // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= " field1=".(isset($this->field1)?"'".$this->db->escape($this->field1)."'":"null").","; - $sql .= " field2=".(isset($this->field2)?"'".$this->db->escape($this->field2)."'":"null").""; - //... - $sql .= ' WHERE rowid=' . $this->id; - - $this->db->begin(); - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - if (!$error && !$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return 1; - } - } - - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - $this->db->begin(); - - if (!$error) { - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_DELETE',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } - } - - // If you need to delete child tables to, you can insert them here - - if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; - $sql .= ' WHERE rowid=' . $this->id; - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return 1; - } - } - - /** - * Load an object from its id and create a new one in database - * - * @param int $fromid Id of object to clone - * - * @return int New id of clone - */ - public function createFromClone($fromid) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - global $user; - $error = 0; - $object = new self($this->db); - - $this->db->begin(); - - // Load source object - $object->fetch($fromid); - // Reset object - $object->id = 0; - - // Clear fields - // ... - - // Create clone - $result = $object->create($user); - - // Other options - if ($result < 0) { - $error ++; - $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - // End - if (!$error) { - $this->db->commit(); - - return $object->id; - } else { - $this->db->rollback(); - - return - 1; - } - } /** * Return a link to the object card (with optionaly the picto) @@ -592,9 +232,7 @@ class MyObject extends CommonObject */ public function initAsSpecimen() { - $this->id = 0; - $this->prop1 = 'prop1'; - $this->prop2 = 'prop2'; + $this->initAsSpecimenCommon(); } } diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 73f00abc89f..14b88767128 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -58,14 +58,27 @@ dol_include_once('/mymodule/class/myobject.class.php'); $langs->loadLangs(array("mymodule","other")); // Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); -$cancel = GETPOST('cancel'); -$backtopage = GETPOST('backtopage'); -$myparam = GETPOST('myparam','alpha'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); -$search_field1=GETPOST("search_field1"); -$search_field2=GETPOST("search_field2"); +// Initialize technical objects +$object=new MyObject($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('myobject'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} if (empty($action) && empty($id) && empty($ref)) $action='view'; @@ -76,19 +89,12 @@ if ($user->societe_id > 0) } //$result = restrictedArea($user, 'mymodule', $id); - -$object = new MyObject_Class($db); -$extrafields = new ExtraFields($db); - // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('mymodule')); - /* @@ -107,7 +113,7 @@ if (empty($reshook)) { if ($action != 'addlink') { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); header("Location: ".$urltogo); exit; } @@ -120,33 +126,35 @@ if (empty($reshook)) { if ($cancel) { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); header("Location: ".$urltogo); exit; } $error=0; - /* object_prop_getpost_prop */ - $object->prop1=GETPOST("field1"); - $object->prop2=GETPOST("field2"); - - if (empty($object->ref)) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors'); - } + foreach ($object->fields as $key => $val) + { + $object->$key=GETPOST($key,'alpha'); + if (in_array($key, array('entity', 'datec', 'tms'))) continue; + if ($val['notnull'] && $object->$key == '') + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); + } + } if (! $error) { - $result=$object->create($user); + $result=$object->createCommon($user); if ($result > 0) { // Creation OK - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); header("Location: ".$urltogo); exit; } + else { // Creation KO if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); @@ -203,7 +211,7 @@ if (empty($reshook)) { // Delete OK setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".dol_buildpath('/mymodule/list.php',1)); + header("Location: ".dol_buildpath('/mymodule/myobject_list.php',1)); exit; } else @@ -225,10 +233,7 @@ if (empty($reshook)) $form=new Form($db); -llxHeader('','MyPageName',''); - - -// Put here content of your page +llxHeader('','MyObject',''); // Example : Adding jquery code print ''."\n"; + } + print '
    '; print ''; print ''; @@ -353,7 +427,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; dol_fiche_head(null); - + print ''; print '
    '.$langs->trans('Company').''; @@ -384,7 +458,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
    '; dol_fiche_end(); - + $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; @@ -408,6 +482,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $num = $db->num_rows($resql); if ($num > 0) { + $sign=1; + if ($object->type == 2) $sign=-1; + $i = 0; print '
    '; @@ -447,19 +524,37 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie while ($i < $num) { $objp = $db->fetch_object($resql); - + + $invoice=new FactureFournisseur($db); + $invoice->fetch($objp->facid); + $paiement = $invoice->getSommePaiement(); + $creditnotes=$invoice->getSumCreditNotesUsed(); + $deposits=$invoice->getSumDepositsUsed(); + $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); + $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); + + // Multicurrency Price + if (!empty($conf->multicurrency->enabled)) + { + $multicurrency_payment = $invoice->getSommePaiement(1); + $multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1); + $multicurrency_deposits=$invoice->getSumDepositsUsed(1); + $multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,'MT'); + $multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,'MT'); + } + print ''; - + // Ref print ''; $invoicesupplierstatic->ref=$objp->ref; $invoicesupplierstatic->id=$objp->facid; print $invoicesupplierstatic->getNomUrl(1); print ''; - + // Ref supplier print ''.$objp->ref_supplier.''; - + // Date if ($objp->df > 0 ) { @@ -470,13 +565,13 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { print '!!!'; } - + // Multicurrency - if (!empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Currency print ''.$objp->multicurrency_code."\n"; - + print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { @@ -485,14 +580,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { print price($objp->multicurrency_am); } print ''; - + print ''; - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { print price($objp->multicurrency_total_ttc - $objp->multicurrency_am); } @@ -500,32 +595,58 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ''.price($objp->total_ttc).''; - + print ''.price($objp->am).''; - - print ''.price($objp->total_ttc - $objp->am).''; - + + print ''.price($remaintopay).''; + + // Amount print ''; + $namef = 'amount_'.$objp->facid; - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->total_ttc - $objp->am)."'"); - print ''; + $nameRemain = 'remain_'.$objp->facid; + + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); + print ''; + print ''; + } + else + { + print ''; + print ''; + } print ""; - - // Multicurrency - if (!empty($conf->multicurrency->enabled)) + + // Multicurrency Price + if (! empty($conf->multicurrency->enabled)) { - print ''; + print ''; + + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - $namef = 'multicurrency_amount_'.$objp->facid; - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->multicurrency_total_ttc - $objp->multicurrency_am)."'"); - print ''; + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print ''; + print ''; + } + else + { + print ''; + print ''; + } } - print ""; + print ""; } - + print "\n"; $total+=$objp->total_ht; $total_ttc+=$objp->total_ttc; @@ -544,12 +665,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.price($total_ttc).''; print ''.price($totalrecu).''; print ''.price($total_ttc - $totalrecu).''; - print ' '; - if (!empty($conf->multicurrency->enabled)) print ' '; + print ''; // Autofilled + if (!empty($conf->multicurrency->enabled)) print ''; print "\n"; } print "\n"; - + print ""; } $db->free($resql); @@ -574,7 +695,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
    '; if (!empty($totalpayment)) $text=$langs->trans('ConfirmSupplierPayment',price($totalpayment),$langs->trans("Currency".$conf->currency)); - if (!empty($multicurrency_totalpayment)) + if (!empty($multicurrency_totalpayment)) { $text.='
    '.$langs->trans('ConfirmSupplierPayment',price($multicurrency_totalpayment),$langs->trans("paymentInInvoiceCurrency")); } @@ -589,7 +710,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
    '; } } - else dol_print_error($db); + else dol_print_error($db); } /* @@ -635,14 +756,14 @@ if (empty($action)) $sql.= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label"; if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= $db->order($sortfield,$sortorder); - + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - + $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); @@ -667,9 +788,9 @@ if (empty($action)) $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } - + $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - + print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); print '
    '; @@ -680,24 +801,24 @@ if (empty($action)) print ''; print ''; print ''; - + $moreforfilter=''; - + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if ($moreforfilter) { print '
    '; print $moreforfilter; print '
    '; } - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
    '; print ''."\n"; @@ -739,11 +860,11 @@ if (empty($action)) //print_liste_field_titre($langs->trans('Invoice'),$_SERVER["PHP_SELF"],'ref_supplier','',$param,'',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; - + while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - + print ''; // Ref payment @@ -764,7 +885,7 @@ if (empty($action)) // Payment number print ''; - + print ''; } + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['b.num_releve']['checked'])) From cb87b314be0cc5753257e2a19ac7fe5de913664d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Jul 2017 03:41:07 +0200 Subject: [PATCH 78/90] FIX Maxi debug of journalization of bank journal. --- .../accountancy/class/bookkeeping.class.php | 2 +- htdocs/accountancy/journal/bankjournal.php | 285 ++++++++++++------ .../journal/expensereportsjournal.php | 12 +- .../accountancy/journal/purchasesjournal.php | 16 +- htdocs/accountancy/journal/sellsjournal.php | 17 +- htdocs/compta/bank/bankentries.php | 110 +++++-- htdocs/compta/bank/class/account.class.php | 58 ++-- .../bank/class/paymentvarious.class.php | 11 +- htdocs/compta/bank/various_payment/card.php | 214 +++++++------ htdocs/compta/bank/various_payment/index.php | 23 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 + htdocs/install/mysql/tables/llx_bank.sql | 1 + htdocs/langs/en_US/accountancy.lang | 8 +- htdocs/langs/en_US/banks.lang | 6 +- htdocs/langs/en_US/compta.lang | 4 +- htdocs/langs/en_US/salaries.lang | 2 +- .../modulebuilder/template/myobject_card.php | 5 +- 17 files changed, 493 insertions(+), 283 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 5c5fb022de9..9970e4672ac 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -176,7 +176,7 @@ class BookKeeping extends CommonObject if (empty($this->credit)) $this->credit = 0; // Check parameters - if (empty($this->numero_compte) || $this->numero_compte == '-1') + if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') { $langs->load("errors"); if (in_array($this->doc_type, array('bank', 'expense_report'))) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 14307185ac6..648abc4d14c 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -52,16 +52,7 @@ require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php'; -$langs->load("companies"); -$langs->load("other"); -$langs->load("compta"); -$langs->load("banks"); -$langs->load('bills'); -$langs->load('donations'); -$langs->load("accountancy"); -$langs->load("trips"); -$langs->load("salaries"); -$langs->load("hrm"); +$langs->loadLangs(array("companies","other","compta","banks",'bills','donations',"accountancy","trips","salaries","hrm")); // Multi journal $id_journal = GETPOST('id_journal', 'int'); @@ -73,6 +64,7 @@ $date_endmonth = GETPOST('date_endmonth'); $date_endday = GETPOST('date_endday'); $date_endyear = GETPOST('date_endyear'); $in_bookkeeping = GETPOST('in_bookkeeping'); +if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; $now = dol_now(); $action = GETPOST('action','aZ09'); @@ -118,10 +110,12 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.row $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; $sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal; -$sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy +$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy if ($date_start && $date_end) $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; -if ($in_bookkeeping == 'yes') +if ($in_bookkeeping == 'already') + $sql .= " AND (b.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; +if ($in_bookkeeping == 'notyet') $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )"; $sql .= " ORDER BY b.datev"; @@ -150,12 +144,12 @@ if ($result) { $num = $db->num_rows($result); // Variables - $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); - $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); - $account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef")); - $account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : $langs->trans("CodeNotDef")); - $account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef")); - $account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : $langs->trans("CodeNotDef")); + $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word + $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word + $account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word + $account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word + $account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word + $account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : 'NotDefined'); // NotDefined is a reserved word $tabcompany = array(); $tabuser = array(); @@ -198,7 +192,7 @@ if ($result) { // Variable bookkeeping $tabpay[$obj->rowid]["date"] = $obj->do; - $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; + $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ... $tabpay[$obj->rowid]["ref"] = $obj->label; $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) { @@ -208,14 +202,20 @@ if ($result) { } $links = $object->get_url($obj->rowid); - // get_url may return -1 which is not traversable - if (is_array($links)) { - // Now loop on each link of record in bank. - foreach ( $links as $key => $val ) { + /*var_dump($i); + var_dump($links);*/ - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary', 'payment_various'))) // So we excluded 'company' here + // get_url may return -1 which is not traversable + if (is_array($links) && count($links) > 0) { + // Now loop on each link of record in bank. + foreach ($links as $key => $val) { + + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary', 'payment_various'))) { + // So we excluded 'company' and 'user' here. We want only payment lines + // We save tabtype for a future use, to remember what kind of payment it is + $tabpay[$obj->rowid]['type'] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type']; } @@ -236,7 +236,8 @@ if ($result) { } else if ($links[$key]['type'] == 'user') { $userstatic->id = $links[$key]['url_id']; $userstatic->name = $links[$key]['label']; - $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); + if ($userstatic->id > 0) $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30); + else $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. $tabtp[$obj->rowid][$compta_user] += $obj->amount; } else if ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; @@ -297,7 +298,7 @@ if ($result) { $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; $paymentvariousstatic->fetch($paymentvariousstatic->id); - $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : $langs->trans("CodeNotDef")); + $account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word $tabtp[$obj->rowid][$account_various] += $obj->amount; } else if ($links[$key]['type'] == 'banktransfert') { $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer"); @@ -305,10 +306,13 @@ if ($result) { } } } + else + { + $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or old record with no links in bank_url. + } $tabbq[$obj->rowid][$compta_bank] += $obj->amount; - // Check account number is ok /*if ($action == 'writebookkeeping') // Make test now in such a case { @@ -330,7 +334,7 @@ if ($result) { // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; - $i ++; + $i++; } } else { dol_print_error($db); @@ -354,7 +358,7 @@ if (! $error && $action == 'writebookkeeping') { $db->begin(); // Bank - if (! $errorforline) + if (! $errorforline && is_array($tabbq[$key])) { // Line into bank account foreach ( $tabbq[$key] as $k => $mt ) @@ -419,19 +423,23 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } + } else if ($tabtype[$key] == 'payment_salary') { + $bookkeeping->subledger_account = ''; + $bookkeeping->label_operation = $tabuser[$key]['name']; + $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment } else if ($tabtype[$key] == 'payment_vat') { $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment } else if ($tabtype[$key] == 'payment_donation') { $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation - } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->subledger_account = ''; - $bookkeeping->label_operation = $tabuser[$key]['name']; - $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment } else if ($tabtype[$key] == 'payment_various') { $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Ref of various payment + } else if ($tabtype[$key] == 'unknown') { + // ??? + $bookkeeping->subledger_account = ''; + $bookkeeping->doc_ref = ''; } $result = $bookkeeping->create($user); @@ -440,7 +448,7 @@ if (! $error && $action == 'writebookkeeping') { { $error++; $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { @@ -454,7 +462,7 @@ if (! $error && $action == 'writebookkeeping') { } // Third party - if (! $errorforline) + if (! $errorforline && is_array($tabtp[$key])) { // Line into thirdparty account foreach ( $tabtp[$key] as $k => $mt ) { @@ -475,22 +483,11 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_create = $now; - if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution - $sqlmid = 'SELECT ch.libelle, t.libelle as labelc'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "chargesociales ch "; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paych ON paych.fk_charge=ch.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "c_chargesociales as t ON ch.fk_type=t.id"; - $sqlmid .= " WHERE paych.fk_bank=" . $key; - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $bookkeeping->label_compte = $objmid->labelc; - $bookkeeping->doc_ref = $objmid->libelle ; - } - $bookkeeping->subledger_account = ''; - $bookkeeping->numero_compte = $k; - } else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice + if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice + $bookkeeping->label_operation = ''; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -500,12 +497,14 @@ if (! $error && $action == 'writebookkeeping') { $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); + $bookkeeping->label_compte = ''; $bookkeeping->doc_ref = $objmid->facnumber; } + } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice + $bookkeeping->label_operation = ''; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -515,16 +514,14 @@ if (! $error && $action == 'writebookkeeping') { $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); + $bookkeeping->label_compte = ''; $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; } - $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; - $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; } else if ($tabtype[$key] == 'payment_expensereport') { + $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->label_operation = $tabuser[$key]['name']; $sqlmid = 'SELECT e.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid"; @@ -533,32 +530,69 @@ if (! $error && $action == 'writebookkeeping') { $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); + $bookkeeping->label_compte = ''; $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } - } else if ($tabtype[$key] == 'payment_vat') { + } else if ($tabtype[$key] == 'payment_salary') { + $bookkeeping->label_operation = $tabuser[$key]['name']; + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_compte = ''; + $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment + } else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution + $bookkeeping->label_operation = ''; $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; + $sqlmid = 'SELECT ch.libelle, t.libelle as labelc'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "chargesociales ch "; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paych ON paych.fk_charge=ch.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "c_chargesociales as t ON ch.fk_type=t.id"; + $sqlmid .= " WHERE paych.fk_bank=" . $key; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->label_compte = $objmid->labelc; + $bookkeeping->doc_ref = $objmid->libelle ; + } + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->label_operation = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat } else if ($tabtype[$key] == 'payment_donation') { + $bookkeeping->label_operation = ''; $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation - } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; - $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; - $bookkeeping->label_operation = $tabuser[$key]['name']; - $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment } else if ($tabtype[$key] == 'payment_various') { + $bookkeeping->label_operation = ''; $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; $bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Rowid of various payment } else if ($tabtype[$key] == 'banktransfert') { + $bookkeeping->label_operation = ''; $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = ''; + $bookkeeping->doc_ref = ''; } else { // Temporary account - $bookkeeping->doc_ref = $k; + $bookkeeping->label_operation = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; + $bookkeeping->label_compte = ''; + $bookkeeping->doc_ref = $k; } $result = $bookkeeping->create($user); @@ -567,7 +601,7 @@ if (! $error && $action == 'writebookkeeping') { { $error++; $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { @@ -586,11 +620,13 @@ if (! $error && $action == 'writebookkeeping') { } else { + //print 'KO for line '.$key.' '.$error.'
    '; $db->rollback(); - if ($error >= 10) + $MAXNBERRORS=5; + if ($error >= $MAXNBERRORS) { - setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); break; // Break in the foreach } } @@ -612,7 +648,7 @@ if (! $error && $action == 'writebookkeeping') { } // Export -if ($action == 'exportcsv') { +if ($action == 'exportcsv') { // ISO and not UTF8 ! $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; @@ -673,7 +709,6 @@ if ($action == 'exportcsv') { print '"' . $date . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - if ($tabtype[$key] == 'payment_supplier') { print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; } else if($tabtype[$key] == 'payment') { @@ -681,9 +716,6 @@ if ($action == 'exportcsv') { } else { print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; } - - - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; if ($companystatic->name == '') { print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep; @@ -699,7 +731,7 @@ if ($action == 'exportcsv') { foreach ( $tabbq[$key] as $k => $mt ) { print '"' . $journal . '"' . $sep; print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; + print '"' . $val["type_payment"] . '"' . $sep; print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; print " " . $sep; @@ -738,7 +770,9 @@ if (empty($action) || $action == 'view') { $builddate = time(); //$description = $langs->trans("DescFinanceJournal") . '
    '; $description.= $langs->trans("DescJournalOnlyBindedVisible").'
    '; - $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0); + + $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal=' . $id_journal; @@ -750,6 +784,15 @@ if (empty($action) || $action == 'view') { print ''; }*/ + // Button to write into Ledger + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' + || empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1' + || empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + } + + print '
    '; print ''; print ''; @@ -784,6 +827,7 @@ if (empty($action) || $action == 'view') { print "
    "; print ""; print ""; + print ""; print ""; print ""; print ""; @@ -861,6 +905,20 @@ if (empty($action) || $action == 'view') { } else dol_print_error($db); } + elseif ($tabtype[$key] == 'payment_salary') + { + $sqlmid = 'SELECT s.rowid as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; + $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $salarystatic->fetch($objmid->id); + $ref=$langs->trans("SalaryPayment").' '.$salarystatic->getNomUrl(1); + } + else dol_print_error($db); + } elseif ($tabtype[$key] == 'payment_vat') { $sqlmid = 'SELECT v.rowid as id'; @@ -889,20 +947,6 @@ if (empty($action) || $action == 'view') { } else dol_print_error($db); } - elseif ($tabtype[$key] == 'payment_salary') - { - $sqlmid = 'SELECT s.rowid as id'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; - $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $salarystatic->fetch($objmid->id); - $ref=$langs->trans("SalaryPayment").' '.$salarystatic->getNomUrl(1); - } - else dol_print_error($db); - } elseif ($tabtype[$key] == 'payment_various') { $sqlmid = 'SELECT v.rowid as id'; @@ -928,18 +972,28 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; + // Ledger account print ""; + // Subledger account + print ""; if ($val['soclib'] == '') { - print ""; + print ""; } else { - print ""; + print ""; } print ""; print ""; @@ -955,13 +1009,36 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; + // Ledger account print ""; + // Subledger account + print ""; print ""; print ""; @@ -976,15 +1053,25 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; + // Ledger account print ""; + // Subledger account + print ""; print ""; - print ""; + print ""; print ""; print ""; print ""; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index e0341b5fa9c..0002bca413f 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -53,6 +53,7 @@ $date_endmonth = GETPOST('date_endmonth'); $date_endday = GETPOST('date_endday'); $date_endyear = GETPOST('date_endyear'); $in_bookkeeping = GETPOST('in_bookkeeping'); +if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; $now = dol_now(); @@ -105,7 +106,9 @@ $sql .= " AND erd.fk_code_ventilation > 0"; $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy if ($date_start && $date_end) $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; -if ($in_bookkeeping == 'yes') +if ($in_bookkeeping == 'already') + $sql .= " AND er.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; +if ($in_bookkeeping == 'notyet') $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; $sql .= " ORDER BY er.date_debut"; @@ -115,8 +118,8 @@ if ($result) { $num = $db->num_rows($result); // Variables - $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"); - $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); + $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'; + $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; $taber = array (); $tabht = array (); @@ -469,7 +472,8 @@ if (empty($action) || $action == 'view') { $builddate = time(); $description.= $langs->trans("DescJournalOnlyBindedVisible").'
    '; - $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0); + $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal=' . $id_journal; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index c4091018f16..4ef04f9f23f 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -52,6 +52,7 @@ $date_endmonth = GETPOST('date_endmonth'); $date_endday = GETPOST('date_endday'); $date_endyear = GETPOST('date_endyear'); $in_bookkeeping = GETPOST('in_bookkeeping'); +if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; $now = dol_now(); @@ -109,7 +110,9 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; -if ($in_bookkeeping == 'yes') +if ($in_bookkeeping == 'already') + $sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; +if ($in_bookkeeping == 'notyet') $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; $sql .= " ORDER BY f.datef"; @@ -119,8 +122,8 @@ if ($result) { $num = $db->num_rows($result); // Variables - $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); + $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'; + $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; $tabfac = array (); $tabht = array (); @@ -139,9 +142,9 @@ if ($result) { $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) - $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); + $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; else - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); + $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; } $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); @@ -489,7 +492,8 @@ if (empty($action) || $action == 'view') { $description .= $langs->trans("DepositsAreIncluded"); } - $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0); + $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal=' . $id_journal; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 59b4a82cbde..3b0fd3abfce 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -56,6 +56,7 @@ $date_endmonth = GETPOST('date_endmonth'); $date_endday = GETPOST('date_endday'); $date_endyear = GETPOST('date_endyear'); $in_bookkeeping = GETPOST('in_bookkeeping'); +if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; $now = dol_now(); @@ -115,7 +116,9 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; -if ($in_bookkeeping == 'yes') +if ($in_bookkeeping == 'already') + $sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; +if ($in_bookkeeping == 'notyet') $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; $sql .= " ORDER BY f.datef"; @@ -132,8 +135,8 @@ if ($result) { $num = $db->num_rows($result); // Variables - $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'; + $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined'; $i = 0; while ( $i < $num ) { @@ -145,9 +148,9 @@ if ($result) { $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) - $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; else - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; } $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); @@ -506,7 +509,9 @@ if (empty($action) || $action == 'view') { $description .= $langs->trans("DepositsAreNotIncluded"); else $description .= $langs->trans("DepositsAreIncluded"); - $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0); + + $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger")); + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal=' . $id_journal; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 5a43548aed1..a58068c8798 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; @@ -46,17 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -$langs->load("banks"); -$langs->load("bills"); -$langs->load("categories"); -$langs->load("companies"); -$langs->load("margins"); -$langs->load("salaries"); -$langs->load("loan"); -$langs->load("donations"); -$langs->load("trips"); -$langs->load("members"); -$langs->load("compta"); +$langs->loadLangs(array("banks","bills","categories","companies","margins","salaries","loan","donations","trips","members","compta","accountancy")); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); @@ -84,6 +75,7 @@ $debit=GETPOST("debit",'alpha'); $credit=GETPOST("credit",'alpha'); $type=GETPOST("type",'alpha'); $account=GETPOST("account",'int'); +$accountancy_code=GETPOST('accountancy_code', 'alpha'); $bid=GETPOST("bid","int"); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); @@ -276,11 +268,11 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) $amount = - price2num($_POST["adddebit"]); } - $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); - $operation=$_POST["operation"]; - $num_chq=$_POST["num_chq"]; - $label=$_POST["label"]; - $cat1=$_POST["cat1"]; + $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); + $operation = GETPOST("operation",'alpha'); + $num_chq = GETPOST("num_chq",'alpha'); + $label = GETPOST("label",'alpha'); + $cat1 = GETPOST("cat1",'alpha'); if (! $dateop) { $error++; @@ -290,15 +282,24 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); } + if (! $label) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Label")), null, 'errors'); + } if (! $amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); } + if (! empty($conf->accounting->enabled) && (empty($accountancy_code) || $accountancy_code == '-1')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + } if (! $error) { $object->fetch($id); - $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user); + $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $accountancy_code); if ($insertid > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -331,6 +332,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->m $form = new Form($db); $formother = new FormOther($db); +$formaccounting = new FormAccounting($db); $companystatic=new Societe($db); $bankaccountstatic=new Account($db); @@ -408,19 +410,32 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); + /* * Buttons actions */ + if ($action != 'reconcile') { print '
    '; if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - if ($user->rights->banque->modifier) { - print ''.$langs->trans("AddBankRecord").''; - } else { - print ''.$langs->trans("AddBankRecord").''; + if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + print ''.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } + } + else // If direct entries is not done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + print ''.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } } } else @@ -637,6 +652,59 @@ if ($resql) // print '
    '.$objp->num_paiement.''; if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.dol_trunc($objp->label,24).''; else print ' '; From de66971d93437c90790d18ffc3d8fa560f72214a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Jul 2017 15:49:33 +0200 Subject: [PATCH 76/90] Fix bad setup --- htdocs/core/modules/modFournisseur.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 233b1601842..74c0070c92e 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -96,12 +96,14 @@ class modFournisseur extends DolibarrModules $this->const[$r][4] = 0; $r++; + /* For supplier invoice, we must not have default pdf template on. In most cases, we need to join PDF from supplier, not have a document generated. $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "canelle"; $this->const[$r][3] = 'Nom du gestionnaire de generation des factures fournisseur en PDF'; $this->const[$r][4] = 0; $r++; + */ $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER"; $this->const[$r][1] = "chaine"; @@ -272,12 +274,12 @@ class modFournisseur extends DolibarrModules $this->rights[$r][5] = 'approve2'; } - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; From 24ecd48b22e5fbfa2e0a81a6ab4ab18fef1d8639 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Jul 2017 03:40:20 +0200 Subject: [PATCH 77/90] Minor fix --- htdocs/compta/bank/bankentries.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index c3afc9634cf..f1ba166001e 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -102,7 +102,7 @@ $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); $pageplusone = GETPOST("pageplusone",'int'); if ($pageplusone) $page = $pageplusone - 1; -if ($page == -1) { $page = 0; } +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -130,7 +130,7 @@ if ($id > 0 || ! empty($ref)) $contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); //var_dump($contextpage); -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('banktransactionlist', $contextpage)); $extrafields = new ExtraFields($db); @@ -580,6 +580,7 @@ if ($resql) print ''; print ''; print ''; + print ''; print ''; print ''; if (GETPOST('bid')) print ''; @@ -1212,6 +1213,7 @@ if ($resql) { print '-" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")" . $langs->trans("AccountAccounting") . "" . $langs->trans("SubledgerAccount") . "" . $langs->trans("Type") . "" . $langs->trans("PaymentMode") . "" . $langs->trans("Debit") . "" . $date . "" . $ref . ""; - $accountoshow = length_accountg($k); - if (empty($accountoshow) || $accountoshow == 'NotDefined') + $accounttoshow = length_accountg($k); + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { print ''.$langs->trans("BankAccountNotDefined").''; } - else print $accountoshow; + else print $accounttoshow; + print ""; + /*$accounttoshow = length_accountg($k); + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + { + print ''.$langs->trans("BankAccountNotDefined").''; + } + else print $accounttoshow;*/ print "" . $bankstatic->label . " - " . $reflabel . "" . $langs->trans("Bank") . " - " . $reflabel . "" . $bankstatic->label . " - " . $val['soclib'] . "" . $langs->trans("Bank") . " - " . $val['soclib'] . "" . $val["type_payment"] . "" . ($mt >= 0 ? price($mt) : '') . "" . $date . "" . $ref . ""; - $accountoshow = length_accounta($k); - if (empty($accountoshow) || $accountoshow == 'NotDefined') + $account_ledger = $k; + if ($tabtype[$key] == 'payment') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + if ($tabtype[$key] == 'payment_supplier') $account_ledger = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; + if ($tabtype[$key] == 'payment_expensereport') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + if ($tabtype[$key] == 'payment_salary') $account_ledger = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $accounttoshow = length_accounta($account_ledger); + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + $errorstring='ThirdpartyDefaultAccountNotDefined'; + if ($tabtype[$key] == 'payment') $errorstring='MainAccountForCustomersNotDefined'; + if ($tabtype[$key] == 'payment_supplier') $errorstring='MainAccountForSuppliersNotDefined'; + if ($tabtype[$key] == 'payment_expensereport') $errorstring='MainAccountForUsersNotDefined'; + if ($tabtype[$key] == 'payment_salary') $errorstring='MainAccountForUsersNotDefined'; + print ''.$langs->trans($errorstring).''; + } + else print $accounttoshow; + print ""; + $accounttoshowsubledger = length_accounta($k); + if ($accounttoshow != $accounttoshowsubledger) + { + if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') + { + print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + } + else print $accounttoshowsubledger; } - else print $accountoshow; print "" . $reflabel . ' ' . $val['soclib'] . "" . $val["type_payment"] . "" . $date . "" . $ref . ""; - if (empty($accountoshow) || $accountoshow == 'NotDefined') + /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') + { + print ''.$langs->trans("WaitAccountNotDefined").''; + } + else */ print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); + print ""; + /*if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { print ''.$langs->trans("WaitAccountNotDefined").''; } else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); + */ print "" . $reflabel . " " . $val["type_payment"] . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "
    '; } + // Form to add a transaction with no invoice + if ($user->rights->banque->modifier && $action == 'addline') + { + print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->accounting->enabled)) + { + print ''; + } + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->accounting->enabled)) + { + print ''; + } + print ''; + print '
    '.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''; + print $langs->trans("AccountAccounting"); + print ' 
    '; + $form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction'); + print ''; + $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); + print ''; + print ''; + print ''; + if ($options) { + print '
    '.$langs->trans("Rubrique").': '; + print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); + } + print '
    '; + print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); + print ''; + print '
    '; + print ''; + print '
    '; + print '
    '; + } /// ajax to adjust value date with plus and less picto print ' diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 43b6dace19c..08631abec79 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -39,7 +39,7 @@ class Account extends CommonObject public $element = 'bank_account'; public $table_element = 'bank_account'; public $picto = 'account'; - + /** * @var int Use id instead of rowid * @deprecated @@ -394,9 +394,10 @@ class Account extends CommonObject * @param User $user User that create * @param string $emetteur Name of cheque writer * @param string $banque Bank of cheque writer + * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='') { // Deprecatîon warning if (is_numeric($oper)) { @@ -456,6 +457,7 @@ class Account extends CommonObject $accline->fk_user_author = $user->id; $accline->fk_account = $this->rowid; $accline->fk_type = $oper; + $accline->numero_compte = $accountancycode; if ($num_chq) { $accline->num_chq = $num_chq; @@ -538,7 +540,7 @@ class Account extends CommonObject $now=dol_now(); $this->db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account ("; $sql.= "datec"; $sql.= ", ref"; @@ -619,14 +621,14 @@ class Account extends CommonObject $result=$this->insertExtraFields(); if ($result < 0) $error++; } - + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('BANKACCOUNT_CREATE',$user); if ($result < 0) $error++; // End call triggers - } + } } else { @@ -670,9 +672,9 @@ class Account extends CommonObject global $langs,$conf, $hookmanager; $error=0; - + $this->db->begin(); - + // Clean parameters $this->state_id = ($this->state_id?$this->state_id:$this->state_id); $this->country_id = ($this->country_id?$this->country_id:$this->country_id); @@ -739,7 +741,7 @@ class Account extends CommonObject if ($result < 0) $error++; } } - + if (! $error && ! $notrigger) { // Call trigger @@ -754,7 +756,7 @@ class Account extends CommonObject $this->error=$this->db->lasterror(); dol_print_error($this->db); } - + if (! $error) { $this->db->commit(); @@ -906,7 +908,7 @@ class Account extends CommonObject $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_update = $this->db->jdate($obj->date_update); - + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); @@ -983,15 +985,15 @@ class Account extends CommonObject global $conf; $error=0; - + $this->db->begin(); - + // Delete link between tag and bank account if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; $sql.= " WHERE fk_account = ".$this->id; - + $resql = $this->db->query($sql); if (!$resql) { @@ -999,15 +1001,15 @@ class Account extends CommonObject $this->error = "Error ".$this->db->lasterror(); } } - + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE rowid = ".$this->rowid; - + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) + if ($result) { // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used @@ -1020,13 +1022,13 @@ class Account extends CommonObject } } } - else + else { $error++; $this->error = "Error ".$this->db->lasterror(); - } + } } - + if (! $error) { $this->db->commit(); @@ -1433,7 +1435,7 @@ class Account extends CommonObject * - DeskCode * * Some countries show less or more bank account properties to the user - * + * * @param int $includeibanbic 1=Return also key for IBAN and BIC * @return array * @see useDetailedBBAN @@ -1554,7 +1556,7 @@ class AccountLine extends CommonObject var $element='bank'; var $table_element='bank'; var $picto = 'generic'; - + var $id; var $ref; var $datec; @@ -1683,8 +1685,9 @@ class AccountLine extends CommonObject $sql .= ", num_chq"; $sql .= ", fk_account"; $sql .= ", fk_type"; - $sql .= ",emetteur,banque"; + $sql .= ", emetteur,banque"; $sql .= ", rappro"; + $sql .= ", numero_compte"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->datec)."'"; $sql .= ", '".$this->db->idate($this->dateo)."'"; @@ -1698,6 +1701,7 @@ class AccountLine extends CommonObject $sql .= ", ".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null"); $sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null"); $sql .= ", ".(int) $this->rappro; + $sql .= ", ".($this->numero_compte ? "'".$this->db->escape($this->numero_compte)."'" : "''"); $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); @@ -1842,7 +1846,7 @@ class AccountLine extends CommonObject function update_conciliation(User $user, $cat) { global $conf; - + $this->db->begin(); // Check statement field @@ -1854,7 +1858,7 @@ class AccountLine extends CommonObject return -1; } } - + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; $sql.= " rappro = 1"; $sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'"; @@ -2042,7 +2046,7 @@ class AccountLine extends CommonObject return $result; } - + /** * Return label of status (activity, closed) * @@ -2053,7 +2057,7 @@ class AccountLine extends CommonObject { return $this->LibStatut($this->status,$mode); } - + /** * Renvoi le libelle d'un statut donne * @@ -2097,6 +2101,6 @@ class AccountLine extends CommonObject if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); }*/ } - + } diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 939872ce7fd..9812269dcb6 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -325,14 +325,14 @@ class PaymentVarious extends CommonObject $sql.= " VALUES ("; $sql.= "'".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", '".$this->sens."'"; + $sql.= ", '".$this->db->escape($this->sens)."'"; $sql.= ", ".$this->amount; - $sql.= ", '".$this->type_payment."'"; - $sql.= ", '".$this->num_payment."'"; + $sql.= ", '".$this->db->escape($this->type_payment)."'"; + $sql.= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->accountancy_code."'"; - $sql.= ", '".$user->id."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code)."'"; + $sql.= ", ".$user->id; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", NULL"; $sql.= ", ".$conf->entity; @@ -342,7 +342,6 @@ class PaymentVarious extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various"); if ($this->id > 0) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index e19deca91c9..f75c111094d 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -29,15 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -$langs->load("compta"); -$langs->load("banks"); -$langs->load("bills"); -$langs->load("users"); -$langs->load("accountancy"); +$langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy")); + +// Get parameters +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); -$id=GETPOST("id",'int'); -$action=GETPOST('action','alpha'); -$cancel=GETPOST('cancel','alpha'); $accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $label=GETPOST("label","alpha"); $sens=GETPOST("sens","int"); @@ -61,115 +60,139 @@ $hookmanager->initHooks(array('variouscard','globalcard')); * Actions */ -if (! empty($cancel)) +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - header("Location: index.php"); - exit; -} - -if ($action == 'add' && empty($cancel)) -{ - $error=0; - - $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); - $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); - if (empty($datev)) $datev=$datep; - - $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount")); - $object->label=GETPOST("label"); - $object->note=GETPOST("note"); - $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; - $object->num_payment=GETPOST("num_payment"); - $object->fk_user_author=$user->id; - $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; - - if (empty($datep) || empty($datev)) + if ($cancel) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - $error++; - } - if (empty($object->type_payment) || $object->type_payment < 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); - $error++; - } - if (empty($object->amount)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); - $error++; - } - if (! empty($conf->banque->enabled) && ! $object->accountid > 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); - $error++; - } - - if (! $error) - { - $db->begin(); - - $ret=$object->create($user); - if ($ret > 0) + if ($action != 'addlink') { - $db->commit(); - header("Location: index.php"); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); + header("Location: ".$urltogo); exit; } - else - { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $action="create"; - } + if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); + $action=''; } - $action='create'; -} - -if ($action == 'delete') -{ - $result=$object->fetch($id); - - if ($object->rappro == 0) + if ($action == 'add') { - $db->begin(); + $error=0; - $ret=$object->delete($user); - if ($ret > 0) + $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); + $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); + if (empty($datev)) $datev=$datep; + + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; + $object->datev=$datev; + $object->datep=$datep; + $object->amount=price2num(GETPOST("amount")); + $object->label=GETPOST("label"); + $object->note=GETPOST("note"); + $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; + $object->num_payment=GETPOST("num_payment"); + $object->fk_user_author=$user->id; + $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; + $object->sens=GETPOST('sens'); + + if (empty($datep) || empty($datev)) { - if ($object->fk_bank) - { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) - } + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); + $error++; + } + if (empty($object->type_payment) || $object->type_payment < 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); + $error++; + } + if (empty($object->amount)) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); + $error++; + } + if (! empty($conf->banque->enabled) && ! $object->accountid > 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); + $error++; + } + if (! empty($conf->accounting->enabled) && ! $object->accountancy_code) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + } - if ($result >= 0) + if (! $error) + { + $db->begin(); + + $ret=$object->create($user); + if ($ret > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + header("Location: index.php"); exit; } else { - $object->error=$accountline->error; + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $action="create"; + } + } + + $action='create'; + } + + if ($action == 'delete') + { + $result=$object->fetch($id); + + if ($object->rappro == 0) + { + $db->begin(); + + $ret=$object->delete($user); + if ($ret > 0) + { + if ($object->fk_bank) + { + $accountline=new AccountLine($db); + $result=$accountline->fetch($object->fk_bank); + if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + } + + if ($result >= 0) + { + $db->commit(); + header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + exit; + } + else + { + $object->error=$accountline->error; + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); } } - else - { - setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); - } } @@ -200,8 +223,9 @@ if ($id) /* ************************************************************************** */ if ($action == 'create') { - print ''; + print ''; print ''; + print ''; print ''; print load_fiche_titre($langs->trans("NewVariousPayment"),'', 'title_accountancy.png'); @@ -269,7 +293,7 @@ if ($action == 'create') // Accountancy account if (! empty($conf->accounting->enabled)) { - print ''.$langs->trans("AccountAccounting").''; + print ''.$langs->trans("AccountAccounting").''; print ''; print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); print ''; @@ -292,7 +316,7 @@ if ($action == 'create') print '
    '; print ''; - print '     '; + print '   '; print ''; print '
    '; diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 3fce9c30fd6..5b2488cc5e8 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -1,5 +1,6 @@ + * Copyright (C) 2017 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 @@ -16,9 +17,9 @@ */ /** - * \file htdocs/compta/bank/various_payment/index.php - * \ingroup bank - * \brief List of various payments + * \file htdocs/compta/bank/various_payment/index.php + * \ingroup bank + * \brief List of various payments */ require '../../../main.inc.php'; @@ -34,6 +35,8 @@ $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'banque', '', '', ''); +$optioncss = GETPOST('optioncss','alpha'); + $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); @@ -50,11 +53,10 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield="v.datep"; if (! $sortorder) $sortorder="DESC"; -$optioncss = GETPOST('optioncss','alpha'); -$filtre=$_GET["filtre"]; +$filtre=GETPOST("filtre",'alpha'); -if (empty($_REQUEST['typeid'])) +if (! GETPOST('typeid')) { $newfiltre=str_replace('filtre=','',$filtre); $filterarray=explode('-',$newfiltre); @@ -66,7 +68,7 @@ if (empty($_REQUEST['typeid'])) } else { - $typeid=$_REQUEST['typeid']; + $typeid=GETPOST('typeid'); } if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers @@ -240,9 +242,12 @@ if ($result) $colspan=4; if (! empty($conf->banque->enabled)) $colspan++; - print ''.$langs->trans("Total").''; + print ''; + print ''.$langs->trans("Total").''; print ''.price($total).""; - print ""; + print ''; + print ''; + print ''; print ""; print '
    '; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 89b4f9cd00c..d18da18ac6a 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -122,6 +122,8 @@ ALTER TABLE llx_actioncomm ADD COLUMN extraparams varchar(255); ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); +ALTER TABLE llx_bank ADD COLUMN numero_compte varchar(32) NULL; + -- VMYSQL4.1 ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer DEFAULT NULL; -- VPGSQL8.2 ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer USING state_id::integer; diff --git a/htdocs/install/mysql/tables/llx_bank.sql b/htdocs/install/mysql/tables/llx_bank.sql index 5ea55b146bd..6c2c8d34537 100644 --- a/htdocs/install/mysql/tables/llx_bank.sql +++ b/htdocs/install/mysql/tables/llx_bank.sql @@ -32,6 +32,7 @@ create table llx_bank fk_type varchar(6), -- TIP,VIR,PRE,CB,CHQ,... (Code in llx_c_paiement) num_releve varchar(50), num_chq varchar(50), + numero_compte varchar(32) NULL, -- FEC:CompteNum | account number rappro tinyint default 0, note text, fk_bordereau integer DEFAULT 0, diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 34e352205b0..8cfdbed4728 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -28,7 +28,13 @@ OverviewOfAmountOfLinesBound=Overview of amount of lines already bound to accoun OtherInfo=Other information DeleteCptCategory=Remove accounting account from group ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account from the accounting account group ? +JournalizationInLedgerStatus=Status of journalization AlreadyInGeneralLedger=Already journalized in ledgers +NotYetInGeneralLedger=Not yet journalized in ledgers + +MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup +MainAccountForSuppliersNotDefined=Main accounting account for suppliers not defined in setup +MainAccountForUsersNotDefined=Main accounting account for users not defined in setup AccountancyArea=Accountancy area AccountancyAreaDescIntro=Usage of the accountancy module is done in several step: @@ -154,7 +160,7 @@ DelBookKeeping=Delete record of the Ledger FinanceJournal=Finance journal ExpenseReportsJournal=Expense reports journal DescFinanceJournal=Finance journal including all the types of payments by bank account -DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the Ledger. +DescJournalOnlyBindedVisible=This is a view of record that are bound to accountancy account and can be recorded into the Ledger. VATAccountNotDefined=Account for VAT not defined ThirdpartyAccountNotDefined=Account for third party not defined ProductAccountNotDefined=Account for product not defined diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 3f995673f88..6e2f19f5f36 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -151,7 +151,7 @@ CheckRejectedAndInvoicesReopened=Check returned and invoices reopened BankAccountModelModule=Document templates for bank accounts DocumentModelSepaMandate=Template of SEPA mandate. Usefull for european countries in EEC only. DocumentModelBan=Template to print a page with BAN information. -NewVariousPayment=New miscellaneous payment -VariousPayment=Miscellaneous payment +NewVariousPayment=New miscellaneous payments +VariousPayment=Miscellaneous payments VariousPayments=Miscellaneous payments -ShowVariousPayment=Show miscellaneous payment +ShowVariousPayment=Show miscellaneous payments diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 6f8a1b5e301..79ad6cfd628 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -191,9 +191,9 @@ ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for collecting VAT - V ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for recovered VAT - VAT on purchases (used if not defined on VAT dictionary setup) ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties -ACCOUNTING_ACCOUNT_CUSTOMER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated customer accouting account on third party is not defined +ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated customer accouting account on third party is not defined. ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for supplier third parties -ACCOUNTING_ACCOUNT_SUPPLIER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined +ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined. CloneTax=Clone a social/fiscal tax ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment CloneTaxForNextMonth=Clone it for next month diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 522bf0a65d7..7e0c80d3380 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -1,6 +1,6 @@ # Dolibarr language file - Source file is en_US - salaries SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties -SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=Dedicated accounting account defined on user card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated user accouting account on user is not defined +SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accouting account on user is not defined. SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for personnel expenses Salary=Salary Salaries=Salaries diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index fefd1f78d9d..994aca35c88 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -258,10 +258,11 @@ if ($action == 'create') print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("MyObject"))); print ''; + print ''; print ''; print ''; - dol_fiche_head(); + dol_fiche_head(array(), ''); print ''."\n"; foreach($object->fields as $key => $val) @@ -277,7 +278,7 @@ if ($action == 'create') dol_fiche_end(); - print '
     
    '; + print '
     
    '; print ''; } From 0763d15b4c5d4418b1a1e9126928697208042ff2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Jul 2017 12:37:31 +0200 Subject: [PATCH 79/90] Debug journalization Debug edition of user BAN. --- .../journal/expensereportsjournal.php | 166 ++++++---- .../accountancy/journal/purchasesjournal.php | 228 ++++++++------ htdocs/accountancy/journal/sellsjournal.php | 297 ++++++++++-------- htdocs/core/menus/standard/eldy.lib.php | 6 +- htdocs/core/modules/modAccounting.class.php | 2 +- htdocs/core/modules/modSalaries.class.php | 12 +- htdocs/user/bank.php | 97 ++++-- htdocs/user/class/userbankaccount.class.php | 3 +- 8 files changed, 487 insertions(+), 324 deletions(-) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 0002bca413f..fb1e77d1c5c 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -36,12 +36,7 @@ require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -$langs->load("compta"); -$langs->load("bills"); -$langs->load("other"); -$langs->load("main"); -$langs->load("accountancy"); -$langs->load("trips"); +$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","trips","errors")); $id_journal = GETPOST('id_journal', 'int'); $action = GETPOST('action','aZ09'); @@ -91,7 +86,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $idpays = $mysoc->country_id; $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; -$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; +$sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; //$sql .= " ct.accountancy_code_buy as account_tva"; @@ -112,22 +107,25 @@ if ($in_bookkeeping == 'notyet') $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; $sql .= " ORDER BY er.date_debut"; -dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql); +dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - - // Variables - $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'; - $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; $taber = array (); $tabht = array (); $tabtva = array (); $def_tva = array (); $tabttc = array (); + $tablocaltax1 = array (); + $tablocaltax2 = array (); $tabuser = array (); + $num = $db->num_rows($result); + + // Variables + $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'; + $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); @@ -138,7 +136,9 @@ if ($result) { $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); - + $compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); + $compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); + // Define array to display all VAT rates that use this accounting account $compta_tva if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) { @@ -149,9 +149,19 @@ if ($result) { $taber[$obj->rowid]["ref"] = $obj->ref; $taber[$obj->rowid]["comments"] = $obj->comments; $taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid; + + // Avoid warnings + if (! isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0; + if (! isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0; + if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; + if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; + if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; + $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc; $tabht[$obj->rowid][$compta_fees] += $obj->total_ht; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; + $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; + $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; $tabuser[$obj->rowid] = array ( 'id' => $obj->uid, 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), @@ -169,7 +179,7 @@ if ($action == 'writebookkeeping') { $now = dol_now(); $error = 0; - foreach ($taber as $key => $val) + foreach ($taber as $key => $val) // Loop on each expense report { $errorforline = 0; @@ -180,7 +190,6 @@ if ($action == 'writebookkeeping') { { foreach ( $tabttc[$key] as $k => $mt ) { if ($mt) { - // get compte id and label $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -190,8 +199,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code']; - $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->label_operation = $tabuser[$key]['name']; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt <= 0) ? $mt : 0; @@ -223,8 +232,6 @@ if ($action == 'writebookkeeping') { if (! $errorforline) { foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k, true); if ($mt) { // get compte id and label $accountingaccount = new AccountingAccount($db); @@ -238,8 +245,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_operation = $accountingaccount->label; $bookkeeping->numero_compte = $k; + $bookkeeping->label_operation = $accountingaccount->label; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -271,9 +278,15 @@ if ($action == 'writebookkeeping') { // VAT if (! $errorforline) { - // var_dump($tabtva); - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { + $listoftax=array(0, 1, 2); + foreach($listoftax as $numtax) + { + $arrayofvat = $tabtva; + if ($numtax == 1) $arrayofvat = $tablocaltax1; + if ($numtax == 2) $arrayofvat = $tablocaltax2; + + foreach ( $arrayofvat[$key] as $k => $mt ) { + if ($mt) { // get compte id and label $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -284,8 +297,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; + $bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt > 0) ? $mt : 0; @@ -309,6 +322,7 @@ if ($action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } + } } } } @@ -329,7 +343,7 @@ if ($action == 'writebookkeeping') { } } - if (empty($error) && count($tabpay)) { + if (empty($error) && count($tabpay) > 0) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } elseif (count($tabpay) == $error) @@ -353,7 +367,7 @@ $form = new Form($db); $userstatic = new User($db); // Export -/*if ($action == 'export_csv') { +/*if ($action == 'exportcsv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; @@ -479,20 +493,25 @@ if (empty($action) || $action == 'view') { journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); - /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { - print ''; - } else { - print ''; - }*/ - + // Button to write into Ledger + if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + } print '
    '; - print ''; + if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { + print ''; + } + else { + print ''; + } + //print ''; print '
    '; print '