diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 5c17f07183e..66f2e156b4c 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -87,9 +87,6 @@ $hookmanager->initHooks(array('admin')); // This page is a generic page to edit dictionaries // 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,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26,0,31,32,0); - // Name of SQL tables of dictionaries $tabname=array(); @@ -148,75 +145,10 @@ $tabfieldcheck=array(); $tabfieldcheck[31] = array(); $tabfieldcheck[32] = array(); -// Complete all arrays with entries found into modules -complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck); - // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); $sourceList=array(); -if ($id == 11) -{ - $langs->load("orders"); - $langs->load("contracts"); - $langs->load("projects"); - $langs->load("propal"); - $langs->load("bills"); - $langs->load("interventions"); - $elementList = array( - '' => '', - 'societe' => $langs->trans('ThirdParty'), -// 'proposal' => $langs->trans('Proposal'), -// 'order' => $langs->trans('Order'), -// 'invoice' => $langs->trans('Bill'), - 'invoice_supplier' => $langs->trans('SupplierBill'), - 'order_supplier' => $langs->trans('SupplierOrder'), -// 'intervention' => $langs->trans('InterventionCard'), -// 'contract' => $langs->trans('Contract'), - 'project' => $langs->trans('Project'), - 'project_task' => $langs->trans('Task'), - 'agenda' => $langs->trans('Agenda'), - // old deprecated - 'contrat' => $langs->trans('Contract'), - 'propal' => $langs->trans('Proposal'), - 'commande' => $langs->trans('Order'), - 'facture' => $langs->trans('Bill'), - 'resource' => $langs->trans('Resource'), -// 'facture_fourn' => $langs->trans('SupplierBill'), - 'fichinter' => $langs->trans('InterventionCard') - ); - if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); - - complete_elementList_with_modules($elementList); - - asort($elementList); - $sourceList = array( - 'internal' => $langs->trans('Internal'), - 'external' => $langs->trans('External') - ); -} -if ($id == 25) -{ - // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']" - $elementList = array(); - if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal'); - if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder'); - if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice'); - if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment'); - if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention'); - if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation'); - if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder'); - if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); - if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); - - $parameters=array('elementList'=>$elementList); - $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks - if ($reshook == 0) { - foreach ($hookmanager->resArray as $item => $value) { - $elementList[$item] = $value; - } - } -} @@ -690,7 +622,6 @@ if ($id) if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } - if ($id == 4) print ''; print ''; print ''; print ''; @@ -731,7 +662,6 @@ if ($id) } } - if ($id == 4) print ''; print ''; if ($tabname[$id] != MAIN_DB_PREFIX.'c_email_templates' || $action != 'edit') { @@ -741,9 +671,8 @@ if ($id) print ""; $colspan=count($fieldlist)+3; - if ($id == 4) $colspan++; - if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of * + if (! empty($alabelisused)) // If there is one label among fields, we show legend of * { print '* '.$langs->trans("LabelUsedByDefault").'.'; } @@ -775,9 +704,38 @@ if ($id) print ''; } - // Title of lines + // Title line with search boxes print ''; foreach ($fieldlist as $field => $value) + { + $showfield=1; // By defaut + + if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } + + if ($showfield) + { + if ($value == 'country') + { + print ''; + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); + print ''; + } + else + { + print ''; + } + } + } + print ''; + print ''; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print ''; + print ''; + + // Title of lines + print ''; + foreach ($fieldlist as $field => $value) { // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de donnees @@ -845,44 +803,11 @@ if ($id) print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); } } - // Favorite - Only activated on country dictionary - if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print ''; - // Title line with search boxes - print ''; - foreach ($fieldlist as $field => $value) - { - $showfield=1; // By defaut - - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } - - if ($showfield) - { - if ($value == 'country') - { - print ''; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); - print ''; - } - else - { - print ''; - } - } - } - if ($id == 4) print ''; - print ''; - print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; - print ''; - if ($num) { // Lines with values @@ -1090,16 +1015,6 @@ if ($id) if ($param) $url .= '&'.$param; $url.='&'; - // Favorite - // Only activated on country dictionary - if ($id == 4) - { - print ''; - if ($iserasable) print ''.$actl[$obj->favorite].''; - else print $langs->trans("AlwaysActive"); - print ''; - } - // Active print ''; if ($canbedisabled) print ''.$actl[$obj->active].''; @@ -1135,65 +1050,6 @@ if ($id) print ''; } -else -{ - /* - * Show list of dictionary to show - */ - - $lastlineisempty=false; - print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - - $showemptyline=''; - foreach ($taborder as $i) - { - if (isset($tabname[$i]) && empty($tabcond[$i])) continue; - - if ($i) - { - if ($showemptyline) - { - print ''; - $showemptyline=0; - } - - - $value=$tabname[$i]; - print ''; - print ''; - print ''; - $lastlineisempty=false; - } - else - { - if (! $lastlineisempty) - { - $showemptyline=1; - $lastlineisempty=true; - } - } - } - print '
'.$langs->trans("Module").''.$langs->trans("Dictionary").''.$langs->trans("Table").'
   
