Exemple #1
0
        }
        if (!$error) {
            if (isset($object) && !is_object($object) || empty($savemethod)) {
                $object = new GenericObject($db);
            }
            // Specific for add_object_linked()
            // TODO add a function for variable treatment
            $object->ext_fk_element = $newvalue;
            $object->ext_element = $ext_element;
            $object->fk_element = $fk_element;
            $object->element = $element;
            $ret = $object->{$savemethodname}($field, $newvalue, $table_element, $fk_element, $format);
            if ($ret > 0) {
                if ($type == 'numeric') {
                    $value = price($newvalue);
                } else {
                    if ($type == 'textarea') {
                        $value = dol_nl2br($newvalue);
                    }
                }
                $return['value'] = $value;
                $return['view'] = !empty($view) ? $view : $value;
            } else {
                $return['error'] = $object->error;
            }
        }
        echo json_encode($return);
    } else {
        echo $langs->trans('NotEnoughPermissions');
    }
}
Exemple #2
0
 print '<td>';
 $contractstatic->id = $obj->cid;
 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
 print $contractstatic->getNomUrl(1, 16);
 print '</td>';
 // Service
 print '<td>';
 if ($obj->pid) {
     $productstatic->id = $obj->pid;
     $productstatic->type = $obj->ptype;
     $productstatic->ref = $obj->pref;
     $productstatic->entity = $obj->pentity;
     print $productstatic->getNomUrl(1, '', 20);
     print $obj->label ? ' - ' . dol_trunc($obj->label, 16) : '';
     if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) {
         print '<br>' . dol_nl2br($obj->description);
     }
 } else {
     if ($obj->type == 0) {
         print img_object($obj->description, 'product') . dol_trunc($obj->description, 20);
     }
     if ($obj->type == 1) {
         print img_object($obj->description, 'service') . dol_trunc($obj->description, 20);
     }
 }
 print '</td>';
 // Third party
 print '<td>';
 $companystatic->id = $obj->socid;
 $companystatic->name = $obj->name;
 $companystatic->client = 1;
Exemple #3
0
/**
 * 	This function is called to encode a string into a HTML string but differs from htmlentities because
 * 	all entities but &,<,> are converted. This permits to encode special chars to entities with no double
 *  encoding for already encoded HTML strings.
 * 	This function also remove last CR/BR.
 *  For PDF usage, you can show text by 2 ways:
 *              - writeHTMLCell -> param must be encoded into HTML.
 *              - MultiCell -> param must not be encoded into HTML.
 *              Because writeHTMLCell convert also \n into <br>, if function
 *              is used to build PDF, nl2brmode must be 1
 *
 * 	@param	string	$stringtoencode		String to encode
 * 	@param	int		$nl2brmode			0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example)
 *  @param  string	$pagecodefrom       Pagecode stringtoencode is encoded
 *  @return	string						String encoded
 */
