コード例 #1
0
 /**
  * Return HTML string to put an input field into a page
  *
  * @param  string  $key            Key of attribute
  * @param  string  $value          Value to show (for date type it must be in timestamp format)
  * @param  string  $moreparam      To add more parametes on html input tag
  * @param  string  $keyprefix      Prefix string to add into name and id of field (can be used to avoid duplicate names)
  * @param  string  $keysuffix      Suffix string to add into name and id of field (can be used to avoid duplicate names)
  * @param  int     $showsize       Value for size attributed
  * @param  int     $objectid       Current object id
  * @return string
  */
 function showInputField($key, $value, $moreparam = '', $keyprefix = '', $keysuffix = '', $showsize = 0, $objectid = 0)
 {
     global $conf, $langs;
     $label = $this->attribute_label[$key];
     $type = $this->attribute_type[$key];
     $size = $this->attribute_size[$key];
     $elementtype = $this->attribute_elementtype[$key];
     $unique = $this->attribute_unique[$key];
     $required = $this->attribute_required[$key];
     $param = $this->attribute_param[$key];
     $perms = $this->attribute_perms[$key];
     $list = $this->attribute_list[$key];
     if (empty($showsize)) {
         if ($type == 'date') {
             $showsize = 10;
         } elseif ($type == 'datetime') {
             $showsize = 19;
         } elseif (in_array($type, array('int', 'double'))) {
             $showsize = 10;
         } else {
             $showsize = round($size);
             if ($showsize > 48) {
                 $showsize = 48;
             }
         }
     }
     if (in_array($type, array('date', 'datetime'))) {
         $tmp = explode(',', $size);
         $newsize = $tmp[0];
         $showtime = in_array($type, array('datetime')) ? 1 : 0;
         // Do not show current date when field not required (see select_date() method)
         if (!$required && $value == '') {
             $value = '-1';
         }
         require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
         global $form;
         if (!is_object($form)) {
             $form = new Form($this->db);
         }
         // TODO Must also support $moreparam
         $out = $form->select_date($value, $keysuffix . 'options_' . $key . $keyprefix, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
     } elseif (in_array($type, array('int'))) {
         $tmp = explode(',', $size);
         $newsize = $tmp[0];
         $out = '<input type="text" class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '" size="' . $showsize . '" maxlength="' . $newsize . '" value="' . $value . '"' . ($moreparam ? $moreparam : '') . '>';
     } elseif ($type == 'varchar') {
         $out = '<input type="text" class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '" size="' . $showsize . '" maxlength="' . $size . '" value="' . $value . '"' . ($moreparam ? $moreparam : '') . '>';
     } elseif ($type == 'text') {
         require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
         $doleditor = new DolEditor($keysuffix . 'options_' . $key . $keyprefix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, 5, 100);
         $out = $doleditor->Create(1);
     } elseif ($type == 'boolean') {
         $checked = '';
         if (!empty($value)) {
             $checked = ' checked value="1" ';
         } else {
             $checked = ' value="1" ';
         }
         $out = '<input type="checkbox" class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '" ' . $checked . ' ' . ($moreparam ? $moreparam : '') . '>';
     } elseif ($type == 'mail') {
         $out = '<input type="text" class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '" size="32" value="' . $value . '" ' . ($moreparam ? $moreparam : '') . '>';
     } elseif ($type == 'phone') {
         $out = '<input type="text" class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '"  size="20" value="' . $value . '" ' . ($moreparam ? $moreparam : '') . '>';
     } elseif ($type == 'price') {
         $out = '<input type="text" class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '"  size="6" value="' . price($value) . '" ' . ($moreparam ? $moreparam : '') . '> ' . $langs->getCurrencySymbol($conf->currency);
     } elseif ($type == 'double') {
         if (!empty($value)) {
             $value = price($value);
         }
         $out = '<input type="text" class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '"  size="6" value="' . $value . '" ' . ($moreparam ? $moreparam : '') . '> ';
     } elseif ($type == 'select') {
         $out = '';
         if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) {
             include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
             $out .= ajax_combobox($keysuffix . 'options_' . $key . $keyprefix, array(), 0);
         }
         $out .= '<select class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '" id="options_' . $key . $keyprefix . '" ' . ($moreparam ? $moreparam : '') . '>';
         $out .= '<option value="0">&nbsp;</option>';
         foreach ($param['options'] as $key => $val) {
             list($val, $parent) = explode('|', $val);
             $out .= '<option value="' . $key . '"';
             $out .= $value == $key ? ' selected' : '';
             $out .= !empty($parent) ? ' parent="' . $parent . '"' : '';
             $out .= '>' . $val . '</option>';
         }
         $out .= '</select>';
     } elseif ($type == 'sellist') {
         $out = '';
         if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) {
             include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
             $out .= ajax_combobox($keysuffix . 'options_' . $key . $keyprefix, array(), 0);
         }
         $out .= '<select class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '" id="options_' . $key . $keyprefix . '" ' . ($moreparam ? $moreparam : '') . '>';
         if (is_array($param['options'])) {
             $param_list = array_keys($param['options']);
             $InfoFieldList = explode(":", $param_list[0]);
             // 0 : tableName
             // 1 : label field name
             // 2 : key fields name (if differ of rowid)
             // 3 : key field parent (for dependent lists)
             // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
             $keyList = empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid';
             if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
                 list($parentName, $parentField) = explode('|', $InfoFieldList[3]);
                 $keyList .= ', ' . $parentField;
             }
             if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
                 if (strpos($InfoFieldList[4], 'extra.') !== false) {
                     $keyList = 'main.' . $InfoFieldList[2] . ' as rowid';
                 } else {
                     $keyList = $InfoFieldList[2] . ' as rowid';
                 }
             }
             $fields_label = explode('|', $InfoFieldList[1]);
             if (is_array($fields_label)) {
                 $keyList .= ', ';
                 $keyList .= implode(', ', $fields_label);
             }
             $sqlwhere = '';
             $sql = 'SELECT ' . $keyList;
             $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
             if (!empty($InfoFieldList[4])) {
                 // can use SELECT request
                 if (strpos($InfoFieldList[4], '$SEL$') !== false) {
                     $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
                 }
                 // current object id can be use into filter
                 if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
                     $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
                 } else {
                     $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
                 }
                 //We have to join on extrafield table
                 if (strpos($InfoFieldList[4], 'extra') !== false) {
                     $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra';
                     $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4];
                 } else {
                     $sqlwhere .= ' WHERE ' . $InfoFieldList[4];
                 }
             } else {
                 $sqlwhere .= ' WHERE 1';
             }
             // Some tables may have field, some other not. For the moment we disable it.
             if (in_array($InfoFieldList[0], array('tablewithentity'))) {
                 $sqlwhere .= ' AND entity = ' . $conf->entity;
             }
             $sql .= $sqlwhere;
             //print $sql;
             $sql .= ' ORDER BY ' . implode(', ', $fields_label);
             dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $out .= '<option value="0">&nbsp;</option>';
                 $num = $this->db->num_rows($resql);
                 $i = 0;
                 while ($i < $num) {
                     $labeltoshow = '';
                     $obj = $this->db->fetch_object($resql);
                     // Several field into label (eq table:code|libelle:rowid)
                     $fields_label = explode('|', $InfoFieldList[1]);
                     if (is_array($fields_label)) {
                         $notrans = true;
                         foreach ($fields_label as $field_toshow) {
                             $labeltoshow .= $obj->{$field_toshow} . ' ';
                         }
                     } else {
                         $labeltoshow = $obj->{$InfoFieldList}[1];
                     }
                     $labeltoshow = dol_trunc($labeltoshow, 45);
                     if ($value == $obj->rowid) {
                         foreach ($fields_label as $field_toshow) {
                             $translabel = $langs->trans($obj->{$field_toshow});
                             if ($translabel != $obj->{$field_toshow}) {
                                 $labeltoshow = dol_trunc($translabel, 18) . ' ';
                             } else {
                                 $labeltoshow = dol_trunc($obj->{$field_toshow}, 18) . ' ';
                             }
                         }
                         $out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
                     } else {
                         if (!$notrans) {
                             $translabel = $langs->trans($obj->{$InfoFieldList}[1]);
                             if ($translabel != $obj->{$InfoFieldList}[1]) {
                                 $labeltoshow = dol_trunc($translabel, 18);
                             } else {
                                 $labeltoshow = dol_trunc($obj->{$InfoFieldList}[1], 18);
                             }
                         }
                         if (empty($labeltoshow)) {
                             $labeltoshow = '(not defined)';
                         }
                         if ($value == $obj->rowid) {
                             $out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
                         }
                         if (!empty($InfoFieldList[3])) {
                             $parent = $parentName . ':' . $obj->{$parentField};
                         }
                         $out .= '<option value="' . $obj->rowid . '"';
                         $out .= $value == $obj->rowid ? ' selected' : '';
                         $out .= !empty($parent) ? ' parent="' . $parent . '"' : '';
                         $out .= '>' . $labeltoshow . '</option>';
                     }
                     $i++;
                 }
                 $this->db->free($resql);
             } else {
                 print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
             }
         }
         $out .= '</select>';
     } elseif ($type == 'checkbox') {
         $out = '';
         $value_arr = explode(',', $value);
         foreach ($param['options'] as $keyopt => $val) {
             $out .= '<input class="flat" type="checkbox" name="' . $keysuffix . 'options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
             $out .= ' value="' . $keyopt . '"';
             if (is_array($value_arr) && in_array($keyopt, $value_arr)) {
                 $out .= 'checked';
             } else {
                 $out .= '';
             }
             $out .= '/>' . $val . '<br>';
         }
     } elseif ($type == 'radio') {
         $out = '';
         foreach ($param['options'] as $keyopt => $val) {
             $out .= '<input class="flat" type="radio" name="' . $keysuffix . 'options_' . $key . $keyprefix . '" ' . ($moreparam ? $moreparam : '');
             $out .= ' value="' . $keyopt . '"';
             $out .= $value == $keyopt ? 'checked' : '';
             $out .= '/>' . $val . '<br>';
         }
     } elseif ($type == 'chkbxlst') {
         if (is_array($value)) {
             $value_arr = $value;
         } else {
             $value_arr = explode(',', $value);
         }
         if (is_array($param['options'])) {
             $param_list = array_keys($param['options']);
             $InfoFieldList = explode(":", $param_list[0]);
             // 0 : tableName
             // 1 : label field name
             // 2 : key fields name (if differ of rowid)
             // 3 : key field parent (for dependent lists)
             // 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
             $keyList = empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid';
             if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
                 list($parentName, $parentField) = explode('|', $InfoFieldList[3]);
                 $keyList .= ', ' . $parentField;
             }
             if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
                 if (strpos($InfoFieldList[4], 'extra.') !== false) {
                     $keyList = 'main.' . $InfoFieldList[2] . ' as rowid';
                 } else {
                     $keyList = $InfoFieldList[2] . ' as rowid';
                 }
             }
             $fields_label = explode('|', $InfoFieldList[1]);
             if (is_array($fields_label)) {
                 $keyList .= ', ';
                 $keyList .= implode(', ', $fields_label);
             }
             $sqlwhere = '';
             $sql = 'SELECT ' . $keyList;
             $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
             if (!empty($InfoFieldList[4])) {
                 // can use SELECT request
                 if (strpos($InfoFieldList[4], '$SEL$') !== false) {
                     $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
                 }
                 // current object id can be use into filter
                 if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
                     $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
                 } else {
                     $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
                 }
                 // We have to join on extrafield table
                 if (strpos($InfoFieldList[4], 'extra') !== false) {
                     $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra';
                     $sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4];
                 } else {
                     $sqlwhere .= ' WHERE ' . $InfoFieldList[4];
                 }
             } else {
                 $sqlwhere .= ' WHERE 1';
             }
             // Some tables may have field, some other not. For the moment we disable it.
             if (in_array($InfoFieldList[0], array('tablewithentity'))) {
                 $sqlwhere .= ' AND entity = ' . $conf->entity;
             }
             // $sql.=preg_replace('/^ AND /','',$sqlwhere);
             // print $sql;
             $sql .= $sqlwhere;
             dol_syslog(get_class($this) . '::showInputField type=chkbxlst', LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $num = $this->db->num_rows($resql);
                 $i = 0;
                 while ($i < $num) {
                     $labeltoshow = '';
                     $obj = $this->db->fetch_object($resql);
                     // Several field into label (eq table:code|libelle:rowid)
                     $fields_label = explode('|', $InfoFieldList[1]);
                     if (is_array($fields_label)) {
                         $notrans = true;
                         foreach ($fields_label as $field_toshow) {
                             $labeltoshow .= $obj->{$field_toshow} . ' ';
                         }
                     } else {
                         $labeltoshow = $obj->{$InfoFieldList}[1];
                     }
                     $labeltoshow = dol_trunc($labeltoshow, 45);
                     if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
                         foreach ($fields_label as $field_toshow) {
                             $translabel = $langs->trans($obj->{$field_toshow});
                             if ($translabel != $obj->{$field_toshow}) {
                                 $labeltoshow = dol_trunc($translabel, 18) . ' ';
                             } else {
                                 $labeltoshow = dol_trunc($obj->{$field_toshow}, 18) . ' ';
                             }
                         }
                         $out .= '<input class="flat" type="checkbox" name="' . $keysuffix . 'options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
                         $out .= ' value="' . $obj->rowid . '"';
                         $out .= 'checked';
                         $out .= '/>' . $labeltoshow . '<br>';
                     } else {
                         if (!$notrans) {
                             $translabel = $langs->trans($obj->{$InfoFieldList}[1]);
                             if ($translabel != $obj->{$InfoFieldList}[1]) {
                                 $labeltoshow = dol_trunc($translabel, 18);
                             } else {
                                 $labeltoshow = dol_trunc($obj->{$InfoFieldList}[1], 18);
                             }
                         }
                         if (empty($labeltoshow)) {
                             $labeltoshow = '(not defined)';
                         }
                         if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
                             $out .= '<input class="flat" type="checkbox" name="' . $keysuffix . 'options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
                             $out .= ' value="' . $obj->rowid . '"';
                             $out .= 'checked';
                             $out .= '';
                             $out .= '/>' . $labeltoshow . '<br>';
                         }
                         if (!empty($InfoFieldList[3])) {
                             $parent = $parentName . ':' . $obj->{$parentField};
                         }
                         $out .= '<input class="flat" type="checkbox" name="' . $keysuffix . 'options_' . $key . $keyprefix . '[]" ' . ($moreparam ? $moreparam : '');
                         $out .= ' value="' . $obj->rowid . '"';
                         $out .= is_array($value_arr) && in_array($obj->rowid, $value_arr) ? ' checked ' : '';
                         $out .= '';
                         $out .= '/>' . $labeltoshow . '<br>';
                     }
                     $i++;
                 }
                 $this->db->free($resql);
             } else {
                 print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
             }
         }
         $out .= '</select>';
     } elseif ($type == 'link') {
         $out = '';
         $param_list = array_keys($param['options']);
         // 0 : ObjectName
         // 1 : classPath
         $InfoFieldList = explode(":", $param_list[0]);
         dol_include_once($InfoFieldList[1]);
         if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) {
             $object = new $InfoFieldList[0]($this->db);
             $object->fetch($value);
             $valuetoshow = $object->ref;
             if ($object->element == 'societe') {
                 $valuetoshow = $object->name;
             }
             // Special case for thirdparty because ref is id because name is not unique
             $out .= '<input type="text" class="flat" name="' . $keysuffix . 'options_' . $key . $keyprefix . '"  size="20" value="' . $valuetoshow . '" >';
         } else {
             dol_syslog('Error bad setup of extrafield', LOG_WARNING);
             $out .= 'Error bad setup of extrafield';
         }
     }
     /* Add comments
     		 if ($type == 'date') $out.=' (YYYY-MM-DD)';
     		elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
     		*/
     return $out;
 }
