function doActions($parameters, &$object, &$action, $hookmanager)
 {
     if (GETPOST('addcontratline')) {
         $fk_line_contrat_origin = GETPOST('fk_line_contrat_origin', 'int');
         if ($fk_line_contrat_origin > 0) {
             global $db;
             dol_include_once('/contrat/class/contrat.class.php');
             $lineContrat = new ContratLigne($db);
             $res = $lineContrat->fetch($fk_line_contrat_origin);
             if ($res > 0) {
                 $linePropal = new PropaleLigne($db);
                 $array_options = array();
                 require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
                 $extrafields = new ExtraFields($db);
                 $TExtra = $extrafields->fetch_name_optionals_label($linePropal->table_element);
                 // Récupération des extrafields de la ligne contrat vers la ligne propal
                 $lineContrat->fetch_optionals();
                 foreach ($lineContrat->array_options as $key => $val) {
                     $subkey = substr($key, 8);
                     if (isset($TExtra[$subkey])) {
                         $array_options[$key] = $val;
                     }
                 }
                 if (isset($TExtra['fk_contratdet_origin'])) {
                     $array_options['options_fk_contratdet_origin'] = $lineContrat->id;
                 }
                 $object->addline($lineContrat->description, $lineContrat->subprice, $lineContrat->qty, $lineContrat->tva_tx, $lineContrat->localtax1_tx, $lineContrat->localtax2_tx, $lineContrat->fk_product, $lineContrat->remise_percent, 'HT', 0.0, $lineContrat->info_bits, 1, -1, 0, 0, 0, $lineContrat->pa_ht, '', $lineContrat->date_ouverture_prevue, $lineContrat->date_fin_validite, $array_options, $lineContrat->fk_unit);
             }
         }
     }
 }
Ejemplo n.º 2
0
	/**
	 *    Constructor de la classe
	 *
	 *    @param   DoliDb  $db     Database handler
	 */

	function __construct($db) {
		$this->db = $db;

		parent::__construct($db);

		$fk_extrafields = new ExtraFields($db);
		$this->fk_extrafields = $fk_extrafields->load("extrafields:" . get_class($this), true); // load and cache

		$this->couchAdmin = new couchAdmin($this->couchdb);

		return 0;
	}
Ejemplo n.º 3
0
 function __construct($db)
 {
     global $couch;
     parent::__construct($db);
     try {
         $this->global = $couch->getDoc("const");
     } catch (Exception $e) {
         dol_print_error('', "Error : no const document in database" . $e->getMessage());
     }
     $fk_extrafields = new ExtraFields($db);
     $this->fk_extrafields = $fk_extrafields->load("extrafields:DolibarrModules", true);
     // load and cache
 }
Ejemplo n.º 4
0
 /**
  * 	Constructor
  *
  * 	@param 		DoliDB		$db		Database handler
  */
 function __construct($db)
 {
     parent::__construct($db);
     try {
         $this->couchdb->useDatabase('adherent');
         $fk_extrafields = new ExtraFields($db);
         $fk_extrafields->useDatabase('adherent');
         $this->fk_extrafields = $fk_extrafields->load("extrafields:" . get_class($this), true);
         // load and cache
     } catch (Exception $e) {
         dol_print_error('', $e->getMessage());
         exit;
     }
     return 1;
 }
Ejemplo n.º 5
0
	/**
	 *    Constructor
	 *
	 *    @param	Client		$db		Database handler
	 */

	public function __construct($db) {
		parent::__construct($db);

		try {
			$fk_extrafields = new ExtraFields($db);
			$this->fk_extrafields = $fk_extrafields->load("extrafields:" . get_class($this), true); // load and cache
			$this->fk_country = $this->couchdb->getDoc("dict:fk_country"); //load country table
		} catch (Exception $e) {
			$error = "Something weird happened: " . $e->getMessage() . " (errcode=" . $e->getCode() . ")\n";
			print $error;
			exit;
		}

		return 1;
	}
Ejemplo n.º 6
0
 public function configure()
 {
     $this->widgetSchema['extra_fields'] = new sfWidgetFormChoice(array('choices' => ExtraFields::getFieldsByType('tickets'), 'expanded' => true, 'multiple' => true));
     $this->widgetSchema['active'] = new sfWidgetFormInputCheckbox(array(), array('value' => 1));
     $this->setDefault('active', 1);
     $this->widgetSchema['name']->setAttribute('class', 'required');
     $this->widgetSchema['sort_order']->setAttribute('size', '3');
     $this->widgetSchema->setLabels(array('sort_order' => 'Sort Order', 'background_color' => 'Background', 'default_value' => 'Default?', 'active' => 'Active?', 'extra_fields' => 'Extra Fields'));
 }
Ejemplo n.º 7
0
 public static function getTypeNameByKey($k)
 {
     $t = ExtraFields::getTypesChoices();
     if (isset($t[$k])) {
         return $t[$k];
     } else {
         return '';
     }
 }