function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UTF-8')
{
    if (dol_textishtml($stringtoencode)) {
        $newstring = $stringtoencode;
        $newstring = preg_replace('/<br(\\s[\\sa-zA-Z_="]*)?\\/?>/i', '<br>', $newstring);
        // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
        $newstring = preg_replace('/<br>$/i', '', $newstring);
        // Remove last <br>
        $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
        $newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom);
        // Make entity encoding
        $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
        //$newstring=strtr($newstring,array('__li__'=>"<li>\n")); // Restore <li>\n
    } else {
        $newstring = dol_nl2br(dol_htmlentities($stringtoencode, ENT_COMPAT, $pagecodefrom), $nl2brmode);
    }
    // Other substitutions that htmlentities does not do
    //$newstring=str_replace(chr(128),'&euro;',$newstring);	// 128 = 0x80. Not in html entity table.     // Seems useles with TCPDF. Make bug with UTF8 languages
    return $newstring;
}
 print '<td>';
 if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) {
     print $form->select_dolusers($task_time->fk_user, 'userid_line');
 } else {
     $userstatic->id = $task_time->fk_user;
     $userstatic->lastname = $task_time->lastname;
     $userstatic->firstname = $task_time->firstname;
     print $userstatic->getNomUrl(1);
 }
 print '</td>';
 // Note
 print '<td align="left">';
 if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) {
     print '<textarea name="timespent_note_line" cols="80" rows="' . ROWS_3 . '">' . $task_time->note . '</textarea>';
 } else {
     print dol_nl2br($task_time->note);
 }
 print '</td>';
 // Time spent
 print '<td align="right">';
 if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) {
     print '<input type="hidden" name="old_duration" value="' . $task_time->task_duration . '">';
     print $form->select_duration('new_duration', $task_time->task_duration, 0, 'text');
 } else {
     print convertSecondToTime($task_time->task_duration, 'allhourmin');
 }
 print '</td>';
 // Edit and delete icon
 print '<td align="center" valign="middle" width="80">';
 if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) {
     print '<input type="hidden" name="lineid" value="' . $_GET['lineid'] . '">';
    /**
     *    Assign custom values for canvas (for example into this->tpl to be used by templates)
     *
     *    @param	string	$action    Type of action
     *    @param	string	$id			Id of object
     *    @param	string	$ref		Ref of object
     *    @return	void
     */
    function assign_values(&$action, $id = 0, $ref = '')
    {
        global $conf, $langs, $user, $mysoc, $canvas;
        global $form, $formadmin, $formcompany;
        if ($action == 'add' || $action == 'update') {
            $this->assign_post($action);
        }
        if ($_GET["type"] == 'f') {
            $this->object->fournisseur = 1;
        }
        if ($_GET["type"] == 'c') {
            $this->object->client = 1;
        }
        if ($_GET["type"] == 'p') {
            $this->object->client = 2;
        }
        if ($_GET["type"] == 'cp') {
            $this->object->client = 3;
        }
        if ($_REQUEST["private"] == 1) {
            $this->object->particulier = 1;
        }
        foreach ($this->object as $key => $value) {
            $this->tpl[$key] = $value;
        }
        $this->tpl['error'] = get_htmloutput_errors($this->object->error, $this->object->errors);
        if (is_array($GLOBALS['errors'])) {
            $this->tpl['error'] = get_htmloutput_mesg('', $GLOBALS['errors'], 'error');
        }
        if ($action == 'create') {
            if ($conf->use_javascript_ajax) {
                $this->tpl['ajax_selecttype'] = "\n" . '<script type="text/javascript" language="javascript">
				$(document).ready(function () {
		              $("#radiocompany").click(function() {
                            document.formsoc.action.value="create";
                            document.formsoc.canvas.value="company";
                            document.formsoc.private.value=0;
                            document.formsoc.submit();
		              });
		               $("#radioprivate").click(function() {
                            document.formsoc.action.value="create";
                            document.formsoc.canvas.value="individual";
                            document.formsoc.private.value=1;
                            document.formsoc.submit();
                      });
		          });
                </script>' . "\n";
            }
        }
        if ($action == 'create' || $action == 'edit') {
            if ($conf->use_javascript_ajax) {
                $this->tpl['ajax_selectcountry'] = "\n" . '<script type="text/javascript" language="javascript">
				$(document).ready(function () {
						$("#selectcountry_id").change(function() {
							document.formsoc.action.value="' . $action . '";
							document.formsoc.canvas.value="' . $canvas . '";
							document.formsoc.submit();
						});
					})
				</script>' . "\n";
            }
            // Load object modCodeClient
            $module = !empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard';
            if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
                $module = substr($module, 0, dol_strlen($module) - 4);
            }
            $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
            foreach ($dirsociete as $dirroot) {
                $res = dol_include_once($dirroot . $module . '.php');
                if ($res) {
                    break;
                }
            }
            $modCodeClient = new $module($db);
            $this->tpl['auto_customercode'] = $modCodeClient->code_auto;
            // We verified if the tag prefix is used
            if ($modCodeClient->code_auto) {
                $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
            }
            // TODO create a function
            $this->tpl['select_customertype'] = '<select class="flat" name="client">';
            $this->tpl['select_customertype'] .= '<option value="2"' . ($this->object->client == 2 ? ' selected="selected"' : '') . '>' . $langs->trans('Prospect') . '</option>';
            $this->tpl['select_customertype'] .= '<option value="3"' . ($this->object->client == 3 ? ' selected="selected"' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
            $this->tpl['select_customertype'] .= '<option value="1"' . ($this->object->client == 1 ? ' selected="selected"' : '') . '>' . $langs->trans('Customer') . '</option>';
            $this->tpl['select_customertype'] .= '<option value="0"' . ($this->object->client == 0 ? ' selected="selected"' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
            $this->tpl['select_customertype'] .= '</select>';
            // Customer
            $this->tpl['customercode'] = $this->object->code_client;
            if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) {
                $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object, 0);
            }
            $this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
            $s = $modCodeClient->getToolTip($langs, $this->object, 0);
            $this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1);
            if (!empty($conf->fournisseur->enabled)) {
                $this->tpl['supplier_enabled'] = 1;
                // Load object modCodeFournisseur
                $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
                if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
                    $module = substr($module, 0, dol_strlen($module) - 4);
                }
                $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
                foreach ($dirsociete as $dirroot) {
                    $res = dol_include_once($dirroot . $module . '.php');
                    if ($res) {
                        break;
                    }
                }
                $modCodeFournisseur = new $module();
                $this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
                // We verified if the tag prefix is used
                if ($modCodeFournisseur->code_auto) {
                    $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
                }
                // Supplier
                $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur", $this->object->fournisseur, 1);
                $this->tpl['suppliercode'] = $this->object->code_fournisseur;
                if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
                    $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object, 1);
                }
                $this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
                $s = $modCodeFournisseur->getToolTip($langs, $this->object, 1);
                $this->tpl['help_suppliercode'] = $form->textwithpicto('', $s, 1);
                $this->object->LoadSupplierCateg();
                $this->tpl['suppliercategory'] = $this->object->SupplierCategories;
            }
            // Zip
            $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
            // Town
            $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
            // Country
            $this->object->country_id = $this->object->country_id ? $this->object->country_id : $mysoc->country_id;
            $this->object->country_code = $this->object->country_code ? $this->object->country_code : $mysoc->country_code;
            $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
            $countrynotdefined = $langs->trans("ErrorSetACountryFirst") . ' (' . $langs->trans("SeeAbove") . ')';
            if ($user->admin) {
                $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
            }
            // State
            if ($this->object->country_id) {
                $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
            } else {
                $this->tpl['select_state'] = $countrynotdefined;
            }
            // Language
            if (!empty($conf->global->MAIN_MULTILANGS)) {
                $this->tpl['select_lang'] = $formadmin->select_language($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT, 'default_lang', 0, 0, 1);
            }
            // VAT
            $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1);
            // Assujeti par defaut en creation
            // Select users
            $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1);
            // Local Tax
            // TODO mettre dans une classe propre au pays
            if ($mysoc->country_code == 'ES') {
                $this->tpl['localtax'] = '';
                if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td><td>';
                    $this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
                    $this->tpl['localtax'] .= '</td><td>' . $langs->trans("LocalTax2IsUsedES") . '</td><td>';
                    $this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
                    $this->tpl['localtax'] .= '</td></tr>';
                } elseif ($mysoc->localtax1_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td><td colspan="3">';
                    $this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
                    $this->tpl['localtax'] .= '</td><tr>';
                } elseif ($mysoc->localtax2_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax2IsUsedES") . '</td><td colspan="3">';
                    $this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
                    $this->tpl['localtax'] .= '</td><tr>';
                }
            }
        } else {
            $head = societe_prepare_head($this->object);
            $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', '', 0, 'company');
            $this->tpl['showend'] = dol_get_fiche_end();
            $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'socid', '', $user->societe_id ? 0 : 1, 'rowid', 'nom');
            $this->tpl['checkcustomercode'] = $this->object->check_codeclient();
            $this->tpl['checksuppliercode'] = $this->object->check_codefournisseur();
            $this->tpl['address'] = dol_nl2br($this->object->address);
            $img = picto_from_langcode($this->object->country_code);
            if ($this->object->isInEEC()) {
                $this->tpl['country'] = $form->textwithpicto(($img ? $img . ' ' : '') . $this->object->country, $langs->trans("CountryIsInEEC"), 1, 0);
            }
            $this->tpl['country'] = ($img ? $img . ' ' : '') . $this->object->country;
            $this->tpl['phone'] = dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
            $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX');
            $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL');
            $this->tpl['url'] = dol_print_url($this->object->url);
            $this->tpl['tva_assuj'] = yn($this->object->tva_assuj);
            // Third party type
            $arr = $formcompany->typent_array(1);
            $this->tpl['typent'] = $arr[$this->object->typent_code];
            if (!empty($conf->global->MAIN_MULTILANGS)) {
                require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
                //$s=picto_from_langcode($this->default_lang);
                //print ($s?$s.' ':'');
                $langs->load("languages");
                $this->tpl['default_lang'] = $this->default_lang ? $langs->trans('Language_' . $this->object->default_lang) : '';
            }
            $this->tpl['image_edit'] = img_edit();
            $this->tpl['display_rib'] = $this->object->display_rib();
            // Sales representatives
            $this->tpl['sales_representatives'] = '';
            $listsalesrepresentatives = $this->object->getSalesRepresentatives($user);
            $nbofsalesrepresentative = count($listsalesrepresentatives);
            if ($nbofsalesrepresentative > 3) {
                $this->tpl['sales_representatives'] .= '<a href="' . DOL_URL_ROOT . '/societe/commerciaux.php?socid=' . $this->object->id . '">';
                $this->tpl['sales_representatives'] .= $nbofsalesrepresentative;
                $this->tpl['sales_representatives'] .= '</a>';
            } else {
                if ($nbofsalesrepresentative > 0) {
                    $userstatic = new User($this->db);
                    $i = 0;
                    foreach ($listsalesrepresentatives as $val) {
                        $userstatic->id = $val['id'];
                        $userstatic->lastname = $val['name'];
                        $userstatic->firstname = $val['firstname'];
                        $this->tpl['sales_representatives'] .= $userstatic->getNomUrl(1);
                        $i++;
                        if ($i < $nbofsalesrepresentative) {
                            $this->tpl['sales_representatives'] .= ', ';
                        }
                    }
                } else {
                    $this->tpl['sales_representatives'] .= $langs->trans("NoSalesRepresentativeAffected");
                }
            }
            // Linked member
            if (!empty($conf->adherent->enabled)) {
                $langs->load("members");
                $adh = new Adherent($this->db);
                $result = $adh->fetch('', '', $this->object->id);
                if ($result > 0) {
                    $adh->ref = $adh->getFullName($langs);
                    $this->tpl['linked_member'] = $adh->getNomUrl(1);
                } else {
                    $this->tpl['linked_member'] = $langs->trans("ThirdpartyNotLinkedToMember");
                }
            }
            // Local Tax
            // TODO mettre dans une classe propre au pays
            if ($mysoc->country_code == 'ES') {
                $this->tpl['localtax'] = '';
                if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td>';
                    $this->tpl['localtax'] .= '<td>' . yn($this->object->localtax1_assuj) . '</td>';
                    $this->tpl['localtax'] .= '<td>' . $langs->trans("LocalTax2IsUsedES") . '</td>';
                    $this->tpl['localtax'] .= '<td>' . yn($this->object->localtax2_assuj) . '</td></tr>';
                } elseif ($mysoc->localtax1_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td>';
                    $this->tpl['localtax'] .= '<td colspan="3">' . yn($this->object->localtax1_assuj) . '</td></tr>';
                } elseif ($mysoc->localtax2_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax2IsUsedES") . '</td>';
                    $this->tpl['localtax'] .= '<td colspan="3">' . yn($this->object->localtax2_assuj) . '</td></tr>';
                }
            }
        }
    }