コード例 #2
0
  */
 if (($action == 'edit' || $action == 're-edit') && 1) {
     print_fiche_titre($langs->trans("WarehouseEdit"), $mesg);
     print '<form action="fiche.php" method="POST">';
     print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
     print '<input type="hidden" name="action" value="update">';
     print '<input type="hidden" name="id" value="' . $object->id . '">';
     print '<table class="border" width="100%">';
     // Ref
     print '<tr><td width="20%" class="fieldrequired">' . $langs->trans("Ref") . '</td><td colspan="3"><input name="libelle" size="20" value="' . $object->libelle . '"></td></tr>';
     print '<tr><td width="20%">' . $langs->trans("LocationSummary") . '</td><td colspan="3"><input name="lieu" size="40" value="' . $object->lieu . '"></td></tr>';
     // Description
     print '<tr><td valign="top">' . $langs->trans("Description") . '</td><td colspan="3">';
     // Editeur wysiwyg
     require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
     $doleditor = new DolEditor('desc', $object->description, '', 180, 'dolibarr_notes', 'In', false, true, $conf->fckeditor->enabled, 5, 70);
     $doleditor->Create();
     print '</td></tr>';
     print '<tr><td>' . $langs->trans('Address') . '</td><td colspan="3"><textarea name="address" cols="60" rows="3" wrap="soft">';
     print $object->address;
     print '</textarea></td></tr>';
     // Zip / Town
     print '<tr><td>' . $langs->trans('Zip') . '</td><td>';
     print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
     print '</td><td>' . $langs->trans('Town') . '</td><td>';
     print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
     print '</td></tr>';
     // Country
     print '<tr><td width="25%">' . $langs->trans('Country') . '</td><td colspan="3">';
     print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code, 'country_id');
     if ($user->admin) {
コード例 #3
0
ファイル: dict.php プロジェクト: Samara94/dolibarr
/**
 *	Show fields in insert/edit mode
 *
 * 	@param		array	$fieldlist		Array of fields
 * 	@param		Object	$obj			If we show a particular record, obj is filled with record fields
 *  @param		string	$tabname		Name of SQL table
 *  @param		string	$context		'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
 *	@return		void
 */
function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
{
    global $conf, $langs, $db;
    global $form;
    global $region_id;
    global $elementList, $sourceList, $localtax_typeList;
    global $bc;
    $formadmin = new FormAdmin($db);
    $formcompany = new FormCompany($db);
    foreach ($fieldlist as $field => $value) {
        if ($fieldlist[$field] == 'country') {
            if (in_array('region_id', $fieldlist)) {
                print '<td>';
                //print join(',',$fieldlist);
                print '</td>';
                continue;
            }
            // For state page, we do not show the country input (we link to region, not country)
            print '<td>';
            $fieldname = 'country';
            print $form->select_country(!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : ''), $fieldname, '', 28, 'maxwidth300');
            print '</td>';
        } elseif ($fieldlist[$field] == 'country_id') {
            if (!in_array('country', $fieldlist)) {
                $country_id = !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : 0;
                print '<td>';
                print '<input type="hidden" name="' . $fieldlist[$field] . '" value="' . $country_id . '">';
                print '</td>';
            }
        } elseif ($fieldlist[$field] == 'region') {
            print '<td>';
            $formcompany->select_region($region_id, 'region');
            print '</td>';
        } elseif ($fieldlist[$field] == 'region_id') {
            $region_id = !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : 0;
            print '<td>';
            print '<input type="hidden" name="' . $fieldlist[$field] . '" value="' . $region_id . '">';
            print '</td>';
        } elseif ($fieldlist[$field] == 'lang') {
            print '<td>';
            print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang');
            print '</td>';
        } elseif ($fieldlist[$field] == 'type_template') {
            print '<td>';
            print $form->selectarray('type_template', $elementList, !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '');
            print '</td>';
        } elseif ($fieldlist[$field] == 'element') {
            print '<td>';
            print $form->selectarray('element', $elementList, !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '');
            print '</td>';
        } elseif ($fieldlist[$field] == 'source') {
            print '<td>';
            print $form->selectarray('source', $sourceList, !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '');
            print '</td>';
        } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX . "c_actioncomm") {
            print '<td>';
            print 'user<input type="hidden" name="type" value="user">';
            print '</td>';
        } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') {
            print '<td>';
            print $form->selectyesno($fieldlist[$field], !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '', 1);
            print '</td>';
        } elseif (in_array($fieldlist[$field], array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) {
            $align = "left";
            if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) {
                $align = "right";
            }
            // Fields aligned on right
            print '<td align="' . $align . '">';
            print '<input type="text" class="flat" value="' . (isset($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '') . '" size="3" name="' . $fieldlist[$field] . '">';
            print '</td>';
        } elseif (in_array($fieldlist[$field], array('libelle_facture'))) {
            print '<td><textarea cols="30" rows="' . ROWS_2 . '" class="flat" name="' . $fieldlist[$field] . '">' . (!empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '') . '</textarea></td>';
        } elseif (in_array($fieldlist[$field], array('content'))) {
            if ($tabname == MAIN_DB_PREFIX . 'c_email_templates') {
                print '<td colspan="4"></td></tr><tr class="pair nohover"><td colspan="5">';
                // To create an artificial CR for the current tr we are on
            } else {
                print '<td>';
            }
            if ($context != 'hide') {
                //print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'</textarea>';
                $doleditor = new DolEditor($fieldlist[$field], !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '', '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%');
                print $doleditor->Create(1);
            } else {
                print '&nbsp;';
            }
            print '</td>';
        } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) {
            print '<td><input type="text" class="flat" value="' . price(!empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '') . '" size="8" name="' . $fieldlist[$field] . '"></td>';
        } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist}[$field])) {
            print '<td><input type="text" class="flat" value="' . (!empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '') . '" size="10" name="' . $fieldlist[$field] . '"></td>';
        } elseif ($fieldlist[$field] == 'unit') {
            print '<td>';
            $units = array('mm' => $langs->trans('SizeUnitmm'), 'cm' => $langs->trans('SizeUnitcm'), 'point' => $langs->trans('SizeUnitpoint'), 'inch' => $langs->trans('SizeUnitinch'));
            print $form->selectarray('unit', $units, !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '', 0, 0, 0);
            print '</td>';
        } elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') {
            print '<td align="center">';
            print $form->selectarray($fieldlist[$field], $localtax_typeList, !empty($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '');
            print '</td>';
        } else {
            print '<td>';
            $size = '';
            if ($fieldlist[$field] == 'code') {
                $size = 'size="8" ';
            }
            if ($fieldlist[$field] == 'position') {
                $size = 'size="4" ';
            }
            if ($fieldlist[$field] == 'libelle') {
                $size = 'size="32" ';
            }
            if ($fieldlist[$field] == 'tracking') {
                $size = 'size="92" ';
            }
            if ($fieldlist[$field] == 'accountancy_code') {
                $size = 'size="10" ';
            }
            if ($fieldlist[$field] == 'accountancy_code_sell') {
                $size = 'size="10" ';
            }
            if ($fieldlist[$field] == 'accountancy_code_buy') {
                $size = 'size="10" ';
            }
            if ($fieldlist[$field] == 'sortorder') {
                $size = 'size="2" ';
            }
            print '<input type="text" ' . $size . ' class="flat" value="' . (isset($obj->{$fieldlist}[$field]) ? $obj->{$fieldlist}[$field] : '') . '" name="' . $fieldlist[$field] . '">';
            print '</td>';
        }
    }
}
コード例 #4
0
ファイル: facture.php プロジェクト: Samara94/dolibarr
 print $form->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF);
 print "</td></tr>";
 // Public note
 print '<tr>';
 print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
 print '<td valign="top" colspan="2">';
 $note_public = $object->getDefaultCreateValueFor('note_public', is_object($objectsrc) ? $objectsrc->note_public : null);
 $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
 print $doleditor->Create(1);
 // Private note
 if (empty($user->societe_id)) {
     print '<tr>';
     print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>';
     print '<td valign="top" colspan="2">';
     $note_private = $object->getDefaultCreateValueFor('note_private', !empty($origin) && !empty($originid) && is_object($objectsrc) ? $objectsrc->note_private : null);
     $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
     print $doleditor->Create(1);
     // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
     print '</td></tr>';
 }
 // Lines from source
 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
     // TODO for compatibility
     if ($origin == 'contrat') {
         // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
         $objectsrc->remise_absolue = $remise_absolue;
         $objectsrc->remise_percent = $remise_percent;
         $objectsrc->update_price(1, -1, 1);
     }
     print "\n<!-- " . $classname . " info -->";
     print "\n";
