<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* Sample page.
*/
include("include/fckeditor/fckeditor.php") ;
include('include/divers/default_cards.php');
if (isset($_POST['cards_x'])) $opt['card_x']=$_POST['cards_x'];
if (isset($_POST['tpl_name'])) $opt['tpl_name']=$_POST['tpl_name'];
if (isset($_POST['cards_y'])) $opt['card_y']=$_POST['cards_y'];
if (isset($_POST['margin_top'])) $opt['margin_top']=$_POST['margin_top'];
if (isset($_POST['tpl_name'])) $opt['tpl_name']=$_POST['tpl_name'];
if (isset($_POST['FCKeditor1'])) $fck_editor=$_POST['FCKeditor1'];
if (isset($_POST['margin_cell'])) $margin_cell=$_POST['margin_cell'];
//OpenWindow.document.write('<tr><div style=\"margin-left: 100px; margin-top: 100px\">');
echo "<script type='text/javascript'>
function doSave(){
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
document.getElementById('fck_editor').innerHTML = oEditor.EditorDocument.body.innerHTML ;
document.getElementById('card_show').innerHTML = 'Done with card template !';
document.getElementById('edit_card_id').innerHTML = '<input type=\"hidden\" name=\"fck_editor\" value=\''+oEditor.EditorDocument.body.innerHTML+'\'>';
}
function SaveTemplate(){
cards_x=document.getElementById('cards_x').value;
html=document.getElementById('fck_editor').innerHTML;
cards_y=document.getElementById('cards_y').value;
margin_cell=document.getElementById('margin_cell').value;
margin_top=document.getElementById('margin_top').value;
tpl_name=document.getElementById('tpl_name_fck').value;
tpls=document.getElementById('tpl_name');
tpls.options.add(new Option(tpl_name,tpl_name));
tpls.value=tpl_name;
new_value=document.getElementById('new_tpl').value;
loc_id=document.getElementById('loc_id').value;
var test=file('include/divers/save_card_tpl.php?html='+html+'&&cards_x='+cards_x+'&&cards_y='+cards_y+'&&tplname='+tpl_name+'&&margin_cell='+margin_cell+'&&margin_top='+margin_top+'&&new='+new_value+'&&locID='+loc_id);
alert(test);
}
function ChangeTpl(opt){
}
// called when FCKeditor is done starting..
function FCKeditor_OnComplete( editorInstance ){
editorInstance.LinkedField.form.onsubmit = doSave;
}
function submitForm(btn)
{
fck=document.getElementById('fck_editor').innerHTML;
if (btn.name=='test_cards') {
openwindow=window.open('', 'cards printing', 'width=800,height=600,status=yes,resizable=yes,menubar=yes,scrollbars=yes');
nb_card=document.getElementById('nb_card').value;
cards_x=document.getElementById('cards_x').value;
cards_y=document.getElementById('cards_y').value;
margin_cell=document.getElementById('margin_cell').value;
margin_top=document.getElementById('margin_top').value;
if (cards_x=='') cards_x=2;
html='<HTML>';
html+='<head><TITLE>Cards printing</TITLE>';
html+='<style type=\"text/css\">@page { size:landscape; margin-top:20cm; margin-right:0cm; margin-left:0cm; margin-bottom: 0px; marks:cross;}</style>';
html+='</head><body>';
html+='<table cellspacing=\"'+margin_cell+'\" style=\"margin-top: '+margin_top+'px; margin-left: auto; margin-right: auto;\" >';
x=0;
for (i=0;i<nb_card;) {
html+='<tr>';
for (j=0;j<cards_x;j++) {
html+='<td style=\"text-align: center; vertical-align: middle;\">';
html+=fck;
html+='</td>';
i++;
}
html+='</tr>';
x++;
if (x==cards_y) {
//html+='<p style=\"page-break-before:always;\"></p>';
}
}
html+='</table>';
html+='</body>';
html+='</HTML>';
openwindow.document.write(html);
openwindow.document.close();
}
else
document.getElementById('frm_tpl_name').submit();
}
function deleteTemplate()
{
tpl_name=document.getElementById('tpl_name').value;
loc_id=".$_SESSION['locID'].";
var test=file('include/divers/delete_tpl_fck.php?tpl_name='+tpl_name+'&&locID='+loc_id);
alert(test);
document.getElementById('frm_tpl_name').submit();
}
</script>";
// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
echo "<form id=\"frm_tpl_name\" name=\"frm_tpl_name\" action=\"phpmyprepaid.php\" method=\"post\">";
echo "<big><big style=\"font-family: Aircut\"><span style=\"font-weight: bold;\"><b>Cards configuration</span></b></big></big><br>
<hr>
<table>
<tr>
<td>Template name : </td>";
$result=$oreon->database->database->query("SELECT * FROM cards_tpl WHERE tpl_location='-1' or tpl_location='".$_SESSION['locID']."' group by tpl_name");
while ($row = $oreon->database->database->fetch_object($result)) {
$tpl_value[$row->tpl_name]=$row->tpl_value;
$tab.=$row->tpl_name.";";
}
if ($opt['tpl_name']=='') $opt['tpl_name']='default1';
echo '<td><select id="tpl_name" name="tpl_name" onChange="submitForm(this)">';
$tab2=split(';',$tab);
foreach ($tab2 as $val)
if ($opt['tpl_name']==$val) {
echo "<option selected=\"selected\" value=\"$val\">$val";
$fck_editor=stripslashes($tpl_value[$val]);
}
else
if ($val!='') echo "<option value=\"$val\">$val";
echo "</select></td>";
echo '<td><input type="button" class="smallButton" name="del_tpl" id="del_tpl" value="Delete Template" onclick="deleteTemplate()">';
echo "</td></tr></table></form><br>";
echo "<form name=\"frm_tpl\" action=\"phpmyprepaid.php\" method=\"post\" enctype=\"multipart/form-data\" >";
if (isset($_POST['fck_editor'])) {
$fck_editor=$_POST['fck_editor'];
$fck_editor=stripslashes($_POST['fck_editor']);
}
echo '<div class="fck_editor" id="fck_editor">'.$fck_editor.'</div>';
echo "<br><table><tr><td>";
//echo '</form>';
echo '<input type="hidden" id="name_tpl" name="tpl_name" value="'.$opt['tpl_name'].'">';
echo '<input type="hidden" name="buttonID" value="edit_tpl_card">';
echo '<div id="edit_card_id"></div>';
echo '<input type="submit" class="smallButton" value="Edit template">';
echo '</form></td><td>';
echo "<form name=\"frm_new_tpl\" action=\"phpmyprepaid.php\" method=\"post\">";
echo '<input type="hidden" name="buttonID" value="new_tpl_card">';
echo '<input type="submit" class="smallButton" value="New template">';
echo '</td></form>';
if ($buttonID=='edit_tpl_card' or $buttonID=='edit_card_tpl' or $buttonID=='new_tpl_card') {
echo '<td>';
echo '<input type="button" class="smallButton" name="test_cards" id="test_cards" value="Test with :" onclick="submitForm(this)">';
echo '</td><td><input id="nb_card" name="nb_card" size="3" value=15>cards';
echo '</td>';
}
echo '</tr></table>';
if ($buttonID=='edit_tpl_card' or $buttonID=='edit_card_tpl' or $buttonID=='new_tpl_card') {
$tpl_name=$_POST['tpl_name'];
$result=$oreon->database->database->query("SELECT * FROM cards_tpl WHERE (tpl_location='-1' or tpl_location='".$_SESSION['locID']."') and tpl_name='$tpl_name'");
while ($row = $oreon->database->database->fetch_object($result)) {
$tpl_value['cards_x']=$row->cards_x;
$tpl_value['tpl_name']=$row->tpl_name;
$tpl_value['cards_y']=$row->cards_y;
$tpl_value['margin_cell']=$row->margin_cell;
$tpl_value['margin_top']=$row->margin_top;
$tpl_value['loc_id']=$row->tpl_location;
}
echo "<br><hr><table><tr>";
echo '<input id="loc_id" type="hidden" name="loc_id" value="'.$tpl_value['loc_id'].'">';
echo "<td>Template name : </td>
<td><input id='tpl_name_fck' name=\"tpl_name_fck\" size=30 value=\"$tpl_name\"></td>
</tr><tr>";
if ($buttonID=='new_tpl_card') {
echo '<input id="new_tpl" type="hidden" name="new_tpl" value="True">';
}
else
echo '<input id="new_tpl" type="hidden" name="new_tpl" value="False">';
echo "<td>Number cards in X : </td>
<td><input id='cards_x' name=\"cards_x\" size=5 value=\"".$tpl_value['cards_x']."\"></td>
</tr><tr>";
echo "<td>Number cards in Y : </td>
<td><input id='cards_y' name=\"cards_y\" size=5 value=\"".$tpl_value['cards_y']."\"></td>
</tr><tr>";
echo "<td>Cell margin : </td>
<td><input id=\"margin_cell\" name=\"margin_cell\" size=5 value=\"".$tpl_value['margin_cell']."\"></td>
</tr><tr>";
echo "<td>Margin top: </td>
<td><input id=\"margin_top\" name=\"margin_top\" size=5 value=\"".$tpl_value['margin_top']."\"></td>
</tr><tr>";
echo '</tr></table>';
echo '<br><table><tr><td>';
echo '<input type="button" class="smallButton" value="Save template" onClick=\'javascript:SaveTemplate()\'>';
echo '</td></tr></table>';
echo '<br><div id="card_show">';
echo "<small> Different possible value are :<b><small> %login; %password; %validity; %location; %price; %creationdate; %billingplan %userid</small><br>";
echo "<FONT COLOR='#cc6600'><br><small> Don't forget to save ur template with the floppy icon !<b><br><br></FONT>";
echo "<form name=\"frm_edit_card\" action=\"phpmyprepaid.php\" method=\"post\">";
$sBasePath = $_SERVER['PHP_SELF'] ;
$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ;
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = "include/fckeditor/" ;
$oFCKeditor->Height = 400 ;
$oFCKeditor->Config['SkinPath'] = '../editor/skins/office2003/' ;
$oFCKeditor->Config['UserFilesPath'] = $images_path ;
if ($fck_editor=='')
$oFCKeditor->Value = $tpl1;
else
$oFCKeditor->Value = $fck_editor;
$oFCKeditor->Create() ;
echo '</form>';
}