Ejemplo n.º 8
0
 public function configure()
 {
     $this->widgetSchema['active'] = new sfWidgetFormInputCheckbox(array(), array('value' => 1));
     $this->setDefault('active', 1);
     $this->widgetSchema['display_in_list'] = new sfWidgetFormInputCheckbox(array(), array('value' => 1));
     $this->setDefault('display_in_list', 0);
     $this->widgetSchema['type'] = new sfWidgetFormChoice(array('choices' => ExtraFields::getTypesChoices()));
     $this->widgetSchema['bind_type'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['name']->setAttribute('class', 'required');
     $this->widgetSchema['sort_order']->setAttribute('size', '3');
     $this->widgetSchema->setLabels(array('display_in_list' => 'Display in Listing?', 'sort_order' => 'Sort Order', 'active' => 'Active?'));
 }
Ejemplo n.º 9
0
/**
 * Get list of products for a category
 *
 * @param	array		$authentication		Array of authentication information
 * @param	array		$id					Category id
 * @param	$lang		$lang				Force lang
 * @return	array							Array result
 */
function getProductsForCategory($authentication, $id, $lang = '')
{
    global $db, $conf, $langs;
    $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
    $langs->setDefaultLang($langcode);
    dol_syslog("Function: getProductsForCategory login="******" id=" . $id);
    if ($authentication['entity']) {
        $conf->entity = $authentication['entity'];
    }
    $objectresp = array();
    $errorcode = '';
    $errorlabel = '';
    $error = 0;
    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
    if (!$error && !$id) {
        $error++;
        $errorcode = 'BAD_PARAMETERS';
        $errorlabel = "Parameter id must be provided.";
    }
    if (!$error) {
        $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
        $langs->setDefaultLang($langcode);
        $fuser->getrights();
        if ($fuser->rights->produit->lire) {
            $categorie = new Categorie($db);
            $result = $categorie->fetch($id);
            if ($result > 0) {
                $table = "product";
                $field = "product";
                $sql = "SELECT fk_" . $field . " FROM " . MAIN_DB_PREFIX . "categorie_" . $table;
                $sql .= " WHERE fk_categorie = " . $id;
                $sql .= " ORDER BY fk_" . $field . " ASC";
                dol_syslog("getProductsForCategory get id of product into category", LOG_DEBUG);
                $res = $db->query($sql);
                if ($res) {
                    while ($rec = $db->fetch_array($res)) {
                        $obj = new Product($db);
                        $obj->fetch($rec['fk_' . $field]);
                        $iProduct = 0;
                        if ($obj->status > 0) {
                            $dir = !empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output;
                            $pdir = get_exdir($obj->id, 2) . $obj->id . "/photos/";
                            $dir = $dir . '/' . $pdir;
                            $products[] = array('id' => $obj->id, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, 'label' => !empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label, 'description' => !empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description, 'date_creation' => dol_print_date($obj->date_creation, 'dayhourrfc'), 'date_modification' => dol_print_date($obj->date_modification, 'dayhourrfc'), 'note' => !empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note, 'status_tosell' => $obj->status, 'status_tobuy' => $obj->status_buy, 'type' => $obj->type, 'barcode' => $obj->barcode, 'barcode_type' => $obj->barcode_type, 'country_id' => $obj->country_id > 0 ? $obj->country_id : '', 'country_code' => $obj->country_code, 'custom_code' => $obj->customcode, 'price_net' => $obj->price, 'price' => $obj->price_ttc, 'vat_rate' => $obj->tva_tx, 'price_base_type' => $obj->price_base_type, 'stock_real' => $obj->stock_reel, 'stock_alert' => $obj->seuil_stock_alerte, 'pmp' => $obj->pmp, 'import_key' => $obj->import_key, 'dir' => $pdir, 'images' => $obj->liste_photos($dir, $nbmax = 10));
                            //Retreive all extrafield for thirdsparty
                            // fetch optionals attributes and labels
                            $extrafields = new ExtraFields($db);
                            $extralabels = $extrafields->fetch_name_optionals_label('product', true);
                            //Get extrafield values
                            $product->fetch_optionals($obj->id, $extralabels);
                            foreach ($extrafields->attribute_label as $key => $label) {
                                $products[$iProduct] = array_merge($products[$iProduct], array('options_' . $key => $product->array_options['options_' . $key]));
                            }
                            $iProduct++;
                        }
                    }
                    // Retour
                    $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'products' => $products);
                } else {
                    $errorcode = 'NORECORDS_FOR_ASSOCIATION';
                    $errorlabel = 'No products associated' . $sql;
                    $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
                    dol_syslog("getProductsForCategory:: " . $c->error, LOG_DEBUG);
                }
            } else {
                $error++;
                $errorcode = 'NOT_FOUND';
                $errorlabel = 'Object not found for id=' . $id;
            }
        } else {
            $error++;
            $errorcode = 'PERMISSION_DENIED';
            $errorlabel = 'User does not have permission for this request';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
Ejemplo n.º 10
0
$langs->load("companies");
$langs->load("commercial");
$langs->load("bills");
$langs->load("banks");
$langs->load("users");
if ($conf->notification->enabled) $langs->load("mails");

$mesg=''; $error=0; $errors=array();

$action		= (GETPOST('action') ? GETPOST('action') : 'view');
$confirm	= GETPOST('confirm');
$socid		= GETPOST('socid');
if ($user->societe_id) $socid=$user->societe_id;

$object = new Societe($db);
$extrafields = new ExtraFields($db);

// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($socid);
$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
if (! empty($canvas))
{
    require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
    $objcanvas = new Canvas($db, $action);
    $objcanvas->getCanvas('thirdparty', 'card', $canvas);
}

// Security check
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas);

// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
Ejemplo n.º 11
0
 $qty = GETPOST('qty');
 // Define info_bits
 $info_bits = 0;
 if (preg_match('/\\*/', $vat_rate)) {
     $info_bits |= 0x1;
 }
 // Define vat_rate
 $vat_rate = str_replace('*', '', $vat_rate);
 $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty);
 $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty);
 // Add buying price
 $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
 $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : '');
 // If buying_price is '0', we muste keep this value
 // Extrafields
 $extrafieldsline = new ExtraFields($db);
 $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
 $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
 // Unset extrafield
 if (is_array($extralabelsline)) {
     // Get extra fields
     foreach ($extralabelsline as $key => $value) {
         unset($_POST["options_" . $key]);
     }
 }
 // Define special_code for special lines
 $special_code = GETPOST('special_code');
 if (!GETPOST('qty')) {
     $special_code = 3;
 }
 $line = new FactureLigne($db);