'; - if (! empty($tabcond[$i])) - { - print ''.$langs->trans($tablib[$i]).''; - } - else - { - print $langs->trans($tablib[$i]); - } - print ''; - /*if (empty($tabcond[$i])) - { - print info_admin($langs->trans("DictionaryDisabledSinceNoModuleNeedIt"),1); - }*/ - print ''.$tabname[$i].'
'; -} print '
'; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 2271fa73c0b..9bbd37449be 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -354,6 +354,7 @@ if ($action == $acts[1]) } } + /* * View */ @@ -527,8 +528,25 @@ if ($id) print ''; } + // Title line with search boxes + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($filterfound) + { + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; + } + print ''; + print ''; + // Title of lines - print ''; + print ''; foreach ($fieldlist as $field => $value) { // Determine le nom du champ par rapport aux noms possibles @@ -562,23 +580,6 @@ if ($id) print getTitleFieldOfList(''); print ''; - // Title line with search boxes - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($filterfound) - { - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - } - print ''; - print ''; - if ($num) { // Lines with values diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 8a1c704f87b..0f9081bdc98 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -100,9 +100,9 @@ $sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ? $sql .= " AND fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; } else { - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; } if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; @@ -277,7 +277,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 32a29177a37..42fbb7ff681 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -295,7 +295,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->thirdparty_code = $companystatic->code_client; + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; @@ -550,12 +550,12 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { - print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); - print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } print '
'; if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { - print ''; + print ''; } else { print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 037d27ea852..d5fed99701e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -419,7 +419,7 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " civility = ".($this->civility_id>0?$this->db->escape($this->civility_id):"null"); + $sql.= " civility = ".($this->civility_id?"'".$this->db->escape($this->civility_id)."'":"null"); $sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null"); $sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null"); $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null"); @@ -1954,49 +1954,102 @@ class Adherent extends CommonObject * * @return array Tableau info des attributs */ - function _load_ldap_info() - { - global $conf,$langs; + function _load_ldap_info() + { + global $conf,$langs; - $info=array(); + $info=array(); + $keymodified=false; - // Object classes - $info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS); + // Object classes + $info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS); - $this->fullname=$this->getFullName($langs); + $this->fullname=$this->getFullName($langs); - // Member - if ($this->fullname && ! empty($conf->global->LDAP_MEMBER_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FULLNAME] = $this->fullname; - if ($this->lastname && ! empty($conf->global->LDAP_MEMBER_FIELD_NAME)) $info[$conf->global->LDAP_MEMBER_FIELD_NAME] = $this->lastname; - if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname; - if ($this->login && ! empty($conf->global->LDAP_MEMBER_FIELD_LOGIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LOGIN] = $this->login; - if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte - if ($this->pass && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // md5 for OpenLdap TODO add type of encryption - if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; - if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; - if ($this->zip && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; - if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; - if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; - if ($this->email && ! empty($conf->global->LDAP_MEMBER_FIELD_MAIL)) $info[$conf->global->LDAP_MEMBER_FIELD_MAIL] = $this->email; - if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; - if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; - if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; - if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; - if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; - if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note_private; - if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = $this->note_public; - if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap'); - if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; - if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap'); + // For avoid ldap error when firstname and lastname are empty + if ($this->morphy == 'mor' && empty($this->fullname)) { + $this->fullname = $this->societe; + $this->lastname = $this->societe; + } - // Subscriptions - if ($this->first_subscription_date && ! empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date,'dayhourldap'); - if (isset($this->first_subscription_amount) && ! empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount; - if ($this->last_subscription_date && ! empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date,'dayhourldap'); - if (isset($this->last_subscription_amount) && ! empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount; + // Possible LDAP KEY (constname => varname) + $ldapkey = array( + 'LDAP_MEMBER_FIELD_FULLNAME' => 'fullname', + 'LDAP_MEMBER_FIELD_NAME' => 'lastname', + 'LDAP_MEMBER_FIELD_LOGIN' => 'login', + 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login', + 'LDAP_MEMBER_FIELD_MAIL' => 'email' + ); - return $info; - } + // Member + foreach ($ldapkey as $constname => $varname) + { + if (! empty($this->$varname) && ! empty($conf->global->$constname)) + { + $info[$conf->global->$constname] = $this->$varname; + + // Check if it is the LDAP key and if its value has been changed + if (! empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) + { + if (! empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) $keymodified=true; // For check if LDAP key has been modified + } + } + } + if ($this->firstname && ! empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname; + if ($this->poste && ! empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; + if ($this->societe && ! empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->societe; + if ($this->address && ! empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; + if ($this->zip && ! empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; + if ($this->town && ! empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; + if ($this->country_code && ! empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; + if ($this->skype && ! empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; + if ($this->phone && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; + if ($this->phone_perso && ! empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; + if ($this->phone_mobile && ! empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; + if ($this->fax && ! empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; + if ($this->note_private && ! empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note_private; + if ($this->note_public && ! empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = $this->note_public; + if ($this->birth && ! empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth,'dayhourldap'); + if (isset($this->statut) && ! empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; + if ($this->datefin && ! empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap'); + + // When password is modified + if (! empty($this->pass)) + { + if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte + if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) + } + // Set LDAP password if possible + else if ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password + { + if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) + { + // Just for the default MD5 ! + if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) + { + if ($this->pass_indatabase_crypted && ! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { + // Create OpenLDAP MD5 password from Dolibarr MD5 password + // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" + $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}'.base64_encode(hex2bin($this->pass_indatabase_crypted)); + } + } + } + // Use $this->pass_indatabase value if exists + else if (! empty($this->pass_indatabase)) + { + if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte + if (! empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption + } + } + + // Subscriptions + if ($this->first_subscription_date && ! empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date,'dayhourldap'); + if (isset($this->first_subscription_amount) && ! empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount; + if ($this->last_subscription_date && ! empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date,'dayhourldap'); + if (isset($this->last_subscription_amount) && ! empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount; + + return $info; + } /** diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 89985c51f0c..ff0bad063bd 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -59,26 +59,23 @@ if (! $result) if ($action == 'dolibarr2ldap') { - $db->begin(); - $ldap=new Ldap(); $result=$ldap->connect_bind(); - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info); - $olddn=$dn; // We can say that old dn = dn as we force synchro - - $result=$ldap->update($dn,$info,$user,$olddn); - - if ($result >= 0) + if ($result > 0) { - setEventMessages($langs->trans("MemberSynchronized"), null, 'mesgs'); - $db->commit(); + $info=$object->_load_ldap_info(); + $dn=$object->_load_ldap_dn($info); + $olddn=$dn; // We can say that old dn = dn as we force synchro + + $result=$ldap->update($dn,$info,$user,$olddn); } - else - { + + if ($result >= 0) { + setEventMessages($langs->trans("MemberSynchronized"), null, 'mesgs'); + } + else { setEventMessages($ldap->errors, $ldap->error, 'errors'); - $db->rollback(); } } diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index bd84c1d6339..517c57c7d0b 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -1,10 +1,10 @@ +/* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2013 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2017 Philippe Grand - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -45,10 +45,18 @@ if (! $user->admin) accessforbidden(); $error=0; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$contextpage=array('admincompany','globaladmin'); +$hookmanager->initHooks($contextpage); + /* * 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 ( ($action == 'update' && ! GETPOST("cancel",'alpha')) || ($action == 'updateedit') ) { diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index cad37cc4ccc..da04c852b2f 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005 Regis Houssin - * Copyright (C) 2006-2008 Laurent Destailleur - * Copyright (C) 2011-2013 Juanjo Menent +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2006-2008 Laurent Destailleur + * Copyright (C) 2011-2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,6 +68,7 @@ if ($action == 'setvalue' && $user->admin) if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY',GETPOST("fieldcompany"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP',GETPOST("fieldzip"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN',GETPOST("fieldtown"),'chaine',0,'',$conf->entity)) $error++; @@ -282,6 +283,14 @@ print ''.$langs->trans("LDAPFieldFaxExample").''; print ' '; print ''; +// Company + +print ''.$langs->trans("LDAPFieldCompany").''; +print ''; +print ''.$langs->trans("LDAPFieldCompanyExample").''; +print ' '; +print ''; + // Address print ''.$langs->trans("LDAPFieldAddress").''; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index a0866c1305a..30ec8d8153c 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -65,6 +65,11 @@ if ($action == 'setvalue' && $user->admin) if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_FIELD_COMPANY',GETPOST("fieldcompany"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP',GETPOST("fieldzip"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN',GETPOST("fieldtown"),'chaine',0,'',$conf->entity)) $error++; + if (! dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY',GETPOST("fieldcountry"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_SID',GETPOST("fieldsid"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_FIELD_TITLE',GETPOST("fieldtitle"),'chaine',0,'',$conf->entity)) $error++; @@ -208,7 +213,7 @@ print ''; print ''.$langs->trans("LDAPFieldPasswordNotCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PASSWORD)?' checked':'').">"; +print ' '; print ''; // Password crypted @@ -216,7 +221,7 @@ print ''; print ''.$langs->trans("LDAPFieldPasswordCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PASSWORD_CRYPTED)?' checked':'').">"; +print ' '; print ''; // Mail @@ -259,12 +264,52 @@ print ''.$langs->trans("LDAPFieldFaxExample").''; print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FAX)?' checked':'').">"; print ''; +// Company + +print ''.$langs->trans("LDAPFieldCompany").''; +print ''; +print ''.$langs->trans("LDAPFieldCompanyExample").''; +print ' '; +print ''; + +// Address + +print ''.$langs->trans("LDAPFieldAddress").''; +print ''; +print ''.$langs->trans("LDAPFieldAddressExample").''; +print ' '; +print ''; + +// ZIP + +print ''.$langs->trans("LDAPFieldZip").''; +print ''; +print ''.$langs->trans("LDAPFieldZipExample").''; +print ' '; +print ''; + +// TOWN + +print ''.$langs->trans("LDAPFieldTown").''; +print ''; +print ''.$langs->trans("LDAPFieldTownExample").''; +print ' '; +print ''; + +// COUNTRY + +print ''.$langs->trans("LDAPFieldCountry").''; +print ''; +print ' '; +print ' '; +print ''; + // Title print ''.$langs->trans("LDAPFieldTitle").''; print ''; print ''.$langs->trans("LDAPFieldTitleExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_TITLE)?' checked':'').">"; +print ' '; print ''; // Note @@ -272,7 +317,7 @@ print ''; print ''.$langs->trans("Note").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").''; -print 'global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_DESCRIPTION)?' checked':'').">"; +print ' '; print ''; // Sid diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 123b5f50bd8..8c170cc78ad 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -33,49 +33,49 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; class Documents extends DolibarrApi { - /** - * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object - */ - static $DOCUMENT_FIELDS = array( - 'modulepart' - ); + /** + * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object + */ + static $DOCUMENT_FIELDS = array( + 'modulepart' + ); - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } + /** + * Constructor + */ + function __construct() + { + global $db; + $this->db = $db; + } - /** - * Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download - * a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie). - * - * @param string $module_part Name of module or area concerned by file download ('facture', ...) - * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) - * @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases. - * Also, note that setting this to 1 nead write access on object. - * @return array List of documents - * - * @throws 500 - * @throws 501 - * @throws 400 - * @throws 401 - * @throws 200 - */ - public function index($module_part, $original_file='', $regeneratedoc=0) - { + /** + * Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download + * a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie). + * + * @param string $module_part Name of module or area concerned by file download ('facture', ...) + * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) + * @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases. + * Also, note that setting this to 1 nead write access on object. + * @return array List of documents + * + * @throws 500 + * @throws 501 + * @throws 400 + * @throws 401 + * @throws 200 + */ + public function index($module_part, $original_file='', $regeneratedoc=0) + { global $conf; if (empty($module_part)) { - throw new RestException(400, 'bad value for parameter modulepart'); + throw new RestException(400, 'bad value for parameter modulepart'); + } + if (empty($original_file)) { + throw new RestException(400, 'bad value for parameter ref or subdir'); } - if (empty($original_file)) { - throw new RestException(400, 'bad value for parameter ref or subdir'); - } //--- Finds and returns the document $entity=$conf->entity; @@ -183,37 +183,37 @@ class Documents extends DolibarrApi $entity = $user->entity; if ($ref) { - if ($modulepart == 'facture' || $modulepart == 'invoice') - { - $modulepart='facture'; - $object=new Facture($db); - $result = $object->fetch('', $ref); - } + if ($modulepart == 'facture' || $modulepart == 'invoice') + { + $modulepart='facture'; + $object=new Facture($db); + $result = $object->fetch('', $ref); + } - if (! ($object->id > 0)) - { - throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); - } + if (! ($object->id > 0)) + { + throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); + } - $tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write'); - $upload_dir = $tmp['original_file']; + $tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write'); + $upload_dir = $tmp['original_file']; - if (empty($upload_dir) || $upload_dir == '/') - { - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); - } + if (empty($upload_dir) || $upload_dir == '/') + { + throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); + } } else { - if ($modulepart == 'invoice') $modulepart ='facture'; + if ($modulepart == 'invoice') $modulepart ='facture'; - $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); - $upload_dir = $tmp['original_file']; + $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); + $upload_dir = $tmp['original_file']; - if (empty($upload_dir) || $upload_dir == '/') - { - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); - } + if (empty($upload_dir) || $upload_dir == '/') + { + throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); + } } @@ -223,46 +223,46 @@ class Documents extends DolibarrApi $destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file; dol_delete_file($destfiletmp); - if (!dol_is_dir($upload_dir)) { - throw new RestException(401,'Directory not exists : '.$upload_dir); - } + if (!dol_is_dir($upload_dir)) { + throw new RestException(401,'Directory not exists : '.$upload_dir); + } - if (! $overwriteifexists && dol_is_file($destfile)) - { - throw new RestException(500, "File with name '".$original_file."' already exists."); - } + if (! $overwriteifexists && dol_is_file($destfile)) + { + throw new RestException(500, "File with name '".$original_file."' already exists."); + } - $fhandle = @fopen($destfiletmp, 'w'); - if ($fhandle) - { - $nbofbyteswrote = fwrite($fhandle, $newfilecontent); - fclose($fhandle); - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); - } - else - { - throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); - } + $fhandle = @fopen($destfiletmp, 'w'); + if ($fhandle) + { + $nbofbyteswrote = fwrite($fhandle, $newfilecontent); + fclose($fhandle); + @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); + } + else + { + throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); + } - $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); + $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); - return $result; - } + return $result; + } - /** - * Validate fields before create or update object - * - * @param array $data Array with data to verify - * @return array - * @throws RestException - */ - function _validate_file($data) { - $result = array(); - foreach (Documents::$DOCUMENT_FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $result[$field] = $data[$field]; - } - return $result; - } + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + function _validate_file($data) { + $result = array(); + foreach (Documents::$DOCUMENT_FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $result[$field] = $data[$field]; + } + return $result; + } } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a7540c69840..d127b0b0e09 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1690,7 +1690,15 @@ if ($action == 'create') //array('type' => 'other','name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '')); array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => $object->note_private)); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetAcceptedRefused'), '', 'setstatut', $formquestion, '', 1, 250); + if (! empty($conf->notification->enabled)) { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $formquestion = array_merge($formquestion, array( + array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)), + )); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250); } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 46ac4cf0327..f719dbf7ea8 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -239,21 +239,25 @@ class Proposals extends DolibarrApi * * @return int */ - function postLine($id, $request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + function postLine($id, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); - } + } - $result = $this->propal->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Commercial Proposal not found'); - } + $result = $this->propal->fetch($id); + if (! $result) { + throw new RestException(404, 'Commercial Proposal not found'); + } - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->propal->addline( + if (! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) + { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $request_data = (object) $request_data; + + $updateRes = $this->propal->addline( $request_data->desc, $request_data->subprice, $request_data->qty, @@ -300,43 +304,52 @@ class Proposals extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { - throw new RestException(401); - } + function putLine($id, $lineid, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->propal->creer) { + throw new RestException(401); + } - $result = $this->propal->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Proposal not found'); - } + $result = $this->propal->fetch($id); + if($result <= 0) { + throw new RestException(404, 'Proposal not found'); + } - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->propal->updateline( + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $request_data = (object) $request_data; + + $propalline = new PropaleLigne($this->db); + $result = $propalline->fetch($lineid); + if ($result <= 0) { + throw new RestException(404, 'Proposal line not found'); + } + + $updateRes = $this->propal->updateline( $lineid, - $request_data->subprice, - $request_data->qty, - $request_data->remise_percent, - $request_data->tva_tx, - $request_data->localtax1_tx, - $request_data->localtax2_tx, - $request_data->desc, + isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, + isset($request_data->qty)?$request_data->qty:$propalline->qty, + isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, + isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, + isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, + isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, + isset($request_data->desc)?$request_data->desc:$propalline->desc, 'HT', - $request_data->info_bits, - $request_data->special_code, - $request_data->fk_parent_line, + isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, + isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, + isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, 0, - $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->label, - $request_data->product_type, - $request_data->date_start, - $request_data->date_end, - $request_data->array_options, - $request_data->fk_unit, - $request_data->multicurrency_subprice + isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, + isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, + isset($request_data->label)?$request_data->label:$propalline->label, + isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, + isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, + isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, + isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, + isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, + isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice ); if ($updateRes > 0) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 230a855bafc..5b9fda29a6d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3654,59 +3654,66 @@ class PropaleLigne extends CommonObjectLine { $objp = $this->db->fetch_object($result); - $this->id = $objp->rowid; - $this->rowid = $objp->rowid; // deprecated - $this->fk_propal = $objp->fk_propal; - $this->fk_parent_line = $objp->fk_parent_line; - $this->label = $objp->custom_label; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->price = $objp->price; // deprecated - $this->subprice = $objp->subprice; - $this->vat_src_code = $objp->vat_src_code; - $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; // deprecated - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->info_bits = $objp->info_bits; + if ($objp) + { + $this->id = $objp->rowid; + $this->rowid = $objp->rowid; // deprecated + $this->fk_propal = $objp->fk_propal; + $this->fk_parent_line = $objp->fk_parent_line; + $this->label = $objp->custom_label; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->price = $objp->price; // deprecated + $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; + $this->tva_tx = $objp->tva_tx; + $this->remise = $objp->remise; // deprecated + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; - $this->fk_fournprice = $objp->fk_fournprice; + $this->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); - $this->pa_ht = $marginInfos[0]; - $this->marge_tx = $marginInfos[1]; - $this->marque_tx = $marginInfos[2]; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); + $this->pa_ht = $marginInfos[0]; + $this->marge_tx = $marginInfos[1]; + $this->marque_tx = $marginInfos[2]; - $this->special_code = $objp->special_code; - $this->product_type = $objp->product_type; - $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->product_type = $objp->product_type; + $this->rang = $objp->rang; - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; - $this->product_desc = $objp->product_desc; - $this->fk_unit = $objp->fk_unit; + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; + $this->product_desc = $objp->product_desc; + $this->fk_unit = $objp->fk_unit; - $this->date_start = $this->db->jdate($objp->date_start); - $this->date_end = $this->db->jdate($objp->date_end); + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); - // Multicurrency - $this->fk_multicurrency = $objp->fk_multicurrency; - $this->multicurrency_code = $objp->multicurrency_code; - $this->multicurrency_subprice = $objp->multicurrency_subprice; - $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva = $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + // Multicurrency + $this->fk_multicurrency = $objp->fk_multicurrency; + $this->multicurrency_code = $objp->multicurrency_code; + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $this->db->free($result); + $this->db->free($result); - return 1; + return 1; + } + else + { + return 0; + } } else { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index f16fec910b4..352e1db5e6b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -324,11 +324,11 @@ if ($action == 'create') // Ref print ''.$langs->trans("Ref").''; - print 'ref).'" maxlength="12">'; + print 'ref).'" maxlength="12" autofocus>'; // Label print ''.$langs->trans("LabelBankCashAccount").''; - print ''; + print ''; // Type print ''.$langs->trans("AccountType").''; @@ -349,7 +349,7 @@ if ($action == 'create') // Status print ''.$langs->trans("Status").''; print ''; - print $form->selectarray("clos", $object->status,(isset($_POST["clos"])?$_POST["clos"]:$object->clos)); + print $form->selectarray("clos", $object->status,(GETPOST("clos",'int')!=''?GETPOST("clos",'int'):$object->clos)); print ''; // Country diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index bf54e4f58ab..3d2daf5a53d 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -74,7 +74,7 @@ if ($mode == 'customer') if ($mode == 'supplier') { $title=$langs->trans("BillsStatisticsSuppliers"); - $dir=$conf->fournisseur->dir_output.'/facture/temp'; + $dir=$conf->fournisseur->facture->dir_temp; } print load_fiche_titre($title, $mesg, 'title_accountancy.png'); diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index a8f795115c4..7dff138f849 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -308,7 +308,7 @@ if ($action == 'create') print ''; print $langs->trans("Label"); print ''; - print ''; + print ''; print ''; print ''; @@ -317,7 +317,7 @@ if ($action == 'create') print $langs->trans("Type"); print ''; print ''; - $formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode")?GETPOST("actioncode"):'','actioncode',1); + $formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1); print ''; print ''; @@ -336,7 +336,7 @@ if ($action == 'create') print ''; print $langs->trans("Amount"); print ''; - print ''; + print ''; print ''; // Project diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 870c4f4bccd..86c1da0af2d 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -298,7 +298,7 @@ class Comment extends CommonObject $sql.= " c.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; $sql.= " WHERE c.fk_element = ".$fk_element; - $sql.= " AND c.element_type = '".$element_type."'"; + $sql.= " AND c.element_type = '".$this->db->escape($element_type)."'"; $sql.= " AND c.entity = ".$conf->entity; $sql.= " ORDER BY c.tms DESC"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c0c737b2d2a..5d96945c17a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Bahfir abbes * Copyright (C) 2017 ATM Consulting + * Copyright (C) 2017 Nicolas ZABOURI * * 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 @@ -2260,132 +2261,158 @@ abstract class CommonObject { global $conf; - include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; + // Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield) + $MODULE = ""; + if ($this->element == 'propal') + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; + elseif ($this->element == 'order') + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; + elseif ($this->element == 'facture') + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; + elseif ($this->element == 'facture_fourn') + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; + elseif ($this->element == 'order_supplier') + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; + elseif ($this->element == 'supplier_proposal') + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; - if ($roundingadjust == '-1') $roundingadjust='auto'; // For backward compatibility + if (! empty($MODULE)) { + if (! empty($conf->global->$MODULE)) { + $modsactivated = explode(',', $conf->global->$MODULE); + foreach ($modsactivated as $mod) { + if ($conf->$mod->enabled) + return 1; // update was disabled by specific setup + } + } + } - $forcedroundingmode=$roundingadjust; - if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; - elseif ($forcedroundingmode == 'auto') $forcedroundingmode='0'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - $error=0; + if ($roundingadjust == '-1') $roundingadjust='auto'; // For backward compatibility - $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; + $forcedroundingmode=$roundingadjust; + if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; + elseif ($forcedroundingmode == 'auto') $forcedroundingmode='0'; - // Define constants to find lines to sum - $fieldtva='total_tva'; - $fieldlocaltax1='total_localtax1'; - $fieldlocaltax2='total_localtax2'; - $fieldup='subprice'; - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') - { - $fieldtva='tva'; - $fieldup='pu_ht'; - } - if ($this->element == 'expensereport') - { - $fieldup='value_unit'; - } + $error=0; - $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,'; - $sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; - if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent'; - $sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; - if ($exclspec) - { - $product_field='product_type'; - if ($this->table_element_line == 'contratdet') $product_field=''; // contratdet table has no product_type field - if ($product_field) $sql.= ' AND '.$product_field.' <> 9'; - } - $sql.= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used + $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; - dol_syslog(get_class($this)."::update_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->total_ht = 0; - $this->total_tva = 0; - $this->total_localtax1 = 0; - $this->total_localtax2 = 0; - $this->total_ttc = 0; - $total_ht_by_vats = array(); - $total_tva_by_vats = array(); - $total_ttc_by_vats = array(); + // Define constants to find lines to sum + $fieldtva='total_tva'; + $fieldlocaltax1='total_localtax1'; + $fieldlocaltax2='total_localtax2'; + $fieldup='subprice'; + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') + { + $fieldtva='tva'; + $fieldup='pu_ht'; + } + if ($this->element == 'expensereport') + { + $fieldup='value_unit'; + } + + $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,'; + $sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; + if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent'; + $sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; + if ($exclspec) + { + $product_field='product_type'; + if ($this->table_element_line == 'contratdet') $product_field=''; // contratdet table has no product_type field + if ($product_field) $sql.= ' AND '.$product_field.' <> 9'; + } + $sql.= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used + + dol_syslog(get_class($this)."::update_price", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->total_ht = 0; + $this->total_tva = 0; + $this->total_localtax1 = 0; + $this->total_localtax2 = 0; + $this->total_ttc = 0; + $total_ht_by_vats = array(); + $total_tva_by_vats = array(); + $total_ttc_by_vats = array(); $this->multicurrency_total_ht = 0; - $this->multicurrency_total_tva = 0; - $this->multicurrency_total_ttc = 0; + $this->multicurrency_total_tva = 0; + $this->multicurrency_total_ttc = 0; - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none' - if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' - { - $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); - $tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); - $diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); - if ($diff) - { - $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; - dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); - $resqlfix=$this->db->query($sqlfix); - if (! $resqlfix) dol_print_error($this->db,'Failed to update line'); - $obj->total_tva = $tmpcal[1]; - $obj->total_ttc = $tmpcal[2]; - // - } - } + // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none' + if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' + { + $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); + $tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); + $diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); + if ($diff) + { + $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; + dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); + $resqlfix=$this->db->query($sqlfix); + if (! $resqlfix) dol_print_error($this->db,'Failed to update line'); + $obj->total_tva = $tmpcal[1]; + $obj->total_ttc = $tmpcal[2]; + // + } + } - $this->total_ht += $obj->total_ht; // The field visible at end of line detail - $this->total_tva += $obj->total_tva; - $this->total_localtax1 += $obj->total_localtax1; - $this->total_localtax2 += $obj->total_localtax2; - $this->total_ttc += $obj->total_ttc; - $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail - $this->multicurrency_total_tva += $obj->multicurrency_total_tva; - $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; + $this->total_ht += $obj->total_ht; // The field visible at end of line detail + $this->total_tva += $obj->total_tva; + $this->total_localtax1 += $obj->total_localtax1; + $this->total_localtax2 += $obj->total_localtax2; + $this->total_ttc += $obj->total_ttc; + $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail + $this->multicurrency_total_tva += $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; - if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; - if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; - if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0; - $total_ht_by_vats[$obj->vatrate] += $obj->total_ht; - $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; - $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; + if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; + if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; + if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0; + $total_ht_by_vats[$obj->vatrate] += $obj->total_ht; + $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; + $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; - if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency - { - $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); - $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); - //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."
\n"; - if ($diff) - { - if (abs($diff) > 0.1) { dol_syslog('A rounding difference was detected into TOTAL but is too high to be corrected', LOG_WARNING); exit; } - $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; - dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); - $resqlfix=$this->db->query($sqlfix); - if (! $resqlfix) dol_print_error($this->db,'Failed to update line'); - $this->total_tva -= $diff; - $this->total_ttc -= $diff; - $total_tva_by_vats[$obj->vatrate] -= $diff; - $total_ttc_by_vats[$obj->vatrate] -= $diff; + if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency + { + $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); + $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); + //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."
\n"; + if ($diff) + { + if (abs($diff) > 0.1) { dol_syslog('A rounding difference was detected into TOTAL but is too high to be corrected', LOG_WARNING); exit; } + $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; + dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); + $resqlfix=$this->db->query($sqlfix); + if (! $resqlfix) dol_print_error($this->db,'Failed to update line'); + $this->total_tva -= $diff; + $this->total_ttc -= $diff; + $total_tva_by_vats[$obj->vatrate] -= $diff; + $total_ttc_by_vats[$obj->vatrate] -= $diff; - } - } + } + } - $i++; - } + $i++; + } - // Add revenue stamp to total - $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; - $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; + // Add revenue stamp to total + $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; // Situations totals - if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) { + if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) + { $prev_sits = $this->get_prev_sits(); foreach ($prev_sits as $sit) { // $sit is an object Facture loaded with a fetch. @@ -2400,59 +2427,59 @@ abstract class CommonObject } } - $this->db->free($resql); + $this->db->free($resql); - // Now update global field total_ht, total_ttc and tva - $fieldht='total_ht'; - $fieldtva='tva'; - $fieldlocaltax1='localtax1'; - $fieldlocaltax2='localtax2'; - $fieldttc='total_ttc'; - // Specific code for backward compatibility with old field names - if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht='total'; - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; - if ($this->element == 'propal') $fieldttc='total'; - if ($this->element == 'expensereport') $fieldtva='total_tva'; - if ($this->element == 'supplier_proposal') $fieldttc='total'; + // Now update global field total_ht, total_ttc and tva + $fieldht='total_ht'; + $fieldtva='tva'; + $fieldlocaltax1='localtax1'; + $fieldlocaltax2='localtax2'; + $fieldttc='total_ttc'; + // Specific code for backward compatibility with old field names + if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht='total'; + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; + if ($this->element == 'propal') $fieldttc='total'; + if ($this->element == 'expensereport') $fieldtva='total_tva'; + if ($this->element == 'supplier_proposal') $fieldttc='total'; - if (empty($nodatabaseupdate)) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; - $sql .= " ".$fieldht."='".price2num($this->total_ht)."',"; - $sql .= " ".$fieldtva."='".price2num($this->total_tva)."',"; - $sql .= " ".$fieldlocaltax1."='".price2num($this->total_localtax1)."',"; - $sql .= " ".$fieldlocaltax2."='".price2num($this->total_localtax2)."',"; - $sql .= " ".$fieldttc."='".price2num($this->total_ttc)."'"; - $sql .= ", multicurrency_total_ht='".price2num($this->multicurrency_total_ht, 'MT', 1)."'"; - $sql .= ", multicurrency_total_tva='".price2num($this->multicurrency_total_tva, 'MT', 1)."'"; - $sql .= ", multicurrency_total_ttc='".price2num($this->multicurrency_total_ttc, 'MT', 1)."'"; - $sql .= ' WHERE rowid = '.$this->id; + if (empty($nodatabaseupdate)) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; + $sql .= " ".$fieldht."='".price2num($this->total_ht)."',"; + $sql .= " ".$fieldtva."='".price2num($this->total_tva)."',"; + $sql .= " ".$fieldlocaltax1."='".price2num($this->total_localtax1)."',"; + $sql .= " ".$fieldlocaltax2."='".price2num($this->total_localtax2)."',"; + $sql .= " ".$fieldttc."='".price2num($this->total_ttc)."'"; + $sql .= ", multicurrency_total_ht='".price2num($this->multicurrency_total_ht, 'MT', 1)."'"; + $sql .= ", multicurrency_total_tva='".price2num($this->multicurrency_total_tva, 'MT', 1)."'"; + $sql .= ", multicurrency_total_ttc='".price2num($this->multicurrency_total_ttc, 'MT', 1)."'"; + $sql .= ' WHERE rowid = '.$this->id; - //print "xx".$sql; - dol_syslog(get_class($this)."::update_price", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $error++; - $this->error=$this->db->lasterror(); - $this->errors[]=$this->db->lasterror(); - } - } + //print "xx".$sql; + dol_syslog(get_class($this)."::update_price", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + $error++; + $this->error=$this->db->lasterror(); + $this->errors[]=$this->db->lasterror(); + } + } - if (! $error) - { - return 1; - } - else - { - return -1; - } - } - else - { - dol_print_error($this->db,'Bad request in update_price'); - return -1; - } + if (! $error) + { + return 1; + } + else + { + return -1; + } + } + else + { + dol_print_error($this->db,'Bad request in update_price'); + return -1; + } } /** diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0151833f13b..9cb120fa61d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3635,6 +3635,13 @@ class Form $more.=$input['value']; $more.=''."\n"; } + + else if ($input['type'] == 'onecolumn') + { + $more.=''; + $more.=$input['value']; + $more.=''."\n"; + } } } $more.=''."\n"; @@ -5701,8 +5708,8 @@ class Form 'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'), - 'order_supplier'=>array('enabled'=>$conf->fournisseur->commande->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), - 'invoice_supplier'=>array('enabled'=>$conf->fournisseur->facture->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')') + 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'), + 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')') ); } diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 64e6f9fd5ef..930a9f10997 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -402,10 +402,10 @@ class Ldap * Add a LDAP entry * Ldap object connect and bind must have been done * - * @param string $dn DN entry key - * @param array $info Attributes array + * @param string $dn DN entry key + * @param array $info Attributes array * @param User $user Objet user that create - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ function add($dn, $info, $user) { @@ -458,7 +458,7 @@ class Ldap * * @param string $dn DN entry key * @param array $info Attributes array - * @param string $user Objet user that modify + * @param User $user Objet user that modify * @return int <0 if KO, >0 if OK */ function modify($dn, $info, $user) @@ -504,17 +504,69 @@ class Ldap } } + /** + * Rename a LDAP entry + * Ldap object connect and bind must have been done + * + * @param string $dn Old DN entry key (uid=qqq,ou=xxx,dc=aaa,dc=bbb) (before update) + * @param string $newrdn New RDN entry key (uid=qqq) + * @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb) + * @param User $user Objet user that modify + * @param bool $deleteoldrdn If TRUE the old RDN value(s) is removed, else the old RDN value(s) is retained as non-distinguished values of the entry. + * @return int <0 if KO, >0 if OK + */ + function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true) + { + global $conf; + + dol_syslog(get_class($this)."::modify dn=".$dn." newrdn=".$newrdn." newparent=".$newparent." deleteoldrdn=".($deleteoldrdn?1:0)); + + // Check parameters + if (! $this->connection) + { + $this->error="NotConnected"; + return -2; + } + if (! $this->bind) + { + $this->error="NotConnected"; + return -3; + } + + // Encode to LDAP page code + $dn=$this->convFromOutputCharset($dn,$this->ldapcharset); + $newrdn=$this->convFromOutputCharset($newrdn,$this->ldapcharset); + $newparent=$this->convFromOutputCharset($newparent,$this->ldapcharset); + + //print_r($info); + $result=@ldap_rename($this->connection, $dn, $newrdn, $newparent, $deleteoldrdn); + + if ($result) + { + dol_syslog(get_class($this)."::rename successfull", LOG_DEBUG); + return 1; + } + else + { + $this->error=@ldap_error($this->connection); + dol_syslog(get_class($this)."::rename failed: ".$this->error, LOG_ERR); + return -1; + } + } + /** * Modify a LDAP entry (to use if dn != olddn) * Ldap object connect and bind must have been done * - * @param string $dn DN entry key - * @param array $info Attributes array - * @param User $user Objet user that update - * @param string $olddn Old DN entry key (before update) - * @return int <0 if KO, >0 if OK + * @param string $dn DN entry key + * @param array $info Attributes array + * @param User $user Objet user that update + * @param string $olddn Old DN entry key (before update) + * @param string $newrdn New RDN entry key (uid=qqq) (for ldap_rename) + * @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb) (for ldap_rename) + * @return int <0 if KO, >0 if OK */ - function update($dn,$info,$user,$olddn) + function update($dn, $info, $user, $olddn, $newrdn=false, $newparent=false) { global $conf; @@ -534,9 +586,17 @@ class Ldap if (! $olddn || $olddn != $dn) { - // If change we make is rename the key of LDAP record, we create new one and if ok, we delete old one. - $result = $this->add($dn, $info, $user); - if ($result > 0 && $olddn && $olddn != $dn) $result = $this->delete($olddn); // If add fails, we do not try to delete old one + if (! empty($olddn) && ! empty($newrdn) && ! empty($newparent) && $conf->global->LDAP_SERVER_PROTOCOLVERSION === '3') + { + // This function currently only works with LDAPv3 + $result = $this->rename($olddn, $newrdn, $newparent, $user, true); + } + else + { + // If change we make is rename the key of LDAP record, we create new one and if ok, we delete old one. + $result = $this->add($dn, $info, $user); + if ($result > 0 && $olddn && $olddn != $dn) $result = $this->delete($olddn); // If add fails, we do not try to delete old one + } } else { @@ -1241,7 +1301,7 @@ class Ldap $this->firstname = $this->convToOutputCharset($result[0][$this->attr_firstname][0],$this->ldapcharset); $this->login = $this->convToOutputCharset($result[0][$this->attr_login][0],$this->ldapcharset); $this->phone = $this->convToOutputCharset($result[0][$this->attr_phone][0],$this->ldapcharset); - $this->skype = $this->convToOutputCharset($result[0][$this->attr_skype][0],$this->ldapcharset); + $this->skype = $this->convToOutputCharset($result[0][$this->attr_skype][0],$this->ldapcharset); $this->fax = $this->convToOutputCharset($result[0][$this->attr_fax][0],$this->ldapcharset); $this->mail = $this->convToOutputCharset($result[0][$this->attr_mail][0],$this->ldapcharset); $this->mobile = $this->convToOutputCharset($result[0][$this->attr_mobile][0],$this->ldapcharset); @@ -1298,27 +1358,29 @@ class Ldap function parseUACF($uacf) { //All flags array - $flags = array( "TRUSTED_TO_AUTH_FOR_DELEGATION" => 16777216, - "PASSWORD_EXPIRED" => 8388608, - "DONT_REQ_PREAUTH" => 4194304, - "USE_DES_KEY_ONLY" => 2097152, - "NOT_DELEGATED" => 1048576, - "TRUSTED_FOR_DELEGATION" => 524288, - "SMARTCARD_REQUIRED" => 262144, - "MNS_LOGON_ACCOUNT" => 131072, - "DONT_EXPIRE_PASSWORD" => 65536, - "SERVER_TRUST_ACCOUNT" => 8192, - "WORKSTATION_TRUST_ACCOUNT" => 4096, - "INTERDOMAIN_TRUST_ACCOUNT" => 2048, - "NORMAL_ACCOUNT" => 512, - "TEMP_DUPLICATE_ACCOUNT" => 256, - "ENCRYPTED_TEXT_PWD_ALLOWED" => 128, - "PASSWD_CANT_CHANGE" => 64, - "PASSWD_NOTREQD" => 32, - "LOCKOUT" => 16, - "HOMEDIR_REQUIRED" => 8, - "ACCOUNTDISABLE" => 2, - "SCRIPT" => 1); + $flags = array( + "TRUSTED_TO_AUTH_FOR_DELEGATION" => 16777216, + "PASSWORD_EXPIRED" => 8388608, + "DONT_REQ_PREAUTH" => 4194304, + "USE_DES_KEY_ONLY" => 2097152, + "NOT_DELEGATED" => 1048576, + "TRUSTED_FOR_DELEGATION" => 524288, + "SMARTCARD_REQUIRED" => 262144, + "MNS_LOGON_ACCOUNT" => 131072, + "DONT_EXPIRE_PASSWORD" => 65536, + "SERVER_TRUST_ACCOUNT" => 8192, + "WORKSTATION_TRUST_ACCOUNT" => 4096, + "INTERDOMAIN_TRUST_ACCOUNT" => 2048, + "NORMAL_ACCOUNT" => 512, + "TEMP_DUPLICATE_ACCOUNT" => 256, + "ENCRYPTED_TEXT_PWD_ALLOWED" => 128, + "PASSWD_CANT_CHANGE" => 64, + "PASSWD_NOTREQD" => 32, + "LOCKOUT" => 16, + "HOMEDIR_REQUIRED" => 8, + "ACCOUNTDISABLE" => 2, + "SCRIPT" => 1 + ); //Parse flags to text $retval = array(); @@ -1341,13 +1403,15 @@ class Ldap */ function parseSAT($samtype) { - $stypes = array( 805306368 => "NORMAL_ACCOUNT", - 805306369 => "WORKSTATION_TRUST", - 805306370 => "INTERDOMAIN_TRUST", - 268435456 => "SECURITY_GLOBAL_GROUP", - 268435457 => "DISTRIBUTION_GROUP", - 536870912 => "SECURITY_LOCAL_GROUP", - 536870913 => "DISTRIBUTION_LOCAL_GROUP"); + $stypes = array( + 805306368 => "NORMAL_ACCOUNT", + 805306369 => "WORKSTATION_TRUST", + 805306370 => "INTERDOMAIN_TRUST", + 268435456 => "SECURITY_GLOBAL_GROUP", + 268435457 => "DISTRIBUTION_GROUP", + 536870912 => "SECURITY_LOCAL_GROUP", + 536870913 => "DISTRIBUTION_LOCAL_GROUP" + ); $retval = ""; while (list($sat, $val) = each($stypes)) { @@ -1422,7 +1486,7 @@ class Ldap $search='('.$conf->global->$keygroup.'=*)'; $result = $this->search($this->groups,$search); - if($result) + if ($result) { $c = $result['count']; $gids = array(); diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 6f2f9e56d61..81842e65c23 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -50,6 +50,7 @@ class Notify 'BILL_PAYED', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', + 'PROPAL_CLOSE_SIGNED', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', 'ORDER_SUPPLIER_VALIDATE', @@ -58,7 +59,7 @@ class Notify 'SHIPPING_VALIDATE' ); - + /** * Constructor * @@ -85,14 +86,14 @@ class Notify $langs->load("mails"); $listofnotiftodo=$this->getNotificationsArray($action,$socid,$object,0); - + $nb=-1; if (is_array($listofnotiftodo)) $nb=count($listofnotiftodo); if ($nb < 0) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); if ($nb == 0) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("NoNotificationsWillBeSent"); if ($nb == 1) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("ANotificationsWillBeSent"); if ($nb >= 2) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("SomeNotificationsWillBeSent",$nb); - + if (is_array($listofnotiftodo)) { $i=0; @@ -106,7 +107,7 @@ class Notify } if ($i) $texte.=')'; } - + return $texte; } @@ -149,9 +150,9 @@ class Notify } $sql.= " AND s.entity IN (".getEntity('societe').")"; if ($socid > 0) $sql.= " AND s.rowid = ".$socid; - + dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); - + $resql = $this->db->query($sql); if ($resql) { @@ -176,7 +177,7 @@ class Notify } } } - + if (! $error) { if ($userid >= 0 && in_array('user', $scope)) @@ -194,9 +195,9 @@ class Notify } $sql.= " AND c.entity IN (".getEntity('user').")"; if ($userid > 0) $sql.= " AND c.rowid = ".$userid; - + dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); - + $resql = $this->db->query($sql); if ($resql) { @@ -237,10 +238,10 @@ class Notify { if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; } - + $threshold = (float) $reg[1]; if ($valueforthreshold < $threshold) continue; - + $tmpemail=explode(',',$val); foreach($tmpemail as $key2 => $val2) { @@ -295,7 +296,7 @@ class Notify $hookmanager=new HookManager($this->db); } $hookmanager->initHooks(array('notification')); - + dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id); $langs->load("other"); @@ -342,7 +343,7 @@ class Notify $sql.= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action"; if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage else $sql.= " AND a.code = '".$notifcode."'"; // New usage - + $result = $this->db->query($sql); if ($result) { @@ -369,7 +370,7 @@ class Notify } $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification"); - + switch ($notifcode) { case 'BILL_VALIDATE': $link='/compta/facture/card.php?facid='.$object->id; @@ -395,6 +396,12 @@ class Notify $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$newref); break; + case 'PROPAL_CLOSE_SIGNED': + $link='/comm/propal/card.php?id='.$object->id; + $dir_output = $conf->propal->dir_output; + $object_type = 'propal'; + $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref); + break; case 'FICHINTER_ADD_CONTACT': $link='/fichinter/card.php?id='.$object->id; $dir_output = $conf->facture->dir_output; @@ -409,7 +416,7 @@ class Notify break; case 'ORDER_SUPPLIER_VALIDATE': $link='/fourn/commande/card.php?id='.$object->id; - $dir_output = $conf->fournisseur->dir_output.'/commande/'; + $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy",$object->ref,$user->getFullName($langs)); @@ -417,7 +424,7 @@ class Notify break; case 'ORDER_SUPPLIER_APPROVE': $link='/fourn/commande/card.php?id='.$object->id; - $dir_output = $conf->fournisseur->dir_output.'/commande/'; + $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$newref,$user->getFullName($langs)); @@ -425,7 +432,7 @@ class Notify break; case 'ORDER_SUPPLIER_REFUSE': $link='/fourn/commande/card.php?id='.$object->id; - $dir_output = $conf->fournisseur->dir_output.'/commande/'; + $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$newref,$user->getFullName($langs)); @@ -462,7 +469,7 @@ class Notify if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; } - + $mailfile = new CMailFile( $subject, $sendto, @@ -478,16 +485,16 @@ class Notify ); if ($mailfile->sendfile()) - { + { if ($obj->type_target == 'touserid') { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)"; $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; - + } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)"; $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; - + } if (! $this->db->query($sql)) { @@ -571,6 +578,12 @@ class Notify $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$newref); break; + case 'PROPAL_CLOSE_SIGNED': + $link='/comm/propal/card.php?id='.$object->id; + $dir_output = $conf->propal->dir_output; + $object_type = 'propal'; + $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref); + break; case 'FICHINTER_ADD_CONTACT': $link='/fichinter/card.php?id='.$object->id; $dir_output = $conf->facture->dir_output; @@ -585,7 +598,7 @@ class Notify break; case 'ORDER_SUPPLIER_VALIDATE': $link='/fourn/commande/card.php?id='.$object->id; - $dir_output = $conf->fournisseur->dir_output.'/commande/'; + $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy",$newref,$user->getFullName($langs)); @@ -593,7 +606,7 @@ class Notify break; case 'ORDER_SUPPLIER_APPROVE': $link='/fourn/commande/card.php?id='.$object->id; - $dir_output = $conf->fournisseur->dir_output.'/commande/'; + $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$newref,$user->getFullName($langs)); @@ -601,7 +614,7 @@ class Notify break; case 'ORDER_SUPPLIER_APPROVE2': $link='/fourn/commande/card.php?id='.$object->id; - $dir_output = $conf->fournisseur->dir_output.'/commande/'; + $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$newref,$user->getFullName($langs)); @@ -664,7 +677,7 @@ class Notify if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; } - + $mailfile = new CMailFile( $subject, $sendto, diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 3cc767c1592..500bbbb3ffb 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -63,18 +63,15 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt var autoselect = '.$autoselect.'; var options = '.json_encode($ajaxoptions).'; - /* Remove product id before select another product use keyup instead of change to avoid loosing the product id. This is needed only for select of predefined product */ - /* TODO Check if we can remove this */ - $("input#search_'.$htmlname.'").keydown(function() { - $("#'.$htmlname.'").val(""); + /* Remove selected id as soon as we type or delete a char (it means old selection is wrong). Use keyup/down instead of change to avoid loosing the product id. This is needed only for select of predefined product */ + $("input#search_'.$htmlname.'").keydown(function(e) { + if (e.keyCode != 9) /* If not "Tab" key */ + { + console.log("Clear id previously selected for field '.$htmlname.'"); + $("#'.$htmlname.'").val(""); + } }); - /* I disable this. A call to trigger is already done later into the select action of the autocomplete code - $("input#search_'.$htmlname.'").change(function() { - console.log("Call the change trigger on input '.$htmlname.' because of a change on search_'.$htmlname.' was triggered"); - $("#'.$htmlname.'").trigger("change"); - });*/ - // Check options for secondary actions when keyup $("input#search_'.$htmlname.'").keyup(function() { if ($(this).val().length == 0) diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index f951439f0c5..f1d721b62e6 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2010-2017 Regis Houssin * Copyright (C) 2015 Frederic France * Copyright (C) 2015 RaphaĂ«l Doursenaud * @@ -42,7 +42,8 @@ function contact_prepare_head(Contact $object) $head[$tab][2] = 'card'; $tab++; - if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) + if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) { $langs->load("ldap"); @@ -94,7 +95,7 @@ function contact_prepare_head(Contact $object) } $head[$tab][2] = 'agenda'; $tab++; - + // Log /* $head[$tab][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 5de20238dce..710fb15ae56 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1279,8 +1279,8 @@ function dol_delete_preview($object) // Define parent dir of elements $element = $object->element; - if ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; - elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture'; + if ($object->element == 'order_supplier') $dir = $conf->fournisseur->commande->dir_output; + elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->facture->dir_output; elseif ($object->element == 'project') $dir = $conf->projet->dir_output; elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; @@ -2083,7 +2083,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output)) { if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1; - $original_file=$conf->fournisseur->dir_output.'/facture/temp/'.$original_file; + $original_file=$conf->fournisseur->facture->dir_temp.'/'.$original_file; } // Wrapping pour les images des stats expeditions elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp)) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c43ecf9d038..f95c75f3017 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3830,7 +3830,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0) * @param float $amount Amount to format * @param integer $form Type of format, HTML or not (not by default) * @param Translate $outlangs Object langs for output - * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before inserted into database or after a computation, so this parameter should be useless. + * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before beeing inserted into database or after a computation, so this parameter should be useless. * @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL) * @param int $forcerounding Force the number of decimal to forcerounding decimal (-1=do not force) * @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency) @@ -6378,7 +6378,7 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') /** - * Set focus onto field with selector + * Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag) * * @param string $selector Selector ('#id' or 'input[name="ref"]') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char. * @return string HTML code to set focus diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 7e5e5e0c604..4da1ed91fae 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -1,7 +1,8 @@ - * Copyright (C) 2015-2016 Alexandre Spangaro - * Copyright (C) 2015 RaphaĂ«l Doursenaud +/* Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2015 RaphaĂ«l Doursenaud + * Copyright (C) 2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,7 +42,8 @@ function member_prepare_head(Adherent $object) $head[$h][2] = 'general'; $h++; - if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE)) + if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) { $langs->load("ldap"); @@ -124,7 +126,8 @@ function member_type_prepare_head(AdherentType $object) $head[$h][2] = 'card'; $h++; - if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) + if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) { $langs->load("ldap"); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index c33ae364a2b..3f6d5269bae 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -663,12 +663,6 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); print ""; - // Ref - print ''; - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); - print $taskstatic->getNomUrl(1,'withproject'); - print ''; - if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) { // Thirdparty @@ -679,6 +673,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''; } + // Ref + print ''; + $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); + print $taskstatic->getNomUrl(1, 'withproject', 'time'); + print ''; + // Label task print ""; for ($k = 0 ; $k < $level ; $k++) print "   "; @@ -686,7 +686,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $taskstatic->ref=$lines[$i]->label; $taskstatic->date_start=$lines[$i]->date_start; $taskstatic->date_end=$lines[$i]->date_end; - print $taskstatic->getNomUrl(0,'withproject'); + print $taskstatic->getNomUrl(0, 'withproject', 'time'); //print "
"; //for ($k = 0 ; $k < $level ; $k++) print "   "; //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 8635c9f3a1b..11232f37ea7 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -87,7 +87,7 @@ function dol_hash($chain,$type=0) if ($type == 1) return sha1($chain); else if ($type == 2) return sha1(md5($chain)); else if ($type == 3) return md5($chain); - else if ($type == 4) return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 + else if ($type == 4) return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base) else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index f39e6ecd628..04bfa5666e2 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -50,13 +50,14 @@ function user_prepare_head($object) $head[$h][2] = 'user'; $h++; - if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) + if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$object->id; - $head[$h][1] = $langs->trans("LDAPCard"); - $head[$h][2] = 'ldap'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$object->id; + $head[$h][1] = $langs->trans("LDAPCard"); + $head[$h][2] = 'ldap'; + $h++; } $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id; @@ -210,13 +211,14 @@ function group_prepare_head($object) $head[$h][2] = 'group'; $h++; - if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) + if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) + && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin))) { $langs->load("ldap"); - $head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$object->id; - $head[$h][1] = $langs->trans("LDAPCard"); - $head[$h][2] = 'ldap'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$object->id; + $head[$h][1] = $langs->trans("LDAPCard"); + $head[$h][2] = 'ldap'; + $h++; } if ($canreadperms) diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 53d47ebc608..6f36c643ccd 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -157,7 +157,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $outputlangs->load("bills"); $outputlangs->load("products"); - if ($conf->fournisseur->dir_output.'/facture') + if ($conf->fournisseur->facture->dir_output) { $object->fetch_thirdparty(); @@ -540,7 +540,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; // Pas d'erreur } else diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 7907ea741f9..07a9740e2dc 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -168,7 +168,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $outputlangs->load("orders"); $nblignes = count($object->lines); - + // Loop on each lines to detect if there is at least one image to show $realpatharray=array(); if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) @@ -190,7 +190,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; $dir = $conf->product->dir_output.'/'.$pdir; } - + $realpath=''; foreach ($objphoto->liste_photos($dir,1) as $key => $obj) { @@ -205,7 +205,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - if ($conf->fournisseur->dir_output.'/commande') + if ($conf->fournisseur->commande->dir_output) { $object->fetch_thirdparty(); @@ -412,11 +412,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $showpricebeforepagebreak=1; $pdf->startTransaction(); - if ($posYAfterImage > 0) + if ($posYAfterImage > 0) { $descWidth = $this->posxpicture-$curX; - } - else + } + else { $descWidth = $this->posxtva-$curX; } @@ -639,7 +639,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; // Pas d'erreur } else diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index a906ec821ed..1e9c2c2ec31 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -51,7 +51,8 @@ class InterfaceLdapsynchro extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing + if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing + if (defined('DISABLE_LDAP_SYNCHRO')) return 0; // If constant defined, we do nothing if (! function_exists('ldap_connect')) { @@ -111,8 +112,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info); + $newrdn=$object->_load_ldap_dn($info,2); + $newparent=$object->_load_ldap_dn($info,1); - $result=$ldap->update($dn,$info,$user,$olddn); + $result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent); } if ($result < 0) $this->error="ErrorLDAP ".$ldap->error; @@ -544,8 +547,10 @@ class InterfaceLdapsynchro extends DolibarrTriggers $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info); + $newrdn=$object->_load_ldap_dn($info,2); + $newparent=$object->_load_ldap_dn($info,1); - $result=$ldap->update($dn,$info,$user,$olddn); + $result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent); // For member type if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index aaea372ef4a..b0acad95c97 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -40,6 +40,7 @@ class InterfaceNotification extends DolibarrTriggers 'BILL_PAYED', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', + 'PROPAL_CLOSE_SIGNED', 'FICHINTER_VALIDATE', 'FICHINTER_ADD_CONTACT', 'ORDER_SUPPLIER_VALIDATE', diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5a855332ff7..aff4eb838af 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -450,8 +450,8 @@ class CommandeFournisseur extends CommonOrder // in order not to lose the attached files $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->fournisseur->dir_output.'/commande/'.$oldref; - $dirdest = $conf->fournisseur->dir_output.'/commande/'.$newref; + $dirsource = $conf->fournisseur->commande->dir_output.'/'.$oldref; + $dirdest = $conf->fournisseur->commande->dir_output.'/'.$newref; if (file_exists($dirsource)) { dol_syslog(get_class($this)."::valid rename dir ".$dirsource." into ".$dirdest); @@ -460,7 +460,7 @@ class CommandeFournisseur extends CommonOrder { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->fournisseur->dir_output.'/commande/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + $listoffiles=dol_dir_list($conf->fournisseur->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/')); foreach($listoffiles as $fileentry) { $dirsource=$fileentry['name']; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 64938bc5787..92b6a3e40ec 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -703,7 +703,7 @@ class PaiementFourn extends Paiement } else { - $modelpath = "core/modules/supplier_payment/pdf/"; + $modelpath = "core/modules/supplier_payment/doc/"; return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 700ce7a770a..49d739be811 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -71,7 +71,7 @@ if ($object->fetch($id,$ref) < 0) exit; } -$upload_dir = $conf->fournisseur->dir_output.'/commande/'.dol_sanitizeFileName($object->ref); +$upload_dir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($object->ref); $object->fetch_thirdparty(); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ace85e8a3e8..bb5ebc86bab 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1021,7 +1021,7 @@ if ($resql) // Other picto tool print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->fournisseur->dir_output.'/commande/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->fournisseur->commande->dir_output.'/' . dol_sanitizeFileName($obj->ref); print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print ''; diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index a1104eeaceb..c3030574ce1 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -140,30 +140,10 @@ if ($action == 'setdatep' && ! empty($_POST['datepday'])) } // Build document -if ($action == 'builddoc') -{ - // Save modele used - $object->fetch($id); - $object->fetch_thirdparty(); - - // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - - $outputlangs = $langs; - $newlang=GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } -} +$upload_dir = $conf->fournisseur->payment->dir_output; +// TODO: get the appropriate permisson +$permissioncreate = true; +include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; /* diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index e4c5437028b..f25dcb9e227 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -330,6 +330,18 @@ if ($id > 0) // For user tab } dol_fiche_end(); + + print '
'; + + $canedit=(($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); + + // Boutons d'actions + if ($canedit) + { + print ''.$langs->trans("AddCP").''; + } + + print '
'; } else { @@ -348,8 +360,6 @@ else }*/ } -if ($id > 0) print '
'; - if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 5d87f42faed..1f3ae70a294 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -41,6 +41,8 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer; -- For 7.0 +ALTER TABLE llx_user ADD COLUMN birth date; + -- VMYSQL4.1 ALTER TABLE llx_holiday_users DROP PRIMARY KEY; ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type, nb_holiday); diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 1fed846bd44..ee4c549ccd3 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -364,6 +364,8 @@ update llx_bank_url as bu set url_id = (select e.fk_user_author from tmp_bank_ur drop table tmp_bank_url_expense_user; +-- VMYSQL4.1 update llx_projet_task_time set task_datehour = task_date where task_datehour < task_date or task_datehour > DATE_ADD(task_date, interval 1 day); + -- Clean product prices --delete from llx_product_price where date_price between '2017-04-20 06:51:00' and '2017-04-20 06:51:05'; diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index ed837b49b51..71ea5a559f5 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -47,6 +47,7 @@ create table llx_user town varchar(50), -- town fk_state integer DEFAULT 0, -- fk_country integer DEFAULT 0, -- + birth date, -- birthday job varchar(128), skype varchar(255), office_phone varchar(20), diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 233e4339bca..1ec51989ee6 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -80,4 +80,5 @@ PermissionsDefDesc=Define here the new permissions provided by your module (once HooksDefDesc=Define in the module_parts['hooks'] property, in the module descriptor, the context of hooks you want to manage (list of contexts can be found by a search on 'initHooks(' in core code).
Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on 'executeHooks' in core code). TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed. SeeIDsInUse=See IDs in use in your installation -SeeReservedIDsRangeHere=See range of reserved IDs \ No newline at end of file +SeeReservedIDsRangeHere=See range of reserved IDs +ToolkitForDevelopers=Toolkit for Dolibarr developers \ No newline at end of file diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a78981f32a1..a8d6bacdf31 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -186,6 +186,7 @@ EMailTextInterventionAddedContact=A newintervention %s has been assigned to you. EMailTextInterventionValidated=The intervention %s has been validated. EMailTextInvoiceValidated=The invoice %s has been validated. EMailTextProposalValidated=The proposal %s has been validated. +EMailTextProposalClosedSigned=The proposal %s has been closed signed. EMailTextOrderValidated=The order %s has been validated. EMailTextOrderApproved=The order %s has been approved. EMailTextOrderValidatedBy=The order %s has been recorded by %s. diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 1a9b5cde8d0..3ae08747510 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -96,7 +96,8 @@ HierarchicView=Hierarchical view UseTypeFieldToChange=Use field Type to change OpenIDURL=OpenID URL LoginUsingOpenID=Use OpenID to login -WeeklyHours=Weekly hours +WeeklyHours=Hours worked (per week) +ExpectedWorkedHours=Expected worked hours per week ColorUser=Color of the user DisabledInMonoUserMode=Disabled in maintenance mode UserAccountancyCode=User accounting code diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 346fcf42934..71f9aae8490 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -180,6 +180,7 @@ EMailTextInterventionAddedContact=Une nouvelle intervention %s vous a été assi EMailTextInterventionValidated=La fiche intervention %s vous concernant a été validée. EMailTextInvoiceValidated=La facture %s vous concernant a été validée. EMailTextProposalValidated=La proposition commerciale %s vous concernant a été validée. +EMailTextProposalClosedSigned=La proposition commerciale %s a été fermée signée. EMailTextOrderValidated=La commande %s vous concernant a été validée. EMailTextOrderApproved=La commande %s a été approuvée. EMailTextOrderValidatedBy=La commande %s a été enregistrée par %s diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 767370786c1..efd0404ee72 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -76,7 +76,7 @@ $newmask = 0; if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; if (empty($newmask)) // This should no happen { - $newmask='0664'; + $newmask='0664'; } @@ -86,179 +86,179 @@ if (empty($newmask)) // This should no happen if ($dirins && $action == 'initmodule' && $modulename) { - if (preg_match('/\s/', $modulename)) - { - $error++; - setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); - } + if (preg_match('/\s/', $modulename)) + { + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + } - if (! $error) - { - $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; - $destdir = $dirins.'/'.strtolower($modulename); + if (! $error) + { + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $destdir = $dirins.'/'.strtolower($modulename); - $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename - ); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename + ); - $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); - //dol_mkdir($destfile); - if ($result <= 0) - { - if ($result < 0) - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); - } - else // $result == 0 - { - setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); - } - } + $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); + //dol_mkdir($destfile); + if ($result <= 0) + { + if ($result < 0) + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors'); + } + else // $result == 0 + { + setEventMessages($langs->trans("AllFilesDidAlreadyExist", $srcdir, $destdir), null, 'warnings'); + } + } - // Delete some files - dol_delete_file($destdir.'/myobject_card.php'); - dol_delete_file($destdir.'/myobject_note.php'); - dol_delete_file($destdir.'/myobject_document.php'); - dol_delete_file($destdir.'/myobject_agenda.php'); - dol_delete_file($destdir.'/myobject_list.php'); - dol_delete_file($destdir.'/lib/myobject.lib.php'); - dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); - dol_delete_file($destdir.'/sql/llx_myobject.sql'); - dol_delete_file($destdir.'/sql/llx_myobject_extrafields.sql'); - dol_delete_file($destdir.'/sql/llx_myobject.key.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'); - } + // Delete some files + dol_delete_file($destdir.'/myobject_card.php'); + dol_delete_file($destdir.'/myobject_note.php'); + dol_delete_file($destdir.'/myobject_document.php'); + dol_delete_file($destdir.'/myobject_agenda.php'); + dol_delete_file($destdir.'/myobject_list.php'); + dol_delete_file($destdir.'/lib/myobject.lib.php'); + dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); + dol_delete_file($destdir.'/sql/llx_myobject.sql'); + dol_delete_file($destdir.'/sql/llx_myobject_extrafields.sql'); + dol_delete_file($destdir.'/sql/llx_myobject.key.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'); + } - // Edit PHP files - if (! $error) - { - $listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1); - foreach($listofphpfilestoedit as $phpfileval) - { - //var_dump($phpfileval['fullname']); - $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename, - 'MYMODULE'=>strtoupper($modulename), - 'My module'=>$modulename, - 'my module'=>$modulename, - 'Mon module'=>$modulename, - 'mon module'=>$modulename, - 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') - ); + // Edit PHP files + if (! $error) + { + $listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1); + foreach($listofphpfilestoedit as $phpfileval) + { + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + ); - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); - //var_dump($result); - if ($result < 0) - { - setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); - } - } - } + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); + //var_dump($result); + if ($result < 0) + { + setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); + } + } + } - if (! $error) - { - setEventMessages('ModuleInitialized', null); - $module=$modulename; - $modulename = ''; - } + if (! $error) + { + setEventMessages('ModuleInitialized', null); + $module=$modulename; + $modulename = ''; + } } if ($dirins && $action == 'initobject' && $module && $objectname) { - if (preg_match('/\s/', $objectname)) - { - $error++; - setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); - } + if (preg_match('/\s/', $objectname)) + { + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + } - $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; - $destdir = $dirins.'/'.strtolower($module); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $destdir = $dirins.'/'.strtolower($module); - // Scan dir class to find if an object with same name already exists. - if (! $error) - { - $dirlist=dol_dir_list($destdir.'/class','files',0,'\.txt$'); - $alreadyfound=false; - foreach($dirlist as $key => $val) - { - $filefound=preg_replace('/\.txt$/','',$val['name']); - if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) - { - $alreadyfound=true; - $error++; - setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors'); - break; - } - } - } + // Scan dir class to find if an object with same name already exists. + if (! $error) + { + $dirlist=dol_dir_list($destdir.'/class','files',0,'\.txt$'); + $alreadyfound=false; + foreach($dirlist as $key => $val) + { + $filefound=preg_replace('/\.txt$/','',$val['name']); + if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) + { + $alreadyfound=true; + $error++; + setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors'); + break; + } + } + } - if (! $error) - { - // Delete some files - $filetogenerate = array( - 'myobject_card.php'=>strtolower($objectname).'_card.php', - 'myobject_note.php'=>strtolower($objectname).'_note.php', - 'myobject_document.php'=>strtolower($objectname).'_document.php', - 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', - 'myobject_list.php'=>strtolower($objectname).'_list.php', - 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', - 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', - 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', - 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.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' - ); + if (! $error) + { + // Delete some files + $filetogenerate = array( + 'myobject_card.php'=>strtolower($objectname).'_card.php', + 'myobject_note.php'=>strtolower($objectname).'_note.php', + 'myobject_document.php'=>strtolower($objectname).'_document.php', + 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', + 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.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' + ); - foreach($filetogenerate as $srcfile => $destfile) - { - $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); - 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", $destfile), null, 'warnings'); - } - } - } + foreach($filetogenerate as $srcfile => $destfile) + { + $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); + 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", $destfile), null, 'warnings'); + } + } + } - if (! $error) - { - // Scan for object class files - $listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$'); + if (! $error) + { + // Scan for object class files + $listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$'); - $firstobjectname=''; - foreach($listofobject as $fileobj) - { - if (preg_match('/^api_/',$fileobj['name'])) continue; - if (preg_match('/^actions_/',$fileobj['name'])) continue; + $firstobjectname=''; + foreach($listofobject as $fileobj) + { + if (preg_match('/^api_/',$fileobj['name'])) continue; + if (preg_match('/^actions_/',$fileobj['name'])) continue; - $tmpcontent=file_get_contents($fileobj['fullname']); - if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) - { - $objectnameloop = $reg[1]; - if (empty($firstobjectname)) $firstobjectname = $objectnameloop; - } + $tmpcontent=file_get_contents($fileobj['fullname']); + if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) + { + $objectnameloop = $reg[1]; + if (empty($firstobjectname)) $firstobjectname = $objectnameloop; + } - // Regenerate left menu entry in descriptor for $objectname - $stringtoadd=" + // Regenerate left menu entry in descriptor for $objectname + $stringtoadd=" \t\t\$this->menu[\$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry @@ -286,123 +286,123 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both "; - $stringtoadd = preg_replace('/MyObject/', $objectnameloop, $stringtoadd); - $stringtoadd = preg_replace('/mymodule/', strtolower($module), $stringtoadd); - $stringtoadd = preg_replace('/myobject/', strtolower($objectnameloop), $stringtoadd); + $stringtoadd = preg_replace('/MyObject/', $objectnameloop, $stringtoadd); + $stringtoadd = preg_replace('/mymodule/', strtolower($module), $stringtoadd); + $stringtoadd = preg_replace('/myobject/', strtolower($objectnameloop), $stringtoadd); - $moduledescriptorfile=$destdir.'/core/modules/mod'.$module.'.class.php'; + $moduledescriptorfile=$destdir.'/core/modules/mod'.$module.'.class.php'; - // TODO Allow a replace with regex using dolReplaceRegexInFile - // TODO Avoid duplicate addition + // TODO Allow a replace with regex using dolReplaceRegexInFile + // TODO Avoid duplicate addition - dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */")); + dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */")); // Add module descriptor to list of files to replace "MyObject' string with real name of object. - $filetogenerate[]='core/modules/mod'.$module.'.class.php'; + $filetogenerate[]='core/modules/mod'.$module.'.class.php'; - // TODO - } - } - } + // TODO + } + } + } - if (! $error) - { - // Edit PHP files - foreach($filetogenerate as $destfile) - { - $phpfileval['fullname'] = $destdir.'/'.$destfile; + if (! $error) + { + // Edit PHP files + foreach($filetogenerate as $destfile) + { + $phpfileval['fullname'] = $destdir.'/'.$destfile; - //var_dump($phpfileval['fullname']); - $arrayreplacement=array( - 'mymodule'=>strtolower($module), - 'MyModule'=>$module, - 'MYMODULE'=>strtoupper($module), - 'My module'=>$module, - 'my module'=>$module, - 'mon module'=>$module, - 'Mon module'=>$module, - 'htdocs/modulebuilder/template/'=>strtolower($modulename), - 'myobject'=>strtolower($objectname), - 'MyObject'=>$objectname - ); + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($module), + 'MyModule'=>$module, + 'MYMODULE'=>strtoupper($module), + 'My module'=>$module, + 'my module'=>$module, + 'mon module'=>$module, + 'Mon module'=>$module, + 'htdocs/modulebuilder/template/'=>strtolower($modulename), + 'myobject'=>strtolower($objectname), + 'MyObject'=>$objectname + ); - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); - //var_dump($result); - if ($result < 0) - { - setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); - } - } - } + $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); + //var_dump($result); + if ($result < 0) + { + setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors'); + } + } + } - if (! $error) - { - // Edit the class file to write properties - $object=rebuildObjectClass($destdir, $module, $objectname, $newmask); - if (is_numeric($object) && $object < 0) $error++; - } - if (! $error) - { - // Edit sql with new properties - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); - if ($result < 0) $error++; - } + if (! $error) + { + // Edit the class file to write properties + $object=rebuildObjectClass($destdir, $module, $objectname, $newmask); + if (is_numeric($object) && $object < 0) $error++; + } + if (! $error) + { + // Edit sql with new properties + $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); + if ($result < 0) $error++; + } - if (! $error) - { - setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); - } + if (! $error) + { + setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); + } } if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj)) { - $objectname = $tabobj; + $objectname = $tabobj; - $srcdir = $dirread.'/'.strtolower($module); - $destdir = $dirins.'/'.strtolower($module); - dol_mkdir($destdir); + $srcdir = $dirread.'/'.strtolower($module); + $destdir = $dirins.'/'.strtolower($module); + dol_mkdir($destdir); - $addfieldentry = array( - 'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'), - 'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' - 'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'), - 'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'), - 'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp')); + $addfieldentry = array( + 'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'), + 'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' + 'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'), + 'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'), + 'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp')); - if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) - { - $addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true); - } + if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) + { + $addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true); + } - // Edit the class file to write properties - if (! $error) - { - $object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry); + // Edit the class file to write properties + if (! $error) + { + $object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry); if (is_numeric($result) && $result <= 0) $error++; - } + } - // Edit sql with new properties - if (! $error) - { - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); + // Edit sql with new properties + if (! $error) + { + $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); if ($result <= 0) { $error++; } - } + } - if (! $error) - { - clearstatcache(); + if (! $error) + { + clearstatcache(); - setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); + setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); - // Make a redirect to reload all data - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); + // Make a redirect to reload all data + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); - clearstatcache(); - exit; - } + clearstatcache(); + exit; + } } if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) @@ -433,171 +433,171 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); - // Make a redirect to reload all data - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); + // Make a redirect to reload all data + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.'&tabobj='.$objectname); - clearstatcache(); - exit; + clearstatcache(); + exit; } } if ($dirins && $action == 'confirm_delete') { - if (preg_match('/\s/', $module)) - { - $error++; - setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); - } + if (preg_match('/\s/', $module)) + { + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + } - if (! $error) - { - $modulelowercase=strtolower($module); + if (! $error) + { + $modulelowercase=strtolower($module); - // Dir for module - $dir = $dirins.'/'.$modulelowercase; + // Dir for module + $dir = $dirins.'/'.$modulelowercase; - $result = dol_delete_dir_recursive($dir); + $result = dol_delete_dir_recursive($dir); - if ($result > 0) - { - setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null); - } - else - { - setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings'); - } - } + if ($result > 0) + { + setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null); + } + else + { + setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings'); + } + } - //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); - //exit; - $action = ''; - $module = 'deletemodule'; + //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); + //exit; + $action = ''; + $module = 'deletemodule'; } if ($dirins && $action == 'confirm_deleteobject' && $objectname) { - if (preg_match('/[^a-z0-9]/i', $objectname)) - { - $error++; - setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); - } + if (preg_match('/[^a-z0-9]/i', $objectname)) + { + $error++; + setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); + } - if (! $error) - { - $modulelowercase=strtolower($module); - $objectlowercase=strtolower($objectname); + if (! $error) + { + $modulelowercase=strtolower($module); + $objectlowercase=strtolower($objectname); - // Dir for module - $dir = $dirins.'/'.$modulelowercase; + // Dir for module + $dir = $dirins.'/'.$modulelowercase; - // Delete some files - $filetogenerate = array( - 'myobject_card.php'=>strtolower($objectname).'_card.php', - 'myobject_note.php'=>strtolower($objectname).'_note.php', - 'myobject_document.php'=>strtolower($objectname).'_document.php', - 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', - 'myobject_list.php'=>strtolower($objectname).'_list.php', - 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', - 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', - 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', - 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.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' - ); + // Delete some files + $filetogenerate = array( + 'myobject_card.php'=>strtolower($objectname).'_card.php', + 'myobject_note.php'=>strtolower($objectname).'_note.php', + 'myobject_document.php'=>strtolower($objectname).'_document.php', + 'myobject_agenda.php'=>strtolower($objectname).'_agenda.php', + 'myobject_list.php'=>strtolower($objectname).'_list.php', + 'lib/myobject.lib.php'=>'lib/'.strtolower($objectname).'.lib.php', + 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', + 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', + 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.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' + ); - $resultko = 0; - foreach($filetogenerate as $filetodelete) - { - $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); - if (! $resulttmp) $resultko++; - } + $resultko = 0; + foreach($filetogenerate as $filetodelete) + { + $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); + if (! $resulttmp) $resultko++; + } - if ($resultko == 0) - { - setEventMessages($langs->trans("FilesDeleted"), null); - } - else - { - setEventMessages($langs->trans("ErrorSomeFilesCouldNotBeDeleted"), null, 'warnings'); - } - } + if ($resultko == 0) + { + setEventMessages($langs->trans("FilesDeleted"), null); + } + else + { + setEventMessages($langs->trans("ErrorSomeFilesCouldNotBeDeleted"), null, 'warnings'); + } + } - //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); - //exit; - $action = ''; - $tabobj = 'deleteobject'; + //header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?module=initmodule'); + //exit; + $action = ''; + $tabobj = 'deleteobject'; } if ($dirins && $action == 'generatepackage') { - $modulelowercase=strtolower($module); + $modulelowercase=strtolower($module); - // Dir for module - $dir = $dirins.'/'.$modulelowercase; - // Zip file to build - $FILENAMEZIP=''; + // Dir for module + $dir = $dirins.'/'.$modulelowercase; + // Zip file to build + $FILENAMEZIP=''; - // Load module - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); - $class='mod'.$module; + // 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; - } + 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"; + $arrayversion=explode('.',$moduleobj->version,3); + if (count($arrayversion)) + { + $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; - $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; - $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; + $dirofmodule = dol_buildpath($modulelowercase, 0).'/bin'; + $outputfilezip = $dirofmodule.'/'.$FILENAMEZIP; if ($dirofmodule) { - if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); - $result = dol_compress_dir($dir, $outputfilezip, 'zip'); + if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); + $result = dol_compress_dir($dir, $outputfilezip, 'zip'); } else { $result = -1; } - if ($result > 0) - { - setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfilezip), null); - } - else - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfilezip), null, 'errors'); - } - } - else - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorCheckVersionIsDefined"), null, 'errors'); - } + if ($result > 0) + { + setEventMessages($langs->trans("ZipFileGeneratedInto", $outputfilezip), null); + } + else + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToGenerateFile", $outputfilezip), null, 'errors'); + } + } + else + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorCheckVersionIsDefined"), null, 'errors'); + } } if ($dirins && $action == 'generatedoc') @@ -673,40 +673,40 @@ if ($dirins && $action == 'generatedoc') // Save file if ($action == 'savefile' && empty($cancel)) { - $relofcustom = basename($dirins); + $relofcustom = basename($dirins); - if ($relofcustom) - { - // Check that relative path ($file) start with name 'custom' - if (! preg_match('/^'.$relofcustom.'/', $file)) $file=$relofcustom.'/'.$file; + if ($relofcustom) + { + // Check that relative path ($file) start with name 'custom' + if (! preg_match('/^'.$relofcustom.'/', $file)) $file=$relofcustom.'/'.$file; - $pathoffile=dol_buildpath($file, 0); - $pathoffilebackup=dol_buildpath($file.'.back', 0); + $pathoffile=dol_buildpath($file, 0); + $pathoffilebackup=dol_buildpath($file.'.back', 0); - // Save old version - if (dol_is_file($pathoffile)) - { - dol_copy($pathoffile, $pathoffilebackup, 0, 1); - } + // Save old version + if (dol_is_file($pathoffile)) + { + dol_copy($pathoffile, $pathoffilebackup, 0, 1); + } - $content = GETPOST('editfilecontent','none'); + $content = GETPOST('editfilecontent','none'); - // Save file on disk - if ($content) - { - dol_delete_file($pathoffile); - file_put_contents($pathoffile, $content); - @chmod($pathoffile, octdec($newmask)); + // Save file on disk + if ($content) + { + dol_delete_file($pathoffile); + file_put_contents($pathoffile, $content); + @chmod($pathoffile, octdec($newmask)); - setEventMessages($langs->trans("FileSaved"), null); - } - else - { + setEventMessages($langs->trans("FileSaved"), null); + } + else + { setEventMessages($langs->trans("ContentCantBeEmpty"), null, 'errors'); - //$action='editfile'; - $error++; - } - } + //$action='editfile'; + $error++; + } + } } // Enable module @@ -770,7 +770,7 @@ $formadmin = new FormAdmin($db); // Set dir where external modules are installed if (! dol_is_dir($dirins)) { - dol_mkdir($dirins); + dol_mkdir($dirins); } $dirins_ok=(dol_is_dir($dirins)); @@ -827,30 +827,30 @@ if ($forceddirread) print $langs->trans("DirScanned").' : '.$dirread.'trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); - $allowfromweb=-1; + $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); + $allowfromweb=-1; } else { - if ($dirins_ok) - { - if (! is_writable(dol_osencode($dirins))) - { - $langs->load("errors"); - $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins)); - $allowfromweb=0; - } - } - else - { + if ($dirins_ok) + { + if (! is_writable(dol_osencode($dirins))) + { + $langs->load("errors"); + $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins)); + $allowfromweb=0; + } + } + else + { - $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); - $allowfromweb=0; - } + $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); + $allowfromweb=0; + } } if ($message) { - print $message; + print $message; } //print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
'; @@ -865,27 +865,27 @@ if (! empty($module) && $module != 'initmodule' && $module != 'deletemodule') { $modulelowercase=strtolower($module); - // Load module - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); - $class='mod'.$module; + // 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++; - print $e->getMessage(); - } - } - else - { - if (empty($forceddirread)) $error++; - $langs->load("errors"); - print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; - } + if (class_exists($class)) + { + try { + $moduleobj = new $class($db); + } + catch(Exception $e) + { + $error++; + print $e->getMessage(); + } + } + else + { + if (empty($forceddirread)) $error++; + $langs->load("errors"); + print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; + } } print '
'; @@ -902,10 +902,10 @@ $h++; foreach($listofmodules as $tmpmodule => $tmpmodulewithcase) { - $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulewithcase.($forceddirread?'@'.$dirread:''); - $head[$h][1] = $tmpmodulewithcase; - $head[$h][2] = $tmpmodulewithcase; - $h++; + $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulewithcase.($forceddirread?'@'.$dirread:''); + $head[$h][1] = $tmpmodulewithcase; + $head[$h][2] = $tmpmodulewithcase; + $h++; } $head[$h][0] = $_SERVER["PHP_SELF"].'?module=deletemodule'; @@ -918,671 +918,671 @@ dol_fiche_head($head, $module, $langs->trans("Modules"), -1, 'generic', 0, $info if ($module == 'initmodule') { - // New module - print '
'; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; - print $langs->trans("EnterNameOfModuleDesc").'

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

