193 lines
7.1 KiB
PHP
193 lines
7.1 KiB
PHP
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Faktury: Produkty na fakturach:</h2></td></tr></table><br />
|
|
<ul class="tablist" style="width:100%;">
|
|
<li>
|
|
<a class="current" href="#">Podstawowe wyszukiwanie</a>
|
|
</li>
|
|
</ul>
|
|
<form action="index.php" method="get" name="SearchFormSales">
|
|
<input type="hidden" name="module" value="EcmInvoiceOutOlds" />
|
|
<input type="hidden" name="action" value="ListSales" />
|
|
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
|
|
<tbody>
|
|
<tr>
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">
|
|
Rok
|
|
</td>
|
|
<td class="dataField" width="30%" nowrap="nowrap">
|
|
<input name="year" id="year" value="<? echo $_REQUEST['year'];?>" title="" tabindex="" size="11" type="text">
|
|
</td>
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">
|
|
Index
|
|
</td>
|
|
<td class="dataField" width="30%" nowrap="nowrap">
|
|
<input name="code" id="code" value="<? echo $_REQUEST['code'];?>" title="" tabindex="" size="11" type="text">
|
|
</td>
|
|
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">
|
|
Ilość
|
|
</td>
|
|
<td class="dataField" width="30%" nowrap="nowrap">
|
|
<input name="quantity" id="quantity" value="<? echo $_REQUEST['quantity'];?>" title="" tabindex="" size="11" type="text">
|
|
</td>
|
|
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">
|
|
Cena
|
|
</td>
|
|
<td class="dataField" width="30%" nowrap="nowrap">
|
|
<input name="price" id="price" value="<? echo $_REQUEST['price'];?>" title="" tabindex="" size="11" type="text">
|
|
</td>
|
|
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">Kontrahent</td>
|
|
<td class="dataField" nowrap="nowrap">
|
|
<input name="account_name" tabindex="" id="account_name" size="" value="<?php echo $_REQUEST['account_name'];?>" title="" type="text">
|
|
<input name="account_id" id="account_id" value="<?php echo $_REQUEST['account_id'];?>" type="hidden">
|
|
<input name="btn_account_name" tabindex="" title="Wybierz [Alt+T]" accesskey="T" class="button" value="Wybierz" onclick='open_popup("Accounts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"SearchFormSales","field_to_name_array":{"id":"account_id","name":"account_name"}}, "single", true);' type="button"></td>
|
|
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<input class="button" name="submit" value="Szukaj" type="submit">
|
|
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmInvoiceOutOlds&action=ListSales';"><?php
|
|
echo ' <input type="button" class="button" name="gets" value="Utwórz PDFy" onclick="location.href=\'index.php?module=EcmInvoiceOutOlds&action=MultiCorPDF&year='.$_REQUEST['year'].'&account_id='.$_REQUEST['account_id'].'&account_name='.$_REQUEST['account_name'].'&parent_order_no='.$_REQUEST['parent_order_no'].'&submit=send&gets=1\';">';
|
|
?>
|
|
</form><br />
|
|
|
|
<?php
|
|
ini_set('display_errors',1);
|
|
set_time_limit(0);
|
|
$tds1='<td class="listViewThS1">';
|
|
|
|
$trs='<tr style="vertical-align:top;">';
|
|
$tre='</tr>';
|
|
|
|
$tds='<td class="oddListRowS1" style="vertical-align:top;">';
|
|
$tde='</td>';
|
|
|
|
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
|
|
$tbe='</table>';
|
|
|
|
$t.=$tbs;
|
|
$t.=$trs;
|
|
$t.=$tds1;
|
|
$t.="Index";
|
|
$t.=$tde;
|
|
$t.=$tds1;
|
|
$t.="Nazwa";
|
|
$t.=$tde;
|
|
$t.=$tds1;
|
|
$t.="Ilość";
|
|
$t.=$tde;
|
|
$t.=$tds1;
|
|
$t.="Cena";
|
|
$t.=$tde;
|
|
$t.=$tds1;
|
|
$t.="Nr dokumentu";
|
|
$t.=$tde;
|
|
$t.=$tds1;
|
|
$t.="Data rejestracji";
|
|
$t.=$tde;
|
|
$t.=$tre;
|
|
$i=1;
|
|
|
|
if($_REQUEST['year'])$wh[]="e.register_date like '".$_REQUEST['year']."%'";
|
|
if($_REQUEST['price'])$wh[]="p.price='".(float)str_replace(",",".",$_REQUEST['price'])."'";
|
|
if($_REQUEST['code'])$wh[]="p.code like '".$_REQUEST['code']."%'";
|
|
if($_REQUEST['quantity'])$wh[]="p.quantity>=".$_REQUEST['quantity']."";
|
|
if($_REQUEST['account_id'])$wh[]="e.parent_id='".$_REQUEST['account_id']."'";
|
|
if($_REQUEST['account_name'] && !$_REQUEST['account_id'])$wh[]="e.parent_name like '".$_REQUEST['account_name']."%'";
|
|
if(count($wh)>0)$where=" and ".implode(" and ",$wh);
|
|
else $where="";
|
|
|
|
if($_REQUEST['submit']){
|
|
$z="select id as iid from ecminvoiceoutolds as e where e.deleted='0'
|
|
and e.type='correct' and e.register_date like '2014%' and e.parent_id='94'";
|
|
echo $z;
|
|
$w=$GLOBALS['db']->query($z);
|
|
echo mysql_error();//echo $z;
|
|
|
|
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
|
$t.=$trs;
|
|
$t.=$tds;
|
|
$t.=$r['code'];
|
|
$t.=$tde;
|
|
$t.=$tds;
|
|
$t.=$r['name'];
|
|
$t.=$tde;
|
|
$t.=$tds;
|
|
$t.=number_format($r['quantity'],0,"","");
|
|
$t.=$tde;
|
|
$t.=$tds;
|
|
$t.=number_format($r['subprice'],2,",",".");
|
|
$t.=$tde;
|
|
$t.=$tds;
|
|
$t.='<a href="index.php?module=EcmInvoiceOutOlds&action=DetailView&record='.$r['iid'].'">'.$r['document_no'].'</a>';
|
|
$t.=$tde;
|
|
$t.=$tds;
|
|
$t.=$GLOBALS['timedate']->to_display_date($r['register_date']);
|
|
$t.=$tde;
|
|
$t.=$tre;
|
|
$i++;
|
|
require_once('modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php');
|
|
if($_REQUEST['gets']==1){
|
|
|
|
$strPath = dirname(__FILE__) . "\\";
|
|
|
|
$s = new EcmInvoiceOutOld();
|
|
$s->retrieve($r['iid']);
|
|
//$pdf2 = new PDFMerger;
|
|
$ab[]=$s->createPdfFileName();
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, 'http://192.168.1.130/crm/index.php?action=Authenticate&module=Users&return_module=Users&return_action=Login&user_name=db&user_password=rudemodz&login_theme=Sugar&login_language=en_us');
|
|
//curl_setopt($ch, CURLOPT_POSTFIELDS,'user_name=db&user_password='.$pass.'');
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
|
|
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
|
|
$page = curl_exec($ch);
|
|
//echo $page;
|
|
//echo $pass = md5('rudemodz');
|
|
$up='http://192.168.1.130/crm/index.php?module=EcmInvoiceOutOlds&action=previewPDF&type=&to_pdf=1&record='.$r['iid'].'';
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_URL, $up);
|
|
|
|
$page = curl_exec($ch);
|
|
$fp = fopen('pdftmp/'.$s->createPdfFileName().'', 'w');
|
|
fwrite($fp, $page);
|
|
fclose($fp);
|
|
//$pdf2->addPDF('pdftmp/'.$s->createPdfFileName().'', 'all');
|
|
}
|
|
}
|
|
}
|
|
if($_REQUEST['gets']==1){
|
|
|
|
//$pdf2->merge('file', 'pdftmp/TEST2.pdf');
|
|
$fp = fopen('generatorfifi2.php', 'w');
|
|
$s="<?php\ninclude 'PDFMerger.php';\n\$pdf = new PDFMerger;\n\$pdf";
|
|
foreach($ab as $k){
|
|
$s.="->addPDF('pdftmp/".$k."', 'all')\n";
|
|
}
|
|
$s.="->merge('file', 'pdftmp/".$current_user->user_name.date("h:y");
|
|
$s.=".pdf');";
|
|
//$b=microtime();
|
|
fwrite($fp, $s);
|
|
fclose($fp);
|
|
//echo microtime();
|
|
|
|
$up='http://192.168.1.130/crm/generatorfifi2.php';
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_URL, $up);
|
|
|
|
$page = curl_exec($ch);
|
|
|
|
|
|
header("Location: pdftmp/".$current_user->user_name.date("h:y").".pdf");
|
|
|
|
}
|
|
$t.=$tbe;
|
|
echo $t;
|
|
?>
|