develop_dict
This commit is contained in:
Regis Houssin 2017-06-18 06:52:20 +02:00
commit dcc152d4a4
36 changed files with 406 additions and 165 deletions

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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
@ -60,6 +61,9 @@ $urlpage = GETPOST('urlpage');
$key = GETPOST('key');
$value = GETPOST('value');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admindefaultvalues','globaladmin'));
/*
* Actions

View File

@ -1,12 +1,12 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* 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
@ -75,11 +75,18 @@ if ($search_version) $param.='&search_version='.urlencode($search_version);
$dirins=DOL_DOCUMENT_ROOT.'/custom';
$urldolibarrmodules='https://www.dolistore.com/';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('adminmodules','globaladmin'));
/*
* Actions
*/
$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 (GETPOST('buttonreset','alpha'))
{
$search_keyword='';
@ -204,7 +211,7 @@ if ($action == 'set' && $user->admin)
setEventMessages($msg, null, 'warnings');
}
}
header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
exit;
}
@ -212,7 +219,7 @@ if ($action == 'reset' && $user->admin)
{
$result=unActivateModule($value);
if ($result) setEventMessages($result, null, 'errors');
header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
exit;
}
@ -476,10 +483,13 @@ if ($mode == 'common')
print $hookmanager->resPrint;
}
$moreforfilter='';
print '<div class="clearboth"></div><br>';
$moreforfilter='';
$parameters=array();
$reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Show list of modules
@ -659,7 +669,7 @@ if ($mode == 'common')
}
else
{
print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=reset&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=reset&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a>';
}
@ -755,7 +765,7 @@ if ($mode == 'common')
}
}
print '<!-- Message to show: '.$warningmessage.' -->'."\n";
print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=set&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '"';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=set&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '"';
if ($warningmessage) print ' onclick="return confirm(\''.dol_escape_js($warningmessage).'\');"';
print '>';
print img_picto($langs->trans("Disabled"),'switch_off');

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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
@ -56,6 +56,9 @@ $pagenext = $page + 1;
if (! $sortfield) $sortfield='lang,transkey';
if (! $sortorder) $sortorder='ASC';
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admintranslation','globaladmin'));
/*
* Actions

View File

@ -3097,9 +3097,18 @@ abstract class CommonObject
$trueWeightUnit=pow(10, $weightUnit);
$totalWeight += $weight * $qty * $trueWeightUnit;
}
else
{
$totalWeight += $weight * $qty; // This may be wrong if we mix different units
else {
if ($weight_units == 99) {
// conversion 1 Pound = 0.45359237 KG
$trueWeightUnit = 0.45359237;
$totalWeight += $weight * $qty * $trueWeightUnit;
} elseif ($weight_units == 98) {
// conversion 1 Ounce = 0.0283495 KG
$trueWeightUnit = 0.0283495;
$totalWeight += $weight * $qty * $trueWeightUnit;
}
else
$totalWeight += $weight * $qty; // This may be wrong if we mix different units
}
if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch)
{

View File

@ -441,7 +441,8 @@ function measuring_units_string($unit,$measuring_style='')
$measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg");
$measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg");
$measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg");
$measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound");
$measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce");
$measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound");
}
else if ($measuring_style == 'size')
{

View File

@ -458,7 +458,7 @@ function pFooter($nonext=0,$setuplang='',$jscheckfunction='', $withpleasewait=0)
$_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'],1 );
if (isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING']; }
}
print $langs->trans("ErrorFoundDuringMigration", $_SERVER["REQUEST_URI"].'&ignoreerrors=1').'<br><br>';
print $langs->trans("ErrorFoundDuringMigration", isset($_SERVER["REQUEST_URI"])?$_SERVER["REQUEST_URI"].'&ignoreerrors=1':'').'<br><br>';
}
print '<input type="submit" '.($nonext == '2' ? 'disabled="disabled" ':'').'value="'.$langs->trans("NextStep").' ->"';

View File

@ -1,64 +0,0 @@
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
-- when current version is 6.0.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
-- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table
-- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex
-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y
-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y
-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
-- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL;
-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL;
-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL;
-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
-- Note: fields with type BLOB/TEXT can't have default value.
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
-- Clean corrupted values for tms
-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL;
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL;
-- Remove default not null on date_fin
-- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL;
-- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL;
-- Move real to numeric for more precision for storing monetary amounts (no rouding)
-- https://wiki.dolibarr.org/index.php/Langages_et_normes#Structure_des_tables_et_champs
ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN debit numeric(24,8);
ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN credit numeric(24,8);
ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant numeric(24,8);
ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount numeric(24,8);
ALTER TABLE llx_blockedlog MODIFY COLUMN amounts numeric(24,8);
ALTER TABLE llx_chargessociales MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_commande MODIFY COLUMN amount_ht numeric(24,8);
ALTER TABLE llx_commande_fournisseur MODIFY COLUMN amount_ht numeric(24,8);
ALTER TABLE llx_don MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_capital numeric(24,8);
ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_insurance numeric(24,8);
ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_interest numeric(24,8);
ALTER TABLE llx_paiementcharge MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_paiementfourn MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_payment_donation MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_payment_expensereport MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_payment_loan MODIFY COLUMN amount_capital numeric(24,8);
ALTER TABLE llx_payment_loan MODIFY COLUMN amount_insurance numeric(24,8);
ALTER TABLE llx_payment_loan MODIFY COLUMN amount_interest numeric(24,8);
ALTER TABLE llx_payment_salary MODIFY COLUMN salary numeric(24,8);
ALTER TABLE llx_payment_salary MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_prelevement_bons MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_prelevement_lignes MODIFY COLUMN amount numeric(24,8);
ALTER TABLE llx_societe MODIFY COLUMN capital numeric(24,8);
ALTER TABLE llx_tva MODIFY COLUMN amount numeric(24,8);

View File

@ -26,17 +26,17 @@ CREATE TABLE llx_accounting_bookkeeping
doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number
fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid
fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid
thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug)
thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug)
subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account
subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account
numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number
label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account
label_operation varchar(255), -- FEC:EcritureLib | label of the operation
debit numeric(24,8) NOT NULL, -- FEC:Debit
credit numeric(24,8) NOT NULL, -- FEC:Credit
montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary)
debit double NOT NULL, -- FEC:Debit
credit double NOT NULL, -- FEC:Credit
montant double NOT NULL, -- FEC:Montant (Not necessary)
sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary)
multicurrency_amount numeric(24,8), -- FEC:Montantdevise
multicurrency_amount double, -- FEC:Montantdevise
multicurrency_code varchar(255), -- FEC:Idevise
lettering_code varchar(255), -- FEC:EcritureLet
date_lettering datetime, -- FEC:DateLet

View File

@ -4,7 +4,7 @@ CREATE TABLE llx_blockedlog
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
action varchar(50),
amounts numeric(24,8) NOT NULL,
amounts real NOT NULL,
signature varchar(100) NOT NULL,
signature_line varchar(100) NOT NULL,
element varchar(50),

View File

@ -34,7 +34,7 @@ create table llx_chargesociales
fk_type integer NOT NULL,
fk_account integer, -- bank account
fk_mode_reglement integer, -- mode de reglement
amount numeric(24,8) default 0 NOT NULL,
amount real default 0 NOT NULL,
paye smallint default 0 NOT NULL,
periode date,
fk_projet integer DEFAULT NULL,

View File

@ -42,7 +42,7 @@ create table llx_commande
fk_user_cloture integer, -- user closing
source smallint, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ?
fk_statut smallint default 0,
amount_ht numeric(24,8) default 0,
amount_ht real default 0,
remise_percent real default 0,
remise_absolue real default 0,
remise real default 0,

View File

@ -46,7 +46,7 @@ create table llx_commande_fournisseur
source smallint NOT NULL, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ?
fk_statut smallint default 0,
billed smallint default 0,
amount_ht numeric(24,8) default 0,
amount_ht real default 0,
remise_percent real default 0,
remise real default 0,
tva double(24,8) default 0,

View File

@ -28,7 +28,7 @@ create table llx_don
tms timestamp,
fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate
datedon datetime, -- Date of the donation/promise
amount numeric(24,8) DEFAULT 0,
amount real DEFAULT 0,
fk_payment integer,
paid smallint default 0 NOT NULL,
firstname varchar(50),

View File

@ -24,9 +24,9 @@ create table llx_loan_schedule
datec datetime, -- creation date
tms timestamp,
datep datetime, -- payment date
amount_capital numeric(24,8) DEFAULT 0,
amount_insurance numeric(24,8) DEFAULT 0,
amount_interest numeric(24,8) DEFAULT 0,
amount_capital real DEFAULT 0,
amount_insurance real DEFAULT 0,
amount_interest real DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50),
note_private text,

View File

@ -23,7 +23,7 @@ create table llx_paiementcharge
datec datetime, -- date de creation
tms timestamp,
datep datetime, -- payment date
amount numeric(24,8) DEFAULT 0,
amount real DEFAULT 0,
fk_typepaiement integer NOT NULL,
num_paiement varchar(50),
note text,

View File

@ -25,7 +25,7 @@ create table llx_paiementfourn
tms timestamp,
datec datetime, -- date de creation de l'enregistrement
datep datetime, -- date de paiement
amount numeric(24,8) DEFAULT 0, -- montant
amount real DEFAULT 0, -- montant
multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount
fk_user_author integer, -- auteur
fk_paiement integer NOT NULL, -- moyen de paiement

View File

@ -23,7 +23,7 @@ create table llx_payment_donation
datec datetime, -- date de creation
tms timestamp,
datep datetime, -- payment date
amount numeric(24,8) DEFAULT 0,
amount real DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50),
note text,

View File

@ -23,7 +23,7 @@ create table llx_payment_expensereport
datec datetime, -- date de creation
tms timestamp,
datep datetime, -- payment date
amount numeric(24,8) DEFAULT 0,
amount real DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50),
note text,

View File

@ -24,9 +24,9 @@ create table llx_payment_loan
datec datetime, -- creation date
tms timestamp,
datep datetime, -- payment date
amount_capital numeric(24,8) DEFAULT 0,
amount_insurance numeric(24,8) DEFAULT 0,
amount_interest numeric(24,8) DEFAULT 0,
amount_capital real DEFAULT 0,
amount_insurance real DEFAULT 0,
amount_interest real DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50),
note_private text,

View File

@ -24,8 +24,8 @@ create table llx_payment_salary
fk_user integer NOT NULL,
datep date, -- date de paiement
datev date, -- date de valeur (this field should not be here, only into bank tables)
salary numeric(24,8), -- salary of user when payment was done
amount numeric(24,8) NOT NULL DEFAULT 0,
salary real, -- salary of user when payment was done
amount real NOT NULL DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50), -- ref
label varchar(255),

View File

@ -29,7 +29,7 @@ create table llx_prelevement_bons
ref varchar(12), -- reference
entity integer DEFAULT 1 NOT NULL, -- multi company id
datec datetime, -- date de creation
amount numeric(24,8) DEFAULT 0, -- montant total du prelevement
amount real DEFAULT 0, -- montant total du prelevement
statut smallint DEFAULT 0, -- statut
credite smallint DEFAULT 0, -- indique si le prelevement a ete credite
note text,

View File

@ -21,7 +21,7 @@ create table llx_prelevement_facture_demande
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_facture integer NOT NULL,
amount numeric(24,8) NOT NULL,
amount real NOT NULL,
date_demande datetime NOT NULL,
traite smallint DEFAULT 0,
date_traite datetime,

View File

@ -24,7 +24,7 @@ create table llx_prelevement_lignes
statut smallint DEFAULT 0,
client_nom varchar(255),
amount numeric(24,8) DEFAULT 0,
amount real DEFAULT 0,
code_banque varchar(128),
code_guichet varchar(6),
number varchar(255),

View File

@ -64,7 +64,7 @@ create table llx_societe
idprof5 varchar(128), -- IDProf5: nu for france
idprof6 varchar(128), -- IDProf6: nu for france
tva_intra varchar(20), -- tva
capital numeric(24,8), -- capital de la societe
capital real, -- capital de la societe
fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut
note_private text, --
note_public text, --

View File

@ -24,11 +24,11 @@ create table llx_tva
datec datetime, -- Create date
datep date, -- date de paiement
datev date, -- date de valeur
amount numeric(24,8) NOT NULL DEFAULT 0,
amount real NOT NULL DEFAULT 0,
fk_typepayment integer NULL,
num_payment varchar(50),
label varchar(255),
entity integer DEFAULT 1 NOT NULL, -- multi company id
entity integer DEFAULT 1 NOT NULL, -- multi company id
note text,
fk_bank integer,
fk_user_creat integer, -- utilisateur who create record

View File

@ -1,11 +1,15 @@
# Dolibarr language file - Source file is en_US - loan
ModuleBuilderDesc=This tools give you utilites to build or edit your own module.
EnterNameOfModuleDesc=Enter name of the module to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...)
EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...)
EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...)
ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): <strong>%s</strong>
ModuleBuilderDesc3=Generated/editable modules found: <strong>%s</strong> (they are detected as editable when the file <strong>%s</strong> exists in root of module directory).
NewModule=New module
NewObject=New object
ModuleKey=Key for new module
ObjectKey=Key for new object
ModuleInitialized=Module initialized
FilesForObjectInitialized=Files for new object initialized
ModuleBuilderDescdescription=Enter here all general information that describe your module
ModuleBuilderDescobjects=Define here the new objects you want to manage with your module. A page to list them and a page to create/edit/view a card will be generated.
ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module.
@ -13,7 +17,7 @@ ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions
ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE.
ModuleBuilderDeschooks=This tab is dedicated to hooks.
ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets.
ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to get your module package file.
ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to build the module package file.
ModuleBuilderDescdangerzone=You can delete your module. WARNING: All files of module will be definetly lost !
DangerZone=Danger zone
BuildPackage=Build package
@ -21,4 +25,10 @@ ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module t
ModuleIsLive=This module has been activated. Any change on it may break a current active feature.
DescriptionLong=Long description
EditorName=Name of editor
EditorUrl=URL of editor
EditorUrl=URL of editor
DescriptorFile=Descriptor file of module
ClassFile=File for PHP class
ApiClassFile=File for PHP API class
PageForList=PHP page for list of record
PageForCreateEditView=PHP page to create/edit/view a record
PathToModulePackage=Path to zip of module/application package

View File

@ -124,6 +124,7 @@ WeightUnitkg=kg
WeightUnitg=g
WeightUnitmg=mg
WeightUnitpound=pound
WeightUnitounce=ounce
Length=Length
LengthUnitm=m
LengthUnitdm=dm

View File

@ -33,11 +33,13 @@ $action=GETPOST('action','aZ09');
$confirm=GETPOST('confirm','alpha');
$module=GETPOST('module','alpha');
$tab=GETPOST('tab','aZ09');
$tabobj=GETPOST('tabobj','alpha');
if (empty($module)) $module='initmodule';
if (empty($tab)) $tab='description';
if (empty($tabobj)) $tabobj='newobject';
$modulename=dol_sanitizeFileName(GETPOST('modulename','alpha'));
$objectname=dol_sanitizeFileName(GETPOST('objectname','alpha'));
// Security check
if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed');
@ -80,6 +82,18 @@ if ($dirins && $action == 'initmodule' && $modulename)
}
}
// Delete some files
dol_delete_file($destdir.'/myobject_card.php');
dol_delete_file($destdir.'/myobject_list.php');
dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php');
dol_delete_file($destdir.'/sql/llx_myobject.key.sql');
dol_delete_file($destdir.'/sql/llx_myobject.sql');
dol_delete_file($destdir.'/scripts/myobject.php');
dol_delete_file($destdir.'/img/object_myobject.png');
dol_delete_file($destdir.'/class/myobject.class.php');
dol_delete_file($destdir.'/class/api_myobject.class.php');
dol_delete_file($destdir.'/class/MyObject.txt');
// Edit PHP files
if (! $error)
{
@ -113,6 +127,86 @@ if ($dirins && $action == 'initmodule' && $modulename)
}
}
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',
'myobject_list.php'=>strtolower($objectname).'_list.php',
'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql',
'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql',
'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php',
'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png',
'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php',
'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php',
'class/MyObject.txt'=>'class/'.$objectname.'.txt'
);
foreach($filetogenerate as $srcfile => $destfile)
{
$result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile);
if ($result <= 0)
{
if ($result < 0)
{
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors');
}
else // $result == 0
{
setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings');
}
}
else
{
// Copy is ok
}
}
// Edit PHP files
foreach($filetogenerate as $destfile)
{
$phpfileval['fullname'] = $destdir.'/'.$destfile;
//var_dump($phpfileval['fullname']);
$arrayreplacement=array(
'mymodule'=>strtolower($modulename),
'MyModule'=>$modulename,
'MYMODULE'=>strtoupper($modulename),
'My module'=>$modulename,
'htdocs/modulebuilder/template/'=>'',
'myobject'=>strtolower($objectname),
'MyObject'=>$objectname
);
$result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
//var_dump($result);
if ($result < 0)
{
setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors');
}
}
if (! $error)
{
setEventMessages('FilesForObjectInitialized', null);
}
}
if ($dirins && $action == 'confirm_delete')
{
$modulelowercase=strtolower($module);
@ -360,7 +454,9 @@ elseif (! empty($module))
$head2 = array();
$h=0;
$modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive");
$modulelowercase=strtolower($module);
$modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive");
if (! empty($conf->$module->enabled))
{
$modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive");
@ -419,7 +515,12 @@ elseif (! empty($module))
if ($tab == 'description')
{
print '<div class="underbanner clearboth"></div>';
$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong><br>';
print '<br>';
print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">';
print '<table class="border centpercent">';
@ -485,9 +586,132 @@ elseif (! empty($module))
if ($tab == 'objects')
{
print $langs->trans("FeatureNotYetAvailable");
$head3 = array();
$h=0;
// Dir for module
$dir = $dirins.'/'.$modulelowercase.'/class';
$head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj=newobject';
$head3[$h][1] = $langs->trans("NewObject");
$head3[$h][2] = 'newobject';
$h++;
$listofobject = dol_dir_list($dir , 'files', 0, '\.txt$');
foreach($listofobject as $fileobj)
{
$objectname = preg_replace('/\.txt$/', '', $fileobj['name']);
$head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj='.$objectname;
$head3[$h][1] = $objectname;
$head3[$h][2] = $objectname;
$h++;
}
dol_fiche_head($head3, $tabobj, '', -1, '');
if ($tabobj == 'newobject')
{
// New module
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="initobject">';
print '<input type="hidden" name="tab" value="objects">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print $langs->trans("EnterNameOfObjectDesc").'<br><br>';
print '<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'">';
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>';
print '</form>';
}
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 '<span class="fa fa-file"></span> '.$langs->trans("ClassFile").' : <strong>'.$pathtoclass.'</strong><br>';
print '<span class="fa fa-file"></span> '.$langs->trans("ApiClassFile").' : <strong>'.$pathtoapi.'</strong><br>';
print '<span class="fa fa-file"></span> '.$langs->trans("PageForList").' : <strong>'.$pathtolist.'</strong><br>';
print '<span class="fa fa-file"></span> '.$langs->trans("PageForCreateEditView").' : <strong>'.$pathtocard.'</strong><br>';
$result = dol_include_once($pathtoclass);
$tmpobjet = new $tabobj($db);
$reflector = new ReflectionClass($tabobj);
$properties = $reflector->getProperties();
$propdefault = $reflector->getDefaultProperties();
print load_fiche_titre($langs->trans("Properties"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="initobject">';
print '<input type="hidden" name="tab" value="objects">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Property").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("DefaultValue").'</td>';
print '<td></td>';
print '</tr>';
print '<tr>';
print '<td><input class="text" name="propname" value=""></td>';
print '<td><input class="text" name="propname" value=""></td>';
print '<td><input class="text" name="propname" value=""></td>';
print '<td><input class="text" name="propname" value=""></td>';
print '<td align="center">';
print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">';
print '</td></tr>';
foreach($properties as $propkey => $propval)
{
if ($propval->class == $tabobj)
{
$propname=$propval->getName();
// Discard generic properties
if (in_array($propname, array('element', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue;
// Keep or not lines
if (in_array($propname, array('fk_element', 'lines'))) continue;
print '<tr class="oddeven"><td>';
print $propname;
print '</td>';
print '<td>';
print '</td>';
print '<td>';
print '</td>';
print '<td>';
print $propdefault[$propname];
print '</td>';
print '<td>';
print '</td>';
print '</tr>';
}
}
print '</table>';
print '</form>';
}
catch(Exception $e)
{
print $e->getMessage();
}
}
}
if ($tab == 'menus')
@ -528,10 +752,9 @@ elseif (! empty($module))
$var=True;
foreach ($triggers as $trigger)
{
print '<tr class="oddeven">';
print '<td valign="top" width="14" align="center">'.$trigger['picto'].'</td>';
print '<td class="tdtop">'.$trigger['file'].'</td>';
print '<td class="tdtop">'.$trigger['relpath'].'</td>';
print '<td valign="top" align="center">'.$trigger['status'].'</td>';
print '<td class="tdtop">';
$text=$trigger['info'];
@ -560,11 +783,56 @@ elseif (! empty($module))
print '<br>';
}
$modulelowercase=strtolower($module);
// Zip file to build
$FILENAMEZIP='';
// Load module
dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php');
$class='mod'.$module;
if (class_exists($class))
{
try {
$moduleobj = new $class($db);
}
catch(Exception $e)
{
$error++;
dol_print_error($e->getMessage());
}
}
else
{
$error++;
$langs->load("errors");
dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module));
exit;
}
$arrayversion=explode('.',$moduleobj->version,3);
if (count($arrayversion))
{
$FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip";
$outputfile = $conf->admin->dir_temp.'/'.$FILENAMEZIP;
}
print '<span class="fa fa-file"></span> '. $langs->trans("PathToModulePackage") . ' : ';
if (! dol_is_file($outputfile)) print '<strong>'.$langs->trans("PackageFileNotYetGenerated").'</strong>';
else {
print '<strong>'.$outputfile.'</strong>';
print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')';
}
print '</strong><br>';
print '<br><br>';
print '<form name="generatepackage">';
print '<input type="hidden" name="action" value="generatepackage">';
print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="submit" class="button" value="'.$langs->trans("Generate").'">';
print '<input type="submit" class="button" value="'.$langs->trans("BuildPackage").'">';
print '</form>';
}

View File

@ -0,0 +1 @@
# If this file exists, it means the class and file for object MyOjbect was generated by ModuleBuilder.

View File

@ -21,8 +21,8 @@
/**
* \file htdocs/modulebuilder/template/class/myobject.class.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* \ingroup mymodule
* \brief This file is a CRUD class file for MyObject (Create/Read/Update/Delete)
*/
// Put here all includes required by your class file
@ -31,24 +31,22 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
/**
* Class MyModuleObject
*
* Put here description of your class.
* Class for MyObject
*/
class MyModuleObject extends CommonObject
class MyObject extends CommonObject
{
/**
* @var string Id to identify managed object
*/
public $element = 'mymoduleobject';
public $element = 'myobject';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'mymoduleobject';
public $table_element = 'myobject';
/**
* @var array Array with all fields and their property
*/
public $picto = 'generic';
public $picto = 'myobject';
/**
* @var array Array with all fields and their property
*/
@ -67,12 +65,12 @@ class MyModuleObject extends CommonObject
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $table_element_line = 'mymoduleobjectdet';
public $class_element_line = 'MyModuleObjectline';
public $fk_element = 'fk_mymoduleobject';
public $table_element_line = 'myobjectdet';
public $class_element_line = 'MyObjectline';
public $fk_element = 'fk_myobject';
/**
* @var MyModuleObjectLine[] Lines
* @var MyObjectLine[] Lines
*/
public $lines = array();

View File

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 360 B

View File

@ -67,48 +67,48 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
if ($cancel) $action='';
// Delete
if ($action == 'delete_confirm')
{
// Security check
if (!$user->rights->opensurvey->write) accessforbidden();
$result=$object->delete($user,'',$numsondage);
header('Location: '.dol_buildpath('/opensurvey/list.php',1));
exit();
}
// Close
if ($action == 'close')
{
$object->status = Opensurveysondage::STATUS_CLOSED;
$object->update($user);
}
// Reopend
if ($action == 'reopen')
{
$object->status = Opensurveysondage::STATUS_VALIDATED;
$object->update($user);
}
// Update
if ($action == 'update')
{
// Security check
if (!$user->rights->opensurvey->write) accessforbidden();
$error=0;
if (! GETPOST('nouveautitre'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
$error++;
$action = 'edit';
}
if (! $error)
{
$object->titre = GETPOST('nouveautitre');
@ -118,7 +118,7 @@ if (empty($reshook))
$object->allow_comments = GETPOST('cancomment') == 'on' ? true : false;
$object->allow_spy = GETPOST('canseeothersvote') == 'on' ? true : false;
$object->mailsonde = GETPOST('mailsonde') == 'on' ? true : false;
$res=$object->update($user);
if ($res < 0)
{
@ -132,7 +132,7 @@ if (empty($reshook))
if (GETPOST('ajoutcomment'))
{
$error=0;
if (! GETPOST('comment'))
{
$error++;
@ -143,33 +143,33 @@ if (empty($reshook))
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors');
}
if (! $error)
{
$comment = GETPOST("comment");
$comment_user = GETPOST('commentuser');
$resql = $object->addComment($comment, $comment_user);
if (! $resql)
{
setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors');
}
}
}
// Delete comment
$idcomment=GETPOST('deletecomment','int');
if ($idcomment)
{
// Security check
if (!$user->rights->opensurvey->write) accessforbidden();
$resql = $object->deleteComment($idcomment);
}
if ($action == 'edit') {
// Security check
if (!$user->rights->opensurvey->write) accessforbidden();
}
@ -307,7 +307,7 @@ print '</td></tr>';
// Expire date
print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">';
if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire',0,0,0,'',1,0,1);
else
else
{
print dol_print_date($object->date_fin,'day');
if ($object->date_fin && $object->date_fin < dol_now()) print img_warning($langs->trans("Expired"));
@ -377,7 +377,7 @@ if ($action != 'edit' && $user->rights->opensurvey->write) {
//Opened button
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=reopen&id=' . $numsondage . '">'.$langs->trans("ReOpen") . '</a>';
}
//Delete button
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?suppressionsondage=1&id='.$numsondage.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
@ -420,7 +420,7 @@ print '<br>';
// Add comment
if ($object->allow_comments) {
print $langs->trans("AddACommentForPoll") . '<br>';
print '<textarea name="comment" rows="2" cols="80"></textarea><br>'."\n";
print '<textarea name="comment" rows="2" class="quatrevingtpercent"></textarea><br>'."\n";
print $langs->trans("Name") .': <input type="text" size="50" name="commentuser" value="'.$user->getFullName($langs).'"><br>'."\n";
print '<input type="submit" class="button" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans("AddComment")).'"><br>'."\n";
if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide=="yes") {

View File

@ -307,7 +307,7 @@ class FormProduct
$return='';
$measuring_units=array();
if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,99=>1);
if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,98=>1,99=>1);
else if ($measuring_style == 'size') $measuring_units=array(-3=>1,-2=>1,-1=>1,0=>1,98=>1,99=>1);
else if ($measuring_style == 'surface') $measuring_units=array(-6=>1,-4=>1,-2=>1,0=>1,98=>1,99=>1);
else if ($measuring_style == 'volume') $measuring_units=array(-9=>1,-6=>1,-3=>1,0=>1,88=>1,89=>1,97=>1,99=>1,/* 98=>1 */); // Liter is not used as already available with dm3

View File

@ -203,7 +203,7 @@ if ($resql)
print '</div>';
print "</form>\n";
$db->free();
$db->free($resql);
}
else
{

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
*
* 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