'; - print ''; - print ''; - print '
'; + print ''; + print ''; + print ''; } elseif ($module == 'deletemodule') { - print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print $langs->trans("EnterNameOfModuleToDeleteDesc").'

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

'; - print ''; - print ''; - print '
'; + print ''; + print ''; + print ''; } elseif (! empty($module)) { // Tabs for module - if (! $error) - { - $head2 = array(); - $h=0; + if (! $error) + { + $head2 = array(); + $h=0; - $modulelowercase=strtolower($module); - $const_name = 'MAIN_MODULE_'.strtoupper($module); + $modulelowercase=strtolower($module); + $const_name = 'MAIN_MODULE_'.strtoupper($module); - $param=''; - if ($tab) $param.= '&tab='.$tab; - if ($module) $param.='&module='.$module; - if ($tabobj) $param.='&tabobj='.$tabobj; + $param=''; + if ($tab) $param.= '&tab='.$tab; + if ($module) $param.='&module='.$module; + if ($tabobj) $param.='&tabobj='.$tabobj; - $urltomodulesetup=''.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").''; - $linktoenabledisable=''; - if (! empty($conf->global->$const_name)) // If module is already activated - { - $linktoenabledisable.=''; - $linktoenabledisable.=img_picto($langs->trans("Activated"),'switch_on'); - $linktoenabledisable.=''; - } - else - { - $linktoenabledisable.=''; - $linktoenabledisable.=img_picto($langs->trans("Disabled"),'switch_off'); - $linktoenabledisable.="\n"; - } - if (! empty($conf->$modulelowercase->enabled)) - { - $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); - } - else - { - $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive", $urltomodulesetup); - } + $urltomodulesetup=''.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").''; + $linktoenabledisable=''; + if (! empty($conf->global->$const_name)) // If module is already activated + { + $linktoenabledisable.=''; + $linktoenabledisable.=img_picto($langs->trans("Activated"),'switch_on'); + $linktoenabledisable.=''; + } + else + { + $linktoenabledisable.=''; + $linktoenabledisable.=img_picto($langs->trans("Disabled"),'switch_off'); + $linktoenabledisable.="\n"; + } + if (! empty($conf->$modulelowercase->enabled)) + { + $modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive"); + } + else + { + $modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive", $urltomodulesetup); + } - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Description"); - $head2[$h][2] = 'description'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Description"); + $head2[$h][2] = 'description'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Specifications"); - $head2[$h][2] = 'specifications'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Specifications"); + $head2[$h][2] = 'specifications'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=languages&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Languages"); - $head2[$h][2] = 'languages'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=languages&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Languages"); + $head2[$h][2] = 'languages'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Objects"); - $head2[$h][2] = 'objects'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Objects"); + $head2[$h][2] = 'objects'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Menus"); - $head2[$h][2] = 'menus'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Menus"); + $head2[$h][2] = 'menus'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Permissions"); - $head2[$h][2] = 'permissions'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Permissions"); + $head2[$h][2] = 'permissions'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Hooks"); - $head2[$h][2] = 'hooks'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Hooks"); + $head2[$h][2] = 'hooks'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Triggers"); - $head2[$h][2] = 'triggers'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Triggers"); + $head2[$h][2] = 'triggers'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("Widgets"); - $head2[$h][2] = 'widgets'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("Widgets"); + $head2[$h][2] = 'widgets'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("CronList"); - $head2[$h][2] = 'cron'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("CronList"); + $head2[$h][2] = 'cron'; + $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module.($forceddirread?'@'.$dirread:''); - $head2[$h][1] = $langs->trans("BuildPackage"); - $head2[$h][2] = 'buildpackage'; - $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("BuildPackage"); + $head2[$h][2] = 'buildpackage'; + $h++; - print $modulestatusinfo; - print ' '.$linktoenabledisable; - print '