コード例 #5
0
ファイル: fckeditor.php プロジェクト: ADDAdev/Dolibarr
        } else {
            if ($value == 1) {
                print '<a href="' . $_SERVER['PHP_SELF'] . '?action=disable_' . strtolower($const) . '">' . img_picto($langs->trans("Enabled"), 'switch_on') . '</a>';
            }
        }
        print "</td>";
        print '</tr>';
    }
    print '</table>' . "\n";
    print '<br>' . "\n";
    print_fiche_titre($langs->trans("TestSubmitForm"), '(mode=' . $mode . ')', '');
    print '<form name="formtest" method="POST" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
    print '<input type="hidden" name="mode" value="' . dol_escape_htmltag($mode) . '">';
    $uselocalbrowser = true;
    $readonly = $mode == 'dolibarr_readonly' ? 1 : 0;
    $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly);
    $editor->Create();
    print '<center><br><input class="button" type="submit" name="save" value="' . $langs->trans("Save") . '"></center>' . "\n";
    print '<div id="divforlog"></div>';
    print '</form>' . "\n";
    // Add env of ckeditor
    // This is to show how CKEditor detect browser to understand why editor is disabled or not
    if (1 == 2) {
        print '<br><script language="javascript">
	    function jsdump(obj, id) {
		    var out = \'\';
		    for (var i in obj) {
		        out += i + ": " + obj[i] + "<br>\\n";
		    }

		    jQuery("#"+id).html(out);
コード例 #6
0
 /**
  *	Get the form to input an email
  *  this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
  *
  *	@param	string	$addfileaction		Name of action when posting file attachments
  *	@param	string	$removefileaction	Name of action when removing file attachments
  *	@return string						Form to show
  */
 function get_form($addfileaction = 'addfile', $removefileaction = 'removefile')
 {
     global $conf, $langs, $user, $hookmanager, $form;
     if (!is_object($form)) {
         $form = new Form($this->db);
     }
     $langs->load("other");
     $langs->load("mails");
     $hookmanager->initHooks(array('formmail'));
     $parameters = array('addfileaction' => $addfileaction, 'removefileaction' => $removefileaction);
     $reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this);
     if (!empty($reshook)) {
         return $hookmanager->resPrint;
     } else {
         $out = '';
         // Define list of attached files
         $listofpaths = array();
         $listofnames = array();
         $listofmimes = array();
         if (!empty($_SESSION["listofpaths"])) {
             $listofpaths = explode(';', $_SESSION["listofpaths"]);
         }
         if (!empty($_SESSION["listofnames"])) {
             $listofnames = explode(';', $_SESSION["listofnames"]);
         }
         if (!empty($_SESSION["listofmimes"])) {
             $listofmimes = explode(';', $_SESSION["listofmimes"]);
         }
         $out .= "\n<!-- Debut form mail -->\n";
         if ($this->withform == 1) {
             $out .= '<form method="POST" name="mailform" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">' . "\n";
             $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />';
         }
         foreach ($this->param as $key => $value) {
             $out .= '<input type="hidden" id="' . $key . '" name="' . $key . '" value="' . $value . '" />' . "\n";
         }
         $out .= '<table class="border" width="100%">' . "\n";
         // Substitution array
         if (!empty($this->withsubstit)) {
             $out .= '<tr><td colspan="2">';
             $help = "";
             foreach ($this->substit as $key => $val) {
                 $help .= $key . ' -> ' . $langs->trans($val) . '<br>';
             }
             $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help);
             $out .= "</td></tr>\n";
         }
         // From
         if (!empty($this->withfrom)) {
             if (!empty($this->withfromreadonly)) {
                 $out .= '<input type="hidden" id="fromname" name="fromname" value="' . $this->fromname . '" />';
                 $out .= '<input type="hidden" id="frommail" name="frommail" value="' . $this->frommail . '" />';
                 $out .= '<tr><td width="180">' . $langs->trans("MailFrom") . '</td><td>';
                 if ($this->fromtype == 'user' && $this->fromid > 0) {
                     $langs->load("users");
                     $fuser = new User($this->db);
                     $fuser->fetch($this->fromid);
                     $out .= $fuser->getNomUrl(1);
                 } else {
                     $out .= $this->fromname;
                 }
                 if ($this->frommail) {
                     $out .= " &lt;" . $this->frommail . "&gt;";
                 } else {
                     if ($this->fromtype) {
                         $langs->load("errors");
                         $out .= '<font class="warning"> &lt;' . $langs->trans("ErrorNoMailDefinedForThisUser") . '&gt; </font>';
                     }
                 }
                 $out .= "</td></tr>\n";
                 $out .= "</td></tr>\n";
             } else {
                 $out .= "<tr><td>" . $langs->trans("MailFrom") . "</td><td>";
                 $out .= $langs->trans("Name") . ':<input type="text" id="fromname" name="fromname" size="32" value="' . $this->fromname . '" />';
                 $out .= '&nbsp; &nbsp; ';
                 $out .= $langs->trans("EMail") . ':&lt;<input type="text" id="frommail" name="frommail" size="32" value="' . $this->frommail . '" />&gt;';
                 $out .= "</td></tr>\n";
             }
         }
         // Replyto
         if (!empty($this->withreplyto)) {
             if ($this->withreplytoreadonly) {
                 $out .= '<input type="hidden" id="replyname" name="replyname" value="' . $this->replytoname . '" />';
                 $out .= '<input type="hidden" id="replymail" name="replymail" value="' . $this->replytomail . '" />';
                 $out .= "<tr><td>" . $langs->trans("MailReply") . "</td><td>" . $this->replytoname . ($this->replytomail ? " &lt;" . $this->replytomail . "&gt;" : "");
                 $out .= "</td></tr>\n";
             }
         }
         // Errorsto
         if (!empty($this->witherrorsto)) {
             //if (! $this->errorstomail) $this->errorstomail=$this->frommail;
             $errorstomail = !empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail;
             if ($this->witherrorstoreadonly) {
                 $out .= '<input type="hidden" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />';
                 $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>';
                 $out .= $errorstomail;
                 $out .= "</td></tr>\n";
             } else {
                 $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>';
                 $out .= '<input size="30" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />';
                 $out .= "</td></tr>\n";
             }
         }
         // To
         if (!empty($this->withto) || is_array($this->withto)) {
             $out .= '<tr><td width="180">';
             if ($this->withtofree) {
                 $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
             } else {
                 $out .= $langs->trans("MailTo");
             }
             $out .= '</td><td>';
             if ($this->withtoreadonly) {
                 if (!empty($this->toname) && !empty($this->tomail)) {
                     $out .= '<input type="hidden" id="toname" name="toname" value="' . $this->toname . '" />';
                     $out .= '<input type="hidden" id="tomail" name="tomail" value="' . $this->tomail . '" />';
                     if ($this->totype == 'thirdparty') {
                         $soc = new Societe($this->db);
                         $soc->fetch($this->toid);
                         $out .= $soc->getNomUrl(1);
                     } else {
                         if ($this->totype == 'contact') {
                             $contact = new Contact($this->db);
                             $contact->fetch($this->toid);
                             $out .= $contact->getNomUrl(1);
                         } else {
                             $out .= $this->toname;
                         }
                     }
                     $out .= ' &lt;' . $this->tomail . '&gt;';
                     if ($this->withtofree) {
                         $out .= '<br>' . $langs->trans("or") . ' <input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />';
                     }
                 } else {
                     $out .= !is_array($this->withto) && !is_numeric($this->withto) ? $this->withto : "";
                 }
             } else {
                 if (!empty($this->withtofree)) {
                     $out .= '<input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />';
                 }
                 if (!empty($this->withto) && is_array($this->withto)) {
                     if (!empty($this->withtofree)) {
                         $out .= " " . $langs->trans("or") . " ";
                     }
                     $out .= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1);
                 }
                 if (isset($this->withtosocid) && $this->withtosocid > 0) {
                     $liste = array();
                     $soc = new Societe($this->db);
                     $soc->fetch($this->withtosocid);
                     foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) {
                         $liste[$key] = $value;
                     }
                     if ($this->withtofree) {
                         $out .= " " . $langs->trans("or") . " ";
                     }
                     $out .= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1);
                 }
             }
             $out .= "</td></tr>\n";
         }
         // CC
         if (!empty($this->withtocc) || is_array($this->withtocc)) {
             $out .= '<tr><td width="180">';
             $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
             $out .= '</td><td>';
             if ($this->withtoccreadonly) {
                 $out .= !is_array($this->withtocc) && !is_numeric($this->withtocc) ? $this->withtocc : "";
             } else {
                 $out .= '<input size="' . (is_array($this->withtocc) ? "30" : "60") . '" id="sendtocc" name="sendtocc" value="' . (!is_array($this->withtocc) && !is_numeric($this->withtocc) ? isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : $this->withtocc : (isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : "")) . '" />';
                 if (!empty($this->withtocc) && is_array($this->withtocc)) {
                     $out .= " " . $langs->trans("or") . " ";
                     $out .= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1);
                 }
             }
             $out .= "</td></tr>\n";
         }
         // CCC
         if (!empty($this->withtoccc) || is_array($this->withtoccc)) {
             $out .= '<tr><td width="180">';
             $out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
             $out .= '</td><td>';
             if (!empty($this->withtocccreadonly)) {
                 $out .= !is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? $this->withtoccc : "";
             } else {
                 $out .= '<input size="' . (is_array($this->withtoccc) ? "30" : "60") . '" id="sendtoccc" name="sendtoccc" value="' . (!is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : $this->withtoccc : (isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : "")) . '" />';
                 if (!empty($this->withtoccc) && is_array($this->withtoccc)) {
                     $out .= " " . $langs->trans("or") . " ";
                     $out .= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1);
                 }
             }
             //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1);
             $out .= "</td></tr>\n";
         }
         // Ask delivery receipt
         if (!empty($this->withdeliveryreceipt)) {
             $out .= '<tr><td width="180">' . $langs->trans("DeliveryReceipt") . '</td><td>';
             if (!empty($this->withdeliveryreceiptreadonly)) {
                 $out .= yn($this->withdeliveryreceipt);
             } else {
                 $out .= $form->selectyesno('deliveryreceipt', isset($_POST["deliveryreceipt"]) ? $_POST["deliveryreceipt"] : 0, 1);
             }
             $out .= "</td></tr>\n";
         }
         // Topic
         if (!empty($this->withtopic)) {
             $this->withtopic = make_substitutions($this->withtopic, $this->substit);
             $out .= '<tr>';
             $out .= '<td width="180">' . $langs->trans("MailTopic") . '</td>';
             $out .= '<td>';
             if ($this->withtopicreadonly) {
                 $out .= $this->withtopic;
                 $out .= '<input type="hidden" size="60" id="subject" name="subject" value="' . $this->withtopic . '" />';
             } else {
                 $out .= '<input type="text" size="60" id="subject" name="subject" value="' . (isset($_POST["subject"]) ? $_POST["subject"] : (is_numeric($this->withtopic) ? '' : $this->withtopic)) . '" />';
             }
             $out .= "</td></tr>\n";
         }
         // Attached files
         if (!empty($this->withfile)) {
             $out .= '<tr>';
             $out .= '<td width="180">' . $langs->trans("MailFile") . '</td>';
             $out .= '<td>';
             if (is_numeric($this->withfile)) {
                 // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
                 $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . "\n";
                 $out .= '<script type="text/javascript" language="javascript">';
                 $out .= 'jQuery(document).ready(function () {';
                 $out .= '    jQuery(".removedfile").click(function() {';
                 $out .= '        jQuery(".removedfilehidden").val(jQuery(this).val());';
                 $out .= '    });';
                 $out .= '})';
                 $out .= '</script>' . "\n";
                 if (count($listofpaths)) {
                     foreach ($listofpaths as $key => $val) {
                         $out .= '<div id="attachfile_' . $key . '">';
                         $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key];
                         if (!$this->withfilereadonly) {
                             $out .= ' <input type="image" style="border: 0px;" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/delete.png" value="' . ($key + 1) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />';
                             //$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
                         }
                         $out .= '<br></div>';
                     }
                 } else {
                     $out .= $langs->trans("NoAttachedFiles") . '<br>';
                 }
                 if ($this->withfile == 2) {
                     $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs->trans("Upload") . '" />';
                     $out .= ' ';
                     $out .= '<input type="submit" class="button" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs->trans("MailingAddFile") . '" />';
                 }
             } else {
                 $out .= $this->withfile;
             }
             $out .= "</td></tr>\n";
         }
         // Message
         if (!empty($this->withbody)) {
             $defaultmessage = "";
             // TODO    A partir du type, proposer liste de messages dans table llx_c_email_template
             if ($this->param["models"] == 'facture_send') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentSendInvoice");
             } elseif ($this->param["models"] == 'facture_relance') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentSendInvoiceReminder");
             } elseif ($this->param["models"] == 'propal_send') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentSendProposal");
             } elseif ($this->param["models"] == 'order_send') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentSendOrder");
             } elseif ($this->param["models"] == 'order_supplier_send') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentSendSupplierOrder");
             } elseif ($this->param["models"] == 'invoice_supplier_send') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentSendSupplierInvoice");
             } elseif ($this->param["models"] == 'shipping_send') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentSendShipping");
             } elseif ($this->param["models"] == 'fichinter_send') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentSendFichInter");
             } elseif ($this->param["models"] == 'thirdparty') {
                 $defaultmessage = $langs->transnoentities("PredefinedMailContentThirdparty");
             } elseif (!is_numeric($this->withbody)) {
                 $defaultmessage = $this->withbody;
             }
             // Complete substitution array
             if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) {
                 require_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';
                 $langs->load('paypal');
                 if ($this->param["models"] == 'order_send') {
                     $url = getPaypalPaymentUrl(0, 'order', $this->substit['__ORDERREF__']);
                     $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url));
                 }
                 if ($this->param["models"] == 'facture_send') {
                     $url = getPaypalPaymentUrl(0, 'invoice', $this->substit['__FACREF__']);
                     $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url));
                 }
             }
             $defaultmessage = str_replace('\\n', "\n", $defaultmessage);
             // Deal with format differences between message and signature (text / HTML)
             if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) {
                 $this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']);
             } else {
                 if (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) {
                     $defaultmessage = dol_nl2br($defaultmessage);
                 }
             }
             if (isset($_POST["message"])) {
                 $defaultmessage = $_POST["message"];
             } else {
                 $defaultmessage = make_substitutions($defaultmessage, $this->substit);
                 // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty)
                 $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage);
                 $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage);
             }
             $out .= '<tr>';
             $out .= '<td width="180" valign="top">' . $langs->trans("MailText") . '</td>';
             $out .= '<td>';
             if ($this->withbodyreadonly) {
                 $out .= nl2br($defaultmessage);
                 $out .= '<input type="hidden" id="message" name="message" value="' . $defaultmessage . '" />';
             } else {
                 if (!isset($this->ckeditortoolbar)) {
                     $this->ckeditortoolbar = 'dolibarr_notes';
                 }
                 // Editor wysiwyg
                 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
                 if ($this->withfckeditor == -1) {
                     if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
                         $this->withfckeditor = 1;
                     } else {
                         $this->withfckeditor = 0;
                     }
                 }
                 $doleditor = new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, 72);
                 $out .= $doleditor->Create(1);
             }
             $out .= "</td></tr>\n";
         }
         if ($this->withform == 1 || $this->withform == -1) {
             $out .= '<tr><td align="center" colspan="2"><center>';
             $out .= '<input class="button" type="submit" id="sendmail" name="sendmail" value="' . $langs->trans("SendMail") . '"';
             // Add a javascript test to avoid to forget to submit file before sending email
             if ($this->withfile == 2 && $conf->use_javascript_ajax) {
                 $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\'' . dol_escape_js($langs->trans("FileWasNotUploaded")) . '\'); return false; } else { return true; }"';
             }
             $out .= ' />';
             if ($this->withcancel) {
                 $out .= ' &nbsp; &nbsp; ';
                 $out .= '<input class="button" type="submit" id="cancel" name="cancel" value="' . $langs->trans("Cancel") . '" />';
             }
             $out .= '</center></td></tr>' . "\n";
         }
         $out .= '</table>' . "\n";
         if ($this->withform == 1) {
             $out .= '</form>' . "\n";
         }
         $out .= "<!-- Fin form mail -->\n";
         return $out;
     }
 }