Exemple #6
0
		$tmpecmdir=0;
	}
	$i++;
}

print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
print $s;
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
if ($_GET["action"] == 'edit')
{
	print '<textarea class="flat" name="description" cols="80">';
	print $ecmdir->description;
	print '</textarea>';
}
else print dol_nl2br($ecmdir->description);
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMCreationUser").'</td><td>';
$userecm=new User($db);
$userecm->fetch($ecmdir->fk_user_c);
print $userecm->getNomUrl(1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>';
print dol_print_date($ecmdir->date_c,'dayhour');
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
print '/ecm/'.$relativepath;
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
print sizeof($filearray);
print '</td></tr>';
Exemple #7
0
            print '<img src="' . dol_buildpath('/opensurvey/img/medaille.png', 1) . '"> ' . $langs->trans('TheBestChoices') . ": <b>" . $meilleursujet . "</b> " . $langs->trans('with') . "  <b>{$meilleurecolonne} </b>" . $vote_str . ".\n";
        }
        print '</p><br>' . "\n";
    }
}
print '<br>';
// Comment list
$comments = $object->getComments();
if ($comments) {
    print "<br><b>" . $langs->trans("CommentsOfVoters") . ":</b><br>\n";
    foreach ($comments as $obj) {
        print '<div class="comment"><span class="usercomment">';
        if (in_array($obj->usercomment, $listofvoters)) {
            print '<a href="' . $_SERVER["PHP_SELF"] . '?deletecomment=' . $obj->id_comment . '&sondage=' . $numsondage . '"> ' . img_picto('', 'delete.png') . '</a> ';
        }
        print dol_htmlentities($obj->usercomment) . ':</span> <span class="comment">' . dol_nl2br(dol_htmlentities($obj->comment)) . "</span></div>";
    }
}
// Form to add comment
if ($object->allow_comments) {
    print '<div class="addcomment">' . $langs->trans("AddACommentForPoll") . "<br>\n";
    print '<textarea name="comment" rows="2" cols="60"></textarea><br>' . "\n";
    print $langs->trans("Name") . ': ';
    print '<input type="text" name="commentuser" maxlength="64" /> &nbsp; ' . "\n";
    print '<input type="submit" class="button" name="ajoutcomment" value="' . dol_escape_htmltag($langs->trans("AddComment")) . '"><br>' . "\n";
    print '</form>' . "\n";
    print '</div>' . "\n";
    // div add comment
}
print '<br><br>';
print '<a name="bas"></a>' . "\n";
    /**
     *	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;
        }
    }
/**
 * 		Show html area for list of contacts
 *
 *		@param	Conf		$conf		Object conf
 * 		@param	Translate	$langs		Object langs
 * 		@param	DoliDB		$db			Database handler
 * 		@param	Object		$object		Third party object
 *      @param  string		$backtopage	Url to go once contact is created
 *      @return	void
 */