Ejemplo n.º 12
0
    {
        print '<tr><td class="nowrap">';
        print $langs->trans("Script").'</td><td align="right">'.$file.'</td></tr>';

        $name = substr($file, 0, dol_strlen($file) - 4);

        // Run sql script
        $ok=run_sql($dir.$file, 0, '', 1);
    }
}


// sync_extrafields: Search list of fields declared and list of fields created into databases and create fields missing
if ($ok)
{
	$extrafields=new ExtraFields($db);
	$listofmodulesextra=array('societe'=>'societe','adherent'=>'adherent','product'=>'product',
				'socpeople'=>'socpeople', 'commande'=>'commande', 'facture'=>'facture',
				'commande_fournisseur'=>'commande_fournisseur', 'actioncomm'=>'actioncomm',
				'adherent_type'=>'adherent_type','user'=>'user','projet'=>'projet', 'projet_task'=>'projet_task');
	foreach($listofmodulesextra as $tablename => $elementtype)
	{
	    // Get list of fields
	    $tableextra=MAIN_DB_PREFIX.$tablename.'_extrafields';

	    // Define $arrayoffieldsdesc
	    $arrayoffieldsdesc=$extrafields->fetch_name_optionals_label($elementtype);

	    // Define $arrayoffieldsfound
	    $arrayoffieldsfound=array();
	    $resql=$db->DDLDescTable($tableextra);
Ejemplo n.º 13
0
 /**
  * Load object in memory from the database
  *
  * @param string $sortorder order
  * @param string $sortfield field
  * @param int $limit page
  * @param int $offset Offset results
  * @param array $filter output
  *
  * @return int <0 if KO, >0 if OK
  */
 function fetch_all($sortorder, $sortfield, $limit, $offset, $filter = array())
 {
     global $langs;
     $sql = "SELECT";
     $sql .= " t.rowid,";
     $sql .= " t.ref,";
     $sql .= " t.ref_ext,";
     $sql .= " t.ref_int,";
     $sql .= " t.fk_c_status,";
     $sql .= " t.fk_c_type,";
     $sql .= " t.fk_soc,";
     $sql .= " t.date_closure,";
     $sql .= " t.amount_prosp,";
     $sql .= " t.fk_user_resp,";
     $sql .= " t.description,";
     $sql .= " t.note_private,";
     $sql .= " t.note_public,";
     $sql .= " t.fk_user_author,";
     $sql .= " t.datec,";
     $sql .= " t.fk_user_mod,";
     $sql .= " t.tms";
     $sql .= " FROM " . MAIN_DB_PREFIX . "lead as t";
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as so ON so.rowid=t.fk_soc";
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as usr ON usr.rowid=t.fk_user_resp";
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_lead_status as leadsta ON leadsta.rowid=t.fk_c_status";
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_lead_type as leadtype ON leadtype.rowid=t.fk_c_type";
     $sql .= " WHERE t.entity IN (" . getEntity('lead') . ")";
     if (is_array($filter)) {
         foreach ($filter as $key => $value) {
             if ($key == 't.fk_c_status' || $key == 't.rowid' || $key == 'so.rowid' || $key == 't.fk_c_type' || $key == 't.fk_user_resp') {
                 $sql .= ' AND ' . $key . ' = ' . $value;
             } elseif ($key == 't.date_closure<') {
                 // To allow $filter['YEAR(s.dated)']=>$year
                 $sql .= " AND t.date_closure<='" . $this->db->idate($value) . "'";
             } elseif (strpos($key, 'date')) {
                 // To allow $filter['YEAR(s.dated)']=>$year
                 $sql .= ' AND ' . $key . ' = \'' . $value . '\'';
             } elseif ($key == 't.fk_c_status !IN') {
                 $sql .= ' AND t.fk_c_status NOT IN (' . $value . ')';
             } elseif ($key == 't.rowid !IN') {
                 $sql .= ' AND t.rowid NOT IN (' . $value . ')';
             } else {
                 $sql .= ' AND ' . $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
             }
         }
     }
     if (!empty($sortfield)) {
         $sql .= " ORDER BY " . $sortfield . ' ' . $sortorder;
     }
     if (!empty($limit)) {
         $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
     }
     dol_syslog(get_class($this) . "::fetch_all sql=" . $sql, LOG_DEBUG);
     $resql = $this->db->query($sql);
     if ($resql) {
         $this->lines = array();
         $num = $this->db->num_rows($resql);
         while ($obj = $this->db->fetch_object($resql)) {
             $line = new Lead($this->db, 1);
             $line->id = $obj->rowid;
             $line->ref = $obj->ref;
             $line->ref_ext = $obj->ref_ext;
             $line->ref_int = $obj->ref_int;
             $line->fk_c_status = $obj->fk_c_status;
             $line->fk_c_type = $obj->fk_c_type;
             $line->fk_soc = $obj->fk_soc;
             $line->date_closure = $this->db->jdate($obj->date_closure);
             $line->amount_prosp = $obj->amount_prosp;
             $line->fk_user_resp = $obj->fk_user_resp;
             $line->description = $obj->description;
             $line->note_private = $obj->note_private;
             $line->note_public = $obj->note_public;
             $line->fk_user_author = $obj->fk_user_author;
             $line->datec = $this->db->jdate($obj->datec);
             $line->fk_user_mod = $obj->fk_user_mod;
             $line->tms = $this->db->jdate($obj->tms);
             $line->status_label = $this->status[$line->fk_c_status];
             $line->type_label = $this->type[$line->fk_c_type];
             $extrafields = new ExtraFields($this->db);
             $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true);
             if (count($extralabels) > 0) {
                 $line->fetch_optionals($line->id, $extralabels);
             }
             $this->lines[] = $line;
         }
         $this->db->free($resql);
         return $num;
     } else {
         $this->error = "Error " . $this->db->lasterror();
         dol_syslog(get_class($this) . "::fetch_all " . $this->error, LOG_ERR);
         return -1;
     }
 }
Ejemplo n.º 14
0
 * 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/categories/admin/categorie_extrafields.php
 *		\ingroup    societe
 *		\brief      Page to setup extra fields of category
 */
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/categories.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$langs->load("categories");
$langs->load("admin");
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) {
    $type2label[$key] = $langs->trans($val);
}
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'categories';
//Must be the $element of the class that manage extrafield
if (!$user->admin) {
    accessforbidden();
}
/*
Ejemplo n.º 15
0
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "DESC";
}
if (!$sortfield) {
    $sortfield = "d.lastname";
}
$label = GETPOST("libelle", "alpha");
$cotisation = GETPOST("cotisation", "int");
$vote = GETPOST("vote", "int");
$comment = GETPOST("comment");
$mail_valid = GETPOST("mail_valid");
// Security check
$result = restrictedArea($user, 'adherent', $rowid, 'adherent_type');
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('adherent_type');
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
    $search_lastname = "";
    $search_login = "";
    $search_email = "";
    $type = "";
    $sall = "";
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('membertypecard', 'globalcard'));
/*
 *	Actions
 */