コード例 #7
0
ファイル: adherent.php プロジェクト: ripasch/dolibarr
function form_constantes($tableau)
{
    global $db, $bc, $langs, $conf, $_Avery_Labels;
    $form = new Form($db);
    print '<table class="noborder" width="100%">';
    print '<tr class="liste_titre">';
    print '<td>' . $langs->trans("Description") . '</td>';
    print '<td>' . $langs->trans("Value") . '*</td>';
    print '<td>&nbsp;</td>';
    print '<td align="center" width="80">' . $langs->trans("Action") . '</td>';
    print "</tr>\n";
    $var = true;
    $listofparam = array();
    foreach ($tableau as $const) {
        $sql = "SELECT ";
        $sql .= "rowid";
        $sql .= ", " . $db->decrypt('name') . " as name";
        $sql .= ", " . $db->decrypt('value') . " as value";
        $sql .= ", type";
        $sql .= ", note";
        $sql .= " FROM " . MAIN_DB_PREFIX . "const";
        $sql .= " WHERE " . $db->decrypt('name') . " = '" . $const . "'";
        $sql .= " AND entity in (0, " . $conf->entity . ")";
        $sql .= " ORDER BY name ASC, entity DESC";
        $result = $db->query($sql);
        dol_syslog("List params sql=" . $sql);
        if ($result) {
            $obj = $db->fetch_object($result);
            // Take first result of select
            $var = !$var;
            print "\n" . '<form action="adherent.php" method="POST">';
            print "<tr " . $bc[$var] . ">";
            // Affiche nom constante
            print '<td>';
            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
            print '<input type="hidden" name="action" value="update">';
            print '<input type="hidden" name="rowid" value="' . $rowid . '">';
            print '<input type="hidden" name="constname" value="' . $const . '">';
            print '<input type="hidden" name="constnote" value="' . nl2br($obj->note) . '">';
            print $langs->trans("Desc" . $const) != "Desc" . $const ? $langs->trans("Desc" . $const) : ($obj->note ? $obj->note : $const);
            if ($const == 'ADHERENT_MAILMAN_URL') {
                print '. ' . $langs->trans("Example") . ': <a href="#" id="exampleclick1">' . img_down() . '</a><br>';
                //print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&subscribees=%EMAIL%&send_welcome_msg_to_this_batch=1';
                print '<div id="example1" class="hidden">';
                print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&subscribe_or_invite=0&send_welcome_msg_to_this_batch=0&notification_to_list_owner=0';
                print '</div>';
            }
            if ($const == 'ADHERENT_MAILMAN_UNSUB_URL') {
                print '. ' . $langs->trans("Example") . ': <a href="#" id="exampleclick2">' . img_down() . '</a><br>';
                print '<div id="example2" class="hidden">';
                print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&send_unsub_ack_to_this_batch=0&send_unsub_notifications_to_list_owner=0';
                print '</div>';
                //print 'http://lists.domain.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
            }
            print "</td>\n";
            if ($const == 'ADHERENT_CARD_TYPE' || $const == 'ADHERENT_ETIQUETTE_TYPE') {
                print '<td>';
                // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php)
                require_once DOL_DOCUMENT_ROOT . '/lib/format_cards.lib.php';
                $arrayoflabels = array();
                foreach (array_keys($_Avery_Labels) as $codecards) {
                    $arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name'];
                }
                print $form->selectarray('constvalue', $arrayoflabels, $obj->value ? $obj->value : 'CARD', 1, 0, 0);
                print '</td><td>';
                print '<input type="hidden" name="consttype" value="yesno">';
                print '</td>';
            } else {
                print '<td>';
                //print 'aa'.$const;
                if (in_array($const, array('ADHERENT_CARD_TEXT', 'ADHERENT_CARD_TEXT_RIGHT'))) {
                    print '<textarea class="flat" name="constvalue" cols="35" rows="5" wrap="soft">' . "\n";
                    print $obj->value;
                    print "</textarea>\n";
                    print '</td><td>';
                    print '<input type="hidden" name="consttype" value="texte">';
                } else {
                    if (in_array($const, array('ADHERENT_AUTOREGISTER_MAIL', 'ADHERENT_MAIL_VALID', 'ADHERENT_MAIL_COTIS', 'ADHERENT_MAIL_RESIL'))) {
                        require_once DOL_DOCUMENT_ROOT . "/lib/doleditor.class.php";
                        $doleditor = new DolEditor('constvalue_' . $const, $obj->value, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, 5, 60);
                        $doleditor->Create();
                        print '</td><td>';
                        print '<input type="hidden" name="consttype" value="texte">';
                    } else {
                        if ($obj->type == 'yesno') {
                            print $form->selectyesno('constvalue', $obj->value, 1);
                            print '</td><td>';
                            print '<input type="hidden" name="consttype" value="yesno">';
                        } else {
                            print '<input type="text" class="flat" size="48" name="constvalue" value="' . $obj->value . '">';
                            print '</td><td>';
                            print '<input type="hidden" name="consttype" value="chaine">';
                        }
                    }
                }
                print '</td>';
            }
            print '<td align="center">';
            print '<input type="submit" class="button" value="' . $langs->trans("Update") . '" name="Button"> &nbsp;';
            // print '<a href="adherent.php?name='.$const.'&action=unset">'.img_delete().'</a>';
            print "</td>";
            print "</tr>\n";
            print "</form>\n";
            $i++;
        }
    }
    print '</table>';
}
コード例 #8
0
ファイル: create_survey.php プロジェクト: Albertopf/prueba
$arrayofjs = array();
$arrayofcss = array('/opensurvey/css/style.css');
llxHeader('', $langs->trans("OpenSurvey"), '', "", 0, 0, $arrayofjs, $arrayofcss);
print load_fiche_titre($langs->trans("CreatePoll") . ' (1 / 2)');
//debut du formulaire
print '<form name="formulaire" action="" method="POST">' . "\n";
dol_fiche_head();
//Affichage des différents champs textes a remplir
print '<table class="border" width="100%">' . "\n";
print '<tr><td class="fieldrequired">' . $langs->trans("PollTitle") . '</td><td><input type="text" name="titre" size="40" maxlength="80" value="' . $_SESSION["titre"] . '"></td>' . "\n";
if (!$_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) {
    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors');
}
print '</tr>' . "\n";
print '<tr><td>' . $langs->trans("Description") . '</td><td>';
$doleditor = new DolEditor('commentaires', $_SESSION["commentaires"], '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, 120);
$doleditor->Create(0, '');
print '</td>' . "\n";
print '</tr>' . "\n";
print '<tr><td class="fieldrequired">' . $langs->trans("ExpireDate") . '</td><td>';
print $form->select_date($champdatefin ? $champdatefin : -1, 'champdatefin', '', '', '', "add", 1, 0, 1);
print '</tr>' . "\n";
print '</table>' . "\n";
dol_fiche_end();
//focus javascript sur le premier champ
print '<script type="text/javascript">' . "\n";
print 'document.formulaire.titre.focus();' . "\n";
print '</script>' . "\n";
print '<br>' . "\n";
// Check or not
if ($_SESSION["mailsonde"]) {
コード例 #9
0
/**
 *	Show array with constants to edit
 *
 *	@param	array	$tableau		Array of constants
 *	@param	int		$strictw3c		0=Include form into table (deprecated), 1=Form is outside table to respect W3C (no form into table), 2=No form nor button at all
 *	@return	void
 */
function form_constantes($tableau, $strictw3c = 0)
{
    global $db, $bc, $langs, $conf, $_Avery_Labels;
    $form = new Form($db);
    if (!empty($strictw3c) && $strictw3c == 1) {
        print "\n" . '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
    }
    print '<table class="noborder" width="100%">';
    print '<tr class="liste_titre">';
    print '<td>' . $langs->trans("Description") . '</td>';
    print '<td>' . $langs->trans("Value") . '*</td>';
    if (empty($strictw3c)) {
        print '<td align="center" width="80">' . $langs->trans("Action") . '</td>';
    }
    print "</tr>\n";
    $var = true;
    $listofparam = array();
    foreach ($tableau as $const) {
        $sql = "SELECT ";
        $sql .= "rowid";
        $sql .= ", " . $db->decrypt('name') . " as name";
        $sql .= ", " . $db->decrypt('value') . " as value";
        $sql .= ", type";
        $sql .= ", note";
        $sql .= " FROM " . MAIN_DB_PREFIX . "const";
        $sql .= " WHERE " . $db->decrypt('name') . " = '" . $const . "'";
        $sql .= " AND entity IN (0, " . $conf->entity . ")";
        $sql .= " ORDER BY name ASC, entity DESC";
        $result = $db->query($sql);
        dol_syslog("List params", LOG_DEBUG);
        if ($result) {
            $obj = $db->fetch_object($result);
            // Take first result of select
            $var = !$var;
            // For avoid warning in strict mode
            if (empty($obj)) {
                $obj = (object) array('rowid' => '', 'name' => '', 'value' => '', 'type' => '', 'note' => '');
            }
            if (empty($strictw3c)) {
                print "\n" . '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
            }
            print "<tr " . $bc[$var] . ">";
            // Show constant
            print '<td>';
            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
            print '<input type="hidden" name="action" value="update">';
            print '<input type="hidden" name="rowid' . (empty($strictw3c) ? '' : '[]') . '" value="' . $obj->rowid . '">';
            print '<input type="hidden" name="constname' . (empty($strictw3c) ? '' : '[]') . '" value="' . $const . '">';
            print '<input type="hidden" name="constnote' . (empty($strictw3c) ? '' : '[]') . '" value="' . nl2br(dol_escape_htmltag($obj->note)) . '">';
            print $langs->trans('Desc' . $const);
            if ($const == 'ADHERENT_MAILMAN_URL') {
                print '. ' . $langs->trans("Example") . ': <a href="#" id="exampleclick1">' . img_down() . '</a><br>';
                //print 'http://lists.exampe.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&subscribees=%EMAIL%&send_welcome_msg_to_this_batch=1';
                print '<div id="example1" class="hidden">';
                print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&amp;adminpw=%MAILMAN_ADMINPW%&amp;subscribe_or_invite=0&amp;send_welcome_msg_to_this_batch=0&amp;notification_to_list_owner=0';
                print '</div>';
            }
            if ($const == 'ADHERENT_MAILMAN_UNSUB_URL') {
                print '. ' . $langs->trans("Example") . ': <a href="#" id="exampleclick2">' . img_down() . '</a><br>';
                print '<div id="example2" class="hidden">';
                print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&amp;adminpw=%MAILMAN_ADMINPW%&amp;send_unsub_ack_to_this_batch=0&amp;send_unsub_notifications_to_list_owner=0';
                print '</div>';
                //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
            }
            if ($const == 'ADHERENT_MAILMAN_LISTS') {
                print '. ' . $langs->trans("Example") . ': <a href="#" id="exampleclick3">' . img_down() . '</a><br>';
                print '<div id="example3" class="hidden">';
                print 'mymailmanlist<br>';
                print 'mymailmanlist1,mymailmanlist2<br>';
                print 'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
                if ($conf->categorie->enabled) {
                    print 'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
                }
                print '</div>';
                //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?adminpw=%MAILMAN_ADMINPW%&unsubscribees=%EMAIL%';
            }
            print "</td>\n";
            // Value
            if ($const == 'ADHERENT_CARD_TYPE' || $const == 'ADHERENT_ETIQUETTE_TYPE') {
                print '<td>';
                // List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php)
                require_once DOL_DOCUMENT_ROOT . '/core/lib/format_cards.lib.php';
                $arrayoflabels = array();
                foreach (array_keys($_Avery_Labels) as $codecards) {
                    $arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name'];
                }
                print $form->selectarray('constvalue' . (empty($strictw3c) ? '' : '[]'), $arrayoflabels, $obj->value ? $obj->value : 'CARD', 1, 0, 0);
                print '<input type="hidden" name="consttype" value="yesno">';
                print '</td>';
            } else {
                print '<td>';
                if (in_array($const, array('ADHERENT_CARD_TEXT', 'ADHERENT_CARD_TEXT_RIGHT', 'ADHERENT_ETIQUETTE_TEXT'))) {
                    print '<textarea class="flat" name="constvalue' . (empty($strictw3c) ? '' : '[]') . '" cols="50" rows="5" wrap="soft">' . "\n";
                    print $obj->value;
                    print "</textarea>\n";
                    print '<input type="hidden" name="consttype" value="texte">';
                } else {
                    if (in_array($const, array('ADHERENT_AUTOREGISTER_NOTIF_MAIL', 'ADHERENT_AUTOREGISTER_MAIL', 'ADHERENT_MAIL_VALID', 'ADHERENT_MAIL_COTIS', 'ADHERENT_MAIL_RESIL'))) {
                        require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
                        $doleditor = new DolEditor('constvalue_' . $const . (empty($strictw3c) ? '' : '[]'), $obj->value, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, 5, 60);
                        $doleditor->Create();
                        print '<input type="hidden" name="consttype' . (empty($strictw3c) ? '' : '[]') . '" value="texte">';
                    } else {
                        if ($obj->type == 'yesno') {
                            print $form->selectyesno('constvalue' . (empty($strictw3c) ? '' : '[]'), $obj->value, 1);
                            print '<input type="hidden" name="consttype' . (empty($strictw3c) ? '' : '[]') . '" value="yesno">';
                        } else {
                            print '<input type="text" class="flat" size="48" name="constvalue' . (empty($strictw3c) ? '' : '[]') . '" value="' . dol_escape_htmltag($obj->value) . '">';
                            print '<input type="hidden" name="consttype' . (empty($strictw3c) ? '' : '[]') . '" value="chaine">';
                        }
                    }
                }
                print '</td>';
            }
            // Submit
            if (empty($strictw3c)) {
                print '<td align="center">';
                print '<input type="submit" class="button" value="' . $langs->trans("Update") . '" name="Button">';
                print "</td>";
            }
            print "</tr>\n";
            if (empty($strictw3c)) {
                print "</form>\n";
            }
        }
    }
    print '</table>';
    if (!empty($strictw3c) && $strictw3c == 1) {
        print '<div align="center"><input type="submit" class="button" value="' . $langs->trans("Update") . '" name="update"></div>';
        print "</form>\n";
    }
}
コード例 #10
0
    /**
     *	Get the form to input an email
     *  this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
     *  this->param:	Contains more parameteres like email templates info
     *
     *	@param	string	$addfileaction		Name of action when posting file attachments
     *	@param	string	$removefileaction	Name of action when removing file attachments
     *	@return string						Form to show
     */
    function get_form($addfileaction = 'addfile', $removefileaction = 'removefile')
    {
        global $conf, $langs, $user, $hookmanager, $form;
        if (!is_object($form)) {
            $form = new Form($this->db);
        }
        $langs->load("other");
        $langs->load("mails");
        $hookmanager->initHooks(array('formmail'));
        $parameters = array('addfileaction' => $addfileaction, 'removefileaction' => $removefileaction);
        $reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this);
        if (!empty($reshook)) {
            return $hookmanager->resPrint;
        } else {
            $out = '';
            // Define list of attached files
            $listofpaths = array();
            $listofnames = array();
            $listofmimes = array();
            if (!empty($_SESSION["listofpaths"])) {
                $listofpaths = explode(';', $_SESSION["listofpaths"]);
            }
            if (!empty($_SESSION["listofnames"])) {
                $listofnames = explode(';', $_SESSION["listofnames"]);
            }
            if (!empty($_SESSION["listofmimes"])) {
                $listofmimes = explode(';', $_SESSION["listofmimes"]);
            }
            // Define output language
            $outputlangs = $langs;
            $newlang = '';
            if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
                $newlang = $this->param['langsmodels'];
            }
            if (!empty($newlang)) {
                $outputlangs = new Translate("", $conf);
                $outputlangs->setDefaultLang($newlang);
                $outputlangs->load('other');
            }
            // Get message template
            $model_id = 0;
            if (array_key_exists('models_id', $this->param)) {
                $model_id = $this->param["models_id"];
            }
            $arraydefaultmessage = $this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
            //var_dump($arraydefaultmessage);
            $out .= "\n<!-- Begin form mail -->\n";
            if ($this->withform == 1) {
                $out .= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '#formmail">' . "\n";
                $out .= '<input style="display:none" type="submit" id="sendmail" name="sendmail">';
                $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />';
                $out .= '<input type="hidden" name="trackid" value="' . $this->trackid . '" />';
                $out .= '<a id="formmail" name="formmail"></a>';
            }
            foreach ($this->param as $key => $value) {
                $out .= '<input type="hidden" id="' . $key . '" name="' . $key . '" value="' . $value . '" />' . "\n";
            }
            $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
            if ($result < 0) {
                setEventMessage($this->error, 'errors');
            }
            $modelmail_array = array();
            foreach ($this->lines_model as $line) {
                $modelmail_array[$line->id] = $line->label;
            }
            // Zone to select its email template
            if (count($modelmail_array) > 0) {
                $out .= '<div style="padding: 3px 0 3px 0">' . "\n";
                $out .= $langs->trans('SelectMailModel') . ': ' . $this->selectarray('modelmailselected', $modelmail_array, 0, 1);
                if ($user->admin) {
                    $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
                }
                $out .= ' &nbsp; ';
                $out .= '<input class="button" type="submit" value="' . $langs->trans('Valid') . '" name="modelselected" id="modelselected">';
                $out .= ' &nbsp; ';
                $out .= '</div>';
            }
            $out .= '<table class="border" width="100%">' . "\n";
            // Substitution array
            if (!empty($this->withsubstit)) {
                $out .= '<tr><td colspan="2">';
                $help = "";
                foreach ($this->substit as $key => $val) {
                    $help .= $key . ' -> ' . $langs->trans($val) . '<br>';
                }
                $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help);
                $out .= "</td></tr>\n";
            }
            // From
            if (!empty($this->withfrom)) {
                if (!empty($this->withfromreadonly)) {
                    $out .= '<input type="hidden" id="fromname" name="fromname" value="' . $this->fromname . '" />';
                    $out .= '<input type="hidden" id="frommail" name="frommail" value="' . $this->frommail . '" />';
                    $out .= '<tr><td width="180">' . $langs->trans("MailFrom") . '</td><td>';
                    if ($this->fromtype == 'user' && $this->fromid > 0) {
                        $langs->load("users");
                        $fuser = new User($this->db);
                        $fuser->fetch($this->fromid);
                        $out .= $fuser->getNomUrl(1);
                    } else {
                        $out .= $this->fromname;
                    }
                    if ($this->frommail) {
                        $out .= " &lt;" . $this->frommail . "&gt;";
                    } else {
                        if ($this->fromtype) {
                            $langs->load("errors");
                            $out .= '<font class="warning"> &lt;' . $langs->trans("ErrorNoMailDefinedForThisUser") . '&gt; </font>';
                        }
                    }
                    $out .= "</td></tr>\n";
                    $out .= "</td></tr>\n";
                } else {
                    $out .= "<tr><td>" . $langs->trans("MailFrom") . "</td><td>";
                    $out .= $langs->trans("Name") . ':<input type="text" id="fromname" name="fromname" size="32" value="' . $this->fromname . '" />';
                    $out .= '&nbsp; &nbsp; ';
                    $out .= $langs->trans("EMail") . ':&lt;<input type="text" id="frommail" name="frommail" size="32" value="' . $this->frommail . '" />&gt;';
                    $out .= "</td></tr>\n";
                }
            }
            // Replyto
            if (!empty($this->withreplyto)) {
                if ($this->withreplytoreadonly) {
                    $out .= '<input type="hidden" id="replyname" name="replyname" value="' . $this->replytoname . '" />';
                    $out .= '<input type="hidden" id="replymail" name="replymail" value="' . $this->replytomail . '" />';
                    $out .= "<tr><td>" . $langs->trans("MailReply") . "</td><td>" . $this->replytoname . ($this->replytomail ? " &lt;" . $this->replytomail . "&gt;" : "");
                    $out .= "</td></tr>\n";
                }
            }
            // Errorsto
            if (!empty($this->witherrorsto)) {
                //if (! $this->errorstomail) $this->errorstomail=$this->frommail;
                $errorstomail = !empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail;
                if ($this->witherrorstoreadonly) {
                    $out .= '<input type="hidden" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />';
                    $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>';
                    $out .= $errorstomail;
                    $out .= "</td></tr>\n";
                } else {
                    $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>';
                    $out .= '<input size="30" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />';
                    $out .= "</td></tr>\n";
                }
            }
            // To
            if (!empty($this->withto) || is_array($this->withto)) {
                $out .= '<tr><td width="180">';
                if ($this->withtofree) {
                    $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
                } else {
                    $out .= $langs->trans("MailTo");
                }
                $out .= '</td><td>';
                if ($this->withtoreadonly) {
                    if (!empty($this->toname) && !empty($this->tomail)) {
                        $out .= '<input type="hidden" id="toname" name="toname" value="' . $this->toname . '" />';
                        $out .= '<input type="hidden" id="tomail" name="tomail" value="' . $this->tomail . '" />';
                        if ($this->totype == 'thirdparty') {
                            $soc = new Societe($this->db);
                            $soc->fetch($this->toid);
                            $out .= $soc->getNomUrl(1);
                        } else {
                            if ($this->totype == 'contact') {
                                $contact = new Contact($this->db);
                                $contact->fetch($this->toid);
                                $out .= $contact->getNomUrl(1);
                            } else {
                                $out .= $this->toname;
                            }
                        }
                        $out .= ' &lt;' . $this->tomail . '&gt;';
                        if ($this->withtofree) {
                            $out .= '<br>' . $langs->trans("or") . ' <input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />';
                        }
                    } else {
                        $out .= !is_array($this->withto) && !is_numeric($this->withto) ? $this->withto : "";
                    }
                } else {
                    if (!empty($this->withtofree)) {
                        $out .= '<input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />';
                    }
                    if (!empty($this->withto) && is_array($this->withto)) {
                        if (!empty($this->withtofree)) {
                            $out .= " " . $langs->trans("or") . " ";
                        }
                        $out .= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1);
                    }
                    if (isset($this->withtosocid) && $this->withtosocid > 0) {
                        $liste = array();
                        $soc = new Societe($this->db);
                        $soc->fetch($this->withtosocid);
                        foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) {
                            $liste[$key] = $value;
                        }
                        if ($this->withtofree) {
                            $out .= " " . $langs->trans("or") . " ";
                        }
                        $out .= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1);
                    }
                }
                $out .= "</td></tr>\n";
            }
            // CC
            if (!empty($this->withtocc) || is_array($this->withtocc)) {
                $out .= '<tr><td width="180">';
                $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
                $out .= '</td><td>';
                if ($this->withtoccreadonly) {
                    $out .= !is_array($this->withtocc) && !is_numeric($this->withtocc) ? $this->withtocc : "";
                } else {
                    $out .= '<input size="' . (is_array($this->withtocc) ? "30" : "60") . '" id="sendtocc" name="sendtocc" value="' . (!is_array($this->withtocc) && !is_numeric($this->withtocc) ? isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : $this->withtocc : (isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : "")) . '" />';
                    if (!empty($this->withtocc) && is_array($this->withtocc)) {
                        $out .= " " . $langs->trans("or") . " ";
                        $out .= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1);
                    }
                }
                $out .= "</td></tr>\n";
            }
            // CCC
            if (!empty($this->withtoccc) || is_array($this->withtoccc)) {
                $out .= '<tr><td width="180">';
                $out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
                $out .= '</td><td>';
                if (!empty($this->withtocccreadonly)) {
                    $out .= !is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? $this->withtoccc : "";
                } else {
                    $out .= '<input size="' . (is_array($this->withtoccc) ? "30" : "60") . '" id="sendtoccc" name="sendtoccc" value="' . (!is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : $this->withtoccc : (isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : "")) . '" />';
                    if (!empty($this->withtoccc) && is_array($this->withtoccc)) {
                        $out .= " " . $langs->trans("or") . " ";
                        $out .= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1);
                    }
                }
                $showinfobcc = '';
                if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') {
                    $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO;
                }
                if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO) && !empty($this->param['models']) && $this->param['models'] == 'askpricesupplier_send') {
                    $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO;
                }
                if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') {
                    $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO;
                }
                if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') {
                    $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO;
                }
                if ($showinfobcc) {
                    $out .= ' + ' . $showinfobcc;
                }
                $out .= "</td></tr>\n";
            }
            // Ask delivery receipt
            if (!empty($this->withdeliveryreceipt)) {
                $out .= '<tr><td width="180">' . $langs->trans("DeliveryReceipt") . '</td><td>';
                if (!empty($this->withdeliveryreceiptreadonly)) {
                    $out .= yn($this->withdeliveryreceipt);
                } else {
                    $defaultvaluefordeliveryreceipt = 0;
                    if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') {
                        $defaultvaluefordeliveryreceipt = 1;
                    }
                    if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ASKPRICESUPPLIER) && !empty($this->param['models']) && $this->param['models'] == 'askpricesupplier_send') {
                        $defaultvaluefordeliveryreceipt = 1;
                    }
                    if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && !empty($this->param['models']) && $this->param['models'] == 'order_send') {
                        $defaultvaluefordeliveryreceipt = 1;
                    }
                    if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') {
                        $defaultvaluefordeliveryreceipt = 1;
                    }
                    $out .= $form->selectyesno('deliveryreceipt', isset($_POST["deliveryreceipt"]) ? $_POST["deliveryreceipt"] : $defaultvaluefordeliveryreceipt, 1);
                }
                $out .= "</td></tr>\n";
            }
            // Topic
            if (!empty($this->withtopic)) {
                $defaulttopic = "";
                if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) {
                    $defaulttopic = $arraydefaultmessage['topic'];
                } elseif (!is_numeric($this->withtopic)) {
                    $defaulttopic = $this->withtopic;
                }
                $defaulttopic = make_substitutions($defaulttopic, $this->substit);
                $out .= '<tr>';
                $out .= '<td width="180">' . $langs->trans("MailTopic") . '</td>';
                $out .= '<td>';
                if ($this->withtopicreadonly) {
                    $out .= $defaulttopic;
                    $out .= '<input type="hidden" size="60" id="subject" name="subject" value="' . $defaulttopic . '" />';
                } else {
                    $out .= '<input type="text" size="60" id="subject" name="subject" value="' . (isset($_POST["subject"]) && !$_POST['modelselected'] ? $_POST["subject"] : ($defaulttopic ? $defaulttopic : '')) . '" />';
                }
                $out .= "</td></tr>\n";
            }
            // Attached files
            if (!empty($this->withfile)) {
                $out .= '<tr>';
                $out .= '<td width="180">' . $langs->trans("MailFile") . '</td>';
                $out .= '<td>';
                if (is_numeric($this->withfile)) {
                    // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
                    $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . "\n";
                    $out .= '<script type="text/javascript" language="javascript">';
                    $out .= 'jQuery(document).ready(function () {';
                    $out .= '    jQuery(".removedfile").click(function() {';
                    $out .= '        jQuery(".removedfilehidden").val(jQuery(this).val());';
                    $out .= '    });';
                    $out .= '})';
                    $out .= '</script>' . "\n";
                    if (count($listofpaths)) {
                        foreach ($listofpaths as $key => $val) {
                            $out .= '<div id="attachfile_' . $key . '">';
                            $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key];
                            if (!$this->withfilereadonly) {
                                $out .= ' <input type="image" style="border: 0px;" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/delete.png" value="' . ($key + 1) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />';
                                //$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
                            }
                            $out .= '<br></div>';
                        }
                    } else {
                        $out .= $langs->trans("NoAttachedFiles") . '<br>';
                    }
                    if ($this->withfile == 2) {
                        $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs->trans("Upload") . '" />';
                        $out .= ' ';
                        $out .= '<input type="submit" class="button" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs->trans("MailingAddFile") . '" />';
                    }
                } else {
                    $out .= $this->withfile;
                }
                $out .= "</td></tr>\n";
            }
            // Message
            if (!empty($this->withbody)) {
                $defaultmessage = "";
                if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['content']) {
                    $defaultmessage = $arraydefaultmessage['content'];
                } elseif (!is_numeric($this->withbody)) {
                    $defaultmessage = $this->withbody;
                }
                // Complete substitution array
                if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) {
                    require_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';
                    $langs->load('paypal');
                    if ($this->param["models"] == 'order_send') {
                        $url = getPaypalPaymentUrl(0, 'order', $this->substit['__ORDERREF__']);
                        $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url));
                    }
                    if ($this->param["models"] == 'facture_send') {
                        $url = getPaypalPaymentUrl(0, 'invoice', $this->substit['__FACREF__']);
                        $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url));
                    }
                }
                $defaultmessage = str_replace('\\n', "\n", $defaultmessage);
                // Deal with format differences between message and signature (text / HTML)
                if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) {
                    $this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']);
                } else {
                    if (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) {
                        $defaultmessage = dol_nl2br($defaultmessage);
                    }
                }
                if (isset($_POST["message"]) && !$_POST['modelselected']) {
                    $defaultmessage = $_POST["message"];
                } else {
                    $defaultmessage = make_substitutions($defaultmessage, $this->substit);
                    // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty)
                    $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage);
                    $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage);
                }
                $out .= '<tr>';
                $out .= '<td width="180" valign="top">' . $langs->trans("MailText") . '</td>';
                $out .= '<td>';
                if ($this->withbodyreadonly) {
                    $out .= nl2br($defaultmessage);
                    $out .= '<input type="hidden" id="message" name="message" value="' . $defaultmessage . '" />';
                } else {
                    if (!isset($this->ckeditortoolbar)) {
                        $this->ckeditortoolbar = 'dolibarr_notes';
                    }
                    // Editor wysiwyg
                    require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
                    if ($this->withfckeditor == -1) {
                        if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
                            $this->withfckeditor = 1;
                        } else {
                            $this->withfckeditor = 0;
                        }
                    }
                    $doleditor = new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, 72);
                    $out .= $doleditor->Create(1);
                }
                $out .= "</td></tr>\n";
            }
            if ($this->withform == 1 || $this->withform == -1) {
                $out .= '<tr><td align="center" colspan="2"><div class="center">';
                $out .= '<input class="button" type="submit" id="sendmail" name="sendmail" value="' . $langs->trans("SendMail") . '"';
                // Add a javascript test to avoid to forget to submit file before sending email
                if ($this->withfile == 2 && $conf->use_javascript_ajax) {
                    $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\'' . dol_escape_js($langs->trans("FileWasNotUploaded")) . '\'); return false; } else { return true; }"';
                }
                $out .= ' />';
                if ($this->withcancel) {
                    $out .= ' &nbsp; &nbsp; ';
                    $out .= '<input class="button" type="submit" id="cancel" name="cancel" value="' . $langs->trans("Cancel") . '" />';
                }
                $out .= '</div></td></tr>' . "\n";
            }
            $out .= '</table>' . "\n";
            if ($this->withform == 1) {
                $out .= '</form>' . "\n";
            }
            // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
            if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) {
                $out .= '<script type="text/javascript" language="javascript">';
                $out .= 'jQuery(document).ready(function () {';
                $out .= '	$(document).on("keypress", \'#mailform\', function (e) {		/* Note this is calle at every key pressed ! */
	    						var code = e.keyCode || e.which;
	    						if (code == 13) {
	        						e.preventDefault();
	        						return false;
	    						}
							});';
                $out .= '		})';
                $out .= '</script>';
            }
            $out .= "<!-- End form mail -->\n";
            return $out;
        }
    }