function show_contacts($conf, $langs, $db, $object, $backtopage = '')
{
    global $user, $conf;
    global $bc;
    $form = new Form($db);
    $sortfield = GETPOST("sortfield", 'alpha');
    $sortorder = GETPOST("sortorder", 'alpha');
    $search_status = GETPOST("search_status", 'int');
    if ($search_status == '') {
        $search_status = 1;
    }
    // always display activ customer first
    $search_name = GETPOST("search_name", 'alpha');
    if (!$sortorder) {
        $sortorder = "ASC";
    }
    if (!$sortfield) {
        $sortfield = "p.lastname";
    }
    $i = -1;
    $contactstatic = new Contact($db);
    if (!empty($conf->clicktodial->enabled)) {
        $user->fetch_clicktodial();
        // lecture des infos de clicktodial
    }
    $buttoncreate = '';
    if ($user->rights->societe->contact->creer) {
        $addcontact = !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress");
        $buttoncreate = '<a class="addnewrecord" href="' . DOL_URL_ROOT . '/contact/fiche.php?socid=' . $object->id . '&amp;action=create&amp;backtopage=' . urlencode($backtopage) . '">' . $addcontact;
        if (empty($conf->dol_optimize_smallscreen)) {
            $buttoncreate .= ' ' . img_picto($addcontact, 'filenew');
        }
        $buttoncreate .= '</a>' . "\n";
    }
    print "\n";
    $title = !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany");
    print_fiche_titre($title, $buttoncreate, '');
    print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '" name="formfilter">';
    print '<input type="hidden" name="socid" value="' . $object->id . '">';
    print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
    print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
    print "\n" . '<table class="noborder" width="100%">' . "\n";
    $param = "socid=" . $object->id;
    if ($search_status != '') {
        $param .= '&amp;search_status=' . $search_status;
    }
    if ($search_name != '') {
        $param .= '&amp;search_name=' . urlencode($search_name);
    }
    $colspan = 9;
    print '<tr class="liste_titre">';
    print_liste_field_titre($langs->trans("Name"), $_SERVER["PHP_SELF"], "p.lastname", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("Poste"), $_SERVER["PHP_SELF"], "p.poste", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("PhonePro"), $_SERVER["PHP_SELF"], "p.phone", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("PhoneMobile"), $_SERVER["PHP_SELF"], "p.phone_mobile", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("Fax"), $_SERVER["PHP_SELF"], "p.fax", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("EMail"), $_SERVER["PHP_SELF"], "p.email", "", $param, '', $sortfield, $sortorder);
    if (!empty($conf->skype->enabled)) {
        $colspan++;
        print '<td>' . $langs->trans("Skype") . '</td>';
    }
    print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder);
    // Copy to clipboard
    print "<td>&nbsp;</td>";
    // Add to agenda
    if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) {
        $colspan++;
        print '<td>&nbsp;</td>';
    }
    // Edit
    print '<td>&nbsp;</td>';
    print "</tr>";
    print '<tr class="liste_titre">';
    print '<td class="liste_titre">';
    print '<input type="text" class="flat" name="search_name" size="20" value="' . $search_name . '">';
    print '</td>';
    print '<td>&nbsp;</td>';
    print '<td>&nbsp;</td>';
    print '<td>&nbsp;</td>';
    print '<td>&nbsp;</td>';
    print '<td>&nbsp;</td>';
    if (!empty($conf->skype->enabled)) {
        $colspan++;
        print '<td>&nbsp;</td>';
    }
    // Status
    print '<td class="liste_titre maxwidthonsmartphone">';
    print $form->selectarray('search_status', array('0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity')), $search_status);
    print '</td>';
    // Copy to clipboard
    print "<td>&nbsp;</td>";
    // Add to agenda
    if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
        $colspan++;
        print '<td>&nbsp;</td>';
    }
    // Edit
    print '<td class="liste_titre" align="right">';
    print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
    print '</td>';
    print "</tr>";
    $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays as country_id, p.poste, p.phone, p.phone_mobile, p.fax, p.email, p.skype, p.statut ";
    $sql .= ", p.civilite as civility_id, p.address, p.zip, p.town";
    $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as p";
    $sql .= " WHERE p.fk_soc = " . $object->id;
    if ($search_status != '') {
        $sql .= " AND p.statut = " . $db->escape($search_status);
    }
    if ($search_name) {
        $sql .= " AND (p.lastname LIKE '%" . $db->escape($search_name) . "%' OR p.firstname LIKE '%" . $db->escape($search_name) . "%')";
    }
    $sql .= " ORDER BY {$sortfield} {$sortorder}";
    dol_syslog('core/lib/company.lib.php :: show_contacts sql=' . $sql, LOG_DEBUG);
    $result = $db->query($sql);
    $num = $db->num_rows($result);
    $var = true;
    if ($num) {
        $i = 0;
        while ($i < $num) {
            $obj = $db->fetch_object($result);
            $var = !$var;
            print "<tr " . $bc[$var] . ">";
            print '<td>';
            $contactstatic->id = $obj->rowid;
            $contactstatic->statut = $obj->statut;
            $contactstatic->lastname = $obj->lastname;
            $contactstatic->firstname = $obj->firstname;
            $contactstatic->civility_id = $obj->civility_id;
            print $contactstatic->getNomUrl(1);
            print '</td>';
            print '<td>' . $obj->poste . '</td>';
            $country_code = getCountry($obj->country_id, 'all');
            // Lien click to dial
            print '<td>';
            print dol_print_phone($obj->phone, $country_code['code'], $obj->rowid, $object->id, 'AC_TEL');
            print '</td>';
            print '<td>';
            print dol_print_phone($obj->phone_mobile, $country_code['code'], $obj->rowid, $object->id, 'AC_TEL');
            print '</td>';
            print '<td>';
            print dol_print_phone($obj->fax, $country_code['code'], $obj->rowid, $object->id, 'AC_FAX');
            print '</td>';
            print '<td>';
            print dol_print_email($obj->email, $obj->rowid, $object->id, 'AC_EMAIL');
            print '</td>';
            if (!empty($conf->skype->enabled)) {
                print '<td>';
                print dol_print_skype($obj->skype, $obj->rowid, $object->id, 'AC_SKYPE');
                print '</td>';
            }
            // Status
            print '<td>' . $contactstatic->getLibStatut(5) . '</td>';
            print '<td align="center">';
            if (!empty($conf->use_javascript_ajax)) {
                // Copy to clipboard
                $coords = '';
                if (!empty($object->name)) {
                    $coords .= $object->name . "<br>";
                }
                $coords .= $contactstatic->getFullName($langs, 1) . ' ';
                $coords .= "<br>";
                if (!empty($obj->address)) {
                    $coords .= dol_nl2br($obj->address, 1, true) . "<br>";
                    if (!empty($obj->zip)) {
                        $coords .= $obj->zip . ' ';
                    }
                    if (!empty($obj->town)) {
                        $coords .= $obj->town;
                    }
                    if (!empty($obj->country_id)) {
                        $coords .= "<br>" . $country_code['label'];
                    }
                } else {
                    if (!empty($object->address)) {
                        $coords .= dol_nl2br($object->address, 1, true) . "<br>";
                        if (!empty($object->zip)) {
                            $coords .= $object->zip . ' ';
                        }
                        if (!empty($object->town)) {
                            $coords .= $object->town;
                        }
                        if (!empty($object->country_id)) {
                            $coords .= "<br>" . $country_code['label'];
                        }
                    }
                }
                // hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile
                print '<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\'' . dol_escape_js($coords) . '\',\'' . dol_escape_js($langs->trans("HelpCopyToClipboard")) . '\');">';
                print img_picto($langs->trans("Address"), 'object_address.png');
                print '</a>';
            }
            print '</td>';
            // Add to agenda
            if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
                print '<td align="center">';
                if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
                    print '<a class="hideonsmartphone" href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&actioncode=AC_RDV&contactid=' . $obj->rowid . '&socid=' . $object->id . '&backtopage=' . urlencode($backtopage) . '">';
                    print img_object($langs->trans("Rendez-Vous"), "action_rdv");
                    print '</a> ';
                }
                print '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&actioncode=&contactid=' . $obj->rowid . '&socid=' . $object->id . '&backtopage=' . urlencode($backtopage) . '">';
                print img_object($langs->trans("Event"), "action");
                print '</a></td>';
            }
            // Edit
            if ($user->rights->societe->contact->creer) {
                print '<td align="right">';
                print '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?action=edit&amp;id=' . $obj->rowid . '&amp;backtopage=' . urlencode($backtopage) . '">';
                print img_edit();
                print '</a></td>';
            } else {
                print '<td>&nbsp;</td>';
            }
            print "</tr>\n";
            $i++;
        }
    } else {
        print "<tr " . $bc[$var] . ">";
        print '<td colspan="' . $colspan . '">' . $langs->trans("None") . '</td>';
        print "</tr>\n";
    }
    print "\n</table>\n";
    print '</form>' . "\n";
    print "<br>\n";
    ?>
<div id="dialog" title="<?php 
    echo dol_escape_htmltag($langs->trans('Address'));
    ?>