'; + print $modulestatusinfo; + print ' '.$linktoenabledisable; + print '

'; - if ($tab == 'description') - { - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; - $pathtofilereadme = $modulelowercase.'/README.md'; - $pathtochangelog = $modulelowercase.'/ChangeLog.md'; + if ($tab == 'description') + { + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + $pathtofilereadme = $modulelowercase.'/README.md'; + $pathtochangelog = $modulelowercase.'/ChangeLog.md'; - if ($action != 'editfile' || empty($file)) - { - dol_fiche_head($head2, $tab, '', -1, ''); // Description - level 2 + if ($action != 'editfile' || empty($file)) + { + dol_fiche_head($head2, $tab, '', -1, ''); // Description - level 2 - print $langs->trans("ModuleBuilderDesc".$tab).'

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

'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print ' '.$langs->trans("ReadmeFile").' : '.$pathtofilereadme.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("ReadmeFile").' : '.$pathtofilereadme.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print ' '.$langs->trans("ChangeLog").' : '.$pathtochangelog.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("ChangeLog").' : '.$pathtochangelog.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print '
'; - print '
'; + print '
'; + print '
'; - print_fiche_titre($langs->trans("DescriptorFile")); + print_fiche_titre($langs->trans("DescriptorFile")); - if (! empty($moduleobj)) - { - print '
'; - print '
'; + if (! empty($moduleobj)) + { + print '
'; + print '
'; - print ''; - print ''; + print '
'; - print $langs->trans("Parameter"); - print ''; - print $langs->trans("Value"); - print '
'; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print '
'; + print $langs->trans("Parameter"); + print ''; + print $langs->trans("Value"); + print '
'; - print $langs->trans("Numero"); - print ''; - print $moduleobj->numero; - print '   ('.$langs->trans("SeeIDsInUse").''; - print ' - '.$langs->trans("SeeReservedIDsRangeHere").')'; - print '
'; + print $langs->trans("Numero"); + print ''; + print $moduleobj->numero; + print '   ('.$langs->trans("SeeIDsInUse").''; + print ' - '.$langs->trans("SeeReservedIDsRangeHere").')'; + print '
'; - print $langs->trans("Name"); - print ''; - print $moduleobj->getName(); - print '
'; + print $langs->trans("Name"); + print ''; + print $moduleobj->getName(); + print '
'; - print $langs->trans("Version"); - print ''; - print $moduleobj->getVersion(); - print '
'; + print $langs->trans("Version"); + print ''; + print $moduleobj->getVersion(); + print '
'; - print $langs->trans("Family"); - //print "
'crm','financial','hr','projects','products','ecm','technic','interface','other'"; - print '
'; - print $moduleobj->family; - print '
'; + print $langs->trans("Family"); + //print "
'crm','financial','hr','projects','products','ecm','technic','interface','other'"; + print '
'; + print $moduleobj->family; + print '
'; - print $langs->trans("EditorName"); - print ''; - print $moduleobj->editor_name; - print '
'; + print $langs->trans("EditorName"); + print ''; + print $moduleobj->editor_name; + print '
'; - print $langs->trans("EditorUrl"); - print ''; - print $moduleobj->editor_url; - print '
'; + print $langs->trans("EditorUrl"); + print ''; + print $moduleobj->editor_url; + print '
'; - print $langs->trans("Description"); - print ''; - print $moduleobj->getDesc(); - print '
'; + print $langs->trans("Description"); + print ''; + print $moduleobj->getDesc(); + print '
'; + print ''; - print '

