Anda di halaman 1dari 8

Letter Template Developer Documentation

1. Add this code in upper section on below “// shipping method” into “card.php” into Estimate
Module. Search by “// shipping method”.

else if($action == 'ModTemplate' && $user->rights->nestimate->creer)

$id = GETPOST('estmid');

$result=$object->editTemplate($id,GETPOST('note_public'));

if ($result >0)

header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);

exit();

else

dol_print_error($db);

2. Add this code on “// Public note” in create New Estimate section.

// Public note

print '<tr>';

print '<td class="border1" valign="top">' . $langs->trans('NotePublic') . '</td>';

print '<td>'; // onchange="getNotes(this);"


require_once DOL_DOCUMENT_ROOT .
'/custom/notestemplate/class/notestemplate.class.php';

$notes = new Notestemplate($db);

$result = $notes->fetchAll();

print '<select name="notestemplate" id ="notestemplate" >';

print '<option value=""> - Select - </option>';

foreach($result as $val)

print '<option value='.$val->rowid.'>'.$val->label.'</option>';

print '</select>';

print '</td>';

print '</tr>';

print '<script type="text/javascript" language="javascript">';

print '$("#notestemplate").on("change", function() {

var param = new Array();

var noteid= $("#notestemplate").val();

param.push({name: "noteid", value: noteid});

param.push({name: "func", value: "getnote"});

$.post("ajax.php", param).done(function(data) {

CKEDITOR.instances.note_public.setData( data );

});

});';
print '</script>';

print '</tr>';

print '<tr>';

print '<td class="border1" valign="top">' . $langs->trans('NoteBody') . '</td>';

print '<td valign="top" colspan="2">';

$note_public = $object->getDefaultCreateValueFor('note_public',
(is_object($objectsrc)?$objectsrc->note_public:null));

$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false,


true, ROWS_3, '90%');

print $doleditor->Create(1);

print '</tr>';

3. Added this section under “Action presend” in card.php of Estimate module

if ($action == 'edittemplate')

require_once DOL_DOCUMENT_ROOT .
'/custom/notestemplate/class/notestemplate.class.php';

$notes = new Notestemplate($db);

$result = $notes->fetchAll();

print '<div id="templatehome" class="fichehalfright">

<div class="ficheaddleft">';

print '<form method="post" action="'.$_SERVER['PHP_SELF'].'#templatehome">';

print '<input type="hidden" name="action" value="ModTemplate">';

print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';

print '<input type="hidden" name="estmid" value='.$object->id.'>';

print '<table summary="" class="centpercent notopnoleftnoright"


style="margin-bottom: 2px;">';

print '<tbody>';
print '<tr>';

print '<td class="nobordernopadding" valign="middle">';

print '<div class="titre">'.$langs->trans('LetterTemplate').'</div>';

print '</td>';

print '</tr>';

print '</tbody>';

print '</table>';

print '<div class="div-table-responsive-no-min">';

print '<table class="liste formdoc noborder" summary="listofdocumentstable"


width="100%">';

print '<tbody>';

print '<tr class="liste_titre">';

print '<th align="center" colspan="5" class="formdoc liste_titre


maxwidthonsmartphone">';

print '<span class="hideonsmartphone">'.$langs->trans('SelectTemplate').' </span>';

print '&nbsp;';

print '<select name="notestemplate" id ="notestemplate">';

print '<option value=""> - Select - </option>';

foreach($result as $val)

print '<option value='.$val->rowid.'>'.$val->label.'</option>';

print '</select>';

print '<input type="submit" id="templatesave" class="button valignmiddle"


value="'.$langs->trans("Save").'">';

print'</th></tr>';

print '<tr class="oddeven">';

print '<td>';
$note_public = $object->note_public;

$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_details', 'In', 0,


false, true, ROWS_3, '90%');

print $doleditor->Create(1);

print '</td>';

print '</tr>';

print '</tbody>';

print '</table>';

print '</form>';

print '</div>';

print '</div></div>';

print '<script type="text/javascript" language="javascript">';

print '$("#notestemplate").on("change", function() {

var param = new Array();

var noteid= $("#notestemplate").val();

param.push({name: "noteid", value: noteid});

param.push({name: "func", value: "getnote"});

$.post("ajax.php", param).done(function(data) {

CKEDITOR.instances.note_public.setData( data );

});

});';

print '</script>';

else

{
print '<div id="templatehome" class="fichehalfright">

<div class="ficheaddleft">';

print '<table summary="" class="centpercent notopnoleftnoright"


style="margin-bottom: 2px;">';

print '<tbody>';

print '<tr>';

print '<td class="nobordernopadding" valign="middle">';

print '<div class="titre">'.$langs->trans('LetterTemplate').'</div>';

print '</td>';

print '</tr>';

print '</tbody>';

print '</table>';

print '<div class="div-table-responsive-no-min">';

print '<table class="liste formdoc noborder" summary="listofdocumentstable"


width="100%">';

print '<tbody>';

print '<tr class="liste_titre">';

print '<th align="center" colspan="5" class="formdoc liste_titre


maxwidthonsmartphone">';

print '<span
class="hideonsmartphone">'.$langs->trans('ClickToChangeTemplate').'</span>';

print '&nbsp;';

// print '<a href="' . $_SERVER["PHP_SELF"] . '?action=edittemplate&amp;id=' .


$object->id.'">';

print '<a href="' . $_SERVER["PHP_SELF"] . '?action=edittemplate&amp;id=' .


$object->id.'#templatehome">';

print '<input type="button" class="button valignmiddle"


value="'.$langs->trans("Modify").'">';

print '</a>';

print'</th></tr>';
print '<tr class="oddeven">';

print '<td>';

$note_public = $object->note_public;

$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_readonly', 'In',


0, false, true, ROWS_3, '90%');

print $doleditor->Create(1);

print '</td>';

print '</tr>';

print '</tbody>';

print '</table>';

print '</div>';

print '</div></div>';

4. Put the “ajax.php” file into the Estimate module

5. Add this function into “estimate.class.php” file under Estimate module under “function
replaceThirdparty” of “Estimate” class

function editTemplate($id,$content)

global $db, $conf;

$sql = "UPDATE ".MAIN_DB_PREFIX."nestimate SET note_public = '$content' ";

$sql.= "WHERE rowid = ".$id;

if ($this->db->query($sql))

return 1;

}
else

return -1;

Anda mungkin juga menyukai