" style="display: none;"></div>
<?php 
    return $i;
}
Exemple #10
0
 /**
  * Output edit in place form
  *
  * @param	object	$object			Object
  * @param	string	$value			Value to show/edit
  * @param	string	$htmlname		DIV ID (field name)
  * @param	int		$condition		Condition to edit
  * @param	string	$inputType		Type of input ('numeric', 'datepicker', 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:xxx')
  * @param	string	$editvalue		When in edit mode, use this value as $value instead of value
  * @param	object	$extObject		External object
  * @param	mixed	$custommsg		String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
  * @return	string   		      	HTML edit in place
  */
 private function editInPlace($object, $value, $htmlname, $condition, $inputType = 'textarea', $editvalue = null, $extObject = null, $custommsg = null)
 {
     global $conf;
     $out = '';
     // Check parameters
     if ($inputType == 'textarea') {
         $value = dol_nl2br($value);
     } else {
         if (preg_match('/^numeric/', $inputType)) {
             $value = price($value);
         } else {
             if ($inputType == 'datepicker') {
                 $value = dol_print_date($value, 'day');
             }
         }
     }
     if ($condition) {
         $element = false;
         $table_element = false;
         $fk_element = false;
         $loadmethod = false;
         $savemethod = false;
         $ext_element = false;
         $button_only = false;
         if (is_object($object)) {
             $element = $object->element;
             $table_element = $object->table_element;
             $fk_element = $object->id;
         }
         if (is_object($extObject)) {
             $ext_element = $extObject->element;
         }
         if (preg_match('/^(string|email|numeric)/', $inputType)) {
             $tmp = explode(':', $inputType);
             $inputType = $tmp[0];
             if (!empty($tmp[1])) {
                 $inputOption = $tmp[1];
             }
             if (!empty($tmp[2])) {
                 $savemethod = $tmp[2];
             }
         } else {
             if (preg_match('/^datepicker/', $inputType) || preg_match('/^datehourpicker/', $inputType)) {
                 $tmp = explode(':', $inputType);
                 $inputType = $tmp[0];
                 if (!empty($tmp[1])) {
                     $inputOption = $tmp[1];
                 }
                 if (!empty($tmp[2])) {
                     $savemethod = $tmp[2];
                 }
                 $out .= '<input id="timestamp" type="hidden"/>' . "\n";
                 // Use for timestamp format
             } else {
                 if (preg_match('/^(select|autocomplete)/', $inputType)) {
                     $tmp = explode(':', $inputType);
                     $inputType = $tmp[0];
                     $loadmethod = $tmp[1];
                     if (!empty($tmp[2])) {
                         $savemethod = $tmp[2];
                     }
                     if (!empty($tmp[3])) {
                         $button_only = true;
                     }
                 } else {
                     if (preg_match('/^textarea/', $inputType)) {
                         $tmp = explode(':', $inputType);
                         $inputType = $tmp[0];
                         $rows = empty($tmp[1]) ? '8' : $tmp[1];
                         $cols = empty($tmp[2]) ? '80' : $tmp[2];
                     } else {
                         if (preg_match('/^ckeditor/', $inputType)) {
                             $tmp = explode(':', $inputType);
                             $inputType = $tmp[0];
                             $toolbar = $tmp[1];
                             if (!empty($tmp[2])) {
                                 $width = $tmp[2];
                             }
                             if (!empty($tmp[3])) {
                                 $heigth = $tmp[3];
                             }
                             if (!empty($tmp[4])) {
                                 $savemethod = $tmp[4];
                             }
                             if (!empty($conf->fckeditor->enabled)) {
                                 $out .= '<input id="ckeditor_toolbar" value="' . $toolbar . '" type="hidden"/>' . "\n";
                             } else {
                                 $inputType = 'textarea';
                             }
                         }
                     }
                 }
             }
         }
         $out .= '<input id="element_' . $htmlname . '" value="' . $element . '" type="hidden"/>' . "\n";
         $out .= '<input id="table_element_' . $htmlname . '" value="' . $table_element . '" type="hidden"/>' . "\n";
         $out .= '<input id="fk_element_' . $htmlname . '" value="' . $fk_element . '" type="hidden"/>' . "\n";
         $out .= '<input id="loadmethod_' . $htmlname . '" value="' . $loadmethod . '" type="hidden"/>' . "\n";
         if (!empty($savemethod)) {
             $out .= '<input id="savemethod_' . $htmlname . '" value="' . $savemethod . '" type="hidden"/>' . "\n";
         }
         if (!empty($ext_element)) {
             $out .= '<input id="ext_element_' . $htmlname . '" value="' . $ext_element . '" type="hidden"/>' . "\n";
         }
         if (!empty($custommsg)) {
             if (is_array($custommsg)) {
                 if (!empty($custommsg['success'])) {
                     $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg['success'] . '" type="hidden"/>' . "\n";
                 }
                 if (!empty($custommsg['error'])) {
                     $out .= '<input id="errormsg_' . $htmlname . '" value="' . $custommsg['error'] . '" type="hidden"/>' . "\n";
                 }
             } else {
                 $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg . '" type="hidden"/>' . "\n";
             }
         }
         if ($inputType == 'textarea') {
             $out .= '<input id="textarea_' . $htmlname . '_rows" value="' . $rows . '" type="hidden"/>' . "\n";
             $out .= '<input id="textarea_' . $htmlname . '_cols" value="' . $cols . '" type="hidden"/>' . "\n";
         }
         $out .= '<span id="viewval_' . $htmlname . '" class="viewval_' . $inputType . ($button_only ? ' inactive' : ' active') . '">' . $value . '</span>' . "\n";
         $out .= '<span id="editval_' . $htmlname . '" class="editval_' . $inputType . ($button_only ? ' inactive' : ' active') . ' hideobject">' . (!empty($editvalue) ? $editvalue : $value) . '</span>' . "\n";
     } else {
         $out = $value;
     }
     return $out;
 }
Exemple #11
0
 print '</td>';
 print '</tr>';
 // Date
 print '<tr><td width="25%">' . $langs->trans("Date") . '</td><td colspan="2">';
 print dol_print_date($object->date, "day");
 print "</td>";
 print '<tr><td>' . $langs->trans("Amount") . '</td><td colspan="2">';
 print price($object->amount, 0, $langs, 0, 0, -1, $conf->currency);
 print '</td></tr>';
 print '<tr><td>' . $langs->trans("PublicDonation") . '</td><td colspan="2">';
 print yn($object->public);
 print '</td></tr>';
 print '<tr><td>' . $langs->trans("Company") . '</td><td colspan="2">' . $object->societe . '</td></tr>';
 print '<tr><td>' . $langs->trans("Lastname") . '</td><td colspan="2">' . $object->lastname . '</td></tr>';
 print '<tr><td>' . $langs->trans("Firstname") . '</td><td colspan="2">' . $object->firstname . '</td></tr>';
 print '<tr><td>' . $langs->trans("Address") . '</td><td>' . dol_nl2br($object->address) . '</td>';
 $rowspan = 6;
 if (!empty($conf->projet->enabled)) {
     $rowspan++;
 }
 print '<td rowspan="' . $rowspan . '" valign="top">';
 /*
  * Payments
  */
 $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
 $sql .= "c.code as type_code,c.libelle as paiement_type";
 $sql .= " FROM " . MAIN_DB_PREFIX . "payment_donation as p";
 $sql .= ", " . MAIN_DB_PREFIX . "c_paiement as c ";
 $sql .= ", " . MAIN_DB_PREFIX . "don as d";
 $sql .= " WHERE d.rowid = '" . $id . "'";
 $sql .= " AND p.fk_donation = d.rowid";
Exemple #12
0
    print '<tr '.$bc[$var].'><td valign="top">'.$langs->trans("Note").'</td>';
    print '<td valign="top">';
    if ($action == 'edit' && $user->rights->societe->creer)
    {
        print '<input type="hidden" name="action" value="add" />';
        print '<input type="hidden" name="socid" value="'.$object->id.'" />';

        // Editeur wysiwyg
        require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
        $doleditor=new DolEditor('note',$object->note,'',360,'dolibarr_notes','In',true,false,$conf->global->FCKEDITOR_ENABLE_SOCIETE,20,70);
        $doleditor->Create();
    }
    else
    {
        print dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true);
    }
    print "</td></tr>";
    $var=!$var;

    print "</table>";

    if ($action == 'edit')
    {
        print '<center><br>';
        print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
        print ' &nbsp; ';
        print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
        print '</center>';
    }
Exemple #13
0
/**
 *  Concat 2 descriptions (second one after first one with a new line separator if required)
 *  text1 html + text2 html => text1 + '<br>' + text2
 *  text1 html + text2 txt  => text1 + '<br>' + dol_nl2br(text2)
 *  text1 txt  + text2 html => dol_nl2br(text1) + '<br>' + text2
 *  text1 txt  + text2 txt  => text1 + '\n' + text2
 *
 *  @param	string	$text1		Text 1
 *  @param	string	$text2		Text 2
 *  @param  bool	$forxml     false=Use <br>, true=Use <br />
 *  @return	string				Text 1 + new line + Text2
 *  @see    dol_textishtml
 */
