Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into
develop_dict
This commit is contained in:
commit
acd5780e32
@ -14,6 +14,7 @@ NEW: Add a payment module for Stripe.
|
||||
NEW: Add module "Product variant" (like red, blue for the product shoes)
|
||||
NEW: Accountancy - Activate multi-journal & Add journal_label to database (FEC)
|
||||
NEW: Add a tracking id into mass emailing.
|
||||
NEW: Tax system more compatible with the new tax roollout in India (IGST / CGST / SGST).
|
||||
NEW: Add calculation function for Loan schedule
|
||||
NEW: Add "depends on" and "required by" into module informations
|
||||
NEW: Add hidden option THIRDPARTY_INCLUDE_PARENT_IN_LINKTO
|
||||
|
||||
@ -353,10 +353,12 @@ begin
|
||||
begin
|
||||
// TODO Copy file or ask to install package ?
|
||||
//CustomMessage('YouWillInstallDoliWamp')+#13#13
|
||||
MsgBox('The package vcredist_x86.exe must have been installed first. It seems it is not. Please install it first from <a href="http://ccc">http://www.microsoft.com/en-us/download/details.aspx?id=30679</a> then restart DoliWamp installation/upgrade.',mbInformation,MB_OK);
|
||||
MsgBox('The package vcredist_x86.exe must have been installed first. It seems it is not. Please install it first from <a href="http://www.microsoft.com/en-us/download/details.aspx?id=30679">http://www.microsoft.com/en-us/download/details.aspx?id=30679</a> then restart DoliWamp installation/upgrade.',mbInformation,MB_OK);
|
||||
end;
|
||||
|
||||
|
||||
// Pb seems similar with msvcp110.dll
|
||||
//vcredist_x64.exe
|
||||
|
||||
|
||||
// If we have a new database version, we should only copy old my.ini file into new directory
|
||||
// and change only all basedir= strings to use new version. Like this, data dir is still correct.
|
||||
// Install of service and stop/start scripts are already rebuild by installer.
|
||||
|
||||
@ -592,6 +592,8 @@ if ($nboftargetok) {
|
||||
print "Remove subdir of custom dir\n";
|
||||
print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\;\n";
|
||||
$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type d -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs but not files
|
||||
print "find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\;\n";
|
||||
$ret=`find $BUILDROOT/$PROJECT/htdocs/custom/* -type l -exec rm -fr {} \\; >/dev/null 2>&1`; # For custom we want to remove all subdirs, even symbolic links, but not files
|
||||
}
|
||||
|
||||
# Build package for each target
|
||||
|
||||
@ -71,6 +71,7 @@ class BookKeeping extends CommonObject
|
||||
/**
|
||||
*/
|
||||
public $doc_date;
|
||||
public $date_lim_reglement;
|
||||
public $doc_type;
|
||||
public $doc_ref;
|
||||
public $fk_doc;
|
||||
@ -255,6 +256,7 @@ class BookKeeping extends CommonObject
|
||||
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " (";
|
||||
$sql .= "doc_date";
|
||||
$sql .= ", date_lim_reglement";
|
||||
$sql .= ", doc_type";
|
||||
$sql .= ", doc_ref";
|
||||
$sql .= ", fk_doc";
|
||||
@ -277,6 +279,7 @@ class BookKeeping extends CommonObject
|
||||
$sql .= ', entity';
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'" . $this->db->idate($this->doc_date) . "'";
|
||||
$sql .= ",'" . $this->db->idate($this->date_lim_reglement) . "'";
|
||||
$sql .= ",'" . $this->db->escape($this->doc_type) . "'";
|
||||
$sql .= ",'" . $this->db->escape($this->doc_ref) . "'";
|
||||
$sql .= "," . $this->fk_doc;
|
||||
@ -444,6 +447,7 @@ class BookKeeping extends CommonObject
|
||||
// Insert request
|
||||
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.'(';
|
||||
$sql .= 'doc_date,';
|
||||
$sql .= 'date_lim_reglement,';
|
||||
$sql .= 'doc_type,';
|
||||
$sql .= 'doc_ref,';
|
||||
$sql .= 'fk_doc,';
|
||||
@ -466,6 +470,7 @@ class BookKeeping extends CommonObject
|
||||
$sql .= 'entity';
|
||||
$sql .= ') VALUES (';
|
||||
$sql .= ' ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'" . $this->db->idate($this->doc_date) . "'") . ',';
|
||||
$sql .= ' ' . (! isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'" . $this->db->idate($this->date_lim_reglement) . "'") . ',';
|
||||
$sql .= ' ' . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ',';
|
||||
$sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ',';
|
||||
$sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ',';
|
||||
@ -540,6 +545,7 @@ class BookKeeping extends CommonObject
|
||||
$sql = 'SELECT';
|
||||
$sql .= ' t.rowid,';
|
||||
$sql .= " t.doc_date,";
|
||||
$sql .= " t.date_lim_reglement,";
|
||||
$sql .= " t.doc_type,";
|
||||
$sql .= " t.doc_ref,";
|
||||
$sql .= " t.fk_doc,";
|
||||
@ -577,6 +583,7 @@ class BookKeeping extends CommonObject
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
$this->doc_date = $this->db->jdate($obj->doc_date);
|
||||
$this->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement);
|
||||
$this->doc_type = $obj->doc_type;
|
||||
$this->doc_ref = $obj->doc_ref;
|
||||
$this->fk_doc = $obj->fk_doc;
|
||||
@ -1260,7 +1267,7 @@ class BookKeeping extends CommonObject
|
||||
|
||||
global $user;
|
||||
$error = 0;
|
||||
$object = new Accountingbookkeeping($this->db);
|
||||
$object = new BookKeeping($this->db);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
@ -401,7 +401,7 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = $val["label"];
|
||||
$bookkeeping->label_compte = $langs->trans("Bank");
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
||||
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
||||
@ -462,7 +462,7 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'];
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||
|
||||
@ -203,7 +203,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
|
||||
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
|
||||
$bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
|
||||
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
|
||||
$bookkeeping->code_journal = $journal;
|
||||
$bookkeeping->journal_label = $journal_label;
|
||||
|
||||
@ -85,7 +85,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
|
||||
$idpays = $mysoc->country_id;
|
||||
|
||||
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,";
|
||||
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, ";
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
|
||||
@ -155,6 +155,7 @@ if ($result) {
|
||||
}
|
||||
|
||||
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
|
||||
$tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr);
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
|
||||
$tabfac[$obj->rowid]["refsologest"] = $obj->ref;
|
||||
$tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier;
|
||||
@ -222,6 +223,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
@ -269,6 +271,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($accountingaccount->fetch(null, $k, true)) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
@ -322,6 +325,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
|
||||
@ -89,7 +89,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
|
||||
$idpays = $mysoc->country_id;
|
||||
|
||||
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,";
|
||||
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr,";
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
|
||||
@ -178,6 +178,7 @@ if ($result) {
|
||||
|
||||
// Invoice lines
|
||||
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
|
||||
$tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr);
|
||||
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
|
||||
$tabfac[$obj->rowid]["type"] = $obj->type;
|
||||
$tabfac[$obj->rowid]["description"] = $obj->label_compte;
|
||||
@ -240,6 +241,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
@ -287,6 +289,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($accountingaccount->fetch(null, $k, true)) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
@ -340,6 +343,7 @@ if ($action == 'writebookkeeping') {
|
||||
if ($mt) {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'customer_invoice';
|
||||
|
||||
@ -43,23 +43,23 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
class Categorie extends CommonObject
|
||||
{
|
||||
// Categories types
|
||||
const TYPE_PRODUCT = 0; // TODO Replace with value 'product'
|
||||
const TYPE_SUPPLIER = 1; // TODO Replace this value with 'supplier'
|
||||
const TYPE_CUSTOMER = 2; // TODO Replace this value with 'customer'
|
||||
const TYPE_MEMBER = 3; // TODO Replace this value with 'member'
|
||||
const TYPE_CONTACT = 4; // TODO Replace this value with 'contact'
|
||||
const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user'
|
||||
|
||||
const TYPE_ACCOUNT = 5; // TODO Replace this value with 'bank_account'
|
||||
const TYPE_PROJECT = 6; // TODO Replace this value with 'project'
|
||||
const TYPE_PRODUCT = 'product';
|
||||
const TYPE_SUPPLIER = 'supplier';
|
||||
const TYPE_CUSTOMER = 'customer';
|
||||
const TYPE_MEMBER = 'member';
|
||||
const TYPE_CONTACT = 'contact';
|
||||
const TYPE_USER = 'user';
|
||||
const TYPE_PROJECT = 'project';
|
||||
const TYPE_ACCOUNT = 'bank_account';
|
||||
const TYPE_BANK_LINE = 'bank_line';
|
||||
|
||||
public $picto = 'category';
|
||||
|
||||
|
||||
/**
|
||||
* @var array ID mapping from type string
|
||||
*
|
||||
* @note This array should be remove in future, once previous constants are moved to the string value.
|
||||
* @note This array should be remove in future, once previous constants are moved to the string value. Deprecated
|
||||
*/
|
||||
private $MAP_ID = array(
|
||||
'product' => 0,
|
||||
@ -67,10 +67,21 @@ class Categorie extends CommonObject
|
||||
'customer' => 2,
|
||||
'member' => 3,
|
||||
'contact' => 4,
|
||||
'user' => 4,
|
||||
'account' => 5,
|
||||
'project' => 6,
|
||||
'user' => 7,
|
||||
);
|
||||
public static $MAP_ID_TO_CODE = array(
|
||||
0 => 'product',
|
||||
1 => 'supplier',
|
||||
2 => 'customer',
|
||||
3 => 'member',
|
||||
4 => 'contact',
|
||||
5 => 'account',
|
||||
6 => 'project',
|
||||
7 => 'user',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array Foreign keys mapping from type string
|
||||
*
|
||||
@ -82,9 +93,9 @@ class Categorie extends CommonObject
|
||||
'supplier' => 'soc',
|
||||
'member' => 'member',
|
||||
'contact' => 'socpeople',
|
||||
'user' => 'user',
|
||||
'account' => 'account',
|
||||
'project' => 'project',
|
||||
'user' => 'user',
|
||||
'account' => 'account',
|
||||
'project' => 'project',
|
||||
);
|
||||
/**
|
||||
* @var array Category tables mapping from type string
|
||||
@ -97,9 +108,9 @@ class Categorie extends CommonObject
|
||||
'supplier' => 'fournisseur',
|
||||
'member' => 'member',
|
||||
'contact' => 'contact',
|
||||
'user' => 'user',
|
||||
'account' => 'account',
|
||||
'project' => 'project',
|
||||
'user' => 'user',
|
||||
'account' => 'account',
|
||||
'project' => 'project',
|
||||
);
|
||||
/**
|
||||
* @var array Object class mapping from type string
|
||||
@ -113,8 +124,8 @@ class Categorie extends CommonObject
|
||||
'member' => 'Adherent',
|
||||
'contact' => 'Contact',
|
||||
'user' => 'User',
|
||||
'account' => 'Account',
|
||||
'project' => 'Project',
|
||||
'account' => 'Account',
|
||||
'project' => 'Project',
|
||||
);
|
||||
/**
|
||||
* @var array Object table mapping from type string
|
||||
@ -128,8 +139,8 @@ class Categorie extends CommonObject
|
||||
'member' => 'adherent',
|
||||
'contact' => 'socpeople',
|
||||
'user' => 'user',
|
||||
'account' => 'bank_account',
|
||||
'project' => 'projet',
|
||||
'account' => 'bank_account',
|
||||
'project' => 'projet',
|
||||
);
|
||||
|
||||
public $element='category';
|
||||
|
||||
@ -39,6 +39,8 @@ $id=GETPOST('id','int');
|
||||
$type=(GETPOST('type','aZ09') ? GETPOST('type','aZ09') : Categorie::TYPE_PRODUCT);
|
||||
$catname=GETPOST('catname','alpha');
|
||||
|
||||
if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -53,8 +55,8 @@ elseif ($type == Categorie::TYPE_CUSTOMER) { $title=$langs->trans("CustomersCat
|
||||
elseif ($type == Categorie::TYPE_MEMBER) { $title=$langs->trans("MembersCategoriesArea"); $typetext='member'; }
|
||||
elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCategoriesArea"); $typetext='contact'; }
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='account'; }
|
||||
elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; }
|
||||
elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; }
|
||||
elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; }
|
||||
else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; }
|
||||
|
||||
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
|
||||
|
||||
@ -42,6 +42,8 @@ $type=GETPOST('type');
|
||||
$action=GETPOST('action','aZ09');
|
||||
$confirm=GETPOST('confirm');
|
||||
|
||||
if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
|
||||
if ($id == "")
|
||||
{
|
||||
dol_print_error('','Missing parameter id');
|
||||
@ -100,15 +102,16 @@ if ($object->id)
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
|
||||
else $title=$langs->trans("Category");
|
||||
elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort");
|
||||
else $title=$langs->trans("Category");
|
||||
|
||||
$head = categories_prepare_head($object,$type);
|
||||
|
||||
|
||||
dol_fiche_head($head, 'photos', $title, -1, 'category');
|
||||
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
$object->ref = $object->label;
|
||||
$morehtmlref='<br><div class="refidno"><a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> ';
|
||||
$ways = $object->print_all_ways(" >> ", '', 1);
|
||||
@ -117,9 +120,9 @@ if ($object->id)
|
||||
$morehtmlref.=$way."<br>\n";
|
||||
}
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression de photo
|
||||
*/
|
||||
@ -129,7 +132,7 @@ if ($object->id)
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border" width="100%">';
|
||||
@ -148,7 +151,7 @@ if ($object->id)
|
||||
|
||||
print "</table>\n";
|
||||
print '</div>';
|
||||
|
||||
|
||||
print dol_fiche_end();
|
||||
|
||||
|
||||
@ -258,7 +261,7 @@ if ($object->id)
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
if ($nbphoto < 1)
|
||||
{
|
||||
print '<div class="opacitymedium">'.$langs->trans("NoPhotoYet")."</div>";
|
||||
|
||||
@ -35,11 +35,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
$langs->load("categories");
|
||||
$langs->load("languages");
|
||||
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action=GETPOST('action','alpha');
|
||||
$cancel=GETPOST('cancel','alpha');
|
||||
$type=GETPOST('type');
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action','alpha');
|
||||
$cancel = GETPOST('cancel','alpha');
|
||||
$type = GETPOST('type','aZ09');
|
||||
|
||||
if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
|
||||
// Security check
|
||||
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
|
||||
@ -153,6 +155,7 @@ elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategor
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort");
|
||||
else $title=$langs->trans("Category");
|
||||
|
||||
$head = categories_prepare_head($object,$type);
|
||||
@ -256,9 +259,9 @@ if ($action == 'edit')
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
@ -271,7 +274,7 @@ if ($action == 'edit')
|
||||
else if ($action != 'add')
|
||||
{
|
||||
if ($cnt_trans) print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
if (! empty($object->multilangs))
|
||||
{
|
||||
foreach ($object->multilangs as $key => $value)
|
||||
|
||||
@ -34,13 +34,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
|
||||
$langs->load("categories");
|
||||
|
||||
$id=GETPOST('id','int');
|
||||
$label=GETPOST('label');
|
||||
$type=GETPOST('type');
|
||||
$id = GETPOST('id','int');
|
||||
$label= GETPOST('label','alpha');
|
||||
$type = GETPOST('type','az09');
|
||||
$action=GETPOST('action','aZ09');
|
||||
$confirm=GETPOST('confirm');
|
||||
$confirm = GETPOST('confirm','alpha');
|
||||
$removeelem = GETPOST('removeelem','int');
|
||||
$elemid=GETPOST('elemid');
|
||||
$elemid = GETPOST('elemid','alpha');
|
||||
|
||||
if ($id == "" && $label == "")
|
||||
{
|
||||
@ -61,6 +61,7 @@ if ($result <= 0)
|
||||
}
|
||||
|
||||
$type=$object->type;
|
||||
if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
@ -187,6 +188,7 @@ elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategor
|
||||
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
|
||||
elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("ProjectsCategoriesShort");
|
||||
else $title=$langs->trans("Category");
|
||||
|
||||
$head = categories_prepare_head($object,$type);
|
||||
|
||||
@ -603,11 +603,17 @@ if ($id > 0)
|
||||
if ($link) $boxstat.='</a>';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreBoxStatsCustomer', $parameters, $object, $action);
|
||||
if(empty($reshook)){
|
||||
$boxstat.= $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
$boxstat.='</td></tr>';
|
||||
$boxstat.='</table>';
|
||||
$boxstat.='</div>';
|
||||
|
||||
print $boxstat;
|
||||
print $boxstat;
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
|
||||
@ -1750,6 +1750,7 @@ if ($action == 'create')
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
|
||||
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherProposals").'</a>)';
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
|
||||
@ -1924,6 +1924,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
|
||||
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherOrders").'</a>)';
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
|
||||
@ -72,7 +72,7 @@ class BankAccounts extends DolibarrApi
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t";
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('bank_account').')';
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
@ -81,7 +81,7 @@ class BankAccounts extends DolibarrApi
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
@ -89,10 +89,10 @@ class BankAccounts extends DolibarrApi
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
|
||||
$sql.= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
|
||||
dol_syslog("API Rest request");
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
@ -236,7 +236,7 @@ class BankAccounts extends DolibarrApi
|
||||
function _validate($data)
|
||||
{
|
||||
$account = array();
|
||||
foreach (Accounts::$FIELDS as $field) {
|
||||
foreach (BankAccounts::$FIELDS as $field) {
|
||||
if (! isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$account[$field] = $data[$field];
|
||||
|
||||
@ -400,6 +400,22 @@ if (empty($reshook))
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $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);
|
||||
}
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'setref_client' && $user->rights->facture->creer)
|
||||
@ -1108,8 +1124,17 @@ if (empty($reshook))
|
||||
|
||||
foreach ($amountdeposit as $tva => $amount)
|
||||
{
|
||||
$arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
|
||||
$descline = $langs->trans('Deposit');
|
||||
$descline.= ' - '.$langs->trans($arraylist[$typeamount]);
|
||||
if ($typeamount=='amount') {
|
||||
$descline.= ' ('. price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')';
|
||||
} elseif ($typeamount=='variable') {
|
||||
$descline.= ' ('. $valuedeposit.'%)';
|
||||
}
|
||||
$descline.= ' - '.$srcobject->ref;
|
||||
$result = $object->addline(
|
||||
$langs->trans('Deposit'),
|
||||
$descline,
|
||||
$amount, // subprice
|
||||
1, // quantity
|
||||
$tva, // vat rate
|
||||
@ -1131,8 +1156,8 @@ if (empty($reshook))
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
$langs->trans('Deposit')
|
||||
0
|
||||
//,$langs->trans('Deposit') //Deprecated
|
||||
);
|
||||
}
|
||||
|
||||
@ -3078,6 +3103,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
|
||||
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherBills").'</a>)';
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
|
||||
@ -338,6 +338,24 @@ class Paiement extends CommonObject
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$ret = $invoice->fetch($id); // Reload to get new records
|
||||
|
||||
$result = $invoice->generateDocument($invoice->modelpdf, $outputlangs);
|
||||
if ($result < 0) {
|
||||
setEventMessages($invoice->error, $invoice->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,7 +305,7 @@ if ($resql)
|
||||
$i = 0;
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
|
||||
|
||||
if ($socid > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
@ -313,7 +313,7 @@ if ($resql)
|
||||
if (empty($search_name)) $search_name = $soc->name;
|
||||
}
|
||||
|
||||
$param='';
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($sall != '') $param.='&sall='.$sall;
|
||||
|
||||
@ -332,7 +332,7 @@ if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights-
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
|
||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
|
||||
$moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1);
|
||||
$moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1);
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
|
||||
@ -523,7 +523,6 @@ while ($i < min($num,$limit))
|
||||
$contractstatic->ref=$obj->ref?$obj->ref:$obj->cid;
|
||||
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
|
||||
@ -28,9 +28,9 @@
|
||||
// $cancel must be defined
|
||||
// $id or $ref must be defined (object is loaded in this file with fetch)
|
||||
|
||||
if (($id > 0 || (! empty($ref) && ! in_array($action, array('create','createtask')))) && empty($cancel))
|
||||
if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && empty($cancel))
|
||||
{
|
||||
$ret = $object->fetch($id,$ref);
|
||||
$ret = $object->fetch($id, $ref);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
@ -38,7 +38,8 @@ if (($id > 0 || (! empty($ref) && ! in_array($action, array('create','createtask
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
if (empty($object->error) && ! count($object->errors)) setEventMessages('Fetch on object return an error without filling $object->error nor $object->errors', null, 'errors');
|
||||
else setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,7 +594,7 @@ if (! $error && $massaction == 'delete' && $permtodelete)
|
||||
$nbok = 0;
|
||||
foreach($toselect as $toselectid)
|
||||
{
|
||||
$result=$objecttmp->fetch($toselectid);
|
||||
$result=$objecttmp->fetch($toselectid);
|
||||
if ($result > 0)
|
||||
{
|
||||
if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
|
||||
|
||||
@ -31,8 +31,17 @@ if (! isset($usedbyinclude) || empty($usedbyinclude))
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
if (! defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN','1');
|
||||
|
||||
$res=@include '../../main.inc.php';
|
||||
if ($res == 'ERROR_NOT_LOGGED')
|
||||
{
|
||||
$langs->load("other");
|
||||
$arrayresult['jumptologin']=array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>'<span class="fa fa-sign-in"></span> '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php');
|
||||
print json_encode($arrayresult);
|
||||
if (is_object($db)) $db->close();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
||||
|
||||
@ -334,23 +334,23 @@ abstract class CommonObject
|
||||
// No constructor as it is an abstract class
|
||||
|
||||
|
||||
/**
|
||||
* Check an object id/ref exists
|
||||
* If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch
|
||||
*
|
||||
/**
|
||||
* Check an object id/ref exists
|
||||
* If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch
|
||||
*
|
||||
* @param string $element String of element ('product', 'facture', ...)
|
||||
* @param int $id Id of object
|
||||
* @param string $ref Ref of object to check
|
||||
* @param string $ref_ext Ref ext of object to check
|
||||
* @return int <0 if KO, 0 if OK but not found, >0 if OK and exists
|
||||
*/
|
||||
static function isExistingObject($element, $id, $ref='', $ref_ext='')
|
||||
{
|
||||
global $db,$conf;
|
||||
*/
|
||||
static function isExistingObject($element, $id, $ref='', $ref_ext='')
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
$sql = "SELECT rowid, ref, ref_ext";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$element;
|
||||
$sql.= " WHERE entity IN (".getEntity($element, true).")" ;
|
||||
$sql.= " WHERE entity IN (".getEntity($element).")" ;
|
||||
|
||||
if ($id > 0) $sql.= " AND rowid = ".$db->escape($id);
|
||||
else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'";
|
||||
@ -371,17 +371,17 @@ abstract class CommonObject
|
||||
else return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to output saved errors
|
||||
*
|
||||
* @return string String with errors
|
||||
*/
|
||||
function errorsToString()
|
||||
{
|
||||
return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):'');
|
||||
}
|
||||
/**
|
||||
* Method to output saved errors
|
||||
*
|
||||
* @return string String with errors
|
||||
*/
|
||||
function errorsToString()
|
||||
{
|
||||
return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):'');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return full name (civility+' '+name+' '+lastname)
|
||||
@ -1309,7 +1309,7 @@ abstract class CommonObject
|
||||
* Load properties id_previous and id_next
|
||||
*
|
||||
* @param string $filter Optional filter. Example: " AND (t.field1 = 'aa' OR t.field2 = 'bb')"
|
||||
* @param int $fieldid Name of field to use for the select MAX and MIN
|
||||
* @param string $fieldid Name of field to use for the select MAX and MIN
|
||||
* @param int $nodbprefix Do not include DB prefix to forge table name
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
@ -1322,6 +1322,7 @@ abstract class CommonObject
|
||||
dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined");
|
||||
return -1;
|
||||
}
|
||||
if ($fieldid == 'none') return 1;
|
||||
|
||||
// this->ismultientitymanaged contains
|
||||
// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
@ -3947,7 +3948,7 @@ abstract class CommonObject
|
||||
|
||||
// Now we add first model found in directories scanned
|
||||
$listofdir=explode(',',$dirtoscan);
|
||||
foreach($listofdir as $key=>$tmpdir)
|
||||
foreach($listofdir as $key => $tmpdir)
|
||||
{
|
||||
$tmpdir=trim($tmpdir);
|
||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
|
||||
@ -4736,19 +4737,6 @@ abstract class CommonObject
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function test if type is date
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isDate($info)
|
||||
{
|
||||
if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is array
|
||||
*
|
||||
@ -4781,13 +4769,26 @@ abstract class CommonObject
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function test if type is date
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
public function isDate($info)
|
||||
{
|
||||
if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is integer
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isInt($info)
|
||||
public function isInt($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
@ -4803,11 +4804,11 @@ abstract class CommonObject
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isFloat($info)
|
||||
public function isFloat($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='float') return true;
|
||||
if (isset($info['type']) && (preg_match('/^(double|real)/i', $info['type']))) return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
@ -4819,7 +4820,7 @@ abstract class CommonObject
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isText($info)
|
||||
public function isText($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
@ -4846,49 +4847,58 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to prepare the values to insert
|
||||
* Function to prepare the values to insert.
|
||||
* Note $this->${field} are set by the page that make the createCommon or the updateCommon.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function set_save_query()
|
||||
{
|
||||
$query=array();
|
||||
foreach ($this->fields as $field=>$info)
|
||||
global $conf;
|
||||
|
||||
$queryarray=array();
|
||||
foreach ($this->fields as $field=>$info) // Loop on definition of fields
|
||||
{
|
||||
// Depending on field type ('datetime', ...)
|
||||
if($this->isDate($info))
|
||||
{
|
||||
if(empty($this->{$field}))
|
||||
{
|
||||
$query[$field] = NULL;
|
||||
$queryarray[$field] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$query[$field] = $this->db->idate($this->{$field});
|
||||
$queryarray[$field] = $this->db->idate($this->{$field});
|
||||
}
|
||||
}
|
||||
else if($this->isArray($info))
|
||||
{
|
||||
$query[$field] = serialize($this->{$field});
|
||||
$queryarray[$field] = serialize($this->{$field});
|
||||
}
|
||||
else if($this->isInt($info))
|
||||
{
|
||||
$query[$field] = (int) price2num($this->{$field});
|
||||
if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field]=$conf->entity;
|
||||
else
|
||||
{
|
||||
$queryarray[$field] = (int) price2num($this->{$field});
|
||||
if (empty($queryarray[$field])) $queryarray[$field]=0; // May be rest to null later if property 'nullifempty' is on for this field.
|
||||
}
|
||||
}
|
||||
else if($this->isFloat($info))
|
||||
{
|
||||
$query[$field] = (double) price2num($this->{$field});
|
||||
}
|
||||
elseif($this->isNull($info))
|
||||
{
|
||||
$query[$field] = (is_null($this->{$field}) || (empty($this->{$field}) && $this->{$field}!==0 && $this->{$field}!=='0') ? null : $this->{$field});
|
||||
$queryarray[$field] = (double) price2num($this->{$field});
|
||||
if (empty($queryarray[$field])) $queryarray[$field]=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$query[$field] = $this->{$field};
|
||||
$queryarray[$field] = $this->{$field};
|
||||
}
|
||||
|
||||
if ($info['type'] == 'timestamp' && empty($queryarray[$field])) unset($queryarray[$field]);
|
||||
if (! empty($info['nullifempty']) && empty($queryarray[$field])) $queryarray[$field] = null;
|
||||
}
|
||||
|
||||
return $query;
|
||||
return $queryarray;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4896,7 +4906,7 @@ abstract class CommonObject
|
||||
*
|
||||
* @param stdClass $obj Contain data of object from database
|
||||
*/
|
||||
private function set_vars_by_db(&$obj)
|
||||
private function setVarsFromFetchObj(&$obj)
|
||||
{
|
||||
foreach ($this->fields as $field => $info)
|
||||
{
|
||||
@ -4913,7 +4923,8 @@ abstract class CommonObject
|
||||
}
|
||||
elseif($this->isInt($info))
|
||||
{
|
||||
$this->{$field} = (int) $obj->{$field};
|
||||
if ($field == 'rowid') $this->id = (int) $obj->{$field};
|
||||
else $this->{$field} = (int) $obj->{$field};
|
||||
}
|
||||
elseif($this->isFloat($info))
|
||||
{
|
||||
@ -4947,15 +4958,14 @@ abstract class CommonObject
|
||||
/**
|
||||
* Add quote to field value if necessary
|
||||
*
|
||||
* @param string|int $value value to protect
|
||||
* @return string|int
|
||||
* @param string|int $value Value to protect
|
||||
* @param array $fieldsentry Properties of field
|
||||
* @return string
|
||||
*/
|
||||
protected function quote($value) {
|
||||
|
||||
if(is_null($value)) return 'NULL';
|
||||
else if(is_numeric($value)) return $value;
|
||||
else return "'".$this->db->escape( $value )."'";
|
||||
|
||||
protected function quote($value, $fieldsentry) {
|
||||
if (is_null($value)) return 'NULL';
|
||||
else if (preg_match('/^(int|double|real)/i', $fieldsentry['type'])) return $this->db->escape("$value");
|
||||
else return "'".$this->db->escape($value)."'";
|
||||
}
|
||||
|
||||
|
||||
@ -4970,23 +4980,29 @@ abstract class CommonObject
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query());
|
||||
$now=dol_now();
|
||||
|
||||
$fieldvalues = $this->set_save_query();
|
||||
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now);
|
||||
if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id;
|
||||
unset($fieldvalues['rowid']); // We suppose the field rowid is reserved field for autoincrement field.
|
||||
|
||||
$keys=array();
|
||||
$values = array();
|
||||
foreach ($fields as $k => $v) {
|
||||
foreach ($fieldvalues as $k => $v) {
|
||||
$keys[] = $k;
|
||||
$values[] = $this->quote($v);
|
||||
$values[] = $this->quote($v, $this->fields[$k]);
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'
|
||||
( '.implode( ",", $keys ).' )
|
||||
VALUES ( '.implode( ",", $values ).' ) ';
|
||||
$res = $this->db->query( $sql );
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= ' ('.implode( ", ", $keys ).')';
|
||||
$sql.= ' VALUES ('.implode( ", ", $values ).')';
|
||||
|
||||
$res = $this->db->query( $sql );
|
||||
if ($res===false) {
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
@ -4998,7 +5014,7 @@ abstract class CommonObject
|
||||
|
||||
if (!$notrigger) {
|
||||
// Call triggers
|
||||
$result=$this->call_trigger(strtoupper(get_class(self)).'_CREATE',$user);
|
||||
$result=$this->call_trigger(strtoupper(get_class($this)).'_CREATE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
@ -5035,8 +5051,10 @@ abstract class CommonObject
|
||||
|
||||
// Load source object
|
||||
$object->fetchCommon($fromid);
|
||||
// Reset object
|
||||
$object->id = 0;
|
||||
// Reset some properties
|
||||
unset($object->id);
|
||||
unset($object->fk_user_creat);
|
||||
unset($object->import_key);
|
||||
|
||||
// Clear fields
|
||||
$object->ref = "copy_of_".$object->ref;
|
||||
@ -5075,11 +5093,11 @@ abstract class CommonObject
|
||||
{
|
||||
if (empty($id) && empty($ref)) return false;
|
||||
|
||||
$sql = 'SELECT '.$this->get_field_list().', datec, tms';
|
||||
$sql = 'SELECT '.$this->get_field_list();
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||
|
||||
if(!empty($id)) $sql.= ' WHERE rowid = '.$id;
|
||||
else $sql.= ' WHERE ref = \''.$this->quote($ref).'\'';
|
||||
else $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']);
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if ($res)
|
||||
@ -5088,12 +5106,7 @@ abstract class CommonObject
|
||||
{
|
||||
if ($obj)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->set_vars_by_db($obj);
|
||||
|
||||
$this->datec = $this->db->idate($obj->datec);
|
||||
$this->tms = $this->db->idate($obj->tms);
|
||||
|
||||
$this->setVarsFromFetchObj($obj);
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
@ -5127,27 +5140,27 @@ abstract class CommonObject
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$fields = $this->set_save_query();
|
||||
$fieldvalues = $this->set_save_query();
|
||||
unset($fieldvalues['rowid']); // We don't update this field, it is the key to define which record to update.
|
||||
|
||||
foreach ($fields as $k => $v) {
|
||||
foreach ($fieldvalues as $k => $v) {
|
||||
if (is_array($key)){
|
||||
$i=array_search($k, $key);
|
||||
if ( $i !== false) {
|
||||
$where[] = $key[$i].'=' . $this->quote( $v ) ;
|
||||
$where[] = $key[$i].'=' . $this->quote($v, $this->fields[$k]);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if ( $k == $key) {
|
||||
$where[] = $k.'=' .$this->quote( $v ) ;
|
||||
$where[] = $k.'=' .$this->quote($v, $this->fields[$k]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$tmp[] = $k.'='.$this->quote($v);
|
||||
$tmp[] = $k.'='.$this->quote($v, $this->fields[$k]);
|
||||
}
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$res = $this->db->query($sql);
|
||||
@ -5160,7 +5173,7 @@ abstract class CommonObject
|
||||
|
||||
if (! $error && ! $notrigger) {
|
||||
// Call triggers
|
||||
$result=$this->call_trigger(strtoupper(get_class(self)).'_MODIFY',$user);
|
||||
$result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY',$user);
|
||||
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
|
||||
// End call triggers
|
||||
}
|
||||
@ -5191,7 +5204,7 @@ abstract class CommonObject
|
||||
if (! $error) {
|
||||
if (! $notrigger) {
|
||||
// Call triggers
|
||||
$result=$this->call_trigger(strtoupper(get_class(self)).'_DELETE', $user);
|
||||
$result=$this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user);
|
||||
if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ class DolEditor
|
||||
// Check if extended editor is ok. If not we force textarea
|
||||
if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea';
|
||||
if ($okforextendededitor === 'ace') $this->tool='ace';
|
||||
if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // TODO ckeditor ko with mobile ? ace ko with mobile ?
|
||||
//if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile
|
||||
|
||||
// Define content and some properties
|
||||
if ($this->tool == 'ckeditor')
|
||||
|
||||
@ -281,7 +281,7 @@ class ExtraFields
|
||||
*/
|
||||
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $default='', $computed='')
|
||||
{
|
||||
global $conf;
|
||||
global $conf,$user;
|
||||
|
||||
if ($elementtype == 'thirdparty') $elementtype='societe';
|
||||
if ($elementtype == 'contact') $elementtype='socpeople';
|
||||
@ -305,7 +305,27 @@ class ExtraFields
|
||||
$params='';
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms, list, ishidden, fielddefault, fieldcomputed)";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(";
|
||||
$sql.= " name,";
|
||||
$sql.= " label,";
|
||||
$sql.= " type,";
|
||||
$sql.= " pos,";
|
||||
$sql.= " size,";
|
||||
$sql.= " entity,";
|
||||
$sql.= " elementtype,";
|
||||
$sql.= " fieldunique,";
|
||||
$sql.= " fieldrequired,";
|
||||
$sql.= " param,";
|
||||
$sql.= " alwayseditable,";
|
||||
$sql.= " perms,";
|
||||
$sql.= " list,";
|
||||
$sql.= " ishidden,";
|
||||
$sql.= " fielddefault,";
|
||||
$sql.= " fieldcomputed,";
|
||||
$sql.= " fk_user_author,";
|
||||
$sql.= " fk_user_modif,";
|
||||
$sql.= " datec";
|
||||
$sql.= " )";
|
||||
$sql.= " VALUES('".$attrname."',";
|
||||
$sql.= " '".$this->db->escape($label)."',";
|
||||
$sql.= " '".$type."',";
|
||||
@ -321,9 +341,12 @@ class ExtraFields
|
||||
$sql.= " ".$list.",";
|
||||
$sql.= " ".$ishidden.",";
|
||||
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
|
||||
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null");
|
||||
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= "'" . $this->db->idate(dol_now()) . "'";
|
||||
$sql.=')';
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::create_label", LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
@ -562,7 +585,7 @@ class ExtraFields
|
||||
*/
|
||||
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$ishidden=0,$default='',$computed='')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $user;
|
||||
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$ishidden.", ".$default.", ".$computed);
|
||||
|
||||
// Clean parameters
|
||||
@ -603,7 +626,10 @@ class ExtraFields
|
||||
$sql.= " list,";
|
||||
$sql.= " ishidden,";
|
||||
$sql.= " fielddefault,";
|
||||
$sql.= " fieldcomputed";
|
||||
$sql.= " fieldcomputed,";
|
||||
$sql.= " fk_user_author,";
|
||||
$sql.= " fk_user_modif,";
|
||||
$sql.= " datec";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$attrname."',";
|
||||
$sql.= " ".$conf->entity.",";
|
||||
@ -620,7 +646,10 @@ class ExtraFields
|
||||
$sql.= " ".$list.", ";
|
||||
$sql.= " ".$ishidden.", ";
|
||||
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
|
||||
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null");
|
||||
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
$sql .= "'" . $this->db->idate(dol_now()) . "'";
|
||||
$sql.= ")";
|
||||
|
||||
$resql2=$this->db->query($sql);
|
||||
|
||||
@ -5866,7 +5866,7 @@ class Form
|
||||
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link.
|
||||
* @param string $morehtml More html content to output just before the nav bar.
|
||||
* @param int $shownav Show Condition (navigation is shown if value is 1).
|
||||
* @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field).
|
||||
* @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field). Use 'none' to disable next/prev.
|
||||
* @param string $fieldref Name of field ref of object (object->ref) to show or 'none' to not show ref.
|
||||
* @param string $morehtmlref More html to show after ref.
|
||||
* @param string $moreparam More param to add in nav link url. Must start with '&...'.
|
||||
|
||||
1254
htdocs/core/class/html.formwebsite.class.php
Normal file
1254
htdocs/core/class/html.formwebsite.class.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -393,6 +393,7 @@ function dol_dir_is_emtpy($folder)
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @return int <0 if KO, Number of lines in files if OK
|
||||
* @see dol_nboflines
|
||||
*/
|
||||
function dol_count_nb_of_line($file)
|
||||
{
|
||||
|
||||
@ -627,18 +627,26 @@ function dol_buildpath($path, $type=0)
|
||||
|
||||
/**
|
||||
* Create a clone of instance of object (new instance with same value for properties)
|
||||
* Property that are reference are also new object (true clone)
|
||||
* With native = 0: Property that are reference are also new object (true clone). This means $this->db is not valid.
|
||||
* With native = 1: Use PHP clone. Property that are reference are same pointer. This means $this->db is still valid.
|
||||
*
|
||||
* @param object $object Object to clone
|
||||
* @param int $native Native method or true method
|
||||
* @return object Object clone
|
||||
* @see https://php.net/manual/language.oop5.cloning.php
|
||||
*/
|
||||
function dol_clone($object)
|
||||
function dol_clone($object, $native=0)
|
||||
{
|
||||
//dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
|
||||
|
||||
//$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable
|
||||
$myclone=unserialize(serialize($object));
|
||||
if (empty($native))
|
||||
{
|
||||
$myclone=unserialize(serialize($object));
|
||||
}
|
||||
else
|
||||
{
|
||||
$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable)
|
||||
}
|
||||
|
||||
return $myclone;
|
||||
}
|
||||
@ -1130,7 +1138,7 @@ function dol_get_fiche_end($notab=0)
|
||||
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link
|
||||
* @param string $morehtml More html content to output just before the nav bar
|
||||
* @param int $shownav Show Condition (navigation is shown if value is 1)
|
||||
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
|
||||
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field). Use 'none' for no prev/next search.
|
||||
* @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
|
||||
* @param string $morehtmlref More html to show after ref
|
||||
* @param string $moreparam More param to add in nav link url.
|
||||
@ -1281,7 +1289,8 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
if ($object->element == 'project' && ! $object->public) $picto = 'project'; // instead of projectpub
|
||||
$nophoto=img_picto('', 'object_'.$picto, '', false, 1);
|
||||
}
|
||||
$morehtmlleft.='<!-- No photo to show --><div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').' src="'.$nophoto.'"></div></div>';
|
||||
$morehtmlleft.='<!-- No photo to show -->';
|
||||
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').' src="'.$nophoto.'"></div></div>';
|
||||
$morehtmlleft.='</div>';
|
||||
}
|
||||
}
|
||||
@ -2548,7 +2557,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
||||
if ($pictoisfullpath)
|
||||
{
|
||||
// Clean parameters
|
||||
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png';
|
||||
if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png';
|
||||
$fullpathpicto = $picto;
|
||||
}
|
||||
else
|
||||
@ -2570,7 +2579,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png';
|
||||
if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png';
|
||||
// If alt path are defined, define url where img file is, according to physical path
|
||||
foreach ($conf->file->dol_document_root as $type => $dirroot) // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir0/htdocs", ...)
|
||||
{
|
||||
@ -4769,22 +4778,57 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
|
||||
* Return first line of text. Cut will depends if content is HTML or not.
|
||||
*
|
||||
* @param string $text Input text
|
||||
* @param int $nboflines Nb of lines to get (default is 1 = first line only)
|
||||
* @return string Output text
|
||||
* @see dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag
|
||||
*/
|
||||
function dolGetFirstLineOfText($text)
|
||||
function dolGetFirstLineOfText($text, $nboflines=1)
|
||||
{
|
||||
if (dol_textishtml($text))
|
||||
if ($nboflines == 1)
|
||||
{
|
||||
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
|
||||
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
|
||||
if (dol_textishtml($text))
|
||||
{
|
||||
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
|
||||
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$firstline=preg_replace('/[\n\r].*/','',$text);
|
||||
}
|
||||
return $firstline.((strlen($firstline) != strlen($text))?'...':'');
|
||||
}
|
||||
else
|
||||
{
|
||||
$firstline=preg_replace('/[\n\r].*/','',$text);
|
||||
$ishtml=0;
|
||||
if (dol_textishtml($text))
|
||||
{
|
||||
$text=preg_replace('/\n/','',$text);
|
||||
$ishtml=1;
|
||||
$repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
$repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
||||
}
|
||||
|
||||
$text = strtr($text, $repTable);
|
||||
if ($charset == 'UTF-8') { $pattern = '/(<br[^>]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
|
||||
else $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag.
|
||||
$a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$firstline='';
|
||||
$i=0;
|
||||
$nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator
|
||||
while (($i < $nba) && ($i < ($nboflines * 2)))
|
||||
{
|
||||
if ($i % 2 == 0) $firstline .= $a[$i];
|
||||
elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) $firstline .= ($ishtml?"<br>\n":"\n");
|
||||
$i++;
|
||||
}
|
||||
unset($a);
|
||||
return $firstline.(($i < $nba)?'...':'');
|
||||
}
|
||||
return $firstline.((strlen($firstline) != strlen($text))?'...':'');
|
||||
}
|
||||
|
||||
|
||||
@ -4946,7 +4990,7 @@ function dol_nboflines($s,$maxchar=0)
|
||||
|
||||
|
||||
/**
|
||||
* Return nb of lines of a formated text with \n and <br> (we can't have both \n and br)
|
||||
* Return nb of lines of a formated text with \n and <br> (WARNING: string must not have mixed \n and br separators)
|
||||
*
|
||||
* @param string $text Text
|
||||
* @param int $maxlinesize Largeur de ligne en caracteres (ou 0 si pas de limite - defaut)
|
||||
@ -4982,6 +5026,8 @@ function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($a);
|
||||
return $nblines;
|
||||
}
|
||||
|
||||
|
||||
@ -77,8 +77,8 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask)
|
||||
$i++;
|
||||
$typephp='';
|
||||
$texttoinsert.= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
|
||||
$texttoinsert.= " 'visible'=>".$val['visible'].",";
|
||||
$texttoinsert.= " 'enabled'=>".$val['enabled'].",";
|
||||
$texttoinsert.= " 'visible'=>".($val['visible']?$val['visible']:0).",";
|
||||
$texttoinsert.= " 'enabled'=>".($val['enabled']?$val['enabled']:0).",";
|
||||
if ($val['position']) $texttoinsert.= " 'position'=>".$val['position'].",";
|
||||
if ($val['notnull']) $texttoinsert.= " 'notnull'=>".$val['notnull'].",";
|
||||
if ($val['index']) $texttoinsert.= " 'index'=>".$val['index'].",";
|
||||
|
||||
@ -1447,55 +1447,55 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
*
|
||||
* @return int Error count (0 if ok)
|
||||
*/
|
||||
function insert_tabs()
|
||||
{
|
||||
global $conf;
|
||||
function insert_tabs()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$err=0;
|
||||
$err=0;
|
||||
|
||||
if (! empty($this->tabs))
|
||||
{
|
||||
$i=0;
|
||||
foreach ($this->tabs as $key => $value)
|
||||
{
|
||||
if (is_array($value) && count($value) == 0) continue; // Discard empty arrays
|
||||
if (! empty($this->tabs))
|
||||
{
|
||||
$i=0;
|
||||
foreach ($this->tabs as $key => $value)
|
||||
{
|
||||
if (is_array($value) && count($value) == 0) continue; // Discard empty arrays
|
||||
|
||||
$entity=$conf->entity;
|
||||
$newvalue = $value;
|
||||
$entity=$conf->entity;
|
||||
$newvalue = $value;
|
||||
|
||||
if (is_array($value))
|
||||
{
|
||||
$newvalue = $value['data'];
|
||||
if (isset($value['entity'])) $entity = $value['entity'];
|
||||
}
|
||||
if (is_array($value))
|
||||
{
|
||||
$newvalue = $value['data'];
|
||||
if (isset($value['entity'])) $entity = $value['entity'];
|
||||
}
|
||||
|
||||
if ($newvalue)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
|
||||
$sql.= "name";
|
||||
$sql.= ", type";
|
||||
$sql.= ", value";
|
||||
$sql.= ", note";
|
||||
$sql.= ", visible";
|
||||
$sql.= ", entity";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= $this->db->encrypt($this->const_name."_TABS_".$i,1);
|
||||
$sql.= ", 'chaine'";
|
||||
$sql.= ", ".$this->db->encrypt($value,1);
|
||||
$sql.= ", null";
|
||||
$sql.= ", '0'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ")";
|
||||
if ($newvalue)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
|
||||
$sql.= "name";
|
||||
$sql.= ", type";
|
||||
$sql.= ", value";
|
||||
$sql.= ", note";
|
||||
$sql.= ", visible";
|
||||
$sql.= ", entity";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= $this->db->encrypt($this->const_name."_TABS_".$i,1);
|
||||
$sql.= ", 'chaine'";
|
||||
$sql.= ", ".$this->db->encrypt($newvalue,1);
|
||||
$sql.= ", null";
|
||||
$sql.= ", '0'";
|
||||
$sql.= ", ".$entity;
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);
|
||||
$this->db->query($sql);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG);
|
||||
$this->db->query($sql);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds constants
|
||||
|
||||
@ -211,7 +211,7 @@ class doc_generic_contract_odt extends ModelePDFContract
|
||||
if (! is_object($object))
|
||||
{
|
||||
$id = $object;
|
||||
$object = new Contract($this->db);
|
||||
$object = new Contrat($this->db);
|
||||
$result=$object->fetch($id);
|
||||
if ($result < 0)
|
||||
{
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -1576,7 +1576,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
if ($object->statut == Facture::STATUS_DRAFT)
|
||||
{
|
||||
$pdf->SetTextColor(128,0,0);
|
||||
$textref.=' - '.$outputlangs->trans("NotValidated");
|
||||
$textref.=' - '.$outputlangs->transnoentities("NotValidated");
|
||||
}
|
||||
$pdf->MultiCell($w, 4, $textref, '', 'R');
|
||||
|
||||
@ -1663,7 +1663,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$posy+=4;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell($w, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
$pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
$texte.=$file['name'].'<br>';
|
||||
}
|
||||
$texte.='<div id="div_'.get_class($this).'">';
|
||||
|
||||
|
||||
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
|
||||
{
|
||||
// Model for creation
|
||||
@ -252,7 +252,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
if (! is_object($object))
|
||||
{
|
||||
$id = $object;
|
||||
$object = new Propale($this->db);
|
||||
$object = new Propal($this->db);
|
||||
$result=$object->fetch($id);
|
||||
if ($result < 0)
|
||||
{
|
||||
|
||||
@ -21,43 +21,45 @@ if (isset($parameters['showblocbydefault'])) $hide=(empty($parameters['showblocb
|
||||
if (isset($object->extraparams[$blocname]['showhide'])) $hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false);
|
||||
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE bloc_showhide.tpl.php -->
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE BLOC SHOW/HIDE -->
|
||||
<?php
|
||||
print '<script type="text/javascript">'."\n";
|
||||
print '$(document).ready(function() {'."\n";
|
||||
print '$("#hide-'.$blocname.'").click(function(){'."\n";
|
||||
print ' setShowHide(0);'."\n";
|
||||
print ' $("#'.$blocname.'_bloc").hide("blind", {direction: "vertical"}, 300).removeClass("nohideobject");'."\n";
|
||||
print ' $(this).hide();'."\n";
|
||||
print ' $("#show-'.$blocname.'").show();'."\n";
|
||||
print '});'."\n";
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#hide-<?php echo $blocname ?>").click(function(){
|
||||
setShowHide(0);
|
||||
$("#<?php echo $blocname ?>_bloc").hide("blind", {direction: "vertical"}, 300).removeClass("nohideobject");
|
||||
$(this).hide();
|
||||
$("#show-<?php echo $blocname ?>").show();
|
||||
});
|
||||
$("#show-<?php echo $blocname ?>").click(function(){
|
||||
setShowHide(1);
|
||||
$("#<?php echo $blocname ?>_bloc").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");
|
||||
$(this).hide();
|
||||
$("#hide-<?php echo $blocname ?>").show();
|
||||
});
|
||||
function setShowHide(status) {
|
||||
var id = <?php echo $object->id; ?>;
|
||||
var element = '<?php echo $object->element; ?>';
|
||||
var htmlelement = '<?php echo $blocname ?>';
|
||||
var type = 'showhide';
|
||||
print '$("#show-'.$blocname.'").click(function(){'."\n";
|
||||
print ' setShowHide(1);'."\n";
|
||||
print ' $("#'.$blocname.'").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n";
|
||||
print ' $(this).hide();'."\n";
|
||||
print ' $("#hide-'.$blocname.'").show();'."\n";
|
||||
print '});'."\n";
|
||||
|
||||
$.get("<?php echo dol_buildpath('/core/ajax/extraparams.php', 1); ?>?id="+id+"&element="+element+"&htmlelement="+htmlelement+"&type="+type+"&value="+status);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
print 'function setShowHide(status) {'."\n";
|
||||
print ' var id = '.$object->id.";\n";
|
||||
print " var element = '".$object->element."';\n";
|
||||
print " var htmlelement = '".$blocname."';\n";
|
||||
print ' var type = "showhide";'."\n";
|
||||
print ' $.get("'.dol_buildpath('/core/ajax/extraparams.php', 1);
|
||||
print '?id="+id+"&element="+element+"&htmlelement="+htmlelement+"&type="+type+"&value="+status);'."\n";
|
||||
print '}'."\n";
|
||||
|
||||
<div style="float:right; position: relative; top: 3px; right:5px;" id="hide-<?php echo $blocname ?>" class="linkobject<?php echo ($hide ? ' hideobject' : ''); ?>"><?php echo img_picto('', '1uparrow.png'); ?></div>
|
||||
<div style="float:right; position: relative; top: 3px; right:5px;" id="show-<?php echo $blocname ?>" class="linkobject<?php echo ($hide ? '' : ' hideobject'); ?>"><?php echo img_picto('', '1downarrow.png'); ?></div>
|
||||
<div id="<?php echo $blocname ?>_title" class="liste_titre"><?php echo $title; ?></div>
|
||||
print '});'."\n";
|
||||
print '</script>'."\n";
|
||||
|
||||
<div id="<?php echo $blocname ?>_bloc" class="<?php echo ($hide ? 'hideobject' : 'nohideobject'); ?>">
|
||||
print '<div style="float:right; position: relative; top: 3px; right:5px;" id="hide-'.$blocname.'"';
|
||||
print ' class="linkobject'.($hide ? ' hideobject' : '').'">'.img_picto('', '1uparrow.png').'</div>'."\n";
|
||||
print '<div style="float:right; position: relative; top: 3px; right:5px;" id="show-'.$blocname.'"';
|
||||
print ' class="linkobject'.($hide ? '' : ' hideobject').'">'.img_picto('', '1downarrow.png').'</div>'."\n";
|
||||
print '<div id="'.$blocname.'_title" class="liste_titre">'.$title.'</div>'."\n";
|
||||
print '<div id="'.$blocname.'_bloc" class="'.($hide ? 'hideobject' : 'nohideobject').'">'."\n";
|
||||
|
||||
<?php include DOL_DOCUMENT_ROOT.'/core/tpl/'.$blocname.'.tpl.php'; ?>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<!-- END PHP TEMPLATE BLOC SHOW/HIDE -->
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/'.$blocname.'.tpl.php';
|
||||
print '</div><br>';
|
||||
?>
|
||||
<!-- END PHP TEMPLATE BLOC SHOW/HIDE -->
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Laurent Destailleur <eldy@destailleur.fr>
|
||||
/* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2017 Laurent Destailleur <eldy@destailleur.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -17,9 +17,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $cssclass must be defined by caller. For example cssclass='fieldtitle"
|
||||
$module = $object->element;
|
||||
$note_public = 'note_public';
|
||||
// $permission must be defined by caller.
|
||||
// $cssclass must be defined by caller. For example cssclass='fieldtitle"
|
||||
$module = $object->element;
|
||||
$note_public = 'note_public';
|
||||
$note_private = 'note_private';
|
||||
|
||||
$colwidth=(isset($colwidth)?$colwidth:(empty($cssclass)?'25':''));
|
||||
|
||||
@ -1577,7 +1577,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
if ($action != 'editdescription' && ($action != 'presend')) {
|
||||
// Validate
|
||||
if ($object->statut == 0 && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
|
||||
if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
|
||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&action=validate"';
|
||||
print '>' . $langs->trans("Validate") . '</a></div>';
|
||||
@ -1585,7 +1585,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Modify
|
||||
if ($object->statut == 1 && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate)))
|
||||
if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate)))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">';
|
||||
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify");
|
||||
@ -1594,7 +1594,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Send
|
||||
if ($object->statut > 0)
|
||||
if ($object->statut > Fichinter::STATUS_DRAFT)
|
||||
{
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
|
||||
{
|
||||
@ -1606,10 +1606,10 @@ else if ($id > 0 || ! empty($ref))
|
||||
// Event agenda
|
||||
if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT))
|
||||
{
|
||||
if (! empty($conf->agenda->enabled) && $object->statut > 0)
|
||||
if (! empty($conf->agenda->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
|
||||
{
|
||||
$langs->load("agenda");
|
||||
if ($object->statut < 2)
|
||||
if ($object->statut < Fichinter::STATUS_BILLED)
|
||||
{
|
||||
if ($user->rights->agenda->myactions->create) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddEvent").'</a></div>';
|
||||
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddEvent").'</a></div>';
|
||||
@ -1618,10 +1618,10 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Proposal
|
||||
if (! empty($conf->propal->enabled) && $object->statut > 0)
|
||||
if (! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
|
||||
{
|
||||
$langs->load("propal");
|
||||
if ($object->statut < 2)
|
||||
if ($object->statut < Fichinter::STATUS_BILLED)
|
||||
{
|
||||
if ($user->rights->propal->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddProp").'</a></div>';
|
||||
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>';
|
||||
@ -1629,10 +1629,10 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Invoicing
|
||||
if (! empty($conf->facture->enabled) && $object->statut > 0)
|
||||
if (! empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
|
||||
{
|
||||
$langs->load("bills");
|
||||
if ($object->statut < 2)
|
||||
if ($object->statut < Fichinter::STATUS_BILLED)
|
||||
{
|
||||
if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>';
|
||||
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddBill").'</a></div>';
|
||||
@ -1640,7 +1640,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
|
||||
if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
|
||||
{
|
||||
if ($object->statut != 2)
|
||||
if ($object->statut != Fichinter::STATUS_BILLED)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled">'.$langs->trans("InterventionClassifyBilled").'</a></div>';
|
||||
}
|
||||
@ -1652,7 +1652,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Done
|
||||
if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > 0 && $object->statut < 3)
|
||||
if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifydone">'.$langs->trans("InterventionClassifyDone").'</a></div>';
|
||||
}
|
||||
@ -1663,7 +1663,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Delete
|
||||
if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
|
||||
if (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete"';
|
||||
print '>'.$langs->trans('Delete').'</a></div>';
|
||||
|
||||
@ -39,7 +39,7 @@ class Fichinter extends CommonObject
|
||||
public $fk_element='fk_fichinter';
|
||||
public $table_element_line='fichinterdet';
|
||||
public $picto = 'intervention';
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -62,6 +62,23 @@ class Fichinter extends CommonObject
|
||||
|
||||
var $lines = array();
|
||||
|
||||
/**
|
||||
* Draft status
|
||||
*/
|
||||
const STATUS_DRAFT = 0;
|
||||
/**
|
||||
* Validated status
|
||||
*/
|
||||
const STATUS_VALIDATED = 1;
|
||||
/**
|
||||
* Billed
|
||||
*/
|
||||
const STATUS_BILLED = 2;
|
||||
/**
|
||||
* Closed
|
||||
*/
|
||||
const STATUS_CLOSED = 3;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -361,7 +378,7 @@ class Fichinter extends CommonObject
|
||||
$this->fk_contrat = $obj->fk_contrat;
|
||||
|
||||
$this->user_creation= $obj->fk_user_author;
|
||||
|
||||
|
||||
$this->extraparams = (array) json_decode($obj->extraparams, true);
|
||||
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
@ -546,23 +563,23 @@ class Fichinter extends CommonObject
|
||||
*/
|
||||
function getAmount() {
|
||||
global $db;
|
||||
|
||||
|
||||
$amount = 0;
|
||||
|
||||
|
||||
$this->author = new User($db);
|
||||
$this->author->fetch($this->user_creation);
|
||||
|
||||
|
||||
$thm = $this->author->thm;
|
||||
|
||||
|
||||
foreach($this->lines as &$line) {
|
||||
|
||||
|
||||
$amount+=$line->qty * $thm;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the label status
|
||||
*
|
||||
@ -599,7 +616,7 @@ class Fichinter extends CommonObject
|
||||
return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
|
||||
if ($mode == 6)
|
||||
return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
|
||||
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -949,7 +966,7 @@ class Fichinter extends CommonObject
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load an object from its id and create a new one in database
|
||||
@ -1001,7 +1018,7 @@ class Fichinter extends CommonObject
|
||||
$this->date_creation = '';
|
||||
$this->date_validation = '';
|
||||
$this->ref_client = '';
|
||||
|
||||
|
||||
// Create clone
|
||||
$result=$this->create($user);
|
||||
if ($result < 0) $error++;
|
||||
@ -1013,7 +1030,7 @@ class Fichinter extends CommonObject
|
||||
{
|
||||
$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
|
||||
}
|
||||
|
||||
|
||||
// Hook of thirdparty module
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
@ -1043,8 +1060,8 @@ class Fichinter extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adding a line of intervention into data base
|
||||
*
|
||||
|
||||
@ -249,16 +249,16 @@ $sql.= $db->plimit($limit+1, $offset);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
|
||||
if ($socid > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($socid);
|
||||
if (empty($search_company)) $search_company = $soc->name;
|
||||
}
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
|
||||
@ -494,7 +494,7 @@ if ($resql)
|
||||
|
||||
if (! GETPOST('cancel'))
|
||||
{
|
||||
$objecttmp=new FactureFourn($db);
|
||||
$objecttmp=new FactureFournisseur($db);
|
||||
$listofselectedid=array();
|
||||
$listofselectedthirdparties=array();
|
||||
$listofselectedref=array();
|
||||
|
||||
@ -448,7 +448,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
}
|
||||
|
||||
// Number of supplier invoices (has paid)
|
||||
if (! empty($conf->supplier_invoice->enabled) && ! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
if (! empty($conf->supplier_invoice->enabled) && ! empty($user->rights->fournisseur->facture->lire))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
$board=new FactureFournisseur($db);
|
||||
|
||||
@ -611,3 +611,7 @@ INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (14
|
||||
-- VMYSQL4.1 ALTER TABLE llx_c_type_resource CHANGE COLUMN rowid rowid integer NOT NULL AUTO_INCREMENT;
|
||||
|
||||
ALTER TABLE llx_import_model MODIFY COLUMN type varchar(50);
|
||||
|
||||
-- Negative buying prices
|
||||
|
||||
UPDATE llx_facturedet SET buy_price_ht = ABS(buy_price_ht)
|
||||
|
||||
@ -32,6 +32,18 @@ ALTER TABLE llx_website_page MODIFY COLUMN pageurl varchar(255);
|
||||
ALTER TABLE llx_website_page ADD COLUMN lang varchar(6);
|
||||
ALTER TABLE llx_website_page ADD COLUMN fk_page integer;
|
||||
|
||||
ALTER TABLE llx_fichinter ADD COLUMN import_key varchar(14);
|
||||
ALTER TABLE llx_livraison ADD COLUMN import_key varchar(14);
|
||||
ALTER TABLE llx_livraison ADD COLUMN extraparams varchar(255);
|
||||
ALTER TABLE llx_don ADD COLUMN extraparams varchar(255);
|
||||
|
||||
ALTER TABLE llx_accounting_account ADD COLUMN import_key varchar(14);
|
||||
ALTER TABLE llx_accounting_account ADD COLUMN extraparams varchar(255);
|
||||
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN import_key varchar(14);
|
||||
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN extraparams varchar(255);
|
||||
|
||||
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_lim_reglement datetime;
|
||||
|
||||
ALTER TABLE llx_c_paiement DROP PRIMARY KEY;
|
||||
ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id;
|
||||
ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement;
|
||||
|
||||
@ -35,4 +35,6 @@ create table llx_accounting_account
|
||||
fk_user_author integer DEFAULT NULL,
|
||||
fk_user_modif integer DEFAULT NULL,
|
||||
active tinyint DEFAULT 1 NOT NULL
|
||||
import_key varchar(14),
|
||||
extraparams varchar(255) -- for other parameters with json format
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -40,14 +40,16 @@ CREATE TABLE llx_accounting_bookkeeping
|
||||
multicurrency_code varchar(255), -- FEC:Idevise
|
||||
lettering_code varchar(255), -- FEC:EcritureLet
|
||||
date_lettering datetime, -- FEC:DateLet
|
||||
date_lim_reglement datetime, -- | date limite de reglement
|
||||
fk_user_author integer NOT NULL, -- | user creating
|
||||
fk_user_modif integer, -- | user making last change
|
||||
date_creation datetime, -- FEC:EcritureDate | creation date
|
||||
tms timestamp, -- | date last modification
|
||||
import_key varchar(14),
|
||||
code_journal varchar(32) NOT NULL, -- FEC:JournalCode
|
||||
journal_label varchar(255), -- FEC:JournalLib
|
||||
piece_num integer NOT NULL, -- FEC:EcritureNum
|
||||
validated tinyint DEFAULT 0 NOT NULL, -- | 0 line not validated / 1 line validated (No deleting / No modification)
|
||||
date_validated datetime -- FEC:ValidDate
|
||||
import_key varchar(14),
|
||||
extraparams varchar(255) -- for other parameters with json format
|
||||
) ENGINE=innodb;
|
||||
|
||||
@ -40,6 +40,7 @@ CREATE TABLE llx_accounting_bookkeeping_tmp
|
||||
multicurrency_code varchar(255), -- FEC:Idevise
|
||||
lettering_code varchar(255), -- FEC:EcritureLet
|
||||
date_lettering datetime, -- FEC:DateLet
|
||||
date_lim_reglement datetime, -- | date limite de reglement
|
||||
fk_user_author integer NOT NULL, -- | user creating
|
||||
fk_user_modif integer, -- | user making last change
|
||||
date_creation datetime, -- FEC:EcritureDate | creation date
|
||||
|
||||
@ -51,5 +51,6 @@ create table llx_don
|
||||
note_private text,
|
||||
note_public text,
|
||||
model_pdf varchar(255),
|
||||
import_key varchar(14)
|
||||
import_key varchar(14),
|
||||
extraparams varchar(255) -- for other parameters with json format
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -37,5 +37,9 @@ create table llx_extrafields
|
||||
param text, -- extra parameters to define possible values of field
|
||||
list integer DEFAULT 0, -- list of values for field that are combo lists
|
||||
langs varchar(24), -- example: fileofmymodule@mymodule
|
||||
ishidden integer DEFAULT 0 -- ??? example of use case ???
|
||||
ishidden integer DEFAULT 0, -- Can be foreign key of external system
|
||||
fk_user_author integer, -- user making creation
|
||||
fk_user_modif integer, -- user making last change
|
||||
datec datetime, -- date de creation
|
||||
tms timestamp
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -31,8 +31,8 @@ create table llx_fichinter
|
||||
date_valid datetime, -- date de validation
|
||||
datei date, -- date de livraison du bon d'intervention
|
||||
fk_user_author integer, -- user making creation
|
||||
fk_user_modif integer, -- user making last change
|
||||
fk_user_valid integer, -- valideur de la fiche
|
||||
fk_user_modif integer, -- user making last change
|
||||
fk_user_valid integer, -- user validating record
|
||||
fk_statut smallint DEFAULT 0,
|
||||
dateo date, -- date de début d'intervention
|
||||
datee date, -- date de fin d'intervention
|
||||
@ -42,5 +42,6 @@ create table llx_fichinter
|
||||
note_private text,
|
||||
note_public text,
|
||||
model_pdf varchar(255),
|
||||
extraparams varchar(255) -- for stock other parameters with json format
|
||||
import_key varchar(14),
|
||||
extraparams varchar(255) -- for other parameters with json format
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -41,6 +41,8 @@ create table llx_livraison
|
||||
note_public text,
|
||||
model_pdf varchar(255),
|
||||
fk_incoterms integer, -- for incoterms
|
||||
location_incoterms varchar(255) -- for incoterms
|
||||
|
||||
location_incoterms varchar(255), -- for incoterms
|
||||
|
||||
import_key varchar(14),
|
||||
extraparams varchar(255) -- for other parameters with json format
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -165,6 +165,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup_extrafield
|
||||
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_product_price_by_qty FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
|
||||
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
|
||||
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website_page FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
|
||||
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
|
||||
|
||||
|
||||
-- Add triggers for timestamp fields named date_m
|
||||
|
||||
@ -423,13 +423,11 @@ if (! $error && $db->connected && $action == "set")
|
||||
// Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre telecharges en passant outre l'authentification
|
||||
$dir[0] = $main_data_dir."/mycompany";
|
||||
$dir[1] = $main_data_dir."/users";
|
||||
$dir[2] = $main_data_dir."/custom";
|
||||
$dir[3] = $main_data_dir."/facture";
|
||||
$dir[4] = $main_data_dir."/propale";
|
||||
$dir[5] = $main_data_dir."/ficheinter";
|
||||
$dir[6] = $main_data_dir."/produit";
|
||||
$dir[7] = $main_data_dir."/doctemplates";
|
||||
$dir[7] = $main_data_dir."/extensions";
|
||||
$dir[2] = $main_data_dir."/facture";
|
||||
$dir[3] = $main_data_dir."/propale";
|
||||
$dir[4] = $main_data_dir."/ficheinter";
|
||||
$dir[5] = $main_data_dir."/produit";
|
||||
$dir[6] = $main_data_dir."/doctemplates";
|
||||
|
||||
// Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas
|
||||
$num=count($dir);
|
||||
|
||||
@ -794,6 +794,7 @@ HRAndBank=HR and Bank
|
||||
AutomaticallyCalculated=Automatically calculated
|
||||
TitleSetToDraft=Go back to draft
|
||||
ConfirmSetToDraft=Are you sure you want to go back to Draft status ?
|
||||
ImportId=Import id
|
||||
# Week day
|
||||
Monday=Monday
|
||||
Tuesday=Tuesday
|
||||
|
||||
@ -25,13 +25,13 @@ EnterNameOfObjectToDeleteDesc=You can delete an object. WARNING: All files relat
|
||||
DangerZone=Danger zone
|
||||
BuildPackage=Build package/documentation
|
||||
BuildDocumentation=Build documentation
|
||||
ModuleIsNotActive=This module was not activated yet. Ggo into %s to make it live or click here:
|
||||
ModuleIsNotActive=This module was not activated yet. Go into %s to make it live or click here:
|
||||
ModuleIsLive=This module has been activated. Any change on it may break a current active feature.
|
||||
DescriptionLong=Long description
|
||||
EditorName=Name of editor
|
||||
EditorUrl=URL of editor
|
||||
DescriptorFile=Descriptor file of module
|
||||
ClassFile=File for PHP class
|
||||
ClassFile=File for PHP DAO CRUD class
|
||||
ApiClassFile=File for PHP API class
|
||||
PageForList=PHP page for list of record
|
||||
PageForCreateEditView=PHP page to create/edit/view a record
|
||||
@ -50,8 +50,10 @@ HooksFile=File for hooks code
|
||||
WidgetFile=Widget file
|
||||
ReadmeFile=Readme file
|
||||
ChangeLog=ChangeLog file
|
||||
TestClassFile=File for PHP Unit Test class
|
||||
SqlFile=Sql file
|
||||
SqlFileExtraFields=Sql file for complementary attributes
|
||||
SqlFileKey=Sql file for keys
|
||||
AnObjectAlreadyExistWithThisNameAndDiffCase=An object already exists with this name and a different case
|
||||
UseAsciiDocFormat=You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown)
|
||||
UseAsciiDocFormat=You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown)
|
||||
IsAMeasure=Is a measure
|
||||
@ -118,6 +118,7 @@ SecondApprovalAlreadyDone=Second approval already done
|
||||
SupplierOrderReceivedInDolibarr=Supplier order %s received %s
|
||||
SupplierOrderSubmitedInDolibarr=Supplier order %s submited
|
||||
SupplierOrderClassifiedBilled=Supplier order %s set billed
|
||||
OtherOrders=Other orders
|
||||
##### Types de contacts #####
|
||||
TypeContact_commande_internal_SALESREPFOLL=Representative following-up customer order
|
||||
TypeContact_commande_internal_SHIPPING=Representative following-up shipping
|
||||
|
||||
@ -18,6 +18,7 @@ NextMonthOfInvoice=Following month (number 1-12) of invoice date
|
||||
TextNextMonthOfInvoice=Following month (text) of invoice date
|
||||
ZipFileGeneratedInto=Zip file generated into <b>%s</b>.
|
||||
DocFileGeneratedInto=Doc file generated into <b>%s</b>.
|
||||
JumpToLogin=Disconnected. Go to login page...
|
||||
|
||||
YearOfInvoice=Year of invoice date
|
||||
PreviousYearOfInvoice=Previous year of invoice date
|
||||
|
||||
@ -64,6 +64,7 @@ ProposalLine=Proposal line
|
||||
AvailabilityPeriod=Availability delay
|
||||
SetAvailability=Set availability delay
|
||||
AfterOrder=after order
|
||||
OtherProposals=Other proposals
|
||||
##### Availability #####
|
||||
AvailabilityTypeAV_NOW=Immediate
|
||||
AvailabilityTypeAV_1W=1 week
|
||||
|
||||
@ -69,6 +69,7 @@ NoPredefinedProductToDispatch=No predefined products for this object. So no disp
|
||||
DispatchVerb=Dispatch
|
||||
StockLimitShort=Limit for alert
|
||||
StockLimit=Stock limit for alert
|
||||
StockLimitDesc="" (empty) default value means no alert. <br>"0" can be used with 'Stock can be negative' configuration.
|
||||
PhysicalStock=Physical stock
|
||||
RealStock=Real Stock
|
||||
RealStockDesc=Physical or real stock is the stock you currently have into your internal warehouses/emplacements.
|
||||
@ -192,4 +193,4 @@ InventoryFlushed=Inventory flushed
|
||||
ExitEditMode=Exit edition
|
||||
inventoryDeleteLine=Delete line
|
||||
RegulateStock=Regulate Stock
|
||||
ListInventory=List
|
||||
ListInventory=List
|
||||
@ -457,9 +457,7 @@ if (! defined('NOLOGIN'))
|
||||
$passwordtotest = GETPOST('password','none',2);
|
||||
$entitytotest = (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1));
|
||||
|
||||
// Validation of login/pass/entity
|
||||
// If ok, the variable login will be returned
|
||||
// If error, we will put error message in session under the name dol_loginmesg
|
||||
// Define if we received data to test the login.
|
||||
$goontestloop=false;
|
||||
if (isset($_SERVER["REMOTE_USER"]) && in_array('http',$authmode)) $goontestloop=true;
|
||||
if ($dolibarr_main_authentication == 'forceuser' && ! empty($dolibarr_auto_user)) $goontestloop=true;
|
||||
@ -473,6 +471,9 @@ if (! defined('NOLOGIN'))
|
||||
$langs->setDefaultLang($langcode);
|
||||
}
|
||||
|
||||
// Validation of login/pass/entity
|
||||
// If ok, the variable login will be returned
|
||||
// If error, we will put error message in session under the name dol_loginmesg
|
||||
if ($test && $goontestloop)
|
||||
{
|
||||
$login = checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode);
|
||||
@ -531,9 +532,10 @@ if (! defined('NOLOGIN'))
|
||||
// End test login / passwords
|
||||
if (! $login || (in_array('ldap',$authmode) && empty($passwordtotest))) // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success.
|
||||
{
|
||||
// We show login page
|
||||
// No data to test login, so we show the login page
|
||||
dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." showing the login form and exit");
|
||||
dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:''));
|
||||
if (defined('NOREDIRECTBYMAINTOLOGIN')) return 'ERROR_NOT_LOGGED';
|
||||
else dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:''));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@ -160,10 +160,6 @@ else if (defined('DOLENTITY') && is_numeric(DOLENTITY)) // For public page wit
|
||||
{
|
||||
$conf->entity = DOLENTITY;
|
||||
}
|
||||
else if (!empty($_COOKIE['DOLENTITY'])) // For other application with MultiCompany module (TODO: We should remove this. entity to use should never be stored into client side)
|
||||
{
|
||||
$conf->entity = $_COOKIE['DOLENTITY'];
|
||||
}
|
||||
|
||||
// Sanitize entity
|
||||
if (! is_numeric($conf->entity)) $conf->entity=1;
|
||||
|
||||
@ -108,7 +108,11 @@ if ($dirins && $action == 'initmodule' && $modulename)
|
||||
|
||||
// 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');
|
||||
@ -132,7 +136,7 @@ if ($dirins && $action == 'initmodule' && $modulename)
|
||||
'MyModule'=>$modulename,
|
||||
'MYMODULE'=>strtoupper($modulename),
|
||||
'My module'=>$modulename,
|
||||
'htdocs/modulebuilder/template/'=>'',
|
||||
'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.'>':'')
|
||||
);
|
||||
|
||||
@ -188,8 +192,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
// Delete some files
|
||||
$filetogenerate = array(
|
||||
'myobject_card.php'=>strtolower($objectname).'_card.php',
|
||||
'myobject_list.php'=>strtolower($objectname).'_list.php',
|
||||
'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
|
||||
'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',
|
||||
@ -276,7 +284,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
'MyModule'=>$module,
|
||||
'MYMODULE'=>strtoupper($module),
|
||||
'My module'=>$module,
|
||||
'htdocs/modulebuilder/template/'=>'',
|
||||
'htdocs/modulebuilder/template/'=>strtolower($modulename),
|
||||
'myobject'=>strtolower($objectname),
|
||||
'MyObject'=>$objectname
|
||||
);
|
||||
@ -360,7 +368,7 @@ if ($dirins && $action == 'confirm_delete')
|
||||
|
||||
if ($dirins && $action == 'confirm_deleteobject' && $objectname)
|
||||
{
|
||||
if (preg_match('/\s/', $objectname))
|
||||
if (preg_match('/[^a-z0-9]/i', $objectname))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors');
|
||||
@ -377,8 +385,12 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname)
|
||||
// Delete some files
|
||||
$filetogenerate = array(
|
||||
'myobject_card.php'=>strtolower($objectname).'_card.php',
|
||||
'myobject_list.php'=>strtolower($objectname).'_list.php',
|
||||
'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
|
||||
'myobject_note.php'=>strtolower($objectname).'_note.php',
|
||||
'myobject_document.php'=>strtolower($objectname).'_note.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',
|
||||
@ -604,7 +616,11 @@ if ($action == 'savefile' && empty($cancel))
|
||||
// Enable module
|
||||
if ($action == 'set' && $user->admin)
|
||||
{
|
||||
$param='module='.$module;
|
||||
$param='';
|
||||
if ($module) $param.='&module='.$module;
|
||||
if ($tab) $param.='&tab='.$tab;
|
||||
if ($tabobj) $param.='&tabobj='.$tabobj;
|
||||
|
||||
$value = GETPOST('value','alpha');
|
||||
$resarray = activateModule($value);
|
||||
if (! empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors');
|
||||
@ -635,7 +651,11 @@ if ($action == 'set' && $user->admin)
|
||||
// Disable module
|
||||
if ($action == 'reset' && $user->admin)
|
||||
{
|
||||
$param='module='.$module;
|
||||
$param='';
|
||||
if ($module) $param.='&module='.$module;
|
||||
if ($tab) $param.='&tab='.$tab;
|
||||
if ($tabobj) $param.='&tabobj='.$tabobj;
|
||||
|
||||
$value = GETPOST('value','alpha');
|
||||
$result=unActivateModule($value);
|
||||
if ($result) setEventMessages($result, null, 'errors');
|
||||
@ -844,7 +864,11 @@ elseif (! empty($module))
|
||||
$modulelowercase=strtolower($module);
|
||||
$const_name = 'MAIN_MODULE_'.strtoupper($module);
|
||||
|
||||
$param='&tab='.$tab.'&module='.$module;
|
||||
$param='';
|
||||
if ($tab) $param.= '&tab='.$tab;
|
||||
if ($module) $param.='&module='.$module;
|
||||
if ($tabobj) $param.='&tabobj='.$tabobj;
|
||||
|
||||
$urltomodulesetup='<a href="'.DOL_URL_ROOT.'/admin/modules.php?search_keyword='.urlencode($module).'">'.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").'</a>';
|
||||
$linktoenabledisable='';
|
||||
if (! empty($conf->global->$const_name)) // If module is already activated
|
||||
@ -1198,6 +1222,7 @@ elseif (! empty($module))
|
||||
$pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php';
|
||||
$pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php';
|
||||
$pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php';
|
||||
$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';
|
||||
@ -1208,6 +1233,9 @@ elseif (! empty($module))
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("ApiClassFile").' : <strong>'.$pathtoapi.'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("TestClassFile").' : <strong>'.$pathtophpunit.'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("SqlFile").' : <strong>'.$pathtosql.'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=sql&file='.urlencode($pathtosql).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
@ -1256,9 +1284,10 @@ elseif (! empty($module))
|
||||
print '<td class="center">'.$langs->trans("NotNull").'</td>';
|
||||
//print '<td>'.$langs->trans("DefaultValue").'</td>';
|
||||
print '<td class="center">'.$langs->trans("DatabaseIndex").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Position").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Enabled").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Visible").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Position").'</td>';
|
||||
print '<td class="right">'.$langs->trans("IsAMeasure").'</td>';
|
||||
print '<td class="center">'.$langs->trans("SearchAll").'</td>';
|
||||
print '<td>'.$langs->trans("Comment").'</td>';
|
||||
print '<td></td>';
|
||||
@ -1270,9 +1299,10 @@ elseif (! empty($module))
|
||||
print '<td class="center"><input class="text" size="2" name="propnotnull" value=""></td>';
|
||||
//print '<td><input class="text" name="propdefault" value=""></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propindex" value=""></td>';
|
||||
print '<td class="right"><input class="text right" size="2" name="propposition" value=""></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propenabled" value=""></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propvisible" value=""></td>';
|
||||
print '<td class="right"><input class="text right" size="2" name="propposition" value=""></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propisameasure" value=""></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propsearchall" value=""></td>';
|
||||
print '<td><input class="text" name="propcomment" value=""></td>';
|
||||
print '<td align="center">';
|
||||
@ -1300,13 +1330,14 @@ elseif (! empty($module))
|
||||
$propname=$propkey;
|
||||
$proplabel=$propval['label'];
|
||||
$proptype=$propval['type'];
|
||||
$propposition=$propval['position'];
|
||||
$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 '<tr class="oddeven">';
|
||||
@ -1329,14 +1360,17 @@ elseif (! empty($module))
|
||||
print '<td class="center">';
|
||||
print $propindex?'X':'';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print $propposition;
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
print $propenabled?$propenabled:'';
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
print $propvisible?$propvisible:'';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print $propposition;
|
||||
print '<td class="center">';
|
||||
print $propisameasure?$propisameasure:'';
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
print $propsearchall?'X':'';
|
||||
|
||||
@ -55,20 +55,39 @@ class MyObject extends CommonObject
|
||||
/**
|
||||
* @var string String with name of icon for myobject
|
||||
*/
|
||||
public $picto = 'myobject';
|
||||
public $picto = 'myobject@mymodule';
|
||||
|
||||
|
||||
/**
|
||||
* 'type' if the field format, 'label' the translation key, 'enabled' is a condition when the filed must be managed,
|
||||
* 'visible' says if field is visible in list (-1 means not shown by default but can be aded into list to be viewed)
|
||||
* 'notnull' if not null in database
|
||||
* 'index' if we want an index in database
|
||||
* 'position' is the sort order of field
|
||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button
|
||||
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
|
||||
* 'comment' is not used. You can store here any text of your choice.
|
||||
*/
|
||||
|
||||
// BEGIN MODULEBUILDER PROPERTIES
|
||||
/**
|
||||
* @var array Array with all fields and their property
|
||||
*/
|
||||
public $fields=array(
|
||||
'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>true, 'index'=>true, 'visible'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
|
||||
'entity'=>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>true, 'index'=>true, 'visible'=>0, 'position'=>20),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'visible'=>1, 'searchall'=>1),
|
||||
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'visible'=>-1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'visible'=>-1, 'position'=>500),
|
||||
'status'=>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'visible'=>1, 'position'=>1000),
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'index'=>true, 'position'=>1, 'comment'=>'Id'),
|
||||
'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>true, 'index'=>true, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>true, 'index'=>true, 'position'=>20),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
|
||||
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1),
|
||||
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000),
|
||||
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValid', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>true, 'position'=>1000, 'nullifempty'=>1),
|
||||
);
|
||||
// END MODULEBUILDER PROPERTIES
|
||||
|
||||
@ -109,18 +128,65 @@ class MyObject extends CommonObject
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create object into database
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
return $this->createCommon($user, $notrigger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param string $ref Ref
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetch($id, $ref = null)
|
||||
{
|
||||
return $this->fetchCommon($id, $ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update(User $user, $notrigger = false)
|
||||
{
|
||||
return $this->updateCommon($user, $notrigger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that deletes
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete(User $user, $notrigger = false)
|
||||
{
|
||||
return $this->deleteCommon($user, $trigger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a link to the object card (with optionaly the picto)
|
||||
*
|
||||
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||
* @param string $option On what the link point to
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param int $maxlen Max length of visible user name
|
||||
* @param string $morecss Add more css on link
|
||||
* @return string String with URL
|
||||
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||
* @param string $option On what the link point to
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $morecss Add more css on link
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @return string String with URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
|
||||
function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
|
||||
{
|
||||
global $db, $conf, $langs;
|
||||
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
||||
@ -131,18 +197,27 @@ class MyObject extends CommonObject
|
||||
$result = '';
|
||||
$companylink = '';
|
||||
|
||||
$label = '<u>' . $langs->trans("MyModule") . '</u>';
|
||||
$label = '<u>' . $langs->trans("MyObject") . '</u>';
|
||||
$label.= '<br>';
|
||||
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
|
||||
$url = DOL_URL_ROOT.'/mymodule/'.$this->table_name.'_card.php?id='.$this->id;
|
||||
$url='';
|
||||
if ($option != 'nolink')
|
||||
{
|
||||
$url = dol_buildpath('/mymodule/myobject_card.php',1).'?id='.$this->id;
|
||||
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
|
||||
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
|
||||
}
|
||||
|
||||
$linkclose='';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$label=$langs->trans("ShowProject");
|
||||
$label=$langs->trans("ShowMyObject");
|
||||
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
@ -223,6 +298,59 @@ class MyObject extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge les informations d'ordre info dans l'objet commande
|
||||
*
|
||||
* @param int $id Id of order
|
||||
* @return void
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
|
||||
$sql.= ' fk_user_creat, fk_user_modif';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
$sql.= ' WHERE t.rowid = '.$id;
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_valid)
|
||||
{
|
||||
$vuser = new User($this->db);
|
||||
$vuser->fetch($obj->fk_user_valid);
|
||||
$this->user_validation = $vuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_cloture)
|
||||
{
|
||||
$cluser = new User($this->db);
|
||||
$cluser->fetch($obj->fk_user_cloture);
|
||||
$this->user_cloture = $cluser;
|
||||
}
|
||||
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = $this->db->jdate($obj->datem);
|
||||
$this->date_validation = $this->db->jdate($obj->datev);
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise object with example values
|
||||
|
||||
@ -129,6 +129,8 @@ class modMyModule extends DolibarrModules
|
||||
// Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1
|
||||
// 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
|
||||
// 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
|
||||
// Can also be: $this->tabs = array('data'=>'...', 'entity'=>0);
|
||||
//
|
||||
// where objecttype can be
|
||||
// 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
|
||||
// 'contact' to add a tab in contact view
|
||||
|
||||
@ -16,11 +16,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file lib/mymodule.lib.php
|
||||
* \file htdocs/modulebuilder/template/lib/mymodule.lib.php
|
||||
* \ingroup mymodule
|
||||
* \brief Example module library.
|
||||
*
|
||||
* Put detailed description here.
|
||||
* \brief Library files with common functions for MyModule
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
70
htdocs/modulebuilder/template/lib/myobject.lib.php
Normal file
70
htdocs/modulebuilder/template/lib/myobject.lib.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/modulebuilder/template/lib/myobject.lib.php
|
||||
* \ingroup mymodule
|
||||
* \brief Library files with common functions for MyObject
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepare array of tabs for MyObject
|
||||
*
|
||||
* @param MyObject $object MyObject
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function myobjectPrepareHead($object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$langs->load("mymodule@mymodule");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = dol_buildpath("/mymodule/myobject_card.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
if (isset($object->fields['note_public']) || isset($object->fields['note_pricate']))
|
||||
{
|
||||
$head[$h][0] = dol_buildpath("/mymodule/myobject_note.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
$head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
$head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
//$this->tabs = array(
|
||||
// 'entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
|
||||
//); // to add new tab
|
||||
//$this->tabs = array(
|
||||
// 'entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
|
||||
//); // to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'myobject@mymodule');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@ -41,13 +41,13 @@ if (! $res) die("Include of main fails");
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
|
||||
if (! $user->rights->mymodule->read) accessforbidden();
|
||||
|
||||
$langs->load("mymodule@mymodule");
|
||||
$langs->loadLangs(array("mymodule@mymodule"));
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
|
||||
|
||||
// Securite acces client
|
||||
if (! $user->rights->mymodule->read) accessforbidden();
|
||||
$socid=GETPOST('socid','int');
|
||||
if (isset($user->societe_id) && $user->societe_id > 0)
|
||||
{
|
||||
|
||||
262
htdocs/modulebuilder/template/myobject_agenda.php
Normal file
262
htdocs/modulebuilder/template/myobject_agenda.php
Normal file
@ -0,0 +1,262 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/modulebuilder/template/myobject_agenda.php
|
||||
* \ingroup mymodule
|
||||
* \brief Page of MyObject events
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
$res=0;
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
|
||||
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
|
||||
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
|
||||
if (! $res) die("Include of main fails");
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
dol_include_once('/mymodule/class/myobject.class.php');
|
||||
dol_include_once('/mymodule/lib/myobject.lib.php');
|
||||
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
$langs->loadLangs(array("mymodule@mymodule","other"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
if (GETPOST('actioncode','array'))
|
||||
{
|
||||
$actioncode=GETPOST('actioncode','array',3);
|
||||
if (! count($actioncode)) $actioncode='0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||
}
|
||||
$search_agenda_label=GETPOST('search_agenda_label');
|
||||
|
||||
// Security check - Protection if external user
|
||||
//if ($user->societe_id > 0) access_forbidden();
|
||||
//if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
//$result = restrictedArea($user, 'mymodule', $id);
|
||||
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortfield) $sortfield='a.datep,a.id';
|
||||
if (! $sortorder) $sortorder='DESC';
|
||||
|
||||
// Initialize technical objects
|
||||
$object=new MyObject($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('myobjectagenda')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('myobject');
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters=array('id'=>$socid);
|
||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
// Cancel
|
||||
if (GETPOST("cancel") && ! empty($backtopage))
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
$actioncode='';
|
||||
$search_agenda_label='';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$contactstatic = new Contact($db);
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$title=$langs->trans("Agenda");
|
||||
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
|
||||
$help_url = '';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if (! empty($conf->notification->enabled)) $langs->load("mails");
|
||||
$head = myobjectPrepareHead($object);
|
||||
|
||||
|
||||
dol_fiche_head($head, 'agenda', $langs->trans("MyObject"), -1, 'myobject@mymodule');
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' .dol_buildpath('/mymodule/myobject_list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
/*
|
||||
// Ref customer
|
||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->mymodule->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
$morehtmlref.=' : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
}*/
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
$object->info($object->id);
|
||||
print dol_print_object_info($object, 1);
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
// Actions buttons
|
||||
|
||||
$objthirdparty=$object;
|
||||
$objcon=new stdClass();
|
||||
|
||||
$out='';
|
||||
$permok=$user->rights->agenda->myactions->create;
|
||||
if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
|
||||
{
|
||||
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
|
||||
if (get_class($objthirdparty) == 'Societe') $out.='&socid='.$objthirdparty->id;
|
||||
$out.=(! empty($objcon->id)?'&contactid='.$objcon->id:'').'&backtopage=1&percentage=-1';
|
||||
//$out.=$langs->trans("AddAnAction").' ';
|
||||
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
|
||||
//$out.="</a>";
|
||||
}
|
||||
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
{
|
||||
$param='&socid='.$socid;
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
|
||||
|
||||
print load_fiche_titre($langs->trans("ActionsOnMyObject"),'','');
|
||||
|
||||
// List of all actions
|
||||
$filters=array();
|
||||
$filters['search_agenda_label']=$search_agenda_label;
|
||||
|
||||
// TODO Replace this with same code than into listactions.php
|
||||
//show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -18,9 +18,8 @@
|
||||
|
||||
/**
|
||||
* \file htdocs/modulebuilder/template/myobject_card.php
|
||||
* \ingroup mymodule othermodule1 othermodule2
|
||||
* \brief This file is an example of a php page
|
||||
* Put here some comments
|
||||
* \ingroup mymodule
|
||||
* \brief Page to create/edit/view myobject
|
||||
*/
|
||||
|
||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||
@ -53,13 +52,16 @@ if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main
|
||||
if (! $res) die("Include of main fails");
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
|
||||
dol_include_once('/mymodule/class/myobject.class.php');
|
||||
dol_include_once('/mymodule/lib/myobject.lib.php');
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
$langs->loadLangs(array("mymodule","other"));
|
||||
$langs->loadLangs(array("mymodule@mymodule","other"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
@ -83,11 +85,9 @@ foreach($object->fields as $key => $val)
|
||||
|
||||
if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||
|
||||
// Protection if external user
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
//accessforbidden();
|
||||
}
|
||||
// Security check - Protection if external user
|
||||
//if ($user->societe_id > 0) access_forbidden();
|
||||
//if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
//$result = restrictedArea($user, 'mymodule', $id);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
@ -110,6 +110,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
if ($cancel)
|
||||
{
|
||||
if ($action != 'addlink')
|
||||
@ -125,19 +127,11 @@ if (empty($reshook))
|
||||
// Action to add record
|
||||
if ($action == 'add' && ! empty($user->rights->mymodule->create))
|
||||
{
|
||||
if ($cancel)
|
||||
{
|
||||
$urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
}
|
||||
|
||||
$error=0;
|
||||
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
|
||||
|
||||
$object->$key=GETPOST($key,'alpha');
|
||||
if (in_array($key, array('entity', 'datec', 'tms'))) continue;
|
||||
if ($val['notnull'] && $object->$key == '')
|
||||
{
|
||||
$error++;
|
||||
@ -172,20 +166,20 @@ if (empty($reshook))
|
||||
// Action to update record
|
||||
if ($action == 'update' && ! empty($user->rights->mymodule->create))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$object->prop1=GETPOST("field1");
|
||||
$object->prop2=GETPOST("field2");
|
||||
|
||||
if (empty($object->ref))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
|
||||
}
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
$object->$key=GETPOST($key,'alpha');
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
if ($val['notnull'] && $object->$key == '')
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$object->update($user);
|
||||
$result=$object->updateCommon($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$action='view';
|
||||
@ -207,7 +201,7 @@ if (empty($reshook))
|
||||
// Action to delete
|
||||
if ($action == 'confirm_delete' && ! empty($user->rights->mymodule->delete))
|
||||
{
|
||||
$result=$object->delete($user);
|
||||
$result=$object->deleteCommon($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
// Delete OK
|
||||
@ -233,6 +227,7 @@ if (empty($reshook))
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
$formfile=new FormFile($db);
|
||||
|
||||
llxHeader('','MyObject','');
|
||||
|
||||
@ -267,12 +262,14 @@ if ($action == 'create')
|
||||
print '<table class="border centpercent">'."\n";
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'datec', 'tms'))) continue;
|
||||
print '<tr><td';
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
print '<tr id="field_'.$key.'"><td';
|
||||
print ' class="titlefieldcreate';
|
||||
if ($val['notnull']) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td><td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td></tr>';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>'."\n";
|
||||
|
||||
@ -298,8 +295,17 @@ if (($id || $ref) && $action == 'edit')
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border centpercent">'."\n";
|
||||
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>';
|
||||
// LIST_OF_TD_LABEL_FIELDS_EDIT
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
print '<tr><td';
|
||||
print ' class="titlefieldcreate';
|
||||
if ($val['notnull']) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
@ -318,14 +324,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
{
|
||||
$res = $object->fetch_optionals($object->id, $extralabels);
|
||||
|
||||
$head = mymodule_prepare_head($object);
|
||||
dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order');
|
||||
$head = myobjectPrepareHead($object);
|
||||
dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, 'myobject@mymodule');
|
||||
|
||||
$formconfirm = '';
|
||||
|
||||
// Confirmation to delete
|
||||
if ($action == 'delete') {
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1);
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
|
||||
}
|
||||
|
||||
// Confirmation of action xxxx
|
||||
@ -353,12 +359,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print $formconfirm;
|
||||
|
||||
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/mymodule/myobject_list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$linkback = '<a href="' .dol_buildpath('/mymodule/myobject_list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
/*
|
||||
@ -412,9 +415,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">'."\n";
|
||||
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
||||
// LIST_OF_TD_LABEL_FIELDS_VIEW
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
print '<tr><td';
|
||||
print ' class="titlefieldcreate';
|
||||
if ($val['notnull']) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
@ -426,7 +438,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
|
||||
// ...
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
@ -484,7 +496,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
|
||||
// Show links to link elements
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
|
||||
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||
|
||||
|
||||
@ -493,7 +505,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, 'order', $socid);
|
||||
$somethingshown = $formactions->showactions($object, 'myobject', $socid);
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
@ -541,7 +553,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
|
||||
print '<div class="clearboth"></div>';
|
||||
print '<br>';
|
||||
print load_fiche_titre($langs->trans('SendOrderByMail'));
|
||||
print load_fiche_titre($langs->trans('SendMyObjectByMail'));
|
||||
|
||||
dol_fiche_head('');
|
||||
|
||||
@ -569,9 +581,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$formmail->withtocc = $liste;
|
||||
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
|
||||
if (empty($object->ref_client)) {
|
||||
$formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__');
|
||||
$formmail->withtopic = $outputlangs->trans('SendMyObjectRef', '__REF__');
|
||||
} else if (! empty($object->ref_client)) {
|
||||
$formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)');
|
||||
$formmail->withtopic = $outputlangs->trans('SendMyObjectRef', '__REF__ (__REFCLIENT__)');
|
||||
}
|
||||
$formmail->withfile = 2;
|
||||
$formmail->withbody = 1;
|
||||
@ -579,7 +591,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$formmail->withcancel = 1;
|
||||
// Tableau des substitutions
|
||||
$formmail->setSubstitFromObject($object);
|
||||
$formmail->substit ['__ORDERREF__'] = $object->ref;
|
||||
$formmail->substit ['__REF__'] = $object->ref;
|
||||
|
||||
$custcontact = '';
|
||||
$contactarr = array();
|
||||
@ -603,9 +615,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
// Tableau des parametres complementaires
|
||||
$formmail->param['action'] = 'send';
|
||||
$formmail->param['models'] = 'order_send';
|
||||
$formmail->param['models'] = 'myobject_send';
|
||||
$formmail->param['models_id']=GETPOST('modelmailselected','int');
|
||||
$formmail->param['orderid'] = $object->id;
|
||||
$formmail->param['myobjectid'] = $object->id;
|
||||
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
|
||||
|
||||
// Init list of files
|
||||
|
||||
183
htdocs/modulebuilder/template/myobject_document.php
Normal file
183
htdocs/modulebuilder/template/myobject_document.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/modulebuilder/template/myobject_document.php
|
||||
* \ingroup mymodule
|
||||
* \brief Tab for documents linked to MyObject
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
$res=0;
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
|
||||
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
|
||||
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
|
||||
if (! $res) die("Include of main fails");
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
dol_include_once('/mymodule/class/myobject.class.php');
|
||||
dol_include_once('/mymodule/lib/myobject.lib.php');
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
$langs->loadLangs(array("mymodule@mymodule","companies","other"));
|
||||
|
||||
|
||||
$action=GETPOST('action','aZ09');
|
||||
$confirm=GETPOST('confirm');
|
||||
$id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
|
||||
// Security check - Protection if external user
|
||||
//if ($user->societe_id > 0) access_forbidden();
|
||||
//if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
//$result = restrictedArea($user, 'mymodule', $id);
|
||||
|
||||
// Get parameters
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="name";
|
||||
|
||||
// Initialize technical objects
|
||||
$object=new MyObject($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('myobjectdocument')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('myobject');
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title=$langs->trans("MyObject").' - '.$langs->trans("Files");
|
||||
$help_url='';
|
||||
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
/*
|
||||
* Show tabs
|
||||
*/
|
||||
if (! empty($conf->notification->enabled)) $langs->load("mails");
|
||||
$head = myobjectPrepareHead($object);
|
||||
|
||||
dol_fiche_head($head, 'document', $langs->trans("MyObject"), -1, 'myobject@mymodule');
|
||||
|
||||
|
||||
// Construit liste des fichiers
|
||||
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
||||
$totalsize=0;
|
||||
foreach($filearray as $key => $file)
|
||||
{
|
||||
$totalsize+=$file['size'];
|
||||
}
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' .dol_buildpath('/mymodule/myobject_list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Prefix
|
||||
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
{
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->client)
|
||||
{
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print $object->code_client;
|
||||
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($object->fournisseur)
|
||||
{
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print $object->code_fournisseur;
|
||||
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Number of files
|
||||
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
||||
|
||||
// Total size
|
||||
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
$modulepart = 'societe';
|
||||
$permission = $user->rights->societe->creer;
|
||||
$permtoedit = $user->rights->societe->creer;
|
||||
$param = '&id=' . $object->id;
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
accessforbidden('',0,0);
|
||||
}
|
||||
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -18,9 +18,8 @@
|
||||
|
||||
/**
|
||||
* \file htdocs/modulebuilder/template/myobject_list.php
|
||||
* \ingroup mymodule othermodule1 othermodule2
|
||||
* \brief This file is an example of a php page
|
||||
* Put here some comments
|
||||
* \ingroup mymodule
|
||||
* \brief List page for myobject
|
||||
*/
|
||||
|
||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||
@ -59,7 +58,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
dol_include_once('/mymodule/class/myobject.class.php');
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
$langs->loadLangs(array("mymodule","other"));
|
||||
$langs->loadLangs(array("mymodule@mymodule","other"));
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
$massaction = GETPOST('massaction','alpha');
|
||||
@ -217,7 +216,8 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
$sql.= " WHERE t.entity IN (".getEntity('myobject').")";
|
||||
foreach($search as $key => $val)
|
||||
{
|
||||
if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0)));
|
||||
$mode=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0);
|
||||
if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode));
|
||||
}
|
||||
if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
// Add where from extra fields
|
||||
@ -227,7 +227,7 @@ foreach ($search_array_options as $key => $val)
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
$typ=$extrafields->attribute_type[$tmpkey];
|
||||
$mode=0;
|
||||
if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
|
||||
if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric
|
||||
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
|
||||
{
|
||||
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
|
||||
@ -307,9 +307,10 @@ foreach ($search_array_options as $key => $val)
|
||||
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||
}
|
||||
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
'presend'=>$langs->trans("SendByMail"),
|
||||
'builddoc'=>$langs->trans("PDFMerge"),
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->mymodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete");
|
||||
if ($massaction == 'presend') $arrayofmassactions=array();
|
||||
@ -325,7 +326,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
@ -363,10 +364,11 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
|
||||
print '<tr class="liste_titre">';
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('datec','tms','status'))) continue;
|
||||
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
|
||||
}
|
||||
// Extra fields
|
||||
@ -399,10 +401,11 @@ print $hookmanager->resPrint;
|
||||
// Rest of fields search
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (! in_array($key, array('datec','tms','status'))) continue;
|
||||
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
|
||||
}
|
||||
// Action column
|
||||
@ -418,10 +421,11 @@ print '</tr>'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('datec','tms','status'))) continue;
|
||||
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
||||
}
|
||||
// Extra fields
|
||||
@ -445,10 +449,11 @@ print $hookmanager->resPrint;
|
||||
// Rest of fields title
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (! in_array($key, array('datec','tms','status'))) continue;
|
||||
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
||||
}
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
|
||||
@ -472,22 +477,36 @@ while ($i < min($num, $limit))
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
// Store properties in $object
|
||||
$object->id = $obj->rowid;
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (isset($obj->$key)) $object->$key = $obj->$key;
|
||||
}
|
||||
|
||||
// Show here line of result
|
||||
print '<tr class="oddeven">';
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('datec','tms','status'))) continue;
|
||||
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked']))
|
||||
{
|
||||
print '<td'.($align?' class="'.$align.'"':'').'>';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour');
|
||||
elseif ($key == 'status') print '<td align="center">'.$object->getLibStatut(3).'</td>';
|
||||
elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1);
|
||||
elseif ($key == 'status') print $object->getLibStatut(3);
|
||||
else print $obj->$key;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! empty($val['isameasure']))
|
||||
{
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
|
||||
$totalarray['val']['t.'.$key] += $obj->$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
@ -505,6 +524,11 @@ while ($i < min($num, $limit))
|
||||
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! empty($val['isameasure']))
|
||||
{
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
|
||||
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -515,18 +539,24 @@ while ($i < min($num, $limit))
|
||||
// Rest of fields
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (! in_array($key, array('datec','tms','status'))) continue;
|
||||
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked']))
|
||||
{
|
||||
print '<td'.($align?' class="'.$align.'"':'').'>';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour');
|
||||
elseif ($key == 'status') print '<td align="center">'.$object->getLibStatut(3).'</td>';
|
||||
elseif ($key == 'status') print $object->getLibStatut(3);
|
||||
else print $obj->$key;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! empty($val['isameasure']))
|
||||
{
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
|
||||
$totalarray['val']['t.'.$key] += $obj->$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Action column
|
||||
@ -546,22 +576,23 @@ while ($i < min($num, $limit))
|
||||
}
|
||||
|
||||
// Show total line
|
||||
if (isset($totalarray['totalhtfield']))
|
||||
if (isset($totalarray['pos']))
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
$i=0;
|
||||
while ($i < $totalarray['nbfield'])
|
||||
{
|
||||
$i++;
|
||||
if ($i == 1)
|
||||
if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
|
||||
else
|
||||
{
|
||||
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||
if ($i == 1)
|
||||
{
|
||||
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||
}
|
||||
print '<td></td>';
|
||||
}
|
||||
elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
|
||||
elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>';
|
||||
elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>';
|
||||
else print '<td></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
163
htdocs/modulebuilder/template/myobject_note.php
Normal file
163
htdocs/modulebuilder/template/myobject_note.php
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/modulebuilder/template/myobject_note.php
|
||||
* \ingroup mymodule
|
||||
* \brief Car with notes on MyObject
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
$res=0;
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
|
||||
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
|
||||
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
|
||||
if (! $res) die("Include of main fails");
|
||||
|
||||
dol_include_once('/mymodule/class/myobject.class.php');
|
||||
dol_include_once('/mymodule/lib/myobject.lib.php');
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
$langs->loadLangs(array("mymodule@mymodule","companies"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
// Initialize technical objects
|
||||
$object=new MyObject($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('myobjectnote')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('myobject');
|
||||
|
||||
// Security check - Protection if external user
|
||||
//if ($user->societe_id > 0) access_forbidden();
|
||||
//if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
//$result = restrictedArea($user, 'mymodule', $id);
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id;
|
||||
|
||||
$permissionnote=1;
|
||||
//$permissionnote=$user->rights->mymodule->creer; // Used by the include of actions_setnotes.inc.php
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
|
||||
$help_url='';
|
||||
llxHeader('',$langs->trans('MyObject'),$help_url);
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = myobjectPrepareHead($object);
|
||||
|
||||
dol_fiche_head($head, 'note', $langs->trans("MyObject"), -1, 'myobject@mymodule');
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="' .dol_buildpath('/mymodule/myobject_list.php',1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
/*
|
||||
// Ref customer
|
||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->mymodule->creer)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||
$morehtmlref.=' : ';
|
||||
if ($action == 'classify') {
|
||||
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||
}
|
||||
} else {
|
||||
if (! empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||
$morehtmlref.=$proj->ref;
|
||||
$morehtmlref.='</a>';
|
||||
} else {
|
||||
$morehtmlref.='';
|
||||
}
|
||||
}
|
||||
}*/
|
||||
$morehtmlref.='</div>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
$cssclass="titlefield";
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -19,8 +19,10 @@ CREATE TABLE llx_myobject(
|
||||
-- BEGIN MODULEBUILDER FIELDS
|
||||
entity INTEGER DEFAULT 1 NOT NULL,
|
||||
label VARCHAR(255),
|
||||
datec DATETIME NOT NULL,
|
||||
qty INTEGER,
|
||||
status INTEGER,
|
||||
date_creation DATETIME NOT NULL,
|
||||
tms TIMESTAMP NOT NULL,
|
||||
status INTEGER
|
||||
import_key VARCHAR(14)
|
||||
-- END MODULEBUILDER FIELDS
|
||||
) ENGINE=innodb;
|
||||
@ -990,11 +990,11 @@ else
|
||||
// Stock min level
|
||||
if ($type != 1 && ! empty($conf->stock->enabled))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("StockLimit").'</td><td>';
|
||||
print '<tr><td>'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).'</td><td>';
|
||||
print '<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST('seuil_stock_alerte').'">';
|
||||
print '</td>';
|
||||
// Stock desired level
|
||||
print '<td>'.$langs->trans("DesiredStock").'</td><td>';
|
||||
print '<td>'.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).'</td><td>';
|
||||
print '<input name="desiredstock" class="maxwidth50" value="'.GETPOST('desiredstock').'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 ATM Consulting <support@atm-consulting.fr>
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -16,698 +20,271 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/inventory/class/product.class.php
|
||||
* \ingroup product
|
||||
* \brief File of class to manage predefined products stock
|
||||
* \file product/inventory/class/inventory.class.php
|
||||
* \ingroup inventory
|
||||
* \brief This file is a CRUD class file for Inventory (Create/Read/Update/Delete)
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/coreobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
|
||||
// Put here all includes required by your class file
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||
|
||||
/**
|
||||
* Class to manage inventories
|
||||
* Class for Inventory
|
||||
*/
|
||||
class Inventory extends CoreObject
|
||||
class Inventory extends CommonObject
|
||||
{
|
||||
public $element='inventory';
|
||||
public $table_element='inventory';
|
||||
public $fk_element='fk_inventory';
|
||||
protected $childtables=array('inventorydet'); // To test if we can delete object
|
||||
protected $isnolinkedbythird = 1; // No field fk_soc
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
/**
|
||||
* Warehouse Id
|
||||
* @var int
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
public $fk_warehouse;
|
||||
public $element = 'inventory';
|
||||
/**
|
||||
* Entity Id
|
||||
* @var int
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'inventory';
|
||||
|
||||
/**
|
||||
* @var array Does this field is linked to a thirdparty ?
|
||||
*/
|
||||
protected $isnolinkedbythird = 1;
|
||||
/**
|
||||
* @var array Does inventory support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
*/
|
||||
protected $ismultientitymanaged = 1;
|
||||
/**
|
||||
* @var string String with name of icon for inventory
|
||||
*/
|
||||
public $picto = 'inventory';
|
||||
|
||||
|
||||
/**
|
||||
* 'type' if the field format, 'label' the translation key, 'enabled' is a condition when the filed must be managed,
|
||||
* 'visible' says if field is visible in list (-1 means not shown by default but can be aded into list to be viewed)
|
||||
* 'notnull' if not null in database
|
||||
* 'index' if we want an index in database
|
||||
* 'position' is the sort order of field
|
||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button
|
||||
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
|
||||
* 'comment' is not used. You can store here any text of your choice.
|
||||
*/
|
||||
|
||||
// BEGIN MODULEBUILDER PROPERTIES
|
||||
/**
|
||||
* @var array Array with all fields and their property
|
||||
*/
|
||||
public $fields=array(
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
|
||||
'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object',),
|
||||
'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
|
||||
'fk_warehouse' => array('type'=>'integer', 'label'=>'', 'visible'=>1, 'enabled'=>1, 'index'=>1,),
|
||||
'date_inventory' => array('type'=>'date', 'label'=>'', 'visible'=>1, 'enabled'=>1,),
|
||||
'title' => array('type'=>'varchar(255)', 'label'=>'', 'visible'=>1, 'enabled'=>1,),
|
||||
'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'index'=>1,),
|
||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500,),
|
||||
'date_validation' => array('type'=>'datetime', 'label'=>'DateValidation', 'visible'=>-1, 'enabled'=>1, 'position'=>500,),
|
||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
|
||||
'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500,),
|
||||
'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500,),
|
||||
'fk_user_valid' => array('type'=>'integer', 'label'=>'UserValid', 'visible'=>-1, 'enabled'=>1, 'position'=>500,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'index'=>1,),
|
||||
);
|
||||
|
||||
public $rowid;
|
||||
public $ref;
|
||||
public $entity;
|
||||
|
||||
/**
|
||||
* Status
|
||||
* @var int
|
||||
*/
|
||||
public $status;
|
||||
/**
|
||||
* Inventory Date
|
||||
* @var date
|
||||
*/
|
||||
public $fk_warehouse;
|
||||
public $date_inventory;
|
||||
/**
|
||||
* Inventory Title
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
public $status;
|
||||
public $date_creation;
|
||||
public $date_validation;
|
||||
public $tms;
|
||||
public $fk_user_creat;
|
||||
public $fk_user_modif;
|
||||
public $fk_user_valid;
|
||||
public $import_key;
|
||||
// END MODULEBUILDER PROPERTIES
|
||||
|
||||
/**
|
||||
* Attribute object linked with database
|
||||
* @var array
|
||||
*/
|
||||
protected $fields=array(
|
||||
'fk_warehouse'=>array('type'=>'integer','index'=>true)
|
||||
,'ref'=>array('type'=>'string','index'=>true)
|
||||
,'entity'=>array('type'=>'integer','index'=>true)
|
||||
,'status'=>array('type'=>'integer','index'=>true)
|
||||
,'date_inventory'=>array('type'=>'date')
|
||||
,'title'=>array('type'=>'string')
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB &$db)
|
||||
|
||||
// If this object has a subtable with lines
|
||||
|
||||
/**
|
||||
* @var int Name of subtable line
|
||||
*/
|
||||
//public $table_element_line = 'inventorydet';
|
||||
/**
|
||||
* @var int Field with ID of parent key if this field has a parent
|
||||
*/
|
||||
//public $fk_element = 'fk_inventory';
|
||||
/**
|
||||
* @var int Name of subtable class that manage subtable lines
|
||||
*/
|
||||
//public $class_element_line = 'Inventoryline';
|
||||
/**
|
||||
* @var array Array of child tables (child tables to delete before deleting a record)
|
||||
*/
|
||||
//protected $childtables=array('inventorydet');
|
||||
/**
|
||||
* @var InventoryLine[] Array of subtable lines
|
||||
*/
|
||||
//public $lines = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDb $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB $db)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
parent::__construct($db);
|
||||
parent::init();
|
||||
|
||||
$this->status = 0;
|
||||
$this->entity = $conf->entity;
|
||||
$this->errors = array();
|
||||
$this->amount = 0;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to sort children object
|
||||
*/
|
||||
public function sortDet()
|
||||
|
||||
/**
|
||||
* Return a link to the object card (with optionaly the picto)
|
||||
*
|
||||
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||
* @param string $option On what the link point to
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $morecss Add more css on link
|
||||
* @return string String with URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='')
|
||||
{
|
||||
if(!empty($this->Inventorydet)) usort($this->Inventorydet, array('Inventory', 'customSort'));
|
||||
}
|
||||
global $db, $conf, $langs;
|
||||
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
||||
global $menumanager;
|
||||
|
||||
/**
|
||||
* Get object and children from database
|
||||
*
|
||||
* @param int $id Id of object to load
|
||||
* @param bool $loadChild used to load children from database
|
||||
* @return int >0 if OK, <0 if KO, 0 if not found
|
||||
*/
|
||||
public function fetch($id, $loadChild = true)
|
||||
{
|
||||
if(!$loadChild) $this->withChild = false;
|
||||
|
||||
$res = parent::fetch($id, $loadChild);
|
||||
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
|
||||
|
||||
if ($res > 0)
|
||||
{
|
||||
$this->sortDet();
|
||||
$this->amount = 0;
|
||||
if(!empty($this->Inventorydet ))
|
||||
{
|
||||
foreach($this->Inventorydet as &$det)
|
||||
{
|
||||
$this->amount += $det->qty_view * $det->pmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
$result = '';
|
||||
$companylink = '';
|
||||
|
||||
/**
|
||||
* Custom function call by usort
|
||||
*
|
||||
* @param Inventorydet $objA first Inventorydet object
|
||||
* @param Inventorydet $objB second Inventorydet object
|
||||
* @return int
|
||||
*/
|
||||
private function customSort(&$objA, &$objB)
|
||||
{
|
||||
$r = strcmp(strtoupper(trim($objA->product->ref)), strtoupper(trim($objB->product->ref)));
|
||||
|
||||
if ($r < 0) $r = -1;
|
||||
elseif ($r > 0) $r = 1;
|
||||
else $r = 0;
|
||||
|
||||
return $r;
|
||||
}
|
||||
$label = '<u>' . $langs->trans("Inventory") . '</u>';
|
||||
$label.= '<br>';
|
||||
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||
|
||||
/**
|
||||
* @param User $user user object
|
||||
* @return int
|
||||
*/
|
||||
public function changePMP(User &$user)
|
||||
{
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
$url = $url = dol_buildpath('/inventory/m_card.php',1).'?id='.$this->id;
|
||||
|
||||
if(!empty($this->Inventorydet))
|
||||
{
|
||||
foreach ($this->Inventorydet as $k => &$Inventorydet)
|
||||
{
|
||||
if($Inventorydet->new_pmp>0)
|
||||
{
|
||||
$Inventorydet->pmp = $Inventorydet->new_pmp;
|
||||
$Inventorydet->new_pmp = 0;
|
||||
|
||||
$res = $this->db->query('UPDATE '.MAIN_DB_PREFIX.'product as p SET pmp = '.$Inventorydet->pmp.' WHERE rowid = '.$Inventorydet->fk_product );
|
||||
if (!$res)
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$res = parent::update($user);
|
||||
if (!$res)
|
||||
$linkclose='';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update object or create or delete if needed
|
||||
*
|
||||
* @param User $user user object
|
||||
* @return < 0 if ko, > 0 if ok
|
||||
*/
|
||||
public function update(User &$user)
|
||||
{
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
// if we valid the inventory we save the stock at the same time
|
||||
if ($this->status)
|
||||
{
|
||||
$res = $this->regulate();
|
||||
if ($res < 0)
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$label=$langs->trans("ShowInventory");
|
||||
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
|
||||
}
|
||||
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
|
||||
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart.=$linkclose.'>';
|
||||
$linkend='</a>';
|
||||
|
||||
if ($withpicto)
|
||||
{
|
||||
$result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||
if ($withpicto != 2) $result.=' ';
|
||||
}
|
||||
|
||||
$res = parent::update($user);
|
||||
if (!$res)
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
$result.= $linkstart . $this->ref . $linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update current object
|
||||
*
|
||||
* @param array $Tab Array of values
|
||||
* @return int
|
||||
*/
|
||||
public function setValues(&$Tab)
|
||||
/**
|
||||
* Retourne le libelle du status d'un user (actif, inactif)
|
||||
*
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
function getLibStatut($mode=0)
|
||||
{
|
||||
return $this->LibStatut($this->status,$mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the status
|
||||
*
|
||||
* @param int $status Id status
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
static function LibStatut($status,$mode=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if (isset($Tab['qty_to_add']))
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
foreach ($Tab['qty_to_add'] as $k => $qty)
|
||||
{
|
||||
$qty = (float) price2num($qty);
|
||||
|
||||
if ($qty < 0)
|
||||
{
|
||||
$this->errors[] = $langs->trans('inventoryErrorQtyAdd');
|
||||
return -1;
|
||||
}
|
||||
|
||||
$product = new Product($this->db);
|
||||
$product->fetch($this->Inventorydet[$k]->fk_product);
|
||||
|
||||
$this->Inventorydet[$k]->pmp = $product->pmp;
|
||||
$this->Inventorydet[$k]->qty_view += $qty;
|
||||
}
|
||||
$prefix='';
|
||||
if ($status == 1) return $langs->trans('Enabled');
|
||||
if ($status == 0) return $langs->trans('Disabled');
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Enabled');
|
||||
if ($status == 0) return $langs->trans('Disabled');
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
|
||||
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
|
||||
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
|
||||
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
||||
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||
}
|
||||
if ($mode == 6)
|
||||
{
|
||||
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
||||
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||
}
|
||||
|
||||
return parent::setValues($Tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to delete all Inventorydet
|
||||
*
|
||||
* @param User $user user object
|
||||
* @return < 0 if ko, > 0 if ok
|
||||
*/
|
||||
public function deleteAllLine(User &$user)
|
||||
{
|
||||
foreach($this->Inventorydet as &$det)
|
||||
{
|
||||
$det->to_delete = true;
|
||||
}
|
||||
|
||||
$res = $this->update($user);
|
||||
|
||||
if ($res > 0) $this->Inventorydet = array();
|
||||
else return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add Inventorydet
|
||||
*
|
||||
* @param int $fk_product fk_product of Inventorydet
|
||||
* @param int $fk_warehouse fk_warehouse target
|
||||
* @return bool
|
||||
*/
|
||||
public function addProduct($fk_product, $fk_warehouse=0)
|
||||
{
|
||||
$k = $this->addChild('Inventorydet');
|
||||
$det = &$this->Inventorydet[$k];
|
||||
|
||||
$det->fk_inventory = $this->id;
|
||||
$det->fk_product = $fk_product;
|
||||
$det->fk_warehouse = empty($fk_warehouse) ? $this->fk_warehouse : $fk_warehouse;
|
||||
|
||||
$det->load_product();
|
||||
|
||||
$date = $this->getDate('date_inventory', 'Y-m-d');
|
||||
if(empty($date)) $date = $this->getDate('datec', 'Y-m-d');
|
||||
$det->setStockDate($date, $fk_warehouse);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplication method product to add datem
|
||||
* Adjust stock in a warehouse for product
|
||||
*
|
||||
* @param int $fk_product id of product
|
||||
* @param int $fk_warehouse id of warehouse
|
||||
* @param double $nbpiece nb of units
|
||||
* @param int $movement 0 = add, 1 = remove
|
||||
* @param string $label Label of stock movement
|
||||
* @param double $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed.
|
||||
* @param string $inventorycode Inventory code
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function correctStock($fk_product, $fk_warehouse, $nbpiece, $movement, $label='', $price=0, $inventorycode='')
|
||||
/**
|
||||
* Initialise object with example values
|
||||
* Id must be 0 if object instance is a specimen
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
if ($fk_warehouse)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php';
|
||||
|
||||
$op[0] = "+".trim($nbpiece);
|
||||
$op[1] = "-".trim($nbpiece);
|
||||
|
||||
$datem = empty($conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT) ? dol_now() : $this->date_inventory;
|
||||
|
||||
$movementstock=new MouvementStock($this->db);
|
||||
$movementstock->origin = new stdClass();
|
||||
$movementstock->origin->element = 'inventory';
|
||||
$movementstock->origin->id = $this->id;
|
||||
$result=$movementstock->_create($user,$fk_product,$fk_warehouse,$op[$movement],$movement,$price,$label,$inventorycode, $datem);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$movementstock->error;
|
||||
$this->errors=$movementstock->errors;
|
||||
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
$this->initAsSpecimenCommon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to regulate stock
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function regulate()
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
if($conf->global->INVENTORY_DISABLE_VIRTUAL)
|
||||
{
|
||||
$pdt_virtuel = false;
|
||||
// Test if virtual product is enabled
|
||||
if($conf->global->PRODUIT_SOUSPRODUITS)
|
||||
{
|
||||
$pdt_virtuel = true;
|
||||
$conf->global->PRODUIT_SOUSPRODUITS = 0;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->Inventorydet as $k => $Inventorydet)
|
||||
{
|
||||
$product = new Product($this->db);
|
||||
$product->fetch($Inventorydet->fk_product);
|
||||
|
||||
if ($Inventorydet->qty_view != $Inventorydet->qty_stock)
|
||||
{
|
||||
$Inventorydet->qty_regulated = $Inventorydet->qty_view - $Inventorydet->qty_stock;
|
||||
$nbpiece = abs($Inventorydet->qty_regulated);
|
||||
$movement = (int) ($Inventorydet->qty_view < $Inventorydet->qty_stock); // 0 = add ; 1 = remove
|
||||
|
||||
//$href = dol_buildpath('/inventory/inventory.php?id='.$this->id.'&action=view', 1);
|
||||
|
||||
$res = $this->correctStock($product->id, $Inventorydet->fk_warehouse, $nbpiece, $movement, $langs->trans('inventoryMvtStock'));
|
||||
if ($res < 0) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if($conf->global->INVENTORY_DISABLE_VIRTUAL)
|
||||
{
|
||||
// Test if virtual product was enabled before regulate
|
||||
if($pdt_virtuel) $conf->global->PRODUIT_SOUSPRODUITS = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
return !empty($this->title) ? $this->title : $langs->trans('inventoryTitle').' '.$this->id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return clicable link of object (with eventually picto)
|
||||
*
|
||||
* @param int $withpicto Add picto into link
|
||||
* @return string
|
||||
*/
|
||||
public function getNomUrl($withpicto = 1)
|
||||
{
|
||||
return '<a href="'.DOL_URL_ROOT.'/product/inventory/card.php?id='.$this->id.'">'.($withpicto ? img_picto('','object_list.png','',0).' ' : '').$this->getTitle().'</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add products by default from warehouse and children
|
||||
*
|
||||
* @param int $fk_warehouse id of warehouse
|
||||
* @param int $fk_category id of category
|
||||
* @param int $fk_supplier id of supplier
|
||||
* @param int $only_prods_in_stock only product with stock
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function addProductsFor($fk_warehouse,$fk_category=0,$fk_supplier=0,$only_prods_in_stock=0)
|
||||
{
|
||||
$warehouse = new Entrepot($this->db);
|
||||
$warehouse->fetch($fk_warehouse);
|
||||
$TChildWarehouses = array($fk_warehouse);
|
||||
$warehouse->get_children_warehouses($fk_warehouse, $TChildWarehouses);
|
||||
|
||||
$sql = 'SELECT ps.fk_product, ps.fk_entrepot';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'product_stock ps';
|
||||
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = ps.fk_product)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product cp ON (cp.fk_product = p.rowid)';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid)';
|
||||
$sql.= ' WHERE ps.fk_entrepot IN ('.implode(', ', $TChildWarehouses).')';
|
||||
|
||||
if ($fk_category>0) $sql.= ' AND cp.fk_categorie='.$fk_category;
|
||||
if ($fk_supplier>0) $sql.= ' AND pfp.fk_soc = '.$fk_supplier;
|
||||
if (!empty($only_prods_in_stock)) $sql.= ' AND ps.reel > 0';
|
||||
|
||||
$sql.=' GROUP BY ps.fk_product, ps.fk_entrepot ORDER BY p.ref ASC,p.label ASC';
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if($res)
|
||||
{
|
||||
while($obj = $this->db->fetch_object($res))
|
||||
{
|
||||
$this->addProduct($obj->fk_product, $obj->fk_entrepot);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable link of inventory object
|
||||
*
|
||||
* @param int $id id of inventory
|
||||
* @param int $withpicto Add picto into link
|
||||
* @return string
|
||||
*/
|
||||
static function getLink($id, $withpicto=1)
|
||||
{
|
||||
global $langs,$db;
|
||||
|
||||
$inventory = new Inventory($db);
|
||||
if($inventory->fetch($id, false) > 0) return $inventory->getNomUrl($withpicto);
|
||||
else return $langs->trans('InventoryUnableToFetchObject');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the sql select of inventory
|
||||
*
|
||||
* @param string $type 'All' to get all data
|
||||
* @return string
|
||||
*/
|
||||
static function getSQL($type)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = '';
|
||||
if($type == 'All')
|
||||
{
|
||||
$sql = 'SELECT i.rowid,i.title, e.label, i.date_inventory, i.fk_warehouse, i.datec, i.tms, i.status';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'inventory i';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot e ON (e.rowid = i.fk_warehouse)';
|
||||
$sql.= ' WHERE i.entity IN ('.getEntity('inventory').')';
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
|
||||
class Inventorydet extends CoreObject
|
||||
/**
|
||||
* Class InventoryObjectLine
|
||||
*/
|
||||
class InventoryObjectLine
|
||||
{
|
||||
public $element='inventorydet';
|
||||
public $table_element='inventorydet';
|
||||
protected $isnolinkedbythird = 1; // No field fk_soc
|
||||
protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
public $fk_inventory;
|
||||
public $fk_warehouse;
|
||||
public $fk_product;
|
||||
public $entity;
|
||||
public $qty_view;
|
||||
public $qty_stock;
|
||||
public $qty_regulated;
|
||||
public $pmp;
|
||||
public $pa;
|
||||
public $new_pmp;
|
||||
|
||||
protected $fields=array(
|
||||
'fk_inventory'=>array('type'=>'int')
|
||||
,'fk_warehouse'=>array('type'=>'int')
|
||||
,'fk_product'=>array('type'=>'int')
|
||||
,'entity'=>array('type'=>'int')
|
||||
,'qty_view'=>array('type'=>'float')
|
||||
,'qty_stock'=>array('type'=>'float')
|
||||
,'qty_regulated'=>array('type'=>'float')
|
||||
,'pmp'=>array('type'=>'float')
|
||||
,'pa'=>array('type'=>'float')
|
||||
,'new_pmp'=>array('type'=>'float')
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct(DoliDB &$db)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
parent::__construct($db);
|
||||
parent::init();
|
||||
|
||||
$this->entity = $conf->entity;
|
||||
$this->errors = array();
|
||||
|
||||
$this->product = null;
|
||||
$this->current_pa = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object and children from database
|
||||
*
|
||||
* @param int $id id of inventorydet object
|
||||
* @param bool $loadChild load children
|
||||
* @return int
|
||||
*/
|
||||
function fetch($id, $loadChild = true)
|
||||
{
|
||||
$res = parent::fetch($id);
|
||||
$this->load_product();
|
||||
$this->fetch_current_pa();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the unit buy price
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function fetch_current_pa()
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
if(empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)) return false;
|
||||
|
||||
if($this->pa > 0)
|
||||
{
|
||||
$this->current_pa = $this->pa;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_include_once('/fourn/class/fournisseur.product.class.php');
|
||||
$p= new ProductFournisseur($db);
|
||||
$p->find_min_price_product_fournisseur($this->fk_product);
|
||||
|
||||
if($p->fourn_qty>0) $this->current_pa = $p->fourn_price / $p->fourn_qty;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to set pa attribute from date en fk_warehouse
|
||||
*
|
||||
* @param date $date date value
|
||||
* @param int $fk_warehouse fk_warehouse target
|
||||
*/
|
||||
function setStockDate($date, $fk_warehouse)
|
||||
{
|
||||
list($pmp, $stock) = $this->getPmpStockFromDate($date, $fk_warehouse);
|
||||
|
||||
$this->qty_stock = $stock;
|
||||
$this->pmp = $pmp;
|
||||
|
||||
$last_pa = 0;
|
||||
$sql = 'SELECT price FROM '.MAIN_DB_PREFIX.'stock_mouvement';
|
||||
$sql.= ' WHERE fk_entrepot = '.$fk_warehouse;
|
||||
$sql.= ' AND fk_product = '.$this->fk_product;
|
||||
$sql.= ' AND (origintype=\'order_supplier\' || origintype=\'invoice_supplier\')';
|
||||
$sql.= ' AND price > 0';
|
||||
$sql.= ' AND datem <= \''.$date.' 23:59:59\'';
|
||||
$sql.= ' ORDER BY datem DESC LIMIT 1';
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
if($res && $obj = $this->db->fetch_object($res))
|
||||
{
|
||||
$last_pa = $obj->price;
|
||||
}
|
||||
|
||||
$this->pa = $last_pa;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the last pmp and last stock from date and warehouse
|
||||
*
|
||||
* @param date $date date to check
|
||||
* @param int $fk_warehouse id of warehouse
|
||||
* @return array
|
||||
*/
|
||||
function getPmpStockFromDate($date, $fk_warehouse)
|
||||
{
|
||||
$res = $this->product->load_stock();
|
||||
|
||||
if($res>0)
|
||||
{
|
||||
$stock = isset($this->product->stock_warehouse[$fk_warehouse]->real) ? $this->product->stock_warehouse[$fk_warehouse]->real : 0;
|
||||
$pmp = $this->product->pmp;
|
||||
}
|
||||
|
||||
//All Stock mouvement between now and inventory date
|
||||
$sql = 'SELECT value, price';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'stock_mouvement';
|
||||
$sql.= ' WHERE fk_product = '.$this->product->id;
|
||||
$sql.= ' AND fk_entrepot = '.$fk_warehouse;
|
||||
$sql.= ' AND datem > \''.date('Y-m-d 23:59:59', strtotime($date)).'\'';
|
||||
$sql.= ' ORDER BY datem DESC';
|
||||
|
||||
$res = $this->db->query($sql);
|
||||
|
||||
$laststock = $stock;
|
||||
$lastpmp = $pmp;
|
||||
|
||||
if($res)
|
||||
{
|
||||
while($mouvement = $this->db->fetch_object($res))
|
||||
{
|
||||
$price = ($mouvement->price > 0 && $mouvement->value > 0) ? $mouvement->price : $lastpmp;
|
||||
$stock_value = $laststock * $lastpmp;
|
||||
$laststock -= $mouvement->value;
|
||||
$last_stock_value = $stock_value - ($mouvement->value * $price);
|
||||
$lastpmp = ($laststock != 0) ? $last_stock_value / $laststock : $lastpmp;
|
||||
}
|
||||
}
|
||||
|
||||
return array($lastpmp, $laststock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the product linked with the line
|
||||
* @return void
|
||||
*/
|
||||
function load_product()
|
||||
{
|
||||
global $db;
|
||||
|
||||
if($this->fk_product>0)
|
||||
{
|
||||
$this->product = new Product($db);
|
||||
$this->product->fetch($this->fk_product);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* @var mixed Sample line property 1
|
||||
*/
|
||||
public $prop1;
|
||||
/**
|
||||
* @var mixed Sample line property 2
|
||||
*/
|
||||
public $prop2;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 ATM Consulting <support@atm-consulting.fr>
|
||||
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -16,119 +17,623 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/inventory/list.php
|
||||
* \ingroup product
|
||||
* \brief File of class to manage inventory
|
||||
* \file product/inventory/list.php
|
||||
* \ingroup inventory
|
||||
* \brief List page for monmodule
|
||||
*/
|
||||
|
||||
require_once '../../main.inc.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/inventory/listview.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php';
|
||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test
|
||||
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test
|
||||
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
|
||||
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
||||
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
||||
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
|
||||
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
||||
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
|
||||
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
||||
|
||||
$langs->load("stock");
|
||||
$langs->load("inventory");
|
||||
|
||||
// Load Dolibarr environment
|
||||
$res=0;
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
|
||||
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
|
||||
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
|
||||
if (! $res) die("Include of main fails");
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
dol_include_once('/inventory/class/inventory.class.php');
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
$langs->loadLangs(array("inventory","other"));
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
$massaction = GETPOST('massaction','alpha');
|
||||
$show_files = GETPOST('show_files','int');
|
||||
$confirm = GETPOST('confirm','alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$toselect = GETPOST('toselect', 'array');
|
||||
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'inventorylist'; // To manage different context of search
|
||||
|
||||
$id = GETPOST('id','int');
|
||||
$backtopage = GETPOST('backtopage');
|
||||
$optioncss = GETPOST('optioncss','alpha');
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = (GETPOST("page",'int')?GETPOST("page", 'int'):0);
|
||||
$sortfield = GETPOST('sortfield','alpha');
|
||||
$sortorder = GETPOST('sortorder','alpha');
|
||||
$page = GETPOST('page','int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortfield) $sortfield="i.title";
|
||||
|
||||
// Initialize technical objects
|
||||
$object=new Inventory($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('inventory');
|
||||
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
|
||||
|
||||
// Default sort order (if not yet defined by previous GETPOST)
|
||||
if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition.
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
|
||||
if (empty($user->rights->stock->lire)) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// None
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('',$langs->trans('inventoryListTitle'),'','');
|
||||
|
||||
echo '<form name="formListInvetory" action="'.$_SERVER['PHP_SELF'].'" method="post" >';
|
||||
|
||||
$inventory = new Inventory($db);
|
||||
$list = new ListView($db, 'listInventory');
|
||||
|
||||
$THide = array('label','title');
|
||||
|
||||
echo $list->render(Inventory::getSQL('All'), array(
|
||||
'param' => array(
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'sortfield' => $sortfield,
|
||||
'sortorder'=> $sortorder,
|
||||
'page'=>$page
|
||||
),
|
||||
'limit' => array(
|
||||
'nbLine' => $limit,
|
||||
),
|
||||
'allow-field-select' => true,
|
||||
'link'=>array(
|
||||
'fk_warehouse'=>'<a href="'.DOL_URL_ROOT.'/product/stock/card.php?id=@val@">'.img_picto('','object_stock.png','',0).' @label@</a>'
|
||||
),
|
||||
'translate'=>array(),
|
||||
'hide'=>$THide,
|
||||
'type'=>array(
|
||||
'datec'=>'date',
|
||||
'tms'=>'datetime',
|
||||
'date_inventory'=>'date'
|
||||
),
|
||||
'list'=>array(
|
||||
'title'=>$langs->trans('inventoryListTitle'),
|
||||
'messageNothing'=>$langs->trans('inventoryListEmpty'),
|
||||
'image' => 'title_products.png'
|
||||
),
|
||||
'title'=>array(
|
||||
'rowid'=>$langs->trans('Title'),
|
||||
'date_inventory'=>$langs->trans('InventoryDate'),
|
||||
'fk_warehouse'=>$langs->trans('Warehouse'),
|
||||
'datec'=>$langs->trans('DateCreation'),
|
||||
'tms'=>$langs->trans('DateModification'),
|
||||
'status'=>$langs->trans('Status')
|
||||
),
|
||||
'eval'=>array(
|
||||
'status' => '(@val@ ? img_picto("'.$langs->trans("inventoryValidate").'", "statut4") : img_picto("'.$langs->trans("inventoryDraft").'", "statut3"))',
|
||||
'rowid'=>'Inventory::getLink(@val@)'
|
||||
),
|
||||
'position' => array(
|
||||
'text-align' => array('status' => 'right')
|
||||
|
||||
),
|
||||
'search'=>array(
|
||||
'rowid' => array('search_type' => true, 'table' => array('i'), 'field' => array('title')),
|
||||
'date_inventory'=>array('search_type' => 'calendars', 'table' => array('i'), 'field' => array('date_inventory')),
|
||||
'status'=>array('search_type' => array(1=>$langs->trans("inventoryValidate"), 0=>$langs->trans("inventoryDraft")))
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
/*if (!empty($user->rights->stock->create))
|
||||
// Protection if external user
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="inventory.php?action=create">'.$langs->trans('inventoryCreate').'</a>';
|
||||
//$socid = $user->societe_id;
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Initialize array of search criterias
|
||||
$search_all=trim(GETPOST("search_all",'alpha'));
|
||||
$search=array();
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha');
|
||||
}
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array();
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label'];
|
||||
}
|
||||
|
||||
// Definition of fields for list
|
||||
$arrayfields=array();
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
// If $val['visible']==0, then we never show the field
|
||||
if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']);
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ACTIONS
|
||||
*
|
||||
* Put here all code to do according to value of "$action" parameter
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
|
||||
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
$search[$key]='';
|
||||
}
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
}
|
||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
|
||||
|| GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
|
||||
{
|
||||
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||
}
|
||||
|
||||
// Mass actions
|
||||
$objectclass='Inventory';
|
||||
$objectlabel='Inventory';
|
||||
$permtoread = $user->rights->inventory->read;
|
||||
$permtodelete = $user->rights->inventory->delete;
|
||||
$uploaddir = $conf->inventory->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* VIEW
|
||||
*
|
||||
* Put here all code to build page
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
//$help_url="EN:Module_Inventory|FR:Module_Inventory_FR|ES:Módulo_Inventory";
|
||||
$help_url='';
|
||||
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Inventorys"));
|
||||
|
||||
|
||||
// Build and execute select
|
||||
// --------------------------------------------------------------------
|
||||
$sql = 'SELECT ';
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
$sql.='t.'.$key.', ';
|
||||
}
|
||||
// Add fields from extrafields
|
||||
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
||||
// Add fields from hooks
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql.=$hookmanager->resPrint;
|
||||
$sql=preg_replace('/, $/','', $sql);
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."inventory as t";
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."inventory_extrafields as ef on (t.rowid = ef.fk_object)";
|
||||
$sql.= " WHERE t.entity IN (".getEntity('inventory').")";
|
||||
foreach($search as $key => $val)
|
||||
{
|
||||
if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0)));
|
||||
}
|
||||
if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
// Add where from extra fields
|
||||
foreach ($search_array_options as $key => $val)
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
$typ=$extrafields->attribute_type[$tmpkey];
|
||||
$mode=0;
|
||||
if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric
|
||||
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
|
||||
{
|
||||
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
|
||||
}
|
||||
}
|
||||
// Add where from hooks
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql.=$hookmanager->resPrint;
|
||||
$sql.=$db->order($sortfield,$sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
}
|
||||
|
||||
$sql.= $db->plimit($limit+1, $offset);
|
||||
|
||||
dol_syslog($script_file, LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
// Direct jump if only one record found
|
||||
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$id = $obj->rowid;
|
||||
header("Location: ".DOL_URL_ROOT.'/inventory/inventory_card.php?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// Output page
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
// Example : Adding jquery code
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
function init_myfunc()
|
||||
{
|
||||
jQuery("#myid").removeAttr(\'disabled\');
|
||||
jQuery("#myid").attr(\'disabled\',\'disabled\');
|
||||
}
|
||||
init_myfunc();
|
||||
jQuery("#mybutton").click(function() {
|
||||
init_myfunc();
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
foreach($search as $key => $val)
|
||||
{
|
||||
$param.= '&search_'.$key.'='.urlencode($search[$key]);
|
||||
}
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
// Add $param from extra fields
|
||||
foreach ($search_array_options as $key => $val)
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||
}
|
||||
|
||||
$arrayofmassactions = array(
|
||||
'presend'=>$langs->trans("SendByMail"),
|
||||
'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->inventory->delete) $arrayofmassactions['delete']=$langs->trans("Delete");
|
||||
if ($massaction == 'presend') $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
||||
}
|
||||
|
||||
$moreforfilter = '';
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
|
||||
$moreforfilter.= '</div>';
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
if (! empty($moreforfilter))
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}*/
|
||||
}
|
||||
|
||||
echo '</form>';
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
|
||||
|
||||
llxFooter('');
|
||||
$db->close();
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
|
||||
// Fields title search
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
$typeofextrafield=$extrafields->attribute_type[$key];
|
||||
print '<td class="liste_titre'.($align?' '.$align:'').'">';
|
||||
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
$searchclass='';
|
||||
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
|
||||
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
|
||||
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Rest of fields search
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
|
||||
}
|
||||
// Action column
|
||||
print '<td class="liste_titre" align="right">';
|
||||
$searchpicto=$form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
||||
// Fields title label
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
$sortonfield = "ef.".$key;
|
||||
if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
|
||||
print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hook fields
|
||||
$parameters=array('arrayfields'=>$arrayfields);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Rest of fields title
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
||||
}
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
|
||||
print '</tr>'."\n";
|
||||
|
||||
|
||||
// Detect if we need a fetch on each output line
|
||||
$needToFetchEachLine=0;
|
||||
foreach ($extrafields->attribute_computed as $key => $val)
|
||||
{
|
||||
if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object
|
||||
}
|
||||
|
||||
|
||||
// Loop on record
|
||||
// --------------------------------------------------------------------
|
||||
$i=0;
|
||||
$totalarray=array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
// Store properties in $object
|
||||
$object->id = $obj->rowid;
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (isset($obj->$key)) $object->$key = $obj->$key;
|
||||
}
|
||||
|
||||
// Show here line of result
|
||||
print '<tr class="oddeven">';
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.='nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked']))
|
||||
{
|
||||
print '<td'.($align?' class="'.$align.'"':'').'>';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour');
|
||||
elseif ($key == 'ref') print $object->getNomUrl(1);
|
||||
elseif ($key == 'status') print $object->getLibStatut(3);
|
||||
else print $obj->$key;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! empty($val['isameasure']))
|
||||
{
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
|
||||
$totalarray['val']['t.'.$key] += $obj->$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
{
|
||||
print '<td';
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
if ($align) print ' align="'.$align.'"';
|
||||
print '>';
|
||||
$tmpkey='options_'.$key;
|
||||
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! empty($val['isameasure']))
|
||||
{
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
|
||||
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fields from hook
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Rest of fields
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue;
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked']))
|
||||
{
|
||||
print '<td'.($align?' class="'.$align.'"':'').'>';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour');
|
||||
elseif ($key == 'status') print $object->getLibStatut(3);
|
||||
else print $obj->$key;
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
if (! empty($val['isameasure']))
|
||||
{
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
|
||||
$totalarray['val']['t.'.$key] += $obj->$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Action column
|
||||
print '<td class="nowrap" align="center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
$selected=0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Show total line
|
||||
if (isset($totalarray['pos']))
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
$i=0;
|
||||
while ($i < $totalarray['nbfield'])
|
||||
{
|
||||
$i++;
|
||||
if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
|
||||
else
|
||||
{
|
||||
if ($i == 1)
|
||||
{
|
||||
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||
}
|
||||
print '<td></td>';
|
||||
}
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// If no record found
|
||||
if ($num == 0)
|
||||
{
|
||||
$colspan=1;
|
||||
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
$db->free($resql);
|
||||
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>'."\n";
|
||||
print '</div>'."\n";
|
||||
|
||||
print '</form>'."\n";
|
||||
|
||||
if ($nbtotalofrecords === '' || $nbtotalofrecords)
|
||||
{
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
// Show list of available documents
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||
$urlsource.=str_replace('&','&',$param);
|
||||
|
||||
$filedir=$diroutputmassaction;
|
||||
$genallowed=$user->rights->inventory->read;
|
||||
$delallowed=$user->rights->inventory->read;
|
||||
|
||||
print $formfile->showdocuments('massfilesarea_inventory','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -614,7 +614,7 @@ if ($id > 0 || $ref)
|
||||
}
|
||||
|
||||
// Stock alert threshold
|
||||
print '<tr><td>'.$form->editfieldkey("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).'</td><td>';
|
||||
print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1),'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).'</td><td>';
|
||||
print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string');
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
@ -971,6 +971,7 @@ class Project extends CommonObject
|
||||
$label .= ($label?'<br>':'').'<b>' . $langs->trans('DateEnd') . ': </b>' . dol_print_date($this->datee, 'day'); // The space must be after the : to not being explode when showing the title in img_picto
|
||||
if ($moreinpopup) $label.='<br>'.$moreinpopup;
|
||||
|
||||
$url='';
|
||||
if ($option != 'nolink')
|
||||
{
|
||||
if (preg_match('/\.php$/',$option)) {
|
||||
@ -1000,7 +1001,7 @@ class Project extends CommonObject
|
||||
}
|
||||
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose.=' class="classfortooltip"';
|
||||
|
||||
|
||||
if (! is_object($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager=new HookManager($this->db);
|
||||
@ -1008,8 +1009,8 @@ class Project extends CommonObject
|
||||
$hookmanager->initHooks(array('projectdao'));
|
||||
$parameters=array('id'=>$this->id);
|
||||
// Note that $action and $object may have been modified by some hooks
|
||||
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action);
|
||||
if ($reshook > 0)
|
||||
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action);
|
||||
if ($reshook > 0)
|
||||
$linkclose = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
|
||||
@ -50,13 +50,6 @@ if ($result < 0) { $error++; }
|
||||
// Define url to go after disconnect
|
||||
$urlfrom=empty($_SESSION["urlfrom"])?'':$_SESSION["urlfrom"];
|
||||
|
||||
// Destroy some cookies
|
||||
// TODO external module
|
||||
if (! empty($conf->phenix->enabled) && ! empty($conf->phenix->cookie))
|
||||
{
|
||||
setcookie($conf->phenix->cookie, '', 1, "/");
|
||||
}
|
||||
|
||||
// Define url to go
|
||||
$url=DOL_URL_ROOT."/index.php"; // By default go to login page
|
||||
if ($urlfrom) $url=DOL_URL_ROOT.$urlfrom;
|
||||
|
||||
@ -500,9 +500,10 @@ class WebsitePage extends CommonObject
|
||||
* @param string $newref New ref/alias of page
|
||||
* @param string $newlang New language
|
||||
* @param int $istranslation 1=New page is a translation of the cloned page.
|
||||
* @param int $newwebsite 0=Same web site, 1=New web site
|
||||
* @return int New id of clone
|
||||
*/
|
||||
public function createFromClone($fromid, $newref, $newlang='', $istranslation=0)
|
||||
public function createFromClone($fromid, $newref, $newlang='', $istranslation=0, $newwebsite=0)
|
||||
{
|
||||
global $user, $langs;
|
||||
|
||||
@ -525,6 +526,7 @@ class WebsitePage extends CommonObject
|
||||
if (! empty($newlang)) $object->lang=$newlang;
|
||||
if ($istranslation) $object->fk_page = $fromid;
|
||||
else $object->fk_page = 0;
|
||||
if (! empty($newwebsite)) $object->fk_website=$newwebsite;
|
||||
|
||||
// Create clone
|
||||
$result = $object->create($user);
|
||||
|
||||
@ -66,12 +66,12 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0,
|
||||
}
|
||||
|
||||
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formwebsite.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
|
||||
|
||||
@ -138,6 +138,8 @@ global $dolibarr_main_data_root;
|
||||
$pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website;
|
||||
$filehtmlheader=$pathofwebsite.'/htmlheader.html';
|
||||
$filecss=$pathofwebsite.'/styles.css.php';
|
||||
$filerobot=$pathofwebsite.'/robots.txt';
|
||||
$filehtaccess=$pathofwebsite.'/.htaccess';
|
||||
$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
|
||||
$fileindex=$pathofwebsite.'/index.php';
|
||||
|
||||
@ -174,10 +176,11 @@ if ($action == 'add')
|
||||
$error++;
|
||||
$action='create';
|
||||
}
|
||||
else if (! preg_match('/^[a-z0-9]+$/i', $objectpage->pageurl))
|
||||
else if (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors');
|
||||
$error++;
|
||||
$action='create';
|
||||
}
|
||||
if (empty($objectpage->title))
|
||||
{
|
||||
@ -310,7 +313,6 @@ if ($action == 'updatecss')
|
||||
$csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
|
||||
$csscontent.= "// END PHP ?>"."\n";
|
||||
|
||||
|
||||
dol_syslog("Save file css into ".$filecss);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
@ -325,6 +327,70 @@ if ($action == 'updatecss')
|
||||
}
|
||||
|
||||
|
||||
// Css file
|
||||
$robotcontent ='';
|
||||
|
||||
/*$robotcontent.= "<?php // BEGIN PHP\n";
|
||||
$robotcontent.= '$websitekey=basename(dirname(__FILE__));'."\n";
|
||||
$robotcontent.= "if (! defined('USEDOLIBARRSERVER')) { require_once './master.inc.php'; } // Not already loaded"."\n";
|
||||
$robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
|
||||
$robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
|
||||
$robotcontent.= "ob_start();\n";
|
||||
$robotcontent.= "header('Content-type: text/css');\n";
|
||||
$robotcontent.= "// END PHP ?>\n";*/
|
||||
|
||||
$robotcontent.= GETPOST('WEBSITE_ROBOT');
|
||||
|
||||
/*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
|
||||
$robotcontent.= "// END PHP ?>"."\n";*/
|
||||
|
||||
dol_syslog("Save file robot into ".$filerobot);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filerobot, $robotcontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filerobot, null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
// Css file
|
||||
$htaccesscontent ='';
|
||||
|
||||
/*$robotcontent.= "<?php // BEGIN PHP\n";
|
||||
$robotcontent.= '$websitekey=basename(dirname(__FILE__));'."\n";
|
||||
$robotcontent.= "if (! defined('USEDOLIBARRSERVER')) { require_once './master.inc.php'; } // Not already loaded"."\n";
|
||||
$robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
|
||||
$robotcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
|
||||
$robotcontent.= "ob_start();\n";
|
||||
$robotcontent.= "header('Content-type: text/css');\n";
|
||||
$robotcontent.= "// END PHP ?>\n";*/
|
||||
|
||||
$htaccesscontent.= GETPOST('WEBSITE_HTACCESS');
|
||||
|
||||
/*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n";
|
||||
$robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n";
|
||||
$robotcontent.= "// END PHP ?>"."\n";*/
|
||||
|
||||
dol_syslog("Save file htaccess into ".$filehtaccess);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtaccess, $htaccesscontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
}
|
||||
|
||||
// Message if no error
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||
@ -549,7 +615,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
|
||||
if (! $error)
|
||||
{
|
||||
$objectpage = new WebsitePage($db);
|
||||
$result = $objectpage->createFromClone($pageid, GETPOST('pageurl','aZ09'), (GETPOST('newlang','aZ09')?GETPOST('newlang','aZ09'):''), $istranslation);
|
||||
$result = $objectpage->createFromClone($pageid, GETPOST('pageurl','aZ09'), (GETPOST('newlang','aZ09')?GETPOST('newlang','aZ09'):''), $istranslation, GETPOST('newwebsite','int'));
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
@ -745,6 +811,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
|
||||
|
||||
$form = new Form($db);
|
||||
$formadmin = new FormAdmin($db);
|
||||
$formwebsite = new FormWebsite($db);
|
||||
|
||||
$help_url='';
|
||||
|
||||
@ -958,7 +1025,9 @@ if (count($object->records) > 0)
|
||||
$formquestion = array(
|
||||
array('type' => 'text', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME") ,'value'=> 'copy_of_'.$objectpage->pageurl),
|
||||
array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0),
|
||||
array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')));
|
||||
array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')),
|
||||
array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("Website"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0))
|
||||
);
|
||||
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 250);
|
||||
|
||||
@ -1094,30 +1163,49 @@ if ($action == 'editcss')
|
||||
$csscontent = @file_get_contents($filecss);
|
||||
// Clean the php css file to remove php code and get only css part
|
||||
$csscontent = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $csscontent);
|
||||
|
||||
$csscontent.= GETPOST('WEBSITE_CSS_INLINE');
|
||||
|
||||
if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n".'body.bodywebsite { margin: 0; }';
|
||||
|
||||
|
||||
$htmlheader = @file_get_contents($filehtmlheader);
|
||||
// Clean the php htmlheader file to remove php code and get only html part
|
||||
$htmlheader = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $htmlheader);
|
||||
|
||||
if (! trim($htmlheader)) $htmlheader='<html>'."\n".'<!-- HTML header content (all pages) -->'."\n".'</html>';
|
||||
else $htmlheader='<html>'."\n".$htmlheader."\n".'</html>';
|
||||
|
||||
$robotcontent = @file_get_contents($filerobot);
|
||||
// Clean the php htmlheader file to remove php code and get only html part
|
||||
$robotcontent = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $robotcontent);
|
||||
if (! trim($robotcontent))
|
||||
{
|
||||
$robotcontent.="# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n";
|
||||
$robotcontent.="User-agent: *\n";
|
||||
$robotcontent.="Allow: /public/\n";
|
||||
$robotcontent.="Disallow: /administrator/\n";
|
||||
}
|
||||
|
||||
$htaccesscontent = @file_get_contents($filehtaccess);
|
||||
// Clean the php htmlheader file to remove php code and get only html part
|
||||
$htaccesscontent = preg_replace('/<\?php \/\/ BEGIN PHP.*END PHP \?>\n*/ims', '', $htaccesscontent);
|
||||
if (! trim($htaccesscontent))
|
||||
{
|
||||
$htaccesscontent.="# Order allow,deny\n";
|
||||
$htaccesscontent.="# Deny from all\n";
|
||||
}
|
||||
//else $htaccesscontent='<html>'."\n".$htaccesscontent."\n".'</html>';*/
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
print '<!-- Edit CSS -->'."\n";
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Website
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
print $langs->trans('WebSite');
|
||||
print '</td><td>';
|
||||
print $website;
|
||||
print '</td></tr>';
|
||||
|
||||
// CSS file
|
||||
print '<tr><td class="tdtop">';
|
||||
print $langs->trans('WEBSITE_CSS_INLINE');
|
||||
print '</td><td>';
|
||||
@ -1125,11 +1213,9 @@ if ($action == 'editcss')
|
||||
$doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
print $doleditor->Create(1, '', true, 'CSS', 'css');
|
||||
|
||||
/*print '<textarea class="flat centpercent" rows="20" name="WEBSITE_CSS_INLINE">';
|
||||
print $csscontent;
|
||||
print '</textarea>';*/
|
||||
print '</td></tr>';
|
||||
|
||||
// Common HTML header
|
||||
print '<tr><td class="tdtop">';
|
||||
print $langs->trans('WEBSITE_HTML_HEADER');
|
||||
print '</td><td>';
|
||||
@ -1137,9 +1223,26 @@ if ($action == 'editcss')
|
||||
$doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheader, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
print $doleditor->Create(1, '', true, 'HTML Header', 'html');
|
||||
|
||||
/*print '<textarea class="flat centpercent" rows="20" name="WEBSITE_HTML_HEADER">';
|
||||
print $htmlheader;
|
||||
print '</textarea>';*/
|
||||
print '</td></tr>';
|
||||
|
||||
// Robot file
|
||||
print '<tr><td class="tdtop">';
|
||||
print $langs->trans('WEBSITE_ROBOT');
|
||||
print '</td><td>';
|
||||
|
||||
$doleditor=new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
print $doleditor->Create(1, '', true, 'Robot file', 'txt');
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// .htaccess
|
||||
print '<tr><td class="tdtop">';
|
||||
print $langs->trans('WEBSITE_HTACCESS');
|
||||
print '</td><td>';
|
||||
|
||||
$doleditor=new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
|
||||
print $doleditor->Create(1, '', true, $langs->trans("File").' .htaccess', 'txt');
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
@ -1238,7 +1341,7 @@ if ($action == 'editsource')
|
||||
* Editing global variables not related to a specific theme
|
||||
*/
|
||||
|
||||
$csscontent = @file_get_contents($filecss);
|
||||
//$csscontent = @file_get_contents($filecss);
|
||||
|
||||
$contentforedit = '';
|
||||
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
|
||||
@ -1257,7 +1360,7 @@ if ($action == 'editcontent')
|
||||
* Editing global variables not related to a specific theme
|
||||
*/
|
||||
|
||||
$csscontent = @file_get_contents($filecss);
|
||||
//$csscontent = @file_get_contents($filecss);
|
||||
|
||||
$contentforedit = '';
|
||||
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
|
||||
|
||||
@ -122,10 +122,75 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* testDolGetFirstLineOfText
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDolGetFirstLineOfText()
|
||||
{
|
||||
// Nb of line is same than entry text
|
||||
|
||||
$input="aaaa";
|
||||
$result=dolGetFirstLineOfText($input);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa", $result);
|
||||
|
||||
$input="aaaa\nbbbbbbbbbbbb\n";
|
||||
$result=dolGetFirstLineOfText($input, 2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa\nbbbbbbbbbbbb", $result);
|
||||
|
||||
$input="aaaa<br>bbbbbbbbbbbb<br>";
|
||||
$result=dolGetFirstLineOfText($input, 2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result);
|
||||
|
||||
// Nb of line is lower
|
||||
|
||||
$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
|
||||
$result=dolGetFirstLineOfText($input);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa...", $result);
|
||||
|
||||
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
|
||||
$result=dolGetFirstLineOfText($input);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa...", $result);
|
||||
|
||||
$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
|
||||
$result=dolGetFirstLineOfText($input, 2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result);
|
||||
|
||||
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
|
||||
$result=dolGetFirstLineOfText($input, 2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result);
|
||||
|
||||
// Nb of line is higher
|
||||
|
||||
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc";
|
||||
$result=dolGetFirstLineOfText($input, 100);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a');
|
||||
|
||||
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
|
||||
$result=dolGetFirstLineOfText($input, 100);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b');
|
||||
|
||||
$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
|
||||
$result=dolGetFirstLineOfText($input, 100);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testDolBuildPath
|
||||
*
|
||||
* @return boolean
|
||||
* @return void
|
||||
*/
|
||||
public function testDolBuildPath()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user