diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 98b9f120a6d..210413b87f2 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -101,7 +101,7 @@ $hookmanager->initHooks(array('admin', 'dictionaryadmin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder = array(9, 15, 30, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 6, 24, 0, 29, 0, 33, 34, 32, 28, 17, 35, 36, 0, 10, 23, 12, 13, 7, 0, 14, 0, 22, 20, 18, 21, 41, 0, 37, 42, 0, 43, 0, 25, 0, 44, 0); +$taborder = array(9, 15, 30, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 6, 24, 0, 29, 0, 33, 34, 32, 28, 17, 35, 36, 0, 10, 31, 23, 12, 13, 7, 0, 14, 0, 22, 20, 18, 21, 41, 0, 37, 42, 0, 43, 0, 25, 0, 44, 0); // Name of SQL tables of dictionaries $tabname = array(); @@ -135,7 +135,7 @@ $tabname[27] = "c_stcomm"; $tabname[28] = "c_holiday_types"; $tabname[29] = "c_lead_status"; $tabname[30] = "c_format_cards"; -//$tabname[31]= "accounting_system"; +$tabname[31] = "c_invoice_subtype"; $tabname[32] = "c_hrm_public_holiday"; $tabname[33] = "c_hrm_department"; $tabname[34] = "c_hrm_function"; @@ -182,7 +182,7 @@ $tablib[27] = "DictionaryProspectStatus"; $tablib[28] = "DictionaryHolidayTypes"; $tablib[29] = "DictionaryOpportunityStatus"; $tablib[30] = "DictionaryFormatCards"; -//$tablib[31]= "DictionaryAccountancysystem"; +$tablib[31] = "DictionaryInvoiceSubtype"; $tablib[32] = "DictionaryPublicHolidays"; $tablib[33] = "DictionaryDepartment"; $tablib[34] = "DictionaryFunction"; @@ -205,10 +205,10 @@ $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as state_code, r.nom as lib $tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite, c.eec FROM ".MAIN_DB_PREFIX."c_country AS c"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; -$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1"; +$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays = c.rowid and c.active = 1"; $tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.position, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid"; $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c"; -$tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; +$tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays = c.rowid"; $tabsql[11] = "SELECT t.rowid as rowid, t.element, t.source, t.code, t.libelle, t.position, t.active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; $tabsql[12] = "SELECT c.rowid as rowid, c.code, c.libelle, c.libelle_facture, c.deposit_percent, c.nbjour, c.type_cdr, c.decalage, c.active, c.sortorder, c.entity FROM ".MAIN_DB_PREFIX."c_payment_term AS c WHERE c.entity = ".getEntity($tabname[12]); $tabsql[13] = "SELECT c.id as rowid, c.code, c.libelle, c.type, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_paiement AS c WHERE c.entity = ".getEntity($tabname[13]); @@ -229,7 +229,7 @@ $tabsql[27] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN $tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.sortorder, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; $tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; -//$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; +$tabsql[31] = "SELECT t.rowid, t.code, t.label, c.label as country, c.code as country_code, t.fk_country as country_id, t.active FROM ".MAIN_DB_PREFIX."c_invoice_subtype as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_country = c.rowid"; $tabsql[32] = "SELECT a.id as rowid, a.entity, a.code, a.fk_country as country_id, c.code as country_code, c.label as country, a.dayrule, a.day, a.month, a.year, a.active FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday as a LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country=c.rowid AND c.active=1"; $tabsql[33] = "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; $tabsql[34] = "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; @@ -276,7 +276,7 @@ $tabsqlsort[27] = "code ASC"; $tabsqlsort[28] = "sortorder ASC, country ASC, code ASC"; $tabsqlsort[29] = "position ASC"; $tabsqlsort[30] = "code ASC"; -//$tabsqlsort[31]="pcg_version ASC"; +$tabsqlsort[31] = "country ASC, code ASC"; $tabsqlsort[32] = "country, year ASC, month ASC, day ASC"; $tabsqlsort[33] = "code ASC"; $tabsqlsort[34] = "code ASC"; @@ -323,7 +323,7 @@ $tabfield[27] = "code,libelle,picto"; $tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative,sortorder"; $tabfield[29] = "code,label,percent,position"; $tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; -//$tabfield[31]= "pcg_version,label"; +$tabfield[31] = "country_id,country,code,label"; $tabfield[32] = "code,dayrule,year,month,day,country_id,country"; $tabfield[33] = "code,label"; $tabfield[34] = "code,label"; @@ -370,7 +370,7 @@ $tabfieldvalue[27] = "code,libelle,picto"; $tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative,sortorder"; $tabfieldvalue[29] = "code,label,percent,position"; $tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; -//$tabfieldvalue[31]= "pcg_version,label"; +$tabfieldvalue[31] = "country,code,label"; $tabfieldvalue[32] = "code,dayrule,day,month,year,country"; $tabfieldvalue[33] = "code,label"; $tabfieldvalue[34] = "code,label"; @@ -417,8 +417,7 @@ $tabfieldinsert[27] = "code,libelle,picto"; $tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative,sortorder"; $tabfieldinsert[29] = "code,label,percent,position"; $tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; -//$tabfieldinsert[31]= "pcg_version,label"; -//$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country"; +$tabfieldinsert[31] = "fk_country,code,label"; $tabfieldinsert[32] = "code,dayrule,day,month,year,fk_country"; $tabfieldinsert[33] = "code,label"; $tabfieldinsert[34] = "code,label"; @@ -467,7 +466,7 @@ $tabrowid[27] = "id"; $tabrowid[28] = ""; $tabrowid[29] = ""; $tabrowid[30] = ""; -//$tabrowid[31]= ""; +$tabrowid[31]= ""; $tabrowid[32] = "id"; $tabrowid[33] = "rowid"; $tabrowid[34] = "rowid"; @@ -514,7 +513,7 @@ $tabcond[27] = isModEnabled("societe"); $tabcond[28] = isModEnabled('holiday'); $tabcond[29] = isModEnabled('project'); $tabcond[30] = (isModEnabled('label') || isModEnabled('barcode') || isModEnabled('adherent')); // stickers format dictionary -//$tabcond[31]= isModEnabled('accounting'); +$tabcond[31] = ((isModEnabled('facture') || isModEnabled('supplier_invoice')) && $mysoc->country_code == 'GR'); $tabcond[32] = (isModEnabled('holiday') || isModEnabled('hrm')); $tabcond[33] = isModEnabled('hrm'); $tabcond[34] = isModEnabled('hrm'); @@ -576,6 +575,7 @@ $tabcomplete = array( 'c_product_nature'=>array('picto'=>'product', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), 'c_productbatch_qcstatus'=>array('picto'=>'lot', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), 'c_asset_disposal_type'=>array('picto'=>'asset', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), + 'c_invoice_subtype'=>array('picto'=>'bill', 'help'=>array('code'=>$langs->trans("EnterAnyCode"))), ); @@ -714,7 +714,7 @@ if (empty($reshook)) { $ok = 1; foreach ($listfield as $f => $value) { // Discard check of mandatory fields for country for some tables - if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) { + if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryInvoiceSubtype', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) { continue; // For some pages, country is not mandatory } if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp'))) { @@ -1201,7 +1201,7 @@ if ($search_country_id > 0) { $param .= '&search_country_id='.urlencode($search_country_id); } if ($search_code != '') { - $param .= '&search_code='.urlencode($search_country_id); + $param .= '&search_code='.urlencode($search_code); } if ($entity != '') { $param .= '&entity='.(int) $entity; @@ -1580,7 +1580,9 @@ if ($id > 0) { } print ''; if ($action != 'edit') { - print ''; + print ''; + } else { + print ''; } print ''; @@ -1614,13 +1616,44 @@ if ($id > 0) { print '
'; } + $filterfound = 0; + foreach ($fieldlist as $field => $value) { + if ($value == 'entity') { + continue; + } + + $showfield = 1; // By default + if ($value == 'region_id' || $value == 'country_id') { + $showfield = 0; + } + + if ($showfield) { + if ($value == 'country') { + $filterfound++; + } elseif ($value == 'code') { + $filterfound++; + } + } + } + print '
'; print ''; // Title line with search input fields print ''."\n"; print ''; - $filterfound = 0; + + // Action button + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + $colspan++; + } + $colspan = 0; foreach ($fieldlist as $field => $value) { if ($value == 'entity') { @@ -1628,7 +1661,6 @@ if ($id > 0) { } $showfield = 1; // By default - if ($value == 'region_id' || $value == 'country_id') { $showfield = 0; } @@ -1638,13 +1670,11 @@ if ($id > 0) { print ''; - $filterfound++; $colspan++; } elseif ($value == 'code') { print ''; - $filterfound++; $colspan++; } else { print ''; $colspan++; } + print ''; $colspan++; - print ''; + $colspan++; } - print ''; - $colspan+=2; + print ''; // Title of lines print ''."\n"; print ''; + + // Action button + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(''); + } + foreach ($fieldlist as $field => $value) { if ($value == 'entity') { continue; @@ -1904,9 +1946,13 @@ if ($id > 0) { print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); } + // Status print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); - print getTitleFieldOfList(''); - print getTitleFieldOfList(''); + + // Action button + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(''); + } print ''; if ($num) { @@ -1914,9 +1960,76 @@ if ($id > 0) { while ($i < $num) { $obj = $db->fetch_object($resql); + // Can an entry be erased or disabled ? + // all true by default + $iserasable = 1; + $canbedisabled = 1; + $canbemodified = 1; + if (isset($obj->code) && $id != 10 && $id != 42) { + if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { + $iserasable = 0; $canbedisabled = 0; + } elseif ($obj->code == 'RECEP') { + $iserasable = 0; $canbedisabled = 0; + } elseif ($obj->code == 'EF0') { + $iserasable = 0; $canbedisabled = 0; + } + } + if ($id == 25 && in_array($obj->code, array('banner', 'blogpost', 'other', 'page'))) { + $iserasable = 0; $canbedisabled = 0; + if (in_array($obj->code, array('banner'))) { + $canbedisabled = 1; + } + } + if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { + $iserasable = 0; + } + if (in_array(empty($obj->code) ? '' : $obj->code, array('AC_OTH', 'AC_OTH_AUTO')) || in_array(empty($obj->type) ? '' : $obj->type, array('systemauto'))) { + $canbedisabled = 0; $canbedisabled = 0; + } + $canbemodified = $iserasable; + + if (!empty($obj->code) && $obj->code == 'RECEP') { + $canbemodified = 1; + } + if ($tabname[$id] == "c_actioncomm") { + $canbemodified = 1; + } + + // Build Url. The table is id=, the id of line is rowid= + $rowidcol = $tabrowid[$id]; + // If rowidcol not defined + if (empty($rowidcol) || in_array($id, array(6, 7, 8, 13, 17, 19, 27, 32))) { + $rowidcol = 'rowid'; + } + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(isset($obj->{$rowidcol}) ? $obj->{$rowidcol} : (!empty($obj->code) ? urlencode($obj->code) : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + if (!empty($param)) { + $url .= '&'.$param; + } + if (!is_null($withentity)) { + $url .= '&entity='.$withentity; + } + $url .= '&'; + + //print_r($obj); print ''; + // Action button + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { $tmpaction = 'edit'; $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); @@ -2151,56 +2264,6 @@ if ($id > 0) { } } - // Can an entry be erased or disabled ? - // all true by default - $iserasable = 1; - $canbedisabled = 1; - $canbemodified = 1; - if (isset($obj->code) && $id != 10 && $id != 42) { - if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { - $iserasable = 0; $canbedisabled = 0; - } elseif ($obj->code == 'RECEP') { - $iserasable = 0; $canbedisabled = 0; - } elseif ($obj->code == 'EF0') { - $iserasable = 0; $canbedisabled = 0; - } - } - if ($id == 25 && in_array($obj->code, array('banner', 'blogpost', 'other', 'page'))) { - $iserasable = 0; $canbedisabled = 0; - if (in_array($obj->code, array('banner'))) { - $canbedisabled = 1; - } - } - if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) { - $iserasable = 0; - } - if (in_array(empty($obj->code) ? '' : $obj->code, array('AC_OTH', 'AC_OTH_AUTO')) || in_array(empty($obj->type) ? '' : $obj->type, array('systemauto'))) { - $canbedisabled = 0; $canbedisabled = 0; - } - $canbemodified = $iserasable; - - if (!empty($obj->code) && $obj->code == 'RECEP') { - $canbemodified = 1; - } - if ($tabname[$id] == "c_actioncomm") { - $canbemodified = 1; - } - - // Build Url. The table is id=, the id of line is rowid= - $rowidcol = $tabrowid[$id]; - // If rowidcol not defined - if (empty($rowidcol) || in_array($id, array(6, 7, 8, 13, 17, 19, 27, 32))) { - $rowidcol = 'rowid'; - } - $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(isset($obj->{$rowidcol}) ? $obj->{$rowidcol} : (!empty($obj->code) ? urlencode($obj->code) : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); - if (!empty($param)) { - $url .= '&'.$param; - } - if (!is_null($withentity)) { - $url .= '&entity='.$withentity; - } - $url .= '&'; - // Favorite & EEC // Only activated on country dictionary if ($id == 4) { @@ -2239,23 +2302,20 @@ if ($id > 0) { } print ""; - // Modify link - if ($canbemodified) { - print ''; - } else { - print ''; - } - - // Delete link - if ($iserasable) { - print ''; - } else { - print ''; } print "\n";
'; + if ($filterfound) { + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + } + print ''; print $form->select_country($search_country_id, 'search_country_id', '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone'); print ''; print ''; print ''; @@ -1659,20 +1689,32 @@ if ($id > 0) { print ''; - if ($filterfound) { - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; + + // Action button + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($filterfound) { + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + } + print '
'; + // Modify link + if ($canbemodified) { + print ''.img_edit().''; + } + // Delete link + if ($iserasable) { + if ($user->admin) { + print ''.img_delete().''; + } + } + print ''.img_edit().' '; - if ($user->admin) { - print ''.img_delete().''; + // Action button + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + // Modify link + if ($canbemodified) { + print ''.img_edit().''; + } + // Delete link + if ($iserasable) { + if ($user->admin) { + print ''.img_delete().''; + } } - //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin print '