function dol_concatdesc($text1, $text2, $forxml = false)
{
    $ret = '';
    $ret .= !dol_textishtml($text1) && dol_textishtml($text2) ? dol_nl2br($text1, 0, $forxml) : $text1;
    $ret .= !empty($text1) && !empty($text2) ? dol_textishtml($text1) || dol_textishtml($text2) ? $forxml ? "<br \\>\n" : "<br>\n" : "\n" : "";
    $ret .= dol_textishtml($text1) && !dol_textishtml($text2) ? dol_nl2br($text2, 0, $forxml) : $text2;
    return $ret;
}
 function beforePDFCreation(&$parameters, &$object, &$action, $hookmanager)
 {
     global $conf, $user, $langs, $db, $mysoc;
     // Sur version 5.0 le $parameters['currentcontext'] == ordersuppliercard et le "pdfgeneration" est dans $parameters['context']
     $TContext = explode(':', $parameters['context']);
     if ($parameters['currentcontext'] === 'pdfgeneration' || in_array('pdfgeneration', $TContext)) {
         $base_object = $parameters['object'];
         if (isset($base_object) && in_array($base_object->element, array('order_supplier', 'commande'))) {
             require_once DOL_DOCUMENT_ROOT . '/core/lib/pdf.lib.php';
             $parameters['outputlangs']->load('deliveries');
             $parameters['outputlangs']->load('orders');
             $usecommande = $usecontact = false;
             // Load des contacts livraison
             $arrayidcontact = $base_object->getIdContact('external', 'SHIPPING');
             if (count($arrayidcontact) > 0) {
                 $usecontact = true;
                 $base_object->fetch_contact($arrayidcontact[0]);
             }
             $base_object->fetchObjectLinked();
             $Qwrite = false;
             if (isset($base_object->linkedObjects['commande']) && !empty($conf->global->GRAPEFRUIT_SUPPLIER_CONTACT_SHIP_ADDRESS)) {
                 // On récupère la donnée de la commande initiale
                 // C'est un tableau basé sur des ID donc on boucle pour sortir le premier item
                 $commande = reset($base_object->linkedObjects['commande']);
                 $date_affiche = date("Y-m-d", $commande->date);
                 $ref = $commande->ref;
                 $ref_client = $commande->ref_client;
                 $usecommande = $Qwrite = true;
             } elseif ($base_object->element === 'commande' && !empty($conf->global->GRAPEFRUIT_ORDER_CONTACT_SHIP_ADDRESS)) {
                 $date_affiche = date("Y-m-d", $base_object->date);
                 $ref = $base_object->ref;
                 $ref_client = $base_object->ref_client;
                 $usecommande = $Qwrite = true;
             }
             if ($usecontact && $Qwrite) {
                 //Recipient name
                 // On peut utiliser le nom de la societe du contact
                 $thirdparty = $base_object->thirdparty;
                 if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                     $thirdparty = $base_object->contact;
                 }
                 $carac_client_name = pdfBuildThirdpartyName($thirdparty, $parameters['outputlangs']);
                 $thecontact = $base_object->contact;
                 // SI un élément manquant ou qu'on veuille envoyé à la société du contact alors on change
                 if (empty($thecontact->address) || empty($thecontact->zip) || empty($thecontact->town)) {
                     $contactSociete = new Societe($db);
                     $contactSociete->fetch($thecontact->socid);
                     $thecontact->address = $contactSociete->address;
                     $thecontact->zip = $contactSociete->zip;
                     $thecontact->town = $contactSociete->town;
                 }
                 $carac_client = pdf_build_address($parameters['outputlangs'], $object->emetteur, $base_object->client, $base_object->contact, $usecontact, 'target');
                 $newcontent = $parameters['outputlangs']->trans('DeliveryAddress') . ' :' . "\n" . '<strong>' . $carac_client_name . '</strong>' . "\n" . $carac_client;
                 if ($usecommande) {
                     if (isset($ref_client)) {
                         $newcontent .= "\n" . "<strong>" . $parameters['outputlangs']->trans('RefOrder') . ' client : </strong>' . $ref_client;
                     }
                     $newcontent .= "\n" . "<strong>" . $parameters['outputlangs']->trans('RefOrder') . ' ' . $mysoc->name . ' : </strong>' . $ref;
                     $newcontent .= "\n" . "<strong>" . $parameters['outputlangs']->trans('OrderDate') . ' : </strong>' . $date_affiche;
                 }
                 if (!empty($parameters['object']->note_public)) {
                     $parameters['object']->note_public = dol_nl2br($newcontent . "\n\n" . $parameters['object']->note_public);
                 } else {
                     $parameters['object']->note_public = dol_nl2br($newcontent);
                 }
             }
         }
         // Fin order / order_supplier
     }
 }
Exemple #15
0
				else
				{
					print '&nbsp;';
				}
				print "</td></tr>\n";
			}

            // Custom code
            print '<tr><td>'.$langs->trans("CustomCode").'</td><td colspan="2">'.$product->customcode.'</td>';

            // Origin country code
            print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td colspan="2">'.getCountry($product->country_id,0,$db).'</td>';


			// Note
			print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="2">'.(dol_textishtml($product->note)?$product->note:dol_nl2br($product->note,1,true)).'</td></tr>';

			print "</table>\n";
		}
		else
		{
			$canvas->assign_values('view');
			$canvas->display_canvas();
		}

		dol_fiche_end();
	}

}
else if ($action != 'create')
{
Exemple #16
0
</head>

<body>

<div class="entete">
<div class="logo"><?php 
print '<img src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=companylogo&amp;file=' . urlencode('/thumbs/' . $mysoc->logo_small) . '">';
?>
</div>
<div class="infos">
<p class="address"><?php 
echo $mysoc->name;
?>
<br>
<?php 
print dol_nl2br(dol_format_address($mysoc));
?>
<br>
</p>

<p class="date_heure"><?php 
// Recuperation et affichage de la date et de l'heure
$now = dol_now();
print dol_print_date($now, 'dayhourtext') . '<br>';
print $object->ref;
?>
</p>
</div>
</div>

<br>
Exemple #17
0
    print '</td>';
    if ($action != 'editdescription' && $object->statut == 0) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdescription&amp;id='.$object->id.'">'.img_edit($langs->trans('Modify'),1).'</a></td>';
    print '</tr></table>';
    print '</td><td colspan="3">';
    if ($action == 'editdescription')
    {
        print '<form name="editdescription" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
        print '<input type="hidden" name="action" value="setdescription">';
        print '<textarea name="description" wrap="soft" cols="70" rows="'.ROWS_3.'">'.dol_htmlentitiesbr_decode($object->description).'</textarea><br>';
        print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
        print '</form>';
    }
    else
    {
        print dol_nl2br($object->description);
    }
    print '</td>';
    print '</tr>';

    // Project
    if ($conf->projet->enabled)
    {
        $langs->load('projects');
        print '<tr>';
        print '<td>';

        print '<table class="nobordernopadding" width="100%"><tr><td>';
        print $langs->trans('Project');
        print '</td>';
        if ($action != 'classin')
}
print '</div>';
if ($action == 'delete') {
    print $form->formconfirm($_SERVER["PHP_SELF"] . '?&id=' . $numsondage, $langs->trans("RemovePoll"), $langs->trans("ConfirmRemovalOfPoll", $id), 'delete_confirm', '', '', 1);
}
print '<br>';
print '<form name="formulaire5" action="#" method="POST">' . "\n";
print_fiche_titre($langs->trans("CommentsOfVoters"), '', '');
// Comment list
$comments = $object->getComments();
if ($comments) {
    foreach ($comments as $comment) {
        if ($user->rights->opensurvey->write) {
            print '<a href="' . dol_buildpath('/opensurvey/card.php', 1) . '?deletecomment=' . $comment->id_comment . '&id=' . $numsondage . '"> ' . img_picto('', 'delete.png') . '</a> ';
        }
        print dol_htmlentities($comment->usercomment) . ': ' . dol_nl2br(dol_htmlentities($comment->comment)) . " <br>";
    }
} else {
    print $langs->trans("NoCommentYet") . '<br>';
}
print '<br>';
// Add comment
if ($object->allow_comments) {
    print $langs->trans("AddACommentForPoll") . '<br>';
    print '<textarea name="comment" rows="2" cols="80"></textarea><br>' . "\n";
    print $langs->trans("Name") . ': <input type="text" name="commentuser" value="' . $user->getFullName($langs) . '"><br>' . "\n";
    print '<input type="submit" class="button" name="ajoutcomment" value="' . dol_escape_htmltag($langs->trans("AddComment")) . '"><br>' . "\n";
    if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide == "yes") {
        print "<font color=#FF0000>" . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")) . "</font>";
    }
}
Exemple #19
0
                // Other attributes
                $parameters = array('colspan' => ' colspan="' . (2 + ($showphoto || $showbarcode ? 1 : 0)) . '"');
                $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
                // Note that $action and $object may have been modified by hook
                if (empty($reshook) && !empty($extrafields->attribute_label)) {
                    print $object->showOptionals($extrafields);
                }
                // Categories
                if ($conf->categorie->enabled) {
                    print '<tr><td valign="middle">' . $langs->trans("Categories") . '</td><td colspan="3">';
                    print $form->showCategories($object->id, 'product', 1);
                    print "</td></tr>";
                }
                // Note
                print '<!-- show Note --> ' . "\n";
                print '<tr><td class="tdtop">' . $langs->trans("Note") . '</td><td colspan="' . (2 + ($showphoto || $showbarcode ? 1 : 0)) . '">' . (dol_textishtml($object->note) ? $object->note : dol_nl2br($object->note, 1, true)) . '</td></tr>' . "\n";
                print '<!-- End show Note --> ' . "\n";
                print "</table>\n";
                print '</div>';
                print '</div></div>';
                print '<div style="clear:both"></div>';
                dol_fiche_end();
            }
        } else {
            if ($action != 'create') {
                exit;
            }
        }
    }
}
// Load object modCodeProduct
Exemple #20
0
		print '<td>';
		$contractstatic->id=$obj->cid;
		$contractstatic->ref=$obj->ref?$obj->ref:$obj->cid;
		print $contractstatic->getNomUrl(1,16);
		print '</td>';

		// Service
		print '<td>';
		if ($obj->pid)
		{
			$productstatic->id=$obj->pid;
			$productstatic->type=$obj->ptype;
			$productstatic->ref=$obj->pref;
			print $productstatic->getNomUrl(1,'',20);
            print $obj->label?' - '.dol_trunc($obj->label,16):'';
            if ($obj->description && $conf->global->PRODUIT_DESC_IN_LIST) print '<br>'.dol_nl2br($obj->description);
		}
		else
		{
			if ($obj->type == 0) print img_object($obj->description,'product').dol_trunc($obj->description,20);
			if ($obj->type == 1) print img_object($obj->description,'service').dol_trunc($obj->description,20);
		}
		print '</td>';

		// Third party
		print '<td>';
		$companystatic->id=$obj->socid;
		$companystatic->nom=$obj->nom;
		$companystatic->client=1;
		print $companystatic->getNomUrl(1,'customer',28);
		print '</td>';