コード例 #11
0
ファイル: html.form.class.php プロジェクト: ADDAdev/Dolibarr
 /**
  * Output val field for an editable field
  *
  * @param	string	$text			Text of label (not used in this function)
  * @param	string	$htmlname		Name of select field
  * @param	string	$value			Value to show/edit
  * @param	object	$object			Object
  * @param	boolean	$perm			Permission to allow button to edit parameter
  * @param	string	$typeofdata		Type of data ('string' by default, 'amount', 'email', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select:xxx'...)
  * @param	string	$editvalue		When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value). Use '' to use same than $value
  * @param	object	$extObject		External object
  * @param	mixed	$custommsg		String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
  * @param	string	$moreparam		More param to add on a href URL
  * @return  string					HTML edit field
  */
 function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '')
 {
     global $conf, $langs, $db;
     $ret = '';
     // Check parameters
     if (empty($typeofdata)) {
         return 'ErrorBadParameter';
     }
     // When option to edit inline is activated
     if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) {
         $ret .= $this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
     } else {
         if (GETPOST('action') == 'edit' . $htmlname) {
             $ret .= "\n";
             $ret .= '<form method="post" action="' . $_SERVER["PHP_SELF"] . ($moreparam ? '?' . $moreparam : '') . '">';
             $ret .= '<input type="hidden" name="action" value="set' . $htmlname . '">';
             $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
             $ret .= '<input type="hidden" name="id" value="' . $object->id . '">';
             $ret .= '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
             $ret .= '<tr><td>';
             if (preg_match('/^(string|email|numeric|amount)/', $typeofdata)) {
                 $tmp = explode(':', $typeofdata);
                 $ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($editvalue ? $editvalue : $value) . '"' . ($tmp[1] ? ' size="' . $tmp[1] . '"' : '') . '>';
             } else {
                 if (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) {
                     $tmp = explode(':', $typeofdata);
                     $ret .= '<textarea id="' . $htmlname . '" name="' . $htmlname . '" wrap="soft" rows="' . ($tmp[1] ? $tmp[1] : '20') . '" cols="' . ($tmp[2] ? $tmp[2] : '100') . '">' . ($editvalue ? $editvalue : $value) . '</textarea>';
                 } else {
                     if ($typeofdata == 'day' || $typeofdata == 'datepicker') {
                         $ret .= $this->form_date($_SERVER['PHP_SELF'] . '?id=' . $object->id, $value, $htmlname);
                     } else {
                         if ($typeofdata == 'datehourpicker') {
                             $ret .= $this->form_date($_SERVER['PHP_SELF'] . '?id=' . $object->id, $value, $htmlname, 1, 1);
                         } else {
                             if (preg_match('/^select;/', $typeofdata)) {
                                 $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
                                 foreach ($arraydata as $val) {
                                     $tmp = explode(':', $val);
                                     $arraylist[$tmp[0]] = $tmp[1];
                                 }
                                 $ret .= $this->selectarray($htmlname, $arraylist, $value);
                             } else {
                                 if (preg_match('/^ckeditor/', $typeofdata)) {
                                     $tmp = explode(':', $typeofdata);
                                     require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
                                     $doleditor = new DolEditor($htmlname, $editvalue ? $editvalue : $value, $tmp[2] ? $tmp[2] : '', $tmp[3] ? $tmp[3] : '100', $tmp[1] ? $tmp[1] : 'dolibarr_notes', 'In', $tmp[5] ? $tmp[5] : 0, true, true, $tmp[6] ? $tmp[6] : '20', $tmp[7] ? $tmp[7] : '100');
                                     $ret .= $doleditor->Create(1);
                                 }
                             }
                         }
                     }
                 }
             }
             $ret .= '</td>';
             if ($typeofdata != 'day' && $typeofdata != 'datepicker' && $typeofdata != 'datehourpicker') {
                 $ret .= '<td align="left">';
                 $ret .= '<input type="submit" class="button" name="modify" value="' . $langs->trans("Modify") . '">';
                 if (preg_match('/ckeditor|textarea/', $typeofdata)) {
                     $ret .= '<br>' . "\n";
                 }
                 $ret .= '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
                 $ret .= '</td>';
             }
             $ret .= '</tr></table>' . "\n";
             $ret .= '</form>' . "\n";
         } else {
             if ($typeofdata == 'email') {
                 $ret .= dol_print_email($value, 0, 0, 0, 0, 1);
             } elseif ($typeofdata == 'amount') {
                 $ret .= $value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : '';
             } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) {
                 $ret .= dol_htmlentitiesbr($value);
             } elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') {
                 $ret .= dol_print_date($value, 'day');
             } elseif ($typeofdata == 'datehourpicker') {
                 $ret .= dol_print_date($value, 'dayhour');
             } else {
                 if (preg_match('/^select;/', $typeofdata)) {
                     $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
                     foreach ($arraydata as $val) {
                         $tmp = explode(':', $val);
                         $arraylist[$tmp[0]] = $tmp[1];
                     }
                     $ret .= $arraylist[$value];
                 } else {
                     if (preg_match('/^ckeditor/', $typeofdata)) {
                         $tmpcontent = dol_htmlentitiesbr($value);
                         if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
                             $firstline = preg_replace('/<br>.*/', '', $tmpcontent);
                             $firstline = preg_replace('/[\\n\\r].*/', '', $firstline);
                             $tmpcontent = $firstline . (strlen($firstline) != strlen($tmpcontent) ? '...' : '');
                         }
                         $ret .= $tmpcontent;
                     } else {
                         $ret .= $value;
                     }
                 }
             }
         }
     }
     return $ret;
 }