if ($action == 'add' && $user->rights->adherent->configurer) {
// Change this following line to use the correct relative path (../, ../../, etc)
require '../config.php';
// Change this following line to use the correct relative path from htdocs (do not remove DOL_DOCUMENT_ROOT)
dol_include_once('/core/lib/admin.lib.php');
dol_include_once('/core/class/extrafields.class.php');
// Access control
if (!$user->admin) {
    accessforbidden();
}
// Parameters
$action = GETPOST('action', 'alpha');
if ($action == 'save') {
    foreach ($_REQUEST['TDivers'] as $name => $param) {
        dolibarr_set_const($db, $name, $param);
        if ($name == 'SCRUM_USE_PROJECT_PRIORITY' && $param == 1) {
            $extrafields = new ExtraFields($db);
            $default_value = array('options' => array(0 => $langs->trans('Normal'), 1 => $langs->trans('Important')));
            $res = $extrafields->addExtraField('priority', 'Priorité', 'select', 1, 0, 'projet', false, false, '', serialize($default_value));
        }
        /*else if($name == 'SCRUM_GROUP_TASK_BY_PRODUCT' && $param == 1) {
              $extrafields=new ExtraFields($db);
              $res = $extrafields->addExtraField('grou', 'Priorité', 'select', 1, 0, 'projet', false, false, '', serialize( $default_value ) );
          }*/
    }
    setEventMessage($langs->trans('RegisterSuccess'));
}
llxHeader('', 'Gestion de scrumboard, à propos', '');
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print_fiche_titre('Scrumboard', $linkback, 'setup');
showParameters();
function showParameters()
/**
 * Create ActionComm
 *
 * @param	array		$authentication		Array of authentication information
 * @param	ActionComm	$actioncomm		    $actioncomm
 * @return	array							Array result
 */
function updateActionComm($authentication, $actioncomm)
{
    global $db, $conf, $langs;
    $now = dol_now();
    dol_syslog("Function: updateActionComm login="******"Actioncomm id is mandatory.";
    }
    if (!$error) {
        $objectfound = false;
        $object = new ActionComm($db);
        $result = $object->fetch($actioncomm['id']);
        if (!empty($object->id)) {
            $objectfound = true;
            $object->datep = $actioncomm['datep'];
            $object->datef = $actioncomm['datef'];
            $object->type_code = $actioncomm['type_code'];
            $object->societe->id = $actioncomm['socid'];
            $object->fk_project = $actioncomm['projectid'];
            $object->note = $actioncomm['note'];
            $object->contact->id = $actioncomm['contactid'];
            $object->usertodo->id = $actioncomm['usertodo'];
            $object->userdone->id = $actioncomm['userdone'];
            $object->label = $actioncomm['label'];
            $object->percentage = $actioncomm['percentage'];
            $object->priority = $actioncomm['priority'];
            $object->fulldayevent = $actioncomm['fulldayevent'];
            $object->location = $actioncomm['location'];
            $object->fk_element = $actioncomm['fk_element'];
            $object->elementtype = $actioncomm['elementtype'];
            //Retreive all extrafield for actioncomm
            // fetch optionals attributes and labels
            $extrafields = new ExtraFields($db);
            $extralabels = $extrafields->fetch_name_optionals_label('actioncomm', true);
            foreach ($extrafields->attribute_label as $key => $label) {
                $key = 'options_' . $key;
                $object->array_options[$key] = $actioncomm[$key];
            }
            $db->begin();
            $result = $object->update($fuser);
            if ($result <= 0) {
                $error++;
            }
        }
        if (!$error && $objectfound) {
            $db->commit();
            $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id);
        } elseif ($objectfound) {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $object->error;
        } else {
            $error++;
            $errorcode = 'NOT_FOUND';
            $errorlabel = 'Actioncomm id=' . $actioncomm['id'] . ' cannot be found';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
Ejemplo n.º 18
0
         $objectline->localtax1_tx = $localtax1_tx;
         $objectline->localtax2_tx = $localtax2_tx;
         $objectline->date_ouverture_prevue = $date_start_update;
         $objectline->date_ouverture = $date_start_real_update;
         $objectline->date_fin_validite = $date_end_update;
         $objectline->date_cloture = $date_end_real_update;
         $objectline->fk_user_cloture = $user->id;
         $objectline->fk_fournprice = $fk_fournprice;
         $objectline->pa_ht = $pa_ht;
         if ($fk_unit > 0) {
             $objectline->fk_unit = GETPOST('unit');
         } else {
             $objectline->fk_unit = null;
         }
         // Extrafields
         $extrafieldsline = new ExtraFields($db);
         $extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
         $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
         $objectline->array_options = $array_options;
         // TODO verifier price_min si fk_product et multiprix
         $result = $objectline->update($user);
         if ($result > 0) {
             $db->commit();
         } else {
             setEventMessage($objectline->error, 'errors');
             $db->rollback();
         }
     } else {
         setEventMessage($objectline->error, 'errors');
     }
 } else {
Ejemplo n.º 19
0
 */

/**
 *      \file       htdocs/societe/admin/societe_extrafields.php
 *		\ingroup    societe
 *		\brief      Page to setup extra fields of third party
 */

require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");

$langs->load("companies");
$langs->load("admin");

$extrafields = new ExtraFields($db);
$form = new Form($db);

// List of supported format
$type2label=array(
'varchar'=>$langs->trans('String'),
'text'=>$langs->trans('Text'),
'int'=>$langs->trans('Int'),
//'date'=>$langs->trans('Date'),
//'datetime'=>$langs->trans('DateAndTime')
);

$yesno=array($langs->trans('No'),$langs->trans('Yes'));

$action=GETPOST("action");
$elementtype='Societe';
Ejemplo n.º 20
0
/**
 *      \file       htdocs/admin/societe_extrafields.php
 *		\ingroup    societe
 *		\brief      Page to setup extra fields of third party
 *		\version    $Id: societe_extrafields.php,v 1.6 2011/07/31 22:23:21 eldy Exp $
 */

require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");

$langs->load("companies");
$langs->load("admin");

$extrafields = new ExtraFields($db);
$form = new Form($db);

// List of supported format
$type2label=array(
'varchar'=>$langs->trans('String'),
'text'=>$langs->trans('Text'),
'int'=>$langs->trans('Int'),
//'date'=>$langs->trans('Date'),
//'datetime'=>$langs->trans('DateAndTime')
);

$action=GETPOST("action");
$elementtype='company';

if (!$user->admin)
Ejemplo n.º 21
0
$action = GETPOST('action', 'alpha');
// Load translation files
$langs->load("main");
$langs->load("members");
$langs->load("companies");
$langs->load("install");
$langs->load("other");
// Security check
if (empty($conf->adherent->enabled)) {
    accessforbidden('', 1, 1, 1);
}
if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
    print $langs->trans("Auto subscription form for public visitors has not been enabled");
    exit;
}
$extrafields = new ExtraFields($db);
/**
 * Show header for new member
 *
 * @param 	string		$title				Title
 * @param 	string		$head				Head array
 * @param 	int    		$disablejs			More content into html header
 * @param 	int    		$disablehead		More content into html header
 * @param 	array  		$arrayofjs			Array of complementary js files
 * @param 	array  		$arrayofcss			Array of complementary css files
 * @return	void
 */
function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
{
    global $user, $conf, $langs, $mysoc;
    top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
Ejemplo n.º 22
0
 /**
  *    Load a contract from database
  *
  *    @param	int		$id     Id of contract to load
  *    @param	string	$ref	Ref
  *    @return   int     		<0 if KO, id of contract if OK
  */
 function fetch($id, $ref = '')
 {
     $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,";
     $sql .= " fk_user_mise_en_service, date_contrat as datecontrat,";
     $sql .= " fk_user_author,";
     $sql .= " fk_projet,";
     $sql .= " fk_commercial_signature, fk_commercial_suivi,";
     $sql .= " note_private, note_public, model_pdf, extraparams";
     $sql .= " ,ref_supplier";
     $sql .= " ,ref_ext";
     $sql .= " FROM " . MAIN_DB_PREFIX . "contrat";
     if ($ref) {
         $sql .= " WHERE ref='" . $this->db->escape($ref) . "'";
         $sql .= " AND entity IN (" . getEntity('contract') . ")";
     } else {
         $sql .= " WHERE rowid=" . $id;
     }
     dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
     $resql = $this->db->query($sql);
     if ($resql) {
         $result = $this->db->fetch_array($resql);
         if ($result) {
             $this->id = $result["rowid"];
             $this->ref = !isset($result["ref"]) || !$result["ref"] ? $result["rowid"] : $result["ref"];
             $this->ref_supplier = $result["ref_supplier"];
             $this->ref_ext = $result["ref_ext"];
             $this->statut = $result["statut"];
             $this->mise_en_service = $this->db->jdate($result["datemise"]);
             $this->date_contrat = $this->db->jdate($result["datecontrat"]);
             $this->date_creation = $this->db->jdate($result["datecontrat"]);
             $this->user_author_id = $result["fk_user_author"];
             $this->commercial_signature_id = $result["fk_commercial_signature"];
             $this->commercial_suivi_id = $result["fk_commercial_suivi"];
             $this->note = $result["note_private"];
             // deprecated
             $this->note_private = $result["note_private"];
             $this->note_public = $result["note_public"];
             $this->modelpdf = $result["model_pdf"];
             $this->fk_projet = $result["fk_projet"];
             // deprecated
             $this->fk_project = $result["fk_projet"];
             $this->socid = $result["fk_soc"];
             $this->fk_soc = $result["fk_soc"];
             $this->extraparams = (array) json_decode($result["extraparams"], true);
             $this->db->free($resql);
             // Retreive all extrafield for thirdparty
             // fetch optionals attributes and labels
             require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
             $extrafields = new ExtraFields($this->db);
             $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true);
             $this->fetch_optionals($this->id, $extralabels);
             /*
              * Lines
              */
             $this->lines = array();
             $result = $this->fetch_lines();
             if ($result < 0) {
                 $this->error = $this->db->lasterror();
                 return -3;
             }
             return $this->id;
         } else {
             dol_syslog(get_class($this) . "::Fetch Erreur contrat non trouve");
             $this->error = "Contract not found";
             return -2;
         }
     } else {
         dol_syslog(get_class($this) . "::Fetch Erreur lecture contrat");
         $this->error = $this->db->error();
         return -1;
     }
 }
Ejemplo n.º 23
0
// Security check
$socid = GETPOST('socid', 'int');
$id = GETPOST('id', 'int');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
if ($user->societe_id && $socid) {
    $result = restrictedArea($user, 'societe', $socid);
}
$error = GETPOST("error");
$donotclearsession = GETPOST('donotclearsession') ? GETPOST('donotclearsession') : 0;
$cactioncomm = new CActionComm($db);
$object = new ActionComm($db);
$contact = new Contact($db);
$extrafields = new ExtraFields($db);
$formfile = new FormFile($db);
$form = new Form($db);
$formfile = new FormFile($db);
$formactions = new FormActions($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
//var_dump($_POST);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('actioncard', 'globalcard'));
/*
 * Actions
 */
$listUserAssignedUpdated = false;
// Remove user to assigned list
if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') {
Ejemplo n.º 24
0
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$langs->load("users");
$langs->load("projects");
$action = GETPOST('action', 'alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$mode = GETPOST('mode', 'alpha');
$mine = $mode == 'mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1;	// Special for projects
$object = new Project($db);
$taskstatic = new Task($db);
$extrafields_project = new ExtraFields($db);
$extrafields_task = new ExtraFields($db);
if ($id > 0 || !empty($ref)) {
    $object->fetch($id, $ref);
    $id = $object->id;
    $ref = $object->ref;
    // fetch optionals attributes and labels
    $extralabels_projet = $extrafields_project->fetch_name_optionals_label($object->table_element);
    $extralabels_task = $extrafields_task->fetch_name_optionals_label($taskstatic->table_element);
}
// Security check
$socid = 0;
if ($user->societe_id > 0) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'projet', $id);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
Ejemplo n.º 25
0
$elemid = GETPOST('elemid');
if ($id == "") {
    dol_print_error('', 'Missing parameter id');
    exit;
}
// Security check
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
$result = $object->fetch($id);
$object->fetch_optionals($id, $extralabels);
if ($result <= 0) {
    dol_print_error($db, $object->error);
    exit;
}
$type = $object->type;
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
/*
 *	Actions
 */
// Remove element from category
if ($id > 0 && $removeelem > 0) {
    if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) {
        require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
        $tmpobject = new Product($db);
        $result = $tmpobject->fetch($removeelem);
        $elementtype = 'product';
    } else {
        if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) {
Ejemplo n.º 26
0
$ref = GETPOST('ref', 'alpha');
// Security check
$socid = '';
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, $origin, $origin_id);
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
//PDF
$hidedetails = GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
$object = new Expedition($db);
$extrafields = new ExtraFields($db);
$extrafieldsline = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// fetch optionals attributes lines and labels
$extralabelslines = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
// Load object. Make an object->fetch
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php';
// Must be include, not include_once
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('expeditioncard', 'globalcard'));
$permissiondellink = $user->rights->expedition->livraison->creer;
// Used by the include of actions_dellink.inc.php
/*
 * Actions
 */
// Set incoterm
 /**
  *		Function called when module is enabled.
  *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  *		It also creates data directories
  *
  *      @param      string	$options    Options when enabling module ('', 'noboxes')
  *      @return     int             	1 if OK, 0 if KO
  */
 function init($options = '')
 {
     $sql = array();
     define('INC_FROM_DOLIBARR', true);
     dol_include_once('/of/config.php');
     dol_include_once('/of/script/create-maj-base.php');
     $result = $this->_load_tables('/of/sql/');
     dol_include_once('/core/class/extrafields.class.php');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('fk_of', 'Ordre de Fabrication', 'sellist', 0, '', 'projet_task', 0, 0, '', serialize(array('options' => array('assetOf:numero:rowid' => null))));
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('fk_product', 'Produit à fabriquer', 'sellist', 0, '', 'projet_task', 0, 0, '', serialize(array('options' => array('product:label:rowid' => null))));
     return $this->_init($sql, $options);
 }
Ejemplo n.º 28
0
 /**
  *	Get object and lines from database
  *
  *	@param      int		$rowid       	Id of object to load
  * 	@param		string	$ref			Reference of invoice
  * 	@param		string	$ref_ext		External reference of invoice
  * 	@param		int		$ref_int		Internal reference of other object
  *	@return     int         			>0 if OK, <0 if KO, 0 if not found
  */
 function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '')
 {
     global $conf;
     if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) {
         return -1;
     }
     $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount,f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp';
     $sql .= ', f.remise_percent, f.remise_absolue, f.remise';
     $sql .= ', f.datef as df';
     $sql .= ', f.date_lim_reglement as dlr';
     $sql .= ', f.datec as datec';
     $sql .= ', f.date_valid as datev';
     $sql .= ', f.tms as datem';
     $sql .= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf';
     $sql .= ', f.fk_facture_source';
     $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams';
     $sql .= ', f.situation_cycle_ref, f.situation_counter, f.situation_final';
     $sql .= ', f.fk_account';
     $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
     $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
     $sql .= ', f.fk_incoterms, f.location_incoterms';
     $sql .= ", i.libelle as libelle_incoterms";
     $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture as f';
     $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
     $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as p ON f.fk_mode_reglement = p.id';
     $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as i ON f.fk_incoterms = i.rowid';
     $sql .= ' WHERE f.entity = ' . $conf->entity;
     if ($rowid) {
         $sql .= " AND f.rowid=" . $rowid;
     }
     if ($ref) {
         $sql .= " AND f.facnumber='" . $this->db->escape($ref) . "'";
     }
     if ($ref_ext) {
         $sql .= " AND f.ref_ext='" . $this->db->escape($ref_ext) . "'";
     }
     if ($ref_int) {
         $sql .= " AND f.ref_int='" . $this->db->escape($ref_int) . "'";
     }
     dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
     $result = $this->db->query($sql);
     if ($result) {
         if ($this->db->num_rows($result)) {
             $obj = $this->db->fetch_object($result);
             $this->id = $obj->rowid;
             $this->ref = $obj->facnumber;
             $this->ref_client = $obj->ref_client;
             $this->ref_ext = $obj->ref_ext;
             $this->ref_int = $obj->ref_int;
             $this->type = $obj->type;
             $this->date = $this->db->jdate($obj->df);
             $this->date_creation = $this->db->jdate($obj->datec);
             $this->date_validation = $this->db->jdate($obj->datev);
             $this->datem = $this->db->jdate($obj->datem);
             $this->remise_percent = $obj->remise_percent;
             $this->remise_absolue = $obj->remise_absolue;
             $this->total_ht = $obj->total;
             $this->total_tva = $obj->tva;
             $this->total_localtax1 = $obj->localtax1;
             $this->total_localtax2 = $obj->localtax2;
             $this->total_ttc = $obj->total_ttc;
             $this->revenuestamp = $obj->revenuestamp;
             $this->paye = $obj->paye;
             $this->close_code = $obj->close_code;
             $this->close_note = $obj->close_note;
             $this->socid = $obj->fk_soc;
             $this->statut = $obj->fk_statut;
             $this->date_lim_reglement = $this->db->jdate($obj->dlr);
             $this->mode_reglement_id = $obj->fk_mode_reglement;
             $this->mode_reglement_code = $obj->mode_reglement_code;
             $this->mode_reglement = $obj->mode_reglement_libelle;
             $this->cond_reglement_id = $obj->fk_cond_reglement;
             $this->cond_reglement_code = $obj->cond_reglement_code;
             $this->cond_reglement = $obj->cond_reglement_libelle;
             $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
             $this->fk_account = $obj->fk_account > 0 ? $obj->fk_account : null;
             $this->fk_project = $obj->fk_projet;
             $this->fk_facture_source = $obj->fk_facture_source;
             $this->note = $obj->note_private;
             // deprecated
             $this->note_private = $obj->note_private;
             $this->note_public = $obj->note_public;
             $this->user_author = $obj->fk_user_author;
             $this->user_valid = $obj->fk_user_valid;
             $this->modelpdf = $obj->model_pdf;
             $this->situation_cycle_ref = $obj->situation_cycle_ref;
             $this->situation_counter = $obj->situation_counter;
             $this->situation_final = $obj->situation_final;
             $this->extraparams = (array) json_decode($obj->extraparams, true);
             //Incoterms
             $this->fk_incoterms = $obj->fk_incoterms;
             $this->location_incoterms = $obj->location_incoterms;
             $this->libelle_incoterms = $obj->libelle_incoterms;
             if ($this->statut == self::STATUS_DRAFT) {
                 $this->brouillon = 1;
             }
             // Retrieve all extrafield for invoice
             // fetch optionals attributes and labels
             require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
             $extrafields = new ExtraFields($this->db);
             $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true);
             $this->fetch_optionals($this->id, $extralabels);
             /*
              * Lines
              */
             $this->lines = array();
             $result = $this->fetch_lines();
             if ($result < 0) {
                 $this->error = $this->db->error();
                 return -3;
             }
             return 1;
         } else {
             $this->error = 'Bill with id ' . $rowid . ' or ref ' . $ref . ' not found sql=' . $sql;
             dol_syslog(get_class($this) . "::fetch Error " . $this->error, LOG_ERR);
             return 0;
         }
     } else {
         $this->error = $this->db->error();
         return -1;
     }
 }