Exemple #21
0
     }
     $addevent = true;
 }
 if ($addevent) {
     $event->id = $icalevent['UID'];
     $event->icalname = $namecal;
     $event->icalcolor = $colorcal;
     $usertime = 0;
     // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output.
     $event->datep = $datestart + $usertime;
     $event->datef = $dateend + $usertime;
     $event->type_code = "ICALEVENT";
     if ($icalevent['SUMMARY']) {
         $event->libelle = $icalevent['SUMMARY'];
     } elseif ($icalevent['DESCRIPTION']) {
         $event->libelle = dol_nl2br($icalevent['DESCRIPTION'], 1);
     } else {
         $event->libelle = $langs->trans("ExtSiteNoLabel");
     }
     $event->date_start_in_calendar = $event->datep;
     if ($event->datef != '' && $event->datef >= $event->datep) {
         $event->date_end_in_calendar = $event->datef;
     } else {
         $event->date_end_in_calendar = $event->datep;
     }
     // Define ponctual property
     if ($event->date_start_in_calendar == $event->date_end_in_calendar) {
         $event->ponctuel = 1;
         //print 'x'.$datestart.'-'.$dateend;exit;
     }
     // Add event into $eventarray if date range are ok.
Exemple #22
0
    print '<tr><td valign="top">'.$langs->trans("Note").'</td>';
    print '<td valign="top">';
    if ($action == 'edit' && $user->rights->societe->creer)
    {
        print "<input type=\"hidden\" name=\"action\" value=\"add\">";
        print "<input type=\"hidden\" name=\"socid\" value=\"".$societe->id."\">";

        // Editeur wysiwyg
        require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
        $doleditor=new DolEditor('note',$societe->note,'',360,'dolibarr_notes','In',true,false,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE,20,70);
        $doleditor->Create();
    }
    else
    {
        print dol_textishtml($societe->note)?$societe->note:dol_nl2br($societe->note,1,true);
    }
    print "</td></tr>";

    if ($action == 'edit')
    {
        print '<tr><td colspan="2" align="center">';
        print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
        print ' &nbsp; ';
        print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
        print '</td></tr>';
    }

    print "</table>";

    print '</form>';
 /**
  *	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;
     }
 }
    /**
     *  Set content of ->tpl array, to use into template
     *
     *  @param	string		$action    Type of action
     *  @param	int			$id			Id
     *  @return	string					HTML output
     */
    function assign_values(&$action, $id)
    {
        global $conf, $langs, $user, $canvas;
        global $form, $formcompany, $objsoc;
        if ($action == 'add' || $action == 'update') {
            $this->assign_post();
        }
        foreach ($this->object as $key => $value) {
            $this->tpl[$key] = $value;
        }
        $this->tpl['error'] = $this->error;
        $this->tpl['errors'] = $this->errors;
        if ($action == 'create' || $action == 'edit') {
            if ($conf->use_javascript_ajax) {
                $this->tpl['ajax_selectcountry'] = "\n" . '<script type="text/javascript" language="javascript">
				jQuery(document).ready(function () {
						jQuery("#selectcountry_id").change(function() {
							document.formsoc.action.value="' . $action . '";
							document.formsoc.canvas.value="' . $canvas . '";
							document.formsoc.submit();
						});
					})
				</script>' . "\n";
            }
            if (is_object($objsoc) && $objsoc->id > 0) {
                $this->tpl['company'] = $objsoc->getNomUrl(1);
                $this->tpl['company_id'] = $objsoc->id;
            } else {
                $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1);
            }
            // Civility
            $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id);
            // Predefined with third party
            if (isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) {
                if (dol_strlen(trim($this->object->address)) == 0) {
                    $this->tpl['address'] = $objsoc->address;
                }
                if (dol_strlen(trim($this->object->zip)) == 0) {
                    $this->object->zip = $objsoc->zip;
                }
                if (dol_strlen(trim($this->object->town)) == 0) {
                    $this->object->town = $objsoc->town;
                }
                if (dol_strlen(trim($this->object->phone_pro)) == 0) {
                    $this->object->phone_pro = $objsoc->phone;
                }
                if (dol_strlen(trim($this->object->fax)) == 0) {
                    $this->object->fax = $objsoc->fax;
                }
                if (dol_strlen(trim($this->object->email)) == 0) {
                    $this->object->email = $objsoc->email;
                }
            }
            // Zip
            $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
            // Town
            $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
            if (dol_strlen(trim($this->object->country_id)) == 0) {
                $this->object->country_id = $objsoc->country_id;
            }
            // Country
            $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
            $countrynotdefined = $langs->trans("ErrorSetACountryFirst") . ' (' . $langs->trans("SeeAbove") . ')';
            if ($user->admin) {
                $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
            }
            // State
            if ($this->object->country_id) {
                $this->tpl['select_state'] = $formcompany->select_state($this->object->fk_departement, $this->object->country_code);
            } else {
                $this->tpl['select_state'] = $countrynotdefined;
            }
            // Public or private
            $selectarray = array('0' => $langs->trans("ContactPublic"), '1' => $langs->trans("ContactPrivate"));
            $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0);
        }
        if ($action == 'view' || $action == 'edit' || $action == 'delete') {
            // Emailing
            if (!empty($conf->mailing->enabled)) {
                $langs->load("mails");
                $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings();
            }
            // Linked element
            $this->tpl['contact_element'] = array();
            $i = 0;
            $this->object->load_ref_elements();
            if (!empty($conf->commande->enabled)) {
                $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders");
                $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder");
                $i++;
            }
            if (!empty($conf->propal->enabled)) {
                $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals");
                $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal");
                $i++;
            }
            if (!empty($conf->contrat->enabled)) {
                $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts");
                $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract");
                $i++;
            }
            if (!empty($conf->facture->enabled)) {
                $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices");
                $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
                $i++;
            }
            // Dolibarr user
            if ($this->object->user_id) {
                $dolibarr_user = new User($this->db);
                $result = $dolibarr_user->fetch($this->object->user_id);
                $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
            } else {
                $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
            }
        }
        if ($action == 'view' || $action == 'delete') {
            $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id');
            if ($this->object->socid > 0) {
                $objsoc = new Societe($this->db);
                $objsoc->fetch($this->object->socid);
                $this->tpl['company'] = $objsoc->getNomUrl(1);
            } else {
                $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany");
            }
            $this->tpl['civility'] = $this->object->getCivilityLabel();
            $this->tpl['address'] = dol_nl2br($this->object->address);
            $this->tpl['zip'] = $this->object->zip ? $this->object->zip . '&nbsp;' : '';
            $img = picto_from_langcode($this->object->country_code);
            $this->tpl['country'] = ($img ? $img . ' ' : '') . $this->object->country;
            $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
            $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
            $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
            $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX');
            $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL');
            $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv);
            $this->tpl['note'] = nl2br($this->object->note);
        }
        if ($action == 'create_user') {
            // Full firstname and lastname separated with a dot : firstname.lastname
            include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
            require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
            $login = dol_buildlogin($this->object->lastname, $this->object->firstname);
            $generated_password = getRandomPassword(false);
            $password = $generated_password;
            // Create a form array
            $formquestion = array(array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));
            $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateContact"), "confirm_create_user", $formquestion, 'no');
        }
    }
 print '</td>';
 print '</tr>';
 // Date
 print '<tr><td width="25%">' . $langs->trans("Date") . '</td><td>';
 print dol_print_date($don->date, "day");
 print "</td>";
 print '<td rowspan="' . $nbrows . '" valign="top" width="50%">' . $langs->trans("Comments") . ' :<br>';
 print nl2br($don->note_private) . '</td></tr>';
 print "<tr>" . '<td>' . $langs->trans("Amount") . '</td><td>' . price($don->amount, 0, $langs, 0, 0, -1, $conf->currency) . '</td></tr>';
 print "<tr><td>" . $langs->trans("PublicDonation") . "</td><td>";
 print yn($don->public);
 print "</td></tr>\n";
 print "<tr>" . '<td>' . $langs->trans("Company") . '</td><td>' . $don->societe . '</td></tr>';
 print "<tr>" . '<td>' . $langs->trans("Firstname") . '</td><td>' . $don->firstname . '</td></tr>';
 print "<tr>" . '<td>' . $langs->trans("Lastname") . '</td><td>' . $don->lastname . '</td></tr>';
 print "<tr>" . '<td>' . $langs->trans("Address") . '</td><td>' . dol_nl2br($don->address) . '</td></tr>';
 // Zip / Town
 print "<tr>" . '<td>' . $langs->trans("Zip") . ' / ' . $langs->trans("Town") . '</td><td>' . $don->zip . ($don->zip && $don->town ? ' / ' : '') . $don->town . '</td></tr>';
 // Country
 print "<tr>" . '<td>' . $langs->trans("Country") . '</td><td>' . $don->country . '</td></tr>';
 // EMail
 print "<tr>" . '<td>' . $langs->trans("EMail") . '</td><td>' . dol_print_email($don->email) . '</td></tr>';
 // Payment mode
 print "<tr><td>" . $langs->trans("PaymentMode") . "</td><td>";
 print $form->form_modes_reglement(null, $don->modepaiementid, 'none');
 print "</td></tr>\n";
 print "<tr>" . '<td>' . $langs->trans("Status") . '</td><td>' . $don->getLibStatut(4) . '</td></tr>';
 // Project
 if (!empty($conf->projet->enabled)) {
     print "<tr>" . '<td>' . $langs->trans("Project") . '</td><td>' . $don->projet . '</td></tr>';
 }