'; + print '

'; // Readme file - print_fiche_titre($langs->trans("ReadmeFile")); + print_fiche_titre($langs->trans("ReadmeFile")); - print '
'; - print '
'; + print '
'; + print '
'; - print $moduleobj->getDescLong(); + print $moduleobj->getDescLong(); - print '

'; + print '

'; - // ChangeLog - print_fiche_titre($langs->trans("ChangeLog")); + // ChangeLog + print_fiche_titre($langs->trans("ChangeLog")); - print '
'; - print '
'; + print '
'; + print '
'; - print $moduleobj->getChangeLog(); + print $moduleobj->getChangeLog(); - print '
'; - } - else - { - print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; - } + print '
'; + } + else + { + print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; + } - dol_fiche_end(); - } - else - { - $fullpathoffile=dol_buildpath($file, 0, 1); // Description - level 2 + dol_fiche_end(); + } + else + { + $fullpathoffile=dol_buildpath($file, 0, 1); // Description - level 2 - if ($fullpathoffile) - { - $content = file_get_contents($fullpathoffile); - } + if ($fullpathoffile) + { + $content = file_get_contents($fullpathoffile); + } - // New module - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - dol_fiche_head($head2, $tab, '', -1, ''); + dol_fiche_head($head2, $tab, '', -1, ''); - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', ''); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%', ''); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - dol_fiche_end(); + dol_fiche_end(); - print '
'; - print ''; - print '   '; - print ''; - print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print '
'; - } - } - else - { - dol_fiche_head($head2, $tab, '', -1, ''); // Level 2 - } + print ''; + } + } + else + { + dol_fiche_head($head2, $tab, '', -1, ''); // Level 2 + } - if ($tab == 'specifications') - { - if ($action != 'editfile' || empty($file)) - { - print $langs->trans("SpecDefDesc").'
'; - print '
'; + if ($tab == 'specifications') + { + if ($action != 'editfile' || empty($file)) + { + print $langs->trans("SpecDefDesc").'
'; + print '
'; - $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$'); + $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$'); - foreach ($specs as $spec) - { - $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; + foreach ($specs as $spec) + { + $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; $format='asciidoc'; if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; - print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - } - } - else - { - // Use MD or asciidoc + print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + } + } + else + { + // Use MD or asciidoc - //print $langs->trans("UseAsciiDocFormat").'
'; + //print $langs->trans("UseAsciiDocFormat").'
'; - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile=dol_buildpath($file, 0); - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print '
'; - } - } + print ''; + } + } - if ($tab == 'languages') - { - if ($action != 'editfile' || empty($file)) - { - print $langs->trans("LanguageDefDesc").'
'; - print '
'; + if ($tab == 'languages') + { + if ($action != 'editfile' || empty($file)) + { + print $langs->trans("LanguageDefDesc").'
'; + print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 1); - print '
'; - print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 1); + print '
'; + print '
'; - print '
'; - print '
'; + print '
'; + print '
'; - $langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); + $langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); - foreach ($langfiles as $langfile) - { - $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; - print ' '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - } - } - else - { - // Edit text language file + foreach ($langfiles as $langfile) + { + $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; + print ' '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + } + } + else + { + // Edit text language file - //print $langs->trans("UseAsciiDocFormat").'
'; + //print $langs->trans("UseAsciiDocFormat").'
'; - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile=dol_buildpath($file, 0); - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'text')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'text')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print '
'; - } - } + print ''; + } + } - if ($tab == 'objects') - { - $head3 = array(); - $h=0; + if ($tab == 'objects') + { + $head3 = array(); + $h=0; - // Dir for module - $dir = $dirread.'/'.$modulelowercase.'/class'; + // Dir for module + $dir = $dirread.'/'.$modulelowercase.'/class'; - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=newobject'; - $head3[$h][1] = $langs->trans("NewObject"); - $head3[$h][2] = 'newobject'; - $h++; + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=newobject'; + $head3[$h][1] = $langs->trans("NewObject"); + $head3[$h][2] = 'newobject'; + $h++; - // Scan for object class files - $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); + // Scan for object class files + $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); - $firstobjectname=''; - foreach($listofobject as $fileobj) - { - if (preg_match('/^api_/',$fileobj['name'])) continue; - if (preg_match('/^actions_/',$fileobj['name'])) continue; + $firstobjectname=''; + foreach($listofobject as $fileobj) + { + if (preg_match('/^api_/',$fileobj['name'])) continue; + if (preg_match('/^actions_/',$fileobj['name'])) continue; - $tmpcontent=file_get_contents($fileobj['fullname']); - if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) - { - //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']); - $objectname = $reg[1]; - if (empty($firstobjectname)) $firstobjectname = $objectname; + $tmpcontent=file_get_contents($fileobj['fullname']); + if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg)) + { + //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']); + $objectname = $reg[1]; + if (empty($firstobjectname)) $firstobjectname = $objectname; - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; - $head3[$h][1] = $objectname; - $head3[$h][2] = $objectname; - $h++; - } - } + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname; + $head3[$h][1] = $objectname; + $head3[$h][2] = $objectname; + $h++; + } + } - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=deleteobject'; - $head3[$h][1] = $langs->trans("DangerZone"); - $head3[$h][2] = 'deleteobject'; - $h++; + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=deleteobject'; + $head3[$h][1] = $langs->trans("DangerZone"); + $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'; - } + // 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, ''); // Level 3 + dol_fiche_head($head3, $tabobj, '', -1, ''); // Level 3 - if ($tabobj == 'newobject') - { - // New object tab - print '
'; - print ''; - print ''; - print ''; - print ''; + if ($tabobj == 'newobject') + { + // New object tab + print ''; + print ''; + print ''; + print ''; + print ''; - print $langs->trans("EnterNameOfObjectDesc").'

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

'; - print ''; - print ''; - print '
'; - } - elseif ($tabobj == 'deleteobject') - { - // Delete object tab - print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print '
'; + } + elseif ($tabobj == 'deleteobject') + { + // Delete object tab + print '
'; + print ''; + print ''; + print ''; + print ''; - print $langs->trans("EnterNameOfObjectToDeleteDesc").'

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

'; - print ''; - print ''; - print '
'; - } - else - { // tabobj = module - 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 - ); + print ''; + print ''; + print ''; + } + else + { // tabobj = module + 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 + ); - // Print form confirm - print $formconfirm; - } + // Print form confirm + print $formconfirm; + } - if ($action != 'editfile' || empty($file)) - { - try { - $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; - $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; - $pathtoagenda = strtolower($module).'/'.strtolower($tabobj).'_agenda.php'; - $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; - $pathtodocument = strtolower($module).'/'.strtolower($tabobj).'_document.php'; - $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; - $pathtonote = strtolower($module).'/'.strtolower($tabobj).'_note.php'; - $pathtophpunit = strtolower($module).'/test/phpunit/'.$tabobj.'Test.php'; - $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; - $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; - $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; - $pathtolib = strtolower($module).'/lib/'.strtolower($tabobj).'.lib.php'; - $pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png'; + if ($action != 'editfile' || empty($file)) + { + try { + $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; + $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; + $pathtoagenda = strtolower($module).'/'.strtolower($tabobj).'_agenda.php'; + $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; + $pathtodocument = strtolower($module).'/'.strtolower($tabobj).'_document.php'; + $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; + $pathtonote = strtolower($module).'/'.strtolower($tabobj).'_note.php'; + $pathtophpunit = strtolower($module).'/test/phpunit/'.$tabobj.'Test.php'; + $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; + $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; + $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; + $pathtolib = strtolower($module).'/lib/'.strtolower($tabobj).'.lib.php'; + $pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png'; - $realpathtoclass = dol_buildpath($pathtoclass, 0, 1); - $realpathtoapi = dol_buildpath($pathtoapi, 0, 1); - $realpathtoagenda = dol_buildpath($pathtoagenda, 0, 1); - $realpathtocard = dol_buildpath($pathtocard, 0, 1); - $realpathtodocument = dol_buildpath($pathtodocument, 0, 1); - $realpathtolist = dol_buildpath($pathtolist, 0, 1); - $realpathtonote = dol_buildpath($pathtonote, 0, 1); - $realpathtophpunit = dol_buildpath($pathtophpunit, 0, 1); - $realpathtosql = dol_buildpath($pathtosql, 0, 1); - $realpathtosqlextra = dol_buildpath($pathtosqlextra, 0, 1); - $realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 1); - $realpathtolib = dol_buildpath($pathtolib, 0, 1); - $realpathtopicto = dol_buildpath($pathtopicto, 0, 1); + $realpathtoclass = dol_buildpath($pathtoclass, 0, 1); + $realpathtoapi = dol_buildpath($pathtoapi, 0, 1); + $realpathtoagenda = dol_buildpath($pathtoagenda, 0, 1); + $realpathtocard = dol_buildpath($pathtocard, 0, 1); + $realpathtodocument = dol_buildpath($pathtodocument, 0, 1); + $realpathtolist = dol_buildpath($pathtolist, 0, 1); + $realpathtonote = dol_buildpath($pathtonote, 0, 1); + $realpathtophpunit = dol_buildpath($pathtophpunit, 0, 1); + $realpathtosql = dol_buildpath($pathtosql, 0, 1); + $realpathtosqlextra = dol_buildpath($pathtosqlextra, 0, 1); + $realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 1); + $realpathtolib = dol_buildpath($pathtolib, 0, 1); + $realpathtopicto = dol_buildpath($pathtopicto, 0, 1); - print '
'; - print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi?'':'').$pathtoapi.($realpathtoapi?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '   '.$langs->trans("GoToApiExplorer").''; - print '
'; - print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit?'':'').$pathtophpunit.($realpathtophpunit?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print '
'; + print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi?'':'').$pathtoapi.($realpathtoapi?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '   '.$langs->trans("GoToApiExplorer").''; + print '
'; + print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit?'':'').$pathtophpunit.($realpathtophpunit?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print '
'; + print '
'; - print ' '.$langs->trans("PageForLib").' : '.($realpathtolib?'':'').$pathtolib.($realpathtodocument?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - print ' '.$langs->trans("PageForPicto").' : '.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':'').''; - //print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("PageForLib").' : '.($realpathtolib?'':'').$pathtolib.($realpathtodocument?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForPicto").' : '.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':'').''; + //print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print '
'; - print ' '.$langs->trans("SqlFile").' : '.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '   '.$langs->trans("DropTableIfEmpty").''; - //print '   '.$langs->trans("RunSql").''; - print '
'; - print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra?'':'').$pathtosqlextra.($realpathtosqlextra?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - //print '   '.$langs->trans("RunSql").''; - print '
'; - print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - //print '   '.$langs->trans("RunSql").''; - print '
'; + print '
'; + print ' '.$langs->trans("SqlFile").' : '.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '   '.$langs->trans("DropTableIfEmpty").''; + //print '   '.$langs->trans("RunSql").''; + print '
'; + print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra?'':'').$pathtosqlextra.($realpathtosqlextra?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + //print '   '.$langs->trans("RunSql").''; + print '
'; + print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + //print '   '.$langs->trans("RunSql").''; + print '
'; - print '
'; - print '
'; + print '
'; + print '
'; - $urloflist = dol_buildpath($pathtolist, 1); - $urlofcard = dol_buildpath($pathtocard, 1); + $urloflist = dol_buildpath($pathtolist, 1); + $urlofcard = dol_buildpath($pathtocard, 1); - print '
'; - print ' '.$langs->trans("PageForList").' : '.($realpathtosql?'':'').$pathtolist.($realpathtosql?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - print ' '.$langs->trans("PageForCreateEditView").' : '.($realpathtocard?'':'').$pathtocard.($realpathtocard?'':'').'?action=create'; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - print ' '.$langs->trans("PageForAgendaTab").' : '.($realpathtoagenda?'':'').$pathtoagenda.($realpathtoagenda?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - print ' '.$langs->trans("PageForDocumentTab").' : '.($realpathtodocument?'':'').$pathtodocument.($realpathtodocument?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print '
'; + print ' '.$langs->trans("PageForList").' : '.($realpathtosql?'':'').$pathtolist.($realpathtosql?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForCreateEditView").' : '.($realpathtocard?'':'').$pathtocard.($realpathtocard?'':'').'?action=create'; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForAgendaTab").' : '.($realpathtoagenda?'':'').$pathtoagenda.($realpathtoagenda?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForDocumentTab").' : '.($realpathtodocument?'':'').$pathtodocument.($realpathtodocument?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':'').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print '
'; + print '
'; - print '
'; + print '
'; - print '


'; + print '


'; - if (empty($forceddirread)) - { - $result = dol_include_once($pathtoclass); - } - else - { - $result = @include_once($dirread.'/'.$pathtoclass); - } - if (class_exists($tabobj)) - { - try { - $tmpobjet = @new $tabobj($db); - } - catch(Exception $e) - { - dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING); - } - } + if (empty($forceddirread)) + { + $result = dol_include_once($pathtoclass); + } + else + { + $result = @include_once($dirread.'/'.$pathtoclass); + } + if (class_exists($tabobj)) + { + try { + $tmpobjet = @new $tabobj($db); + } + catch(Exception $e) + { + dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING); + } + } - if (! empty($tmpobjet)) - { - $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 (! empty($tmpobjet)) + { + $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 load_fiche_titre($langs->trans("Properties"), '', ''); + print load_fiche_titre($langs->trans("Properties"), '', ''); - print '
'; + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + print '
'.$langs->trans("Property"); - print ' ('.$langs->trans("Example").')'; - print ''; - print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); - print ''.$langs->trans("Type").''.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).''.$langs->trans("NotNull").''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("Position").''.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).''.$langs->trans("Comment").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $properties = dol_sort_array($tmpobjet->fields, 'position'); + $properties = dol_sort_array($tmpobjet->fields, 'position'); - if (! empty($properties)) - { - // Line to add a property - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if (! empty($properties)) + { + // Line to add a property + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - foreach($properties as $propkey => $propval) - { - /* If from Reflection + foreach($properties as $propkey => $propval) + { + /* If from Reflection if ($propval->class == $tabobj) { $propname=$propval->getName(); @@ -1596,154 +1596,154 @@ elseif (! empty($module)) if (in_array($propname, array('fk_element', 'lines'))) continue; }*/ - $propname=$propkey; - $proplabel=$propval['label']; - $proptype=$propval['type']; - $proparrayofkeyval=$propval['arrayofkeyval']; - $propnotnull=$propval['notnull']; - $propsearchall=$propval['searchall']; - //$propdefault=$propval['default']; - $propindex=$propval['index']; - $propposition=$propval['position']; - $propenabled=$propval['enabled']; - $propvisible=$propval['visible']; - $propisameasure=$propval['isameasure']; - $propcomment=$propval['comment']; + $propname=$propkey; + $proplabel=$propval['label']; + $proptype=$propval['type']; + $proparrayofkeyval=$propval['arrayofkeyval']; + $propnotnull=$propval['notnull']; + $propsearchall=$propval['searchall']; + //$propdefault=$propval['default']; + $propindex=$propval['index']; + $propposition=$propval['position']; + $propenabled=$propval['enabled']; + $propvisible=$propval['visible']; + $propisameasure=$propval['isameasure']; + $propcomment=$propval['comment']; - print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - /*print ''; + print ''; + print ''; + print ''; + print ''; + /*print '';*/ - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - } - } - else - { - print ''; - } - print '
'.$langs->trans("Property"); + print ' ('.$langs->trans("Example").')'; + print ''; + print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); + print ''.$langs->trans("Type").''.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).''.$langs->trans("NotNull").''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("Position").''.$form->textwithpicto($langs->trans("Enabled"), $langs->trans("EnabledDesc")).''.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).''.$form->textwithpicto($langs->trans("IsAMeasure"), $langs->trans("IsAMeasureDesc")).''.$form->textwithpicto($langs->trans("SearchAll"), $langs->trans("SearchAllDesc")).''.$langs->trans("Comment").'
'; - print ''; - print '
'; + print ''; + print '
'; - print $propname; - print ''; - print $proplabel; - print ''; - print $proptype; - print ''; - if ($proparrayofkeyval) - { - print json_encode($proparrayofkeyval); - } - print ''; - print $propnotnull; - print ''; + print ''; + print $propname; + print ''; + print $proplabel; + print ''; + print $proptype; + print ''; + if ($proparrayofkeyval) + { + print json_encode($proparrayofkeyval); + } + print ''; + print $propnotnull; + print ''; print $propdefault; print ''; - print $propindex?'X':''; - print ''; - print $propposition; - print ''; - print $propenabled?$propenabled:''; - print ''; - print $propvisible?$propvisible:''; - print ''; - print $propisameasure?$propisameasure:''; - print ''; - print $propsearchall?'X':''; - print ''; - print $propcomment; - print ''; - print ''.img_delete().''; - print ''; + print $propindex?'X':''; + print ''; + print $propposition; + print ''; + print $propenabled?$propenabled:''; + print ''; + print $propvisible?$propvisible:''; + print ''; + print $propisameasure?$propisameasure:''; + print ''; + print $propsearchall?'X':''; + print ''; + print $propcomment; + print ''; + print ''.img_delete().''; + print '
'.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').'
'; + print ''; + } + } + else + { + print ''.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').''; + } + print ''; print '
'; - print '
'; - } - else - { - print ''.$langs->trans('Failed to init the object with the new.').''; - } - } - catch(Exception $e) - { - print $e->getMessage(); - } - } - else - { - if (empty($forceddirread)) - { - $fullpathoffile=dol_buildpath($file, 0); - } - else - { - $fullpathoffile=$dirread.'/'.$file; - } + print ''; + } + else + { + print ''.$langs->trans('Failed to init the object with the new.').''; + } + } + catch(Exception $e) + { + print $e->getMessage(); + } + } + else + { + if (empty($forceddirread)) + { + $fullpathoffile=dol_buildpath($file, 0); + } + else + { + $fullpathoffile=$dirread.'/'.$file; + } - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print '
'; - } - } + print ''; + } + } - dol_fiche_end(); // Level 3 - } + dol_fiche_end(); // Level 3 + } - if ($tab == 'menus') - { - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + if ($tab == 'menus') + { + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; - //$menus = $moduleobj->; + //$menus = $moduleobj->; - if ($action != 'editfile' || empty($file)) - { - print $langs->trans("MenusDefDesc", ''.$langs->trans('Menus').'').'
'; - print '
'; + if ($action != 'editfile' || empty($file)) + { + print $langs->trans("MenusDefDesc", ''.$langs->trans('Menus').'').'
'; + print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print '
'; - //print load_fiche_titre($langs->trans("MenusList"), '', ''); + print '
'; + //print load_fiche_titre($langs->trans("MenusList"), '', ''); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - /* + /* print '
'; print ''; @@ -1814,58 +1814,58 @@ elseif (! empty($module)) print ''; */ - } - else - { - $fullpathoffile=dol_buildpath($file, 0); + } + else + { + $fullpathoffile=dol_buildpath($file, 0); - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print ''; - } - } + print ''; + } + } - if ($tab == 'permissions') - { - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + if ($tab == 'permissions') + { + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; - //$perms = $moduleobj->; + //$perms = $moduleobj->; - if ($action != 'editfile' || empty($file)) - { - print $langs->trans("PermissionsDefDesc", ''.$langs->trans('DefaultPermissions').'').'
'; - print '
'; + if ($action != 'editfile' || empty($file)) + { + print $langs->trans("PermissionsDefDesc", ''.$langs->trans('DefaultPermissions').'').'
'; + print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print '
'; - print load_fiche_titre($langs->trans("ListOfPermissionsDefined"), '', ''); + print '
'; + print load_fiche_titre($langs->trans("ListOfPermissionsDefined"), '', ''); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print 'TODO...'; /* @@ -1939,81 +1939,81 @@ elseif (! empty($module)) print ''; */ - } - else - { - $fullpathoffile=dol_buildpath($file, 0); + } + else + { + $fullpathoffile=dol_buildpath($file, 0); - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print ''; - } - } + print ''; + } + } - if ($tab == 'hooks') - { - if ($action != 'editfile' || empty($file)) + if ($tab == 'hooks') + { + if ($action != 'editfile' || empty($file)) { print $langs->trans("HooksDefDesc").'
'; print '
'; - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; + $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; print ' '.$langs->trans("HooksFile").' : '.$pathtohook.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile=dol_buildpath($file, 0); - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print ''; + print ''; } - } + } - if ($tab == 'triggers') - { - require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + if ($tab == 'triggers') + { + require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interfaces = new Interfaces($db); $triggers = $interfaces->getTriggersList(array('/'.strtolower($module).'/core/triggers')); @@ -2025,14 +2025,14 @@ elseif (! empty($module)) if (! empty($triggers)) { - foreach ($triggers as $trigger) - { - $pathtofile = $trigger['relpath']; + foreach ($triggers as $trigger) + { + $pathtofile = $trigger['relpath']; - print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - } + print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + } } else { @@ -2041,34 +2041,34 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile=dol_buildpath($file, 0); - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print ''; + print ''; } - } + } - if ($tab == 'widgets') - { - require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + if ($tab == 'widgets') + { + require_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; $widgets = ModeleBoxes::getWidgetsList(array('/'.strtolower($module).'/core/boxes')); @@ -2076,260 +2076,260 @@ elseif (! empty($module)) { if (! empty($widget)) { - foreach ($widgets as $widget) - { - $pathtofile = $widget['relpath']; + foreach ($widgets as $widget) + { + $pathtofile = $widget['relpath']; - print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - } - } - else - { - print $langs->trans("NoWidget"); - } + print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + } + } + else + { + print $langs->trans("NoWidget"); + } } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile=dol_buildpath($file, 0); - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print ''; + print ''; } - } + } - if ($tab == 'cron') - { - $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + if ($tab == 'cron') + { + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; - $cronjobs = $moduleobj->cronjobs; + $cronjobs = $moduleobj->cronjobs; - if ($action != 'editfile' || empty($file)) - { - print $langs->trans("CronJobDefDesc", ''.$langs->trans('CronList').'').'
'; - print '
'; + if ($action != 'editfile' || empty($file)) + { + print $langs->trans("CronJobDefDesc", ''.$langs->trans('CronList').'').'
'; + print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; - print '
'; - print load_fiche_titre($langs->trans("CronJobProfiles"), '', ''); + print '
'; + print load_fiche_titre($langs->trans("CronJobProfiles"), '', ''); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; - print '
'; + print '
'; + print '
'; - print ''; - print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print "\n"; + print ''; + print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder); + print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print "\n"; - if (count($cronjobs)) - { - foreach ($cronjobs as $cron) - { - print ''; + if (count($cronjobs)) + { + foreach ($cronjobs as $cron) + { + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - } - } - else - { - print ''; - } + print ''; + } + } + else + { + print ''; + } - print '
'; - print $cron['label']; - print ''; + print $cron['label']; + print ''; - if ($cron['jobtype']=='method') - { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$module.'
'; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
'; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
'; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - elseif ($cron['jobtype']=='command') - { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - print $form->textwithpicto($text, $texttoshow, 1); - print '
'; + if ($cron['jobtype']=='method') + { + $text=$langs->trans("CronClass"); + $texttoshow=$langs->trans('CronModule').': '.$module.'
'; + $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
'; + $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
'; + $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; + $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + elseif ($cron['jobtype']=='command') + { + $text=$langs->trans('CronCommand'); + $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); + $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + print $form->textwithpicto($text, $texttoshow, 1); + print '
'; - if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); - print ''; + if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); + if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); + if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); + if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); + print ''; - print $cron['status']; - print ''; + print $cron['status']; + print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} - print ''; + if (!empty($cron['comment'])) {print $cron['comment'];} + print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; - print '
'; + print ''; + print '
'; - print ''; - } - else - { - $fullpathoffile=dol_buildpath($file, 0); + print ''; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); - $content = file_get_contents($fullpathoffile); + $content = file_get_contents($fullpathoffile); - // New module - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; - print '
'; - } - } + print ''; + } + } - if ($tab == 'buildpackage') - { - if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) - { - print img_warning().' '.$langs->trans("ErrNoZipEngine"); - print '
'; - } + if ($tab == 'buildpackage') + { + if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) + { + print img_warning().' '.$langs->trans("ErrNoZipEngine"); + print '
'; + } - $modulelowercase=strtolower($module); + $modulelowercase=strtolower($module); - // Zip file to build - $FILENAMEZIP=''; + // Zip file to build + $FILENAMEZIP=''; - // Load module - dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php'); - $class='mod'.$module; + // 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; - } + 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"; - $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; + $arrayversion=explode('.',$moduleobj->version,3); + if (count($arrayversion)) + { + $FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip"; + $outputfilezip = dol_buildpath($modulelowercase, 0).'/bin/'.$FILENAMEZIP; - $FILENAMEDOC=$modulelowercase.'.html'; - $outputfiledoc = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOC; - } + $FILENAMEDOC=$modulelowercase.'.html'; + $outputfiledoc = dol_buildpath($modulelowercase, 0).'/doc/'.$FILENAMEDOC; + } - print '
'; + print '
'; - print ' '. $langs->trans("PathToModulePackage") . ' : '; - if (! dol_is_file($outputfilezip)) print ''.$langs->trans("FileNotYetGenerated").''; - else { - $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP; - print ''.$outputfilezip.''; - print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfilezip), 'dayhour').')'; - } - print '

