Exemplo n.º 1
0
    {
        // Check values
        if (GETPOST('type')=='varchar' && GETPOST('size') > 255)
        {
            $error++;
            $langs->load("errors");
            $mesg=$langs->trans("ErrorSizeTooLongForVarcharType");
            $action = 'create';
        }

        if (! $error)
        {
            // Type et taille non encore pris en compte => varchar(255)
            if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
            {
                $result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$_POST['size'],$elementtype);
                if ($result > 0)
                {
                    Header("Location: ".$_SERVER["PHP_SELF"]);
                    exit;
                }
                else
                {
                    $error++;
                    $mesg=$extrafields->error;
                }
            }
            else
            {
                $error++;
                $langs->load("errors");
 /**
  *		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);
 }
 /**
  *		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('/factor/config.php');
     dol_include_once('/factor/script/create-maj-base.php');
     dol_include_once('/core/class/extrafields.class.php');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('fk_soc_factor', 'Fournisseur du factor', 'sellist', 0, '', 'societe', 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:32:"societe:nom:rowid::fournisseur=1";N;}}'));
     //Ne peut prendre de order by
     $res = $extrafields->addExtraField('factor_suivi', 'Utiliser le factor', 'select', 0, '', 'societe', 0, 0, '', array("options" => array(2 => 'Non', 1 => 'Oui')));
     $res = $extrafields->addExtraField('factor_depot', 'Déposé au factor', 'select', 0, '', 'facture', 0, 0, '', array("options" => array(2 => 'A déposer', 1 => 'Oui')));
     $result = $this->_load_tables('/factor/sql/');
     return $this->_init($sql, $options);
 }
// 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()
{
    global $db, $conf, $langs;
 /**
  *		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 = '')
 {
     global $db;
     $sql = array();
     define('INC_FROM_DOLIBARR', true);
     dol_include_once('/propalautosend/config.php');
     dol_include_once('/propalautosend/script/create-maj-base.php');
     dol_include_once('/core/class/extrafields.class.php');
     $result = $this->_load_tables('/propalautosend/sql/');
     $e = new ExtraFields($db);
     $e->addExtraField('date_relance', 'Date de relance', 'date', 0, '', 'propal');
     return $this->_init($sql, $options);
 }
if (!$user->admin) {
    accessforbidden();
}
// Parameters
$action = GETPOST('action', 'alpha');
if (preg_match('/set_(.*)/', $action, $reg)) {
    $code = $reg[1];
    if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) {
        if ($code == 'SCRUM_USE_PROJECT_PRIORITY') {
            $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 ($code == 'SCRUM_GROUP_TASK_BY_RAL' && GETPOST($code) == 1) {
                $extrafields = new ExtraFields($db);
                $res = $extrafields->addExtraField('fk_product_ral', 'RALLinkedToOrder', 'varchar', '', 255, 'projet_task');
            }
        }
        /*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'));
        header("Location: " . $_SERVER["PHP_SELF"]);
        exit;
    } else {
        dol_print_error($db);
    }
}
if (preg_match('/del_(.*)/', $action, $reg)) {
    $code = $reg[1];
 /**
  *		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('/contratconcurrent/config.php');
     dol_include_once('/contratconcurrent/script/create-maj-base.php');
     dol_include_once('/core/class/extrafields.class.php');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('concurrent', 'Contrat concurrent', 'select', 1, '', 'contrat', 0, 0, '', array("options" => array('non', 'oui')));
     $result = $this->_load_tables('/contratconcurrent/sql/');
     return $this->_init($sql, $options);
 }
function create_extrafield($code, $label, $type, $elementtype, $options = array())
{
    global $db;
    $e = new ExtraFields($db);
    $e->addExtraField($code, $label, $type, '', '', $elementtype, 0, 0, '', $options);
}
 /**
  *		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('/mandarin/config.php');
     dol_include_once('/mandarin/script/create-maj-base.php');
     $result = $this->_load_tables('/mandarin/sql/');
     dol_include_once('/core/class/extrafields.class.php');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('contrat', 'Contrat', 'varchar', 0, 150, 'user');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('thm', 'THM', 'double', 0, '', 'user');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('horaire', 'Horaire contractuel', 'varchar', 0, 150, 'user');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('dds', 'Date de sortie', 'date', 0, 10, 'user');
     return $this->_init($sql, $options);
 }
    /**
     * 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
     */
    public function init($options = '')
    {
        global $db;
        $sql = array();
        $result = $this->loadTables();
        $db->query("ALTER TABLE `" . MAIN_DB_PREFIX . "projet_task` \n\t\t\t\t\tADD `grid_col` FLOAT NOT NULL DEFAULT '0',\n\t\t\t\t\tADD `grid_row` FLOAT NOT NULL DEFAULT '999999'");
        $db->query("ALTER TABLE `" . MAIN_DB_PREFIX . "projet_task`\n\t\t\t\t\tADD grid_height FLOAT NOT NULL DEFAULT 0");
        $db->query('ALTER TABLE `' . MAIN_DB_PREFIX . 'projet_task`
				ADD INDEX `grid_row_grid_col` (`grid_row`, `grid_col`)');
        $db->query("ALTER TABLE " . MAIN_DB_PREFIX . "projet_task\n\t\t\t\tADD date_estimated_start DATETIME NOT NULL \n\t\t\t  , ADD date_estimated_end DATETIME NOT NULL \n\t\t\t  , ADD INDEX (date_estimated_start, date_estimated_end)");
        dol_include_once('/core/class/extrafields.class.php');
        $extrafields = new ExtraFields($this->db);
        $res = $extrafields->addExtraField('color', 'Couleur du projet', 'varchar', 1, 8, 'projet', false, false, '');
        $extrafields = new ExtraFields($this->db);
        $res = $extrafields->addExtraField('grid_use', 'Afficher sur la grille de planning', 'boolean', 0, '', 'projet_task');
        $extrafields = new ExtraFields($this->db);
        $res = $extrafields->addExtraField('needed_ressource', 'nb ressources nécessaires', 'int', 0, '', 'projet_task');
        return $this->_init($sql, $options);
    }
 /**
  *		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('/facturecourrier/config.php');
     dol_include_once('/facturecourrier/script/create-maj-base.php');
     dol_include_once('/core/class/extrafields.class.php');
     $extrafields = new ExtraFields($this->db);
     $res = $extrafields->addExtraField('facture_papier', 'Facture par courrier', 'select', 0, '', 'societe', 0, 0, '', array("options" => array(1 => 'Non', 2 => 'Oui')));
     $res = $extrafields->addExtraField('courrier_envoi', 'Facture envoyée par courrier', 'date', 0, '', 'facture', 0, 0, '');
     $result = $this->_load_tables('/facturecourrier/sql/');
     return $this->_init($sql, $options);
 }
        break;
    case 'saveIDCategToExclude':
        if (_saveConst($db, 'REMISE_ID_CATEG_TO_EXCLUDE', $_REQUEST['idcategtoexclude'])) {
            setEventMessage($langs->trans('IDCategSaved'));
        } else {
            setEventMessage($langs->trans('IDCategNotSaved'), 'errors');
        }
    case 'save':
        $const_name = array_keys($_REQUEST['TDivers'])[0];
        $val = $conf->global->{$const_name};
        $val = !$val;
        if ($const_name === 'REMISE_USE_THIRDPARTY_DISCOUNT' && !empty($val)) {
            dolibarr_set_const($db, 'REMISE_USE_THIRDPARTY_DISCOUNT', $val);
            dolibarr_set_const($db, 'REMISE_USE_WEIGHT', !$val);
            $e = new ExtraFields($db);
            $e->addExtraField('remsup', 'Remise supplémentaire', 'double', '', '24,8', 'societe');
        } elseif ($const_name === 'REMISE_USE_WEIGHT' && !empty($val)) {
            dolibarr_set_const($db, 'REMISE_USE_WEIGHT', $val);
            dolibarr_set_const($db, 'REMISE_USE_THIRDPARTY_DISCOUNT', !$val);
        } else {
            dolibarr_set_const($db, $const_name, $val);
        }
    default:
        break;
}
/*
 * View
 */
//print_r($TFraisDePort);
$page_name = "RemiseSetup";
llxHeader('', $langs->trans($page_name));
 /**
  * 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
  */
 public function init($options = '')
 {
     global $db, $conf;
     $sql = array();
     $result = $this->loadTables();
     // Création extrafield pour choix si remise doit apparaitre sur doc.
     dol_include_once('/core/class/extrafields.class.php');
     //function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0,$default_value='', $param=0)
     $ext = new ExtraFields($db);
     $res = $ext->addExtraField("use_remise", 'Automatisation des remises', 'select', 0, "", 'propal', 0, 0, '', array("options" => array("Oui" => "Oui", "Non" => "Non")));
     $res = $ext->addExtraField("use_remise", 'Automatisation des remises', 'select', 0, "", 'commande', 0, 0, '', array("options" => array("Oui" => "Oui", "Non" => "Non")));
     $res = $ext->addExtraField("use_remise", 'Automatisation des remises', 'select', 0, "", 'facture', 0, 0, '', array("options" => array("Oui" => "Oui", "Non" => "Non")));
     define('INC_FROM_DOLIBARR', true);
     dol_include_once('/remise/config.php');
     dol_include_once('/remise/class/remise.class.php');
     $PDOdb = new TPDOdb();
     $o = new TRemise();
     $o->init_db_by_vars($PDOdb);
     if (!empty($conf->global->REMISE_WEIGHT_ARRAY)) {
         $TRemise = unserialize($conf->global->REMISE_WEIGHT_ARRAY);
         foreach ($TRemise as $remise) {
             $o = new TRemise();
             $o->palier = $remise['weight'];
             $o->remise = $remise['remise'];
             $o->zip = $remise['zip'];
             $o->type = 'WEIGHT';
             $o->save($PDOdb);
         }
         dolibarr_del_const($db, 'REMISE_WEIGHT_ARRAY');
     }
     if (!empty($conf->global->REMISE_ARRAY)) {
         $TRemise = unserialize($conf->global->REMISE_ARRAY);
         foreach ($TRemise as $palier => $remise) {
             $o = new TRemise();
             $o->palier = $palier;
             $o->remise = $remise;
             $o->type = 'AMOUNT';
             $o->save($PDOdb);
         }
         dolibarr_del_const($db, 'REMISE_ARRAY');
     }
     return $this->_init($sql, $options);
 }