Exemple #26
0
/**
 *	This function is called to encode a string into a HTML string but differs from htmlentities because
 * 	all entities but &,<,> are converted. This permits to encode special chars to entities with no double
 *  encoding for already encoded HTML strings.
 * 	This function also remove last CR/BR.
 *  For PDF usage, you can show text by 2 ways:
 *              - writeHTMLCell -> param must be encoded into HTML.
 *              - MultiCell -> param must not be encoded into HTML.
 *              Because writeHTMLCell convert also \n into <br>, if function
 *              is used to build PDF, nl2brmode must be 1.
 *	@param		stringtoencode		String to encode
 *	@param		nl2brmode			0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example)
 *  @param      pagecodefrom        Pagecode stringtoencode is encoded
 */
function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UTF-8')
{
    if (dol_textishtml($stringtoencode)) {
        $newstring = $stringtoencode;
        //$newstring=preg_replace('/([^<li\s*>]+)(\r\n|\r|\n)+/i',($forxml?'$1<br />':'$1<br>'),$stringtoencode); // Don't replace if in list
        //$newstring=preg_replace('/<li\s*>(\r\n|\r|\n)+/','__li__',$newstring); // Don't replace if \n is just after a li
        //$newstring=preg_replace('/(\r\n|\r|\n)+/i',($forxml?'<br />':'<br>'),$newstring); // If already HTML, CR should be <br> so we don't change \n
        $newstring = preg_replace('/<br(\\s[\\sa-zA-Z_="]*)?\\/?>/i', '<br>', $newstring);
        // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
        $newstring = preg_replace('/<br>$/i', '', $newstring);
        // Remove last <br>
        $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
        $newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom);
        // Make entity encoding
        $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
        //$newstring=strtr($newstring,array('__li__'=>"<li>\n")); // Restore <li>\n
    } else {
        $newstring = dol_nl2br(dol_htmlentities($stringtoencode, ENT_COMPAT, $pagecodefrom), $nl2brmode);
    }
    // Other substitutions that htmlentities does not do
    //$newstring=str_replace(chr(128),'&euro;',$newstring);	// 128 = 0x80. Not in html entity table.
    return $newstring;
}
Exemple #27
0
	// Note
    print '<tr><td valign="top">'.$langs->trans("Note").'</td>';
	print '<td valign="top" colspan="3">';
	if ($action == 'edit' && $user->rights->user->user->creer)
	{
		print "<input type=\"hidden\" name=\"action\" value=\"update\">";
		print "<input type=\"hidden\" name=\"id\" value=\"".$fuser->id."\">";
	    // Editeur wysiwyg
		require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
		$doleditor=new DolEditor('note',$fuser->note,'',280,'dolibarr_notes','In',true,false,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_USER,10,80);
		$doleditor->Create();
	}
	else
	{
		print dol_textishtml($fuser->note)?$fuser->note:dol_nl2br($fuser->note,1,true);
	}
	print "</td></tr>";

	if ($action == 'edit')
	{
		print '<tr><td colspan="4" align="center">';
		print '<input type="submit" class="button" name="update" value="'.$langs->trans("Save").'">';
		print '&nbsp; &nbsp;';
		print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
		print '</td></tr>';
	}

    print "</table>";
	print "</form>\n";
 /**
  * dol_nl2br
  *
  * @return void
  */
 public function testDolNl2Br()
 {
     //String to encode
     $string = "a\na";
     $this->assertEquals(dol_nl2br($string), "a<br>\na");
     //With $forxml parameter
     $this->assertEquals(dol_nl2br($string, 0, 1), "a<br />\na");
     //Replacing \n by br
     $this->assertEquals(dol_nl2br($string, 1), "a<br>a");
     //With $forxml parameter
     $this->assertEquals(dol_nl2br($string, 1, 1), "a<br />a");
 }