Debug module parnership. Add the type of partnership.
This commit is contained in:
parent
e8a2fc33c3
commit
2234522519
@ -2107,7 +2107,7 @@ if ($id) {
|
||||
if ($iserasable) {
|
||||
print '<td class="center">';
|
||||
if ($user->admin) {
|
||||
print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
|
||||
print '<a class="reposition" href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
|
||||
}
|
||||
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
|
||||
print '</td>';
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/lib/memory.lib.php
|
||||
* \brief Set of function for memory/cache management
|
||||
* \file htdocs/core/lib/modulebuilder.lib.php
|
||||
* \brief Set of function for modulebuilder management
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -82,6 +82,8 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private,
|
||||
|
||||
ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code);
|
||||
|
||||
ALTER TABLE llx_partnership ADD COLUMN fk_type integer DEFAULT 0 NOT NULL;
|
||||
|
||||
ALTER TABLE llx_c_holiday_types CHANGE COLUMN newByMonth newbymonth double(8,5) DEFAULT 0 NOT NULL;
|
||||
|
||||
ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0;
|
||||
|
||||
@ -20,6 +20,7 @@ CREATE TABLE llx_partnership(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
ref varchar(128) DEFAULT '(PROV)' NOT NULL,
|
||||
status smallint NOT NULL DEFAULT '0',
|
||||
fk_type integer DEFAULT 0 NOT NULL,
|
||||
fk_soc integer,
|
||||
fk_member integer,
|
||||
date_partnership_start date NOT NULL,
|
||||
|
||||
@ -262,6 +262,7 @@ if ($dirins && $action == 'initmodule' && $modulename) {
|
||||
|
||||
// Delete some files related to Object (because the previous dolCopyDir has copied everything)
|
||||
dol_delete_file($destdir.'/myobject_card.php');
|
||||
dol_delete_file($destdir.'/myobject_contact.php');
|
||||
dol_delete_file($destdir.'/myobject_note.php');
|
||||
dol_delete_file($destdir.'/myobject_document.php');
|
||||
dol_delete_file($destdir.'/myobject_agenda.php');
|
||||
@ -337,6 +338,14 @@ if ($dirins && $action == 'initmodule' && $modulename) {
|
||||
setEventMessages('ModuleInitialized', null);
|
||||
$module = $modulename;
|
||||
$modulename = '';
|
||||
|
||||
clearstatcache(true);
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_reset(); // remove the include cache hell !
|
||||
}
|
||||
|
||||
header("Location: ".$_SERVER["PHP_SELF"].'?module='.$modulename);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -953,7 +962,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
|
||||
if ($notnull) {
|
||||
$string .= ", 'notnull'=>".$notnull;
|
||||
}
|
||||
if ($fieldname == 'ref') {
|
||||
if ($fieldname == 'ref' || $fieldname == 'code') {
|
||||
$string .= ", 'showoncombobox'=>1";
|
||||
}
|
||||
$string .= ", 'position'=>".$position;
|
||||
@ -1417,6 +1426,14 @@ if ($dirins && $action == 'confirm_deletemodule') {
|
||||
|
||||
if ($result > 0) {
|
||||
setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null);
|
||||
|
||||
clearstatcache(true);
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_reset(); // remove the include cache hell !
|
||||
}
|
||||
|
||||
header("Location: ".$_SERVER["PHP_SELF"].'?module=deletemodule');
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings');
|
||||
}
|
||||
@ -1757,6 +1774,10 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') {
|
||||
$loadclasserrormessage = $e->getMessage()."<br>\n";
|
||||
$loadclasserrormessage .= 'File: '.$e->getFile()."<br>\n";
|
||||
$loadclasserrormessage .= 'Line: '.$e->getLine()."<br>\n";
|
||||
} catch (Exception $e) {
|
||||
$loadclasserrormessage = $e->getMessage()."<br>\n";
|
||||
$loadclasserrormessage .= 'File: '.$e->getFile()."<br>\n";
|
||||
$loadclasserrormessage .= 'Line: '.$e->getLine()."<br>\n";
|
||||
}
|
||||
|
||||
if (class_exists($class)) {
|
||||
@ -1771,6 +1792,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') {
|
||||
$error++;
|
||||
}
|
||||
$langs->load("errors");
|
||||
print '<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
|
||||
print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'<br>';
|
||||
print $loadclasserrormessage;
|
||||
}
|
||||
@ -2423,8 +2445,8 @@ if ($module == 'initmodule') {
|
||||
print '<span class="opacitymedium">'.$langs->trans("EnterNameOfObjectDesc").'</span><br><br>';
|
||||
|
||||
print '<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOST('objectname', 'alpha') ? GETPOST('objectname', 'alpha') : $modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'"><br>';
|
||||
print '<input type="checkbox" name="includerefgeneration" value="includerefgeneration"> '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'<br>';
|
||||
print '<input type="checkbox" name="includedocgeneration" value="includedocgeneration"> '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'<br>';
|
||||
print '<input type="checkbox" name="includerefgeneration" id="includerefgeneration" value="includerefgeneration"> <label for="includerefgeneration">'.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'</label><br>';
|
||||
print '<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'</label><br>';
|
||||
print '<input type="submit" class="button smallpaddingimp" name="create" value="'.dol_escape_htmltag($langs->trans("Generate")).'"'.($dirins ? '' : ' disabled="disabled"').'>';
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
@ -2633,6 +2655,7 @@ if ($module == 'initmodule') {
|
||||
|
||||
print '<br><br><br>';
|
||||
|
||||
clearstatcache(true);
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell !
|
||||
}
|
||||
|
||||
@ -767,7 +767,7 @@ class MyObject extends CommonObject
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
if ($url && $add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
}
|
||||
@ -784,13 +784,13 @@ class MyObject extends CommonObject
|
||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
}
|
||||
|
||||
if ($option == 'nolink') {
|
||||
if ($option == 'nolink' || empty($url)) {
|
||||
$linkstart = '<span';
|
||||
} else {
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
}
|
||||
$linkstart .= $linkclose.'>';
|
||||
if ($option == 'nolink') {
|
||||
if ($option == 'nolink' || empty($url)) {
|
||||
$linkend = '</span>';
|
||||
} else {
|
||||
$linkend = '</a>';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2021 NextGestion <contact@nextgestion.com>
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2021 NextGestion <contact@nextgestion.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -27,6 +27,7 @@ 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 for Partnership
|
||||
*/
|
||||
@ -105,7 +106,7 @@ class Partnership extends CommonObject
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
|
||||
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
|
||||
//'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnershiptype.class.php', 'label' => 'Type', 'default' => 1, 'enabled' => 1, 'visible' => 1, 'position' => 20),
|
||||
'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php', 'label' => 'Type', 'enabled' => 1, 'visible' => 1, 'position' => 20),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
|
||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
|
||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
|
||||
@ -366,14 +367,15 @@ class Partnership extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = 'SELECT p.rowid, p.ref, p.fk_soc, p.fk_member, p.status';
|
||||
$sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
|
||||
$sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
|
||||
$sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
|
||||
$sql .= ', p.note_private, p.note_public';
|
||||
$sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
|
||||
$sql .= ', p.import_key, p.model_pdf';
|
||||
|
||||
$sql .= ', pt.code as type_code, pt.label as type_label';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
|
||||
|
||||
if ($id) {
|
||||
$sql .= " WHERE p.rowid=".((int) $id);
|
||||
@ -400,8 +402,12 @@ class Partnership extends CommonObject
|
||||
if ($obj) {
|
||||
$this->id = $obj->rowid;
|
||||
$this->entity = $obj->entity;
|
||||
$this->rowid = $obj->rowid;
|
||||
$this->ref = $obj->ref;
|
||||
|
||||
$this->fk_type = $obj->fk_type;
|
||||
$this->type_code = $obj->type_code;
|
||||
$this->type_label = $obj->type_label;
|
||||
|
||||
$this->fk_soc = $obj->fk_soc;
|
||||
$this->fk_member = $obj->fk_member;
|
||||
$this->status = $obj->status;
|
||||
|
||||
562
htdocs/partnership/class/partnership_type.class.php
Normal file
562
htdocs/partnership/class/partnership_type.class.php
Normal file
@ -0,0 +1,562 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018-2019 Thibault Foucart <support@ptibogxiv.net>
|
||||
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/partnership/class/partnership_type.class.php
|
||||
* \ingroup partnership
|
||||
* \brief File of class to manage partnership types
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage partnership type
|
||||
*/
|
||||
class PartnershipType extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'c_partnership_type';
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
public $element = 'partnership_type';
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'generic';
|
||||
|
||||
/**
|
||||
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
* @var int
|
||||
*/
|
||||
public $ismultientitymanaged = 1;
|
||||
|
||||
/**
|
||||
* @var string Partnership code
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string Partnership type label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
|
||||
public $fields=array(
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1),
|
||||
'code' =>array('type'=>'varchar(32)', 'label'=>'Code', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20, 'showoncombobox'=>1),
|
||||
'label' =>array('type'=>'varchar(64)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25, 'showoncombobox'=>1),
|
||||
'active' =>array('type'=>'integer', 'label'=>'Active', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30),
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDb $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB $db)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
|
||||
$this->fields['rowid']['visible'] = 0;
|
||||
}
|
||||
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
|
||||
$this->fields['entity']['enabled'] = 0;
|
||||
}
|
||||
|
||||
// Example to show how to set values of fields definition dynamically
|
||||
/*if ($user->rights->mymodule->myobject->read) {
|
||||
$this->fields['myfield']['visible'] = 1;
|
||||
$this->fields['myfield']['noteditable'] = 0;
|
||||
}*/
|
||||
|
||||
// Unset fields that are disabled
|
||||
foreach ($this->fields as $key => $val) {
|
||||
if (isset($val['enabled']) && empty($val['enabled'])) {
|
||||
unset($this->fields[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Translate some data of arrayofkeyval
|
||||
if (is_object($langs)) {
|
||||
foreach ($this->fields as $key => $val) {
|
||||
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
|
||||
foreach ($val['arrayofkeyval'] as $key2 => $val2) {
|
||||
$this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$resultcreate = $this->createCommon($user, $notrigger);
|
||||
|
||||
//$resultvalidate = $this->validate($user, $notrigger);
|
||||
|
||||
return $resultcreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$result = $this->fetchCommon($id, $ref);
|
||||
if ($result > 0 && !empty($this->table_element_line)) {
|
||||
$this->fetchLines();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load list of objects in memory from the database.
|
||||
*
|
||||
* @param string $sortorder Sort Order
|
||||
* @param string $sortfield Sort field
|
||||
* @param int $limit limit
|
||||
* @param int $offset Offset
|
||||
* @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
|
||||
* @param string $filtermode Filter mode (AND or OR)
|
||||
* @return array|int int <0 if KO, array of pages if OK
|
||||
*/
|
||||
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$records = array();
|
||||
|
||||
$sql = "SELECT ";
|
||||
$sql .= $this->getFieldList('t');
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
|
||||
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
|
||||
$sql .= " WHERE t.entity IN (".getEntity($this->table_element).")";
|
||||
} else {
|
||||
$sql .= " WHERE 1 = 1";
|
||||
}
|
||||
// Manage filter
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key == 't.rowid') {
|
||||
$sqlwhere[] = $key." = ".((int) $value);
|
||||
} elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
|
||||
$sqlwhere[] = $key." = '".$this->db->idate($value)."'";
|
||||
} elseif ($key == 'customsql') {
|
||||
$sqlwhere[] = $value;
|
||||
} elseif (strpos($value, '%') === false) {
|
||||
$sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
|
||||
} else {
|
||||
$sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
|
||||
}
|
||||
|
||||
if (!empty($sortfield)) {
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($limit)) {
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < ($limit ? min($limit, $num) : $num)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$record = new self($this->db);
|
||||
$record->setVarsFromFetchObj($obj);
|
||||
|
||||
$records[$record->id] = $record;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return $records;
|
||||
} else {
|
||||
$this->errors[] = 'Error '.$this->db->lasterror();
|
||||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update(User $user, $notrigger = false)
|
||||
{
|
||||
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, $notrigger);
|
||||
//return $this->deleteCommon($user, $notrigger, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set draft status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function setDraft($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status <= self::STATUS_DRAFT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
|
||||
{
|
||||
$this->error='Permission denied';
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIPTYPE_UNVALIDATE');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cancel status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, 0=Nothing done, >0 if OK
|
||||
*/
|
||||
public function cancel($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_VALIDATED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
|
||||
{
|
||||
$this->error='Permission denied';
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIPTYPE_CANCEL');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set back to validated status
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
|
||||
* @return int <0 if KO, 0=Nothing done, >0 if OK
|
||||
*/
|
||||
public function reopen($user, $notrigger = 0)
|
||||
{
|
||||
// Protection
|
||||
if ($this->status != self::STATUS_CANCELED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
|
||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
|
||||
{
|
||||
$this->error='Permission denied';
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'PARTNERSHIPTYPE_REOPEN');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ('nolink', ...)
|
||||
* @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
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
|
||||
{
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
}
|
||||
|
||||
$result = '';
|
||||
|
||||
$label = img_picto('', $this->picto).' <u>'.$langs->trans("PartnershipType").'</u>';
|
||||
if (isset($this->status)) {
|
||||
$label .= ' '.$this->getLibStatut(5);
|
||||
}
|
||||
$label .= '<br>';
|
||||
$label .= '<b>'.$langs->trans('Code').':</b> '.$this->code;
|
||||
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
|
||||
|
||||
//$url = dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$this->id;
|
||||
$url = '';
|
||||
|
||||
if ($option != 'nolink') {
|
||||
// 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 ($url && $add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
}
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowMyObject");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
|
||||
} else {
|
||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
}
|
||||
|
||||
if ($option == 'nolink' || empty($url)) {
|
||||
$linkstart = '<span';
|
||||
} else {
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
}
|
||||
$linkstart .= $linkclose.'>';
|
||||
if ($option == 'nolink' || empty($url)) {
|
||||
$linkend = '</span>';
|
||||
} else {
|
||||
$linkend = '</a>';
|
||||
}
|
||||
|
||||
$result .= $linkstart;
|
||||
|
||||
if (empty($this->showphoto_on_popup)) {
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
} else {
|
||||
if ($withpicto) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
list($class, $module) = explode('@', $this->picto);
|
||||
$upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
|
||||
$filearray = dol_dir_list($upload_dir, "files");
|
||||
$filename = $filearray[0]['name'];
|
||||
if (!empty($filename)) {
|
||||
$pospoint = strpos($filearray[0]['name'], '.');
|
||||
|
||||
$pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
|
||||
if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
|
||||
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
|
||||
} else {
|
||||
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
|
||||
}
|
||||
|
||||
$result .= '</div>';
|
||||
} else {
|
||||
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($withpicto != 2) {
|
||||
$result .= $this->ref;
|
||||
}
|
||||
|
||||
$result .= $linkend;
|
||||
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
|
||||
|
||||
global $action, $hookmanager;
|
||||
$hookmanager->initHooks(array('myobjectdao'));
|
||||
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
|
||||
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook > 0) {
|
||||
$result = $hookmanager->resPrint;
|
||||
} else {
|
||||
$result .= $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the label of the status
|
||||
*
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function getLabelStatus($mode = 0)
|
||||
{
|
||||
return $this->LibStatut($this->status, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the label of the status
|
||||
*
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function getLibStatut($mode = 0)
|
||||
{
|
||||
return $this->LibStatut($this->status, $mode);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* 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, 6=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("mymodule@mymodule");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
|
||||
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
|
||||
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
|
||||
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
|
||||
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
|
||||
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
|
||||
}
|
||||
|
||||
$statusType = 'status'.$status;
|
||||
//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
|
||||
if ($status == self::STATUS_CANCELED) {
|
||||
$statusType = 'status6';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the info information in the object
|
||||
*
|
||||
* @param int $id Id of object
|
||||
* @return void
|
||||
*/
|
||||
public 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 = ".((int) $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
|
||||
* Id must be 0 if object instance is a specimen
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
// Set here init that are not commonf fields
|
||||
// $this->property1 = ...
|
||||
// $this->property2 = ...
|
||||
|
||||
$this->initAsSpecimenCommon();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user