コード例 #12
0
 /**
  *  Return HTML string to put an input field into a page
  *
  *  @param	string	$key             Key of attribute
  *  @param  string	$value           Value to show
  *  @param  string	$moreparam       To add more parametes on html input tag
  *  @return	void
  */
 function showInputField($key, $value, $moreparam = '')
 {
     global $conf;
     $label = $this->attribute_label[$key];
     $type = $this->attribute_type[$key];
     $size = $this->attribute_size[$key];
     $elementtype = $this->attribute_elementtype[$key];
     if ($type == 'date') {
         $showsize = 10;
     } elseif ($type == 'datetime') {
         $showsize = 19;
     } elseif ($type == 'int') {
         $showsize = 10;
     } else {
         $showsize = round($size);
         if ($showsize > 48) {
             $showsize = 48;
         }
     }
     if ($type == 'int') {
         $out = '<input type="text" name="options_' . $key . '" size="' . $showsize . '" maxlength="' . $size . '" value="' . $value . '"' . ($moreparam ? $moreparam : '') . '>';
     } else {
         if ($type == 'varchar') {
             $out = '<input type="text" name="options_' . $key . '" size="' . $showsize . '" maxlength="' . $size . '" value="' . $value . '"' . ($moreparam ? $moreparam : '') . '>';
         } else {
             if ($type == 'text') {
                 require_once DOL_DOCUMENT_ROOT . "/core/class/doleditor.class.php";
                 $doleditor = new DolEditor('options_' . $key, $value, '', 200, 'dolibarr_notes', 'In', false, false, $conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE, 5, 100);
                 $out = $doleditor->Create(1);
             } else {
                 if ($type == 'date') {
                     $out .= ' (YYYY-MM-DD)';
                 } else {
                     if ($type == 'datetime') {
                         $out .= ' (YYYY-MM-DD HH:MM:SS)';
                     }
                 }
             }
         }
     }
     return $out;
 }