Ejemplo n.º 29
0
$contextpage = 'productservicelist';
if ($type === '1') {
    $contextpage = 'servicelist';
    if ($search_type == '') {
        $search_type = '1';
    }
}
if ($type === '0') {
    $contextpage = 'productlist';
    if ($search_type == '') {
        $search_type = '0';
    }
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array($contextpage));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('product');
$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_');
if (empty($action)) {
    $action = 'list';
}
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$canvas = GETPOST("canvas");
$objcanvas = null;
if (!empty($canvas)) {
    require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php';
    $objcanvas = new Canvas($db, $action);
    $objcanvas->getCanvas('product', 'list', $canvas);
}
// Security check
Ejemplo n.º 30
0
 /**
  *	Charge un objet group avec toutes ces caracteristiques (excpet ->members array)
  *
  *	@param      int		$id			id du groupe a charger
  *	@param      string	$groupname	name du groupe a charger
  *	@return		int					<0 if KO, >0 if OK
  */
 function fetch($id = '', $groupname = '')
 {
     global $conf;
     $sql = "SELECT g.rowid, g.entity, g.nom as name, g.note, g.datec, g.tms as datem";
     $sql .= " FROM " . MAIN_DB_PREFIX . "usergroup as g";
     if ($groupname) {
         $sql .= " WHERE g.nom = '" . $this->db->escape($groupname) . "'";
     } else {
         $sql .= " WHERE g.rowid = " . $id;
     }
     dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
     $result = $this->db->query($sql);
     if ($result) {
         if ($this->db->num_rows($result)) {
             $obj = $this->db->fetch_object($result);
             $this->id = $obj->rowid;
             $this->ref = $obj->rowid;
             $this->entity = $obj->entity;
             $this->name = $obj->name;
             $this->nom = $obj->name;
             // Deprecated
             $this->note = $obj->note;
             $this->datec = $obj->datec;
             $this->datem = $obj->datem;
             $this->members = $this->listUsersForGroup();
             // Retreive all extrafield for group
             // fetch optionals attributes and labels
             dol_include_once('/core/class/extrafields.class.php');
             $extrafields = new ExtraFields($this->db);
             $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true);
             $this->fetch_optionals($this->id, $extralabels);
             // Sav current LDAP Current DN
             //$this->ldap_dn = $this->_load_ldap_dn($this->_load_ldap_info(),0);
         }
         $this->db->free($result);
         return 1;
     } else {
         $this->error = $this->db->lasterror();
         return -1;
     }
 }