'; + print ' '. $langs->trans("PathToModulePackage") . ' : '; + if (! dol_is_file($outputfilezip)) print ''.$langs->trans("FileNotYetGenerated").''; + else { + $relativepath = $modulelowercase.'/bin/'.$FILENAMEZIP; + print ''.$outputfilezip.''; + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfilezip), 'dayhour').')'; + } + print '
'; - print '
'; + print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; - print '


'; + print '


'; - print ' '. $langs->trans("PathToModuleDocumentation") . ' : '; - if (! dol_is_file($outputfiledoc)) print ''.$langs->trans("FileNotYetGenerated").''; - else { - print ''.$outputfiledoc.''; - print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfiledoc), 'dayhour').')'; - } - print '
'; + print ' '. $langs->trans("PathToModuleDocumentation") . ' : '; + if (! dol_is_file($outputfiledoc)) print ''.$langs->trans("FileNotYetGenerated").''; + else { + print ''.$outputfiledoc.''; + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfiledoc), 'dayhour').')'; + } + print '
'; - print '
'; + print '
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - } + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + } - if ($tab != 'description') - { - dol_fiche_end(); - } - } + if ($tab != 'description') + { + dol_fiche_end(); + } + } } dol_fiche_end(); // End modules diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index c9c577742e6..b4ed7aeab9f 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -108,7 +108,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', { $action = ''; $search_categ=''; - $search_usertoprocessid = ''; + $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; $search_project_ref = ''; @@ -242,13 +242,14 @@ if ($action == 'addtime' && $user->rights->projet->lire) $object->timespent_note = GETPOST($key.'note'); if (GETPOST($key."hour") != '' && GETPOST($key."hour") >= 0) // If hour was entered { - $object->timespent_date = dol_mktime(GETPOST($key."hour"),GETPOST($key."min"),0,$monthofday,$dayofday,$yearofday); + $object->timespent_datehour = dol_mktime(GETPOST($key."hour"),GETPOST($key."min"),0,$monthofday,$dayofday,$yearofday); $object->timespent_withhour = 1; } else { - $object->timespent_date = dol_mktime(12,0,0,$monthofday,$dayofday,$yearofday); + $object->timespent_datehour = dol_mktime(12,0,0,$monthofday,$dayofday,$yearofday); } + $object->timespent_date = $object->timespent_datehour; if ($object->timespent_date > 0) { @@ -501,7 +502,10 @@ if (count($tasksarray) > 0) if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) $colspan++; print ' - '.$langs->trans("Total").' + '; + print $langs->trans("Total"); + //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; + print '
 
@@ -526,7 +530,7 @@ $modeinput='hours'; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index b808017123d..8ff05e459ed 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -121,7 +121,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', { $action = ''; $search_categ=''; - $search_usertoprocessid = ''; + $search_usertoprocessid = $user->id; $search_task_ref = ''; $search_task_label = ''; $search_project_ref = ''; @@ -247,6 +247,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) $object->timespent_duration = $newduration; $object->timespent_fk_user = $usertoprocess->id; $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd'); + $object->timespent_datehour = $object->timespent_date; $result=$object->addTimeSpent($user); if ($result < 0) @@ -514,7 +515,10 @@ if (count($tasksarray) > 0) if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++; print ' - '.$langs->trans("Total").' + '; + print $langs->trans("Total"); + print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; + print '
 
 
 
@@ -544,7 +548,7 @@ $modeinput='hours'; print '