コード例 #13
0
print '<td>' . $langs->trans("Mention") . '</td>' . "\n";
print '<td>&nbsp;</td>' . "\n";
print '</tr>';
foreach ($TFactor as $idFactor) {
    $factor = new TFactor();
    $factor->load($PDOdb, $idFactor);
    // Example with a yes / no select
    $var = !$var;
    print '<tr ' . $bc[$var] . '>';
    ob_start();
    $form->select_comptes($factor->fk_bank_account, 'TFactor[' . $factor->getId() . '][fk_bank_account]');
    $selectBank = ob_get_clean();
    echo '<td>' . $form->select_thirdparty_list($factor->fk_soc, 'TFactor[' . $factor->getId() . '][fk_soc]', 'fournisseur=1') . '<br />' . $selectBank . '</td>';
    // supplier
    if (!empty($conf->fckeditor->enabled)) {
        $editor = new DolEditor('TFactor[' . $factor->getId() . '][mention]', $factor->mention, '', 200);
        echo '<td>' . $editor->Create(1) . '<td>';
    } else {
        echo '<td>' . $formCore->zonetexte('', 'TFactor[' . $factor->getId() . '][mention]', $factor->mention, 80, 5) . '</td>';
    }
    echo '<td><a href="?action=delete_factor&id=' . $factor->getId() . '">' . img_delete($langs->trans('Delete')) . '</a></td>';
    print '</tr>';
}
print '</table><div class="tabsAction">';
echo $formCore->btsubmit($langs->trans('Add'), 'bt_add', '', 'butAction');
echo $formCore->btsubmit($langs->trans('Save'), 'bt_save', '', 'butAction');
echo '</div>';
$formCore->end();
// Setup page goes here
$var = false;
print '<table class="noborder" width="100%">';