Add php files
This commit is contained in:
34
import/EcmPriceBooks/AddToPriceBook.php
Normal file
34
import/EcmPriceBooks/AddToPriceBook.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?
|
||||
$result = $GLOBALS['db']->query("select name,id from ecmproducts where deleted='0'");
|
||||
$ile=$result->num_rows;
|
||||
if(!$_REQUEST['pricebook_id'])$_REQUEST['pricebook_id']=$_SESSION['add_to_pricebook_id'];
|
||||
$arr=array();
|
||||
for($i=0;$i<$ile;$i++)
|
||||
{
|
||||
if($_REQUEST['check'][$i])$arr[]=$i;
|
||||
}
|
||||
|
||||
foreach($arr as $i)
|
||||
{
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select remarks from ecmproduct_language where language='PL' and ecmproduct_id='".$_REQUEST['check'][$i]."'"));
|
||||
$remarks_pl=$rr['remarks'];
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select remarks from ecmproduct_language where language='EN' and ecmproduct_id='".$_REQUEST['check'][$i]."'"));
|
||||
$remarks_en=$rr['remarks'];
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select remarks from ecmproduct_language where language='DE' and ecmproduct_id='".$_REQUEST['check'][$i]."'"));
|
||||
$remarks_de=$rr['remarks'];
|
||||
|
||||
$w=$GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and deleted='0' and ecmproduct_id='".$_REQUEST['check'][$i]."'");
|
||||
$price=floatval(str_replace(",",".",$_REQUEST['list_price_'.$_REQUEST['check'][$i]]));
|
||||
if(mysql_num_rows($w)==0)
|
||||
{
|
||||
$GLOBALS['db']->query("insert into ecmpricebooks_ecmproducts(id,ecmpricebook_id,ecmproduct_id,deleted,price,remarks_pl,remarks_en,remarks_de,created_by,date_entered,date_modified,modified_user_id) values('".create_guid()."','".$_REQUEST['pricebook_id']."','".$_REQUEST['check'][$i]."','0','".$price."','".$remarks_pl."','".$remarks_en."','".$remarks_de."','".$_SESSION['authenticated_user_id']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','".$_SESSION['authenticated_user_id']."')");
|
||||
}
|
||||
else
|
||||
{
|
||||
$z="update ecmpricebooks_ecmproducts set price='".$price."' where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$_REQUEST['check'][$i]."'";
|
||||
$GLOBALS['db']->query($z);
|
||||
}
|
||||
}
|
||||
//print mysql_error();
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['pricebook_id']."&tab=items");
|
||||
?>
|
||||
374
import/EcmPriceBooks/CreatePDF.php
Normal file
374
import/EcmPriceBooks/CreatePDF.php
Normal file
@@ -0,0 +1,374 @@
|
||||
<?php
|
||||
set_time_limit(99999999);
|
||||
define('RELATIVE_PATH','include/html2fpdf/');
|
||||
define('FPDF_FONTPATH','include/html2fpdf/font/');
|
||||
require_once("include/html2fpdf/html2fpdf.php");
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
|
||||
$_SESSION['pricebook_images']=$_REQUEST['images'];
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,description,ecmlanguage,currency_value from ecmpricebooks where id='".$_SESSION['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$description=$r['description'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
$lang=$_REQUEST['langs'];
|
||||
//echo $lang;
|
||||
//die($lang);
|
||||
$er_value=$r['currency_value'];
|
||||
if(!$er_value){
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
}
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
$lc=0;
|
||||
foreach($t as $tt)
|
||||
{
|
||||
if($tt!="")$lc++;
|
||||
}
|
||||
if($lc>3)
|
||||
{
|
||||
$width=1100;
|
||||
$widthl=1020;
|
||||
$or="L";
|
||||
$title_width=$width-500;
|
||||
if($_REQUEST['images']=="true" || (!$_REQUEST['images'] && $_SESSION['pricebook_images_pdf']))
|
||||
{
|
||||
$l=5;
|
||||
$height=100;
|
||||
$product_name_width=400;
|
||||
if ($lc>=4) $product_name_width = 300;
|
||||
}
|
||||
else
|
||||
{
|
||||
$l=8;
|
||||
$height=50;
|
||||
$product_name_width=500;
|
||||
}
|
||||
}
|
||||
elseif($lc==0){
|
||||
$width=720;
|
||||
$widthl=670;
|
||||
$or="P";
|
||||
$title_width=$width-500;
|
||||
if($_REQUEST['images']=="true" || (!$_REQUEST['images'] && $_SESSION['pricebook_images_pdf']))
|
||||
{
|
||||
$l=8;
|
||||
$height=100;
|
||||
$product_name_width=620;
|
||||
}
|
||||
else
|
||||
{
|
||||
$l=16;
|
||||
$height=50;
|
||||
$product_name_width=720;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$width=720;
|
||||
$widthl=670;
|
||||
$or="P";
|
||||
$title_width=$width-500;
|
||||
if($_REQUEST['images']=="true" || (!$_REQUEST['images'] && $_SESSION['pricebook_images_pdf']))
|
||||
{
|
||||
$l=8;
|
||||
$height=100;
|
||||
$product_name_width=200;
|
||||
}
|
||||
else
|
||||
{
|
||||
$l=16;
|
||||
$height=50;
|
||||
$product_name_width=300;
|
||||
}
|
||||
}
|
||||
//if(in_array($c,"name"))@$col_width=($width-$product_name_width)/($lc-1);
|
||||
//else
|
||||
$isname=false;
|
||||
foreach($c as $ccc){
|
||||
if($ccc=="name"){
|
||||
$isname=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($isname){
|
||||
if($_REQUEST['images']=="true")@$col_width=($width-100-$product_name_width)/($lc-1);
|
||||
else @$col_width=($width-$product_name_width)/($lc-1);
|
||||
}
|
||||
else{
|
||||
if($_REQUEST['images']=="true")@$col_width=($width-100)/$lc;
|
||||
else @$col_width=($width)/$lc;
|
||||
}
|
||||
|
||||
$pdf = new HTML2FPDF($or);
|
||||
$pdf->lMargin = 3;
|
||||
$pdf->rMargin = 0;
|
||||
$pdf->tMargin = 0;
|
||||
$pdf->bMargin = 0;
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
//print $where;
|
||||
$z="select
|
||||
ecmpricebooks_ecmproducts.price as price,
|
||||
ecmpricebooks_ecmproducts.recipient_code as recipient_code,
|
||||
ecmpricebooks_ecmproducts.id as idp,
|
||||
ecmpricebooks_ecmproducts.remarks_pl as remarks_pl,
|
||||
ecmpricebooks_ecmproducts.remarks_en as remarks_en,
|
||||
ecmpricebooks_ecmproducts.remarks_de as remarks_de,
|
||||
|
||||
|
||||
ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate,
|
||||
|
||||
ecmproduct_language_pl_view.ean as ean_pl,
|
||||
ecmproduct_language_pl_view.short_description as short_description_pl,
|
||||
ecmproduct_language_pl_view.long_description as long_description_pl,
|
||||
ecmproduct_language_pl_view.remarks as default_remarks_pl,
|
||||
|
||||
ecmproduct_language_en_view.ean as ean_en,
|
||||
ecmproduct_language_en_view.short_description as short_description_en,
|
||||
ecmproduct_language_en_view.long_description as long_description_en,
|
||||
ecmproduct_language_en_view.remarks as default_remarks_en,
|
||||
|
||||
ecmproduct_language_de_view.ean as ean_de,
|
||||
ecmproduct_language_de_view.short_description as short_description_de,
|
||||
ecmproduct_language_de_view.long_description as long_description_de,
|
||||
ecmproduct_language_de_view.remarks as default_remarks_de
|
||||
|
||||
from ecmpricebooks_ecmproducts
|
||||
|
||||
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
where ".$where." ecmpricebooks_ecmproducts.ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
|
||||
//$z.="order by ecmproducts.product_category_name asc,ecmpricebooks_ecmproducts.price asc";
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
else
|
||||
$z.=" order by ecmpricebooks_ecmproducts.position";
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
//print mysql_error();
|
||||
$j=0;
|
||||
$k=0;
|
||||
$st=0;
|
||||
$ile=1 + ceil(($result->num_rows-$l)/($l+1));
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
$stop[$row['count']]=false;
|
||||
$stop[$row['code']]=false;
|
||||
$sale30="";
|
||||
$qty30="";
|
||||
$sale90="";
|
||||
$qty90="";
|
||||
$sale180="";
|
||||
$qty180="";
|
||||
if($j==0)
|
||||
{
|
||||
if ($st==0) {
|
||||
|
||||
$html.='<table border="0" width="'.$width.'"><tr height="140" width="'.$width.'">';
|
||||
$html.='<td style="padding-right:0px" height="140" align="center" width="900"><img src="modules/EcmPriceBooks/card_images/topper.jpg" border="0" width="800" height="100"></td>';
|
||||
$html.='<td height="140" align="center" width="150"><font color="#808080">'.iconv("UTF-8","ISO-8859-2",$description).'</font></td>';
|
||||
$html.='</tr></table>';
|
||||
} else {
|
||||
$html.='<table border="0" width="'.$width.'"><tr height="40" width="'.$width.'">';
|
||||
$html.='<td style="padding-right:0px" height="40" align="center" width="900"><img src="modules/EcmPriceBooks/card_images/cennik.jpg" border="0" width="30" height="30"></td>';
|
||||
$html.='<td height="40" align="center" width="150"></td>';
|
||||
$html.='</tr></table>';
|
||||
}
|
||||
if ($st==1) $l++;
|
||||
$html.='<table border=1><tr align="center" height="30" width="'.$width.'">';
|
||||
if($_REQUEST['images']=="true" || (!$_REQUEST['images'] && $_SESSION['pricebook_images_pdf']))$html.='<td bgcolor="#008CD1" height="30" width="80"> </td>';
|
||||
//$html.='<td bgcolor="#FF6600" align="center" height="30" width="'.$product_name_width.'"><font color="#ffffff">Product name</font></td>';
|
||||
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
if($c[$i]=="name")$html.='<td bgcolor="#008CD1" align="center" height="30" width="'.$product_name_width.'"><font color="#ffffff">'.$t[$i].'</font></td>';
|
||||
elseif($t[$i])$html.='<td bgcolor="#008CD1" align="center" height="30" width="'.$col_width.'"><font color="#ffffff">'.iconv("UTF-8","ISO-8859-2",$t[$i]).'</font></td>';
|
||||
}
|
||||
$html.='</tr>';
|
||||
}
|
||||
|
||||
//if ($j % 2 == 1) $bg = 'bgcolor="#EBEDED"'; else $bg='';
|
||||
|
||||
$html.='<tr height="'.$height.'" width="'.$width.'">';
|
||||
if($_REQUEST['images']=="true")$html.='<td '.$bg.' height="'.$height.'" align="left" width="100">';
|
||||
if($_REQUEST['images']=="true" && (substr($row['product_picture'],-3,3)=="jpg" || substr($row['product_picture'],-3,3)=="png" || substr($row['product_picture'],-3,3)=="gif" || substr($row['product_picture'],-4,4)=="jpeg") && file_exists("modules/EcmProducts/upload/images/".$row['product_picture']) && $row['product_picture']){
|
||||
|
||||
$image_big='modules/EcmProducts/upload/images/'.$row['product_picture'];
|
||||
$image_thumb='modules/EcmProducts/upload/images/thumbs/'.$row['product_picture'];
|
||||
|
||||
if(!file_exists($image_thumb)){
|
||||
$imgo=@GetImageSize($image_big);
|
||||
resizeImage($image_big,100,100,$image_thumb,100);
|
||||
}
|
||||
/*
|
||||
$imgo=@GetImageSize($image_big);
|
||||
$is=90;
|
||||
if($imgo[0]>=$is){
|
||||
$widtho=$is;
|
||||
$heighto=$imgo[1]*$widtho/$imgo[0];
|
||||
if($heighto>$is){
|
||||
$heighto=$is;
|
||||
$widtho=$imgo[0]*$heighto/$imgo[1];
|
||||
}
|
||||
}
|
||||
else{
|
||||
$widtho=$imgo[0];
|
||||
$heighto=$imgo[1];
|
||||
}*/
|
||||
$widtho=90;
|
||||
$heighto=84;
|
||||
if(file_exists('modules/EcmProducts/upload/images/thumbs/'.$row['product_picture']))$html.='<img src="modules/EcmProducts/upload/images/thumbs/'.$row['product_picture'].'" width='.$widtho.' height='.$heighto.'>';
|
||||
else $html.="o";
|
||||
}
|
||||
if($_REQUEST['images']=="true")$html.='</td>';
|
||||
//$html.='<td valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['name']).'</td>';
|
||||
/*
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select purchase_price from ecmproducts where id='".$row['id']."'"));
|
||||
$purchase_price=$rr['purchase_price'];
|
||||
@$margin=100-(100*$purchase_price/$row['price']);
|
||||
$margin=number_format($margin,2,",",".");*/
|
||||
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
if($t[$i])
|
||||
{
|
||||
if(($c[$i]=="sale_qty30" || $c[$i]=="sale_qty90" || $c[$i]=="sale_qty180" || $c[$i]=="sale_avg_price30" || $c[$i]=="sale_avg_price90" || $c[$i]=="sale_avg_price180") && $stop[$row['code']]==false){
|
||||
$w=$GLOBALS['db']->query("select ecmproducts_fk_list.price as price,ecmproducts_fk_list.quantity as quantity,ecmproducts_fk_list.date as date from ecmproducts_fk_list where ecmproducts_fk_list.code like '".$row['code']."'");
|
||||
//echo mysql_error();die();
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$date=date("Y-m");
|
||||
$m=(int)date("m");
|
||||
$date1=date("Y-m",mktime(0,0,0,($m-1),1,date("Y")));
|
||||
$date2=date("Y-m",mktime(0,0,0,($m-2),1,date("Y")));
|
||||
$date3=date("Y-m",mktime(0,0,0,($m-3),1,date("Y")));
|
||||
$date4=date("Y-m",mktime(0,0,0,($m-4),1,date("Y")));
|
||||
$date5=date("Y-m",mktime(0,0,0,($m-5),1,date("Y")));
|
||||
$date6=date("Y-m",mktime(0,0,0,($m-6),1,date("Y")));
|
||||
|
||||
$d=explode("-",$r['date']);
|
||||
|
||||
$dd=$d[0]."-".$d[1];
|
||||
|
||||
if($dd==$date || $dd==$date1){
|
||||
$sale30+=$r['price']*$r['quantity'];
|
||||
$qty30+=$r['quantity'];
|
||||
$aq30[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date || $dd==$date1 || $dd==$date2 || $dd==$date3){
|
||||
$sale90+=$r['price']*$r['quantity'];
|
||||
$qty90+=$r['quantity'];
|
||||
$aq390[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date || $dd==$date1 || $dd==$date2 || $dd==$date3 || $dd==$date4 || $dd==$date5 || $dd==$date6){
|
||||
$sale180+=$r['price']*$r['quantity'];
|
||||
$qty180+=$r['quantity'];
|
||||
$aq180[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
}
|
||||
if($qty>0)$sq=round($sale/$qty,2);
|
||||
if($qty30>0)$sq30=round($sale30/$qty30,2);
|
||||
else $sq30="";
|
||||
if($qty90>0)$sq90=round($sale90/$qty90,2);
|
||||
else $sq90="";
|
||||
if($qty180>0)$sq180=round($sale180/$qty180,2);
|
||||
else $sq180="";
|
||||
$stop[$row['code']]=true;
|
||||
}
|
||||
|
||||
//if ($j % 2 == 0) $bg = 'bgcolor="#EBEDED"';
|
||||
|
||||
$tds='<td '.$bg.' valign="top" align="center" height="'.$height.'" width="'.$col_width.'">';
|
||||
$tde='</td>';
|
||||
|
||||
if($c[$i]=="ordered")$html.=$tds.number_format($row['ordered'],0,"","").$tde;
|
||||
elseif($c[$i]=="sale_qty30")$html.=$tds.number_format($qty30,0,"","").$tde;
|
||||
elseif($c[$i]=="sale_qty90")$html.=$tds.number_format($qty90,0,"","").$tde;
|
||||
elseif($c[$i]=="sale_qty180")$html.=$tds.number_format($qty180,0,"","").$tde;
|
||||
elseif($c[$i]=="sale_avg_price30")$html.=$tds.number_format($sq30,2,",",".").$tde;
|
||||
elseif($c[$i]=="sale_avg_price90")$html.=$tds.number_format($sq90,2,",",".").$tde;
|
||||
elseif($c[$i]=="sale_avg_price180")$html.=$tds.number_format($sq180,2,",",".").$tde;
|
||||
elseif($c[$i]=="ems_qty_in_stock")$html.=$tds.number_format($row['ems_qty_in_stock'],2,"","").$tde;
|
||||
elseif($c[$i]=="list_price")$html.=$tds.iconv("UTF-8","ISO-8859-2",addExchangeRateValue($row['price'],$c[$i],$er_value)).$tde;
|
||||
elseif($c[$i]=="margin_rate")$html.=$tds.number_format($row['margin_rate'],2,",",".").$tde;
|
||||
elseif($c[$i]=="name"){
|
||||
if($lang=="en_us"){
|
||||
$html.='<td '.$bg.' valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['short_description_en']).'</td>';
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
$html.='<td '.$bg.' valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['short_description_de']).'</td>';
|
||||
}
|
||||
else $html.='<td '.$bg.' valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['name']).'</td>';
|
||||
}
|
||||
elseif($c[$i]=="product_category_name"){
|
||||
if($lang=="en_us"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_en from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
$html.=$tds.iconv("UTF-8","ISO-8859-2",$rrp['name_en']).$tde;
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_de from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
$html.=$tds.iconv("UTF-8","ISO-8859-2",$rrp['name_de']).$tde;
|
||||
}
|
||||
else $html.=$tds.iconv("UTF-8","ISO-8859-2",$row['product_category_name']).$tde;
|
||||
}
|
||||
else $html.=$tds.iconv("UTF-8","ISO-8859-2",addExchangeRateValue($row[$c[$i]],$c[$i],$er_value)).$tde;
|
||||
}
|
||||
}
|
||||
$html.='</tr>';
|
||||
$j++;
|
||||
$k++;
|
||||
|
||||
if($j==$l || $result->num_rows==$k)
|
||||
{
|
||||
$st++;
|
||||
$html.='</table>';
|
||||
$html.='<table border="0" width="'.$width.'"><tr height="30" width="'.$width.'">';
|
||||
$html.='<td height="30" align="left" width="'.$widthl.'"><img src="modules/EcmPriceBooks/card_images/footer.jpg" width="300" height="50"/></td>';
|
||||
$html.='<td height="30" align="right" width="80">'.$st.'/'.$ile.'</td>';
|
||||
$html.='</tr></table>';
|
||||
$ohtml=$html;
|
||||
$html='';
|
||||
$pdf->AddPage();
|
||||
$pdf->WriteHTML($ohtml);
|
||||
$j=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($_REQUEST['disposition']=="I")
|
||||
{
|
||||
$pdf->Output("Products.pdf", "I");
|
||||
}
|
||||
elseif($_REQUEST['disposition']=="D")
|
||||
{
|
||||
$pdf->Output("Products.pdf", "D");
|
||||
}
|
||||
else
|
||||
{
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
$pdf->Output("cache/upload/Products".$microtime.".pdf", "F");
|
||||
}
|
||||
?>
|
||||
73
import/EcmPriceBooks/CreateXLS.csv.php
Normal file
73
import/EcmPriceBooks/CreateXLS.csv.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
|
||||
if($_REQUEST['disposition']=="D")
|
||||
{
|
||||
header('Content-type: text/html; charset=windows-1250');
|
||||
header("Content-type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: attachment; filename=\"Products.csv\"");
|
||||
header('Pragma: private');
|
||||
header('Cache-control: private, must-revalidate');
|
||||
}
|
||||
else
|
||||
{
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
}
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
$z="select ecmpricebooks_ecmproducts.price as price,ecmpricebooks_ecmproducts.recipient_code as recipient_code,ecmpricebooks_ecmproducts.id as idp,ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate from ecmpricebooks_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id where ".$where."ecmpricebooks_ecmproducts.ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
print '"'.$t[$i].'",';
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")print '"'.addExchangeRateValue($row['price'],$c[$i],$er_value).'",';
|
||||
elseif($c[$i]=="margin_rate")print '"'.number_format($row['margin_rate'],2,",",".").'",';
|
||||
else print '"'.iconv("utf-8","cp1250",addExchangeRateValue($row[$c[$i]],$c[$i],$er_value)).'",';
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
$j++;
|
||||
}
|
||||
|
||||
?>
|
||||
128
import/EcmPriceBooks/CreateXLS.ok.php
Normal file
128
import/EcmPriceBooks/CreateXLS.ok.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?
|
||||
//require_once('include/write_excell/Worksheet.php');
|
||||
//require_once('include/write_excell/Workbook.php');
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
require_once('include/we/OLEwriter.php');
|
||||
require_once('include/we/BIFFwriter.php');
|
||||
require_once('include/we/Worksheet.php');
|
||||
require_once('include/we/Workbook.php');
|
||||
|
||||
if($_REQUEST['disposition']=="D")
|
||||
{
|
||||
header('Content-type: text/html; charset=windows-1250');
|
||||
header("Content-type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: attachment; filename=\"Products.xls\"");
|
||||
header('Pragma: private');
|
||||
header('Cache-control: private, must-revalidate');
|
||||
$workbook = new Workbook("-");
|
||||
}
|
||||
else
|
||||
{
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
$workbook = new Workbook("cache/upload/Products".$microtime.".xls");
|
||||
}
|
||||
|
||||
$worksheet =& $workbook->add_worksheet('arkusz');
|
||||
$worksheet->set_column(0, 0, 45);
|
||||
$worksheet->set_column(1, 9, 15);
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_SESSION['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
//print $where;
|
||||
$z="select
|
||||
ecmpricebooks_ecmproducts.price as price,
|
||||
ecmpricebooks_ecmproducts.recipient_code as recipient_code,
|
||||
ecmpricebooks_ecmproducts.id as idp,
|
||||
ecmpricebooks_ecmproducts.remarks_pl as remarks_pl,
|
||||
ecmpricebooks_ecmproducts.remarks_en as remarks_en,
|
||||
ecmpricebooks_ecmproducts.remarks_de as remarks_de,
|
||||
|
||||
|
||||
ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate,
|
||||
|
||||
ecmproduct_language_pl_view.ean as ean_pl,
|
||||
ecmproduct_language_pl_view.short_description as short_description_pl,
|
||||
ecmproduct_language_pl_view.long_description as long_description_pl,
|
||||
ecmproduct_language_pl_view.remarks as default_remarks_pl,
|
||||
|
||||
ecmproduct_language_en_view.ean as ean_en,
|
||||
ecmproduct_language_en_view.short_description as short_description_en,
|
||||
ecmproduct_language_en_view.long_description as long_description_en,
|
||||
ecmproduct_language_en_view.remarks as default_remarks_en,
|
||||
|
||||
ecmproduct_language_de_view.ean as ean_de,
|
||||
ecmproduct_language_de_view.short_description as short_description_de,
|
||||
ecmproduct_language_de_view.long_description as long_description_de,
|
||||
ecmproduct_language_de_view.remarks as default_remarks_de
|
||||
|
||||
from ecmpricebooks_ecmproducts
|
||||
|
||||
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
where ".$where." ecmpricebooks_ecmproducts.ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
|
||||
//print $z;
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
print mysql_error();
|
||||
$header =& $workbook->addformat();
|
||||
$header->set_bold();
|
||||
$header->set_size(12);
|
||||
$header->set_color('blue');
|
||||
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
$worksheet->write_string(0,$i,dy($t[$i]),$header);
|
||||
}
|
||||
}
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")$worksheet->write($j,$i,dy(addExchangeRateValue($row['price'],$c[$i],$er_value)));
|
||||
elseif($c[$i]=="margin_rate")$worksheet->write($j,$i,dy(number_format($row['margin_rate'],2,",",".")));
|
||||
else $worksheet->write($j,$i,iconv("utf-8","windows-1250",addExchangeRateValue($row[$c[$i]],$c[$i],$er_value)));
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
|
||||
|
||||
$workbook->close();
|
||||
|
||||
?>
|
||||
240
import/EcmPriceBooks/CreateXLS.php
Normal file
240
import/EcmPriceBooks/CreateXLS.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
set_time_limit(99999999);
|
||||
ini_set('display_errors',1);
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,ecmlanguage,currency_value from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
$lang=$_REQUEST['langs2'];
|
||||
$er_value=$r['currency_value'];
|
||||
if(!$er_value){
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
}
|
||||
set_include_path('include/PHPExcel/');
|
||||
include 'PHPExcel.php';
|
||||
include 'PHPExcel/Writer/Excel2007.php';
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
$objPHPExcel = new PHPExcel();
|
||||
//print "t";
|
||||
$objPHPExcel->getProperties()->setCreator("E5 CRM");
|
||||
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
|
||||
$objPHPExcel->getProperties()->setTitle("Office 2007 PRICEBOOK");
|
||||
$objPHPExcel->getProperties()->setSubject("Office 2007 PRICEBOOK");
|
||||
$objPHPExcel->getProperties()->setDescription("PRICEBOOK");
|
||||
//print "t";
|
||||
|
||||
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
|
||||
array(
|
||||
'fill' => array(
|
||||
'type' => PHPExcel_Style_Fill::FILL_SOLID,
|
||||
'color' => array('argb' => 'FFCCFFCC')
|
||||
),
|
||||
'borders' => array(
|
||||
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
|
||||
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
|
||||
)
|
||||
),
|
||||
"A1:Z1"
|
||||
);
|
||||
|
||||
//print "t";
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
//print $where;
|
||||
$z="select
|
||||
ecmpricebooks_ecmproducts.price as price,
|
||||
ecmpricebooks_ecmproducts.recipient_code as recipient_code,
|
||||
ecmpricebooks_ecmproducts.id as idp,
|
||||
ecmpricebooks_ecmproducts.remarks_pl as remarks_pl,
|
||||
ecmpricebooks_ecmproducts.remarks_en as remarks_en,
|
||||
ecmpricebooks_ecmproducts.remarks_de as remarks_de,
|
||||
|
||||
|
||||
ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate,
|
||||
|
||||
ecmproduct_language_pl_view.ean as ean_pl,
|
||||
ecmproduct_language_pl_view.short_description as short_description_pl,
|
||||
ecmproduct_language_pl_view.long_description as long_description_pl,
|
||||
ecmproduct_language_pl_view.remarks as default_remarks_pl,
|
||||
|
||||
ecmproduct_language_en_view.ean as ean_en,
|
||||
ecmproduct_language_en_view.short_description as short_description_en,
|
||||
ecmproduct_language_en_view.long_description as long_description_en,
|
||||
ecmproduct_language_en_view.remarks as default_remarks_en,
|
||||
|
||||
ecmproduct_language_de_view.ean as ean_de,
|
||||
ecmproduct_language_de_view.short_description as short_description_de,
|
||||
ecmproduct_language_de_view.long_description as long_description_de,
|
||||
ecmproduct_language_de_view.remarks as default_remarks_de
|
||||
|
||||
from ecmpricebooks_ecmproducts
|
||||
|
||||
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
where ".$where." ecmpricebooks_ecmproducts.ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
if($_REQUEST['order_by']){
|
||||
$order=str_replace($_REQUEST['order_by']." desc",$_REQUEST['order_by']." ".$_REQUEST['sorder'],$order);
|
||||
$order=str_replace($_REQUEST['order_by']." asc",$_REQUEST['order_by']." ".$_REQUEST['sorder'],$order);
|
||||
}
|
||||
//$z.=" order by ".$_REQUEST['order_by'];
|
||||
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
|
||||
//print $z;
|
||||
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="name")$width="50";
|
||||
else $width="30";
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i])->setWidth($width);
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].'1',$t[$i]);
|
||||
|
||||
}
|
||||
}
|
||||
$j=2;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
$stop[$row['code']]=false;
|
||||
$stop[$row['code']]=false;
|
||||
$sale30="";
|
||||
$qty30="";
|
||||
$sale90="";
|
||||
$qty90="";
|
||||
$sale180="";
|
||||
$qty180="";
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if(($c[$i]=="sale_qty30" || $c[$i]=="sale_qty90" || $c[$i]=="sale_qty180" || $c[$i]=="sale_avg_price30" || $c[$i]=="sale_avg_price90" || $c[$i]=="sale_avg_price180") && $stop[$row['code']]==false){
|
||||
$w=$GLOBALS['db']->query("select ecmproducts_fk_list.price as price,ecmproducts_fk_list.quantity as quantity,ecmproducts_fk_list.date as date from ecmproducts_fk_list where ecmproducts_fk_list.code like '".$row['code']."'");
|
||||
//echo mysql_error();die();
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$date=date("Y-m");
|
||||
$m=(int)date("m");
|
||||
$date1=date("Y-m",mktime(0,0,0,($m-1),1,date("Y")));
|
||||
$date2=date("Y-m",mktime(0,0,0,($m-2),1,date("Y")));
|
||||
$date3=date("Y-m",mktime(0,0,0,($m-3),1,date("Y")));
|
||||
$date4=date("Y-m",mktime(0,0,0,($m-4),1,date("Y")));
|
||||
$date5=date("Y-m",mktime(0,0,0,($m-5),1,date("Y")));
|
||||
$date6=date("Y-m",mktime(0,0,0,($m-6),1,date("Y")));
|
||||
|
||||
$d=explode("-",$r['date']);
|
||||
|
||||
$dd=$d[0]."-".$d[1];
|
||||
|
||||
if($dd==$date || $dd==$date1){
|
||||
$sale30+=$r['price']*$r['quantity'];
|
||||
$qty30+=$r['quantity'];
|
||||
$aq30[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date || $dd==$date1 || $dd==$date2 || $dd==$date3){
|
||||
$sale90+=$r['price']*$r['quantity'];
|
||||
$qty90+=$r['quantity'];
|
||||
$aq390[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date || $dd==$date1 || $dd==$date2 || $dd==$date3 || $dd==$date4 || $dd==$date5 || $dd==$date6){
|
||||
$sale180+=$r['price']*$r['quantity'];
|
||||
$qty180+=$r['quantity'];
|
||||
$aq180[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
}
|
||||
if($qty>0)$sq=round($sale/$qty,2);
|
||||
if($qty30>0)$sq30=round($sale30/$qty30,2);
|
||||
else $sq30="";
|
||||
if($qty90>0)$sq90=round($sale90/$qty90,2);
|
||||
else $sq90="";
|
||||
if($qty180>0)$sq180=round($sale180/$qty180,2);
|
||||
else $sq180="";
|
||||
|
||||
$stop[$row['code']]=true;
|
||||
}
|
||||
|
||||
if($c[$i]=="ordered")$html.=$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['ordered']);
|
||||
elseif($c[$i]=="sale_qty30")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$qty30);
|
||||
elseif($c[$i]=="sale_qty90")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$qty90);
|
||||
elseif($c[$i]=="sale_qty180")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$qty180);
|
||||
elseif($c[$i]=="sale_avg_price30")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$sq30);
|
||||
elseif($c[$i]=="sale_avg_price90")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$sq90);
|
||||
elseif($c[$i]=="sale_avg_price180")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$sq180);
|
||||
elseif($c[$i]=="ems_qty_in_stock")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['ems_qty_in_stock']);
|
||||
elseif($c[$i]=="list_price")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,addExchangeRateValue($row['price'],$c[$i],$er_value,true));
|
||||
elseif($c[$i]=="margin_rate")$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['margin_rate']);
|
||||
elseif($c[$i]=="name"){
|
||||
if($lang=="en_us"){
|
||||
//$html.='<td valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['short_description_en']).'</td>';
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['short_description_en']);
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
//$html.='<td valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['short_description_en']).'</td>';
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['short_description_de']);
|
||||
}
|
||||
else {
|
||||
//$html.='<td valign="top" height="'.$height.'" width="'.$product_name_width.'">'.iconv("UTF-8","ISO-8859-2",$row['name']).'</td>';
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['name']);
|
||||
}
|
||||
}
|
||||
elseif($c[$i]=="product_category_name"){
|
||||
if($lang=="en_us"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_en from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
//$html.=$tds.iconv("UTF-8","ISO-8859-2",$rrp['name_en']).$tde;
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$rrp['name_en']);
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_de from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
//$html.=$tds.iconv("UTF-8","ISO-8859-2",$rrp['name_en']).$tde;
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$rrp['name_de']);
|
||||
}
|
||||
else {
|
||||
//$html.=$tds.iconv("UTF-8","ISO-8859-2",$row['product_category_name']).$tde;
|
||||
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,$row['product_category_name']);
|
||||
}
|
||||
}
|
||||
else $objPHPExcel->getActiveSheet()->SetCellValue($alf[$i].$j,addExchangeRateValue($row[$c[$i]],$c[$i],$er_value,true));
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
//print "t";
|
||||
//$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
//print "t";
|
||||
$microtime=str_replace(".","",str_replace(" ","",microtime()));
|
||||
$name="cache/upload/Products".$microtime.".xlsx";
|
||||
$objWriter->save($name);
|
||||
//print "tr";
|
||||
chmod($name,0777);
|
||||
//print $name;
|
||||
if($_REQUEST['disposition']=="D")header("Location: ".$name);
|
||||
?>
|
||||
72
import/EcmPriceBooks/CreateXLS1.php
Normal file
72
import/EcmPriceBooks/CreateXLS1.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
|
||||
header("Content-Type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: attachment; filename=Products.xls");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
$z="select ecmpricebooks_ecmproducts.price as price,ecmpricebooks_ecmproducts.recipient_code as recipient_code,ecmpricebooks_ecmproducts.id as idp,ecmproducts.*,
|
||||
if(ecmpricebooks_ecmproducts.price>0,(100-(100*ecmproducts.purchase_price/ecmpricebooks_ecmproducts.price)),0) as margin_rate from ecmpricebooks_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id where ".$where."ecmpricebooks_ecmproducts.ecmpricebook_id='".$_COOKIE['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
|
||||
$ca="abcdefghijklmnopqrstuvwxyz";
|
||||
$html='';
|
||||
$html.='<table border="1">';
|
||||
$html.='<tr>';
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
|
||||
$html.='<th><b>'.iconv("utf-8","cp1250",$t[$i]).'</b></th>';
|
||||
}
|
||||
}
|
||||
$html.='</tr>';
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
$html.='<tr>';
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")$html.='<td>'.iconv("utf-8","cp1250",addExchangeRateValue($row['price'],$c[$i],$er_value)).'</td>';
|
||||
elseif($c[$i]=="margin_rate")$html.='<td>'.number_format($row['margin_rate'],2,",",".").'</td>';
|
||||
else $html.='<td>'.iconv("utf-8","cp1250",addExchangeRateValue($row[$c[$i]],$c[$i],$er_value)).'</td>';
|
||||
}
|
||||
}
|
||||
$html.='</tr>';
|
||||
$j++;
|
||||
}
|
||||
$html.='</table>';
|
||||
echo $html;
|
||||
?>
|
||||
73
import/EcmPriceBooks/CreateXLS2.php
Normal file
73
import/EcmPriceBooks/CreateXLS2.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
require ("modules/EcmPriceBooks/excel.php");
|
||||
$workbook = "test.xls";
|
||||
$pathin = "/var/www/html/e5crm/vserver/e5crm.more7.com/www/e5test/modules/EcmPriceBooks/";
|
||||
$sheet = "test";
|
||||
$pathout = "/";
|
||||
|
||||
$E = new Excel;
|
||||
$E->XL($workbook,$pathin,$sheet);
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricebooks_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
$result = $GLOBALS['db']->query("select ecmpricebooks_ecmproducts.price as price,ecmpricebooks_ecmproducts.id as idp,ecmproducts.* from ecmpricebooks_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id where ".$where."ecmpricebooks_ecmproducts.ecmpricebook_id='".$_COOKIE['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0' order by ".$_SESSION['pricebook_order_by']." ".$_SESSION['pricebook_sorder']);
|
||||
|
||||
$header =& $workbook->addformat();
|
||||
$header->set_bold();
|
||||
$header->set_size(12);
|
||||
$header->set_color('blue');
|
||||
|
||||
$worksheet->write_string(0,0,"Product name",$header);
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
//$worksheet->write_string(0,$i+1,dy($t[$i]),$header);
|
||||
$E->writerange("sheet1","A".$i+1,$t[$i]);
|
||||
}
|
||||
}
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
$worksheet->write($j,0,dy($row['name']));
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")$E->writerange("sheet1",$alf[$j].$i+1,addExchangeRateValue($row['price'],$c[$i],$er_value));
|
||||
else $E->writerange("sheet1",$alf[$j].$i+1,addExchangeRateValue($c[$i],$c[$i],$er_value));
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
$E->saveas("newwkb",$pathout,"xls");
|
||||
$E->closexl();
|
||||
unset($E);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $current_user;
|
||||
|
||||
$dashletData['MyEcmPriceBooksDashlet']['searchFields'] = array(
|
||||
'date_entered' => array('default' => ''),
|
||||
'date_modified' => array('default' => ''),
|
||||
'assigned_user_id' => array('type' => 'assigned_user_name',
|
||||
'default' => $current_user->name)
|
||||
);
|
||||
|
||||
$dashletData['MyEcmPriceBooksDashlet']['columns'] = array(
|
||||
'name' => array(
|
||||
'width' => '40',
|
||||
'label' => 'LBL_LIST_NAME',
|
||||
'link' => true,
|
||||
'default' => true),
|
||||
'date_entered' => array(
|
||||
'width' => '15',
|
||||
'label' => 'LBL_DATE_ENTERED'),
|
||||
'date_modified' => array(
|
||||
'width' => '15',
|
||||
'label' => 'LBL_DATE_MODIFIED'),
|
||||
'created_by' => array(
|
||||
'width' => '8',
|
||||
'label' => 'LBL_CREATED'),
|
||||
'assigned_user_name' => array(
|
||||
'width' => '8',
|
||||
'label' => 'LBL_LIST_ASSIGNED_USER'),
|
||||
);
|
||||
?>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $app_strings;
|
||||
|
||||
$dashletMeta['MyEcmPriceBooksDashlet'] = array(
|
||||
'title' => translate('LBL_LIST_MY_ECMPRICEBOOKS', 'EcmPriceBooks'),
|
||||
'icon' => 'modules/EcmPriceBooks/images/EcmPriceBooks.gif',
|
||||
'description' => 'A customizable view into EcmPriceBooks',
|
||||
'category' => 'Module Views',
|
||||
'hidden' => true);
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/Dashlets/DashletGeneric.php');
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('modules/EcmPriceBooks/Dashlets/MyEcmPriceBooksDashlets/MyEcmPriceBooksDashlet.data.php');
|
||||
|
||||
class MyEcmPriceBooksDashlet extends DashletGeneric {
|
||||
function MyEcmPriceBooksDashlet($id, $def = null) {
|
||||
global $current_user, $app_strings, $dashletData;
|
||||
parent::DashletGeneric($id, $def);
|
||||
|
||||
$this->searchFields = $dashletData['MyEcmPriceBooksDashlet']['searchFields'];
|
||||
$this->columns = $dashletData['MyEcmPriceBooksDashlet']['columns'];
|
||||
|
||||
if(empty($def['title']))
|
||||
$this->title = translate('LBL_LIST_MY_ECMPRICEBOOKS', 'EcmPriceBooks');
|
||||
$this->seedBean = new EcmPriceBook();
|
||||
}
|
||||
|
||||
function displayOptions() {
|
||||
$this->processDisplayOptions();
|
||||
$this->configureSS->assign('searchFields', $this->currentSearchFields);
|
||||
return $this->configureSS->fetch($this->configureTpl);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
67
import/EcmPriceBooks/Delete.php
Normal file
67
import/EcmPriceBooks/Delete.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
|
||||
$focus = new EcmPriceBook();
|
||||
|
||||
// PERFORM THE DELETE IF GIVEN A RECORD TO DELETE
|
||||
if(!isset($_REQUEST['record']))
|
||||
sugar_die("A record number must be specified to delete the record.");
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
if(!$focus->ACLAccess('Delete')){
|
||||
ACLController::displayNoAccess(true);
|
||||
sugar_cleanup(true);
|
||||
}
|
||||
$focus->mark_deleted($_REQUEST['record']);
|
||||
|
||||
// NOW THAT THE DELETE HAS BEEN PERFORMED, RETURN TO GIVEN LOCATION
|
||||
header("Location: index.php?module=".$_REQUEST['return_module']."&action=".$_REQUEST['return_action']."&record=".$_REQUEST['return_id']);
|
||||
?>
|
||||
7
import/EcmPriceBooks/DeleteCustomView.php
Normal file
7
import/EcmPriceBooks/DeleteCustomView.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?
|
||||
$sugarEntry=true;
|
||||
global $db;
|
||||
$db->query("delete from ecmpricebooks_customview where id='".$_REQUEST['record']."'");
|
||||
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_COOKIE['pricebook_id']);
|
||||
?>
|
||||
33
import/EcmPriceBooks/DeleteFromPriceBook.php
Normal file
33
import/EcmPriceBooks/DeleteFromPriceBook.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?
|
||||
if($_REQUEST['action']!="DeleteFromPriceBook" || !$_REQUEST['but'])die();
|
||||
//echo $_REQUEST['return_id'];
|
||||
//print_r($_SESSION['pricebook_check']);
|
||||
/*
|
||||
$sugarEntry=true;
|
||||
global $db;
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set deleted='1' where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$_REQUEST['record']."'");
|
||||
$_REQUEST['customview_id']=$_COOKIE['customview_id'];
|
||||
include("modules/EcmPriceBooks/ListViewProductsAjax.php");*/
|
||||
$input=array();
|
||||
if(count($_SESSION['pricebook_check'][$_REQUEST['return_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_REQUEST['return_id']] as $key=>$value)
|
||||
{
|
||||
if($_SESSION['pricebook_check'][$_REQUEST['return_id']][$key]=="true")
|
||||
{
|
||||
//$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set date_modified='".date("Y-m-d H:i:s")."',modified_user_id='".$_SESSION['authenticated_user_id']."',deleted='1' where id='".$key."' and ecmpricebook_id='".$_REQUEST['return_id']."'");
|
||||
$input[]=$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
//print mysql_error();
|
||||
if(count($input)>0){
|
||||
echo '<form action="index.php?module=EcmPriceBooks&action=deleteProducts" method="post"><input type="hidden" value="'.implode("|",$input).'" name="keys"><input type="hidden" value="'.$_REQUEST['return_id'].'" name="return_id">Following products will be deleted:<br>';
|
||||
foreach($input as $in){
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select p.name,p.code from ecmproducts as p inner join ecmpricebooks_ecmproducts as e on e.ecmproduct_id=p.id where e.id='".$in."'"));
|
||||
echo $r['coce']." ".$r['name']."<br>";
|
||||
}
|
||||
echo '<br><input type="submit" name="del" value="Confirm"></form>';
|
||||
}
|
||||
|
||||
?>
|
||||
12
import/EcmPriceBooks/DeleteFromPriceBook1.php
Normal file
12
import/EcmPriceBooks/DeleteFromPriceBook1.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value)
|
||||
{
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true")
|
||||
{
|
||||
$GLOBALS['db']->query("delete from ecmpricebooks_ecmproducts where id='".$key."'");
|
||||
}
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['return_id']);
|
||||
?>
|
||||
301
import/EcmPriceBooks/DetailView.php
Normal file
301
import/EcmPriceBooks/DetailView.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
include ("modules/EcmProducts/moduleMenu.php");
|
||||
|
||||
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
||||
die ( 'Not A Valid Entry Point' );
|
||||
$_SESSION ['pricebook_duplicate_id'] = $_REQUEST ['record'];
|
||||
require_once ('XTemplate/xtpl.php');
|
||||
require_once ('data/Tracker.php');
|
||||
require_once ('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once ('modules/EcmPriceBooks/Forms.php');
|
||||
require_once ('include/DetailView/DetailView.php');
|
||||
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $db;
|
||||
|
||||
$focus = new EcmPriceBook ();
|
||||
|
||||
$detailView = new DetailView ();
|
||||
$offset = 0;
|
||||
|
||||
// ONLY LOAD A RECORD IF A RECORD ID IS GIVEN;
|
||||
// A RECORD ID IS NOT GIVEN WHEN VIEWING IN LAYOUT EDITOR
|
||||
if (isset ( $_REQUEST ['offset'] ) or isset ( $_REQUEST ['record'] )) {
|
||||
$result = $detailView->processSugarBean ( "ECMPRICEBOOKS", $focus, $offset );
|
||||
if ($result == null) {
|
||||
sugar_die ( $app_strings ['ERROR_NO_RECORD'] );
|
||||
}
|
||||
$focus = $result;
|
||||
} else {
|
||||
header ( "Location: index.php?module={EcmPriceBooks}&action=index" );
|
||||
}
|
||||
|
||||
if (isset ( $_REQUEST ['isDuplicate'] ) && $_REQUEST ['isDuplicate'] == 'true') {
|
||||
$focus->id = "";
|
||||
}
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title ( $mod_strings ['LBL_MODULE_ID'], $mod_strings ['LBL_MODULE_NAME'] . ": " . $focus->name, true );
|
||||
echo "\n</p>\n";
|
||||
global $theme;
|
||||
$theme_path = "themes/" . $theme . "/";
|
||||
$image_path = $theme_path . "images/";
|
||||
require_once ($theme_path . 'layout_utils.php');
|
||||
|
||||
if(!$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']){ $result = $GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts"); $checkc=''; while($ro=$GLOBALS['db']->fetchByAssoc($result)){ $_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$ro['id']]="true"; } $_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']="true"; }
|
||||
|
||||
$_SESSION['pricebook_check'][$_REQUEST['record']]['all']="true";
|
||||
$GLOBALS ['log']->info ( "EcmPriceBooks detail view" );
|
||||
$focus->format_all_fields ();
|
||||
$xtpl = new XTemplate ( 'modules/EcmPriceBooks/DetailView.html' );
|
||||
$xtpl->assign ( "MOD", $mod_strings );
|
||||
$xtpl->assign ( "APP", $app_strings );
|
||||
$xtpl->assign ( "THEME", $theme );
|
||||
$xtpl->assign ( "GRIDLINE", $gridline );
|
||||
$xtpl->assign ( "IMAGE_PATH", $image_path );
|
||||
$xtpl->assign ( "PRINT_URL", "index.php?" . $GLOBALS ['request_string'] );
|
||||
$xtpl->assign ( "ID", $focus->id );
|
||||
$xtpl->assign ( "ASSIGNED_TO", $focus->assigned_user_name );
|
||||
$xtpl->assign ( "NAME", $focus->name );
|
||||
$xtpl->assign ( "DATE_ENTERED", $focus->date_entered );
|
||||
$xtpl->assign ( "DATE_MODIFIED", $focus->date_modified );
|
||||
include ("modules/EcmDocs/Pagination.php");
|
||||
$xtpl->assign ( "PAGINATION1", getPagination ( "ecmpricebooks", "EcmPriceBooks", $_REQUEST ['record'] ) );
|
||||
|
||||
if ($focus->active == '1')
|
||||
$xtpl->assign ( 'ACTIVE', "Active" );
|
||||
elseif ($focus->active == '2')
|
||||
$xtpl->assign ( 'ACTIVE', "Inactive" );
|
||||
if ($focus->archived == '1')
|
||||
$xtpl->assign ( 'ARCHIVED', "checked" );
|
||||
$xtpl->assign ( "DESCRIPTION", nl2br ( url2html ( $focus->description ) ) );
|
||||
$r = $db->fetchByAssoc ( $db->query ( "select name from ecmproductexchangerates where id='" . $focus->exchange_rate_id . "'" ) );
|
||||
$focus->exchange_rate_name = $r ['name'];
|
||||
|
||||
$desc = '';
|
||||
$desc .= '<input title="Product Card" class="button" onclick="if(document.getElementById(\'div_desc2\').style.display==\'none\')document.getElementById(\'div_desc2\').style.display=\'block\';else document.getElementById(\'div_desc2\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="' . $mod_strings ['LBL_PRODUCT_CARD'] . '">';
|
||||
$desc .= '<div id="div_desc2" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
|
||||
$desc .= 'Generuj jako JPG: <select name="new_image" id="new_image"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
|
||||
$desc .= $mod_strings ['LBL_LIST_PRICE_NAME_A'] . ': <select name="new_show_price" id="new_show_price"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
|
||||
$desc .= $mod_strings ['LBL_LIST_PRICE_NAME'] . ': <select name="new_price" id="new_price"><option value="pricebook_price">Pricebook price</option><option value="srp_price">SRP Price</option></select><br /><br />';
|
||||
$desc .= $mod_strings ['LBL_LANGS'] . ': <select name="new_language" id="new_language"><option value="pl">pl</option><option value="en">en</option></select><br /><br />';
|
||||
$desc .= 'EAN: <select name="new_ean" id="new_ean"><option value="1">1</option><option value="2">2</option></select><br /><br />';
|
||||
$desc.='<input type="button" class="button" name="generate" id="generate" value="' . $mod_strings ['LBL_PRODUCT_CARD'] . '" onclick="window.open(\'index.php?module=EcmProducts&action=generateProductCardsFromPricebook&record='.$_REQUEST['record'].'&to_pdf=1&price=\'+document.getElementById(\'new_price\').value+\'&create_img=\'+document.getElementById(\'new_image\').value+\'&show_price=\'+document.getElementById(\'new_show_price\').value+\'&language=\'+document.getElementById(\'new_language\').value+\'&ean=\'+document.getElementById(\'new_ean\').value);"></div>';
|
||||
|
||||
|
||||
$xtpl->assign ( "CATALOGUE", $desc );
|
||||
|
||||
$xtpl->assign ( "EXCHANGE_RATE_NAME", $focus->exchange_rate_name );
|
||||
$xtpl->assign ( "EXCHANGE_RATE_ID", $focus->exchange_rate_id );
|
||||
$xtpl->assign ( "ACCOUNT_NAME", $focus->account_name );
|
||||
$xtpl->assign ( "ACCOUNT_ID", $focus->account_id );
|
||||
$xtpl->assign ( "LEAD_NAME", $focus->lead_name );
|
||||
$xtpl->assign ( "LEAD_ID", $focus->lead_id );
|
||||
if ($focus->name == "leobitepl" || $focus->name == "www.e5" || $focus->name == "getmir") {
|
||||
// $xtpl->assign("NAME_style", 'style="display:none;"');
|
||||
if ($focus->name == "leobitepl") {
|
||||
$addrl = "leobite.pl";
|
||||
$shop = "leobite";
|
||||
} elseif ($focus->name == "getmir") {
|
||||
$addrl = "getmir.com";
|
||||
$shop = "Getmir shop";
|
||||
} else {
|
||||
$addrl = "e5.pl";
|
||||
$shop = "e5 shop PL";
|
||||
}
|
||||
$xtpl->assign ( "LEOBITE", '<input title="Update prices on leobite"
|
||||
class="button"
|
||||
onclick="window.open(\'http://www.' . $addrl . '/administrator/components/com_virtuemart/more7_refreshStock.php?m7_debug=0&m7_test=1\');"
|
||||
type="button"
|
||||
name="upol"
|
||||
value=" Update prices on ' . $shop . ' ">' );
|
||||
}
|
||||
if ($focus->name == "www.e5") {
|
||||
$addrl = "shop-en.e5.pl";
|
||||
$shop = "e5 shop EN";
|
||||
$xtpl->assign ( "LEOBITEEN", '<input title="Update prices on leobite"
|
||||
class="button"
|
||||
onclick="window.open(\'http://' . $addrl . '/administrator/components/com_virtuemart/more7_refreshStock.php?m7_debug=0&m7_test=1\');"
|
||||
type="button"
|
||||
name="upol"
|
||||
value=" Update prices on ' . $shop . ' ">' );
|
||||
}
|
||||
/*
|
||||
$xtpl->assign ( "SHOWPDF", '<input title="Pokaż PDF"
|
||||
class="button"
|
||||
onclick="location.href=\'index.php?module=EcmPriceBooks&action=CreatePDF&record=' . $focus->id . '&to_pdf=1&disposition=D&images=\'+document.getElementById(\'images\').checked;"
|
||||
type="button"
|
||||
name="showpdf"
|
||||
value="Pokaż PDF">' ); */
|
||||
$xtpl->assign ( "SORT_ORDER", '<input title="Sortuj według"
|
||||
class="button"
|
||||
onclick="location.href=\'index.php?module=EcmPriceBooks&action=categoryOrder&record=' . $focus->id . '\';"
|
||||
type="button"
|
||||
name="sort_order"
|
||||
value="Sortuj według">' );
|
||||
require_once ('modules/Currencies/Currency.php');
|
||||
$currency = new Currency ();
|
||||
if (isset ( $focus->exchange_rate_id ) && ! empty ( $focus->exchange_rate_id )) {
|
||||
$currency->retrieve ( $focus->exchange_rate_id );
|
||||
if ($currency->deleted != 1) {
|
||||
$xtpl->assign ( "CURRENCY", $currency->iso4217 . ' ' . $currency->symbol );
|
||||
} else
|
||||
$xtpl->assign ( "CURRENCY", $currency->getDefaultISO4217 () . ' ' . $currency->getDefaultCurrencySymbol () );
|
||||
} else {
|
||||
|
||||
$xtpl->assign ( "CURRENCY", $currency->getDefaultISO4217 () . ' ' . $currency->getDefaultCurrencySymbol () );
|
||||
}
|
||||
|
||||
if ($_SESSION ['pricebook_images'] == "true")
|
||||
$xtpl->assign ( "IMAGES_CHECKED", "checked" );
|
||||
|
||||
global $current_user;
|
||||
|
||||
if (is_admin ( $current_user ) && $_REQUEST ['module'] != 'DynamicLayout' && ! empty ( $_SESSION ['editinplace'] )) {
|
||||
$xtpl->assign ( "ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST ['action'] . "&from_module=" . $_REQUEST ['module'] . "&record=" . $_REQUEST ['record'] . "'>" . get_image ( $image_path . "EditLayout", "border='0' alt='Edit Layout' align='bottom'" ) . "</a>" );
|
||||
}
|
||||
|
||||
$result = $db->query ( "select ecmproduct_id,price from ecmpricebooks_ecmproducts where ecmpricebook_id='" . $_REQUEST ['record'] . "' and deleted='0'" );
|
||||
|
||||
$products = "";
|
||||
while ( ($row = $db->fetchByAssoc ( $result )) != null ) {
|
||||
$row1 = $db->fetchByAssoc ( $db->query ( "select name from ecmproducts where id='" . $row ['ecmproduct_id'] . "' and deleted='0'" ) );
|
||||
$products .= $row1 ['name'] . ", price: " . $row ['price'] . "<br>";
|
||||
}
|
||||
$xtpl->assign ( "PRODUCTS", $products );
|
||||
|
||||
$result = $db->query ( "select id,name from ecmpricebooks_customview where name!='' order by name asc" );
|
||||
if (! $_COOKIE ['customview_id'] || $_COOKIE ['customview_id'] == "select" || $_COOKIE ['customview_id'] == "Select") {
|
||||
$rrr = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "select id,name from ecmpricebooks_customview where name!='' order by name asc" ) );
|
||||
setcookie ( "customview_id", $rrr ['id'], time () + 3600 * 24 * 60 );
|
||||
$_COOKIE ['customview_id'] = $rrr ['id'];
|
||||
}
|
||||
$products = "";
|
||||
$cv_select = '<select name="customview" onchange="mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=ListViewProductsAjax&customview_id=\'+this.value+\'&pricebook_id=' . $_REQUEST ['record'] . '&sorder=asc\',\'products\');" id="customview"><option>Select</option>';
|
||||
while ( ($row = $db->fetchByAssoc ( $result )) != null ) {
|
||||
$cv_select .= '<option value="' . $row ['id'] . '"';
|
||||
if ($_COOKIE ['customview_id'] == $row ['id'])
|
||||
$cv_select .= ' selected';
|
||||
$cv_select .= '>' . $row ['name'] . "</option>";
|
||||
}
|
||||
$cv_select .= '</select> <a style="cursor:pointer;" onclick="location.href=\'index.php?module=EcmPriceBooks&action=EditCustomView&record=\'+document.getElementById(\'customview\').value;">' . $mod_strings ['LBL_CV_EDIT'] . '</a> | <a style="cursor:pointer;" onclick="if(confirm(\'' . $mod_strings ['LBL_CV_QUESTION'] . '\'))location.href=\'index.php?module=EcmPriceBooks&action=DeleteCustomView&record=\'+document.getElementById(\'customview\').value;">' . $mod_strings ['LBL_CV_DELETE'] . '</a> | <a style="cursor:pointer;" onclick="location.href=\'index.php?module=EcmPriceBooks&action=EditCustomView\';">' . $mod_strings ['LBL_CV_CREATE'] . '</a><script>mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=ListViewProductsAjax&customview_id=' . $_COOKIE ['customview_id'] . '&pricebook_id=' . $_REQUEST ['record'] . '&sorder=asc\',\'products\');</script>';
|
||||
$xtpl->assign ( "CUSTOMVIEW_SELECT", $cv_select );
|
||||
|
||||
$xtpl->assign ( "CURRENCY_VALUE", $focus->currency_value );
|
||||
$xtpl->assign ( "CREATED_BY", $focus->created_by_name );
|
||||
$xtpl->assign ( "MODIFIED_BY", $focus->modified_by_name );
|
||||
$desc='';
|
||||
$desc.='<input title="'.$mod_strings ['LBL_SHOW_PDF'] .'" class="button" onclick="if(document.getElementById(\'div_desc\').style.display==\'none\')document.getElementById(\'div_desc\').style.display=\'block\';else document.getElementById(\'div_desc\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="Generuj PDF">';
|
||||
$desc .= '<div id="div_desc" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
|
||||
$lol="'index.php?to_pdf=1&module=EcmPriceBooks&action=selectImages','images'";
|
||||
$desc .=$mod_strings ['LBL_LANGS'] .' :<select tabindex="108" title="" id="langs" name="langs">
|
||||
<option selected="selected" value="pl_pl" label="Polski">PL</option>
|
||||
<option value="en_us" label="Angielski">US</option>
|
||||
</select><br>';
|
||||
$desc .= 'Pokaż zdjęcia: <input type="checkbox" value="1" id="images" name="images" onclick="mintajaxget('.$lol.');"/><br /><br />';
|
||||
$desc .= '<input title="Pokaż PDF"
|
||||
class="button"
|
||||
onclick="location.href=\'index.php?module=EcmPriceBooks&action=CreatePDF&record=' . $focus->id . '&to_pdf=1&disposition=D&images=\'+document.getElementById(\'images\').checked+\'&langs=\'+document.getElementById(\'langs\').value;"
|
||||
type="button"
|
||||
name="showpdf"
|
||||
value="'.$mod_strings ['LBL_SHOW_PDF'] .'"></div>';
|
||||
|
||||
|
||||
$xtpl->assign ("PDFGEN",$desc);
|
||||
$desc='';
|
||||
$desc.='<input title="'.$mod_strings ['LBL_SHOW_XLS2'] .'" class="button" onclick="if(document.getElementById(\'div_desc3\').style.display==\'none\')document.getElementById(\'div_desc3\').style.display=\'block\';else document.getElementById(\'div_desc3\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="Generuj XLS">';
|
||||
$desc .= '<div id="div_desc3" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
|
||||
//$lol="'index.php?to_pdf=1&module=EcmPriceBooks&action=selectImages','images'";
|
||||
$desc .=$mod_strings ['LBL_LANGS'] .' :<select tabindex="108" title="" id="langs2" name="langs2">
|
||||
<option selected="selected" value="pl_pl" label="Polski">PL</option>
|
||||
<option value="en_us" label="Angielski">US</option>
|
||||
</select><br>';
|
||||
//$desc .= 'Pokaż zdjęcia: <input type="checkbox" value="1" id="images" name="images" onclick="mintajaxget('.$lol.');"/><br /><br />';
|
||||
$desc.='<input value="'.$mod_strings ['LBL_SHOW_XLS'] .'"
|
||||
class="button"
|
||||
onclick="location.href=\'index.php?module=EcmPriceBooks&action=CreateXLS&to_pdf=1&disposition=D&langs2=\'+document.getElementById(\'langs2\').value;" type="button" >';
|
||||
$xtpl->assign("GENXLS",$desc);
|
||||
// $xtpl->assign("CATALOGUE",'<input type="button" class="button" value="Create Catalogue PL" onclick="location.href=\'index.php?module=EcmPriceBooks&action=createCatalogue&language=pl&record='.$focus->id.'&to_pdf=1\';"> <input type="button" class="button" value="Create Catalogue EN" onclick="location.href=\'index.php?module=EcmPriceBooks&action=createCatalogue&language=en&record='.$focus->id.'&to_pdf=1\';">');
|
||||
|
||||
$detailView->processListNavigation ( $xtpl, "ECMPRICEBOOKS", $offset, $focus->is_AuditEnabled () );
|
||||
|
||||
// ADDING CUSTOM FIELDS:
|
||||
require_once ('modules/DynamicFields/templates/Files/DetailView.php');
|
||||
|
||||
if (! empty ( $focus->id )) {
|
||||
$merge_button = <<<EOQ
|
||||
<input title="{$app_strings['LBL_DUP_MERGE']}" accessKey="M" class="button" onclick="this.form.return_module.value='EcmPriceBooks'; this.form.return_action.value='DetailView';this.form.return_id.value='{$focus->id}'; this.form.action.value='Step1'; this.form.module.value='MergeRecords';" type="submit" name="Merge" value=" {$app_strings['LBL_DUP_MERGE']} "/>
|
||||
EOQ;
|
||||
$xtpl->assign ( "FIND_DUPES_MERGE_BUTTON", $merge_button );
|
||||
}
|
||||
if ($_REQUEST ['tab'])
|
||||
$xtpl->assign ( "LOAD_TAB", "<script>showBlock('" . $_REQUEST ['tab'] . "');</script>" );
|
||||
$xtpl->parse ( "main" );
|
||||
$xtpl->out ( "main" );
|
||||
|
||||
$sub_xtpl = $xtpl;
|
||||
$old_contents = ob_get_contents ();
|
||||
ob_end_clean ();
|
||||
ob_start ();
|
||||
echo $old_contents;
|
||||
|
||||
require_once ('modules/SavedSearch/SavedSearch.php');
|
||||
$savedSearch = new SavedSearch ();
|
||||
$json = getJSONobj ();
|
||||
$savedSearchSelects = $json->encode ( array (
|
||||
$GLOBALS ['app_strings'] ['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . $savedSearch->getSelect ( 'EcmPriceBooks' )
|
||||
) );
|
||||
$str = "<script>
|
||||
YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, $savedSearchSelects);
|
||||
</script>";
|
||||
echo $str;
|
||||
setcookie ( "pricebook_id", $_REQUEST ['record'], time () + 60 * 24 * 60 * 3600 );
|
||||
$_SESSION ['pricebook_id'] = $_REQUEST ['record'];
|
||||
?>
|
||||
342
import/EcmPriceBooks/EcmPriceBook.php
Normal file
342
import/EcmPriceBooks/EcmPriceBook.php
Normal file
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
require_once('data/SugarBean.php');
|
||||
require_once('include/utils.php');
|
||||
|
||||
// SHOULD INCLUDE SELECTIVELY
|
||||
|
||||
|
||||
class EcmPriceBook extends SugarBean {
|
||||
var $field_name_map = array();
|
||||
// STANDARD FIELDS
|
||||
var $id;
|
||||
var $date_entered;
|
||||
var $date_modified;
|
||||
var $modified_user_id;
|
||||
var $assigned_user_id;
|
||||
var $name;
|
||||
|
||||
//TABLE COLUMNS
|
||||
var $active;
|
||||
var $description;
|
||||
var $exchange_rate_name;
|
||||
var $exchange_rate_id;
|
||||
var $account_name;
|
||||
var $account_id;
|
||||
var $lead_name;
|
||||
var $lead_id;
|
||||
var $price;
|
||||
var $ecmlanguage;
|
||||
|
||||
// RELATED FIELDS
|
||||
var $created_by;
|
||||
var $created_by_name;
|
||||
var $modified_by_name;
|
||||
var $assigned_user_name;
|
||||
|
||||
// SUBPANELS RELATED
|
||||
|
||||
// MODULE OBJECT DETAILS
|
||||
var $module_dir = 'EcmPriceBooks';
|
||||
var $table_name = "ecmpricebooks";
|
||||
var $object_name = "EcmPriceBook";
|
||||
|
||||
//RELATED TABLE NAMES
|
||||
|
||||
|
||||
// USED TO RETRIEVE RELATED FIELDS FROM FORM POSTS.
|
||||
var $additional_column_fields = Array(
|
||||
'assigned_user_name',
|
||||
'assigned_user_id',
|
||||
'modified_user_id',
|
||||
'created_by',
|
||||
);
|
||||
|
||||
var $relationship_fields = Array(
|
||||
//RELATIONSHIP FIELDS
|
||||
|
||||
);
|
||||
|
||||
function EcmPriceBook() {
|
||||
if(!$_REQUEST['isDuplicate'] && $_REQUEST['action']=="EditView")$_SESSION['pricebook_duplicate_id']="";
|
||||
parent::SugarBean();
|
||||
$this->setupCustomFields('EcmPriceBooks');
|
||||
foreach ($this->field_defs as $field)
|
||||
{
|
||||
$this->field_name_map[$field['name']] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
var $new_schema = true;
|
||||
|
||||
function get_summary_text(){
|
||||
return "$this->name";
|
||||
}
|
||||
|
||||
function create_list_query($order_by, $where, $show_deleted = 0){
|
||||
// Fill in the assigned_user_name
|
||||
$custom_join = $this->custom_fields->getJOIN();
|
||||
$query = "SELECT ";
|
||||
$query .= "
|
||||
ecmpricebooks.*";
|
||||
if($_REQUEST['pricebook_product_id'])$query.=" ,ecmpricebooks_ecmproducts.price as price";
|
||||
$query.=",users.user_name as assigned_user_name";
|
||||
if($custom_join){
|
||||
$query .= $custom_join['select'];
|
||||
}
|
||||
$query .= " FROM ecmpricebooks
|
||||
LEFT JOIN users
|
||||
ON ecmpricebooks.assigned_user_id=users.id";
|
||||
if($_REQUEST['pricebook_product_id'])$query.=" LEFT JOIN ecmpricebooks_ecmproducts
|
||||
ON ecmpricebooks_ecmproducts.ecmpricebook_id=ecmpricebooks.id";
|
||||
|
||||
|
||||
$query .= " ";
|
||||
if($custom_join){
|
||||
$query .= $custom_join['join'];
|
||||
}
|
||||
$where_auto = '1=1';
|
||||
if($show_deleted == 0){
|
||||
$where_auto = " $this->table_name.deleted=0 ";
|
||||
}else if($show_deleted == 1){
|
||||
$where_auto = " $this->table_name.deleted=1 ";
|
||||
}
|
||||
|
||||
|
||||
if($where != "")
|
||||
$query .= "where $where AND ".$where_auto;
|
||||
else
|
||||
$query .= "where ".$where_auto;
|
||||
if($_REQUEST['pricebook_product_id'])$query.=" AND ecmpricebooks_ecmproducts.ecmproduct_id='".$_REQUEST['pricebook_product_id']."'";
|
||||
//if($_REQUEST['exchange_rate_id'])$query.=" AND ecmpricebooks.exchange_rate_id='".$_REQUEST['exchange_rate_id']."'";
|
||||
if($_GET['pricebook_id'])$query.=" AND ecmpricebooks.id='".$_GET['pricebook_id']."'";
|
||||
if(substr_count($order_by, '.') > 0){
|
||||
$query .= " ORDER BY $order_by";
|
||||
}
|
||||
else if($order_by != "")
|
||||
$query .= " ORDER BY $order_by";
|
||||
else
|
||||
$query .= " ORDER BY ecmpricebooks.name";
|
||||
//echo $query;
|
||||
return $query;
|
||||
}
|
||||
/*
|
||||
function create_new_list_query($order_by, $where, $show_deleted = 0){
|
||||
// Fill in the assigned_user_name
|
||||
$custom_join = $this->custom_fields->getJOIN();
|
||||
|
||||
if($_REQUEST['pricebook_product_id']){
|
||||
$w=$GLOBALS['db']->query("select distinct ecmpricebook_id from ecmpricebooks_ecmproducts where deleted='0' and ecmproduct_id='".$_REQUEST['pricebook_product_id']."'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w))$arr[]="ecmpricebooks.id like '".$r['ecmpricebook_id']."'";
|
||||
$wpr="( ".implode(" or ",$arr)." )";
|
||||
}
|
||||
|
||||
$select = "SELECT ";
|
||||
$select .= "ecmpricebooks.*";
|
||||
$select.=",users.user_name as assigned_user_name";
|
||||
if($custom_join){
|
||||
$select .= $custom_join['select'];
|
||||
}
|
||||
|
||||
$from = " FROM ecmpricebooks LEFT JOIN users ON ecmpricebooks.assigned_user_id=users.id";
|
||||
|
||||
if($custom_join){
|
||||
$from .= $custom_join['join'];
|
||||
}
|
||||
|
||||
$where_auto = '1=1';
|
||||
if($show_deleted == 0){
|
||||
$where_auto = " $this->table_name.deleted=0 ";
|
||||
}
|
||||
else if($show_deleted == 1){
|
||||
$where_auto = " $this->table_name.deleted=1 ";
|
||||
}
|
||||
|
||||
|
||||
if($where != "")
|
||||
$wh= "where $where AND ".$where_auto;
|
||||
else
|
||||
$wh = "where ".$where_auto;
|
||||
|
||||
if($_REQUEST['pricebook_product_id']){
|
||||
$wh.=" and ".$wpr;
|
||||
}
|
||||
|
||||
if(substr_count($order_by, '.') > 0)$ob= " ORDER BY $order_by";
|
||||
else if($order_by != "")$ob = " ORDER BY $order_by";
|
||||
else $ob = " ORDER BY ecmpricebooks.name";
|
||||
|
||||
$query['select']=$select;
|
||||
$query['from']=$from;
|
||||
$query['where']=$wh;
|
||||
$query['order_by']=$ob;
|
||||
|
||||
$GLOBALS['db']->query($query['select']." ".$query['from']." ".$query['where']." ".$query['order_by']);
|
||||
print $query['select']." ".$query['from']." ".$query['where']." ".$query['order_by'];
|
||||
print mysql_error();
|
||||
return $query;
|
||||
}
|
||||
*/
|
||||
function create_export_query($order_by, $where){
|
||||
$custom_join = $this->custom_fields->getJOIN();
|
||||
$query = "SELECT
|
||||
ecmpricebooks.*,
|
||||
users.user_name assigned_user_name";
|
||||
if($custom_join){
|
||||
$query .= $custom_join['select'];
|
||||
}
|
||||
$query .= " FROM ecmpricebooks ";
|
||||
|
||||
$query .= " LEFT JOIN users
|
||||
ON ecmpricebooks.assigned_user_id=users.id";
|
||||
if($custom_join){
|
||||
$query .= $custom_join['join'];
|
||||
}
|
||||
$query .= "";
|
||||
$where_auto = " ecmpricebooks.deleted=0
|
||||
";
|
||||
|
||||
if($where != "")
|
||||
$query .= " where $where AND ".$where_auto;
|
||||
else
|
||||
$query .= " where ".$where_auto;
|
||||
|
||||
if($order_by != "")
|
||||
$query .= " ORDER BY $order_by";
|
||||
else
|
||||
$query .= " ORDER BY ecmpricebooks.name";
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
function fill_in_additional_list_fields(){
|
||||
if ($this->active==1)
|
||||
$this->active='yes';
|
||||
else
|
||||
$this->active='no';
|
||||
}
|
||||
|
||||
function fill_in_additional_detail_fields(){
|
||||
// FILL IN THE ASSIGNED_USER_NAME
|
||||
$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
|
||||
$this->created_by_name = get_assigned_user_name($this->created_by);
|
||||
$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
|
||||
}
|
||||
|
||||
function get_list_view_data(){
|
||||
global $current_language,$current_user;
|
||||
$the_array = parent::get_list_view_data();
|
||||
$app_list_strings = return_app_list_strings_language($current_language);
|
||||
$mod_strings = return_module_language($current_language, 'EcmPriceBooks');
|
||||
|
||||
// THE NEW LISTVIEW CODE ONLY FETCHES COLUMNS THAT WE'RE DISPLAYING AND NOT ALL
|
||||
// THE COLUMNS SO WE NEED THESE CHECKS.
|
||||
$the_array['NAME'] = (($this->name == "") ? "<em>blank</em>" : $this->name);
|
||||
$the_array['ENCODED_NAME'] = $this->name;
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select * from ecmpricebooks where id='".$this->id."'"));
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($r['exchange_rate_id']);
|
||||
|
||||
$the_array['EXCHANGE_RATE_NAME'] = $currency->iso4217;
|
||||
$w=$GLOBALS['db']->query("select price,recipient_code from ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['pricebook_product_id']."' and ecmpricebook_id='".$this->id."' and deleted='0'");
|
||||
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
//$the_array['LIST_PRICE']=number_format($r['price'],2,$GLOBALS['sugar_config']['default_decimal_seperator'],$GLOBALS['sugar_config']['default_number_grouping_seperator']);
|
||||
$the_array['PRICE']=number_format($r['price'],2,$GLOBALS['sugar_config']['default_decimal_seperator'],$GLOBALS['sugar_config']['default_number_grouping_seperator']);
|
||||
$the_array['RECIPIENT_CODE']=$r['recipient_code'];
|
||||
|
||||
if(mysql_num_rows($w)==0)$the_array['LIST_PRICE']=$mod_strings['LBL_NO_ON_THIS_PRICEBOOK'];
|
||||
require_once("modules/EcmProducts/EcmProduct.php");
|
||||
$prod=new EcmProduct();
|
||||
$prod->retrieve($_REQUEST['pricebook_product_id']);
|
||||
$prod->format_all_fields();
|
||||
$the_array['INDEX']=$prod->product_index;
|
||||
return $the_array;
|
||||
}
|
||||
|
||||
/**
|
||||
BUILDS A GENERIC SEARCH BASED ON THE QUERY STRING USING OR.
|
||||
DO NOT INCLUDE ANY $THIS-> BECAUSE THIS IS CALLED ON WITHOUT HAVING THE CLASS INSTANTIATED.
|
||||
*/
|
||||
function build_generic_where_clause ($the_query_string) {
|
||||
$where_clauses = Array();
|
||||
$the_query_string = PearDatabase::quote(from_html($the_query_string));
|
||||
array_push($where_clauses, "ecmpricebooks.name like '$the_query_string%'");
|
||||
|
||||
$the_where = "";
|
||||
foreach($where_clauses as $clause){
|
||||
if($the_where != "") $the_where .= " or ";
|
||||
$the_where .= $clause;
|
||||
}
|
||||
return $the_where;
|
||||
}
|
||||
|
||||
function set_notification_body($xtpl, $simplemodule){
|
||||
global $mod_strings, $app_list_strings;
|
||||
|
||||
$xtpl->assign("NAME", $simplemodule->name);
|
||||
$xtpl->assign("ECMPRICEBOOKS_DESCRIPTION", $ecmpricebooks->description);
|
||||
return $xtpl;
|
||||
}
|
||||
|
||||
function bean_implements($interface){
|
||||
switch($interface){
|
||||
case 'ACL':return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save($check_notify = FALSE){
|
||||
return parent::save($check_notify);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
99
import/EcmPriceBooks/EcmPriceBooksQuickCreate.php
Normal file
99
import/EcmPriceBooks/EcmPriceBooksQuickCreate.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/EditView/QuickCreate.php');
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('include/javascript/javascript.php');
|
||||
|
||||
class EcmPriceBooksQuickCreate extends QuickCreate {
|
||||
|
||||
var $javascript;
|
||||
|
||||
function process() {
|
||||
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
|
||||
$mod_strings = return_module_language($current_language, 'EcmPriceBooks');
|
||||
|
||||
parent::process();
|
||||
|
||||
//BUILDER:START dropdowns setup
|
||||
//BUILDER:END dropdowns setup
|
||||
|
||||
if($this->viaAJAX) { // OVERRIDE FOR AJAX CALL
|
||||
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"ecmpricebooksQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"ecmpricebooks\"); else return false;'");
|
||||
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_ecmpricebooks\")';");
|
||||
}
|
||||
|
||||
$this->ss->assign('viaAJAX', $this->viaAJAX);
|
||||
|
||||
$this->javascript = new javascript();
|
||||
$this->javascript->setFormName('ecmpricebooksQuickCreate');
|
||||
|
||||
$focus = new EcmPriceBook();
|
||||
$this->javascript->setSugarBean($focus);
|
||||
$this->javascript->addAllFields('');
|
||||
|
||||
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
|
||||
|
||||
$json = getJSONobj();
|
||||
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'ecmpricebooksQuickCreate',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'account_id',
|
||||
'name' => 'account_name',
|
||||
),
|
||||
);
|
||||
|
||||
$encoded_popup_request_data = $json->encode($popup_request_data);
|
||||
$this->ss->assign('encoded_popup_request_data', $encoded_popup_request_data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
229
import/EcmPriceBooks/EditCustomView.php
Normal file
229
import/EcmPriceBooks/EditCustomView.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?
|
||||
global $db;
|
||||
|
||||
$result = $db->query("select * from ecmpricebooks_customview where id='".$_REQUEST['record']."'");
|
||||
$row=$db->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
$o=explode("||",$row['orders']);
|
||||
|
||||
$name=$row['name'];
|
||||
|
||||
for($i=0;$i<count($o);$i++){
|
||||
$exp=explode(" ",$o[$i]);
|
||||
$sorder[$i+1]=$exp[1];
|
||||
$oi[$i+1]=$exp[0];
|
||||
}
|
||||
|
||||
|
||||
require("modules/EcmProducts/vardefs.php");
|
||||
require("modules/EcmProducts/language/en_us.lang.php");
|
||||
|
||||
function showSorder($i,$value){
|
||||
require("modules/EcmPriceBooks/language/en_us.lang.php");
|
||||
$html='<select name="sorder'.$i.'">';
|
||||
$html.='<option value="asc"';
|
||||
if($value=="asc")$html.=' selected';
|
||||
$html.='>'.$mod_strings['LBL_ASCENDING'].'</option>';
|
||||
$html.='<option value="desc"';
|
||||
if($value=="desc")$html.=' selected';
|
||||
$html.='>'.$mod_strings['LBL_DESCENDING'].'</option>';
|
||||
$html.='</select>';
|
||||
return $html;
|
||||
}
|
||||
function selectColumn($fields,$i,$value)
|
||||
{
|
||||
for($j=1;$j<=9;$j++)$sos.='showOrderSelect('.$j.',document.getElementById(\'order'.$j.'\').value);';
|
||||
$html='<select onchange="'.$sos.'" name="column'.$i.'" id="column'.$i.'"><option value="">Select</option>';
|
||||
foreach($fields as $field)
|
||||
{
|
||||
if($field['name'] && $field['vname'])
|
||||
{
|
||||
$html.='<option value="'.$field['name'].'"';
|
||||
if($value==$field['name'])$html.=' selected';
|
||||
$html.='>'.$field['vname'].'</option>';
|
||||
}
|
||||
}
|
||||
$html.='</select>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
$fields=$dictionary['EcmProduct']['fields'];
|
||||
$js="";
|
||||
foreach($fields as $field)$f[]=array("vname"=>$mod_strings[$field['vname']],"name"=>$field['name']);
|
||||
$f[]=array("vname"=>$mod_strings['LBL_LIST_PRICE'],"name"=>"list_price");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_MARGIN'],"name"=>"margin_rate");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_RECIPIENT_CODE'],"name"=>"recipient_code");
|
||||
|
||||
$f[]=array("vname"=>$mod_strings['LBL_EAN_PL'],"name"=>"ean_pl");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_SHORT_DESCRIPTION_PL'],"name"=>"short_description_pl");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_LONG_DESCRIPTION_PL'],"name"=>"long_description_pl");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_REMARKS_PL'],"name"=>"remarks_pl");
|
||||
|
||||
$f[]=array("vname"=>$mod_strings['LBL_EAN_EN'],"name"=>"ean_en");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_SHORT_DESCRIPTION_EN'],"name"=>"short_description_en");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_LONG_DESCRIPTION_EN'],"name"=>"long_description_en");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_REMARKS_EN'],"name"=>"remarks_en");
|
||||
|
||||
$f[]=array("vname"=>$mod_strings['LBL_EAN_DE'],"name"=>"ean_de");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_SHORT_DESCRIPTION_DE'],"name"=>"short_description_de");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_LONG_DESCRIPTION_DE'],"name"=>"long_description_de");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_REMARKS_DE'],"name"=>"remarks_de");
|
||||
|
||||
$f[]=array("vname"=>$mod_strings['LBL_DEFAULT_REMARKS_PL'],"name"=>"default_remarks_pl");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_DEFAULT_REMARKS_EN'],"name"=>"default_remarks_en");
|
||||
$f[]=array("vname"=>$mod_strings['LBL_DEFAULT_REMARKS_DE'],"name"=>"default_remarks_de");
|
||||
|
||||
$f[]=array("vname"=>"Qty in last 1 m","name"=>"sale_qty30");
|
||||
$f[]=array("vname"=>"Qty in last 3 m","name"=>"sale_qty90");
|
||||
$f[]=array("vname"=>"Qty in last 6 m","name"=>"sale_qty180");
|
||||
|
||||
$f[]=array("vname"=>"Avg price in last 1 m","name"=>"sale_avg_price30");
|
||||
$f[]=array("vname"=>"Avg price in last 3 m","name"=>"sale_avg_price90");
|
||||
$f[]=array("vname"=>"Avg price in last 6 m","name"=>"sale_avg_price180");
|
||||
|
||||
$f[]=array("vname"=>"Ordered","name"=>"ordered");
|
||||
sort($f);
|
||||
foreach($f as $ff)$js.='names["'.$ff['name'].'"]="'.$ff['vname'].'"
|
||||
';
|
||||
?>
|
||||
<script>
|
||||
function showOrderSelect(no,v)
|
||||
{
|
||||
var names=new Array();
|
||||
<?print $js;?>
|
||||
var html='<select name="order'+no+'" id="order'+no+'"><option value="">select</option>';
|
||||
html=html+'<option value="name"';
|
||||
if("name"==v)
|
||||
{
|
||||
html=html+' selected';
|
||||
}
|
||||
for(var i=1;i<=9;i++)
|
||||
{
|
||||
if(document.getElementById('column'+i).value)
|
||||
{
|
||||
html=html+'<option value="'+document.getElementById('column'+i).value+'"';
|
||||
if(v==document.getElementById('column'+i).value)
|
||||
{
|
||||
html=html+' selected';
|
||||
}
|
||||
html=html+'>'+names[document.getElementById('column'+i).value]+'</option>';
|
||||
}
|
||||
}
|
||||
html=html+'</select>';
|
||||
document.getElementById('dorder'+no).innerHTML=html;
|
||||
return html;
|
||||
}
|
||||
</script>
|
||||
<form name="EditView" method="POST" action="index.php?module=EcmPriceBooks&action=SaveCustomView&record=<?print $_REQUEST['record'];?>">
|
||||
<div style="padding-top: 2px">
|
||||
<input title="Save" class="button" type="submit" name="button" value="Save" >
|
||||
<input title="Cancel" class="button" type="submit" name="button" value="Cancel">
|
||||
</div><br />
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="15%" class="dataLabel"><span sugar='slot1'>View name <span class="required">*</span></span sugar='slot'></td>
|
||||
<td width="35%" class="dataField"><span sugar='slot1b'><input name='name' type="text" tabindex='1' size='35' maxlength='50' value="<? print $name; ?>"></span sugar='slot'></td>
|
||||
<td width="15%" class="dataLabel" > </td>
|
||||
<td width="35%" class="dataField"> </td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="dataLabel"><span sugar='slot3'>Choose columns </span sugar='slot'></td>
|
||||
<td class="dataField"> </td>
|
||||
<td valign="top" class="dataLabel"> </td>
|
||||
<td valign="top" class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" valign="top" class="dataLabel"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><?print selectColumn($f,1,$c[0]);?></td>
|
||||
<td><?print selectColumn($f,2,$c[1]);?></td>
|
||||
<td><?print selectColumn($f,3,$c[2]);?>;</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?print selectColumn($f,4,$c[3]);?></td>
|
||||
<td><?print selectColumn($f,5,$c[4]);?></td>
|
||||
<td><?print selectColumn($f,6,$c[5]);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?print selectColumn($f,7,$c[6]);?></td>
|
||||
<td><?print selectColumn($f,8,$c[7]);?></td>
|
||||
<td><?print selectColumn($f,9,$c[8]);?></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="dataLabel">Columns titles </td>
|
||||
<td class="dataField"> </td>
|
||||
<td class="dataLabel" valign="top"> </td>
|
||||
<td class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" valign="top" class="dataLabel"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><input name="title1" type="text" id="title1" value="<?print $t[0];?>" size="30" /></td>
|
||||
<td><input name="title2" type="text" id="title2" value="<?print $t[1];?>" size="30" /></td>
|
||||
<td><input name="title3" type="text" id="title3" value="<?print $t[2];?>" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="title4" type="text" id="title4" value="<?print $t[3];?>" size="30" /></td>
|
||||
<td><input name="title5" type="text" id="title5" value="<?print $t[4];?>" size="30" /></td>
|
||||
<td><input name="title6" type="text" id="title6" value="<?print $t[5];?>" size="30" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="title7" type="text" id="title7" value="<?print $t[6];?>" size="30" /></td>
|
||||
<td><input name="title8" type="text" id="title8" value="<?print $t[7];?>" size="30" /></td>
|
||||
<td><input name="title9" type="text" id="title9" value="<?print $t[8];?>" size="30" /></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="dataLabel">Sort order </td>
|
||||
<td class="dataField"> </td>
|
||||
<td class="dataLabel" valign="top"> </td>
|
||||
<td class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" valign="top" class="dataLabel"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><div style="display:inline;" id="dorder1"></div><? print showSorder(1,$sorder[1]);?></td>
|
||||
<td><div style="display:inline;" id="dorder2"></div><? print showSorder(2,$sorder[2]);?></td>
|
||||
<td><div style="display:inline;" id="dorder3"></div><? print showSorder(3,$sorder[3]);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div style="display:inline;" id="dorder4"></div><? print showSorder(4,$sorder[4]);?></td>
|
||||
<td><div style="display:inline;" id="dorder5"></div><? print showSorder(5,$sorder[5]);?></td>
|
||||
<td><div style="display:inline;" id="dorder6"></div><? print showSorder(6,$sorder[6]);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div style="display:inline;" id="dorder7"></div><? print showSorder(7,$sorder[7]);?></td>
|
||||
<td><div style="display:inline;" id="dorder8"></div><? print showSorder(8,$sorder[8]);?></td>
|
||||
<td><div style="display:inline;" id="dorder9"></div><? print showSorder(9,$sorder[9]);?></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="padding-top: 2px">
|
||||
<input title="Save" class="button" type="submit" name="button" value="Save" >
|
||||
<input title="Cancel" class="button" type="submit" name="button" value="Cancel">
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
showOrderSelect(1,'<?print $oi[1];?>');
|
||||
showOrderSelect(2,'<?print $oi[2];?>');
|
||||
showOrderSelect(3,'<?print $oi[3];?>');
|
||||
showOrderSelect(4,'<?print $oi[4];?>');
|
||||
showOrderSelect(5,'<?print $oi[5];?>');
|
||||
showOrderSelect(6,'<?print $oi[6];?>');
|
||||
showOrderSelect(7,'<?print $oi[7];?>');
|
||||
showOrderSelect(8,'<?print $oi[8];?>');
|
||||
showOrderSelect(9,'<?print $oi[9];?>');
|
||||
</script>
|
||||
368
import/EcmPriceBooks/EditView1.php
Normal file
368
import/EcmPriceBooks/EditView1.php
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
include("modules/EcmProducts/moduleMenu.php");
|
||||
|
||||
// INCLUDE SUPPPORT MODULES
|
||||
require_once('XTemplate/xtpl.php');
|
||||
require_once('data/Tracker.php');
|
||||
|
||||
// INCLUDE MODULE OBJECT AND FORMS
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('modules/EcmPriceBooks/Forms.php');
|
||||
|
||||
global $app_strings;
|
||||
global $mod_strings;
|
||||
global $mod_strings;
|
||||
global $current_user;
|
||||
global $sugar_version, $sugar_config;
|
||||
global $db;
|
||||
|
||||
echo 'test';
|
||||
// INSTANTIATES THE MODULE CLASSES
|
||||
$focus = new EcmPriceBook();
|
||||
|
||||
// IF PROCESSING AN EXISTING RECORD, RETRIEVE IT
|
||||
if(isset($_REQUEST['record'])) {
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
$focus->unformat_all_fields();
|
||||
}
|
||||
if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
|
||||
$_SESSION['pricebook_duplicate_id']=$_REQUEST['record'];
|
||||
$focus->id = "";
|
||||
$focus->simplemodule_number = "";
|
||||
echo 't'.$_SESSION['pricebook_duplicate_id'];
|
||||
}
|
||||
|
||||
$prefillArray = array(
|
||||
'priority' => 'priority',
|
||||
'name' => 'name',
|
||||
'description' => 'description',
|
||||
'status' => 'status',
|
||||
'type' => 'type',
|
||||
);
|
||||
|
||||
foreach($prefillArray as $requestKey => $focusVar) {
|
||||
if (isset($_REQUEST[$requestKey]) && is_null($focus->$focusVar)) {
|
||||
$focus->$focusVar = urldecode($_REQUEST[$requestKey]);
|
||||
}
|
||||
}
|
||||
|
||||
// BUILD MODULE TITLE LINE
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($mod_strings['LBL_MODULE_ID'], $mod_strings['LBL_MODULE_NAME'].": ".$focus->name, true);
|
||||
echo "\n</p>\n";
|
||||
|
||||
global $theme;
|
||||
$theme_path = "themes/".$theme."/";
|
||||
$image_path = $theme_path."images/";
|
||||
require_once ($theme_path.'layout_utils.php');
|
||||
|
||||
$GLOBALS['log']->info("EcmPriceBooks detail view");
|
||||
|
||||
// ASSIGN XTEMPLATE
|
||||
$xtpl = new XTemplate ('modules/EcmPriceBooks/EditView.html');
|
||||
|
||||
// FILL XTEMPLATE MODULE & APPLICATION LANGUAGE STRINGS
|
||||
$xtpl->assign("MOD", $mod_strings);
|
||||
$xtpl->assign("APP", $app_strings);
|
||||
$xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
|
||||
|
||||
if (isset($_REQUEST['return_module'])) $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
|
||||
if (isset($_REQUEST['return_action'])) $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
|
||||
if (isset($_REQUEST['return_id'])) $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
|
||||
|
||||
if (empty($_REQUEST['return_id'])) {
|
||||
$xtpl->assign("RETURN_ACTION", 'index');
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
// SETUP POPUPS START
|
||||
// Users Popup
|
||||
$json = getJSONobj();
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'assigned_user_id',
|
||||
'user_name' => 'assigned_user_name',
|
||||
),
|
||||
);
|
||||
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'account_id',
|
||||
'name' => 'account_name',
|
||||
),
|
||||
);
|
||||
$xtpl->assign('encoded_accounts_popup_request_data', $json->encode($popup_request_data));
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'lead_id',
|
||||
'name' => 'lead_name',
|
||||
),
|
||||
);
|
||||
$xtpl->assign('encoded_leads_popup_request_data', $json->encode($popup_request_data));
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// ACCOUNT_ID WILL BE SET WHEN USER CHOOSES TO CREATE A NEW SIMPLEMODULE FROM ACCOUNT DETAIL VIEW.
|
||||
if (isset($_REQUEST['account_id'])) $xtpl->assign("ACCOUNT_ID", $_REQUEST['account_id']);
|
||||
if (isset($_REQUEST['contact_id'])) $xtpl->assign("CONTACT_ID", $_REQUEST['contact_id']);
|
||||
|
||||
// SET THE CASE_ID, IF SET.
|
||||
// WITH NEW CONCEPT OF SUBPANELS IT,
|
||||
// WHEN THE SUBPANEL IS DISPLAYED IT PULLS FROM THE CLASS NAME WHICH IN THE SITUATION OF CASES IS ACASE SO THE FORM IS GENERATED
|
||||
// WITH ACASE_ID INSTEAD OF CASE_ID, SO I HAVE DONE THE MAPPING HERE
|
||||
if (isset($_REQUEST['acase_id'])) $xtpl->assign("CASE_ID",$_REQUEST['acase_id']);
|
||||
else if(isset($_REQUEST['case_id'])) $xtpl->assign("CASE_ID",$_REQUEST['case_id']);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// QUICK SEARCH SETUP
|
||||
require_once('include/QuickSearchDefaults.php');
|
||||
$qsd = new QuickSearchDefaults();
|
||||
$sqs_objects = array(
|
||||
'assigned_user_name' => $qsd->getQSUser(),
|
||||
|
||||
'account_name' => array(
|
||||
'method' => 'query',
|
||||
'modules' => array('Accounts'),
|
||||
'group' => 'or',
|
||||
'field_list' => array('name', 'id'),
|
||||
'populate_list' => array('account_name', 'account_id'),
|
||||
'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
|
||||
'order' => 'name',
|
||||
'limit' => '30',
|
||||
'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
|
||||
),
|
||||
'lead_name' => array(
|
||||
'method' => 'query',
|
||||
'modules' => array('Leads'),
|
||||
'group' => 'or',
|
||||
'field_list' => array('last_name', 'id'),
|
||||
'populate_list' => array('lead_name', 'lead_id'),
|
||||
'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
|
||||
'order' => 'last_name',
|
||||
'limit' => '30',
|
||||
'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
|
||||
),
|
||||
/*
|
||||
//BUILDER:START Pro only
|
||||
'team_name' => $qsd->getQSTeam()
|
||||
//BUILDER:END Pro only
|
||||
*/
|
||||
);
|
||||
$quicksearch_js = $qsd->getQSScripts();
|
||||
$quicksearch_js .= '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
|
||||
// QUICK SEARCH SETUP
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ASSIGN GLOBAL VARIABLES
|
||||
$xtpl->assign("THEME", $theme);
|
||||
$xtpl->assign("IMAGE_PATH", $image_path);$xtpl->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
|
||||
$xtpl->assign("JAVASCRIPT", get_set_focus_js().get_validate_record_js(). $quicksearch_js);
|
||||
$xtpl->assign("USER_DATEFORMAT", '('. $timedate->get_user_date_format().')');
|
||||
$xtpl->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
|
||||
// ASSIGN GLOBAL VARIABLES
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ASSIGN MODULE DEFAULT VARIABLES
|
||||
|
||||
|
||||
$xtpl->assign("ID", $focus->id);
|
||||
if (!empty($focus->name))
|
||||
$xtpl->assign("NAME", $focus->name);
|
||||
else $xtpl->assign("NAME", "");
|
||||
$xtpl->assign("DATE_ENTERED", $focus->date_entered);
|
||||
$xtpl->assign("DATE_MODIFIED", $focus->date_modified);
|
||||
$xtpl->assign("CREATED_BY", $focus->created_by_name);
|
||||
$xtpl->assign("MODIFIED_BY", $focus->modified_by_name);
|
||||
|
||||
if (empty($focus->assigned_user_id) && empty($focus->id)) $focus->assigned_user_id = $current_user->id;
|
||||
if (empty($focus->assigned_name) && empty($focus->id)) $focus->assigned_user_name = $current_user->user_name;
|
||||
$xtpl->assign("ASSIGNED_USER_OPTIONS", get_select_options_with_id(get_user_array(TRUE, "Active", $focus->assigned_user_id), $focus->assigned_user_id));
|
||||
$xtpl->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
|
||||
$xtpl->assign("ASSIGNED_USER_ID", $focus->assigned_user_id );
|
||||
|
||||
// ASSIGN MODULE SPECIFIC VARIABLES
|
||||
|
||||
if (!empty($_REQUEST['active'])) {
|
||||
$xtpl->assign("ACTIVE", "checked");
|
||||
}
|
||||
|
||||
|
||||
if ($focus->active == '1') $xtpl->assign("ACTIVE", "checked");
|
||||
|
||||
|
||||
$xtpl->assign("DESCRIPTION", $focus->description);
|
||||
|
||||
|
||||
$xtpl->assign("EXCHANGE_RATE_NAME", $focus->exchange_rate_name);
|
||||
|
||||
|
||||
$xtpl->assign("EXCHANGE_RATE_ID", $focus->exchange_rate_id);
|
||||
|
||||
|
||||
$xtpl->assign("ACCOUNT_NAME", $focus->account_name);
|
||||
|
||||
|
||||
$xtpl->assign("ACCOUNT_ID", $focus->account_id);
|
||||
|
||||
|
||||
$xtpl->assign("LEAD_NAME", $focus->lead_name);
|
||||
|
||||
|
||||
$xtpl->assign("LEAD_ID", $focus->lead_id);
|
||||
|
||||
//load currencies
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency_list = $currency->get_full_list('name');
|
||||
$currency->retrieve('-99');
|
||||
if(is_array($currency_list))
|
||||
{
|
||||
$currency_list = array_merge(Array($currency), $currency_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
$currency_list = Array($currency);
|
||||
}
|
||||
$arr = array();
|
||||
foreach($currency_list as $key=>$value)
|
||||
{
|
||||
$arr[$value->id] = $value->name;
|
||||
}
|
||||
$xtpl->assign("EXCHANGE_RATE_ID", get_select_options_with_id($arr, $focus->exchange_rate_id));
|
||||
|
||||
// ASSIGN MODULE DROPDOWNS WITH DEFAULT KEY
|
||||
|
||||
// ASSIGN MODULE VARIABLES AFFECTED BY DUPLICATE ACTION
|
||||
if(!isset($_REQUEST['isDuplicate'])) {
|
||||
$focus->id = "";
|
||||
}
|
||||
|
||||
|
||||
// ASSIGN MODULE DROPDOWNS WITHOUT DEFAULT KEY
|
||||
|
||||
//BUILDER:END of xtpl
|
||||
|
||||
// ADD CUSTOM FIELDS
|
||||
require_once('modules/DynamicFields/templates/Files/EditView.php');
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// USER ASSIGNMENT
|
||||
global $current_user;
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
|
||||
$record = '';
|
||||
// USER ASSIGNMENT
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if(!empty($_REQUEST['record'])){
|
||||
$record = $_REQUEST['record'];
|
||||
}
|
||||
$xtpl->assign("ADMIN_EDIT","<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$xtpl->parse("main");
|
||||
$xtpl->out("main");
|
||||
require_once('include/javascript/javascript.php');
|
||||
$javascript = new javascript();
|
||||
$javascript->setFormName('EditView');
|
||||
$javascript->setSugarBean($focus);
|
||||
$javascript->addAllFields('');
|
||||
|
||||
//BUILDER:START Pro only
|
||||
// $javascript->addFieldGeneric( 'team_name', 'varchar', $app_strings['LBL_TEAM'] ,'true');
|
||||
// $javascript->addToValidateBinaryDependency('team_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_TEAM'], 'false', '', 'team_id');
|
||||
//BUILDER:END Pro only
|
||||
|
||||
$javascript->addToValidateBinaryDependency('assigned_user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id');
|
||||
|
||||
echo $javascript->getScript();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// SELECT CHANGES TEXT INPUT FIELD
|
||||
/*
|
||||
$prob_array = $json->encode($app_list_strings['sales_probability_dom']);
|
||||
$prePopProb = '';
|
||||
if(empty($focus->id)) $prePopProb = 'document.getElementsByName(\'sales_stage\')[0].onchange();';
|
||||
echo <<<EOQ
|
||||
<script>
|
||||
prob_array = $prob_array;
|
||||
document.getElementsByName('sales_stage')[0].onchange = function() {
|
||||
if(typeof(document.getElementsByName('sales_stage')[0].value) != "undefined" && prob_array[document.getElementsByName('sales_stage')[0].value]) {
|
||||
document.getElementsByName('probability')[0].value = prob_array[document.getElementsByName('sales_stage')[0].value];
|
||||
}
|
||||
};
|
||||
$prePopProb
|
||||
</script>
|
||||
EOQ;
|
||||
*/
|
||||
//
|
||||
/// SELECT CHANGES TEXT INPUT FIELD
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
require_once('modules/SavedSearch/SavedSearch.php');
|
||||
$savedSearch = new SavedSearch();
|
||||
$json = getJSONobj();
|
||||
$savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . $savedSearch->getSelect('EcmPriceBooks')));
|
||||
$str = "<script>
|
||||
YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, $savedSearchSelects);
|
||||
</script>";
|
||||
echo $str;
|
||||
|
||||
?>
|
||||
354
import/EcmPriceBooks/EmailSave.php
Normal file
354
import/EcmPriceBooks/EmailSave.php
Normal file
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
* *******************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description:
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
|
||||
* Reserved. Contributor(s): ______________________________________..
|
||||
*********************************************************************************/
|
||||
|
||||
require_once('modules/Emails/Email.php');
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// EMAIL SEND/SAVE SETUP
|
||||
$focus = new Email();
|
||||
|
||||
if(!isset($prefix)) {
|
||||
$prefix = '';
|
||||
}
|
||||
if(isset($_POST[$prefix.'meridiem']) && !empty($_POST[$prefix.'meridiem'])) {
|
||||
$_POST[$prefix.'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix.'time_start'], $timedate->get_time_format(true), $_POST[$prefix.'meridiem']);
|
||||
}
|
||||
//retrieve the record
|
||||
if(isset($_POST['record']) && !empty($_POST['record'])) {
|
||||
$focus->retrieve($_POST['record']);
|
||||
|
||||
}
|
||||
if(isset($_REQUEST['user_id'])) {
|
||||
$focus->assigned_user_id = $_REQUEST['user_id'];
|
||||
}
|
||||
if(!$focus->ACLAccess('Save')){
|
||||
ACLController::displayNoAccess(true);
|
||||
sugar_cleanup(true);
|
||||
}
|
||||
if(!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
|
||||
$check_notify = TRUE;
|
||||
}
|
||||
//populate the fields of this Email
|
||||
$allfields = array_merge($focus->column_fields, $focus->additional_column_fields);
|
||||
foreach($allfields as $field) {
|
||||
if(isset($_POST[$field])) {
|
||||
$value = $_POST[$field];
|
||||
$focus->$field = $value;
|
||||
}
|
||||
}
|
||||
if (!isset($_REQUEST['to_addrs'])) {
|
||||
$_REQUEST['to_addrs'] = "";
|
||||
}
|
||||
if (!isset($_REQUEST['to_addrs_ids'])) {
|
||||
$_REQUEST['to_addrs_ids'] = "";
|
||||
}
|
||||
if (!isset($_REQUEST['to_addrs_names'])) {
|
||||
$_REQUEST['to_addrs_names'] = "";
|
||||
}
|
||||
if (!isset($_REQUEST['to_addrs_emails'])) {
|
||||
$_REQUEST['to_addrs_emails'] = "";
|
||||
}
|
||||
|
||||
//compare the 3 fields and return list of contact_ids to link:
|
||||
$focus->to_addrs_arr = $focus->parse_addrs($_REQUEST['to_addrs'], $_REQUEST['to_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['to_addrs_emails']);
|
||||
|
||||
// make sure the cc_* and bcc_* fields are at least empty if not set
|
||||
$fields_to_check = array(
|
||||
'cc_addrs',
|
||||
'cc_addrs_ids',
|
||||
'bcc_addrs',
|
||||
'bcc_addrs_ids',
|
||||
'cc_addrs_names',
|
||||
'cc_addrs_emails',
|
||||
'bcc_addrs_emails',
|
||||
);
|
||||
foreach ($fields_to_check as $field_to_check) {
|
||||
if (!isset($_REQUEST[$field_to_check])) {
|
||||
$_REQUEST[$field_to_check] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$focus->cc_addrs_arr = $focus->parse_addrs($_REQUEST['cc_addrs'], $_REQUEST['cc_addrs_ids'], $_REQUEST['cc_addrs_names'], $_REQUEST['cc_addrs_emails']);
|
||||
$focus->bcc_addrs_arr = $focus->parse_addrs($_REQUEST['bcc_addrs'], $_REQUEST['bcc_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['bcc_addrs_emails']);
|
||||
|
||||
|
||||
if(!empty($_REQUEST['type'])) {
|
||||
$focus->type = $_REQUEST['type'];
|
||||
} elseif(empty($focus->type)) { // cn: from drafts/quotes
|
||||
$focus->type = 'archived';
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// TEMPLATE PARSING
|
||||
// cn: bug 7244 - need to pass an empty bean to parse email templates
|
||||
$object_arr = array();
|
||||
if(!empty($focus->parent_id)) {
|
||||
$object_arr[$focus->parent_type] = $focus->parent_id;
|
||||
}
|
||||
if(isset($focus->to_addrs_arr[0]['contact_id'])) {
|
||||
$object_arr['Contacts'] = $focus->to_addrs_arr[0]['contact_id'];
|
||||
}
|
||||
if(empty($object_arr)) {
|
||||
$object_arr = array('Contacts' => '123');
|
||||
}
|
||||
|
||||
// do not parse email templates if the email is being saved as draft....
|
||||
if($focus->type != 'draft' && count($object_arr) > 0) {
|
||||
require_once($beanFiles['EmailTemplate']);
|
||||
$focus->name = EmailTemplate::parse_template($focus->name, $object_arr);
|
||||
$focus->description = EmailTemplate::parse_template($focus->description, $object_arr);
|
||||
$focus->description_html = EmailTemplate::parse_template($focus->description_html, $object_arr);
|
||||
}
|
||||
//// END TEMPLATE PARSING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// PREP FOR ATTACHMENTS
|
||||
if(empty($focus->id)){
|
||||
$focus->id = create_guid();
|
||||
$focus->new_with_id = true;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// ATTACHMENT HANDLING
|
||||
$focus->handleAttachments();
|
||||
|
||||
if($_SESSION['pricebook_id'])
|
||||
{
|
||||
$cn=explode(";",$_REQUEST['to_addrs_ids']);
|
||||
if($_REQUEST['attach_pdf'])
|
||||
{
|
||||
$_REQUEST['images']=$_REQUEST['email_images'];
|
||||
include('modules/EcmPriceBooks/CreatePDF.php');
|
||||
if($microtime != '')
|
||||
{
|
||||
require_once('modules/Notes/Note.php');
|
||||
$n = new Note();
|
||||
$n->name = 'Products.pdf';
|
||||
$n->filename = 'Products.pdf';
|
||||
$n->file_mime_type = 'application/pdf';
|
||||
$n->parent_id = $focus->id;
|
||||
$n->parent_type = $focus->module_dir;
|
||||
$n->parent_name = $focus->name;
|
||||
$n->contact_id=trim($cn[0]);
|
||||
$nid=$n->save();
|
||||
|
||||
rename('cache/upload/Products'.$microtime.'.pdf', 'cache/upload/'.$nid);
|
||||
$focus->saved_attachments[] = $n;
|
||||
}
|
||||
}
|
||||
if($_REQUEST['attach_xls'])
|
||||
{
|
||||
include('modules/EcmPriceBooks/CreateXLS.php');
|
||||
if($microtime != '')
|
||||
{
|
||||
require_once('modules/Notes/Note.php');
|
||||
$n = new Note();
|
||||
$n->name = 'Products.xls';
|
||||
$n->filename = 'Products.xls';
|
||||
$n->file_mime_type = 'application/ms-excel';
|
||||
$n->parent_id = $focus->id;
|
||||
$n->parent_type = $focus->module_dir;
|
||||
$n->parent_name = $focus->name;
|
||||
$n->contact_id=trim($cn[0]);
|
||||
$nid=$n->save();
|
||||
|
||||
rename('cache/upload/Products'.$microtime.'.xls', 'cache/upload/'.$nid);
|
||||
$focus->saved_attachments[] = $n;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
}
|
||||
if($_REQUEST['attach_pdf'])
|
||||
{
|
||||
include('modules/EcmPriceBooks/CreateXLS.php');
|
||||
if($microtime != '')
|
||||
{
|
||||
require_once('modules/Notes/Note.php');
|
||||
$n = new Note();
|
||||
$n->name = 'Products.xls';
|
||||
$n->filename = 'Products.xls';
|
||||
$n->file_mime_type = 'application/x-msexcel';
|
||||
$n->parent_id = $focus->id;
|
||||
$n->parent_type = $focus->module_dir;
|
||||
$n->parent_name = $focus->name;
|
||||
$nid=$n->save();
|
||||
|
||||
$focus->saved_attachments[] = $n;
|
||||
rename('cache/upload/Products'.$microtime.'.xls', 'cache/upload/'.$nid);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//// END ATTACHMENT HANDLING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
$focus->status = 'draft';
|
||||
if($focus->type == 'archived' ) {
|
||||
$focus->status= 'archived';
|
||||
} elseif(($focus->type == 'out' || $focus->type == 'forward')) {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//// REPLY PROCESSING
|
||||
$old = array('<','>');
|
||||
$new = array('<','>');
|
||||
|
||||
if($_REQUEST['from_addr'] != $_REQUEST['from_addr_name'].' <'.$_REQUEST['from_addr_email'].'>') {
|
||||
if(false === strpos($_REQUEST['from_addr'], '<')) { // we have an email only?
|
||||
$focus->from_addr = $_REQUEST['from_addr'];
|
||||
$focus->from_name = '';
|
||||
} else { // we have a compound string
|
||||
$newFromAddr = str_replace($old, $new, $_REQUEST['from_addr']);
|
||||
$focus->from_addr = substr($newFromAddr, (1 + strpos($newFromAddr, '<')), (strpos($newFromAddr, '>') - strpos($newFromAddr, '<')) -1 );
|
||||
$focus->from_name = substr($newFromAddr, 0, (strpos($newFromAddr, '<') -1));
|
||||
}
|
||||
} elseif(!empty($_REQUEST['from_addr_email']) && isset($_REQUEST['from_addr_email'])) {
|
||||
$focus->from_addr = $_REQUEST['from_addr_email'];
|
||||
$focus->from_name = $_REQUEST['from_addr_name'];
|
||||
} else {
|
||||
$focus->from_addr = $focus->getSystemDefaultEmail();
|
||||
}
|
||||
//// REPLY PROCESSING
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
if($focus->send()) {
|
||||
$focus->status = 'sent';
|
||||
} else {
|
||||
$focus->status = 'send_error';
|
||||
}
|
||||
}
|
||||
$focus->to_addrs = $_REQUEST['to_addrs'];
|
||||
|
||||
// delete the existing relationship of all the email addresses with this email
|
||||
$query = "update emails_email_addr_rel set deleted = 1 WHERE email_id = '{$focus->id}'";
|
||||
$focus->db->query($query);
|
||||
|
||||
// delete al the relationship of this email with all the beans
|
||||
$query = "update emails_beans set deleted = 1, bean_id = '', bean_module = '' WHERE email_id = '{$focus->id}'";
|
||||
$focus->db->query($query);
|
||||
|
||||
if(isset($_REQUEST['object_type']) && !empty($_REQUEST['object_type']) && isset($_REQUEST['object_id']) && !empty($_REQUEST['object_id'])) {
|
||||
//run linking code only if the object_id has not been linked as part of the contacts above
|
||||
$GLOBALS['log']->debug("CESELY".$_REQUEST['object_type']);
|
||||
if(!in_array($_REQUEST['object_id'],$exContactIds)){
|
||||
$rel = strtolower($_REQUEST['object_type']);
|
||||
$focus->load_relationship($rel);
|
||||
$focus->$rel->add($_REQUEST['object_id']);
|
||||
$GLOBALS['log']->debug("CESELY LOADED".$_REQUEST['object_type']);
|
||||
}
|
||||
}
|
||||
//// handle legacy parent_id/parent_type relationship calls
|
||||
elseif(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
|
||||
//run linking code only if the object_id has not been linked as part of the contacts above
|
||||
if(!isset($exContactIds) || !in_array($_REQUEST['parent_id'],$exContactIds)){
|
||||
$rel = strtolower($_REQUEST['parent_type']);
|
||||
$focus->load_relationship($rel);
|
||||
$focus->$rel->add($_REQUEST['parent_id']);
|
||||
}
|
||||
}
|
||||
//// END RELATIONSHIP LINKING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// If came from email archiving edit view, this would have been set from form input.
|
||||
if (!isset($focus->date_start))
|
||||
{
|
||||
$today = gmdate('Y-m-d H:i:s');
|
||||
$focus->date_start = $timedate->to_display_date($today);
|
||||
$focus->time_start = $timedate->to_display_time($today, true);
|
||||
}
|
||||
|
||||
$focus->date_sent = "";
|
||||
$focus->save(false);
|
||||
//// END EMAIL SAVE/SEND SETUP
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// RELATIONSHIP LINKING
|
||||
$focus->load_relationship('users');
|
||||
$focus->users->add($current_user->id);
|
||||
|
||||
if(!empty($_REQUEST['to_addrs_ids'])) {
|
||||
$focus->load_relationship('contacts');
|
||||
$exContactIds = explode(';', $_REQUEST['to_addrs_ids']);
|
||||
foreach($exContactIds as $contactId) {
|
||||
$contactId = trim($contactId);
|
||||
$focus->contacts->add($contactId);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// PAGE REDIRECTION
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
$return_id = $focus->id;
|
||||
|
||||
if(empty($_POST['return_module'])) {
|
||||
$return_module = "Emails";
|
||||
} else {
|
||||
$return_module = $_POST['return_module'];
|
||||
}
|
||||
if(empty($_POST['return_action'])) {
|
||||
$return_action = "DetailView";
|
||||
} else {
|
||||
$return_action = $_POST['return_action'];
|
||||
}
|
||||
$GLOBALS['log']->debug("Saved record with id of ".$return_id);
|
||||
require_once('include/formbase.php');
|
||||
if($focus->type == 'draft') {
|
||||
if($return_module == 'Emails') {
|
||||
header("Location: index.php?module=$return_module&action=ListViewDrafts");
|
||||
} else {
|
||||
handleRedirect($return_id, 'Emails');
|
||||
}
|
||||
} elseif($focus->type == 'out') {
|
||||
if($return_module == 'Home') {
|
||||
header('Location: index.php?module='.$return_module.'&action=index');
|
||||
}
|
||||
if(!empty($_REQUEST['return_id'])) {
|
||||
$return_id = $_REQUEST['return_id'];
|
||||
}
|
||||
header('Location: index.php?action='.$return_action.'&module='.$return_module.'&record='.$return_id.'&assigned_user_id='.$current_user->id.'&type=inbound');
|
||||
} elseif(isset($_POST['return_id']) && $_POST['return_id'] != "") {
|
||||
$return_id = $_POST['return_id'];
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=Emails&to_pdf=1&bodyclass=tabForm&type=out&pricebook_id=".$_REQUEST['pricebook_id']);
|
||||
?>
|
||||
894
import/EcmPriceBooks/Emails.php
Normal file
894
import/EcmPriceBooks/Emails.php
Normal file
@@ -0,0 +1,894 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/**
|
||||
* EditView for Email
|
||||
*
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
*/
|
||||
|
||||
$toTemplate = '';
|
||||
if(isset($_REQUEST['pTypeTo']) && $_REQUEST['pTypeTo']!='' && isset($_REQUEST['pIdTo']) && $_REQUEST['pIdTo']!='') {
|
||||
if($_REQUEST['pTypeTo'] == "Accounts") {
|
||||
require_once('modules/Accounts/Account.php');
|
||||
$acc = new Account();
|
||||
$acc->retrieve($_REQUEST['pIdTo']);
|
||||
if(isset($acc->id) && $acc->id!='') {
|
||||
$_REQUEST['to_addrs'] = $acc->name.' <'.$acc->email1.'>; ';
|
||||
}
|
||||
}
|
||||
if($_REQUEST['pTypeTo'] == "Contacts") {
|
||||
require_once('modules/Contacts/Contact.php');
|
||||
$con = new Contact();
|
||||
$con->retrieve($_REQUEST['pIdTo']);
|
||||
if(isset($con->id) && $con->id!='') {
|
||||
$_REQUEST['to_addrs'] = $con->name.' <'.$con->email1.'>; ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['pTypeTo']) && $_REQUEST['pTypeTo']!='')
|
||||
if($_REQUEST['pTypeTo'] == "Accounts") $toTemplate = 'InvoiceTemplateAccount';
|
||||
else
|
||||
if($_REQUEST['pTypeTo'] == "Contacts") $toTemplate = 'InvoiceTemplateContact';
|
||||
|
||||
|
||||
if(isset($_REQUEST['pTypeFrom']) && $_REQUEST['pTypeFrom']!='' && isset($_REQUEST['pIdFrom']) && $_REQUEST['pIdFrom']!='') {
|
||||
if($_REQUEST['pTypeFrom'] == "Users") {
|
||||
require_once('modules/Users/User.php');
|
||||
$us = new User();
|
||||
global $current_user;
|
||||
$us->retrieve($current_user->id);//$_REQUEST['pIdFrom']);
|
||||
if(isset($us->id) && $us->id!='') {
|
||||
$_REQUEST['from_addr'] = $us->name.' <'.$us->email1.'>; ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo '<script type="text/javascript">var asynchronous_key = "'.$_SESSION['asynchronous_key'].'";</script>';
|
||||
|
||||
$GLOBALS['log']->info("Email edit view");
|
||||
|
||||
require_once('include/SugarTinyMCE.php');
|
||||
require_once('modules/Emails/Email.php');
|
||||
require_once('modules/EmailTemplates/EmailTemplate.php');
|
||||
require_once('XTemplate/xtpl.php');
|
||||
|
||||
global $theme;
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
require_once($theme_path.'layout_utils.php');
|
||||
|
||||
global $app_strings;
|
||||
global $app_list_strings;
|
||||
global $current_user;
|
||||
global $sugar_version, $sugar_config;
|
||||
global $timedate;
|
||||
$mod_strings = return_module_language($current_language, 'Emails');
|
||||
|
||||
$OPT = array();
|
||||
if(isset($_REQUEST['invoiceout_id']) && $_REQUEST['invoiceout_id']!='') {
|
||||
$OPT['invoiceout_id'] = $_REQUEST['invoiceout_id'];
|
||||
} else $OPT['invoiceout_id'] = '';
|
||||
|
||||
if(isset($_REQUEST['sended']) && $_REQUEST['sended']!='') {
|
||||
$OPT['sended'] = $_REQUEST['sended'];
|
||||
} else $OPT['sended'] = '0';
|
||||
|
||||
|
||||
$json = getJSONobj();
|
||||
echo '<script language="javascript">
|
||||
|
||||
var OPT = '.$json->encode($OPT).';
|
||||
function invoiceoutAlert(method) {
|
||||
if(OPT[\'invoiceout_id\']==\'\') {
|
||||
alert(\'Invoice not saved!\');
|
||||
return false;
|
||||
}
|
||||
if(method == \'save\') {
|
||||
prepSave(); document.forms.EditView.action.value=\'EmailSave\'; document.forms.EditView.send.value=\'1\'; document.forms.EditView.type.value=\'out\'; return fill_form(\'out\', \''.$mod_strings['ERR_NOT_ADDRESSED'].'\');
|
||||
}
|
||||
if(method == \'save_draft\') {
|
||||
document.forms.EditView.action.value=\'EmailSave\'; document.forms.EditView.send.value=\'0\'; document.forms.EditView.type.value=\'draft\'; fill_form(\'draft\', \''.$mod_strings['ERR_NOT_ADDRESSED'].'\');
|
||||
}
|
||||
};
|
||||
if(OPT[\'sended\']==\'1\') alert(\'Email was sended\');
|
||||
</script>';
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// PREPROCESS BEAN DATA FOR DISPLAY
|
||||
$focus = new Email();
|
||||
$email_type = 'archived';
|
||||
|
||||
if(isset($_REQUEST['record'])) {
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
}
|
||||
if(!empty($_REQUEST['type'])) {
|
||||
$email_type = $_REQUEST['type'];
|
||||
} elseif(!empty($focus->id)) {
|
||||
$email_type = $focus->type;
|
||||
}
|
||||
|
||||
$focus->type = $email_type;
|
||||
|
||||
//needed when creating a new email with default values passed in
|
||||
if(isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
|
||||
$focus->contact_name = $_REQUEST['contact_name'];
|
||||
}
|
||||
|
||||
if(!empty($_REQUEST['load_id']) && !empty($beanList[$_REQUEST['load_module']])) {
|
||||
$class_name = $beanList[$_REQUEST['load_module']];
|
||||
require_once($beanFiles[$class_name]);
|
||||
$contact = new $class_name();
|
||||
if($contact->retrieve($_REQUEST['load_id'])) {
|
||||
$link_id = $class_name . '_id';
|
||||
$focus->$link_id = $_REQUEST['load_id'];
|
||||
$focus->contact_name = (isset($contact->full_name)) ? $contact->full_name : $contact->name;
|
||||
$focus->to_addrs_names = $focus->contact_name;
|
||||
$focus->to_addrs_ids = $_REQUEST['load_id'];
|
||||
//Retrieve the email address.
|
||||
//If Opportunity or Case then Oppurtinity/Case->Accounts->(email_addr_bean_rel->email_addresses)
|
||||
//If Contacts, Leads etc.. then Contact->(email_addr_bean_rel->email_addresses)
|
||||
$sugarEmailAddress = new SugarEmailAddress();
|
||||
if($class_name == 'Opportunity' || $class_name == 'aCase'){
|
||||
$account = new Account();
|
||||
if($contact->account_id != null && $account->retrieve($contact->account_id)){
|
||||
$sugarEmailAddress->handleLegacyRetrieve($account);
|
||||
if(isset($account->email1)){
|
||||
$focus->to_addrs_emails = $account->email1;
|
||||
$focus->to_addrs = "$focus->contact_name <$account->email1>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sugarEmailAddress->handleLegacyRetrieve($contact);
|
||||
if(isset($contact->email1)){
|
||||
$focus->to_addrs_emails = $contact->email1;
|
||||
$focus->to_addrs = "$focus->contact_name <$contact->email1>";
|
||||
}
|
||||
}
|
||||
if(!empty($_REQUEST['parent_type']) && empty($app_list_strings['record_type_display'][$_REQUEST['parent_type']])){
|
||||
if(!empty($app_list_strings['record_type_display'][$_REQUEST['load_module']])){
|
||||
$_REQUEST['parent_type'] = $_REQUEST['load_module'];
|
||||
$_REQUEST['parent_id'] = $focus->contact_id;
|
||||
$_REQUEST['parent_name'] = $focus->to_addrs_names;
|
||||
} else {
|
||||
unset($_REQUEST['parent_type']);
|
||||
unset($_REQUEST['parent_id']);
|
||||
unset($_REQUEST['parent_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
|
||||
$focus->contact_id = $_REQUEST['contact_id'];
|
||||
}
|
||||
if(isset($_REQUEST['parent_name'])) {
|
||||
$focus->parent_name = $_REQUEST['parent_name'];
|
||||
}
|
||||
if(isset($_REQUEST['parent_id'])) {
|
||||
$focus->parent_id = $_REQUEST['parent_id'];
|
||||
}
|
||||
if(isset($_REQUEST['parent_type'])) {
|
||||
$focus->parent_type = $_REQUEST['parent_type'];
|
||||
}
|
||||
elseif(is_null($focus->parent_type)) {
|
||||
$focus->parent_type = $app_list_strings['record_type_default_key'];
|
||||
}
|
||||
if(isset($_REQUEST['to_email_addrs'])) {
|
||||
$focus->to_addrs = $_REQUEST['to_email_addrs'];
|
||||
}
|
||||
// needed when clicking through a Contacts detail view:
|
||||
if(isset($_REQUEST['to_addrs_ids'])) {
|
||||
$focus->to_addrs_ids = $_REQUEST['to_addrs_ids'];
|
||||
}
|
||||
if(isset($_REQUEST['to_addrs_emails'])) {
|
||||
$focus->to_addrs_emails = $_REQUEST['to_addrs_emails'];
|
||||
}
|
||||
if(isset($_REQUEST['to_addrs_names'])) {
|
||||
$focus->to_addrs_names = $_REQUEST['to_addrs_names'];
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['to_addrs'])) {
|
||||
$focus->to_addrs = $_REQUEST['to_addrs'];
|
||||
}// user's email, go through 3 levels of precedence:
|
||||
if(isset($_REQUEST['from_addr'])) {
|
||||
$focus->from_addr = $_REQUEST['from_addr'];
|
||||
}// user's email, go through 3 levels of precedence:
|
||||
$from = $current_user->getEmailInfo();
|
||||
//// END PREPROCESSING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// XTEMPLATE ASSIGNMENT
|
||||
if($email_type == 'archived') {
|
||||
// echo get_module_title('Emails', $mod_strings['LBL_ARCHIVED_MODULE_NAME'].":", true);
|
||||
$xtpl=new XTemplate('modules/Emails/EditViewArchive.html');
|
||||
} else {
|
||||
// echo get_module_title('Emails', $mod_strings['LBL_COMPOSE_MODULE_NAME'].":", true);
|
||||
$xtpl=new XTemplate('modules/EcmPriceBooks/Emails.html');
|
||||
}
|
||||
echo "\n</p>\n";
|
||||
|
||||
// CHECK USER'S EMAIL SETTINGS TO ENABLE/DISABLE 'SEND' BUTTON
|
||||
if(!$focus->check_email_settings() &&($email_type == 'out' || $email_type == 'draft')) {
|
||||
print "<font color='red'>".$mod_strings['WARNING_SETTINGS_NOT_CONF']." <a href='index.php?module=Users&action=EditView&record=".$current_user->id."&return_module=Emails&type=out&return_action=EditView'>".$mod_strings['LBL_EDIT_MY_SETTINGS']."</a></font>";
|
||||
$xtpl->assign("DISABLE_SEND", 'DISABLED');
|
||||
}
|
||||
|
||||
// CHECK THAT SERVER HAS A PLACE TO PUT UPLOADED TEMP FILES SO THAT ATTACHMENTS WILL WORK
|
||||
// cn: Bug 5995
|
||||
$tmpUploadDir = ini_get('upload_tmp_dir');
|
||||
if(!empty($tmpUploadDir)) {
|
||||
if(!is_writable($tmpUploadDir)) {
|
||||
echo "<font color='red'>{$mod_strings['WARNING_UPLOAD_DIR_NOT_WRITABLE']}</font>";
|
||||
}
|
||||
} else {
|
||||
//echo "<font color='red'>{$mod_strings['WARNING_NO_UPLOAD_DIR']}</font>";
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// INBOUND EMAIL HANDLING
|
||||
if(isset($_REQUEST['email_name'])) {
|
||||
$name = str_replace('_',' ',$_REQUEST['email_name']);
|
||||
}
|
||||
if(isset($_REQUEST['inbound_email_id'])) {
|
||||
$ieMail = new Email();
|
||||
$ieMail->retrieve($_REQUEST['inbound_email_id']);
|
||||
|
||||
$invoiceoutd = '';
|
||||
// cn: bug 9725: replies/forwards lose real content
|
||||
$invoiceoutdHtml = $ieMail->invoiceoutHtmlEmail($ieMail->description_html);
|
||||
|
||||
// plain-text
|
||||
$desc = nl2br(trim($ieMail->description));
|
||||
|
||||
$exDesc = explode('<br />', $desc);
|
||||
foreach($exDesc as $k => $line) {
|
||||
$invoiceoutd .= '> '.trim($line)."\r";
|
||||
}
|
||||
|
||||
// prefill empties with the other's contents
|
||||
if(empty($invoiceoutdHtml) && !empty($invoiceoutd)) {
|
||||
$invoiceoutdHtml = nl2br($invoiceoutd);
|
||||
}
|
||||
if(empty($invoiceoutd) && !empty($invoiceoutdHtml)) {
|
||||
$invoiceoutd = strip_tags(br2nl($invoiceoutdHtml));
|
||||
}
|
||||
|
||||
// forwards have special text
|
||||
if($_REQUEST['type'] == 'forward') {
|
||||
$header = $ieMail->getForwardHeader();
|
||||
// subject is handled in Subject line handling below
|
||||
} else {
|
||||
// we have a reply in focus
|
||||
$header = $ieMail->getReplyHeader();
|
||||
}
|
||||
|
||||
$invoiceoutd = br2nl($header.$invoiceoutd);
|
||||
$invoiceoutdHtml = $header.$invoiceoutdHtml;
|
||||
|
||||
|
||||
// if not a forward: it's a reply
|
||||
if($_REQUEST['type'] != 'forward') {
|
||||
$ieMailName = 'RE: '.$ieMail->name;
|
||||
} else {
|
||||
$ieMailName = $ieMail->name;
|
||||
}
|
||||
|
||||
$focus->id = null; // nulling this to prevent overwriting a replied email(we're basically doing a "Duplicate" function)
|
||||
$focus->to_addrs = $ieMail->from_addr;
|
||||
$focus->description = $invoiceoutd; // don't know what i was thinking: ''; // this will be filled on save/send
|
||||
$focus->description_html = $invoiceoutdHtml; // cn: bug 7357 - htmlentities() breaks FCKEditor
|
||||
$focus->parent_type = $ieMail->parent_type;
|
||||
$focus->parent_id = $ieMail->parent_id;
|
||||
$focus->parent_name = $ieMail->parent_name;
|
||||
$focus->name = $ieMailName;
|
||||
$xtpl->assign('INBOUND_EMAIL_ID',$_REQUEST['inbound_email_id']);
|
||||
// un/READ flags
|
||||
if(!empty($ieMail->status)) {
|
||||
// "Read" flag for InboundEmail
|
||||
if($ieMail->status == 'unread') {
|
||||
// creating a new instance here to avoid data corruption below
|
||||
$e = new Email();
|
||||
$e->retrieve($ieMail->id);
|
||||
$e->status = 'read';
|
||||
$e->save();
|
||||
$email_type = $e->status;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//// PRIMARY PARENT LINKING
|
||||
if(empty($focus->parent_type) && empty($focus->parent_id)) {
|
||||
$focus->fillPrimaryParentFields();
|
||||
}
|
||||
//// END PRIMARY PARENT LINKING
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// setup for my/mailbox email switcher
|
||||
$mbox = $ieMail->getMailboxDefaultEmail();
|
||||
$user = $current_user->getPreferredEmail();
|
||||
$useGroup = ' <input id="use_mbox" name="use_mbox" type="checkbox" CHECKED onClick="switchEmail()" >
|
||||
<script type="text/javascript">
|
||||
function switchEmail() {
|
||||
var mboxName = "'.$mbox['name'].'";
|
||||
var mboxAddr = "'.$mbox['email'].'";
|
||||
var userName = "'.$user['name'].'";
|
||||
var userAddr = "'.$user['email'].'";
|
||||
|
||||
if(document.getElementById("use_mbox").checked) {
|
||||
document.getElementById("from_addr_field").value = mboxName + " <" + mboxAddr + ">";
|
||||
document.getElementById("from_addr_name").value = mboxName;
|
||||
document.getElementById("from_addr_email").value = mboxAddr;
|
||||
} else {
|
||||
document.getElementById("from_addr_field").value = userName + " <" + userAddr + ">";
|
||||
document.getElementById("from_addr_name").value = userName;
|
||||
document.getElementById("from_addr_email").value = userAddr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>';
|
||||
$useGroup .= $mod_strings['LBL_USE_MAILBOX_INFO'];
|
||||
|
||||
$xtpl->assign('FROM_ADDR_GROUP', $useGroup);
|
||||
}
|
||||
//// END INBOUND EMAIL HANDLING
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// SUBJECT FIELD MANIPULATION
|
||||
$name = '';
|
||||
if(!empty($_REQUEST['parent_id']) && !empty($_REQUEST['parent_type'])) {
|
||||
$focus->parent_id = $_REQUEST['parent_id'];
|
||||
$focus->parent_type = $_REQUEST['parent_type'];
|
||||
}
|
||||
if(!empty($focus->parent_id) && !empty($focus->parent_type)) {
|
||||
if($focus->parent_type == 'Cases') {
|
||||
require_once('modules/Cases/Case.php');
|
||||
$myCase = new aCase();
|
||||
$myCase->retrieve($focus->parent_id);
|
||||
$myCaseMacro = $myCase->getEmailSubjectMacro();
|
||||
if(isset($ieMail->name) && !empty($ieMail->name)) { // if replying directly to an InboundEmail
|
||||
$oldEmailSubj = $ieMail->name;
|
||||
} elseif(isset($_REQUEST['parent_name']) && !empty($_REQUEST['parent_name'])) {
|
||||
$oldEmailSubj = $_REQUEST['parent_name'];
|
||||
} else {
|
||||
$oldEmailSubj = $focus->name; // replying to an email using old subject
|
||||
}
|
||||
|
||||
if(!preg_match('/^re:/i', $oldEmailSubj)) {
|
||||
$oldEmailSubj = 'RE: '.$oldEmailSubj;
|
||||
}
|
||||
$focus->name = $oldEmailSubj;
|
||||
|
||||
if(strpos($focus->name, str_replace('%1',$myCase->case_number,$myCaseMacro))) {
|
||||
$name = $focus->name;
|
||||
} else {
|
||||
$name = $focus->name.' '.str_replace('%1',$myCase->case_number,$myCaseMacro);
|
||||
}
|
||||
} else {
|
||||
$name = $focus->name;
|
||||
}
|
||||
} else {
|
||||
if(empty($focus->name)) {
|
||||
$name = '';
|
||||
} else {
|
||||
$name = $focus->name;
|
||||
}
|
||||
}
|
||||
if($email_type == 'forward') {
|
||||
$name = 'FW: '.$name;
|
||||
}
|
||||
//// END SUBJECT FIELD MANIPULATION
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// GENERAL TEMPLATE ASSIGNMENTS
|
||||
$xtpl->assign('MOD', return_module_language($current_language, 'Emails'));
|
||||
$xtpl->assign('APP', $app_strings);
|
||||
|
||||
if(!isset($focus->id)) $xtpl->assign('USER_ID', $current_user->id);
|
||||
if(!isset($focus->id) && isset($_REQUEST['contact_id'])) $xtpl->assign('CONTACT_ID', $_REQUEST['contact_id']);
|
||||
|
||||
$xtpl->assign("INVOICEOUT_ID",$_REQUEST['invoiceout_id']);
|
||||
if(isset($_REQUEST['return_module']) && !empty($_REQUEST['return_module'])) {
|
||||
$xtpl->assign('RETURN_MODULE', $_REQUEST['return_module']);
|
||||
} else {
|
||||
$xtpl->assign('RETURN_MODULE', 'Emails');
|
||||
}
|
||||
if(isset($_REQUEST['return_action']) && !empty($_REQUEST['return_action']) && ($_REQUEST['return_action'] != 'SubPanelViewer')) {
|
||||
$xtpl->assign('RETURN_ACTION', $_REQUEST['return_action']);
|
||||
} else {
|
||||
$xtpl->assign('RETURN_ACTION', 'DetailView');
|
||||
}
|
||||
if(isset($_REQUEST['return_id']) && !empty($_REQUEST['return_id'])) {
|
||||
$xtpl->assign('RETURN_ID', $_REQUEST['return_id']);
|
||||
}
|
||||
// handle Create $module then Cancel
|
||||
if(empty($_REQUEST['return_id']) && !isset($_REQUEST['type'])) {
|
||||
$xtpl->assign('RETURN_ACTION', 'index');
|
||||
}
|
||||
|
||||
$xtpl->assign('THEME', $theme);
|
||||
$xtpl->assign('IMAGE_PATH', $image_path);$xtpl->assign('PRINT_URL', 'index.php?'.$GLOBALS['request_string']);
|
||||
|
||||
if(isset($_REQUEST['bodyclass']) && $_REQUEST['bodyclass'] != '') $xtpl->assign('BODYCLASS',$_REQUEST['bodyclass']);
|
||||
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
$m = new EcmPriceBook();
|
||||
//$mfp = $m->loadParserArray('email');
|
||||
$xtpl->assign("MFP",$mfp);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// QUICKSEARCH CODE
|
||||
require_once('include/QuickSearchDefaults.php');
|
||||
$qsd = new QuickSearchDefaults();
|
||||
$sqs_objects = array('parent_name' => $qsd->getQSParent(),
|
||||
'assigned_user_name' => $qsd->getQSUser(),
|
||||
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
$json = getJSONobj();
|
||||
|
||||
$quicksearch_js = $qsd->getQSScripts();
|
||||
$sqs_objects_encoded = $json->encode($sqs_objects);
|
||||
$quicksearch_js .= <<<EOQ
|
||||
<script type="text/javascript" language="javascript">sqs_objects = $sqs_objects_encoded;
|
||||
function changeQS() {
|
||||
//new_module = document.getElementById('parent_type').value;
|
||||
new_module = document.EditView.parent_type.value;
|
||||
if(new_module == 'Contacts' || new_module == 'Leads' || typeof(disabledModules[new_module]) != 'undefined') {
|
||||
sqs_objects['parent_name']['disable'] = true;
|
||||
document.getElementById('parent_name').readOnly = true;
|
||||
}
|
||||
else {
|
||||
sqs_objects['parent_name']['disable'] = false;
|
||||
document.getElementById('parent_name').readOnly = false;
|
||||
}
|
||||
|
||||
sqs_objects['parent_name']['module'] = new_module;
|
||||
}
|
||||
changeQS();
|
||||
</script>
|
||||
EOQ;
|
||||
$xtpl->assign('JAVASCRIPT', get_set_focus_js().$quicksearch_js);
|
||||
//// END QUICKSEARCH CODE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// cn: bug 14191 - duping archive emails overwrites the original
|
||||
if(!isset($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] != 'true') {
|
||||
$xtpl->assign('ID', $focus->id);
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
|
||||
$xtpl->assign('OBJECT_ID', $_REQUEST['parent_id']);
|
||||
$xtpl->assign('OBJECT_TYPE', $_REQUEST['parent_type']);
|
||||
}
|
||||
|
||||
$xtpl->assign('FROM_ADDR', $focus->from_addr);
|
||||
$xtpl->assign('FROM_ADDR', $current_user->first_name." ".$current_user->last_name." <". $current_user->getPreference('mail_fromaddress').">");
|
||||
//// prevent TO: prefill when type is 'forward'
|
||||
if($email_type != 'forward') {
|
||||
$xtpl->assign('TO_ADDRS', $focus->to_addrs);
|
||||
$xtpl->assign('FROM_ADDRS', $focus->from_addrs);
|
||||
$xtpl->assign('TO_ADDRS_IDS', $focus->to_addrs_ids);
|
||||
$xtpl->assign('TO_ADDRS_NAMES', $focus->to_addrs_names);
|
||||
$xtpl->assign('TO_ADDRS_EMAILS', $focus->to_addrs_emails);
|
||||
$xtpl->assign('CC_ADDRS', $focus->cc_addrs);
|
||||
$xtpl->assign('CC_ADDRS_IDS', $focus->cc_addrs_ids);
|
||||
$xtpl->assign('CC_ADDRS_NAMES', $focus->cc_addrs_names);
|
||||
$xtpl->assign('CC_ADDRS_EMAILS', $focus->cc_addrs_emails);
|
||||
$xtpl->assign('BCC_ADDRS', $focus->bcc_addrs);
|
||||
$xtpl->assign('BCC_ADDRS_IDS', $focus->bcc_addrs_ids);
|
||||
$xtpl->assign('BCC_ADDRS_NAMES', $focus->bcc_addrs_names);
|
||||
$xtpl->assign('BCC_ADDRS_EMAILS', $focus->bcc_addrs_emails);
|
||||
}
|
||||
|
||||
//$xtpl->assign('FROM_ADDR', $from['name'].' <'.$from['email'].'>');
|
||||
$xtpl->assign('FROM_ADDR_NAME', $from['name']);
|
||||
$xtpl->assign('FROM_ADDR_EMAIL', $from['email']);
|
||||
|
||||
$xtpl->assign('NAME', from_html($name));
|
||||
//$xtpl->assign('DESCRIPTION_HTML', from_html($focus->description_html));
|
||||
$xtpl->assign('DESCRIPTION', $focus->description);
|
||||
$xtpl->assign('TYPE',$email_type);
|
||||
|
||||
// Unimplemented until jscalendar language files are fixed
|
||||
// $xtpl->assign('CALENDAR_LANG',((empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]));
|
||||
$xtpl->assign('CALENDAR_LANG', 'en');
|
||||
$xtpl->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
|
||||
$xtpl->assign('DATE_START', $focus->date_start);
|
||||
$xtpl->assign('TIME_FORMAT', '('. $timedate->get_user_time_format().')');
|
||||
$xtpl->assign('TIME_START', substr($focus->time_start,0,5));
|
||||
$xtpl->assign('TIME_MERIDIEM', $timedate->AMPMMenu('',$focus->time_start));
|
||||
|
||||
$parent_types = $app_list_strings['record_type_display'];
|
||||
$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
|
||||
|
||||
foreach($disabled_parent_types as $disabled_parent_type){
|
||||
if($disabled_parent_type != $focus->parent_type){
|
||||
unset($parent_types[$disabled_parent_type]);
|
||||
}
|
||||
}
|
||||
|
||||
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
|
||||
$xtpl->assign('USER_DATEFORMAT', '('. $timedate->get_user_date_format().')');
|
||||
$xtpl->assign('PARENT_NAME', $focus->parent_name);
|
||||
$xtpl->assign('PARENT_ID', $focus->parent_id);
|
||||
if(empty($focus->parent_type)) {
|
||||
$xtpl->assign('PARENT_RECORD_TYPE', '');
|
||||
} else {
|
||||
$xtpl->assign('PARENT_RECORD_TYPE', $focus->parent_type);
|
||||
}
|
||||
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
|
||||
$record = '';
|
||||
if(!empty($_REQUEST['record'])){
|
||||
$record = $_REQUEST['record'];
|
||||
}
|
||||
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
|
||||
}
|
||||
|
||||
//// END GENERAL TEMPLATE ASSIGNMENTS
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
///
|
||||
/// SETUP PARENT POPUP
|
||||
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'parent_id',
|
||||
'name' => 'parent_name',
|
||||
),
|
||||
);
|
||||
|
||||
$encoded_popup_request_data = $json->encode($popup_request_data);
|
||||
|
||||
/// Users Popup
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'assigned_user_id',
|
||||
'user_name' => 'assigned_user_name',
|
||||
),
|
||||
);
|
||||
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
|
||||
|
||||
|
||||
|
||||
$xtpl->assign('PRICEBOOK_ID', $_REQUEST['pricebook_id']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
///////////////////////////////////////
|
||||
|
||||
$change_parent_button = '<input type="button" name="button" tabindex="2" class="button" '
|
||||
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
|
||||
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
|
||||
. 'value="' . $app_strings['LBL_SELECT_BUTTON_LABEL'] . '" '
|
||||
. "onclick='open_popup(document.EditView.parent_type.value,600,400,\"&tree=ProductsProd\",true,false,$encoded_popup_request_data);' />\n";
|
||||
$xtpl->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
|
||||
|
||||
$button_attr = '';
|
||||
if(!ACLController::checkAccess('Contacts', 'list', true)){
|
||||
$button_attr = 'disabled="disabled"';
|
||||
}
|
||||
|
||||
$change_to_addrs_button = '<input type="button" name="to_button" tabindex="3" class="button" '
|
||||
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
|
||||
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
|
||||
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
|
||||
. "onclick='button_change_onclick(this);' $button_attr />\n";
|
||||
$xtpl->assign("CHANGE_TO_ADDRS_BUTTON", $change_to_addrs_button);
|
||||
|
||||
$change_cc_addrs_button = '<input type="button" name="cc_button" tabindex="3" class="button" '
|
||||
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
|
||||
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
|
||||
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
|
||||
. "onclick='button_change_onclick(this);' $button_attr />\n";
|
||||
$xtpl->assign("CHANGE_CC_ADDRS_BUTTON", $change_cc_addrs_button);
|
||||
|
||||
$change_bcc_addrs_button = '<input type="button" name="bcc_button" tabindex="3" class="button" '
|
||||
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
|
||||
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
|
||||
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
|
||||
. "onclick='button_change_onclick(this);' $button_attr />\n";
|
||||
$xtpl->assign("CHANGE_BCC_ADDRS_BUTTON", $change_bcc_addrs_button);
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
//// USER ASSIGNMENT
|
||||
global $current_user;
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
|
||||
$record = '';
|
||||
if(!empty($_REQUEST['record'])) {
|
||||
$record = $_REQUEST['record'];
|
||||
}
|
||||
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
|
||||
}
|
||||
|
||||
if(empty($focus->assigned_user_id) && empty($focus->id))
|
||||
$focus->assigned_user_id = $current_user->id;
|
||||
if(empty($focus->assigned_name) && empty($focus->id))
|
||||
$focus->assigned_user_name = $current_user->user_name;
|
||||
$xtpl->assign('ASSIGNED_USER_OPTIONS', get_select_options_with_id(get_user_array(TRUE, 'Active', $focus->assigned_user_id), $focus->assigned_user_id));
|
||||
$xtpl->assign('ASSIGNED_USER_NAME', $focus->assigned_user_name);
|
||||
$xtpl->assign('ASSIGNED_USER_ID', $focus->assigned_user_id);
|
||||
$xtpl->assign('DURATION_HOURS', $focus->duration_hours);
|
||||
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
|
||||
$xtpl->assign("PIDFROM",$_REQUEST['pIdFrom']);
|
||||
$xtpl->assign("PTYPEFROM",$_REQUEST['pTypeFrom']);
|
||||
$xtpl->assign("PIDTO",$_REQUEST['pIdTo']);
|
||||
$xtpl->assign("PTYPETO",$_REQUEST['pTypeTo']);
|
||||
if(isset($focus->duration_minutes)) {
|
||||
$xtpl->assign('DURATION_MINUTES_OPTIONS', get_select_options_with_id($focus->minutes_values,$focus->duration_minutes));
|
||||
}
|
||||
//// END USER ASSIGNMENT
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//Add Custom Fields
|
||||
require_once('modules/DynamicFields/templates/Files/EditView.php');
|
||||
require_once("modules/Notes/Note.php");
|
||||
|
||||
///////////////////////////////////////
|
||||
//// ATTACHMENTS
|
||||
$attachments = '';
|
||||
if(!empty($focus->id) || (!empty($_REQUEST['record']) && $_REQUEST['type'] == 'forward')) {
|
||||
|
||||
$attachments = "<input type='hidden' name='removeAttachment' id='removeAttachment' value=''>\n";
|
||||
$ids = '';
|
||||
|
||||
$focusId = empty($focus->id) ? $_REQUEST['record'] : $focus->id;
|
||||
$note = new Note();
|
||||
$where = "notes.parent_id='{$focusId}' AND notes.filename IS NOT NULL";
|
||||
$notes_list = $note->get_full_list("", $where,true);
|
||||
|
||||
if(!isset($notes_list)) {
|
||||
$notes_list = array();
|
||||
}
|
||||
for($i = 0;$i < count($notes_list);$i++) {
|
||||
$the_note = $notes_list[$i];
|
||||
if(empty($the_note->filename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
|
||||
if(!empty($ids)) {
|
||||
$ids .= ",";
|
||||
}
|
||||
$ids .= $the_note->id;
|
||||
|
||||
$attachments .= "
|
||||
<div id='noteDiv{$the_note->id}'>
|
||||
<img onclick='deletePriorAttachment(\"{$the_note->id}\");' src='themes/{$theme}/images/delete_inline.gif' value='{$the_note->id}'> ";
|
||||
$attachments .= '<a href="'.UploadFile::get_url($the_note->filename,$the_note->id).'" target="_blank">'. $the_note->filename .'</a></div>';
|
||||
|
||||
}
|
||||
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
|
||||
$attachments .= "<input type='hidden' name='prior_attachments' value='{$ids}'>";
|
||||
|
||||
// workaround $mod_strings being overriden by Note object instantiation above.
|
||||
global $current_language, $mod_strings;
|
||||
$mod_strings = return_module_language($current_language, 'Emails');
|
||||
}
|
||||
|
||||
$attJs = '<script type="text/javascript">';
|
||||
$attJs .= 'var file_path = "'.$sugar_config['site_url'].'/'.$sugar_config['upload_dir'].'";';
|
||||
$attJs .= 'var lnk_remove = "'.$app_strings['LNK_REMOVE'].'";';
|
||||
$attJs .= '</script>';
|
||||
$xtpl->assign('ATTACHMENTS', $attachments);
|
||||
$xtpl->assign('ATTACHMENTS_JAVASCRIPT', $attJs);
|
||||
//// END ATTACHMENTS
|
||||
///////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// DOCUMENTS
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'document_set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'related_doc_id',
|
||||
'document_name' => 'related_document_name',
|
||||
),
|
||||
);
|
||||
$json = getJSONobj();
|
||||
$xtpl->assign('encoded_document_popup_request_data', $json->encode($popup_request_data));
|
||||
//// END DOCUMENTS
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$parse_open = true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($parse_open) {
|
||||
$xtpl->parse('main.open_source_1');
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//// EMAIL TEMPLATES
|
||||
if(ACLController::checkAccess('EmailTemplates', 'list', true) && ACLController::checkAccess('EmailTemplates', 'view', true)) {
|
||||
$et = new EmailTemplate();
|
||||
$etResult = $focus->db->query($et->create_list_query('','',''));
|
||||
$email_templates_arr[] = '';
|
||||
$toTemplateId = '';
|
||||
while($etA = $focus->db->fetchByAssoc($etResult)) {
|
||||
if($toTemplate == $etA['name']) { $toTemplateId = $etA['id']; }
|
||||
$email_templates_arr[$etA['id']] = $etA['name'];
|
||||
}
|
||||
} else {
|
||||
$email_templates_arr = array('' => $app_strings['LBL_NONE']);
|
||||
}
|
||||
|
||||
$xtpl->assign('EMAIL_TEMPLATE_OPTIONS', get_select_options_with_id($email_templates_arr, $toTemplateId));
|
||||
//// END EMAIL TEMPLATES
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////
|
||||
//// TEXT EDITOR
|
||||
// cascade from User to Sys Default
|
||||
$editor = $focus->getUserEditorPreference();
|
||||
|
||||
if($editor != 'plain') {
|
||||
// this box is checked by Javascript on-load.
|
||||
$xtpl->assign('EMAIL_EDITOR_OPTION', 'CHECKED');
|
||||
}
|
||||
$description_html = from_html($focus->description_html);
|
||||
$description = $focus->description;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// signatures
|
||||
if($sig = $current_user->getDefaultSignature()) {
|
||||
if(!$focus->hasSignatureInBody($sig) && $focus->type != 'draft') {
|
||||
if($current_user->getPreference('signature_prepend')) {
|
||||
$description_html = '<br />'.from_html($sig['signature_html']).'<br /><br />'.$description_html;
|
||||
$description = "\n".$sig['signature']."\n\n".$description;
|
||||
} else {
|
||||
$description_html .= '<br /><br />'.from_html($sig['signature_html']);
|
||||
$description = $description."\n\n".$sig['signature'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$xtpl->assign('DESCRIPTION', $description);
|
||||
// sigs
|
||||
/////////////////////////////////////////////////
|
||||
$tiny = new SugarTinyMCE();
|
||||
$ed = $tiny->getInstance("description_html");
|
||||
$xtpl->assign("TINY", $ed);
|
||||
$xtpl->assign("DESCRIPTION_HTML", $description_html);
|
||||
|
||||
if((!isset($_REQUEST['record']) || $_REQUEST['record'] == '') && isset($toTemplateId) && $toTemplateId != "") {
|
||||
require_once('modules/EmailTemplates/EmailTemplate.php');
|
||||
$et = new EmailTemplate();
|
||||
$et->retrieve($toTemplateId);
|
||||
if(isset($et->id) && $et->id != '') {
|
||||
$xtpl->assign("NAME",$et->subject);
|
||||
$xtpl->assign("DESCRIPTION",$et->body);
|
||||
$xtpl->assign("DESCRIPTION_HTML",$et->body_html);
|
||||
}
|
||||
}
|
||||
|
||||
$xtpl->parse('main.htmlarea');
|
||||
//// END TEXT EDITOR
|
||||
///////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////
|
||||
//// SPECIAL INBOUND LANDING SCREEN ASSIGNS
|
||||
if(!empty($_REQUEST['inbound_email_id'])) {
|
||||
if(!empty($_REQUEST['start'])) {
|
||||
$parts = $focus->getStartPage(base64_decode($_REQUEST['start']));
|
||||
$xtpl->assign('RETURN_ACTION', $parts['action']);
|
||||
$xtpl->assign('RETURN_MODULE', $parts['module']);
|
||||
$xtpl->assign('GROUP', $parts['group']);
|
||||
}
|
||||
$xtpl->assign('ASSIGNED_USER_ID', $current_user->id);
|
||||
$xtpl->assign('MYINBOX', 'this.form.type.value=\'inbound\';');
|
||||
}
|
||||
//// END SPECIAL INBOUND LANDING SCREEN ASSIGNS
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo '<script>var disabledModules='. $json->encode($disabled_parent_types) . ';</script>';
|
||||
$jsVars = 'var lbl_send_anyways = "'.$mod_strings['LBL_SEND_ANYWAYS'].'";';
|
||||
$xtpl->assign('JS_VARS', $jsVars);
|
||||
$xtpl->parse("main");
|
||||
$xtpl->out("main");
|
||||
echo '<script>checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);</script>';
|
||||
//// END XTEMPLATE ASSIGNMENT
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('include/javascript/javascript.php');
|
||||
$javascript = new javascript();
|
||||
$javascript->setFormName('email_EditView');
|
||||
$javascript->setSugarBean($focus);
|
||||
$skip_fields = array();
|
||||
if($email_type == 'out') {
|
||||
$skip_fields['name'] = 1;
|
||||
$skip_fields['date_start'] = 1;
|
||||
}
|
||||
$javascript->addAllFields('',$skip_fields);
|
||||
$javascript->addToValidateBinaryDependency('parent_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
|
||||
$javascript->addToValidateBinaryDependency('parent_type', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
|
||||
|
||||
|
||||
|
||||
|
||||
$javascript->addToValidateBinaryDependency('user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id');
|
||||
if($email_type == 'archived') {
|
||||
$javascript->addFieldIsValidDate('date_start', 'date', $mod_strings['LBL_DATE'], $mod_strings['ERR_DATE_START'], true);
|
||||
$javascript->addFieldIsValidTime('time_start', 'time', $mod_strings['LBL_TIME'], $mod_strings['ERR_TIME_START'], true);
|
||||
}
|
||||
echo $javascript->getScript();
|
||||
111
import/EcmPriceBooks/Forms.php
Normal file
111
import/EcmPriceBooks/Forms.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* CREATE JAVASCRIPT TO VALIDATE THE DATA ENTERED INTO A RECORD.
|
||||
*******************************************************************************/
|
||||
function get_validate_record_js () {
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* CREATE FORM FOR MENU RAPID CREATE
|
||||
*******************************************************************************/
|
||||
function get_new_record_form () {
|
||||
if(!ACLController::checkAccess('EcmPriceBooks', 'edit', true)){
|
||||
return '';
|
||||
}
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $app_list_strings;
|
||||
global $mod_strings;
|
||||
global $theme;
|
||||
global $current_user;
|
||||
|
||||
$lbl_subject = $mod_strings['LBL_SUBJECT'];
|
||||
$lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
|
||||
$lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
|
||||
$lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
|
||||
$lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
|
||||
$user_id = $current_user->id;
|
||||
|
||||
|
||||
$the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
|
||||
$the_form .= <<<EOQ
|
||||
|
||||
<form name="EcmPriceBookSave" onSubmit="return check_form('EcmPriceBooksSave')" method="POST" action="index.php">
|
||||
<input type="hidden" name="module" value="EcmPriceBooks">
|
||||
<input type="hidden" name="record" value="">
|
||||
<input type="hidden" name="assigned_user_id" value='${user_id}'>
|
||||
<input type="hidden" name="action" value="Save">
|
||||
|
||||
${lbl_subject} <span class="required">${lbl_required_symbol}</span><br>
|
||||
<p><input name='name' type="text" size='20' maxlength="255"value=""><br>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input title="${lbl_save_button_title}" accessKey="${lbl_save_button_key}" class="button" type="submit" name="button" value=" ${lbl_save_button_label} " >
|
||||
</p>
|
||||
|
||||
</form>
|
||||
EOQ;
|
||||
require_once('include/javascript/javascript.php');
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
$javascript = new javascript();
|
||||
$javascript->setFormName('EcmPriceBooksSave}');
|
||||
$javascript->setSugarBean(new EcmPriceBook());
|
||||
$javascript->addRequiredFields('');
|
||||
$the_form .= $javascript->getScript();
|
||||
$the_form .= get_left_form_footer();
|
||||
|
||||
return $the_form;
|
||||
}
|
||||
|
||||
?>
|
||||
148
import/EcmPriceBooks/ListHelper.php
Normal file
148
import/EcmPriceBooks/ListHelper.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?
|
||||
function dy($text) {
|
||||
$text=str_replace("ą","1",$text);
|
||||
$text=str_replace("ć","a",$text);
|
||||
$text=str_replace("ę","e",$text);
|
||||
$text=str_replace("A<EFBFBD>","3",$text);
|
||||
$text=str_replace("A<EFBFBD>","n",$text);
|
||||
$text=str_replace("A3","<EFBFBD>",$text);
|
||||
$text=str_replace("A<EFBFBD>","o",$text);
|
||||
$text=str_replace("A1","?",$text);
|
||||
$text=str_replace("Ao","Y",$text);
|
||||
$text=str_replace("Ą","Y",$text);
|
||||
$text=str_replace("Ć","A",$text);
|
||||
$text=str_replace("<EFBFBD>~","E",$text);
|
||||
$text=str_replace("A<EFBFBD>","L",$text);
|
||||
$text=str_replace("Af","N",$text);
|
||||
$text=str_replace("A<EFBFBD>","<EFBFBD>",$text);
|
||||
$text=str_replace("A<EFBFBD>","O",$text);
|
||||
$text=str_replace("A<EFBFBD>","<EFBFBD>",$text);
|
||||
$text=str_replace("A1","?",$text);
|
||||
return plc($text);
|
||||
}
|
||||
function plc($string, $type = UTF8_TO_WIN1250)
|
||||
{
|
||||
$win2utf = array(
|
||||
"\xb9" => "\xc4\x85", "\xa5" => "\xc4\x84",
|
||||
"\xe6" => "\xc4\x87", "\xc6" => "\xc4\x86",
|
||||
"\xea" => "\xc4\x99", "\xca" => "\xc4\x98",
|
||||
"\xb3" => "\xc5\x82", "\xa3" => "\xc5\x81",
|
||||
"\xf3" => "\xc3\xb3", "\xd3" => "\xc3\x93",
|
||||
"\x9c" => "\xc5\x9b", "\x8c" => "\xc5\x9a",
|
||||
"\xbf" => "\xc5\xbc", "\x8f" => "\xc5\xbb",
|
||||
"\x9f" => "\xc5\xba", "\xaf" => "\xc5\xb9",
|
||||
"\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83"
|
||||
);
|
||||
$iso2utf = array(
|
||||
"\xb1" => "\xc4\x85", "\xa1" => "\xc4\x84",
|
||||
"\xe6" => "\xc4\x87", "\xc6" => "\xc4\x86",
|
||||
"\xea" => "\xc4\x99", "\xca" => "\xc4\x98",
|
||||
"\xb3" => "\xc5\x82", "\xa3" => "\xc5\x81",
|
||||
"\xf3" => "\xc3\xb3", "\xd3" => "\xc3\x93",
|
||||
"\xb6" => "\xc5\x9b", "\xa6" => "\xc5\x9a",
|
||||
"\xbc" => "\xc5\xba", "\xac" => "\xc5\xb9",
|
||||
"\xbf" => "\xc5\xbc", "\xaf" => "\xc5\xbb",
|
||||
"\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83"
|
||||
);
|
||||
|
||||
if ($type == ISO88592_TO_UTF8)
|
||||
return strtr($string, $iso2utf);
|
||||
if ($type == UTF8_TO_ISO88592)
|
||||
return strtr($string, array_flip($iso2utf));
|
||||
if ($type == WIN1250_TO_UTF8)
|
||||
return strtr($string, $win2utf);
|
||||
if ($type == UTF8_TO_WIN1250)
|
||||
return strtr($string, array_flip($win2utf));
|
||||
if ($type == ISO88592_TO_WIN1250)
|
||||
return strtr($string, "\xa1\xa6\xac\xb1\xb6\xbc",
|
||||
"\xa5\x8c\x8f\xb9\x9c\x9f");
|
||||
if ($type == WIN1250_TO_ISO88592)
|
||||
return strtr($string, "\xa5\x8c\x8f\xb9\x9c\x9f",
|
||||
"\xa1\xa6\xac\xb1\xb6\xbc");
|
||||
}
|
||||
function imgType($name){
|
||||
if(substr($name, -4, 4) == '.jpg' || substr($name, -4, 4) == 'jpeg')return "IMAGETYPE_JPEG";
|
||||
elseif(substr($name, -4, 4) == '.gif')return "IMAGETYPE_GIF";
|
||||
elseif(substr($name, -4, 4) == '.png') return "IMAGETYPE_PNG";
|
||||
}
|
||||
|
||||
function resizeImage($source, $max_x, $max_y, $save_image, $jpeg_quality = 100){
|
||||
if(imgType($source) == "IMAGETYPE_JPEG")$img_src = imagecreatefromjpeg($source);
|
||||
elseif(imgType($source) == "IMAGETYPE_GIF")$img_src = imagecreatefromgif($source);
|
||||
elseif(imgType($source) == "IMAGETYPE_PNG")$img_src = imagecreatefrompng($source);
|
||||
else die('Wrong filetype! Accepted images: JPG/JPEG, GIF, PNG');
|
||||
|
||||
$image_x = imagesx($img_src);
|
||||
$image_y = imagesy($img_src);
|
||||
if($image_x > $image_y){
|
||||
$ratio_x = ($image_x > $max_x) ? $max_x/$image_x : 1;
|
||||
$ratio_y = $ratio_x;
|
||||
$move = 'y';
|
||||
}
|
||||
else{
|
||||
$ratio_y = ($image_y > $max_y) ? $max_y/$image_y : 1;
|
||||
$ratio_x = $ratio_y;
|
||||
$move = 'x';
|
||||
}
|
||||
$new_x = $image_x*$ratio_x;
|
||||
$new_y = $image_y*$ratio_y;
|
||||
|
||||
$move_x = ($move == "x") ? ($max_x-$new_x)/2 : 0;
|
||||
$move_y = ($move == "y") ? ($max_y-$new_y)/2 : 0;
|
||||
|
||||
$new_img = imagecreatetruecolor($max_x, $max_y);
|
||||
$background = imagecolorallocate($new_img, 255, 255, 255);
|
||||
$black = imagecolorallocate($new_img,0,0,0);
|
||||
imagefill($new_img, 0, 0, $background);
|
||||
imagecopyresampled($new_img, $img_src, $move_x, $move_y, 0, 0, $new_x, $new_y, $image_x, $image_y);
|
||||
|
||||
$ix=ceil($max_x/90);
|
||||
$iy=ceil($max_y/90);
|
||||
for($i=0;$i<$ix;$i++)imageline($new_img,$i,0,$i,$max_y,$background);
|
||||
for($i=0;$i<$iy;$i++)imageline($new_img,0,$i,$max_x,$i,$background);
|
||||
for($i=0;$i<$ix;$i++)imageline($new_img,$max_x-$i,0,$max_x-$i,$max_y,$background);
|
||||
for($i=0;$i<$iy;$i++)imageline($new_img,0,$max_y-$i,$max_x,$max_y-$i,$background);
|
||||
|
||||
if(imgType($save_image) == "IMAGETYPE_JPEG")imagejpeg($new_img, $save_image,100);
|
||||
elseif(imgType($save_image) == "IMAGETYPE_GIF")imagegif($new_img, $save_image,100);
|
||||
elseif(imgType($save_image) == "IMAGETYPE_PNG") imagepng($new_img, $save_image,100);
|
||||
}
|
||||
function addExchangeRateValue($value,$field,$er,$n=false)
|
||||
{
|
||||
$tabs=array("fob_price","purchase_price","ems_price","srp_price","srp_promo_price","price","list_price");
|
||||
foreach($tabs as $tab)
|
||||
{
|
||||
if($tab==$field)
|
||||
{
|
||||
if(!$n)$value=number_format($value/$er,2,",",".");
|
||||
else $value=$value/$er;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function sortLink($order_by,$sorder,$title)
|
||||
{
|
||||
if($order_by==$_REQUEST['order_by'])
|
||||
{
|
||||
if($sorder=="desc")
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow_down.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s="asc";
|
||||
}
|
||||
else
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow_up.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s="desc";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$img='<img border="0" src="themes/Sugar/images/arrow.gif" width="8" height="10" align="absmiddle" alt="">';
|
||||
$s=$sorder;
|
||||
}
|
||||
|
||||
return '<a style="cursor:pointer;" onclick="mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=ListViewProductsAjax&customview_id='.$_GET['customview_id'].'&pricebook_id='.$_REQUEST['pricebook_id'].'&order_by='.$order_by.'&sorder='.$s.'\',\'products\');">'.$title.' '.$img.'</a>';
|
||||
}
|
||||
?>
|
||||
51
import/EcmPriceBooks/ListView.php
Normal file
51
import/EcmPriceBooks/ListView.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('modules/EcmPriceBooks/Forms.php');
|
||||
require_once ('include/time.php');
|
||||
require_once('include/json_config.php');
|
||||
|
||||
$json_config = new json_config();
|
||||
|
||||
$focus = new EcmPriceBook();
|
||||
|
||||
if(isset($_REQUEST['record'])) {
|
||||
$focus->retrieve($_REQUEST['record']);
|
||||
}
|
||||
else {}
|
||||
|
||||
require_once('include/MVC/View/SugarView.php');
|
||||
|
||||
if(file_exists('modules/EcmPriceBooks/views/view.list.php')) {
|
||||
require_once('modules/EcmPriceBooks/views/view.list.php');
|
||||
$list = new EcmPriceBooksViewList();
|
||||
}
|
||||
else {
|
||||
require_once('include/MVC/View/views/view.list.php');
|
||||
$list = new ViewList();
|
||||
}
|
||||
|
||||
$list->bean = $focus;
|
||||
|
||||
// if(!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != "true") require_once('modules/EcmGroupSales/HeaderMenu.php');
|
||||
|
||||
|
||||
//$_REQUEST['query']="true";
|
||||
//$_REQUEST['clear_query']="true";
|
||||
if(!$_REQUEST['query'] && !$_REQUEST['clear_query']){
|
||||
$_REQUEST['archived_basic']="0";
|
||||
$_REQUEST['archived']="0";
|
||||
}
|
||||
elseif($_REQUEST['query'] && $_REQUEST['clear_query']){
|
||||
$_REQUEST['archived_basic']="0";
|
||||
$_REQUEST['archived']="0";
|
||||
}
|
||||
//print_r($_REQUEST);
|
||||
$list->preDisplay();
|
||||
$list->display();
|
||||
|
||||
?>
|
||||
196
import/EcmPriceBooks/ListViewAdd.php
Normal file
196
import/EcmPriceBooks/ListViewAdd.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
require_once ('XTemplate/xtpl.php');
|
||||
require_once ("data/Tracker.php");
|
||||
require_once ('modules/EcmProducts/EcmProduct.php');
|
||||
require_once ('themes/'.$theme.'/layout_utils.php');
|
||||
require_once ('log4php/LoggerManager.php');
|
||||
require_once('include/ListView/ListViewSmarty.php');
|
||||
require_once('include/ListView/ListView.php');
|
||||
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
|
||||
if(file_exists('custom/modules/EcmProducts/metadata/listviewdefs.php')){
|
||||
require_once('custom/modules/EcmProducts/metadata/listviewdefs.php');
|
||||
}else{
|
||||
require_once('modules/EcmProducts/metadata/listviewdefs.php');
|
||||
}
|
||||
require_once('modules/SavedSearch/SavedSearch.php');
|
||||
require_once('include/SearchForm/SearchForm.php');
|
||||
|
||||
$header_text = '';
|
||||
|
||||
global $app_strings;
|
||||
global $mod_strings;
|
||||
global $app_list_strings;
|
||||
global $current_language;
|
||||
$current_module_strings = return_module_language($current_language, 'EcmProducts');
|
||||
|
||||
global $urlPrefix;
|
||||
global $currentModule;
|
||||
|
||||
global $theme;
|
||||
global $current_user;
|
||||
// FOCUS_LIST IS THE MEANS OF PASSING DATA TO A LISTVIEW.
|
||||
global $focus_list;
|
||||
|
||||
// SETUP QUICKSEARCH
|
||||
require_once('include/QuickSearchDefaults.php');
|
||||
$qsd = new QuickSearchDefaults();
|
||||
|
||||
// CLEAR THE DISPLAY COLUMNS BACK TO DEFAULT WHEN CLEAR QUERY IS CALLED
|
||||
if(!empty($_REQUEST['clear_query']) && $_REQUEST['clear_query'] == 'true')
|
||||
$current_user->setPreference('ListViewDisplayColumns', array(), 0, $currentModule);
|
||||
|
||||
$savedDisplayColumns = $current_user->getPreference('ListViewDisplayColumns', $currentModule); // GET USER DEFINED DISPLAY COLUMNS
|
||||
|
||||
$json = getJSONobj();
|
||||
|
||||
$seedEcmProduct = new EcmProduct(); // SEED BEAN
|
||||
$searchForm = new SearchForm('EcmProducts', $seedEcmProduct); // NEW SEARCHFORM INSTANCE
|
||||
// SETUP LISTVIEW SMARTY
|
||||
$lv = new ListViewSmarty();
|
||||
|
||||
$displayColumns = array();
|
||||
// CHECK $_REQUEST IF NEW DISPLAY COLUMNS FROM POST
|
||||
if (!empty($_REQUEST['displayColumns'])) {
|
||||
foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) {
|
||||
if (!empty($listViewDefs['EcmProducts'][$col]))
|
||||
$displayColumns[$col] = $listViewDefs['EcmProducts'][$col];
|
||||
}
|
||||
}elseif(!empty($savedDisplayColumns)) { // USE USER DEFINED DISPLAY COLUMNS FROM PREFERENCES
|
||||
$displayColumns = $savedDisplayColumns;
|
||||
}else { // USE COLUMNS DEFINED IN LISTVIEWDEFS FOR DEFAULT DISPLAY COLUMNS
|
||||
foreach($listViewDefs['EcmProducts'] as $col => $params) {
|
||||
if(!empty($params['default']) && $params['default'])
|
||||
$displayColumns[$col] = $params;
|
||||
}
|
||||
}
|
||||
$params = array('massupdate' => true); // SETUP LISTVIEWSMARTY PARAMS
|
||||
if(!empty($_REQUEST['orderBy'])) { // ORDER BY COMING FROM $_REQUEST
|
||||
$params['orderBy'] = $_REQUEST['orderBy'];
|
||||
$params['overrideOrder'] = true;
|
||||
if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
|
||||
}
|
||||
$lv->displayColumns = $displayColumns;
|
||||
if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) { // HANDLE AJAX REQUESTS FOR SEARCH FORMS ONLY
|
||||
switch($_REQUEST['search_form_view']) {
|
||||
case 'basic_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayBasic(false);
|
||||
break;
|
||||
case 'advanced_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayAdvanced(false);
|
||||
break;
|
||||
case 'saved_views':
|
||||
echo $searchForm->displaySavedViews($listViewDefs, $lv, false);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// USE THE STORED QUERY IF THERE IS ONE
|
||||
if (!isset($where)) $where = "";
|
||||
require_once('modules/MySettings/StoreQuery.php');
|
||||
$storeQuery = new StoreQuery();
|
||||
|
||||
if(!isset($_REQUEST['query'])){
|
||||
$storeQuery->loadQuery($currentModule);
|
||||
$storeQuery->populateRequest();
|
||||
}else{
|
||||
$storeQuery->saveFromGet($currentModule);
|
||||
}
|
||||
if(isset($_REQUEST['query'])){
|
||||
// WE HAVE A QUERY
|
||||
// FIRST SAVE COLUMNS
|
||||
$current_user->setPreference('ListViewDisplayColumns', $displayColumns, 0, $currentModule);
|
||||
$searchForm->populateFromRequest(); // GATHERS SEARCH FIELD INPUTS FROM $_REQUEST
|
||||
$where_clauses = $searchForm->generateSearchWhere(true, "EcmProduct"); // BUILDS THE WHERE CLAUSE FROM SEARCH FIELD INPUTS
|
||||
if (count($where_clauses) > 0 )$where = implode(' and ', $where_clauses);
|
||||
$GLOBALS['log']->info("Here is the where clause for the list view: $where");
|
||||
}
|
||||
|
||||
// START DISPLAY
|
||||
// WHICH TAB OF SEARCH FORM TO DISPLAY
|
||||
if(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
|
||||
$searchForm->setup();
|
||||
if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
|
||||
$searchForm->displayAdvanced();
|
||||
}elseif(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'saved_views'){
|
||||
$searchForm->displaySavedViews($listViewDefs, $lv);
|
||||
}else {
|
||||
$searchForm->displayBasic();
|
||||
}
|
||||
}
|
||||
echo $qsd->GetQSScripts();
|
||||
/*
|
||||
$lv->setup($seedEcmProduct, 'include/ListView/ListViewGeneric.tpl', $where, $params);
|
||||
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
|
||||
echo get_form_header($current_module_strings['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
|
||||
echo $lv->display();
|
||||
*/
|
||||
$ListView = new ListView();
|
||||
$ListView->initNewXTemplate('modules/EcmProducts/ListView1.html',$current_module_strings);
|
||||
$ListView->setHeaderTitle($current_module_strings['LBL_LIST_FORM_TITLE']);
|
||||
$ListView->setQuery($where, "", "name asc", "ECMPRODUCT");
|
||||
$ListView->processListView($seedEcmProduct, "main", "ECMPRODUCT");
|
||||
$savedSearch = new SavedSearch();
|
||||
$json = getJSONobj();
|
||||
// FILLS IN SAVED VIEWS SELECT BOX ON SHORTCUT MENU
|
||||
$savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '<br>' . $savedSearch->getSelect('EcmProducts')));
|
||||
$str = "<script>
|
||||
YAHOO.util.Event.addListener(window, 'load', SUGAR.util.fillShortcuts, $savedSearchSelects);
|
||||
</script>";
|
||||
echo '<input type="hidden" name="pricebook_id" value="'.$_REQUEST['pricebook_id'].'">';
|
||||
echo '</form>';
|
||||
echo $str;
|
||||
?>
|
||||
54
import/EcmPriceBooks/ListViewAddToPriceBook.php
Normal file
54
import/EcmPriceBooks/ListViewAddToPriceBook.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($mod_strings['LBL_MODULE_ID'], $mod_strings['LBL_MODULE_TITLE'], true);
|
||||
echo "\n</p>\n";
|
||||
?>
|
||||
<script language="javascript" src="modules/EcmProducts/helper.js"></script>
|
||||
<ul class="tablist">
|
||||
<li class="active"><a class="current" href="#">Basic Search</a></li>
|
||||
</ul>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td valign="top" noWrap class="dataLabel"> </td>
|
||||
<td valign="top" class="dataField"> </td>
|
||||
<td valign="top" class="dataLabel"> </td>
|
||||
<td valign="top" class="dataField"> </td>
|
||||
<td valign="top" class="dataLabel"> </td>
|
||||
<td valign="top" class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="10%" valign="top" noWrap class="dataLabel">
|
||||
<span sugar='slot1'><? print $mod_strings['LBL_NAME'];?></span sugar='slot'></td>
|
||||
<td width="20%" valign="top" class="dataField">
|
||||
<span sugar='slot1b'>
|
||||
<input type=text name="name" id="name" class=dataField value="" />
|
||||
</span sugar='slot'> </td>
|
||||
<td width="10%" valign="top" class="dataLabel"><span sugar='slot2'><? print $mod_strings['LBL_INDEX'];?></span sugar='slot'></td>
|
||||
<td width="20%" valign="top" class="dataField"><input name='code' id='code' type="text" tabindex='2' title="Code" value="" maxlength='40' /></td>
|
||||
<td width="15%" valign="top" class="dataLabel"><? print $mod_strings['LBL_UNIT_PRICE'];?> </td>
|
||||
<td width="15%" valign="top" class="dataField"><input name='unit_price' id='unit_price' type="text" tabindex='2' value="" maxlength='40' /></td>
|
||||
</tr>
|
||||
<tr><td width="10%" valign="top" class="dataLabel"><? print $mod_strings['LBL_MANUFACTURER'];?></td>
|
||||
<td width="20%" valign="top" class="dataField"><select style="width:121px;" name="manufacturer" id="manufacturer"><option value=""><? print $mod_strings['LBL_ALL'];?></option><?
|
||||
$w=$GLOBALS['db']->query("select name,id from ecmproductmanufacturers order by name asc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w))
|
||||
{
|
||||
print '<option value="'.$r['id'].'">'.$r['name'].'</option>';
|
||||
}
|
||||
?></select></td>
|
||||
<td width="20%" valign="top" class="dataLabel"><? print $mod_strings['LBL_PRODUCT_CATEGORY'];?></td>
|
||||
<td width="20%" valign="top" class="dataField"><select style="width:121px;" name="product_category" id="product_category"><option value=""><? print $mod_strings['LBL_ALL'];?></option><?
|
||||
$w=$GLOBALS['db']->query("select name,id from ecmproductcategories order by name asc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w))
|
||||
{
|
||||
print '<option value="'.$r['id'].'">'.$r['name'].'</option>';
|
||||
}
|
||||
?></select></td>
|
||||
<td width="10%" valign="top" class="dataLabel"><input class="button" name="search" type="button" id="search" value="Search" onclick="mintajaxget('index.php?to_pdf=1&pricebook_id=<?print $_REQUEST['pricebook_id'];?>&module=EcmPriceBooks&action=ListViewAddToPriceBookAjax&name='+document.getElementById('name').value+'&unit_price='+document.getElementById('unit_price').value+'&code='+document.getElementById('code').value+'&product_category='+document.getElementById('product_category').value+'&manufacturer='+document.getElementById('manufacturer').value,'list');"></td>
|
||||
<td width="20%" valign="top" class="dataField"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
</table>
|
||||
|
||||
<div id="list"></div>
|
||||
<script language="javascript">mintajaxget('index.php?to_pdf=1&pricebook_id=<?print $_REQUEST['pricebook_id'];?>&module=EcmPriceBooks&action=ListViewAddToPriceBookAjax','list');</script>
|
||||
86
import/EcmPriceBooks/ListViewAddToPriceBookAjax.php
Normal file
86
import/EcmPriceBooks/ListViewAddToPriceBookAjax.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
$_COOKIE['pricebook_id']=$_REQUEST['pricebook_id'];
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,id from ecmpricebooks where id='".$_REQUEST['pricebook_id']."'"));
|
||||
$pricebook_name=$r['name'];
|
||||
$pricebook_id=$r['id'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
$t=array(" ",$mod_strings['LBL_PRODUCT_NAME'],$mod_strings['LBL_INDEX'],$mod_strings['LBL_PRICEBOOK_NAME'], $mod_strings['LBL_UNIT_PRICE'],$mod_strings['LBL_MARGIN'],$mod_strings['LBL_LIST_PRICE_ADD']);
|
||||
|
||||
$sorder=$_REQUEST['sorder'];
|
||||
print '<script language="javascript" src="modules/EcmProducts/helper.js"></script>';
|
||||
|
||||
print '<form name="AddToPriceBook" method="post" action="index.php">';
|
||||
print '<input type="hidden" name="to_pdf" value="1">';
|
||||
print '<input type="hidden" name="module" value="EcmPriceBooks">';
|
||||
print '<input type="hidden" name="action" value="AddToPriceBook">';
|
||||
print '<input type="hidden" name="pricebook_id" value="'.$_REQUEST['pricebook_id'].'">';
|
||||
print '<input class="button" type="submit" value="Update"><br><br>';
|
||||
print '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="ListView"><tr>';
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
print '<td class="listViewThS1">'.$t[$i].'</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
if($_REQUEST['name'])$arr[]="ecmproducts.name like '%".$_REQUEST['name']."%'";
|
||||
if($_REQUEST['code'])$arr[]="ecmproducts.code like '%".$_REQUEST['code']."%'";
|
||||
if($_REQUEST['purchase_price'])$arr[]="ecmproducts.purchase_price='".$_REQUEST['purchase_price']."'";
|
||||
if($_REQUEST['product_category'])$arr[]="ecmproducts.product_category_id='".$_REQUEST['product_category']."'";
|
||||
if($_REQUEST['manufacturer'])$arr[]="ecmproducts.manufacturer_id='".$_REQUEST['manufacturer']."'";
|
||||
$arr[]="ecmproducts.deleted='0'";
|
||||
|
||||
$w=$GLOBALS['db']->query("select ecmproduct_id from ecmpricebooks_ecmproducts where deleted='0' and ecmpricebook_id='".$_REQUEST['pricebook_id']."'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w))$arr[]="ecmproducts.id!='".$r['ecmproduct_id']."'";
|
||||
|
||||
$where=implode(" and ",$arr);
|
||||
$z="select ecmproducts.name as name,ecmproducts.code as code,ecmproducts.id as id,ecmproducts.purchase_price as purchase_price from ecmproducts where ".$where." order by ecmproducts.name";
|
||||
//print $z;
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
|
||||
|
||||
print mysql_error();
|
||||
$i=0;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
print '<tr>';
|
||||
print '<input type="hidden" name="product_id['.$i.']" value="'.$row['id'].'">';
|
||||
|
||||
print '<td class="oddListRowS1" width="1%"><input onclick="getPrice(\''.$row['id'].'\',\'up\');ShowHideBlock(\'price_block2_'.$row['id'].'\');ShowHideBlock(\'price_block3_'.$row['id'].'\');" type="checkbox" name="check['.$i.']" value="'.$row['id'].'"></td>';
|
||||
|
||||
print '<td class="oddListRowS1"><a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['name'].'</a></td>';
|
||||
print '<td class="oddListRowS1">'.$row['code'].'</td>';
|
||||
print '<td class="oddListRowS1"><a href="index.php?module=EcmPriceBooks&action=DetailView&record='.$pricebook_id.'">'.$pricebook_name.'</a></td>';
|
||||
print '<td class="oddListRowS1">'.number_format($row['purchase_price'],2,",",".").'</td>';
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$row['id']."'"));
|
||||
|
||||
//print '<td class="oddListRowS1">'.number_format($r['price'],2,",",".").'</td>';
|
||||
|
||||
print '
|
||||
<div id="price_block1_'.$row['id'].'" style="display:none;">
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'down\');" onclick="getPrice(\''.$row['id'].'\',\'up\');" name="purchase_price_'.$row['id'].'" type="hidden" id="purchase_price_'.$row['id'].'" value="'.$row['purchase_price'].'" size="5" />
|
||||
</div>
|
||||
';
|
||||
print '<td>
|
||||
<div id="price_block2_'.$row['id'].'" style="display:none;">
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'down\');" onclick="getPrice(\''.$row['id'].'\',\'up\');" name="margin_rate_'.$row['id'].'" type="text" id="margin_rate_'.$row['id'].'" value="20" size="2" />
|
||||
</td>
|
||||
<td>
|
||||
<div id="price_block3_'.$row['id'].'" style="display:none;">
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'down\');" onclick="getPrice(\''.$row['id'].'\',\'up\');" name="list_price_'.$row['id'].'" type="text" id="list_price_'.$row['id'].'" value="" size="6" />
|
||||
<script>getPrice(\''.$row['id'].'\',\'up\');</script>
|
||||
</div>
|
||||
</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '<br><input class="button" type="submit" value="'.$mod_strings['LBL_UPDATE'].'">';
|
||||
print '</form>';
|
||||
|
||||
?>
|
||||
73
import/EcmPriceBooks/ListViewPriceBooksAddToChangeOn.php
Normal file
73
import/EcmPriceBooks/ListViewPriceBooksAddToChangeOn.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($mod_strings['LBL_MODULE_ID'], $mod_strings['LBL_MODULE_TITLE'], true);
|
||||
echo "\n</p>\n";
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select id,name,purchase_price from ecmproducts where id='".$_REQUEST['product_id']."'"));
|
||||
$product_name=$r['name'];
|
||||
$product_id=$r['id'];
|
||||
$purchase_price=$r['purchase_price'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmproductexchangerates where id='".$exchange_rate_id."'"));
|
||||
$er_value=$r['value'];
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_REQUEST['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$t=array(" ",$mod_strings['LBL_PRODUCT_NAME'],$mod_strings['LBL_PRICEBOOK_NAME'],$mod_strings['LBL_PURCHASE_PRICE'],$mod_strings['LBL_LIST_PRICE'], " ");
|
||||
|
||||
$sorder=$_REQUEST['sorder'];
|
||||
print '<script language="javascript" src="modules/EcmProducts/helper.js"></script>';
|
||||
print '<form name="UpdatePriceBook" method="post" action="index.php">';
|
||||
print '<input type="hidden" name="to_pdf" value="1">';
|
||||
print '<input type="hidden" name="module" value="EcmPriceBooks">';
|
||||
print '<input type="hidden" name="action" value="UpdatePriceBook">';
|
||||
print '<input type="hidden" name="product_id" value="'.$_REQUEST['product_id'].'">';
|
||||
print '<input type="hidden" name="return_id" value="'.$_REQUEST['return_id'].'">';
|
||||
print '<input type="hidden" name="return_module" value="'.$_REQUEST['return_module'].'">';
|
||||
print '<input type="hidden" name="return_action" value="'.$_REQUEST['return_action'].'">';
|
||||
print '<input class="button" type="submit" value="'.$mod_strings['LBL_UPDATE'].'"><br><br>';
|
||||
print '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="ListView"><tr>';
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
print '<td class="listViewThS1">'.$t[$i].'</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$result = $GLOBALS['db']->query("select name,id from ecmpricebooks where deleted='0'");
|
||||
|
||||
$i=0;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
print '<tr>';
|
||||
print '<input type="hidden" name="pricebook_id['.$i.']" value="'.$row['id'].'">';
|
||||
|
||||
print '<td class="oddListRowS1" width="1%"><input onclick="ShowHideBlock(\'price_block_'.$row['id'].'\');" type="checkbox" name="check['.$i.']" value="'.$row['id'].'"></td>';
|
||||
|
||||
print '<td class="oddListRowS1"><a href="index.php?module=EcmProducts&action=DetailView&record='.$product_id.'">'.$product_name.'</a></td>';
|
||||
print '<td class="oddListRowS1"><a href="index.php?module=EcmPriceBooks&action=DetailView&record='.$row['id'].'">'.$row['name'].'</a></td>';
|
||||
print '<td class="oddListRowS1">'.number_format($purchase_price,2,",",".").'</td>';
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price from ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['product_id']."' and ecmpricebook_id='".$row['id']."'"));
|
||||
$price=$r['price'];
|
||||
|
||||
print '<td class="oddListRowS1">'.number_format($price,2,",",".").'</td>';
|
||||
print '<td>
|
||||
<div id="price_block_'.$row['id'].'" style="display:none;">
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'up\');" onclick="getPrice(\''.$row['id'].'\',\'down\');" name="purchase_price_'.$row['id'].'" type="text" id="purchase_price_'.$row['id'].'" value="'.$purchase_price.'" size="5" />
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'up\');" onclick="getPrice(\''.$row['id'].'\',\'down\');" name="margin_rate_'.$row['id'].'" type="text" id="margin_rate_'.$row['id'].'" value="20" size="2" />
|
||||
<input onchange="getPrice(\''.$row['id'].'\',\'up\');" onclick="getPrice(\''.$row['id'].'\',\'down\');" name="list_price_'.$row['id'].'" type="text" id="list_price_'.$row['id'].'" value="" size="6" />
|
||||
<script>getPrice(\''.$row['id'].'\',\'up\');</script></div></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '<br><input class="button" type="submit" value="'.$mod_strings['LBL_UPDATE'].'">';
|
||||
print '</form>';
|
||||
|
||||
?>
|
||||
438
import/EcmPriceBooks/ListViewProductsAjax.php
Normal file
438
import/EcmPriceBooks/ListViewProductsAjax.php
Normal file
@@ -0,0 +1,438 @@
|
||||
<?
|
||||
set_time_limit(50);
|
||||
require_once("modules/EcmPriceBooks/ListHelper.php");
|
||||
//$GLOBALS['db']->query("SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricebooks_customview where id='".$_GET['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
$o=explode("||",$row['orders']);
|
||||
|
||||
if($_COOKIE['customview_id']!=$_GET['customview_id'] || $_SESSION['customview_id']=="" || !$_GET['order_by'])
|
||||
{
|
||||
$pbo=array();
|
||||
for($i=0;$i<=8;$i++)
|
||||
{
|
||||
if($o[$i])
|
||||
{
|
||||
$exp=explode(" ",$o[$i]);
|
||||
$adesc=$exp[1];
|
||||
$ord=$exp[0];
|
||||
if($ord=="list_price")$pbo[]="ecmpricebooks_ecmproducts.price ".$adesc;
|
||||
else $pbo[]="ecmproducts.".$ord." ".$adesc;
|
||||
}
|
||||
}
|
||||
$_SESSION['pricebook_order']=implode(",",$pbo);
|
||||
}
|
||||
setcookie('customview_id',$_GET['customview_id'],time()+60*24*60*3600);
|
||||
|
||||
$order=$_SESSION['pricebook_order'];
|
||||
$order=str_replace("ecmproducts.margin_rate","margin_rate",$order);
|
||||
if($_REQUEST['order_by']){
|
||||
$order=str_replace($_REQUEST['order_by']." desc",$_REQUEST['order_by']." ".$_REQUEST['sorder'],$order);
|
||||
$order=str_replace($_REQUEST['order_by']." asc",$_REQUEST['order_by']." ".$_REQUEST['sorder'],$order);
|
||||
}
|
||||
|
||||
$_SESSION['pricebook_order']=$order;
|
||||
|
||||
if($_REQUEST['order_by'] && $_REQUEST['sorder'])$_SESSION['pricebook_order']=$_REQUEST['order_by']." ".$_REQUEST['sorder'];
|
||||
|
||||
//if($_REQUEST['order_by'])$_SESSION['pricebook_order_by']=$_SESSION['pricebook_order']=$_REQUEST['order_by'];
|
||||
//$_SESSION['pricebook_sorder']=$_REQUEST['sorder'];
|
||||
$_SESSION['pricebook_sorder']=$_REQUEST['sorder'];
|
||||
$_COOKIE['pricebook_id']=$_REQUEST['pricebook_id'];
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,ecmlanguage,currency_value from ecmpricebooks where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
$lang=$r['ecmlanguage'];
|
||||
$er_value=$r['currency_value'];
|
||||
if(!$er_value){
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
}
|
||||
$sorder=$_REQUEST['sorder'];
|
||||
$result = $GLOBALS['db']->query("select ecmpricebooks_ecmproducts.price as price,ecmpricebooks_ecmproducts.id as idp,ecmproducts.* from ecmpricebooks_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id where ecmpricebooks_ecmproducts.ecmpricebook_id='".$_COOKIE['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'");
|
||||
$checkc='';
|
||||
$checkc.='if(document.getElementById(\'checkin\').checked==true)
|
||||
{
|
||||
mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=checkAllProducts&pricebook_id='.$_REQUEST['pricebook_id'].'&value=true\',\'checkin\');
|
||||
}
|
||||
else
|
||||
{
|
||||
mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=checkAllProducts&pricebook_id='.$_REQUEST['pricebook_id'].'&value=false\',\'checkin\');
|
||||
}';
|
||||
while($ro=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
|
||||
$checkc.='if(document.getElementById(\'checkin\').checked==true)
|
||||
{
|
||||
document.getElementById(\'checkc'.$ro['idp'].'\').checked=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById(\'checkc'.$ro['idp'].'\').checked=false;
|
||||
}
|
||||
';
|
||||
}
|
||||
print '</tr>';
|
||||
$z="select
|
||||
ecmpricebooks_ecmproducts.price as price,
|
||||
ecmpricebooks_ecmproducts.popular as popular,
|
||||
ecmpricebooks_ecmproducts.recipient_code as recipient_code,
|
||||
ecmpricebooks_ecmproducts.id as idp,
|
||||
ecmpricebooks_ecmproducts.margin_rate,
|
||||
ecmpricebooks_ecmproducts.position as position,
|
||||
ecmpricebooks_ecmproducts.remarks_pl as remarks_pl,
|
||||
ecmpricebooks_ecmproducts.remarks_en as remarks_en,
|
||||
ecmpricebooks_ecmproducts.remarks_de as remarks_de,
|
||||
ecmproducts.*,
|
||||
|
||||
ecmproduct_language_pl_view.ean as ean_pl,
|
||||
ecmproduct_language_pl_view.short_description as short_description_pl,
|
||||
ecmproduct_language_pl_view.long_description as long_description_pl,
|
||||
ecmproduct_language_pl_view.remarks as default_remarks_pl,
|
||||
|
||||
ecmproduct_language_en_view.ean as ean_en,
|
||||
ecmproduct_language_en_view.short_description as short_description_en,
|
||||
ecmproduct_language_en_view.long_description as long_description_en,
|
||||
ecmproduct_language_en_view.remarks as default_remarks_en,
|
||||
|
||||
ecmproduct_language_de_view.ean as ean_de,
|
||||
ecmproduct_language_de_view.short_description as short_description_de,
|
||||
ecmproduct_language_de_view.long_description as long_description_de,
|
||||
ecmproduct_language_de_view.remarks as default_remarks_de
|
||||
|
||||
from ecmpricebooks_ecmproducts
|
||||
|
||||
left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
inner join ecmproducts on ecmproducts.id=ecmpricebooks_ecmproducts.ecmproduct_id
|
||||
|
||||
where ecmpricebooks_ecmproducts.ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmpricebooks_ecmproducts.deleted='0'";
|
||||
|
||||
$tmp = substr(trim($_SESSION['pricebook_order']), -1);
|
||||
if ($tmp!='.')
|
||||
if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order'];
|
||||
|
||||
//$z.=" COLLATE utf8_polish_ci";
|
||||
//print $z;
|
||||
|
||||
|
||||
if ($_REQUEST['customview_id']=='4cf54ba0-db9b-dc0d-e781-522f24a92e60') {
|
||||
$ttttt = '
|
||||
<br><br>
|
||||
<form action="index.php?module=EcmPriceBooks&action=updatePrices&record='.$_REQUEST['pricebook_id'].'" method="post">
|
||||
Marża: <input id="margin" name="margin" type="text" value="0"/> 
|
||||
Rabat: <input id="discount" name="discount" type="text" value="0"/> 
|
||||
Cena z VAT: <input id="with_tax" name="with_tax" type="checkbox"/> 
|
||||
Rodzaj przeliczania:
|
||||
<select id="type" name="type"/>
|
||||
<option value="1">Od dołu</option>
|
||||
<option value="2">Od góry</option>
|
||||
</select>
|
||||
<input type="submit" value="Przelicz ceny"/>
|
||||
<br><br>
|
||||
</form>
|
||||
';
|
||||
echo $ttttt;
|
||||
}
|
||||
|
||||
$result = $GLOBALS['db']->query($z);
|
||||
include_once("modules/EcmProductReports/vtigerConnector.php");
|
||||
$count = $result->num_rows;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
if ($licz%100==0 && $licz>0) {
|
||||
print '</table>';
|
||||
print '<input type="submit" name="save_prices" class="button" value="Save">';
|
||||
print '</form>';
|
||||
}
|
||||
if ($licz%100==0) {
|
||||
print '<form action="index.php?module=EcmPriceBooks&action=SavePrices&record='.$_REQUEST['pricebook_id'].'" method="post">';
|
||||
print '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="list view" border="1"><tr>';
|
||||
print '<td class="listViewThS1" width="2%"><input type="checkbox" id="checkin" value="true" onclick="'.$checkc.'"';
|
||||
if($_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']=="true"){print ' checked';}
|
||||
print '></td>';
|
||||
print '<td class="listViewThS1">'.sortLink("ecmpricebooks_ecmproducts.position",$sorder,"Pos.").'</td>';
|
||||
//print mysql_error();
|
||||
$t[1]='Nazwa';
|
||||
$t[2]='Kategoria';
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
$corder_by="ecmproducts.".$c[$i];
|
||||
if($c[$i]=="list_price")$corder_by="ecmpricebooks_ecmproducts.price";
|
||||
|
||||
if($c[$i]=="ean_pl")$corder_by="ecmproduct_language_pl_view.ean";
|
||||
if($c[$i]=="short_description_pl")$corder_by="ecmproduct_language_pl_view.short_description";
|
||||
if($c[$i]=="long_description_pl")$corder_by="ecmproduct_language_pl_view.long_description";
|
||||
if($c[$i]=="default_remarks_pl")$corder_by="ecmproduct_language_pl_view.remarks";
|
||||
|
||||
if($c[$i]=="remarks_pl")$corder_by="ecmpricebooks_ecmproducts.remarks_pl";
|
||||
|
||||
if($c[$i]=="ean_en")$corder_by="ecmproduct_language_en_view.ean";
|
||||
if($c[$i]=="short_description_en")$corder_by="ecmproduct_language_en_view.short_description";
|
||||
if($c[$i]=="long_description_en")$corder_by="ecmproduct_language_en_view.long_description";
|
||||
if($c[$i]=="default_remarks_en")$corder_by="ecmproduct_language_en_view.remarks";
|
||||
|
||||
if($c[$i]=="remarks_en")$corder_by="ecmpricebooks_ecmproducts.remarks_en";
|
||||
|
||||
if($c[$i]=="ean_de")$corder_by="ecmproduct_language_de_view.ean";
|
||||
if($c[$i]=="short_description_de")$corder_by="ecmproduct_language_de_view.short_description";
|
||||
if($c[$i]=="long_description_de")$corder_by="ecmproduct_language_de_view.long_description";
|
||||
if($c[$i]=="default_remarks_de")$corder_by="ecmproduct_language_de_view.remarks";
|
||||
|
||||
if($c[$i]=="remarks_de")$corder_by="ecmpricebooks_ecmproducts.remarks_de";
|
||||
|
||||
if($c[$i]=="margin_rate")$corder_by="margin_rate";
|
||||
|
||||
if($c[$i]=="sale_qty30")$corder_by="name";
|
||||
if($c[$i]=="sale_qty90")$corder_by="name";
|
||||
if($c[$i]=="sale_qty180")$corder_by="name";
|
||||
if($c[$i]=="sale_avg_price30")$corder_by="name";
|
||||
if($c[$i]=="sale_avg_price90")$corder_by="name";
|
||||
if($c[$i]=="sale_avg_price180")$corder_by="name";
|
||||
|
||||
|
||||
|
||||
if($t[$i])print '<td class="listViewThS1">'.sortLink($corder_by,$sorder,$t[$i]).'</td>';
|
||||
}
|
||||
$mm=$mod_strings;
|
||||
print '<td class="listViewThS1" width="1%">Popularność</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_UNIT_PRICE'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_MARGIN'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_LIST_PRICE_PRICEBOOK'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">Cena brutto</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_RECIPIENT_CODE'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_REMARKS_PL'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_REMARKS_EN'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%">'.$mm['LBL_REMARKS_DE'].'</td>';
|
||||
print '<td class="listViewThS1" width="1%"> </td>';
|
||||
print '<td class="listViewThS1" width="1%"> </td>';
|
||||
print '<td class="listViewThS1" width="1%"> </td>';
|
||||
}
|
||||
|
||||
$stop[$row['code']]=false;
|
||||
$sale30="";
|
||||
$qty30="";
|
||||
$sale90="";
|
||||
$qty90="";
|
||||
$sale180="";
|
||||
$qty180="";
|
||||
if($_SESSION['EcmPriceBooks_high'][$row['idp']])$color="#cccccc";
|
||||
else $color="";
|
||||
$licz++;
|
||||
print '<tr id="row'.$row['idp'].'" style="background:'.$color.'">';
|
||||
|
||||
print '<td class="oddListRowS1"><input type="hidden" id="check'.$row['idp'].'"><input id="checkc'.$row['idp'].'" onclick="mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=checkProduct&record='.$row['idp'].'&pricebook_id='.$_REQUEST['pricebook_id'].'&value=\'+this.checked,\'check'.$row['idp'].'\');" type="checkbox" name="check[]" value="'.$row['idp'].'"';
|
||||
if($_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']=="true" || $_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$row['idp']]=="true")print ' checked';
|
||||
print '></td>';
|
||||
print '<td class="oddListRowS1" style="text-align: left">'.($row['position']).'</td>';
|
||||
//print '<td class="oddListRowS1"><a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['name'].'</a></td>';
|
||||
|
||||
/*$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select purchase_price from ecmproducts where id='".$row['id']."'"));
|
||||
$purchase_price=$rr['purchase_price'];
|
||||
@$margin=100-(100*$purchase_price/$row['price']);
|
||||
$margin=number_format($margin,2,",",".");*/
|
||||
for($i=0;$i<count($t);$i++)
|
||||
{
|
||||
if($t[$i])
|
||||
{
|
||||
|
||||
if(($c[$i]=="sale_qty30" || $c[$i]=="sale_qty90" || $c[$i]=="sale_qty180" || $c[$i]=="sale_avg_price30" || $c[$i]=="sale_avg_price90" || $c[$i]=="sale_avg_price180") && $stop[$row['code']]==false){
|
||||
$ddate=date("Y-m-d",mktime()-200*24*3600);
|
||||
|
||||
$w=$GLOBALS['db']->query("select ecminvoiceoutitems.price as price,ecminvoiceoutitems.quantity as quantity,ecminvoiceouts.register_date as date from ecminvoiceoutitems inner join ecminvoiceouts on ecminvoiceoutitems.ecminvoiceout_id=ecminvoiceouts.id where ecminvoiceoutitems.ecmproduct_id='".$row['id']."' and ecminvoiceouts.type!='correct' and ecminvoiceouts.register_date>'".$ddate."'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$sale+=$r['price']*$r['quantity'];
|
||||
$qty+=$r['quantity'];
|
||||
$aq[$r['no']]+=$r['quantity'];
|
||||
|
||||
$date=date("Y-m");
|
||||
|
||||
$date1=date("Y-m",mktime()-1*24*3600*31);
|
||||
$date2=date("Y-m",mktime()-2*24*3600*31);
|
||||
$date3=date("Y-m",mktime()-3*24*3600*31);
|
||||
$date4=date("Y-m",mktime()-4*24*3600*31);
|
||||
$date5=date("Y-m",mktime()-5*24*3600*31);
|
||||
$date6=date("Y-m",mktime()-6*24*3600*31);
|
||||
|
||||
$d=explode("-",$r['date']);
|
||||
|
||||
$dd=$d[0]."-".$d[1];
|
||||
if($dd==$date6){
|
||||
//echo 3;
|
||||
$qty_6+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date5){
|
||||
//echo 3;
|
||||
$qty_5+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date4){
|
||||
//echo 3;
|
||||
$qty_4+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date3){
|
||||
//echo 3;
|
||||
$qty_3+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date2){
|
||||
//echo 2;
|
||||
$qty_2+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date1){
|
||||
//echo 1;
|
||||
$qty_1+=$r['quantity'];
|
||||
}
|
||||
|
||||
if($dd==$date){
|
||||
$sale0+=$r['price']*$r['quantity'];
|
||||
$qty0+=$r['quantity'];
|
||||
$aq0[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date1){
|
||||
$sale30+=$r['price']*$r['quantity'];
|
||||
$qty30+=$r['quantity'];
|
||||
$aq30[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date1 || $dd==$date2 || $dd==$date3){
|
||||
$sale90+=$r['price']*$r['quantity'];
|
||||
$qty90+=$r['quantity'];
|
||||
$aq90[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
if($dd==$date1 || $dd==$date2 || $dd==$date3 || $dd==$date4 || $dd==$date5 || $dd==$date6){
|
||||
$sale180+=$r['price']*$r['quantity'];
|
||||
$qty180+=$r['quantity'];
|
||||
$aq180[$r['no']]+=$r['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@$trend_6_5=$qty_5/$qty_6;
|
||||
@$trend_5_4=$qty_4/$qty_5;
|
||||
@$trend_4_3=$qty_3/$qty_4;
|
||||
@$trend_3_2=$qty_2/$qty_3;
|
||||
@$trend_2_1=$qty_1/$qty_2;
|
||||
|
||||
$trend=($qty_1+$qty_2+$qty_3)/3;
|
||||
|
||||
$qty__1=$trend;
|
||||
$qty__2=$trend;
|
||||
$qty__3=$trend;
|
||||
|
||||
if($qty__1<0)$qty__1=0;
|
||||
if($qty__2<0)$qty__2=0;
|
||||
if($qty__3<0)$qty__3=0;
|
||||
|
||||
$stop[$row['code']]=true;
|
||||
}
|
||||
|
||||
|
||||
print '<td class="oddListRowS1" style="text-align: left">';
|
||||
if($c[$i]=="ordered")print number_format($row['ordered'],0,"","");
|
||||
elseif($c[$i]=="sale_qty30")print number_format($qty30,0,"","");
|
||||
elseif($c[$i]=="sale_qty90")print number_format($qty90/3,0,"","");
|
||||
elseif($c[$i]=="sale_qty180")print number_format($qty180/6,0,"","");
|
||||
elseif($c[$i]=="sale_avg_price30")print number_format($sale30,2,",",".");
|
||||
elseif($c[$i]=="sale_avg_price90")print number_format($sale90,2,",",".");
|
||||
elseif($c[$i]=="sale_avg_price180")print number_format($sale180,2,",",".");
|
||||
elseif($c[$i]=="ems_qty_in_stock")print number_format($row['ems_qty_in_stock'],0,"","");
|
||||
elseif($c[$i]=="list_price")print addExchangeRateValue($row['price'],$c[$i],$er_value);
|
||||
elseif($c[$i]=="margin_rate")print number_format($row['margin_rate'],2,",",".");
|
||||
elseif($c[$i]=="name"){
|
||||
if($lang=="en_us"){
|
||||
if($row['short_description_en'])print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['short_description_en'].'</a>';
|
||||
else print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">none</a>';
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
if($row['short_description_de'])print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['short_description_de'].'</a>';
|
||||
else print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">none</a>';
|
||||
}
|
||||
else print '<a href="index.php?module=EcmProducts&action=DetailView&record='.$row['id'].'">'.$row['name'].'</a>';
|
||||
}
|
||||
elseif($c[$i]=="product_category_name"){
|
||||
if($lang=="en_us"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_en from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
if($rrp['name_en'])print $rrp['name_en'];
|
||||
}
|
||||
elseif($lang=="ge_ge"){
|
||||
$rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_de from ecmproductcategories where id='".$row['product_category_id']."'"));
|
||||
if($rrp['name_de'])print $rrp['name_de'];
|
||||
}
|
||||
else print $row['product_category_name'];
|
||||
print ' <a target="_blank" href="index.php?record='.$_REQUEST['pricebook_id'].'&to_pdf=1&action=generateCategoryContent&module=EcmProducts&category_id='.$row['product_category_id'].'&category_name='.$row['product_category_name'].'&lang='.$lang.'"><img src="themes/default/images/PDFlanguages.gif" border="0" /></a>';
|
||||
}
|
||||
else print addExchangeRateValue($row[$c[$i]],$c[$i],$er_value);
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($row['popular']==1)$po_checked="checked";
|
||||
else $po_checked="";
|
||||
print '<td>
|
||||
<input size="8" id="popular_'.$licz.'" name="popular_'.$licz.'" readonly type="checkbox" value="1" '.$po_checked.'/>
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="purchase_price_'.$licz.'" name="purchase_price_'.$licz.'" readonly type="text" onchange="getPricePricebook();" onclick="getPricePricebook();" onblur="getPricePricebook();" value="'.number_format($row['purchase_price'],2,",",".").'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="4" id="margin_'.$licz.'" name="margin_'.$licz.'" type="text" onchange="getPricePricebook();" onclick="getPricePricebook();" onblur="getPricePricebook();" value="'.number_format($row['margin_rate'],2,",",".").'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="price_'.$licz.'" name="price_'.$licz.'" type="text" onchange="getPricePricebook();" onclick="getPricePricebook();" onblur="getPricePricebook();" value="'.number_format($row['price'],2,",",".").'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="price_brutto_'.$licz.'" name="price_brutto_'.$licz.'" type="text" onchange="getPricePricebook();" onclick="getPricePricebook();" onblur="getPricePricebook();" value="'.number_format(($row['price']*(1+$row['vat_value']/100)),2,",",".").'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="recipient_code_'.$licz.'" name="recipient_code_'.$licz.'" type="text" value="'.$row['recipient_code'].'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="remarks_pl_'.$licz.'" name="remarks_pl_'.$licz.'" type="text" value="'.$row['remarks_pl'].'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="remarks_en_'.$licz.'" name="remarks_en_'.$licz.'" type="text" value="'.$row['remarks_en'].'" />
|
||||
</td>
|
||||
<td>
|
||||
<input size="8" id="remarks_de_'.$licz.'" name="remarks_de_'.$licz.'" type="text" value="'.$row['remarks_de'].'" />
|
||||
</td>
|
||||
<td>
|
||||
<input id="product_id_'.$licz.'" name="product_id_'.$licz.'" type="hidden" value="'.$row['idp'].'" /></td>';
|
||||
|
||||
|
||||
print '<td class="oddListRowS1">
|
||||
<a id="edit'.$row['id'].'" style="cursor:pointer;" onclick="document.getElementById(\'row'.$row['idp'].'\').style.background=\'#e6e6e6\';showdiv(\'edit'.$row['id'].'\',\'price-block\',80,240);showprice(\''.$row['id'].'\',\''.number_format($row['price'],2,",",".").'\',\''.number_format($row['purchase_price'],2,",",".").'\',\''.number_format($row['margin_rate'],2,",",".").'\',\''.$row['remarks_pl'].'\',\''.$row['remarks_en'].'\',\''.$row['remarks_de'].'\',\''.$_REQUEST['order_by'].'\',\''.$_REQUEST['sorder'].'\',\''.$row['recipient_code'].'\');"><img src="themes/Sugar/images/edit_inline.gif" border="0"></a>';
|
||||
print '<td class="oddListRowS1">
|
||||
<a id="delete'.$row['id'].'" style="cursor:pointer;" onclick="if(confirm(\''.$mod_strings['LBL_QUESTION_DELETE'].'\')){mintajaxget(\'index.php?to_pdf=1&module=EcmPriceBooks&action=deleteProductFromPriceBook&id='.$row['idp'].'\',\'row'.$row['idp'].'\');document.getElementById(\'row'.$row['idp'].'\').style.display=\'none\';}"><img src="themes/Sugar/images/delete_inline.gif" border="0"></a>
|
||||
</td>';
|
||||
print '</tr>';
|
||||
if ($licz==$count) {
|
||||
print '</table>';
|
||||
print '<input type="submit" name="save_prices" class="button" value="Save">';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//print '</table>';
|
||||
print '<div style="text-align:left"><br><input class="button" value="Delete" name="delete" type="button" onclick="if(confirm(\'Are You sure?\'))location.href=\'index.php?module=EcmPriceBooks&action=DeleteFromPriceBook&but=1&return_id='.$_COOKIE['pricebook_id'].'\';"></div>';
|
||||
|
||||
?>
|
||||
58
import/EcmPriceBooks/Menu.php
Normal file
58
import/EcmPriceBooks/Menu.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $mod_strings;
|
||||
|
||||
|
||||
|
||||
$module="EcmPriceBooks";
|
||||
if(ACLController::checkAccess($module, 'edit', true))$module_menu [] = Array("index.php?module=".$module."&action=EditView&return_module=".$module."&return_action=DetailView", $mod_strings['LNK_NEW_'.strtoupper($module)],"Create".$module,$module);
|
||||
if(ACLController::checkAccess($module, 'list', true))$module_menu [] = Array("index.php?module=".$module."&action=index&return_module=".$module."&return_action=DetailView", $mod_strings['LNK_'.strtoupper($module).'_LIST'],$module, $module);
|
||||
?>
|
||||
5
import/EcmPriceBooks/PDF.php
Normal file
5
import/EcmPriceBooks/PDF.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?
|
||||
session_start();
|
||||
$_SESSION['pricebook_images']=$_REQUEST['images'];
|
||||
header("Location: modules/EcmPriceBooks/CreatePDF.php");
|
||||
?>
|
||||
57
import/EcmPriceBooks/Popup.php
Normal file
57
import/EcmPriceBooks/Popup.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
require_once('modules/EcmPriceBooks/Popup_picker.php');
|
||||
|
||||
$popup = new Popup_Picker();
|
||||
|
||||
echo $popup->process_page();
|
||||
|
||||
?>
|
||||
154
import/EcmPriceBooks/Popup_picker.php
Normal file
154
import/EcmPriceBooks/Popup_picker.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
global $theme;
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('themes/'.$theme.'/layout_utils.php');
|
||||
require_once('log4php/LoggerManager.php');
|
||||
require_once('XTemplate/xtpl.php');
|
||||
require_once('include/ListView/ListView.php');
|
||||
$image_path = 'themes/'.$theme.'/images/';
|
||||
|
||||
class Popup_Picker{
|
||||
|
||||
function Popup_Picker(){
|
||||
;
|
||||
}
|
||||
|
||||
function _get_where_clause(){
|
||||
$where = '';
|
||||
if(isset($_REQUEST['query'])){
|
||||
$where_clauses = array();
|
||||
append_where_clause($where_clauses, "name", "ecmpricebooks.name");
|
||||
$where = generate_where_statement($where_clauses);
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
function process_page(){
|
||||
global $theme;
|
||||
global $mod_strings;
|
||||
global $app_strings;
|
||||
global $currentModule;
|
||||
|
||||
$output_html = '';
|
||||
$where = '';
|
||||
$where = $this->_get_where_clause();
|
||||
|
||||
$image_path = 'themes/'.$theme.'/images/';
|
||||
|
||||
$name = empty($_REQUEST['name']) ? '' : $_REQUEST['name'];
|
||||
$request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
|
||||
$hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true;
|
||||
$button = "<form action='index.php' method='post' name='form' id='form'>\n";
|
||||
if(!$hide_clear_button){
|
||||
$button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='"
|
||||
.$app_strings['LBL_CLEAR_BUTTON_TITLE']."' accesskey='"
|
||||
.$app_strings['LBL_CLEAR_BUTTON_KEY'] ."' value=' "
|
||||
.$app_strings['LBL_CLEAR_BUTTON_LABEL']." ' />\n";
|
||||
}
|
||||
$button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='"
|
||||
.$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accesskey='"
|
||||
.$app_strings['LBL_CANCEL_BUTTON_KEY'] ."' value=' "
|
||||
.$app_strings['LBL_CANCEL_BUTTON_LABEL']." ' />\n";
|
||||
$button .= "</form>\n";
|
||||
$form = new XTemplate('modules/EcmPriceBooks/Popup_picker.html');
|
||||
$form->assign('MOD', $mod_strings);
|
||||
$form->assign('APP', $app_strings);
|
||||
$form->assign('THEME', $theme);
|
||||
$form->assign('MODULE_NAME', $currentModule);
|
||||
$form->assign('NAME', $name);
|
||||
$form->assign('request_data', $request_data);
|
||||
$form->assign('PRICEBOOK_PRODUCT_ID', $_REQUEST['pricebook_product_id']);
|
||||
$form->assign('EXCHANGE_RATE_ID', $_REQUEST['exchange_rate_id']);
|
||||
|
||||
ob_start();
|
||||
insert_popup_header($theme);
|
||||
$output_html .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false);
|
||||
|
||||
$form->parse('main.SearchHeader');
|
||||
$output_html .= $form->text('main.SearchHeader');
|
||||
$output_html .= get_form_footer();
|
||||
|
||||
// RESET THE SECTIONS THAT ARE ALREADY IN THE PAGE SO THAT THEY DO NOT PRINT AGAIN LATER.
|
||||
$form->reset('main.SearchHeader');
|
||||
|
||||
// CREATE THE LISTVIEW
|
||||
$seed_bean = new EcmPriceBook();
|
||||
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price from ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['pricebook_product_id']."' and ecmpricebook_id='".$seed_bean->id."'"));
|
||||
$seed_bean->price=$r['price'];
|
||||
|
||||
$ListView = new ListView();
|
||||
$ListView->show_export_button = false;
|
||||
$ListView->process_for_popups = true;
|
||||
$ListView->setXTemplate($form);
|
||||
$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']);
|
||||
$ListView->setHeaderText($button);
|
||||
|
||||
$ListView->setQuery($where, '', 'name', 'ECMPRICEBOOK');
|
||||
$ListView->setModStrings($mod_strings);
|
||||
|
||||
ob_start();
|
||||
$ListView->processListView($seed_bean, 'main', 'ECMPRICEBOOK');
|
||||
$output_html .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$output_html .= get_form_footer();
|
||||
$output_html .= insert_popup_footer();
|
||||
return $output_html;
|
||||
}
|
||||
} // end of class Popup_Picker
|
||||
?>
|
||||
115
import/EcmPriceBooks/Save.php
Normal file
115
import/EcmPriceBooks/Save.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('modules/EcmPriceBooks/EcmPriceBook.php');
|
||||
require_once('include/formbase.php');
|
||||
|
||||
|
||||
$focus = new EcmPriceBook();
|
||||
|
||||
$focus->retrieve($_POST['record']);
|
||||
if(!$focus->ACLAccess('Save')){
|
||||
ACLController::displayNoAccess(true);
|
||||
sugar_cleanup(true);
|
||||
}
|
||||
if (!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
|
||||
$check_notify = TRUE;
|
||||
}else{
|
||||
$check_notify = FALSE;
|
||||
}
|
||||
|
||||
foreach($focus->column_fields as $field){
|
||||
if(isset($_POST[$field])){
|
||||
$value = $_POST[$field];
|
||||
$focus->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($focus->additional_column_fields as $field){
|
||||
if(isset($_POST[$field])){
|
||||
$value = $_POST[$field];
|
||||
$focus->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_POST[ekmp_active])) {
|
||||
$focus->ekmp_active = '0';
|
||||
}else{
|
||||
$focus->ekmp_active = '1';
|
||||
}
|
||||
$focus->account_name=$_REQUEST['account_name'];
|
||||
$focus->unformat_all_fields();
|
||||
$focus->save($check_notify);
|
||||
$return_id = $focus->id;
|
||||
|
||||
if(!$_REQUEST['currency_value']){
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($_REQUEST['exchange_rate_id']);
|
||||
$er_value=$currency->conversion_rate;
|
||||
}
|
||||
else $er_value=unformat_number($_REQUEST['currency_value']);
|
||||
|
||||
|
||||
|
||||
$GLOBALS['db']->query("update ecmpricebooks set currency_value='".$er_value."',account_name='".$_POST['account_name']."' where id='".$return_id."'");
|
||||
echo $_SESSION['pricebook_duplicate_id'].'<br>';
|
||||
echo $_POST['duplicateSave'].'<br>';
|
||||
|
||||
if($_SESSION['pricebook_duplicate_id'] && $_POST['duplicateSave']=="true"){
|
||||
$w=$GLOBALS['db']->query("select * from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_SESSION['pricebook_duplicate_id']."'");
|
||||
$_SESSION['pricebook_duplicate_id']="";
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)) {
|
||||
$GLOBALS['db']->query("insert into ecmpricebooks_ecmproducts values('".create_guid()."','".$return_id."','".$r['ecmproduct_id']."','".$r['deleted']."','".$r['price']."','".$r['recipient_code']."','".$r['created_by']."','".$r['remarks_pl']."','".$r['remarks_en']."','".$r['remarks_de']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','".$_SESSION['authenticated_user_id']."','".$r['popular']."','".$r['position']."', '".$r['margin_rate']."');");
|
||||
}
|
||||
}
|
||||
handleRedirect($return_id,'EcmPriceBooks');
|
||||
|
||||
?>
|
||||
33
import/EcmPriceBooks/SaveCustomView.php
Normal file
33
import/EcmPriceBooks/SaveCustomView.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?
|
||||
global $db;
|
||||
|
||||
require("modules/EcmProducts/vardefs.php");
|
||||
require("modules/EcmProducts/language/en_us.lang.php");
|
||||
|
||||
$fields=$dictionary['EcmProduct']['fields'];
|
||||
|
||||
$columns=$_REQUEST['column1']."||".$_REQUEST['column2']."||".$_REQUEST['column3']."||".$_REQUEST['column4']."||".$_REQUEST['column5']."||".$_REQUEST['column6']."||".$_REQUEST['column7']."||".$_REQUEST['column8']."||".$_REQUEST['column9'];
|
||||
|
||||
$fields=$dictionary['EcmProduct']['fields'];
|
||||
|
||||
for($i=1;$i<=9;$i++)
|
||||
{
|
||||
$str=$fields[$_REQUEST['column'.$i]]['vname'];
|
||||
if(!$_REQUEST['title'.$i])$_REQUEST['title'.$i]=$mod_strings[$str];
|
||||
}
|
||||
|
||||
$titles=$_REQUEST['title1']."||".$_REQUEST['title2']."||".$_REQUEST['title3']."||".$_REQUEST['title4']."||".$_REQUEST['title5']."||".$_REQUEST['title6']."||".$_REQUEST['title7']."||".$_REQUEST['title8']."||".$_REQUEST['title9'];
|
||||
|
||||
for($i=1;$i<=9;$i++){
|
||||
if($_REQUEST['order'.$i] && $_REQUEST['sorder'.$i]){
|
||||
$ord[$i]=$_REQUEST['order'.$i]." ".$_REQUEST['sorder'.$i];
|
||||
}
|
||||
}
|
||||
|
||||
$orders=implode("||",$ord);
|
||||
|
||||
if($_REQUEST['record'])$db->query("update ecmpricebooks_customview set name='".$_REQUEST['name']."',columns='".$columns."',titles='".$titles."',orders='".$orders."' where id='".$_REQUEST['record']."'");
|
||||
else $db->query("insert into ecmpricebooks_customview values('".create_guid()."','".$_REQUEST['name']."','".$columns."','".$titles."','".$orders."')");
|
||||
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_SESSION['pricebook_id']."&tab=items");
|
||||
?>
|
||||
10
import/EcmPriceBooks/SaveOrder.php
Normal file
10
import/EcmPriceBooks/SaveOrder.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?
|
||||
for($i=0;$i<=$_REQUEST['num'];$i++)
|
||||
{
|
||||
if($_REQUEST['c'.$i])$v[]=$_REQUEST['c'.$i];
|
||||
}
|
||||
$value=implode(",",$v);
|
||||
$_SESSION['columns_order']=$value;
|
||||
$_SESSION['pricebook_order']=str_replace(","," asc,",$value)." asc";
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['record']."&tab=items");
|
||||
?>
|
||||
15
import/EcmPriceBooks/SavePrice.php
Normal file
15
import/EcmPriceBooks/SavePrice.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?
|
||||
$sugarEntry=true;
|
||||
global $db;
|
||||
function priceToDb($v){
|
||||
$v=str_replace(".","",$v);
|
||||
$v=str_replace(",",".",$v);
|
||||
return floatval($v);
|
||||
}
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set recipient_code='".$_REQUEST['recipient_code']."',remarks_pl='".$_REQUEST['remarks_pl']."',remarks_en='".$_REQUEST['remarks_en']."',remarks_de='".$_REQUEST['remarks_de']."',price='".priceToDb($_REQUEST['price'])."' where ecmpricebook_id='".$_REQUEST['pricebook_id']."' and ecmproduct_id='".$_REQUEST['record']."'");
|
||||
$_REQUEST['customview_id']=$_COOKIE['customview_id'];
|
||||
$_GET['customview_id']=$_COOKIE['customview_id'];
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts where ecmproduct_id='".$_REQUEST['record']."' and ecmpricebook_id='".$_REQUEST['pricebook_id']."'"));
|
||||
$_SESSION['EcmPriceBooks_high'][$r['id']]=true;
|
||||
include("modules/EcmPriceBooks/ListViewProductsAjax.php");
|
||||
?>
|
||||
27
import/EcmPriceBooks/SavePrices.php
Normal file
27
import/EcmPriceBooks/SavePrices.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?
|
||||
$sugarEntry=true;
|
||||
global $db;
|
||||
function priceToDb($v){
|
||||
$v=str_replace(".","",$v);
|
||||
$v=str_replace(",",".",$v);
|
||||
return floatval($v);
|
||||
}
|
||||
for($i=1;$i<=1000;$i++){
|
||||
if (!$_REQUEST['product_id_'.$i]) continue;
|
||||
$prod = $_REQUEST['product_id_'.$i];
|
||||
if($_REQUEST['product_id_'.$i]){
|
||||
$rp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ecmproduct_id,price from ecmpricebooks_ecmproducts where id='".$_REQUEST['product_id_'.$i]."' and deleted='0'"));
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select vat_value from ecmproducts where id='".$rp['ecmproduct_id']."'"));
|
||||
$price=priceToDb($_REQUEST['price_brutto_'.$i])/(1+$r['vat_value']/100);
|
||||
if($rp['price']!=priceToDb($_REQUEST['price_'.$i]) || $_REQUEST['price_'.$i]=="")$price=priceToDb($_REQUEST['price_'.$i]);
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set popular='".$_REQUEST['popular_'.$i]."',recipient_code='".$_REQUEST['recipient_code_'.$i]."',remarks_pl='".$_REQUEST['remarks_pl_'.$i]."',remarks_en='".$_REQUEST['remarks_en_'.$i]."',remarks_de='".$_REQUEST['remarks_de_'.$i]."',price='".$price."' where id='".$_REQUEST['product_id_'.$i]."'");
|
||||
$_SESSION['EcmPriceBooks_high'][$_REQUEST['product_id_'.$i]]=true;
|
||||
}
|
||||
}
|
||||
$_REQUEST['customview_id']=$_COOKIE['customview_id'];
|
||||
$_GET['customview_id']=$_COOKIE['customview_id'];
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ecmpricebook_id from ecmpricebooks_ecmproducts where id='".$prod."'"));
|
||||
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$r['ecmpricebook_id']."&tab=items");
|
||||
?>
|
||||
130
import/EcmPriceBooks/SubPanelView.php
Normal file
130
import/EcmPriceBooks/SubPanelView.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('XTemplate/xtpl.php');
|
||||
require_once("data/Tracker.php");
|
||||
require_once("include/ListView/ListView.php");
|
||||
|
||||
global $app_strings;
|
||||
global $current_language;
|
||||
$current_module_strings = return_module_language($current_language, 'EcmPriceBooks');
|
||||
$header_text = '';
|
||||
global $currentModule;
|
||||
global $theme;
|
||||
global $focus;
|
||||
global $action;
|
||||
|
||||
$theme_path="themes/".$theme."/";
|
||||
$image_path=$theme_path."images/";
|
||||
require_once($theme_path.'layout_utils.php');
|
||||
|
||||
///////////////////////////////////////
|
||||
/// SETUP PARENT POPUP
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return_and_save',
|
||||
'form_name' => 'DetailView',
|
||||
'field_to_name_array' => array(
|
||||
'id' => 'ecmpricebook_id',
|
||||
),
|
||||
);
|
||||
$json = getJSONobj();
|
||||
$encoded_popup_request_data = $json->encode($popup_request_data);
|
||||
///
|
||||
///////////////////////////////////////
|
||||
|
||||
// FOCUS_LIST IS THE MEANS OF PASSING DATA TO A SUBPANELVIEW.
|
||||
global $focus_list;
|
||||
|
||||
$button = "<form action='index.php' method='post' name='form' id='form'>\n";
|
||||
$button .= "<input type='hidden' name='module' value='EcmPriceBooks'>\n";
|
||||
|
||||
if ($currentModule == 'Accounts') {
|
||||
$button .= "<input type='hidden' name='account_id' value='$focus->id'>\n";
|
||||
$button .= "<input type='hidden' name='account_name' value='$focus->name'>\n";
|
||||
|
||||
}elseif ($currentModule == 'Contacts') {
|
||||
$button .= "<input type='hidden' name='account_id' value='$focus->account_id'>\n";
|
||||
$button .= "<input type='hidden' name='account_name' value='$focus->account_name'>\n";
|
||||
$button .= "<input type='hidden' name='contact_id' value='$focus->id'>\n";
|
||||
|
||||
}elseif ($currentModule == 'Cases') {
|
||||
$button .= "<input type='hidden' name='case_id' value='$focus->id'>\n";
|
||||
}
|
||||
|
||||
$button .= "<input type='hidden' name='return_module' value='".$currentModule."'>\n";
|
||||
$button .= "<input type='hidden' name='return_action' value='".$action."'>\n";
|
||||
$button .= "<input type='hidden' name='return_id' value='".$focus->id."'>\n";
|
||||
$button .= "<input type='hidden' name='action'>\n";
|
||||
$button .= "<input title='".$app_strings['LBL_NEW_BUTTON_TITLE']
|
||||
."' accessKey='".$app_strings['LBL_NEW_BUTTON_KEY']
|
||||
."' class='button' onclick=\"this.form.action.value='EditView'\" type='submit' name='New' value=' "
|
||||
.$app_strings['LBL_NEW_BUTTON_LABEL']." '>\n";
|
||||
$button .= "<input title='".$app_strings['LBL_SELECT_BUTTON_TITLE']."' accessKey='"
|
||||
.$app_strings['LBL_SELECT_BUTTON_KEY']."' type='button' class='button' value=' "
|
||||
.$app_strings['LBL_SELECT_BUTTON_LABEL']
|
||||
." ' name='button' onclick='open_popup(\"EcmPriceBooks\", 600, 400, \"\", false, true, {$encoded_popup_request_data});'>\n";
|
||||
$button .= "</form>\n";
|
||||
|
||||
$ListView = new ListView();
|
||||
$ListView->initNewXTemplate( 'modules/EcmPriceBooks/SubPanelView.html',$current_module_strings);
|
||||
$ListView->xTemplateAssign("RETURN_URL", "&return_module=".$currentModule."&return_action=DetailView&return_id={$_REQUEST['record']}");
|
||||
$ListView->xTemplateAssign("EDIT_INLINE_PNG", get_image($image_path.'edit_inline', 'align="absmiddle" alt="'.$app_strings['LNK_EDIT'] .'" border="0"'));
|
||||
$ListView->xTemplateAssign("DELETE_INLINE_PNG", get_image($image_path.'delete_inline','align="absmiddle" alt="'.$app_strings['LNK_REMOVE'].'" border="0"'));
|
||||
|
||||
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
|
||||
$header_text = " <a href='index.php?action=index&module=DynamicLayout&from_action=SubPanelView&from_module=EcmPriceBooks&record="
|
||||
.$_REQUEST['record']."'>"
|
||||
.get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")
|
||||
."</a>";
|
||||
}
|
||||
$ListView->setHeaderTitle($current_module_strings['LBL_MODULE_NAME'] . $header_text );
|
||||
$ListView->setHeaderText($button);
|
||||
$ListView->processListView($focus_list, "main", "ECMPRICEBOOK");
|
||||
?>
|
||||
23
import/EcmPriceBooks/UpdatePriceBook.php
Normal file
23
import/EcmPriceBooks/UpdatePriceBook.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?
|
||||
$result = $GLOBALS['db']->query("select name,id from ecmpricebooks where deleted='0'");
|
||||
|
||||
$ile=mysql_num_rows($result);
|
||||
for($i=0;$i<$ile;$i++)
|
||||
{
|
||||
if($_REQUEST['check'][$i])
|
||||
{
|
||||
$w=$GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['pricebook_id'][$i]."' and ecmproduct_id='".$_REQUEST['product_id']."'");
|
||||
if(mysql_num_rows($w)==0)
|
||||
{
|
||||
$GLOBALS['db']->query("insert into ecmpricebooks_ecmproducts(id,ecmpricebook_id,ecmproduct_id,deleted,price,created_by,date_entered,date_modified,modified_user_id) values('".create_guid()."','".$_REQUEST['pricebook_id'][$i]."','".$_REQUEST['product_id']."','0','".$_REQUEST['list_price_'.$_REQUEST['pricebook_id'][$i]]."','".$_SESSION['authenticated_user_id']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','".$_SESSION['authenticated_user_id']."')");
|
||||
}
|
||||
else
|
||||
{
|
||||
$z="update ecmpricebooks_ecmproducts set price='".$_REQUEST['list_price_'.$_REQUEST['pricebook_id'][$i]]."' where ecmpricebook_id='".$_REQUEST['pricebook_id'][$i]."' and ecmproduct_id='".$_REQUEST['product_id']."'";
|
||||
//print $z;
|
||||
$GLOBALS['db']->query($z);
|
||||
}
|
||||
}
|
||||
}
|
||||
header("Location: index.php?module=".$_REQUEST['return_module']."&action=".$_REQUEST['return_action']."&record=".$_REQUEST['return_id']);
|
||||
?>
|
||||
4
import/EcmPriceBooks/XLS.php
Normal file
4
import/EcmPriceBooks/XLS.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?
|
||||
header("Content-type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: inline; filename=\"../../cache/upload/".$_REQUEST['file']."\"");
|
||||
?>
|
||||
114
import/EcmPriceBooks/categoryOrder.php
Normal file
114
import/EcmPriceBooks/categoryOrder.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?
|
||||
if($_REQUEST['reset']==1){
|
||||
$GLOBALS['db']->query("delete from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."'");
|
||||
header("Location: index.php?module=EcmPriceBooks&action=categoryOrder&record=".$_REQUEST['record']);
|
||||
}
|
||||
if($_REQUEST['save']){
|
||||
$b=explode("|",$_REQUEST['sort_order']);
|
||||
$i=1;
|
||||
foreach($b as $box){
|
||||
if(strlen($box)>=1 && $box!="" && $box!=" ")$boxy[]=$box;
|
||||
}
|
||||
$GLOBALS['db']->query("delete from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."'");
|
||||
for($i=1;$i<=count($boxy);$i++){
|
||||
|
||||
$z="insert into ecmpricebooks_ecmproducts_categories_sort set id='".create_guid()."',position='".$i."',ecmpricebook_id='".$_REQUEST['record']."',category_id='".$boxy[$i-1]."'";
|
||||
$GLOBALS['db']->query($z);
|
||||
//echo $z.'<br>';;
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=productsOrder&record=".$_REQUEST['record']);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript" src="modules/EcmPriceBooks/moo1.2.js"></script>
|
||||
<script language="javascript">
|
||||
/* when the DOM is ready */
|
||||
window.addEvent('domready', function() {
|
||||
|
||||
/* create sortables */
|
||||
var sb = new Sortables('sortable-list', {
|
||||
/* set options */
|
||||
clone:true,
|
||||
revert: true,
|
||||
/* initialization stuff here */
|
||||
initialize: function() {
|
||||
|
||||
},
|
||||
/* once an item is selected */
|
||||
onStart: function(el) {
|
||||
el.setStyle('background','#add8e6');
|
||||
},
|
||||
/* when a drag is complete */
|
||||
onComplete: function(el) {
|
||||
el.setStyle('background','#ddd');
|
||||
//build a string of the order
|
||||
var sort_order = '';
|
||||
$$('#sortable-list li').each(function(li) { sort_order = sort_order + li.get('alt') + '|'; });
|
||||
$('sort_order').value = sort_order;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
li.sortme {
|
||||
padding:2px 2px;
|
||||
font-size: 9px;
|
||||
color:#000;
|
||||
cursor:move;
|
||||
list-style:none;
|
||||
width:700px;
|
||||
background:#ddd;
|
||||
margin:10px 0;
|
||||
border:1px solid #999;
|
||||
}
|
||||
#sortable-list{
|
||||
clear: none;
|
||||
float: left;
|
||||
margin: 2px;
|
||||
padding: 4px;
|
||||
}
|
||||
</style>
|
||||
<table width='100%' cellpadding='0' cellspacing='0' border='0' class='moduleTitle'><tr><td valign='top'>
|
||||
</td><td width='100%'><h2>Set Categories Order:
|
||||
<?php
|
||||
$z="select name from ecmpricebooks where id='".$_REQUEST['record']."'";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
print " ".$r['name'];
|
||||
?>
|
||||
</h2></td>
|
||||
</tr></table>
|
||||
<form action="index.php?module=EcmPriceBooks&action=categoryOrder&record=<?php echo $_REQUEST['record'];?>" method="post">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding-bottom: 2px;">
|
||||
<input type="submit" value="Save" name="save" class="button">
|
||||
<input type="button" value="Reset" name="reset" class="button" onclick="location.href='index.php?module=EcmPriceBooks&reset=1&action=categoryOrder&record=<?php echo $_REQUEST['record'];?>';">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
|
||||
<tr>
|
||||
<td class="dataLabel">
|
||||
<ul id="sortable-list">
|
||||
<?php
|
||||
$w = $GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."'");
|
||||
if ($w->num_rows==0)
|
||||
$z="select id from ecmproductcategories where deleted='0' order by name asc";
|
||||
else
|
||||
$z="select position,category_id as id from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."' order by position asc";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from ecmproductcategories where id='".$r['id']."'"));
|
||||
print '<li class="sortme" alt="'.$r['id'].'">'.$rr['name'].'</li>';
|
||||
$sort_order[] = $r['id'];
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<input type="hidden" name="sort_order" id="sort_order" value="<?php echo implode($sort_order,'|'); ?>" />
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
15
import/EcmPriceBooks/changeDM.php
Normal file
15
import/EcmPriceBooks/changeDM.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
if($_REQUEST['record']){
|
||||
if($GLOBALS['db']->query("update ecmproducts set date_modified='".date("Y-m-d H:i:s")."' where id='".$_REQUEST['record']."'"))echo "ok";
|
||||
else echo "false";
|
||||
}
|
||||
else{
|
||||
$w=$GLOBALS['db']->query("select p.date_modified,p.id,p.name,p.code from ecmpricebooks_ecmproducts as e inner join ecmproducts as p on p.id=e.ecmproduct_id where e.ecmpricebook_id='418fa92d-1f20-4a4f-bd78-4d6662e89059' and e.deleted='0' order by p.date_modified desc");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
echo '<a href="index.php?module=EcmPriceBooks&action=changeDM&record='.$r['id'].'">'.$r['date_modified'].' '.$r['code'].' '.$r['name'].'</a> ';
|
||||
//if($GLOBALS['db']->query("update ecmproducts set date_modified='".date("Y-m-d H:i:s")."' where id='".$r['id']."'"))echo "ok";
|
||||
//else echo "false";
|
||||
echo '<br>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
10
import/EcmPriceBooks/checkAllProducts.php
Normal file
10
import/EcmPriceBooks/checkAllProducts.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?
|
||||
$result = $GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['pricebook_id']."'");
|
||||
$checkc='';
|
||||
$_SESSION['pricebook_check']=array();
|
||||
while($ro=$GLOBALS['db']->fetchByAssoc($result))
|
||||
{
|
||||
$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$ro['id']]=$_GET['value'];
|
||||
}
|
||||
$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']]['all']=$_GET['value'];
|
||||
?>
|
||||
4
import/EcmPriceBooks/checkProduct.php
Normal file
4
import/EcmPriceBooks/checkProduct.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?
|
||||
$_SESSION['pricebook_check'][$_REQUEST['pricebook_id']][$_GET['record']]=$_GET['value'];
|
||||
print $_GET['value'];
|
||||
?>
|
||||
43
import/EcmPriceBooks/createCatalogue.php
Normal file
43
import/EcmPriceBooks/createCatalogue.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
set_time_limit(99999);
|
||||
error_reporting(E_ERROR);
|
||||
$bag1='modules/EcmProducts/bag1.png';
|
||||
$bag2='modules/EcmProducts/bag2.png';
|
||||
$_REQUEST['html']=1;
|
||||
$_GET['no_print']=1;
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="i.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="i.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricebooks_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="i.id='9999999999999999' and ";
|
||||
|
||||
$w=$GLOBALS['db']->query("select i.ecmproduct_id from ecmpricebooks_ecmproducts as i inner join ecmproducts as p on p.id=i.ecmproduct_id where ".$where." i.ecmpricebook_id='".$_REQUEST['record']."' and i.deleted='0' order by p.product_category_name asc,p.code asc");
|
||||
|
||||
include_once("include/html2fpdf/html2fpdf.php");
|
||||
include_once("modules/EcmProducts/productCard.php");
|
||||
$p=new HTML2FPDF();
|
||||
|
||||
$i=0;
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$i++;
|
||||
$id=$r['ecmproduct_id'];
|
||||
if($i%2>0)$p->AddPage();
|
||||
$p=printCatalogue($p,$id,$_REQUEST['language'],true,true,false);
|
||||
|
||||
}
|
||||
|
||||
$p->Output("Catalogue.pdf","D");
|
||||
?>
|
||||
6
import/EcmPriceBooks/deleteProductFromPriceBook.php
Normal file
6
import/EcmPriceBooks/deleteProductFromPriceBook.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?
|
||||
if($_REQUEST['id']){
|
||||
if($GLOBALS['db']->query("update ecmpricebooks_ecmproducts set date_modified='".date("Y-m-d H:i:s")."',modified_user_id='".$_SESSION['authenticated_user_id']."',deleted='1' where id='".$_REQUEST['id']."'"))print "ok";
|
||||
else print "no";
|
||||
}
|
||||
?>
|
||||
7
import/EcmPriceBooks/deleteProducts.php
Normal file
7
import/EcmPriceBooks/deleteProducts.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$e=explode("|",$_REQUEST['keys']);
|
||||
foreach($e as $ee){
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set date_modified='".date("Y-m-d H:i:s")."',modified_user_id='".$_SESSION['authenticated_user_id']."',deleted='1' where id='".$ee."' and ecmpricebook_id='".$_REQUEST['return_id']."'");
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['return_id']."&tab=items");
|
||||
?>
|
||||
425
import/EcmPriceBooks/excel.php
Normal file
425
import/EcmPriceBooks/excel.php
Normal file
@@ -0,0 +1,425 @@
|
||||
<?php
|
||||
/* Class for use with PHP4 scripts only*/
|
||||
|
||||
|
||||
/*
|
||||
* This is an Excel class to create,load,read,write,save and use some of the internal
|
||||
* functionalities of workbooks and sheets.
|
||||
* Tested with Windows 98 - MS Office 2000
|
||||
* Apache 1.3.9 PHP4.02 Running as CGI
|
||||
* (c) Alain M. Samoun 09/2000.
|
||||
* alain@sonic.net
|
||||
* Gnu GPL code (see www.fsf.org for more information).
|
||||
*/
|
||||
|
||||
|
||||
class Excel {
|
||||
|
||||
/* variables */
|
||||
|
||||
var $ex;
|
||||
var $pathin;
|
||||
var $pathout;
|
||||
var $workbook;
|
||||
var $sheet;
|
||||
var $visible;
|
||||
var $fformatin;
|
||||
var $fformatout;
|
||||
var $cell;
|
||||
var $rangesens;
|
||||
var $range;
|
||||
var $ext;
|
||||
var $oext;
|
||||
|
||||
|
||||
/* Constructor */
|
||||
|
||||
function excel()
|
||||
{
|
||||
#Instantiate Excel
|
||||
//$this->ex = new COM("Excel.sheet") or Die ("Did not instantiate Excel");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function XL($workbook,$pathin="",$sheet="sheet1")
|
||||
{
|
||||
|
||||
if ($workbook != "")
|
||||
{
|
||||
#Load the workbook
|
||||
$wkb = $this->ex->application->Workbooks->Open($pathin.$workbook) or Die ("Did not open $pathin $workbook");
|
||||
|
||||
}else{
|
||||
#New workbook
|
||||
$wkb = $this->ex->application->Workbooks->Add or Die ("Unable to add a workbook");
|
||||
}
|
||||
|
||||
if ($sheet != "")
|
||||
{
|
||||
#Activate the sheet
|
||||
$sheets = $wkb->Worksheets($sheet) or Die ("Unable to activate $sheet");
|
||||
|
||||
}else{
|
||||
#new sheet
|
||||
$sheet = "sheet1" ;
|
||||
|
||||
}
|
||||
#Excel Won't prompt the user when replacing or closing workbooks
|
||||
#Comment the line below if you want Excel to prompt
|
||||
$this->ex->application->DisplayAlerts = "False";
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function readrange($sheet="sheet1",$range)
|
||||
{
|
||||
|
||||
#Read all the cells in the range to $result and return it
|
||||
unset ($result);
|
||||
|
||||
$range = trim($range);
|
||||
#Determine start and end of range
|
||||
$tokstart = strtok($range,":");
|
||||
$tokend = strtok(":");
|
||||
if ($tokend =="")
|
||||
{
|
||||
#Read one single cell
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
#Select the cell
|
||||
$selcell = $sheets->Range($range);
|
||||
$selcell->activate;
|
||||
return $selcell->value;
|
||||
}
|
||||
#Read a range of cells
|
||||
#determine column and row numbers
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
$rgstart = $sheets->range($tokstart);
|
||||
$colstart = $rgstart->column;
|
||||
$rowstart = $rgstart->row;
|
||||
$rgend = $sheets->range($tokend);
|
||||
$colend = $rgend->column;
|
||||
$rowend = $rgend->row;
|
||||
if ($colstart>$colend or $rowstart>$rowend)
|
||||
{
|
||||
Print ("Notation Error! Cell Column/Row should be increasing.");
|
||||
return;
|
||||
}
|
||||
#Now read each cell
|
||||
|
||||
if ($colstart == $colend)
|
||||
{
|
||||
#Read Vertically
|
||||
$j=0;
|
||||
For ($i= $rowstart; $i<=$rowend; $i++)
|
||||
{
|
||||
|
||||
$selcell = $sheets->cells($i,$colstart);
|
||||
$selcell->activate;
|
||||
$result[$j] = $selcell->value;
|
||||
$j++;
|
||||
}
|
||||
}else
|
||||
{
|
||||
#Read horizontally
|
||||
$j=0;
|
||||
For ($i= $colstart; $i<=$colend; $i++)
|
||||
{
|
||||
|
||||
$selcell = $sheets->cells($rowstart,$i);
|
||||
$selcell->activate;
|
||||
$result[$j] = $selcell->value;
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function writerange($sheet="sheet1",$range,$value)
|
||||
{
|
||||
|
||||
#Fill up all the cells in the range with array
|
||||
|
||||
$range = trim($range);
|
||||
#Determine start and end of range
|
||||
$tokstart = strtok($range,":");
|
||||
$tokend = strtok(":");
|
||||
if ($tokend =="")
|
||||
{
|
||||
|
||||
# Write to a single cell in the active sheet
|
||||
$cell = trim($range);
|
||||
#Select the sheet
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
#Select the cell
|
||||
$selcell = $sheets->Range($cell);
|
||||
$selcell->activate;
|
||||
$selcell->value = $value;
|
||||
return;
|
||||
}
|
||||
|
||||
#determine column and row numbers
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
$rgstart = $sheets->range($tokstart);
|
||||
$colstart = $rgstart->column;
|
||||
$rowstart = $rgstart->row;
|
||||
$rgend = $sheets->range($tokend);
|
||||
$colend = $rgend->column;
|
||||
$rowend = $rgend->row;
|
||||
if ($colstart>$colend or $rowstart>$rowend)
|
||||
{
|
||||
Print ("Notation Error! Cell Column/Row should be increasing.");
|
||||
return;
|
||||
}
|
||||
#Now write each cell
|
||||
|
||||
if ($colstart == $colend)
|
||||
{
|
||||
#write Vertically
|
||||
$j=0;
|
||||
For ($i= $rowstart; $i<=$rowend; $i++)
|
||||
{
|
||||
|
||||
$selcell = $sheets->cells($i,$colstart);
|
||||
$selcell->activate;
|
||||
$selcell->value = $value[$j];
|
||||
$j++;
|
||||
}
|
||||
}else
|
||||
{
|
||||
#Write horizontally
|
||||
$j=0;
|
||||
For ($i= $colstart; $i<=$colend; $i++)
|
||||
{
|
||||
|
||||
$selcell = $sheets->cells($rowstart,$i);
|
||||
$selcell->activate;
|
||||
$selcell->value = $value[$j];
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
function saveas($workbook,$pathout,$ext)
|
||||
{
|
||||
|
||||
|
||||
#First get the file format code for the extension $ext
|
||||
$code = $this->fileformater($ext);
|
||||
$basefile = strtok($workbook,".");
|
||||
$newworkbook = $basefile."."."$ext";
|
||||
|
||||
|
||||
#If no prompt and file exists it will be replaced.
|
||||
|
||||
|
||||
#Save the current workbook as new workbook
|
||||
#The following line will work for converting spreadsheets file to xls
|
||||
#but if the original is an excel file and the new file another format
|
||||
#then it may not work because limitations of excel.(See excel doc)
|
||||
|
||||
$this->ex->Application->ActiveWorkbook->SaveAS($pathout.$newworkbook,$code);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function fileformater($ext)
|
||||
{
|
||||
|
||||
switch(strtolower($ext))
|
||||
{
|
||||
|
||||
case "slk":
|
||||
return 2;
|
||||
break;
|
||||
|
||||
case "xlt":
|
||||
return -4143;
|
||||
break;
|
||||
|
||||
case "txt":
|
||||
return -4158;
|
||||
break;
|
||||
|
||||
case "csv":
|
||||
return 6;
|
||||
break;
|
||||
|
||||
case "xlw":
|
||||
return 35;
|
||||
break;
|
||||
|
||||
case "w4k":
|
||||
return 38;
|
||||
break;
|
||||
|
||||
case "wq1":
|
||||
return 34;
|
||||
break;
|
||||
|
||||
case "prn":
|
||||
return -4158;
|
||||
break;
|
||||
|
||||
case "dif":
|
||||
return 9;
|
||||
break;
|
||||
|
||||
case "xla":
|
||||
return -4143;
|
||||
break;
|
||||
|
||||
case "wk3":
|
||||
return 32;
|
||||
break;
|
||||
|
||||
case "xls":
|
||||
return -4143;
|
||||
break;
|
||||
|
||||
case "htm":
|
||||
return 44;
|
||||
break;
|
||||
|
||||
case "wks":
|
||||
return 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -4143;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function XLTranslate($pathin,$pathout,$oext,$ext,$kill=0)
|
||||
{
|
||||
|
||||
#This function will translate automatically all spreadsheets files, with the
|
||||
#$oext extension, in the $pathin directory, to another spreadsheet file,
|
||||
#with the $ext extension, to the $pathout directory.
|
||||
#It will erase the original file if $kill switch = 1.
|
||||
#Limitations: Will work always when translating none excel files to
|
||||
#excel files(Extension=xl*) and with the translation xls->htm . It will
|
||||
#not generally work when translating excel files to other formats because
|
||||
#the questions asked by the excel program stop the script.
|
||||
|
||||
#Get all files in the source directory $pathin to the $filelist array
|
||||
chdir($pathin);
|
||||
$dir=dir (".");
|
||||
$i=1;
|
||||
while($file=$dir->read())
|
||||
{
|
||||
$filelist [$i] = $file;
|
||||
$i++;
|
||||
}
|
||||
$dir->close;
|
||||
|
||||
#Translate each file, with the original extension $oext, in the $filelist
|
||||
#to the needed extension $ext.
|
||||
|
||||
for ($i=1;$i<= sizeof($filelist); $i++)
|
||||
{
|
||||
|
||||
$file = $filelist[$i];
|
||||
|
||||
$basefile = strtok($file,".");
|
||||
$extension = strtok(".");
|
||||
|
||||
|
||||
if (strtolower($extension) == strtolower($oext))
|
||||
{
|
||||
echo "<BR> $file";
|
||||
$this->XL($file,$pathin,$sheet="");
|
||||
$this->saveas($file,$pathout,$ext,"");
|
||||
#Erase the original file if $kill=1
|
||||
if ($kill)
|
||||
{
|
||||
chmod ($file,0777);
|
||||
unlink ($pathin.$file);
|
||||
}
|
||||
#Close the new workbook
|
||||
$this->closeXL();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function closexl()
|
||||
{
|
||||
|
||||
#Close active workbook without prompt from Excel
|
||||
|
||||
$this->ex->application->ActiveWorkbook->Close("False");
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
function runfunction($funct,$arrayparam)
|
||||
{
|
||||
#Run and return value of an excel function
|
||||
|
||||
$params = implode(",",$arrayparam);
|
||||
|
||||
eval ("\$result = \$this->ex->application->$funct($params);");
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
Function runmacro($workbook,$macroname)
|
||||
{
|
||||
$this->ex->application->Run("$workbook!$macroname");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Function createhyperlink($sheet="sheet1",$cell,$hyperl)
|
||||
{
|
||||
#Not working as 9/2/00 4:57PM
|
||||
print "<br>link = $hyperl <br>";
|
||||
$sheets = $this->ex->Application->Worksheets($sheet);
|
||||
$sheets->activate;
|
||||
#Select the cell
|
||||
$selcell = $sheets->Range($cell);
|
||||
|
||||
$sheets->hyperlinks->add($selcell,$hyperl);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
function calculate($sheet="sheet1")
|
||||
{
|
||||
#Calculate (update) the current sheet
|
||||
$sheets = $this->ex->Application->Worksheets($sheet); #Select the sheet
|
||||
$sheets->activate;
|
||||
$sheets->Calculate;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} /* end of Excel class */
|
||||
|
||||
?>
|
||||
97
import/EcmPriceBooks/field_arrays.php
Normal file
97
import/EcmPriceBooks/field_arrays.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
$fields_array['EcmPriceBook'] = array (
|
||||
'column_fields' => Array(
|
||||
"id",
|
||||
"name",
|
||||
"date_entered",
|
||||
"date_modified",
|
||||
"modified_user_id",
|
||||
"assigned_user_id",
|
||||
"created_by",
|
||||
//NEW COLUMN FIELDS
|
||||
"active",
|
||||
"description",
|
||||
"exchange_rate_name",
|
||||
"exchange_rate_id",
|
||||
"account_name",
|
||||
"account_id",
|
||||
"lead_name",
|
||||
"lead_id",
|
||||
"price",
|
||||
"ecmlanguage",
|
||||
"currency_value",
|
||||
"archived"
|
||||
),
|
||||
|
||||
'list_fields' => Array(
|
||||
'id',
|
||||
'name',
|
||||
'assigned_user_name',
|
||||
'assigned_user_id',
|
||||
//NEW LIST_FIELDS
|
||||
'active',
|
||||
'description',
|
||||
'exchange_rate_name',
|
||||
'exchange_rate_id',
|
||||
'account_name',
|
||||
'account_id',
|
||||
'lead_name',
|
||||
'lead_id',
|
||||
'price',
|
||||
'ecmlanguage',
|
||||
'currency_value',
|
||||
'archived',
|
||||
),
|
||||
'required_fields' => array(
|
||||
'name'=>1
|
||||
),
|
||||
);
|
||||
?>
|
||||
25
import/EcmPriceBooks/getPriceBooks.php
Normal file
25
import/EcmPriceBooks/getPriceBooks.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?
|
||||
global $db;
|
||||
//if($_REQUEST['account_id'])$arr[]="(account_id='".$_REQUEST['account_id']."')";
|
||||
//if($_REQUEST['exchange_rate_id'])$arr[]="exchange_rate_id like '".$_REQUEST['exchange_rate_id']."'";
|
||||
//$where="where ".@implode(" and ",$arr);
|
||||
|
||||
$z="select id,name from ecmpricebooks ".$where." order by name asc";
|
||||
//print $z;
|
||||
$result = $db->query($z);
|
||||
$pbs='<select id="pricebook_id" name="pricebook_id"><option value="">standard</option>';
|
||||
$i=0;
|
||||
$stop=0;
|
||||
while(($row=$db->fetchByAssoc($result))!=null)
|
||||
{
|
||||
$pbs.='<option value="'.$row['id'].'"';
|
||||
if($_GET['pricebook_id']==$row['id'] && $stop==0){
|
||||
$pbs.=' selected';
|
||||
$stop=1;
|
||||
}
|
||||
$pbs.='>'.$row['name'].'</option>';
|
||||
$i++;
|
||||
}
|
||||
$pbs.='</select>';
|
||||
print $pbs;
|
||||
?>
|
||||
12
import/EcmPriceBooks/importpricebooks.php
Normal file
12
import/EcmPriceBooks/importpricebooks.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?
|
||||
$GLOBALS['db']->query("truncate table ecmpricebooks");
|
||||
$w=$GLOBALS['db']->query("select pricebook.* from pricebook inner join crmentity on crmentity.crmid=pricebook.pricebookid where crmentity.deleted='0'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)) {
|
||||
if($r['currency']==1)$er="bea4e045-359e-1d69-20af-48f2f98b0ca1";
|
||||
if($r['currency']==2)$er="def7187b-9f88-4e6f-a513-48f2f98d01ba";
|
||||
if($r['currency']==3)$er="-99";
|
||||
if($GLOBALS['db']->query("insert into ecmpricebooks values('".$r['pricebookid']."','".$r['bookname']."','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1','1','1','0','".$r['active']."','".$r['description']."','','".$er."','','','','','')"))print "ok";
|
||||
else print "no";
|
||||
print "<br>";
|
||||
}
|
||||
?>
|
||||
9
import/EcmPriceBooks/importproductrels.php
Normal file
9
import/EcmPriceBooks/importproductrels.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?
|
||||
$GLOBALS['db']->query("truncate table ecmpricebooks_ecmproducts");
|
||||
$w=$GLOBALS['db']->query("select * from pricebookproductrel");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)) {
|
||||
if($GLOBALS['db']->query("insert into ecmpricebooks_ecmproducts values('".create_guid()."','".$r['pricebookid']."','".$r['productid']."','0','".$r['listprice']."','1','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','1')"))print "ok";
|
||||
else print "no";
|
||||
print "<br>";
|
||||
}
|
||||
?>
|
||||
6
import/EcmPriceBooks/index.php
Normal file
6
import/EcmPriceBooks/index.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
global $current_user;
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
require_once('modules/EcmPriceBooks/ListView.php');
|
||||
|
||||
?>
|
||||
183
import/EcmPriceBooks/language/en_us.lang.php
Normal file
183
import/EcmPriceBooks/language/en_us.lang.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$mod_strings = array (
|
||||
//added 02.12.2009
|
||||
'LBL_PRODUCT_CARD' => 'Create Catalogue',
|
||||
'LBL_ARCHIVED'=>'Archived',
|
||||
'LBL_CURRENCY_VALUE'=>'Currency value',
|
||||
//added 01.09.2009
|
||||
'LBL_CV_EDIT'=>'Edit',
|
||||
'LBL_CV_DELETE'=>'Delete',
|
||||
'LBL_CV_CREATE'=>'Create Custom View',
|
||||
'LBL_CV_QUESTION'=>'Are you sure?',
|
||||
'LBL_ADD_PRODUCTS_TO_PRICEBOOK'=>'Add Products To Pricebook',
|
||||
//added 09.03.2009
|
||||
'LBL_ECMLANGUAGE'=>'Language',
|
||||
//added 19.02.2009
|
||||
'LBL_NO_ON_THIS_PRICEBOOK' => 'No on this Price Book',
|
||||
'LBL_LIST_PRICE_NAME' => 'Price',
|
||||
// added 19.01.2009
|
||||
'LBL_REMARKS_PL'=>'Remarks PL',
|
||||
'LBL_REMARKS_EN'=>'Remarks EN',
|
||||
'LBL_REMARKS_DE'=>'Remarks DE',
|
||||
|
||||
// added
|
||||
'LBL_RECIPIENT_CODE'=>'Recipient Code',
|
||||
// added 17.12.2008
|
||||
'LBL_ASCENDING'=>'Ascending',
|
||||
'LBL_DESCENDING'=>'Descending',
|
||||
'LBL_QUESTION_DELETE'=>'Are You sure to delete this record?',
|
||||
'LBL_UNIT_PRICE'=>'Unit Price',
|
||||
'LBL_MARGIN'=>'Margin',
|
||||
'LBL_LIST_PRICE_PRICEBOOK'=>'List Price',
|
||||
// added 12.12.2008
|
||||
'LBL_MARGIN'=>'Margin',
|
||||
'LBL_LIST_PRICE_ADD'=>'List Price',
|
||||
//added
|
||||
'LBL_DETAILS'=>'Details',
|
||||
'LBL_ITEMS'=>'Items',
|
||||
'LBL_PREVIEWPDF'=>'Preview PDF',
|
||||
'LBL_PREVIEWXLS'=>'Preview XLS',
|
||||
'LBL_EMAIL'=>'Email',
|
||||
'LBL_ACCOUNT_NAME'=>'Account name',
|
||||
'LBL_LEAD_NAME'=>'Lead name',
|
||||
'LBL_EDIT_PRICE'=>'Edit price',
|
||||
'LBL_INDEX'=>'Index',
|
||||
'LBL_PURCHASE_PRICE'=>'Purchase price',
|
||||
'LBL_LIST_PRICE'=>'List price',
|
||||
'LBL_MANUFACTURER'=>'Manufacturer',
|
||||
'LBL_ALL'=>'All',
|
||||
'LBL_PRODUCT_CATEGORY'=>'Product category',
|
||||
'LBL_PRODUCT_NAME'=>'Product name',
|
||||
'LBL_PRICEBOOK_NAME'=>'Price Book name',
|
||||
'LBL_UPDATE'=>'Update',
|
||||
|
||||
'LBL_LIST_PRICE' => 'Price',
|
||||
'LBL_ACCOUNT_NAME' => 'Account',
|
||||
// FOR SYSTEM USE
|
||||
'LBL_MODULE_NAME' => 'Price Books',
|
||||
'LBL_MODULE_TITLE' => 'Price Books: Home',
|
||||
'LBL_MODULE_ID' => 'Price Books',
|
||||
'LBL_SEARCH_FORM_TITLE' => 'Price Books Search',
|
||||
'LBL_LIST_FORM_TITLE' => 'Price Books List',
|
||||
'LBL_NEW_FORM_TITLE' => 'New Price Books',
|
||||
'LBL_ECMPRICEBOOKS' => 'Price Books:',
|
||||
'LBL_ECMPRICEBOOKS_SUBJECT' => 'Price Books Subject:',
|
||||
'LBL_SYSTEM_ID' => 'System ID',
|
||||
'LBL_LANGS' => 'Language',
|
||||
'LBL_SHOW_XLS'=>'Show XLS',
|
||||
'LBL_SHOW_XLS2'=>'Generate XLS',
|
||||
'LBL_SHOW_PDF'=>'Generate PDF',
|
||||
'LBL_LIST_PRICE_NAME_A' => 'Show price',
|
||||
'LBL_IMAGE_S'=>'Show image',
|
||||
// FOR LIST VIEW
|
||||
'LBL_LIST_NAME' => 'Name',
|
||||
'LBL_LIST_SUBJECT' => 'Subject',
|
||||
'LBL_LIST_LAST_MODIFIED' => 'Last Modified',
|
||||
'LBL_LIST_MY_ECMPRICEBOOKS' => 'My Assigned Price Books',
|
||||
'LBL_LIST_ASSIGNED_TO_NAME' => 'Assigned User',
|
||||
'LBL_LIST_ACTIVE' => 'Product active',
|
||||
'LBL_LIST_DESCRIPTION' => 'Description',
|
||||
'LBL_LIST_EXCHANGE_RATE_NAME' => 'Exchange rate',
|
||||
'LBL_LIST_EXCHANGE_RATE_ID' => 'Exchange rate',
|
||||
|
||||
// FOR NOTIFICATION POPUPS
|
||||
'NTC_DELETE_CONFIRMATION' => 'Are you sure you want to remove this ecmpricebook from this Price Book?',
|
||||
'NTC_REMOVE_INVITEE' => 'Are you sure you want to remove this contact from the Price Book?',
|
||||
'NTC_REMOVE_ACCOUNT_CONFIRMATION' => 'Are you sure you want to remove this ecmpricebook from this account?',
|
||||
'ERR_DELETE_RECORD' => 'A record number must be specified to delete the ecmpricebook.',
|
||||
|
||||
// FOR DEFAULT FIELDS
|
||||
'LBL_NAME' => 'Name:',
|
||||
'LBL_SUBJECT' => 'Name:',
|
||||
'LBL_CREATED_BY' => 'Created by:',
|
||||
'LBL_CREATED' => 'Created by:',
|
||||
'LBL_ASSIGNED_TO' => 'Assigned to:',
|
||||
'LBL_ASSIGNED_USER_ID' => 'Assigned To:',
|
||||
'LBL_DATE_ENTERED' => 'Date Created:',
|
||||
'LBL_DATE_CREATED' => 'Create Date:',
|
||||
'LBL_DATE_MODIFIED' => 'Last Modified',
|
||||
'LBL_MODIFIED_BY' => 'Last Modified by:',
|
||||
'LBL_MODIFIED' => 'Modified by:',
|
||||
'LBL_DATE_LAST_MODIFIED' => 'Modify Date:',
|
||||
|
||||
// FOR NEW FIELDS
|
||||
'LBL_ACTIVE' => 'Active',
|
||||
'LBL_DESCRIPTION' => 'Description',
|
||||
'LBL_EXCHANGE_RATE_NAME' => 'Exchange rate',
|
||||
'LBL_EXCHANGE_RATE_ID' => 'Exchange rate',
|
||||
|
||||
// FOR GROUPS
|
||||
'LBL_GROUP_MASTER' => 'PRICEBOOK INFORMATION',
|
||||
'LBL_GROUP_ACTIVE' => '',
|
||||
'LBL_GROUP_DESCRIPTION' => '',
|
||||
'LBL_GROUP_EXCHANGE_RATE_NAME' => '',
|
||||
'LBL_GROUP_EXCHANGE_RATE_ID' => '',
|
||||
// FOR SUBPANELS
|
||||
'LBL_ECMPRICEBOOKS_SUBPANEL_TITLE' => 'Price Books',
|
||||
'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities',
|
||||
'LBL_HISTORY_SUBPANEL_TITLE' => 'History',
|
||||
'LBL_ECMPRICEBOOKS' => 'Price Books',
|
||||
|
||||
// FOR MENU LABELS
|
||||
'LNK_NEW_ECMPRICEBOOKS' => 'Create Price Book',
|
||||
'LNK_LIST_ECMPRICEBOOK' => 'Price Books List',
|
||||
|
||||
// FOR MENU LINKS
|
||||
'LNK_NEW_ECMPRICEBOOK' => 'Create Price Books',
|
||||
'LNK_ECMPRICEBOOKS_LIST' => 'Price Books',
|
||||
'LNK_ECMPRICEBOOKS_REPORTS' => 'Price Books Reports',
|
||||
// FOR ADDITIONAL MENUS
|
||||
|
||||
// FOR DASHLETS
|
||||
'LBL_LIST_ECMPRICEBOOKS' => 'Price Books',
|
||||
);
|
||||
?>
|
||||
184
import/EcmPriceBooks/language/pl_pl.lang.php
Normal file
184
import/EcmPriceBooks/language/pl_pl.lang.php
Normal file
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$mod_strings = array (
|
||||
//added 01.09.2009
|
||||
'LBL_PRODUCT_CARD' => 'Generuj Katalog',
|
||||
'LBL_CV_EDIT'=>'Edytuj',
|
||||
'LBL_CV_DELETE'=>'Usuń',
|
||||
'LBL_CV_CREATE'=>'Utwórz Widok',
|
||||
'LBL_CV_QUESTION'=>'Na pewno?',
|
||||
'LBL_ADD_PRODUCTS_TO_PRICEBOOK'=>'Dodaj Produkty do Cennika',
|
||||
//added 09.03.2009
|
||||
'LBL_ECMLANGUAGE'=>'Jezyk',
|
||||
//added 19.02.2009
|
||||
'LBL_NO_ON_THIS_PRICEBOOK' => 'Nie na tym cenniku',
|
||||
'LBL_LIST_PRICE_NAME' => 'Cena',
|
||||
'LBL_LIST_PRICE_NAME_A' => 'Pokaż Cene',
|
||||
'LBL_CURRENCY_VALUE'=>'Cena',
|
||||
// added 19.01.2009
|
||||
'LBL_REMARKS_PL'=>'Uwagi PL',
|
||||
'LBL_REMARKS_EN'=>'Uwagi EN',
|
||||
'LBL_REMARKS_DE'=>'Uwagi DE',
|
||||
'LBL_LANGS' => 'Język',
|
||||
'LBL_IMAGE_S'=>'Pokaż zdjęcie',
|
||||
'LBL_SHOW_XLS'=>'Pokaż XLS',
|
||||
'LBL_SHOW_XLS2'=>'Generuj XLS',
|
||||
'LBL_SHOW_PDF'=>'Generuj PDF',
|
||||
|
||||
// added
|
||||
'LBL_RECIPIENT_CODE'=>'Kod Odbiorcy',
|
||||
// added 17.12.2008
|
||||
'LBL_ASCENDING'=>'Rosnaco',
|
||||
'LBL_DESCENDING'=>'Malejaco',
|
||||
'LBL_QUESTION_DELETE'=>'Jestes pewny, ze chcesz usunac ten rekord?',
|
||||
'LBL_UNIT_PRICE'=>'Cena Zakupu',
|
||||
'LBL_MARGIN'=>'Marza',
|
||||
'LBL_LIST_PRICE_PRICEBOOK'=>'Cena na Cenniku',
|
||||
// added 12.12.2008
|
||||
'LBL_MARGIN'=>'Marza',
|
||||
'LBL_LIST_PRICE_ADD'=>'Cena na Cenniku',
|
||||
//added
|
||||
'LBL_DETAILS'=>'Szczególy',
|
||||
'LBL_ITEMS'=>'Produkty',
|
||||
'LBL_PREVIEWPDF'=>'Podglad PDF',
|
||||
'LBL_PREVIEWXLS'=>'Podglad XLS',
|
||||
'LBL_EMAIL'=>'Email',
|
||||
'LBL_ACCOUNT_NAME'=>'Nazwa Firmy',
|
||||
'LBL_LEAD_NAME'=>'Wizytówka',
|
||||
'LBL_EDIT_PRICE'=>'Edytuj Cene',
|
||||
'LBL_INDEX'=>'Indeks',
|
||||
'LBL_PURCHASE_PRICE'=>'Cena Zakupu',
|
||||
'LBL_LIST_PRICE'=>'Cena na Cenniku',
|
||||
'LBL_MANUFACTURER'=>'Wytwórca',
|
||||
'LBL_ALL'=>'Wszystkie',
|
||||
'LBL_PRODUCT_CATEGORY'=>'Kategoria',
|
||||
'LBL_PRODUCT_NAME'=>'Nazwa Produktu',
|
||||
'LBL_PRICEBOOK_NAME'=>'Nazwa Cennika',
|
||||
'LBL_UPDATE'=>'Uaktualnij',
|
||||
|
||||
'LBL_LIST_PRICE' => 'Cena',
|
||||
'LBL_ACCOUNT_NAME' => 'Firma',
|
||||
// FOR SYSTEM USE
|
||||
'LBL_MODULE_NAME' => 'Cenniki',
|
||||
'LBL_MODULE_TITLE' => 'Cenniki: Strona Glówna',
|
||||
'LBL_MODULE_ID' => 'Cenniki',
|
||||
'LBL_SEARCH_FORM_TITLE' => 'Wyszukaj',
|
||||
'LBL_LIST_FORM_TITLE' => 'List Cenników',
|
||||
'LBL_NEW_FORM_TITLE' => 'Nowy Cennik',
|
||||
'LBL_ECMPRICEBOOKS' => 'Cenniki:',
|
||||
'LBL_ECMPRICEBOOKS_SUBJECT' => 'Tytul Cennika:',
|
||||
'LBL_SYSTEM_ID' => 'System ID',
|
||||
|
||||
// FOR LIST VIEW
|
||||
'LBL_LIST_NAME' => 'Nazwa',
|
||||
'LBL_LIST_SUBJECT' => 'Tytul',
|
||||
'LBL_LIST_LAST_MODIFIED' => 'Ostatnio Modyfikowane',
|
||||
'LBL_LIST_MY_ECMPRICEBOOKS' => 'Moje Przypisane Cenniki',
|
||||
'LBL_LIST_ASSIGNED_TO_NAME' => 'Przypisany Uzytkownik',
|
||||
'LBL_LIST_ACTIVE' => 'Produkt Aktywny',
|
||||
'LBL_LIST_DESCRIPTION' => 'Opis',
|
||||
'LBL_LIST_EXCHANGE_RATE_NAME' => 'Waluta',
|
||||
'LBL_LIST_EXCHANGE_RATE_ID' => 'Waluta',
|
||||
'LBL_PRICE_DETAIL_NAME'=> 'Cennik: Szczegóły',
|
||||
'LBL_PRICE_PRODUCT_NAME'=>'Cennik: Produkty',
|
||||
|
||||
// FOR NOTIFICATION POPUPS
|
||||
'NTC_DELETE_CONFIRMATION' => 'Czy napewno chcesz usunac Cennik?',
|
||||
'NTC_REMOVE_INVITEE' => 'Czy napewno chcesz usunac kontakt z Cennika?',
|
||||
'NTC_REMOVE_ACCOUNT_CONFIRMATION' => 'Czy napewno chcesz usunac Cennik z Firmy?',
|
||||
'ERR_DELETE_RECORD' => 'Musisz podac numer rekordu aby usunac.',
|
||||
|
||||
// FOR DEFAULT FIELDS
|
||||
'LBL_NAME' => 'Nazwa:',
|
||||
'LBL_SUBJECT' => 'Nazwa:',
|
||||
'LBL_CREATED_BY' => 'Utworzone przez:',
|
||||
'LBL_CREATED' => 'Utworzone przez:',
|
||||
'LBL_ASSIGNED_TO' => 'Przypisane do:',
|
||||
'LBL_ASSIGNED_USER_ID' => 'Przypisane do:',
|
||||
'LBL_DATE_ENTERED' => 'Data Utworzenia:',
|
||||
'LBL_DATE_CREATED' => 'Data Utworzenia:',
|
||||
'LBL_DATE_MODIFIED' => 'Ostatnio Modyfikowane',
|
||||
'LBL_MODIFIED_BY' => 'Ostatnio Modyfikowane przez:',
|
||||
'LBL_MODIFIED' => 'Modifikowane przez:',
|
||||
'LBL_DATE_LAST_MODIFIED' => 'Data Modyfikacji:',
|
||||
|
||||
// FOR NEW FIELDS
|
||||
'LBL_ACTIVE' => 'Aktywne',
|
||||
'LBL_DESCRIPTION' => 'Opis',
|
||||
'LBL_EXCHANGE_RATE_NAME' => 'Waluta',
|
||||
'LBL_EXCHANGE_RATE_ID' => 'Waluta',
|
||||
|
||||
// FOR GROUPS
|
||||
'LBL_GROUP_MASTER' => 'INFORMACJE O CENNIKU',
|
||||
'LBL_GROUP_ACTIVE' => '',
|
||||
'LBL_GROUP_DESCRIPTION' => '',
|
||||
'LBL_GROUP_EXCHANGE_RATE_NAME' => '',
|
||||
'LBL_GROUP_EXCHANGE_RATE_ID' => '',
|
||||
// FOR SUBPANELS
|
||||
'LBL_ECMPRICEBOOKS_SUBPANEL_TITLE' => 'Cenniki',
|
||||
'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Aktywnosci',
|
||||
'LBL_HISTORY_SUBPANEL_TITLE' => 'Historia',
|
||||
'LBL_ECMPRICEBOOKS' => 'Cenniki',
|
||||
|
||||
// FOR MENU LABELS
|
||||
'LNK_NEW_ECMPRICEBOOKS' => 'Utwórz Cennik',
|
||||
'LNK_LIST_ECMPRICEBOOK' => 'Lista Cenników',
|
||||
|
||||
// FOR MENU LINKS
|
||||
'LNK_NEW_ECMPRICEBOOK' => 'Utwórz Cennik',
|
||||
'LNK_ECMPRICEBOOKS_LIST' => 'Cenniki',
|
||||
'LNK_ECMPRICEBOOKS_REPORTS' => 'Raport Cenników',
|
||||
// FOR ADDITIONAL MENUS
|
||||
|
||||
// FOR DASHLETS
|
||||
'LBL_LIST_ECMPRICEBOOKS' => 'Cenniki',
|
||||
);
|
||||
?>
|
||||
57
import/EcmPriceBooks/layout_defs.php
Normal file
57
import/EcmPriceBooks/layout_defs.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
$smarty->debugging = true;
|
||||
$smarty->debugging_ctrl=($_SERVER['SERVER_NAME']=='localhost:8080')?'URL':'NONE';
|
||||
$layout_defs['EcmPriceBooks'] = array(
|
||||
//LIST OF WHAT SUBPANELS TO SHOW IN THE DETAILVIEW
|
||||
'subpanel_setup' => array(
|
||||
),
|
||||
);
|
||||
?>
|
||||
60
import/EcmPriceBooks/metadata/SearchFields.php
Normal file
60
import/EcmPriceBooks/metadata/SearchFields.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
$searchFields['EcmPriceBooks'] =
|
||||
array (
|
||||
'name' => array('query_type' => 'default'),
|
||||
'current_user_only'=> array('query_type' => 'default',
|
||||
'db_field' => array('assigned_user_id'),
|
||||
'my_items' => true
|
||||
),
|
||||
'archived'=>array('query_type'=>'default'),
|
||||
'assigned_user_id' => array('query_type' => 'default'),
|
||||
);
|
||||
?>
|
||||
84
import/EcmPriceBooks/metadata/additionalDetails.php
Normal file
84
import/EcmPriceBooks/metadata/additionalDetails.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/utils.php');
|
||||
|
||||
function additionalDetailsEcmPriceBook($fields) {
|
||||
static $mod_strings;
|
||||
global $app_strings;
|
||||
if(empty($mod_strings)) {
|
||||
global $current_language;
|
||||
$mod_strings = return_module_language($current_language, 'EcmPriceBooks');
|
||||
}
|
||||
|
||||
$overlib_string = '';
|
||||
|
||||
//BUILDER:START overlibstring
|
||||
if(!empty($fields['ACTIVE'])){
|
||||
$overlib_string .= '<b>'. $mod_strings['LBL_ACTIVE'] . '</b> <BR>' . substr($fields['ACTIVE'], 0, 300);
|
||||
if(strlen($fields['ACTIVE']) > 300) $overlib_string .= '...';
|
||||
$overlib_string .= '<br>';
|
||||
}
|
||||
if(!empty($fields['DESCRIPTION'])){
|
||||
$overlib_string .= '<b>'. $mod_strings['LBL_DESCRIPTION'] . '</b> <BR>' . substr($fields['DESCRIPTION'], 0, 300);
|
||||
if(strlen($fields['DESCRIPTION']) > 300) $overlib_string .= '...';
|
||||
$overlib_string .= '<br>';
|
||||
}
|
||||
//BUILDER:END overlibstring
|
||||
|
||||
return array(
|
||||
'fieldToAddTo' => 'NAME',
|
||||
'string' => $overlib_string,
|
||||
'editLink' => "index.php?action=EditView&module=EcmPriceBooks&return_module=EcmPriceBooks&record={$fields['ID']}",
|
||||
'viewLink' => "index.php?action=DetailView&module=EcmPriceBooks&return_module=EcmPriceBooks&record={$fields['ID']}");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
58
import/EcmPriceBooks/metadata/editviewdefs.php
Normal file
58
import/EcmPriceBooks/metadata/editviewdefs.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
$viewdefs['EcmPriceBooks']['EditView'] = array(
|
||||
'templateMeta'=>array(
|
||||
'form' => array(
|
||||
'buttons'=>array('SAVE', 'CANCEL'),
|
||||
'enctype'=> 'multipart/form-data',
|
||||
),
|
||||
'maxColumns'=>'2',
|
||||
'widths'=>array(
|
||||
array('label'=>'10','field'=>'30'),
|
||||
array('label'=>'10','field'=>'30'),
|
||||
),
|
||||
),
|
||||
'panels'=>array(
|
||||
'DEFAULT'=>array(
|
||||
array('name','assigned_user_name'),
|
||||
array('active','exchange_rate_id'),
|
||||
array('account_name','lead_name'),
|
||||
array('description','currency_value'),
|
||||
array('ecmlanguage'),
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
98
import/EcmPriceBooks/metadata/listviewdefs.php
Normal file
98
import/EcmPriceBooks/metadata/listviewdefs.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$listViewDefs['EcmPriceBooks'] = array(
|
||||
'NAME' => array(
|
||||
'width' => '20',
|
||||
'label' => 'LBL_NAME',
|
||||
'default' => true,
|
||||
'link' => true),
|
||||
|
||||
'ACTIVE' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_ACTIVE'),
|
||||
'DESCRIPTION' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_DESCRIPTION'),
|
||||
'ACCOUNT_ID' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_ACCOUNT_ID'),
|
||||
'ACCOUNT_NAME' => array(
|
||||
'width' => '10',
|
||||
'link' => true,
|
||||
'module' => 'Accounts',
|
||||
'id' => 'ACCOUNT_ID',
|
||||
'label' => 'LBL_ACCOUNT_NAME',
|
||||
'default' => true),
|
||||
'EXCHANGE_RATE_NAME' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_EXCHANGE_RATE_NAME',
|
||||
'default' => true),
|
||||
|
||||
'DATE_MODIFIED' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_DATE_MODIFIED',
|
||||
'default' => true),
|
||||
'DATE_ENTERED' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_DATE_ENTERED',
|
||||
'default' => true),
|
||||
'CREATED_BY_NAME' => array(
|
||||
'width' => '10',
|
||||
'label' => 'LBL_CREATED'),
|
||||
'ASSIGNED_USER_NAME' => array(
|
||||
'width' => '2',
|
||||
'label' => 'LBL_LIST_ASSIGNED_USER',
|
||||
'default' => true),
|
||||
'MODIFIED_USER_NAME' => array(
|
||||
'width' => '2',
|
||||
'label' => 'LBL_MODIFIED')
|
||||
);
|
||||
?>
|
||||
62
import/EcmPriceBooks/metadata/popupdefs.php
Normal file
62
import/EcmPriceBooks/metadata/popupdefs.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$popupMeta = array(
|
||||
'moduleMain' => 'EcmPriceBook',
|
||||
'varName' => 'ECMPRICEBOOK',
|
||||
'orderBy' => 'ecmpricebooks.name',
|
||||
'whereClauses' => array(
|
||||
'name' => 'ecmpricebooks.name',
|
||||
'exchange_rate_id' => 'ecmpricebooks.exchange_rate_id',
|
||||
'account_id' => 'ecmpricebooks.account_id',
|
||||
),
|
||||
'searchInputs' => array('name', 'name')
|
||||
);
|
||||
?>
|
||||
67
import/EcmPriceBooks/metadata/searchdefs.php
Normal file
67
import/EcmPriceBooks/metadata/searchdefs.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*
|
||||
* Created on May 29, 2007
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
$searchdefs['EcmPriceBooks'] = array(
|
||||
'templateMeta' => array(
|
||||
'maxColumns' => '3',
|
||||
'widths' => array('label' => '10', 'field' => '30'),
|
||||
),
|
||||
'layout' => array(
|
||||
'basic_search' => array(
|
||||
'name',
|
||||
array('name'=>'current_user_only', 'label'=>'LBL_CURRENT_USER_FILTER', 'type'=>'bool'),
|
||||
'description',
|
||||
'active',
|
||||
//array('name'=>'active','displayParams' => array('size' => 2)),
|
||||
//array('name'=>'pricebook_product_id','type'=>'hidden','value'=>$_REQUEST['pricebook_product_id']),
|
||||
|
||||
),
|
||||
'advanced_search' => array(
|
||||
'name',
|
||||
array('name' => 'assigned_user_id', 'type' => 'enum', 'label' => 'LBL_ASSIGNED_TO', 'function' => array('name' => 'get_user_array', 'params' => array(false))),
|
||||
'description',
|
||||
'active',
|
||||
//array('name'=>'active','displayParams' => array('size' => 2)),
|
||||
//array('name'=>'pricebook_product_id','type'=>'hidden','value'=>$_REQUEST['pricebook_product_id']),
|
||||
),
|
||||
),
|
||||
);
|
||||
?>
|
||||
76
import/EcmPriceBooks/metadata/studio.php
Normal file
76
import/EcmPriceBooks/metadata/studio.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$GLOBALS['studioDefs']['EcmPriceBooks'] = array(
|
||||
'LBL_DETAILVIEW'=>array(
|
||||
'template' => 'xtpl',
|
||||
'template_file' => 'modules/EcmPriceBooks/DetailView.html',
|
||||
'php_file' => 'modules/EcmPriceBooks/DetailView.php',
|
||||
'type' => 'DetailView',
|
||||
),
|
||||
'LBL_EDITVIEW'=>array(
|
||||
'template' => 'xtpl',
|
||||
'template_file' => 'modules/EcmPriceBooks/EditView.html',
|
||||
'php_file' => 'modules/EcmPriceBooks/EditView.php',
|
||||
'type' => 'EditView',
|
||||
),
|
||||
'LBL_LISTVIEW'=>array(
|
||||
'template' => 'listview',
|
||||
'meta_file' => 'modules/EcmPriceBooks/listviewdefs.php',
|
||||
'type' => 'ListView',
|
||||
),
|
||||
'LBL_SEARCHFORM'=>array(
|
||||
'template' => 'xtpl',
|
||||
'template_file' => 'modules/EcmPriceBooks/SearchForm.html',
|
||||
'php_file' => 'modules/EcmPriceBooks/ListView.php',
|
||||
'type' => 'SearchForm',
|
||||
),
|
||||
|
||||
);
|
||||
92
import/EcmPriceBooks/metadata/subpanels/ForProducts.php
Normal file
92
import/EcmPriceBooks/metadata/subpanels/ForProducts.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelAddToChangeOnPriceBook'),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
'fill_in_additional_fields' => true,
|
||||
|
||||
'list_fields' => array(
|
||||
'name'=>array(
|
||||
'vname' => 'LBL_LIST_NAME',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '50%',
|
||||
),
|
||||
'date_entered'=>array(
|
||||
'vname' => 'LBL_LIST_PRICE',
|
||||
'widget_class' => 'GetPriceFromPriceBook',
|
||||
'width' => '20%',
|
||||
),
|
||||
'assigned_user_name' => array (
|
||||
'name' => 'assigned_user_name',
|
||||
'vname' => 'LBL_LIST_ASSIGNED_TO_NAME',
|
||||
),
|
||||
'active' => array (
|
||||
'name' => 'active',
|
||||
'vname' => 'LBL_ACTIVE',
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '4%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '5%',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
82
import/EcmPriceBooks/metadata/subpanels/default.php
Normal file
82
import/EcmPriceBooks/metadata/subpanels/default.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelTopCreateButton'),
|
||||
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'EcmPriceBooks'),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
'list_fields' => array(
|
||||
'name'=>array(
|
||||
'vname' => 'LBL_LIST_NAME',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '50%',
|
||||
),
|
||||
'assigned_user_name' => array (
|
||||
'name' => 'assigned_user_name',
|
||||
'vname' => 'LBL_LIST_ASSIGNED_TO_NAME',
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '4%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '5%',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
118
import/EcmPriceBooks/productsOrder.php
Normal file
118
import/EcmPriceBooks/productsOrder.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?
|
||||
if($_REQUEST['reset']==1){
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set position=0 where ecmpricebook_id='".$_REQUEST['record']."'");
|
||||
header("Location: index.php?module=EcmPriceBooks&action=productsOrder&record=".$_REQUEST['record']);
|
||||
}
|
||||
if($_REQUEST['save']){
|
||||
$b=explode("|",$_REQUEST['sort_order']);
|
||||
$i=1;
|
||||
foreach($b as $box){
|
||||
if(strlen($box)>=1 && $box!="" && $box!=" ")$boxy[]=$box;
|
||||
}
|
||||
for($i=1;$i<=count($boxy);$i++){
|
||||
$z="update ecmpricebooks_ecmproducts set position='".$i."' where deleted='0' and ecmproduct_id='".$boxy[$i-1]."' and ecmpricebook_id='".$_REQUEST['record']."'";
|
||||
$GLOBALS['db']->query($z);
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['record']);
|
||||
}
|
||||
$z="select id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_REQUEST['record']."' and deleted='0'";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
$ile=mysql_num_rows($w);
|
||||
?>
|
||||
<script type="text/javascript" src="modules/EcmPriceBooks/moo1.2.js"></script>
|
||||
<script language="javascript">
|
||||
/* when the DOM is ready */
|
||||
window.addEvent('domready', function() {
|
||||
|
||||
/* create sortables */
|
||||
var sb = new Sortables('sortable-list', {
|
||||
/* set options */
|
||||
clone:true,
|
||||
revert: true,
|
||||
/* initialization stuff here */
|
||||
initialize: function() {
|
||||
|
||||
},
|
||||
/* once an item is selected */
|
||||
onStart: function(el) {
|
||||
el.setStyle('background','#add8e6');
|
||||
},
|
||||
/* when a drag is complete */
|
||||
onComplete: function(el) {
|
||||
el.setStyle('background','#ddd');
|
||||
//build a string of the order
|
||||
var sort_order = '';
|
||||
$$('#sortable-list li').each(function(li) { sort_order = sort_order + li.get('alt') + '|'; });
|
||||
$('sort_order').value = sort_order;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
li.sortme {
|
||||
padding:2px 2px;
|
||||
font-size: 9px;
|
||||
color:#000;
|
||||
cursor:move;
|
||||
list-style:none;
|
||||
width:700px;
|
||||
background:#ddd;
|
||||
margin:10px 0;
|
||||
border:1px solid #999;
|
||||
}
|
||||
#sortable-list{
|
||||
clear: none;
|
||||
float: left;
|
||||
margin: 2px;
|
||||
padding: 4px;
|
||||
}
|
||||
</style>
|
||||
<table width='100%' cellpadding='0' cellspacing='0' border='0' class='moduleTitle'><tr><td valign='top'>
|
||||
</td><td width='100%'><h2>Set Products Order:
|
||||
<?php
|
||||
$z="select name from ecmpricebooks where id='".$_REQUEST['record']."'";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
print " ".$r['name'];
|
||||
?>
|
||||
</h2></td>
|
||||
</tr></table>
|
||||
<form action="index.php?module=EcmPriceBooks&action=productsOrder&record=<?php echo $_REQUEST['record'];?>" method="post">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding-bottom: 2px;">
|
||||
<input type="submit" value="Save" name="save" class="button">
|
||||
<input type="button" value="Reset" name="reset" class="button" onclick="location.href='index.php?module=EcmPriceBooks&reset=1&action=productsOrder&record=<?php echo $_REQUEST['record'];?>';">
|
||||
<input type="button" value="Categories Order" name="cat_order" class="button" onclick="location.href='index.php?module=EcmPriceBooks&action=categoryOrder&record=<?php echo $_REQUEST['record'];?>';">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
|
||||
<tr>
|
||||
<td class="dataLabel">
|
||||
<ul id="sortable-list">
|
||||
<?php
|
||||
if(mysql_num_rows($GLOBALS['db']->query("select id from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."'"))==0)$zz="select id from ecmproductcategories where deleted='0' order by name asc";
|
||||
else $zz="select position,category_id as id from ecmpricebooks_ecmproducts_categories_sort where ecmpricebook_id='".$_REQUEST['record']."' order by position asc";
|
||||
$ww=$GLOBALS['db']->query($zz);
|
||||
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||||
?>
|
||||
<?
|
||||
$z="select e.id,e.position,e.ecmproduct_id,p.product_category_name,p.name,p.code from ecmpricebooks_ecmproducts as e inner join ecmproducts as p on p.id=e.ecmproduct_id where e.ecmpricebook_id='".$_REQUEST['record']."' and e.deleted='0' and p.product_category_id='".$rr['id']."' order by e.position asc,p.product_category_name asc,p.code asc";
|
||||
$w=$GLOBALS['db']->query($z);
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
print '<li class="sortme" alt="'.$r['ecmproduct_id'].'"><table><tr><td width="100"><b>'.$r['code'].'</b></td><td width="150">'.$r['product_category_name'].'</td><td>'.$r['name'].'</td></tr></table></li>';
|
||||
$sort_order[] = $r['ecmproduct_id'];
|
||||
}
|
||||
?>
|
||||
|
||||
<?php echo '<br>';} ?>
|
||||
</ul>
|
||||
<input type="hidden" name="sort_order" id="sort_order" value="<?php echo implode($sort_order,'|'); ?>" />
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
16
import/EcmPriceBooks/saveProductsOrder.php
Normal file
16
import/EcmPriceBooks/saveProductsOrder.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
set_time_limit(9999999);
|
||||
$b=explode(",",str_replace(" ","",$_GET['boxes']));
|
||||
$i=1;
|
||||
foreach($b as $box){
|
||||
if(strlen($box)>=1 && $box!="" && $box!=" ")$boxy[]=$box;
|
||||
}
|
||||
for($i=1;$i<=count($boxy);$i++){
|
||||
$z="update ecmpricebooks_ecmproducts set position='".$i."' where deleted='0' and ecmproduct_id='".$boxy[$i-1]."' and ecmpricebook_id='".$_REQUEST['record']."'";
|
||||
if($GLOBALS['db']->query($z))$ok=1;
|
||||
else $error="Error";
|
||||
}
|
||||
if($error)print $error;
|
||||
else print "Saved";
|
||||
exit;
|
||||
?>
|
||||
5
import/EcmPriceBooks/selectImages.php
Normal file
5
import/EcmPriceBooks/selectImages.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?
|
||||
if(!$_SESSION['pricebook_images_pdf'] || $_SESSION['pricebook_images_pdf']=="false")$_SESSION['pricebook_images_pdf']="true";
|
||||
else $_SESSION['pricebook_images_pdf']="false";
|
||||
print "1";
|
||||
?>
|
||||
2
import/EcmPriceBooks/showEmail.php
Normal file
2
import/EcmPriceBooks/showEmail.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<? session_start();$seid=$_SESSION['pricebook_id'];?>
|
||||
<iframe id=\'emailIFRAME\' style='border:none;width:100%;height:670px;' frameborder='no' src='index.php?module=EcmPriceBooks&action=Emails&to_pdf=1&bodyclass=tabForm&type=out&pricebook_id=<?print $seid;?>'>Yours browser not accept iframes!</iframe>
|
||||
1
import/EcmPriceBooks/showPDF.php
Normal file
1
import/EcmPriceBooks/showPDF.php
Normal file
@@ -0,0 +1 @@
|
||||
<iframe style='border:none;width:100%;height:500px;' frameborder='no' src='index.php?module=EcmPriceBooks&action=CreatePDF&to_pdf=1&disposition=I&images=<?print $_REQUEST['images'];?>'>Yours browser not accept iframes!</iframe>
|
||||
1
import/EcmPriceBooks/showXLS.php
Normal file
1
import/EcmPriceBooks/showXLS.php
Normal file
@@ -0,0 +1 @@
|
||||
<iframe style='border:none;width:100%;height:1200px;' frameborder='no' src='index.php?module=EcmPriceBooks&action=CreateXLS&to_pdf=1&disposition=D'>Yours browser not accept iframes!</iframe>
|
||||
5
import/EcmPriceBooks/showrecipientcode.php
Normal file
5
import/EcmPriceBooks/showrecipientcode.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?
|
||||
$w=$GLOBALS['db']->query("select recipient_code,ecmproduct_id,ecmpricebook_id from ecmpricebooks_ecmproducts where recipient_code!='' and recipient_code IS NOT NULL");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
print "update ecmpricebooks_ecmproducts set recipient_code='".$r['recipient_code']."' where ecmproduct_id='".$r['ecmproduct_id']."' and ecmpricebook_id='".$r['ecmpricebook_id']."';<br>";
|
||||
}
|
||||
82
import/EcmPriceBooks/subpanels/default.php
Normal file
82
import/EcmPriceBooks/subpanels/default.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
$subpanel_layout = array(
|
||||
'top_buttons' => array(
|
||||
array('widget_class' => 'SubPanelTopCreateButton'),
|
||||
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'EcmPriceBooks'),
|
||||
),
|
||||
|
||||
'where' => '',
|
||||
|
||||
'list_fields' => array(
|
||||
'name'=>array(
|
||||
'vname' => 'LBL_LIST_NAME',
|
||||
'widget_class' => 'SubPanelDetailViewLink',
|
||||
'width' => '50%',
|
||||
),
|
||||
'assigned_user_name' => array (
|
||||
'name' => 'assigned_user_name',
|
||||
'vname' => 'LBL_LIST_ASSIGNED_TO_NAME',
|
||||
),
|
||||
'edit_button'=>array(
|
||||
'widget_class' => 'SubPanelEditButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '4%',
|
||||
),
|
||||
'remove_button'=>array(
|
||||
'widget_class' => 'SubPanelRemoveButton',
|
||||
'module' => 'EcmPriceBooks',
|
||||
'width' => '5%',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
36
import/EcmPriceBooks/updatePrices.php
Normal file
36
import/EcmPriceBooks/updatePrices.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
$db = $GLOBALS['db'];
|
||||
|
||||
$res = $db->query("SELECT p.purchase_price as price, p.vat_value, pp.id, p.srp_price, p.srp_price_eur, pr.exchange_rate_id FROM ecmpricebooks_ecmproducts as pp INNER JOIN ecmproducts AS p ON p.id=pp.ecmproduct_id INNER JOIN ecmpricebooks as pr ON pp.ecmpricebook_id=pr.id WHERE pp.ecmpricebook_id='".$_REQUEST['record']."' and pp.deleted='0'");
|
||||
|
||||
//echo "SELECT p.purchase_price as price, p.vat_value, pp.id, p.srp_price, p.srp_price_eur, pp.exchange_rate_id FROM ecmpricebooks_ecmproducts as pp INNER JOIN ecmproducts AS p ON p.id=pp.ecmproduct_id WHERE pp.ecmpricebook_id='".$_REQUEST['record']."' and pp.deleted='0'";
|
||||
|
||||
|
||||
while ($row = $db->fetchByAssoc($res)) {
|
||||
if ($_REQUEST['type']=="1") {
|
||||
$price = $row['price'] * (1 + $_REQUEST['margin']/100);
|
||||
|
||||
if (intval($_REQUEST['discount'])>0)
|
||||
$price = $price - ($price * ($_REQUEST['discount']/100));
|
||||
|
||||
if (isset($_REQUEST['with_tax']) && $_REQUEST['with_tax']=='on')
|
||||
$price = $price * (1 + $row['vat_value']/100);
|
||||
}
|
||||
if ($_REQUEST['type']=="2") {
|
||||
if ($row['exchange_rate_id']=='-99')
|
||||
$price = $row['srp_price'];
|
||||
else $price = $row['srp_price_eur'];
|
||||
|
||||
if (!isset($_REQUEST['with_tax']))
|
||||
$price = round($price * 100 / (100 + $row['vat_value']),2);
|
||||
|
||||
if (intval($_REQUEST['discount'])>0)
|
||||
$price = $price - ($price * ($_REQUEST['discount']/100));
|
||||
|
||||
$db->query("update ecmpricebooks set currency_value='1' where id='".$_REQUEST['record']."'");
|
||||
//echo "update ecmpricebooks set currency_value='1' where id='".$_REQUEST['record']."'"; die();
|
||||
|
||||
}
|
||||
$db->query("UPDATE ecmpricebooks_ecmproducts SET price='".$price."' WHERE id='".$row['id']."'");
|
||||
}
|
||||
header("Location: index.php?module=EcmPriceBooks&action=DetailView&record=".$_REQUEST['record']."&tab=items");
|
||||
11
import/EcmPriceBooks/update_accounts_ecmproducts.php
Normal file
11
import/EcmPriceBooks/update_accounts_ecmproducts.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$w=$GLOBALS['db']->query("select id,account_id from ecmpricebooks where deleted='0'");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$ww=$GLOBALS['db']->query("select ecmproduct_id from ecmpricebooks_ecmproducts where deleted='0' and ecmpricebook_id='".$r['id']."'");
|
||||
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||||
if(mysql_num_rows($GLOBALS['db']->query("select id from accounts_ecmproducts where account_id='".$r['account_id']."' and ecmproduct_id='".$rr['ecmproduct_id']."' and deleted='0'"))==0){
|
||||
$GLOBALS['db']->query("insert into accounts_ecmproducts set id='".create_guid()."',account_id='".$r['account_id']."',ecmproduct_id='".$rr['ecmproduct_id']."',date_modified='".date("Y-m-d H:i:s")."',deleted='0'");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
6
import/EcmPriceBooks/updatepc.php
Normal file
6
import/EcmPriceBooks/updatepc.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?
|
||||
$w=$GLOBALS['db']->query("select productcategory,productcategoryen from productcategory");
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$GLOBALS['db']->query("update ecmproductcategories set name_en='".$r['productcategoryen']."' where name like '".$r['productcategory']."'");
|
||||
}
|
||||
?>
|
||||
7
import/EcmPriceBooks/updaterecipientcode.php
Normal file
7
import/EcmPriceBooks/updaterecipientcode.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?
|
||||
$w=$GLOBALS['db']->query("select recipientcode,pricebookid,productid from pricebookproductrel");
|
||||
print mysql_error();
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$GLOBALS['db']->query("update ecmpricebooks_ecmproducts set recipient_code='".$r['recipientcode']."' where ecmproduct_id='".$r['productid']."' and ecmpricebook_id='".$r['pricebookid']."'");
|
||||
}
|
||||
?>
|
||||
11
import/EcmPriceBooks/updateremarks.php
Normal file
11
import/EcmPriceBooks/updateremarks.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<textarea><?
|
||||
$w=$GLOBALS['db']->query("select * from ecmproduct_language");
|
||||
print mysql_error();
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
if($r['language']=="PL")print "update ecmpricebooks_ecmproducts set remarks_pl='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
|
||||
if($r['language']=="EN")print "update ecmpricebooks_ecmproducts set remarks_en='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
|
||||
if($r['language']=="DE")print "update ecmpricebooks_ecmproducts set remarks_de='".$r['remarks']."' where ecmproduct_id='".$r['ecmproduct_id']."'";
|
||||
print "<br>";
|
||||
}
|
||||
|
||||
?></textarea>
|
||||
386
import/EcmPriceBooks/vardefs.php
Normal file
386
import/EcmPriceBooks/vardefs.php
Normal file
@@ -0,0 +1,386 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
/*****************************************************************************
|
||||
* The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
|
||||
* Version 1.1 ("License"); You may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://opensource.org/licenses/rpl.php. Software distributed under the
|
||||
* License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
|
||||
* either express or implied.
|
||||
*
|
||||
* You may:
|
||||
* a) Use and distribute this code exactly as you received without payment or
|
||||
* a royalty or other fee.
|
||||
* b) Create extensions for this code, provided that you make the extensions
|
||||
* publicly available and document your modifications clearly.
|
||||
* c) Charge for a fee for warranty or support or for accepting liability
|
||||
* obligations for your customers.
|
||||
*
|
||||
* You may NOT:
|
||||
* a) Charge for the use of the original code or extensions, including in
|
||||
* electronic distribution models, such as ASP (Application Service
|
||||
* Provider).
|
||||
* b) Charge for the original source code or your extensions other than a
|
||||
* nominal fee to cover distribution costs where such distribution
|
||||
* involves PHYSICAL media.
|
||||
* c) Modify or delete any pre-existing copyright notices, change notices,
|
||||
* or License text in the Licensed Software
|
||||
* d) Assert any patent claims against the Licensor or Contributors, or
|
||||
* which would in any way restrict the ability of any third party to use the
|
||||
* Licensed Software.
|
||||
*
|
||||
* You must:
|
||||
* a) Document any modifications you make to this code including the nature of
|
||||
* the change, the authors of the change, and the date of the change.
|
||||
* b) Make the source code for any extensions you deploy available via an
|
||||
* Electronic Distribution Mechanism such as FTP or HTTP download.
|
||||
* c) Notify the licensor of the availability of source code to your extensions
|
||||
* and include instructions on how to acquire the source code and updates.
|
||||
* d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
|
||||
* reproduce, perform, modify, sublicense, and distribute your extensions.
|
||||
*
|
||||
* The Original Code is: CommuniCore
|
||||
* Olavo Farias
|
||||
* 2006-04-7 olavo.farias@gmail.com
|
||||
*
|
||||
* The Initial Developer of the Original Code is CommuniCore.
|
||||
* Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
$dictionary['EcmPriceBook'] = array(
|
||||
'table' => 'ecmpricebooks',
|
||||
'audited' => true,
|
||||
'comment' => 'EcmPriceBooks',
|
||||
'duplicate_merge' => true,
|
||||
'unified_search' => true,
|
||||
'fields' => array (
|
||||
//STANDARD FIELDS SECTION
|
||||
'id' => array (
|
||||
'name' => 'id',
|
||||
'vname' => 'LBL_ID',
|
||||
'type' => 'id',
|
||||
'required' => true,
|
||||
'reportable' => false,
|
||||
'comment' => 'Unique identifier'
|
||||
),
|
||||
'name' => array (
|
||||
'name' => 'name',
|
||||
'vname' => 'LBL_NAME',
|
||||
'type' => 'name',
|
||||
'required' => true,
|
||||
'dbType' => 'varchar',
|
||||
'len' => 255,
|
||||
'audited' => true,
|
||||
'unified_search' => true,
|
||||
'comment' => 'The short description of the record contents',
|
||||
'massupdate' => true,
|
||||
'merge_filter' => 'selected',
|
||||
),
|
||||
'date_entered' => array (
|
||||
'name' => 'date_entered',
|
||||
'vname' => 'LBL_DATE_ENTERED',
|
||||
'type' => 'datetime',
|
||||
'required' => true,
|
||||
'comment' => 'Date record created'
|
||||
),
|
||||
'date_modified' => array (
|
||||
'name' => 'date_modified',
|
||||
'vname' => 'LBL_DATE_MODIFIED',
|
||||
'type' => 'datetime',
|
||||
'required' => true,
|
||||
'comment' => 'Date record last modified'
|
||||
),
|
||||
'modified_user_id' => array (
|
||||
'name' => 'modified_user_id',
|
||||
'rname' => 'user_name',
|
||||
'id_name' => 'modified_user_id',
|
||||
'vname' => 'LBL_MODIFIED',
|
||||
'type' => 'assigned_user_name',
|
||||
'table' => 'modified_user_id_users',
|
||||
'isnull' => 'false',
|
||||
'dbType' => 'varchar',
|
||||
'len' => 36,
|
||||
'required' => true,
|
||||
'reportable' => true,
|
||||
'comment' => 'User who last modified record'
|
||||
),
|
||||
'assigned_user_id' =>
|
||||
|
||||
array (
|
||||
|
||||
'name' => 'assigned_user_id',
|
||||
|
||||
'rname' => 'user_name',
|
||||
|
||||
'id_name' => 'assigned_user_id',
|
||||
|
||||
'vname' => 'LBL_ASSIGNED_TO_ID',
|
||||
|
||||
'group' => 'assigned_user_name',
|
||||
|
||||
'type' => 'relate',
|
||||
|
||||
'table' => 'users',
|
||||
|
||||
'reportable' => true,
|
||||
|
||||
'Importable' => false,
|
||||
|
||||
'isnull' => 'false',
|
||||
|
||||
'dbType' => 'id',
|
||||
|
||||
'audited' => true,
|
||||
|
||||
'comment' => 'User ID assigned to record',
|
||||
|
||||
'duplicate_merge' => 'disabled',
|
||||
|
||||
'massupdate' => false,
|
||||
|
||||
),
|
||||
|
||||
'assigned_user_name' =>
|
||||
|
||||
array (
|
||||
|
||||
'name' => 'assigned_user_name',
|
||||
|
||||
'vname' => 'LBL_ASSIGNED_TO',
|
||||
|
||||
'type' => 'relate',
|
||||
|
||||
'reportable' => false,
|
||||
|
||||
'source' => 'non-db',
|
||||
|
||||
'table' => 'users',
|
||||
|
||||
'id_name' => 'assigned_user_id',
|
||||
|
||||
'module' => 'Users',
|
||||
|
||||
'duplicate_merge' => 'disabled',
|
||||
|
||||
'massupdate' => false,
|
||||
|
||||
),
|
||||
'created_by' => array (
|
||||
'name' => 'created_by',
|
||||
'rname' => 'user_name',
|
||||
'id_name' => 'created_by',
|
||||
'vname' => 'LBL_CREATED',
|
||||
'type' => 'assigned_user_name',
|
||||
'table' => 'created_by_users',
|
||||
'isnull' => 'false',
|
||||
'dbType' => 'varchar',
|
||||
'len' => 36,
|
||||
'comment' => 'User that created the record'
|
||||
),
|
||||
'created_by_link' => array (
|
||||
'name' => 'created_by_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'ecmpricebooks_created_by',
|
||||
'vname' => 'LBL_CREATED_BY_USER',
|
||||
'link_type' => 'one',
|
||||
'module' => 'Users',
|
||||
'bean_name' => 'User',
|
||||
'source' => 'non-db',
|
||||
),
|
||||
'modified_user_link' => array (
|
||||
'name' => 'modified_user_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'ecmpricebooks_modified_user',
|
||||
'vname' => 'LBL_MODIFIED_BY_USER',
|
||||
'link_type' => 'one',
|
||||
'module' => 'Users',
|
||||
'bean_name' => 'User',
|
||||
'source' => 'non-db',
|
||||
),
|
||||
'assigned_user_link' => array (
|
||||
'name' => 'assigned_user_link',
|
||||
'type' => 'link',
|
||||
'relationship' => 'ecmpricebooks_assigned_user',
|
||||
'vname' => 'LBL_ASSIGNED_TO_USER',
|
||||
'link_type' => 'one',
|
||||
'module' => 'Users',
|
||||
'bean_name' => 'User',
|
||||
'source' => 'non-db',
|
||||
'duplicate_merge' => 'enabled',
|
||||
'rname' => 'user_name',
|
||||
'id_name' => 'assigned_user_id',
|
||||
'table' => 'users',
|
||||
),
|
||||
'deleted' => array (
|
||||
'name' => 'deleted',
|
||||
'vname' => 'LBL_CREATED_BY',
|
||||
'type' => 'bool',
|
||||
'required' => true,
|
||||
'reportable' => false,
|
||||
'comment' => 'Record deletion indicator'
|
||||
),
|
||||
|
||||
//NEW FIELDS SECTION
|
||||
'active' => array(
|
||||
'type' => 'bool',
|
||||
'name' => 'active',
|
||||
'options' => 'ecmpricebooks_active_dom',
|
||||
'vname' => 'LBL_ACTIVE',
|
||||
'comment' => 'Product active',
|
||||
'default' => '1',
|
||||
),
|
||||
|
||||
'description' => array(
|
||||
'type' => 'text',
|
||||
'name' => 'description',
|
||||
'vname' => 'LBL_DESCRIPTION',
|
||||
'comment' => 'Description',
|
||||
'unified_search' => true,
|
||||
),
|
||||
|
||||
|
||||
'exchange_rate_id' =>
|
||||
array (
|
||||
'name' => 'exchange_rate_id',
|
||||
'type' => 'id',
|
||||
'group'=>'exchange_rate_id',
|
||||
'vname' => 'LBL_EXCHANGE_RATE_NAME',
|
||||
'function'=>array('name'=>'getCurrencyDropDown', 'returns'=>'html'),
|
||||
'reportable'=>false,
|
||||
'comment' => 'Currency used for display purposes'
|
||||
),
|
||||
'exchange_rate_name' =>
|
||||
array (
|
||||
'name' => 'exchange_rate_name',
|
||||
'vname' => 'LBL_EXCHANGE_RATE_NAME',
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
|
||||
'account_id' =>
|
||||
array (
|
||||
'name' => 'account_id',
|
||||
'rname' => 'name',
|
||||
'id_name' => 'account_id',
|
||||
'vname' => 'LBL_ACCOUNT_ID',
|
||||
'group' => 'product_category_name',
|
||||
'type' => 'relate',
|
||||
'table' => 'accounts',
|
||||
'reportable' => true,
|
||||
'Importable' => false,
|
||||
'isnull' => 'false',
|
||||
'dbType' => 'id',
|
||||
'audited' => true,
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
'account_name' =>
|
||||
array (
|
||||
'name' => 'account_name',
|
||||
'vname' => 'LBL_ACCOUNT_NAME',
|
||||
'type' => 'relate',
|
||||
'reportable' => false,
|
||||
//'source' => 'non-db',
|
||||
'table' => 'accounts',
|
||||
'id_name' => 'account_id',
|
||||
'module' => 'Accounts',
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
|
||||
'lead_id' =>
|
||||
array (
|
||||
'name' => 'lead_id',
|
||||
'rname' => 'name',
|
||||
'id_name' => 'lead_id',
|
||||
'vname' => 'LBL_LEAD_ID',
|
||||
'group' => 'lead_name',
|
||||
'type' => 'relate',
|
||||
'table' => 'leads',
|
||||
'reportable' => true,
|
||||
'Importable' => false,
|
||||
'isnull' => 'false',
|
||||
'dbType' => 'id',
|
||||
'audited' => true,
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
'lead_name' =>
|
||||
array (
|
||||
'name' => 'lead_name',
|
||||
'vname' => 'LBL_LEAD_NAME',
|
||||
'type' => 'relate',
|
||||
'reportable' => false,
|
||||
//'source' => 'non-db',
|
||||
'table' => 'leads',
|
||||
'id_name' => 'lead_id',
|
||||
'module' => 'Leads',
|
||||
'duplicate_merge' => 'disabled',
|
||||
'massupdate' => false,
|
||||
),
|
||||
|
||||
'price' => array (
|
||||
'name' => 'price',
|
||||
'type' => 'int',
|
||||
'len' => '1',
|
||||
'reportable'=>false,
|
||||
),
|
||||
'currency_value' => array (
|
||||
'name' => 'currency_value',
|
||||
'type' => 'decimal',
|
||||
'len' => '5,2',
|
||||
'vname'=>'LBL_CURRENCY_VALUE',
|
||||
'reportable'=>false,
|
||||
),
|
||||
'ecmlanguage' =>
|
||||
array(
|
||||
'name' => 'ecmlanguage',
|
||||
'vname' => 'LBL_ECMLANGUAGE',
|
||||
'type' => 'enum',
|
||||
'options' => 'ecmlanguages_dom',
|
||||
'required' => true,
|
||||
'len' => 35,
|
||||
'massupdate' => false,
|
||||
),
|
||||
/*'archived' =>
|
||||
array(
|
||||
'name'=>'archived',
|
||||
'vname'=>'LBL_ARCHIVED',
|
||||
'type'=>'bool',
|
||||
'len'=>1,
|
||||
),*/
|
||||
|
||||
|
||||
//FOR SUBPANELS
|
||||
|
||||
|
||||
),
|
||||
|
||||
//INDICES SECTION
|
||||
'indices' => array (
|
||||
array('name' =>'ecmpricebooksspk', 'type' =>'primary', 'fields'=>array('id')),
|
||||
array('name' =>'idx_ecmpricebooks_name', 'type' =>'index', 'fields'=>array('name'))
|
||||
)
|
||||
|
||||
//RELATIONSHIPS SECTION
|
||||
, 'relationships' => array (
|
||||
'ecmpricebooks_assigned_user' => array(
|
||||
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
|
||||
'rhs_module'=> 'EcmPriceBooks', 'rhs_table'=> 'ecmpricebooks', 'rhs_key' => 'assigned_user_id',
|
||||
'relationship_type'=>'one-to-many')
|
||||
|
||||
,'ecmpricebooks_modified_user' => array(
|
||||
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
|
||||
'rhs_module'=> 'EcmPriceBooks', 'rhs_table'=> 'ecmpricebooks', 'rhs_key' => 'modified_user_id',
|
||||
'relationship_type'=>'one-to-many')
|
||||
|
||||
,'ecmpricebooks_created_by' => array(
|
||||
'lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
|
||||
'rhs_module'=> 'EcmPriceBooks', 'rhs_table'=> 'ecmpricebooks', 'rhs_key' => 'created_by',
|
||||
'relationship_type'=>'one-to-many')
|
||||
|
||||
),
|
||||
//THIS FLAG ENABLES OPTIMISTIC LOCKING FOR SAVES FROM EDITVIEW
|
||||
'optimistic_locking'=>true,
|
||||
);
|
||||
?>
|
||||
253
import/EcmPriceBooks/views/view.list.php
Normal file
253
import/EcmPriceBooks/views/view.list.php
Normal file
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
/*********************************************************************************
|
||||
|
||||
* Description: This file is used to override the default Meta-data EditView behavior
|
||||
* to provide customization specific to the Calls module.
|
||||
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________..
|
||||
********************************************************************************/
|
||||
|
||||
require_once('include/MVC/View/views/view.list.php');
|
||||
|
||||
class EcmPriceBooksViewList extends ViewList{
|
||||
|
||||
function EcmPriceBooksViewList(){
|
||||
|
||||
parent::ViewList();
|
||||
}
|
||||
|
||||
function display(){
|
||||
if(!$this->bean->ACLAccess('list')){
|
||||
ACLController::displayNoAccess();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->module=$module = "EcmPriceBooks";
|
||||
$metadataFile = null;
|
||||
$foundViewDefs = false;
|
||||
if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
|
||||
$metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
|
||||
$foundViewDefs = true;
|
||||
}else{
|
||||
if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
|
||||
require_once('custom/modules/'.$module.'/metadata/metafiles.php');
|
||||
if(!empty($metafiles[$module]['listviewdefs'])){
|
||||
$metadataFile = $metafiles[$module]['listviewdefs'];
|
||||
$foundViewDefs = true;
|
||||
}
|
||||
}elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
|
||||
require_once('modules/'.$module.'/metadata/metafiles.php');
|
||||
if(!empty($metafiles[$module]['listviewdefs'])){
|
||||
$metadataFile = $metafiles[$module]['listviewdefs'];
|
||||
$foundViewDefs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
|
||||
$metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
|
||||
}
|
||||
require_once($metadataFile);
|
||||
|
||||
if(!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
|
||||
if(empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query']!='true')) {
|
||||
$this->saved_search = loadBean('SavedSearch');
|
||||
$this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
|
||||
$this->saved_search->populateRequest();
|
||||
}
|
||||
elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
|
||||
$_SESSION['LastSavedView'][$_REQUEST['module']] = '';
|
||||
unset($_REQUEST['saved_search_select']);
|
||||
unset($_REQUEST['saved_search_select_name']);
|
||||
}
|
||||
}
|
||||
|
||||
$storeQuery = new StoreQuery();
|
||||
if(!isset($_REQUEST['query'])){
|
||||
$storeQuery->loadQuery($this->module);
|
||||
$storeQuery->populateRequest();
|
||||
}else{
|
||||
$storeQuery->saveFromRequest($this->module);
|
||||
}
|
||||
|
||||
$seed = $this->bean;
|
||||
$lv = new ListViewSmarty();
|
||||
$displayColumns = array();
|
||||
if(!empty($_REQUEST['displayColumns'])) {
|
||||
foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
|
||||
if(!empty($listViewDefs[$module][$col]))
|
||||
$displayColumns[$col] = $listViewDefs[$module][$col];
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach($listViewDefs[$module] as $col => $params) {
|
||||
if(!empty($params['default']) && $params['default'])
|
||||
$displayColumns[$col] = $params;
|
||||
}
|
||||
}
|
||||
$params = array('massupdate' => true, 'export'=>false);
|
||||
|
||||
$lv->quickViewLinks = false;
|
||||
$lv->export = false;
|
||||
$lv->mergeduplicates = false;
|
||||
$lv->createEcmInvoiceOut = true;
|
||||
|
||||
if(!empty($_REQUEST['orderBy'])) {
|
||||
$params['orderBy'] = $_REQUEST['orderBy'];
|
||||
$params['overrideOrder'] = true;
|
||||
if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
|
||||
}
|
||||
|
||||
$lv->displayColumns = $displayColumns;
|
||||
|
||||
$this->seed = $seed;
|
||||
$this->module = $module;
|
||||
|
||||
$searchForm = null;
|
||||
|
||||
//search
|
||||
$view = 'basic_search';
|
||||
if(!empty($_REQUEST['search_form_view']))
|
||||
$view = $_REQUEST['search_form_view'];
|
||||
$headers = true;
|
||||
if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
|
||||
$headers = false;
|
||||
elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
|
||||
if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
|
||||
$view = 'advanced_search';
|
||||
}else {
|
||||
$view = 'basic_search';
|
||||
}
|
||||
}
|
||||
|
||||
$use_old_search = true;
|
||||
if(file_exists('modules/'.$this->module.'/SearchForm.html')){
|
||||
require_once('include/SearchForm/SearchForm.php');
|
||||
$searchForm = new SearchForm($this->module, $this->seed);
|
||||
}else{
|
||||
$use_old_search = false;
|
||||
require_once('include/SearchForm/SearchForm2.php');
|
||||
|
||||
if(!empty($metafiles[$this->module]['searchdefs']))
|
||||
require_once($metafiles[$this->module]['searchdefs']);
|
||||
elseif(file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
require_once('modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
|
||||
if (file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
{
|
||||
require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
}
|
||||
elseif (!empty($metafiles[$this->module]['searchdefs']))
|
||||
{
|
||||
require_once($metafiles[$this->module]['searchdefs']);
|
||||
}
|
||||
elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
|
||||
{
|
||||
require_once('modules/'.$this->module.'/metadata/searchdefs.php');
|
||||
}
|
||||
|
||||
if(!empty($metafiles[$this->module]['searchfields']))
|
||||
require_once($metafiles[$this->module]['searchfields']);
|
||||
elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
|
||||
require_once('modules/'.$this->module.'/metadata/SearchFields.php');
|
||||
|
||||
$searchForm = new SearchForm($this->seed, $this->module, $this->action);
|
||||
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', $view, $listViewDefs);
|
||||
|
||||
$searchForm->lv = $lv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($this->options['show_title']) && $this->options['show_title'] && (!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != "true")) {
|
||||
$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
|
||||
|
||||
echo "\n<p>\n";
|
||||
echo get_module_title($moduleName, $GLOBALS['mod_strings']['LBL_MODULE_TITLE'], true);
|
||||
echo "\n</p>\n";
|
||||
|
||||
}
|
||||
|
||||
$where = '';
|
||||
if(isset($_REQUEST['query']))
|
||||
{
|
||||
// we have a query
|
||||
if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
|
||||
$searchForm->populateFromArray($storeQuery->query);
|
||||
}
|
||||
else {
|
||||
$searchForm->populateFromRequest();
|
||||
}
|
||||
$where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
|
||||
if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
|
||||
$GLOBALS['log']->info("List View Where Clause: $where");
|
||||
}
|
||||
if($use_old_search){
|
||||
switch($view) {
|
||||
case 'basic_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayBasic($headers);
|
||||
break;
|
||||
case 'advanced_search':
|
||||
$searchForm->setup();
|
||||
$searchForm->displayAdvanced($headers);
|
||||
break;
|
||||
case 'saved_views':
|
||||
echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
|
||||
break;
|
||||
}
|
||||
|
||||
}else{
|
||||
echo $searchForm->display($headers);
|
||||
}
|
||||
if(!$headers)
|
||||
return;
|
||||
|
||||
if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
|
||||
// $this->processQuickSearch();
|
||||
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
|
||||
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
|
||||
echo get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
|
||||
echo $lv->display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
141
import/import/AjaxSearchQuery.php
Executable file
141
import/import/AjaxSearchQuery.php
Executable file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
if(isset($_REQUEST['as_inputSearch']) && $_REQUEST['as_inputSearch'] != '') {
|
||||
$AS_INPUTSEARCH = strtoupper($_REQUEST['as_inputSearch']);
|
||||
|
||||
$language_translate = array(
|
||||
'en_us' => 'en',
|
||||
'ge_ge' => 'de',
|
||||
'pl_pl' => 'pl'
|
||||
);
|
||||
|
||||
if(isset($_REQUEST['ecmlanguage']) && $_REQUEST['ecmlanguage'] != '') {
|
||||
if(isset($language_translate[$_REQUEST['ecmlanguage']]) && $language_translate[$_REQUEST['ecmlanguage']] != '') {
|
||||
$use_language = $language_translate[$_REQUEST['ecmlanguage']];
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT DISTINCT";
|
||||
$query .= " `pr`.`id`";
|
||||
$query .= ", `pr`.`code`";
|
||||
$query .= ", `pr`.`unit_id` as unitid";
|
||||
$query .= ", `pr`.`name`";
|
||||
$query .= ", `pr`.`selling_price`";
|
||||
$query .= ", `pr`.`purchase_price`";
|
||||
$query .= ", `pr`.`vat_id`";
|
||||
$query .= ", `pr`.`vat_name`";
|
||||
$query .= ", `pr`.`vat_value`";
|
||||
$query .= ", `pr`.`exchange_rate_id` as `currency_id`";
|
||||
$query .= ", `pr`.`product_category_id` as `category_id`";
|
||||
$query .= ", `pr`.`usage_unit_id` as `unit_id`";
|
||||
|
||||
/*if(isset($use_language)) {
|
||||
$query .= ", `pr_lang`.`short_description`";
|
||||
$query .= ", `pr_lang`.`long_description`";
|
||||
}*/
|
||||
|
||||
$query .= " FROM";
|
||||
$query .= " `ecmproducts` as `pr`";
|
||||
//if(isset($use_language))
|
||||
//$query .= " RIGHT JOIN `ecmproduct_language_".$use_language."_view` as `pr_lang` ON `pr`.`id` = `pr_lang`.`ecmproduct_id`";
|
||||
|
||||
$query .= " WHERE";
|
||||
$query .= " (";
|
||||
$query .= "UPPER(`pr`.`code`) LIKE '%$AS_INPUTSEARCH'";
|
||||
$query .= " || UPPER(`pr`.`code`) LIKE '$AS_INPUTSEARCH%'";
|
||||
$query .= " || UPPER(`pr`.`code`) LIKE '%$AS_INPUTSEARCH%'";
|
||||
$query .= " || UPPER(`pr`.`name`) LIKE '%$AS_INPUTSEARCH'";
|
||||
$query .= " || UPPER(`pr`.`name`) LIKE '$AS_INPUTSEARCH%'";
|
||||
$query .= " || UPPER(`pr`.`name`) LIKE '%$AS_INPUTSEARCH%'";
|
||||
|
||||
/*if(isset($use_language)) {
|
||||
$query .= " || UPPER(`pr_lang`.`long_description`) LIKE '%$AS_INPUTSEARCH'";
|
||||
$query .= " || UPPER(`pr_lang`.`long_description`) LIKE '%$AS_INPUTSEARCH%'";
|
||||
$query .= " || UPPER(`pr_lang`.`long_description`) LIKE '$AS_INPUTSEARCH%'";
|
||||
$query .= " || UPPER(`pr_lang`.`short_description`) LIKE '%$AS_INPUTSEARCH'";
|
||||
$query .= " || UPPER(`pr_lang`.`short_description`) LIKE '%$AS_INPUTSEARCH%'";
|
||||
$query .= " || UPPER(`pr_lang`.`short_description`) LIKE '$AS_INPUTSEARCH%'";
|
||||
}*/
|
||||
|
||||
$query .= ")";
|
||||
$query .= " AND `pr`.`deleted`='0'";
|
||||
$result = $GLOBALS['db']->query($query);
|
||||
|
||||
|
||||
global $sugar_config;
|
||||
$defaultCurrency = $sugar_config['default_currency_symbol'];
|
||||
$currencies = array ( -99 => $defaultCurrency );
|
||||
|
||||
$arr = array();
|
||||
if($result)
|
||||
while($row = $GLOBALS['db']->fetchByAssoc($result)) {
|
||||
$op = new EcmStockOperation();
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select quantity from ecmstockstates where product_id='".$row['id']."' and stock_id='".$_REQUEST['stock_id']."' and deleted='0'"));
|
||||
$row['on_stock']=$op->getStock($row['id'], $_REQUEST['stock_id']);
|
||||
if ($row['category_id']=='d7f876b0-1a3d-43a1-7c9b-511ba40df3d1') $row['on_stock'] ='-';
|
||||
//$row['on_stock']=number_format($r['quantity'],0,"","");
|
||||
//$row['on_stock']=5;
|
||||
$row['unit_id']=$row['unitid'];
|
||||
$row['unit_name']=$app_list_strings['ecmproducts_unit_dom'][$row['unitid']];
|
||||
|
||||
$row['price'] = $row['srp_price'];
|
||||
|
||||
if (!$row['price']) $row['price'] = 0;
|
||||
|
||||
$row['purchase_price'] = format_number($row['purchase_price']);
|
||||
|
||||
$row['selling_price'] = format_number($row['selling_price']);
|
||||
|
||||
|
||||
if(array_key_exists($row['currency_id'],$currencies))
|
||||
$row['currency_symbol'] = $currencies[$row['currency_id']];
|
||||
else {
|
||||
|
||||
$query = "SELECT symbol FROM currencies WHERE id='".$row['currency_id']."' AND deleted=0;";
|
||||
$result2 = $GLOBALS['db']->query($query);
|
||||
if($result2) {
|
||||
$row2 = $GLOBALS['db']->fetchByAssoc($result2);
|
||||
if($row2) {
|
||||
$currencies[$id] = $row2['symbol'];
|
||||
$row['currency_symbol'] = $row2['symbol'];
|
||||
} else $row['currency_symbol'] = '';
|
||||
} else $row['currency_symbol'] = '';
|
||||
|
||||
}
|
||||
/*
|
||||
if(isset($use_language) && $use_language!="pl") {/*
|
||||
if(strpos(strtoupper($row['long_description']), $AS_INPUTSEARCH) !== false)
|
||||
$row['name'] = $row['long_description'];
|
||||
else
|
||||
if(strpos(strtoupper($row['short_description']), $AS_INPUTSEARCH) !== false)
|
||||
$row['name'] = $row['short_description'];
|
||||
else
|
||||
if(strpos(strtoupper($row['name']), $AS_INPUTSEARCH) === false || strpos(strtoupper($row['code']), $AS_INPUTSEARCH) !== false) {
|
||||
if(isset($row['long_description']) && $row['long_description'] != '')
|
||||
$row['name'] = $row['long_description'];
|
||||
else
|
||||
if(isset($row['short_description']) && $row['short_description'] != '')
|
||||
$row['name'] = $row['short_description'];
|
||||
}
|
||||
unset($row['long_description'], $row['short_description']);/
|
||||
if($row['long_description'])$row['name']=$row['long_description'];
|
||||
elseif(!$row['long_description'] && $row['short_description'])$row['name']=$row['short_description'];
|
||||
elseif(!$row['long_description'] && !$row['short_description'])$row['name']=$row['name'];
|
||||
unset($row['long_description'],$row['short_desciption']);
|
||||
|
||||
}
|
||||
*/
|
||||
$arr[] = $row;
|
||||
|
||||
}
|
||||
|
||||
if(count($arr) > 0) {
|
||||
$json = getJSONobj();
|
||||
echo str_replace(""", '\"', $json->encode($arr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
4
import/import/aa.php
Executable file
4
import/import/aa.php
Executable file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
include_once("helper.php");
|
||||
echo create_guid();
|
||||
?>
|
||||
83
import/import/accounts.php
Executable file
83
import/import/accounts.php
Executable file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
die();
|
||||
include_once("/var/www/html/e5new/config.php");
|
||||
global $sugar_config;
|
||||
$db= new mysqli($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
|
||||
//users id array
|
||||
//old_id => new_id
|
||||
$users = array(
|
||||
//kl
|
||||
'4' => '40e80a1d-6fd9-83d1-e61e-5236e3e39979',
|
||||
//mf
|
||||
'5' => 'be5b7acb-cb35-186b-7229-523818723665',
|
||||
//jj
|
||||
'3' => '755927dd-4c7e-24de-38b1-524ad5c47b89',
|
||||
//mz
|
||||
'f1963700-4249-2022-1022-4e393326a7b4' => '1',
|
||||
//s8 - bg
|
||||
'812d6ca4-77c8-8908-f695-4c0cec0f8a56' => 'b5810ca7-fa8f-8aef-b694-5236e3c983c9',
|
||||
//s2 - pg
|
||||
'dbf183f4-70da-2e17-1745-4acb40d0294b' => 'c054ae2d-7d94-5a74-28a0-5236e3d1493e',
|
||||
//s1 - s1
|
||||
'c06124a2-9623-5020-dcd8-4f718387a989' => '41949394-ef36-a332-df4f-524418147444',
|
||||
//s7 - s7
|
||||
'adb13cf1-6db5-7032-6086-4c0cec9d6386' => '231e3dc2-c567-33e7-1aae-52441966e742',
|
||||
//s4 - ja
|
||||
'657e23f8-dc76-a0b2-89b1-515aa91fa90e' => '1051daeb-d468-f7eb-89a1-52381821bc8d',
|
||||
//l.lisinska - ll
|
||||
'12a80231-c3a6-52a3-aed1-51a47dfcf849' => 'e3a315cd-5752-4e83-aa73-5236e2a2d39c',
|
||||
//d.piotrowska - dp
|
||||
'408fb7aa-98f4-ff78-0efd-4bc8007660e5' => 'c397ef4d-ddad-ea86-3161-5236e3b16caf',
|
||||
//a.drozdowska - ad
|
||||
'ca868d4a-9821-9707-d59c-51112661e4f9' => '54eb00ac-d71a-1749-1111-524ad6b2886a',
|
||||
//magazyn - magazyn
|
||||
'94e62fc0-3c5b-fbd9-d61e-4923f30ba6ea' => '6cb17cef-cf4c-e5db-57bc-52455441b1c1',
|
||||
//magazyn1 - finanse
|
||||
'ce224fce-3a28-d3aa-f005-4923f36fcaf2' => 'b991adbb-ddad-5d5d-8a49-52455568184a',
|
||||
//r.kubiak - rk
|
||||
'23cae697-a9ad-69b0-a305-51932bb22ca2' => '74279c89-5ef5-01da-7018-524553519e26',
|
||||
//grafik - ba
|
||||
'84bbd698-5424-2991-369e-4b9e5441d77e' => '76a7515b-8584-64fc-105e-524554ceecd7',
|
||||
);
|
||||
|
||||
$other_user = '82d4af6b-f416-7ede-57f6-524ad799b1d7'; //Pan Import
|
||||
$db->query("use e5crm");
|
||||
$res = $db->query("SELECT * FROM accounts WHERE deleted='0'");
|
||||
|
||||
$accounts = array();
|
||||
$mails = $array();
|
||||
|
||||
while ($row = $db->fetchByAssoc($res)) {
|
||||
|
||||
if ($users[$row['created_by']])
|
||||
$created_by = $users[$row['created_by']];
|
||||
else
|
||||
$created_by=$other_user;
|
||||
|
||||
if ($users[$row['modified_user_id']])
|
||||
$modified_user_id = $users[$row['modified_user_id']];
|
||||
else
|
||||
$modified_user_id=$other_user;
|
||||
|
||||
if ($users[$row['assigned_user_id']])
|
||||
$assigned_user_id = $users[$row['assigned_user_id']];
|
||||
else
|
||||
$assigned_user_id=$other_user;
|
||||
|
||||
//fields
|
||||
$fields = array(
|
||||
'id', 'created_by', 'modified_user_id', 'assigned_user_id', 'date_entered', 'date_modified'
|
||||
);
|
||||
|
||||
//query to insert account
|
||||
$q = "
|
||||
INSERT INTO accounts VALUES (
|
||||
'id'
|
||||
);
|
||||
";
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
273
import/import/cfk.php
Executable file
273
import/import/cfk.php
Executable file
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
ini_set('display_errors',0);
|
||||
set_time_limit(9999999999);
|
||||
ini_set('memory_limit', '-1');
|
||||
include_once("class.dbf.php");
|
||||
include_once("../config.php");
|
||||
include_once("helper.php");
|
||||
global $sugar_config;
|
||||
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_query("set character set utf8;");
|
||||
mysql_query("truncate table ecminvoiceouts");
|
||||
mysql_query("truncate table ecminvoiceoutitems");
|
||||
|
||||
|
||||
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
function getnr($nr_sys){
|
||||
//echo $nr_sys;
|
||||
$dbfi = new dbf_class('dbf/_INDEKSY.DBF');
|
||||
$num_rec=$dbfi->dbf_num_rec;
|
||||
for($i=0;$i<$num_rec;$i++){
|
||||
$indeks=$dbfi->getRowAssoc($i);
|
||||
|
||||
//echo $indeks['INDEKS']."\r\n";
|
||||
if ($indeks['INDEKS']==$nr_sys)
|
||||
{
|
||||
//echo $indeks['INDEKS'];
|
||||
return ch($indeks['NR_SYSTEM']);
|
||||
}
|
||||
}
|
||||
return 'BRAK INDEKSU';
|
||||
}
|
||||
|
||||
function addFk($row,$i,$stock_id){
|
||||
|
||||
$r=mysql_fetch_array(mysql_query("select id,name from ekomer.accounts where index_dbf2 = '".trim($row['INDEKS_KON'])."' and deleted='0'"));
|
||||
$r2=mysql_fetch_array(mysql_query("select id,name from ekomer.ecminvoiceouts where name like 'FK ".trim($row['NR_FK'])."'"));
|
||||
//echo "<br>select id,name from ekomer.ecminvoiceouts where name like 'FK ".trim($row['NR_FK'])."'<br>";
|
||||
//echo $r['id']."\n\r";
|
||||
$parent_id=$r['id'];
|
||||
$parent_name=$r['name'];
|
||||
$rd=$row['DATA'];
|
||||
$sd=$row['DATA_SPRZ'];
|
||||
$a1=explode(" ",$row['ADRES2']);
|
||||
$pre="KF";
|
||||
$id=create_guid();
|
||||
|
||||
if($row['ANULOWANA']=="F" || $row['ANULOWANA']=="")
|
||||
$type = '0';
|
||||
else
|
||||
$type = '1';
|
||||
|
||||
$year = substr($row['DATA_SPRZ'], 0, 4);
|
||||
if (($year=='2012') || ($year=='2011') || ($year=='2010'))
|
||||
//$type = 'normal';
|
||||
|
||||
$waluta = "PLN";
|
||||
$subtotal = $row['ROZN_NETTO'];
|
||||
$total = $row['ROZN_BRUT'];
|
||||
$kurs = 0;
|
||||
if ($row['KURS']!=0) {
|
||||
$kurs = $row['KURS'];
|
||||
$waluta = "EUR";
|
||||
}
|
||||
$arr=array(
|
||||
"id"=>$id,
|
||||
"name"=>$pre." ".trim($row['NR_KF']),
|
||||
"description"=>ch($row['TYT1'])." ".ch($row['TYT2']),
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"modified_user_id"=>"d9c0007b-1247-5e82-31b6-4f168a01d290",
|
||||
"assigned_user_id"=>"d9c0007b-1247-5e82-31b6-4f168a01d290",
|
||||
"created_by"=>"d9c0007b-1247-5e82-31b6-4f168a01d290",
|
||||
"deleted"=>0,
|
||||
"number"=>($i+1),
|
||||
"document_no"=>$pre." ".trim($row['NR_KF']),
|
||||
"parent_type"=>"Accounts",
|
||||
"parent_name"=>$parent_name,
|
||||
"parent_id"=>$parent_id,
|
||||
"type"=>"correct",
|
||||
"ecminvoiceout_id"=>$r2['id'],
|
||||
"ecminvoiceout_name"=>$r2['name'],
|
||||
"status"=>"accepted",
|
||||
"register_date"=>$rd[0].$rd[1].$rd[2].$rd[3]."-".$rd[4].$rd[5]."-".$rd[6].$rd[7],
|
||||
"sell_date"=>$sd[0].$sd[1].$sd[2].$sd[3]."-".$sd[4].$sd[5]."-".$sd[6].$sd[7],
|
||||
"payment_date"=>$rd[0].$rd[1].$rd[2].$rd[3]."-".$rd[4].$rd[5]."-".$rd[6].$rd[7],
|
||||
"parent_address_street"=>ch(str_replace("'","",$row['ADRES2'])),
|
||||
"parent_address_city"=>ch($a1[1]),
|
||||
"parent_address_postalcode"=>$a1[0],
|
||||
"to_nip"=>"",
|
||||
"subtotal"=>$subtotal,
|
||||
"total"=>$total,
|
||||
"discount"=>0,
|
||||
"to_vatid"=>"",
|
||||
"to_is_vat_free"=>"",
|
||||
"header_text"=>"",
|
||||
"footer_text"=>"",
|
||||
"ads_text"=>"",
|
||||
"template_id"=>"ef0c4dea-ddf3-de51-9d08-512257d4b675",
|
||||
"template_name"=>"BSL Truck",
|
||||
"accepted"=>"",
|
||||
"email_id"=>"",
|
||||
"ecmlanguage"=>"pl_pl",
|
||||
"ecmpaymentcondition_id"=>"",
|
||||
"ecmpaymentcondition_text"=>"",
|
||||
"wz_id"=>"",
|
||||
"parent_contact_name"=>"",
|
||||
"parent_contact_title"=>"",
|
||||
"contact_id"=>"",
|
||||
"currency_id"=>$waluta,
|
||||
"currency_value"=>$kurs,
|
||||
"deleted"=>$type,
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
|
||||
mysql_query("set character set utf8;");
|
||||
$query = "insert into ekomer.ecminvoiceouts set ".implode(",",$in).";\n";
|
||||
echo $query;
|
||||
//echo $query.';\n';
|
||||
return $id;
|
||||
}
|
||||
|
||||
function addProductLine($id,$i,$r){
|
||||
$vats=array(
|
||||
0=>"9b783d21-5548-6653-e1d6-49610eb3f9dd",
|
||||
22=>"9c592a4a-2de0-1fa3-e082-494aeceb122c",
|
||||
7=>"bf3a5fec-435f-af22-024a-4958b51863c8",
|
||||
'OO'=>"d7a2073e-44ca-7d52-cc02-5301eedef40f",
|
||||
23=>"93295ab1-bc7d-74a3-5644-4d21770fa33b",
|
||||
|
||||
);
|
||||
mysql_query("SET NAMES 'utf8'");
|
||||
mysql_query("set character set utf8;");
|
||||
//$text = str_replace ("(l|ł)","l" , $r['INDEKS']);
|
||||
//$text = str_replace ("(L|Ł)","L" , $r['INDEKS']);
|
||||
//$rr=mysql_fetch_array(mysql_query("select id from ecmproducts where index_dbf like '%".$text."%' and deleted='0'"));
|
||||
//$rr=mysql_fetch_array(mysql_query("select id from ecmproducts where index_dbf like '%".$r['INDEKS']."%' and deleted='0'"));
|
||||
//$pid=$rr['id'];
|
||||
$rr=mysql_fetch_array(mysql_query("select id from ekomer.ecmproducts where code ='".$r['INDEKS']."' and deleted='0'"));
|
||||
$pid=$rr['id'];
|
||||
//echo 'id do produ: '.$pid;
|
||||
//if ($rr['id'] == '') $pid=getnr($r['INDEKS']);
|
||||
$iid=create_guid();
|
||||
if (($r['VAT']=='7') || ($r['VAT']=='8')) $vat_tmp = $vats[7];
|
||||
elseif (($r['VAT']=='22') || ($r['VAT']=='23')) $vat_tmp = $vats[22];
|
||||
else $vat_tmp = $vats[0];
|
||||
|
||||
//repair prices (remove ',')
|
||||
$r['CENA_SPRZ'] = trim(str_replace(",", ".", $r['CENA_SPRZ']));
|
||||
$r['CENA_POCZ'] = trim(str_replace(",", ".", $r['CENA_POCZ']));
|
||||
$r['WARTOSC'] = trim(str_replace(",", ".", $r['WARTOSC']));
|
||||
$r['RABAT'] = trim(str_replace(",", ".", $r['RABAT']));
|
||||
$r['CENA_EWID'] = trim(str_replace(",", ".", $r['CENA_EWID']));
|
||||
$subtotal = $r['WARTOSC']-$r['POD_WART'];
|
||||
$arr=array(
|
||||
"id"=>$iid,
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"modified_user_id"=>"d9c0007b-1247-5e82-31b6-4f168a01d290",
|
||||
"assigned_user_id"=>"d9c0007b-1247-5e82-31b6-4f168a01d290",
|
||||
"created_by"=>"d9c0007b-1247-5e82-31b6-4f168a01d290",
|
||||
"deleted"=>0,
|
||||
"ecminvoiceout_id"=>$id,
|
||||
"ecmproduct_id"=>$pid,
|
||||
"position"=>$i,
|
||||
"code"=>ch(str_replace("'","",$r['INDEKS'])),
|
||||
"name"=>ch(str_replace("'","",$r['NAZWA'])),
|
||||
"quantity"=>$r['ILOSC'],
|
||||
"subprice"=>$r['CENA_SPRZ'],
|
||||
"total"=>$r['WARTOSC'],
|
||||
"startprice"=>$r['CENA_POCZ'],
|
||||
"purchase_price"=>$r['CENA_EWID'],
|
||||
"discount"=>$r['RABAT'],
|
||||
"subtotal"=>$subtotal,
|
||||
"dd_unit_name"=>$r['NAZWA_J_M'],
|
||||
"dd_unit_id"=>'KG',
|
||||
"ecmvat_id"=>$vat_tmp,
|
||||
"ecmvat_value"=>$r['VAT'],
|
||||
"ecmvat_name"=>$r['VAT']."%",
|
||||
"ecmproductcategory_id"=>"",
|
||||
"currency_id"=>"PLN",
|
||||
"currency_name"=>"PLN",
|
||||
"tax_code"=>"",
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
mysql_query("set character set utf8;");
|
||||
$query="insert into ekomer.ecminvoiceoutitems set ".implode(",",$in).";\n";
|
||||
// $a="insert into ekomer.ecminvoiceoutitems set ".implode(",",$in);
|
||||
// echo $a.';\n';
|
||||
echo $query;
|
||||
return $iid;
|
||||
|
||||
|
||||
}
|
||||
|
||||
include_once("class.dbf.php");
|
||||
include_once("helper.php");
|
||||
|
||||
$start = getmicrotime();
|
||||
|
||||
$dbfp = new dbf_class('dbf/_kf_list.dbf');
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$products = array();
|
||||
for($i=0;$i<$num_recp;$i++){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
$products[$rowp['NR_SYSTEM']][] = $rowp;
|
||||
}
|
||||
|
||||
$dbf = new dbf_class('dbf/_kf.dbf');
|
||||
$num_rec=$dbf->dbf_num_rec;
|
||||
|
||||
//$num_rec=1000;
|
||||
for($i=0;$i<$num_rec;$i++){
|
||||
$docs[$i]=$dbf->getRowAssoc($i);
|
||||
}
|
||||
$add = 0;
|
||||
|
||||
$stop =0;
|
||||
//echo 'tutaj';
|
||||
|
||||
for($i=$num_rec-1;$i>-1;$i--){
|
||||
//echo $docs[$i]['ANULOWANA']=ch($docs[$i]['ANULOWANA']);
|
||||
//echo 'cz: '.$docs[$i]['ANULOWANA'].'<br>';
|
||||
//echo $docs[$i]['NR_FK'].' a '.$docs[$i]['ANULOWANA'];
|
||||
|
||||
//echo "pole: ".$docs[$i]['ANULOWANA']."\n";
|
||||
if ((trim($docs[$i]['NR_FK'])=='') or ($docs[$i]['ANULOWANA'])=='P') continue;
|
||||
$data1 = mktime(0, 0, 0, substr($docs[$i]['DATA'],4,2),substr($docs[$i]['DATA'],6,2),substr($docs[$i]['DATA'],0,4));
|
||||
$data2 = mktime(0, 0, 0, 1, 1, 2004);
|
||||
//echo substr($docs[$i]['DATA'],4,2)."\n\r";
|
||||
//echo substr($docs[$i]['DATA'],6,2)."\n\r";
|
||||
//echo substr($docs[$i]['DATA'],0,4)."\n\r";
|
||||
//echo $data1."\n\r";
|
||||
//echo $data2."\n\r";
|
||||
if ($data1 < $data2) break;
|
||||
|
||||
//echo 'to: '.trim($docs[$i]['NR_FK']).'';
|
||||
$result = mysql_query("SELECT id FROM ekomer.ecminvoiceouts WHERE document_no ='FVCOR ".trim($docs[$i]['NR_KF'])."'");
|
||||
//echo 'sadasdasdas';
|
||||
//stop - zabezpieczenie w przypadku braku kolejności w numerach
|
||||
|
||||
if (mysql_num_rows($result)!=0) {
|
||||
$stop++;
|
||||
if ($stop==5) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
//echo '2342332';
|
||||
$add++;
|
||||
|
||||
$id=addFk($docs[$i],$i,'');
|
||||
$j=1;
|
||||
|
||||
//echo 'tutaj';
|
||||
foreach($products[$docs[$i]['NR_SYSTEM']] as $prod){
|
||||
addProductLine($id,$j,$prod);
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
//echo "Podsumowanie:\nW dbf: ".$num_rec."\nDodano: ".$add."\n";
|
||||
$koniec = getmicrotime();
|
||||
//echo "Czas trawania:".(($koniec - $start)/60)." minut\n";
|
||||
mysql_close($sql);
|
||||
|
||||
?>
|
||||
46
import/import/change_index.php
Executable file
46
import/import/change_index.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
include_once("class.dbf.php");
|
||||
include_once("/var/www/crm/config.php");
|
||||
include_once("helper.php");
|
||||
global $sugar_config;
|
||||
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
||||
|
||||
mysql_query("set character set utf8;");
|
||||
|
||||
$path = dirname(__FILE__).'/_indeksy.dbf';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
for($i=0;$i<$num_recp;$i++){
|
||||
|
||||
if ($i % 5000 == 0) echo $i.'
|
||||
';
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
|
||||
//get id
|
||||
$r = mysql_fetch_array(mysql_query("SELECT id FROM ecmproducts WHERE index_dod='".$rowp['INDEKS']."'"));
|
||||
|
||||
$id = $r['id'];
|
||||
|
||||
if ((!isset($id)) || ($id=='')) {
|
||||
echo 'nie ma
|
||||
';
|
||||
continue;
|
||||
}
|
||||
//update ecmproducts
|
||||
$q=ch("update ecmproducts set name='".addslashes($rowp['NAZWA'])."' where id='$id'");
|
||||
|
||||
mysql_query($q);
|
||||
|
||||
//update ecmstockstartes
|
||||
//$q="update ecmstockstates set product_code='".$rowp['INDEKS_DOD']."' where product_id='$id'";
|
||||
|
||||
//mysql_query($q);
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
120
import/import/class.dbf.php
Executable file
120
import/import/class.dbf.php
Executable file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
class dbf_class {
|
||||
|
||||
var $dbf_num_rec; //Number of records in the file
|
||||
var $dbf_num_field; //Number of columns in each row
|
||||
var $dbf_names = array(); //Information on each column ['name'],['len'],['type']
|
||||
//These are private....
|
||||
var $_raw; //The raw input file
|
||||
var $_rowsize; //Length of each row
|
||||
var $_hdrsize; //Length of the header information (offset to 1st record)
|
||||
var $_memos; //The raw memo file (if there is one).
|
||||
|
||||
function dbf_class($filename) {
|
||||
if ( !file_exists($filename)) {
|
||||
echo 'Not a valid DBF file !!!'. $filename; exit;
|
||||
}
|
||||
$tail=substr($filename,-4);
|
||||
if (strcasecmp($tail, '.dbf')!=0) {
|
||||
echo 'Not a valid DBF file !!!'. $filename; exit;
|
||||
}
|
||||
|
||||
//Read the File
|
||||
$handle = fopen($filename, "r");
|
||||
if (!$handle) { echo "Cannot read DBF file"; exit; }
|
||||
$filesize = filesize($filename);
|
||||
$this->_raw = fread ($handle, $filesize);
|
||||
fclose ($handle);
|
||||
//Make sure that we indeed have a dbf file...
|
||||
if(!(ord($this->_raw[0]) == 3 || ord($this->_raw[0]) == 131) && ord($this->_raw[$filesize]) != 26) {
|
||||
echo 'Not a valid DBF file !!!'. $filename; exit;
|
||||
}
|
||||
// 3= file without DBT memo file; 131 ($83)= file with a DBT.
|
||||
$arrHeaderHex = array();
|
||||
for($i=0; $i<32; $i++){
|
||||
$arrHeaderHex[$i] = str_pad(dechex(ord($this->_raw[$i]) ), 2, "0", STR_PAD_LEFT);
|
||||
}
|
||||
//Initial information
|
||||
$line = 32;//Header Size
|
||||
//Number of records
|
||||
$this->dbf_num_rec= hexdec($arrHeaderHex[7].$arrHeaderHex[6].$arrHeaderHex[5].$arrHeaderHex[4]);
|
||||
$this->_hdrsize= hexdec($arrHeaderHex[9].$arrHeaderHex[8]);//Header Size+Field Descriptor
|
||||
//Number of fields
|
||||
$this->_rowsize = hexdec($arrHeaderHex[11].$arrHeaderHex[10]);
|
||||
$this->dbf_num_field = floor(($this->_hdrsize - $line ) / $line ) ;//Number of Fields
|
||||
|
||||
//Field properties retrieval looping
|
||||
for($j=0; $j<$this->dbf_num_field; $j++){
|
||||
$name = '';
|
||||
$beg = $j*$line+$line;
|
||||
for($k=$beg; $k<$beg+11; $k++){
|
||||
if(ord($this->_raw[$k])!=0){
|
||||
$name .= $this->_raw[$k];
|
||||
}
|
||||
}
|
||||
$this->dbf_names[$j]['name']= $name;//Name of the Field
|
||||
$this->dbf_names[$j]['len']= ord($this->_raw[$beg+16]);//Length of the field
|
||||
$this->dbf_names[$j]['type']= $this->_raw[$beg+11];
|
||||
}
|
||||
if (ord($this->_raw[0])==131) { //See if this has a memo file with it...
|
||||
//Read the File
|
||||
$tail=substr($tail,-1,1); //Get the last character...
|
||||
if ($tail=='F'){ //See if upper or lower case
|
||||
$tail='T'; //Keep the case the same
|
||||
} else {
|
||||
$tail='t';
|
||||
}
|
||||
$memoname = substr($filename,0,strlen($filename)-1).$tail;
|
||||
$handle = fopen($memoname, "r");
|
||||
if (!$handle) { echo "Cannot read DBT file"; exit; }
|
||||
$filesize = filesize($memoname);
|
||||
$this->_memos = fread ($handle, $filesize);
|
||||
fclose ($handle);
|
||||
}
|
||||
}
|
||||
|
||||
function getRow($recnum) {
|
||||
$memoeot = chr(26).chr(26);
|
||||
$rawrow = substr($this->_raw,$recnum*$this->_rowsize+$this->_hdrsize,$this->_rowsize);
|
||||
$rowrecs = array();
|
||||
$beg=1;
|
||||
if (ord($rawrow[0])==42) {
|
||||
return false; //Record is deleted...
|
||||
}
|
||||
for ($i=0; $i<$this->dbf_num_field; $i++) {
|
||||
$col=trim(substr($rawrow,$beg,$this->dbf_names[$i]['len']));
|
||||
if ($this->dbf_names[$i]['type']!='M') {
|
||||
|
||||
$rowrecs[]=$col;
|
||||
} else {
|
||||
$memobeg=$col*512; //Find start of the memo block (0=header so it works)
|
||||
$memoend=strpos($this->_memos,$memoeot,$memobeg); //Find the end of the memo
|
||||
$rowrecs[]=substr($this->_memos,$memobeg,$memoend-$memobeg);
|
||||
}
|
||||
$beg+=$this->dbf_names[$i]['len'];
|
||||
}
|
||||
return $rowrecs;
|
||||
}
|
||||
|
||||
function getRowAssoc($recnum) {
|
||||
$rawrow = substr($this->_raw,$recnum*$this->_rowsize+$this->_hdrsize,$this->_rowsize);
|
||||
$rowrecs = array();
|
||||
$beg=1;
|
||||
if (ord($rawrow[0])==42) {
|
||||
return false; //Record is deleted...
|
||||
}
|
||||
for ($i=0; $i<$this->dbf_num_field; $i++) {
|
||||
$col=trim(substr($rawrow,$beg,$this->dbf_names[$i]['len']));
|
||||
if ($this->dbf_names[$i]['type']!='M') {
|
||||
$rowrecs[$this->dbf_names[$i]['name']]=$col;
|
||||
} else {
|
||||
$memobeg=$col*512; //Find start of the memo block (0=header so it works)
|
||||
$memoend=strpos($this->_memos,$memoeot,$memobeg); //Find the end of the memo
|
||||
$rowrecs[$this->dbf_names[$i]['name']]=substr($this->_memos,$memobeg,$memoend-$memobeg);
|
||||
}
|
||||
$beg+=$this->dbf_names[$i]['len'];
|
||||
}
|
||||
return $rowrecs;
|
||||
}
|
||||
}
|
||||
?>
|
||||
510
import/import/fk.php
Executable file
510
import/import/fk.php
Executable file
@@ -0,0 +1,510 @@
|
||||
<?php
|
||||
|
||||
ini_set('display_errors', 0);
|
||||
set_time_limit(-1);
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
include_once("class.dbf.php");
|
||||
include_once("helper.php");
|
||||
$sugar_config = array(
|
||||
|
||||
|
||||
'dbconfig' =>
|
||||
array(
|
||||
'db_host_name' => 'localhost',
|
||||
'db_user_name' => 'root',
|
||||
'db_password' => '%g7!@fG',
|
||||
'db_name' => 'preDb_45ab7160e7af49269e17044eaed9e0ba',
|
||||
'db_type' => 'mysql',
|
||||
),
|
||||
);
|
||||
|
||||
//Tworzenie polaczenia z baza
|
||||
echo '************************************************<br>Ustawianie polaczenia z baza...<br>';
|
||||
$mysqli = new mysqli($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password'], $sugar_config['dbconfig']['db_name']);
|
||||
if(mysqli_connect_errno()){
|
||||
echo 'Nie nawiazano polaczenia z baza...<br>';
|
||||
exit($mysqli->error);
|
||||
}else{
|
||||
echo 'Ustawiono polaczenie z baza na serwerze ' . $sugar_config['dbconfig']['db_host_name'] . ' uzywajac loginu: '. $sugar_config['dbconfig']['db_user_name'] . ' i domyslna baza to: '.$sugar_config['dbconfig']['db_name'] . '<br>';
|
||||
}
|
||||
|
||||
if ($mysqli->set_charset("utf8")) {
|
||||
echo 'Ustawiono kodowanie: ' . $mysqli->get_charset()->charset . '<br>';
|
||||
} else {
|
||||
echo "Blad w ustawianiu kodowania utf8<br>";
|
||||
$mysqli->close();
|
||||
exit($mysqli->error);
|
||||
}
|
||||
|
||||
if($mysqli->query('TRUNCATE TABLE ecminvoiceoutitems')){
|
||||
echo 'Wyczyszczono tabele ecminvoiceoutitems<br>';
|
||||
}else{
|
||||
echo 'Nie usunieto danych z ecminvoiceoutitems<br>';
|
||||
$mysqli->close();
|
||||
exit($mysqli->error);
|
||||
}
|
||||
|
||||
if($mysqli->query('TRUNCATE TABLE ecminvoiceouts')){
|
||||
echo 'Wyczyszczono tabele ecminvoiceouts<br>';
|
||||
}else{
|
||||
echo 'Nie usunieto danych z ecminvoiceouts<br>';
|
||||
$mysqli->close();
|
||||
exit($mysqli->error);
|
||||
}
|
||||
echo 'Zakonczono ustanawianie polaczenia z baza<br>************************************************<br><br>';
|
||||
|
||||
|
||||
function microtime_float(){
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
function getnr($nr_sys, $path) {
|
||||
//echo $nr_sys;
|
||||
if($path==NULL){
|
||||
$dbfi = new dbf_class(dirname(__FILE__).'/bsl/_indeksy.dbf');
|
||||
}else{
|
||||
$dbfi = new dbf_class(dirname(__FILE__).'/bsl/_indeksy.dbf');
|
||||
}
|
||||
|
||||
$num_rec = $dbfi->dbf_num_rec;
|
||||
for ($i = 0; $i < $num_rec; $i++) {
|
||||
$indeks = $dbfi->getRowAssoc($i);
|
||||
|
||||
//echo $indeks['INDEKS']."\r\n";
|
||||
if ($indeks['INDEKS'] == $nr_sys) {
|
||||
//echo $indeks['INDEKS'];
|
||||
return ch($indeks['NR_SYSTEM']);
|
||||
}
|
||||
}
|
||||
return 'BRAK INDEKSU';
|
||||
}
|
||||
|
||||
function dodajFaktury($dokumenty, $idmagazynu, $nrmagazynu=NULL) {
|
||||
|
||||
global $mysqli;
|
||||
|
||||
if(!isset($dokumenty) || count($dokumenty)==0){
|
||||
return NULL;
|
||||
}
|
||||
$tmpplatnosc = array();
|
||||
foreach($dokumenty as $key => $row){
|
||||
$result = $mysqli->query("SELECT id, name, to_vatid FROM accounts WHERE index_dbf = '" . ch(trim($row['INDEKS_KON'])) . "'");
|
||||
if($result->num_rows>0){
|
||||
$r = $result->fetch_array(MYSQLI_ASSOC);
|
||||
} else {
|
||||
$result = $mysqli->query('SELECT id, name, to_vatid FROM accounts WHERE index_dbf = "' . ch(trim($row['INDEKS_KON'])) . '"');
|
||||
if($result->num_rows>0){
|
||||
$r = $result->fetch_array(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($r)){
|
||||
$result = $mysqli->query("SELECT id, name, to_vatid FROM accounts WHERE to_vatid = '" . trim($row['NR_IDENT']) . "'");
|
||||
$r = $result->fetch_array(MYSQLI_ASSOC);
|
||||
if(!isset($r)){
|
||||
$result = $mysqli->query("SELECT id, name, to_vatid FROM accounts WHERE to_vatid = '" . str_replace('-', '', trim($row['NR_IDENT'])) . "'");
|
||||
$r = $result->fetch_array(MYSQLI_ASSOC);
|
||||
if(!isset($r)){
|
||||
//var_dump($row);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rd = $row['DATA'];
|
||||
$sd = $row['DATA_SPRZ'];
|
||||
$a1 = explode(" ", $row['ADRES1']);
|
||||
$pre = "FK";
|
||||
if(isset($nrmagazynu)){
|
||||
|
||||
}
|
||||
$id = create_guid();
|
||||
|
||||
if ($row['ANULOWANA'] == "F" || $row['ANULOWANA'] == "")
|
||||
$canceled = '0';
|
||||
else
|
||||
$canceled = '1';
|
||||
|
||||
$year = substr($row['DATA_SPRZ'], 0, 4);
|
||||
$waluta = "PLN";
|
||||
$subtotal = $row['WARTOSC'] - $row['PODATEK'];
|
||||
|
||||
$kurs = 0;
|
||||
if ($row['KURS'] != 0) {
|
||||
$kurs = strtolower (str_replace(',','.',$row['KURS']));
|
||||
$waluta = "EUR";
|
||||
}
|
||||
$n = substr($row['NR_FK'], 0, -3);
|
||||
if ($n < 100 && $n > 9) {
|
||||
$ad = 0;
|
||||
} else {
|
||||
$ad = '';
|
||||
}
|
||||
if ($n < 10) {
|
||||
$ad = '00';
|
||||
}
|
||||
$date = $rd[0] . $rd[1] . $rd[2] . $rd[3] . "" . $rd[4] . $rd[5] . "" . $rd[6] . $rd[7] . $ad . $n;
|
||||
$date2 = $rd[0] . $rd[1] . $rd[2] . $rd[3] . "-" . $rd[4] . $rd[5] . "-" . $rd[6] . $rd[7];
|
||||
$n = (int) $row['TERMIN'];
|
||||
date_default_timezone_set('Europe/Warsaw');
|
||||
$date3 = new DateTime($date2);
|
||||
$date3->add(new DateInterval('P' . $n . 'D'));
|
||||
|
||||
$payment_method_dom=array (
|
||||
'PRZELEW' => 'Przelew',
|
||||
'' => 'Inny',
|
||||
'PRZEDPLATA' => 'Przedpłata',
|
||||
'ZA POBRANIEM' => 'Za pobraniem',
|
||||
'PRZY ODBIORZE' => 'Przy odbiorze',
|
||||
'GOTÓWKĄ' => 'Gotówka',
|
||||
'*PRZELEW*' => '*Przelew*',
|
||||
);
|
||||
$payment_method_dom = array(
|
||||
"PRZELEW"=>'PRZELEW',
|
||||
"PRZEDPŁATA"=>'PRZEDPLATA',
|
||||
"PRZELEWEM"=>'PRZELEW',
|
||||
"GOTÓWKA"=>'GOTÓWKĄ',
|
||||
"POBRANIE T.K."=>'ZA POBRANIEM',
|
||||
"POBRANIE"=>'ZA POBRANIEM',
|
||||
"GOTÓWKĄ"=>'GOTÓWKĄ',
|
||||
"POBRANIE GOTÓWKA"=>'ZA POBRANIEM',
|
||||
"POPRANIE"=>'ZA POBRANIEM',
|
||||
"GOTWKA"=>'GOTÓWKĄ',
|
||||
"KOMPENSATA"=>'',
|
||||
);
|
||||
|
||||
$payment_date_days = $n;
|
||||
$id = create_guid();
|
||||
$name = $pre . " " . trim($row['NR_FK']);
|
||||
$description = ch($row['ADRES2'] . " " . $row['ADRES1'] . " " . $row['UWAGI'] . " " . $row['UWAGI1']);
|
||||
$date_entered = date("Y-m-d H:i:s");
|
||||
$date_modified = $date_entered;
|
||||
$modified_user_id = "eaa650d6-5a48-8a29-cd7c-554207f71255";
|
||||
$assigned_user_id = $modified_user_id;
|
||||
$created_by = $modified_user_id;
|
||||
$stock_id = $idmagazynu;
|
||||
$number = $date;
|
||||
$document_no = $pre . " " . trim($row['NR_FK']);
|
||||
$parent_type = "Accounts";
|
||||
$parent_name = empty($r['name']) ? '' : str_replace("'", "",$r['name']);
|
||||
$parent_id = empty($r['id']) ? '' : $r['id'];
|
||||
$type = "normal";
|
||||
$ecminvoiceout_id = 't';
|
||||
$ecminvoiceout_name = "";
|
||||
$status = "accepted";
|
||||
$register_date = $rd[0] . $rd[1] . $rd[2] . $rd[3] . "-" . $rd[4] . $rd[5] . "-" . $rd[6] . $rd[7];
|
||||
$sell_date = $sd[0] . $sd[1] . $sd[2] . $sd[3] . "-" . $sd[4] . $sd[5] . "-" . $sd[6] . $sd[7];
|
||||
$payment_date = $date3->format('Y-m-d');
|
||||
$parent_address_street = ch(str_replace("'", "", $row['ADRES2']));
|
||||
$parent_address_city = empty(ch($a1[1])) ? '' : ch($a1[1]);
|
||||
$parent_address_postalcode = empty($a1[0]) ? '' : $a1[0];
|
||||
$prepaid = empty($row['PRZEDPLATA']) ? '' : $row['PRZEDPLATA'];
|
||||
$paid_val = empty($row['GOTOWKA']) ? '' : $row['GOTOWKA'];
|
||||
$total_brutto = empty($row['WARTOSC']) ? '' : $row['WARTOSC'];
|
||||
$total_netto = $row['WARTOSC'] - $row['PODATEK'];
|
||||
$total_vat = $row['PODATEK'];
|
||||
if ($row['KURS'] != 0) {
|
||||
$total_brutto = round($total_brutto * $kurs,2);
|
||||
$total_netto = round($total_netto * $kurs,2);
|
||||
$total_vat = round($total_vat * $kurs,2);
|
||||
}
|
||||
$paid_val = $row['GOTOWKA'];
|
||||
$payment_method = $payment_method_dom[ch($row['SPOS_ZAP'])];
|
||||
$discount = 0;
|
||||
$pdf_type = 'K';
|
||||
$ecmlanguage = "pl_pl";
|
||||
$currency_id = empty($waluta) ? '' : $waluta;
|
||||
$currency_value = empty($kurs) ? '' : $kurs;
|
||||
$deleted = empty($type) ? '' : $type;
|
||||
$nr_system = $row['NR_SYSTEM'];
|
||||
|
||||
|
||||
$query = "INSERT ecminvoiceouts (";
|
||||
$query .= " id, ";
|
||||
$query .= " name, ";
|
||||
$query .= " deleted, ";
|
||||
$query .= " date_entered, ";
|
||||
$query .= " date_modified, ";
|
||||
$query .= " modified_user_id, ";
|
||||
$query .= " assigned_user_id, ";
|
||||
$query .= " created_by, ";
|
||||
$query .= " number, ";
|
||||
$query .= " document_no, ";
|
||||
$query .= " parent_type, ";
|
||||
$query .= " parent_name, ";
|
||||
$query .= " parent_id, ";
|
||||
$query .= " type, ";
|
||||
$query .= " register_date, ";
|
||||
$query .= " sell_date, ";
|
||||
$query .= " total_netto, ";
|
||||
$query .= " total_brutto, ";
|
||||
$query .= " total_vat, ";
|
||||
$query .= " parent_address_street, ";
|
||||
$query .= " parent_address_city, ";
|
||||
$query .= " parent_address_postalcode, ";
|
||||
$query .= " parent_nip_unformated, ";
|
||||
$query .= " parent_nip, ";
|
||||
$query .= " currency_id, ";
|
||||
$query .= " currency_value, ";
|
||||
$query .= " currency_value_nbp, ";
|
||||
$query .= " payment_date_days, ";
|
||||
$query .= " payment_date, ";
|
||||
$query .= " paid_val, ";
|
||||
$query .= " payment_method, ";
|
||||
$query .= " sys_number, ";
|
||||
$query .= " pdf_type, ";
|
||||
$query .= " canceled, ";
|
||||
$query .= " stock_id, ";
|
||||
$query .= " ecmlanguage, ";
|
||||
$query .= " document_autoincrement ";
|
||||
$query .= " ) VALUES (";
|
||||
$query .= "'" . $id . "',"; // id
|
||||
$query .= "'" . $name . "',"; // name
|
||||
$query .= "0,"; // deleted
|
||||
$query .= "NOW(),"; //date_entered
|
||||
$query .= "NOW(),"; //date_modified
|
||||
$query .= "'". $modified_user_id ."',"; //modified_user_id
|
||||
$query .= "'". $assigned_user_id ."',"; //assigned_user_id
|
||||
$query .= "'". $created_by ."',"; //created_by
|
||||
$query .= "'" . $number . "' ,"; // number
|
||||
$query .= "'" . $document_no . "' ,"; // document_no
|
||||
$query .= "'Accounts',"; // parent_type
|
||||
$query .= "'" . $parent_name . "',"; // parent_name
|
||||
$query .= "'" . $parent_id . "' ,"; // parent_id
|
||||
$query .= "'normal',"; // type
|
||||
$query .= "'" . $register_date . "',"; // register_date
|
||||
$query .= "'" . $sell_date . "',"; // sell_date
|
||||
$query .= "'" . $total_netto . "',"; // total_netto
|
||||
$query .= "'" . $total_brutto . "',"; // total_brutto
|
||||
$query .= "'" . $total_vat . "',"; // total_vat
|
||||
$query .= "'" . $parent_address_street . "',"; // parent_address_street
|
||||
$query .= "'" . $parent_address_city . "',"; // parent_address_city
|
||||
$query .= "'" . $parent_address_postalcode . "',"; // parent_address_postalcode
|
||||
$query .= "'" . $r['to_vatid'] . "',"; // parent_nip
|
||||
$query .= "'" . str_replace("-", '', $r['to_vatid']) . "',"; // parent_nip_unformated
|
||||
$query .= "'" . $currency_id . "',"; // currency_id
|
||||
$query .= "'" . $currency_value . "',"; // currency_value
|
||||
$query .= "'" . $currency_value . "',"; // currency_value
|
||||
$query .= "'" . $payment_date_days . "',"; // payment_date_days
|
||||
$query .= "'" . $payment_date . "',"; // payment_date$paid_val
|
||||
$query .= "'" . $paid_val . "',"; // paid_val
|
||||
$query .= "'" . $payment_method . "',"; // payment_method
|
||||
$query .= "'" . $nr_system . "',"; // sys_number
|
||||
$query .= "'" . $pdf_type . "',"; // sys_number
|
||||
$query .= "'" . $canceled . "',"; // canceled
|
||||
$query .= "'" . $idmagazynu . "',"; // payment_date
|
||||
$aa=explode('/',$document_no);
|
||||
preg_match('|\d+|',$aa[0],$matches);
|
||||
|
||||
$document_auto=date("Ymd",strtotime($register_date)).''.sprintf('%05d',(string)((int)$matches[0]));
|
||||
$query .= " 'pl_pl',"; // ecmlanguage
|
||||
$query .= "'" . $document_auto . "'"; // payment_date
|
||||
$query .= ");";
|
||||
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
echo $query . '<Br><br>';
|
||||
echo $mysqli->error;
|
||||
}
|
||||
foreach($row['LISTA_POZYCJI'] as $klucz => $wartosc){
|
||||
if(isset($nrmagazynu)){
|
||||
addProductLine($id, $klucz, $wartosc, $nrmagazynu);
|
||||
}else{
|
||||
addProductLine($id, $klucz, $wartosc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function addProductLine($id, $i, $r, $nrmagazynu=NULL) {
|
||||
|
||||
$jed=strtolower (str_replace('.','',$r['NAZWA_J_M']));
|
||||
$unit_id=array_search($jed, $jednostki);
|
||||
global $mysqli;
|
||||
$result = $mysqli->query("SELECT id FROM ecmproducts WHERE code ='" . ch($r['INDEKS']) . "' and deleted='0'");
|
||||
$rr = $result->fetch_array(MYSQLI_ASSOC);
|
||||
$pid = $rr['id'];
|
||||
if ($rr['id'] == ''){
|
||||
$result = $mysqli->query('SELECT id FROM ecmproducts WHERE code ="' . ch($r['INDEKS']). '" and deleted="0"');
|
||||
$rr = $result->fetch_array(MYSQLI_ASSOC);
|
||||
$pid = $rr['id'];
|
||||
if ($rr['id'] == ''){
|
||||
$pid=getnr($r['INDEKS'], $nrmagazynu);
|
||||
}
|
||||
}
|
||||
$iid = create_guid();
|
||||
|
||||
//repair prices (remove ',')
|
||||
$r['CENA_SPRZ'] = trim(str_replace(",", ".", $r['CENA_SPRZ']));
|
||||
$r['CENA_POCZ'] = trim(str_replace(",", ".", $r['CENA_POCZ']));
|
||||
$r['WARTOSC'] = trim(str_replace(",", ".", $r['WARTOSC']));
|
||||
$r['RABAT'] = trim(str_replace(",", ".", $r['RABAT']));
|
||||
$r['CENA_EWID'] = trim(str_replace(",", ".", $r['CENA_EWID']));
|
||||
$subtotal = $r['WARTOSC'];
|
||||
$arr = array(
|
||||
"id" => $iid,
|
||||
"date_entered" => date("Y-m-d H:i:s"),
|
||||
"date_modified" => date("Y-m-d H:i:s"),
|
||||
"modified_user_id" => "eaa650d6-5a48-8a29-cd7c-554207f71255",
|
||||
"assigned_user_id" => "eaa650d6-5a48-8a29-cd7c-554207f71255",
|
||||
"created_by" => "eaa650d6-5a48-8a29-cd7c-554207f71255",
|
||||
"deleted" => 0,
|
||||
"ecminvoiceout_id" => $id,
|
||||
"ecmproduct_id" => $pid,
|
||||
"position" => $i,
|
||||
"code" => ch(str_replace("'", "", $r['INDEKS'])),
|
||||
"name" => ch(str_replace("'", "", $r['NAZWA'])),
|
||||
"quantity" => $r['ILOSC'],
|
||||
"price_start" => $r['CENA_POCZ'],
|
||||
"price_netto" => $r['CENA_SPRZ'],
|
||||
"price_brutto" => round($r['CENA_SPRZ']*strtolower (str_replace('.','',$r['VAT'])),2) + $r['CENA_SPRZ'],
|
||||
"discount" => $r['RABAT'],
|
||||
"total_netto" => $r['WARTOSC'],
|
||||
"total_brutto" => $r['WARTOSC'] + $r['POD_WART'],
|
||||
"total_vat" => $r['POD_WART'],
|
||||
"price_purchase" => round($r['CENA_EWID'] / $r['ILOSC'],2),
|
||||
"dd_unit_name" => $r['NAZWA_J_M'],
|
||||
"dd_unit_id" => md5($r['NAZWA_J_M']),
|
||||
"ecmvat_id" => md5($r['VAT'].'asd'),
|
||||
"ecmvat_value" => strtolower (str_replace('.','',$r['VAT'])),
|
||||
"ecmvat_name" => $r['VAT'] . "%",
|
||||
);
|
||||
foreach ($arr as $k => $v) {
|
||||
$in[] = $k . "='" . $v . "'";
|
||||
}
|
||||
$query = "insert into ecminvoiceoutitems set " . implode(",", $in) . ";\n";
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
echo $mysqli->error;
|
||||
echo $query . '<Br><br>';
|
||||
}
|
||||
}
|
||||
|
||||
function wczytajFaktury($path, $path2){
|
||||
//Naglowki faktur
|
||||
$dbf = new dbf_class($path);
|
||||
$num_rec = $dbf->dbf_num_rec;
|
||||
$dokumenty = array();
|
||||
echo $num_rec. '<br>';
|
||||
for ($i = 0; $i < $num_rec; $i++) {
|
||||
$row = $dbf->getRowAssoc($i);
|
||||
if(!$row){
|
||||
// echo 'Pominieto wiersz naglowka'.$i.' z '. $num_rec. ' '.$path.'<br>';
|
||||
continue;
|
||||
}
|
||||
if(strlen($row['NR_SYSTEM'])>0){
|
||||
$dokumenty[$row['NR_SYSTEM']] = array();
|
||||
//$dokumenty[$row['NR_SYSTEM']] = $row;
|
||||
foreach($row as $key => $value){
|
||||
if(strlen($value)>0){
|
||||
$dokumenty[$row['NR_SYSTEM']][$key] = $value;
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo 'BRAK NUMERU FAKTURY!<br>';
|
||||
// var_dump($row);
|
||||
echo '<br><br>';
|
||||
}
|
||||
}
|
||||
|
||||
//Pozycje faktur
|
||||
$dbfp = new dbf_class($path2);
|
||||
$num_recp = $dbfp->dbf_num_rec;
|
||||
for ($i = 0; $i < $num_recp; $i++) {
|
||||
$row = $dbfp->getRowAssoc($i);
|
||||
if(!$row){
|
||||
// echo 'Pominieto wiersz pozycji'.$i.' z '. $num_rec. ' ' .$path2. '<br>';
|
||||
continue;
|
||||
}
|
||||
if(isset($dokumenty[$row['NR_SYSTEM']])){
|
||||
if(isset($dokumenty[$row['NR_SYSTEM']]['LISTA_POZYCJI'])){
|
||||
$tmprow = array();
|
||||
foreach($row as $key => $value){
|
||||
if(strlen($value)>0){
|
||||
$tmprow[$key] = $value;
|
||||
}
|
||||
}
|
||||
$dokumenty[$row['NR_SYSTEM']]['LISTA_POZYCJI'][] = $tmprow;
|
||||
}else{
|
||||
$dokumenty[$row['NR_SYSTEM']]['LISTA_POZYCJI'] = array();
|
||||
$tmprow = array();
|
||||
foreach($row as $key => $value){
|
||||
if(strlen($value)>0){
|
||||
$tmprow[$key] = $value;
|
||||
}
|
||||
}
|
||||
$dokumenty[$row['NR_SYSTEM']]['LISTA_POZYCJI'][] = $tmprow;
|
||||
}
|
||||
}else{
|
||||
// var_dump($row);
|
||||
echo '<br><br>';
|
||||
}
|
||||
}
|
||||
return $dokumenty;
|
||||
}
|
||||
|
||||
// Obsluga importu
|
||||
$start = microtime_float();
|
||||
|
||||
echo 'Wczytywanie dokumentow...<br>';
|
||||
$re = $mysqli->query('SELECT id, dir, name FROM ecmstocks');
|
||||
while($magazyn = $re->fetch_array(MYSQLI_ASSOC)){
|
||||
|
||||
echo 'Magazyn: ' . $magazyn['name'] . '<br>';
|
||||
if($magazyn['dir']=='mg'){
|
||||
$path2 = dirname(__FILE__).'/bsl/_fk_list.dbf';
|
||||
$path = dirname(__FILE__).'/bsl/_fk.dbf';;
|
||||
$dokumenty = wczytajFaktury($path , $path2);
|
||||
dodajFaktury($dokumenty, $magazyn['id']);
|
||||
} else {
|
||||
$path2 = dirname(__FILE__).'/bsl/_fk_list.dbf';
|
||||
$path = dirname(__FILE__).'/bsl/_fk.dbf';;
|
||||
$dokumenty = wczytajFaktury($path , $path2);
|
||||
dodajFaktury($dokumenty, $magazyn['id'], $magazyn['dir']);
|
||||
}
|
||||
}
|
||||
echo 'Zakonczono wczytywanie dokumentow<br>';
|
||||
//echo 'Dodawanie faktur...<br>';
|
||||
//
|
||||
//echo 'Zakonczono dodawanie faktur<br>';
|
||||
|
||||
|
||||
$res2 = $mysqli->query("select * from ecminvoiceouts where type='normal'");
|
||||
|
||||
while($r = $res2->fetch_array(MYSQLI_ASSOC)){
|
||||
|
||||
$vats_summary = '';
|
||||
$total_netto = 0;
|
||||
$total_brutto = 0;
|
||||
$total_vat = 0;
|
||||
|
||||
$res = $mysqli->query( "select ROUND(sum(total_netto),2) AS total_netto,ROUND(sum((total_netto*ecmvat_value)/100),2) AS total_vat,
|
||||
ROUND(sum(((total_netto*ecmvat_value)/100)+total_netto),2) AS total_brutto,ecmvat_value,ecmvat_name
|
||||
from ecminvoiceoutitems where ecminvoiceout_id='" . $r['id'] . "' group by ecmvat_id" );
|
||||
while ( $cc=$res->fetch_array(MYSQLI_ASSOC) ) {
|
||||
$total_netto += $cc ['total_netto'];
|
||||
$total_brutto += $cc ['total_brutto'];
|
||||
$total_vat += $cc ['total_vat'];
|
||||
if($cc ['ecmvat_name']=='OO'){
|
||||
$cc ['ecmvat_value']=$cc ['ecmvat_name'];
|
||||
} else {
|
||||
$cc ['ecmvat_value']=$cc ['ecmvat_name'];
|
||||
}
|
||||
$vats_summary .= $cc ['ecmvat_value'] . ':' . $cc ['total_netto'] . ':' . $cc ['total_vat'] . ':' . $cc ['total_brutto'] . ',';
|
||||
}
|
||||
$res = $mysqli->query( "update ecminvoiceouts set vats_summary='" . $vats_summary . "',total_netto='" . $total_netto . "',total_vat='" . $total_vat . "',
|
||||
total_brutto='" . $total_brutto . "' where id='" .$r['id']. "'" );
|
||||
|
||||
}
|
||||
|
||||
$koniec = microtime_float();
|
||||
echo "<br><br>Czas trawania:".(($koniec - $start)/60)." minut<br>";
|
||||
$mysqli->close();
|
||||
|
||||
?>
|
||||
595
import/import/fk_p.php
Normal file
595
import/import/fk_p.php
Normal file
@@ -0,0 +1,595 @@
|
||||
<?php
|
||||
|
||||
ini_set('display_errors', 0);
|
||||
set_time_limit(999999999);
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
include_once("class.dbf.php");
|
||||
include_once("helper.php");
|
||||
$sugar_config = array(
|
||||
|
||||
|
||||
'dbconfig' =>
|
||||
array(
|
||||
'db_host_name' => 'localhost',
|
||||
'db_user_name' => 'root',
|
||||
'db_password' => '%g7!@fG',
|
||||
'db_name' => 'preDb_7561b7965a2f9cebf2cbca60a9a07064',
|
||||
'db_type' => 'mysql',
|
||||
),
|
||||
);
|
||||
|
||||
//Tworzenie polaczenia z baza
|
||||
echo '************************************************<br>Ustawianie polaczenia z baza...<br>';
|
||||
$mysqli = new mysqli($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password'], $sugar_config['dbconfig']['db_name']);
|
||||
if(mysqli_connect_errno()){
|
||||
echo 'Nie nawiazano polaczenia z baza...<br>';
|
||||
exit($mysqli->error);
|
||||
}else{
|
||||
echo 'Ustawiono polaczenie z baza na serwerze ' . $sugar_config['dbconfig']['db_host_name'] . ' uzywajac loginu: '. $sugar_config['dbconfig']['db_user_name'] . ' i domyslna baza to: '.$sugar_config['dbconfig']['db_name'] . '<br>';
|
||||
}
|
||||
|
||||
if ($mysqli->set_charset("utf8")) {
|
||||
echo 'Ustawiono kodowanie: ' . $mysqli->get_charset()->charset . '<br>';
|
||||
} else {
|
||||
echo "Blad w ustawianiu kodowania utf8<br>";
|
||||
$mysqli->close();
|
||||
exit($mysqli->error);
|
||||
}
|
||||
|
||||
if($mysqli->query('TRUNCATE TABLE ecminvoiceoutitems')){
|
||||
echo 'Wyczyszczono tabele ecminvoiceoutitems<br>';
|
||||
}else{
|
||||
echo 'Nie usunieto danych z ecminvoiceoutitems<br>';
|
||||
$mysqli->close();
|
||||
exit($mysqli->error);
|
||||
}
|
||||
|
||||
if($mysqli->query('TRUNCATE TABLE ecminvoiceouts')){
|
||||
echo 'Wyczyszczono tabele ecminvoiceouts<br>';
|
||||
}else{
|
||||
echo 'Nie usunieto danych z ecminvoiceouts<br>';
|
||||
$mysqli->close();
|
||||
exit($mysqli->error);
|
||||
}
|
||||
echo 'Zakonczono ustanawianie polaczenia z baza<br>************************************************<br><br>';
|
||||
|
||||
|
||||
function microtime_float(){
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
function getnr($nr_sys, $path) {
|
||||
//echo $nr_sys;
|
||||
if($path==NULL){
|
||||
$dbfi = new dbf_class(dirname(__FILE__).'/przemyslowka/glowny/_INDEKSY.DBF');
|
||||
}else{
|
||||
$dbfi = new dbf_class(dirname(__FILE__).'/przemyslowka/glowny/_INDEKSY.DBF');
|
||||
}
|
||||
|
||||
$num_rec = $dbfi->dbf_num_rec;
|
||||
for ($i = 0; $i < $num_rec; $i++) {
|
||||
$indeks = $dbfi->getRowAssoc($i);
|
||||
|
||||
//echo $indeks['INDEKS']."\r\n";
|
||||
if ($indeks['INDEKS'] == $nr_sys) {
|
||||
//echo $indeks['INDEKS'];
|
||||
return ch($indeks['NR_SYSTEM']);
|
||||
}
|
||||
}
|
||||
return 'BRAK INDEKSU';
|
||||
}
|
||||
|
||||
function dodajFaktury($dokumenty, $idmagazynu, $nrmagazynu=NULL) {
|
||||
|
||||
global $mysqli;
|
||||
|
||||
if(!isset($dokumenty) || count($dokumenty)==0){
|
||||
return NULL;
|
||||
}
|
||||
$tmpplatnosc = array();
|
||||
foreach($dokumenty as $key => $row){
|
||||
$result = $mysqli->query("SELECT id, name, to_vatid FROM accounts WHERE index_dbf = '" . ch(trim($row['INDEKS_KON'])) . "' and account_type='c37746a5-0f62-5173-9020-574edf44b054'");
|
||||
if($result->num_rows>0){
|
||||
$r = $result->fetch_array(MYSQLI_ASSOC);
|
||||
} else {
|
||||
$result = $mysqli->query('SELECT id, name, to_vatid FROM accounts WHERE index_dbf = "' . ch(trim($row['INDEKS_KON'])) . '" and account_type="c37746a5-0f62-5173-9020-574edf44b054"');
|
||||
if($result->num_rows>0){
|
||||
$r = $result->fetch_array(MYSQLI_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($r)){
|
||||
$result = $mysqli->query("SELECT id, name, to_vatid FROM accounts WHERE to_vatid = '" . trim($row['NR_IDENT']) . "' and account_type='c37746a5-0f62-5173-9020-574edf44b054'");
|
||||
$r = $result->fetch_array(MYSQLI_ASSOC);
|
||||
if(!isset($r)){
|
||||
$result = $mysqli->query("SELECT id, name, to_vatid FROM accounts WHERE to_vatid = '" . str_replace('-', '', trim($row['NR_IDENT'])) . "' and account_type='c37746a5-0f62-5173-9020-574edf44b054'");
|
||||
$r = $result->fetch_array(MYSQLI_ASSOC);
|
||||
if(!isset($r)){
|
||||
//var_dump($row);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rd = $row['DATA'];
|
||||
$sd = $row['DATA_SPRZ'];
|
||||
$a1 = explode(" ", $row['ADRES1']);
|
||||
$pre = "FK";
|
||||
if(isset($nrmagazynu)){
|
||||
|
||||
}
|
||||
$id = create_guid();
|
||||
|
||||
if ($row['ANULOWANA'] == "F" || $row['ANULOWANA'] == "")
|
||||
$canceled = '0';
|
||||
else
|
||||
$canceled = '1';
|
||||
|
||||
$year = substr($row['DATA_SPRZ'], 0, 4);
|
||||
$waluta = "PLN";
|
||||
$subtotal = $row['WARTOSC'] - $row['PODATEK'];
|
||||
|
||||
$kurs = 0;
|
||||
if ($row['KURS'] != 0) {
|
||||
$kurs = strtolower (str_replace(',','.',$row['KURS']));
|
||||
$waluta = "EUR";
|
||||
}
|
||||
$n = substr($row['NR_FK'], 0, -3);
|
||||
if ($n < 100 && $n > 9) {
|
||||
$ad = 0;
|
||||
} else {
|
||||
$ad = '';
|
||||
}
|
||||
if ($n < 10) {
|
||||
$ad = '00';
|
||||
}
|
||||
$date = $rd[0] . $rd[1] . $rd[2] . $rd[3] . "" . $rd[4] . $rd[5] . "" . $rd[6] . $rd[7] . $ad . $n;
|
||||
$date2 = $rd[0] . $rd[1] . $rd[2] . $rd[3] . "-" . $rd[4] . $rd[5] . "-" . $rd[6] . $rd[7];
|
||||
$n = (int) $row['TERMIN'];
|
||||
date_default_timezone_set('Europe/Warsaw');
|
||||
$date3 = new DateTime($date2);
|
||||
$date3->add(new DateInterval('P' . $n . 'D'));
|
||||
|
||||
$payment_method_dom=array (
|
||||
'PRZELEW' => 'Przelew',
|
||||
'' => 'Inny',
|
||||
'PRZEDPLATA' => 'Przedpłata',
|
||||
'ZA POBRANIEM' => 'Za pobraniem',
|
||||
'PRZY ODBIORZE' => 'Przy odbiorze',
|
||||
'GOTÓWKĄ' => 'Gotówka',
|
||||
'*PRZELEW*' => '*Przelew*',
|
||||
);
|
||||
$payment_method_dom = array(
|
||||
"PRZELEW"=>'PRZELEW',
|
||||
"PRZEDPŁATA"=>'PRZEDPLATA',
|
||||
"PRZELEWEM"=>'PRZELEW',
|
||||
"GOTÓWKA"=>'GOTÓWKĄ',
|
||||
"POBRANIE T.K."=>'ZA POBRANIEM',
|
||||
"POBRANIE"=>'ZA POBRANIEM',
|
||||
"GOTÓWKĄ"=>'GOTÓWKĄ',
|
||||
"POBRANIE GOTÓWKA"=>'ZA POBRANIEM',
|
||||
"POPRANIE"=>'ZA POBRANIEM',
|
||||
"GOTWKA"=>'GOTÓWKĄ',
|
||||
"KOMPENSATA"=>'',
|
||||
);
|
||||
|
||||
$payment_date_days = $n;
|
||||
$id = create_guid();
|
||||
$name = $pre . " " . trim($row['NR_FK']);
|
||||
$description = ch($row['ADRES2'] . " " . $row['ADRES1'] . " " . $row['UWAGI'] . " " . $row['UWAGI1']);
|
||||
$date_entered = date("Y-m-d H:i:s");
|
||||
$date_modified = $date_entered;
|
||||
$modified_user_id = "eaa650d6-5a48-8a29-cd7c-554207f71255";
|
||||
$assigned_user_id = $modified_user_id;
|
||||
$created_by = $modified_user_id;
|
||||
$stock_id = $idmagazynu;
|
||||
$number = $date;
|
||||
$document_no = $pre . " " . trim($row['NR_FK']);
|
||||
$parent_type = "Accounts";
|
||||
$parent_name = empty($r['name']) ? '' : str_replace("'", "",$r['name']);
|
||||
$parent_id = empty($r['id']) ? '' : $r['id'];
|
||||
$type = "normal";
|
||||
$ecminvoiceout_id = 't';
|
||||
$ecminvoiceout_name = "";
|
||||
$status = "accepted";
|
||||
$register_date = $rd[0] . $rd[1] . $rd[2] . $rd[3] . "-" . $rd[4] . $rd[5] . "-" . $rd[6] . $rd[7];
|
||||
$sell_date = $sd[0] . $sd[1] . $sd[2] . $sd[3] . "-" . $sd[4] . $sd[5] . "-" . $sd[6] . $sd[7];
|
||||
$payment_date = $date3->format('Y-m-d');
|
||||
$parent_address_street = ch(str_replace("'", "", $row['ADRES2']));
|
||||
$parent_address_city = empty(ch($a1[1])) ? '' : ch($a1[1]);
|
||||
$parent_address_postalcode = empty($a1[0]) ? '' : $a1[0];
|
||||
$prepaid = empty($row['PRZEDPLATA']) ? '' : $row['PRZEDPLATA'];
|
||||
$paid_val = empty($row['GOTOWKA']) ? '' : $row['GOTOWKA'];
|
||||
$total_brutto = empty($row['WARTOSC']) ? '' : $row['WARTOSC'];
|
||||
$total_netto = $row['WARTOSC'] - $row['PODATEK'];
|
||||
$total_vat = $row['PODATEK'];
|
||||
if ($row['KURS'] != 0) {
|
||||
$total_brutto = round($total_brutto * $kurs,2);
|
||||
$total_netto = round($total_netto * $kurs,2);
|
||||
$total_vat = round($total_vat * $kurs,2);
|
||||
}
|
||||
$paid_val = $row['GOTOWKA'];
|
||||
$payment_method = $payment_method_dom[ch($row['SPOS_ZAP'])];
|
||||
$discount = 0;
|
||||
$pdf_type = 'K';
|
||||
$ecmlanguage = "pl_pl";
|
||||
$currency_id = empty($waluta) ? '' : $waluta;
|
||||
$currency_value = empty($kurs) ? '' : $kurs;
|
||||
$deleted = empty($type) ? '' : $type;
|
||||
$nr_system = $row['NR_SYSTEM'];
|
||||
|
||||
|
||||
$query = "INSERT ecminvoiceouts (";
|
||||
$query .= " id, ";
|
||||
$query .= " name, ";
|
||||
$query .= " deleted, ";
|
||||
$query .= " date_entered, ";
|
||||
$query .= " date_modified, ";
|
||||
$query .= " modified_user_id, ";
|
||||
$query .= " assigned_user_id, ";
|
||||
$query .= " created_by, ";
|
||||
$query .= " number, ";
|
||||
$query .= " document_no, ";
|
||||
$query .= " parent_type, ";
|
||||
$query .= " parent_name, ";
|
||||
$query .= " parent_id, ";
|
||||
$query .= " type, ";
|
||||
$query .= " register_date, ";
|
||||
$query .= " sell_date, ";
|
||||
$query .= " total_netto, ";
|
||||
$query .= " total_brutto, ";
|
||||
$query .= " total_vat, ";
|
||||
$query .= " parent_address_street, ";
|
||||
$query .= " parent_address_city, ";
|
||||
$query .= " parent_address_postalcode, ";
|
||||
$query .= " parent_nip_unformated, ";
|
||||
$query .= " parent_nip, ";
|
||||
$query .= " currency_id, ";
|
||||
$query .= " currency_value, ";
|
||||
$query .= " currency_value_nbp, ";
|
||||
$query .= " payment_date_days, ";
|
||||
$query .= " payment_date, ";
|
||||
$query .= " paid_val, ";
|
||||
$query .= " payment_method, ";
|
||||
$query .= " sys_number, ";
|
||||
$query .= " pdf_type, ";
|
||||
$query .= " canceled, ";
|
||||
$query .= " stock_id, ";
|
||||
$query .= " ecmlanguage, ";
|
||||
$query .= " document_autoincrement ";
|
||||
$query .= " ) VALUES (";
|
||||
$query .= "'" . $id . "',"; // id
|
||||
$query .= "'" . $name . "',"; // name
|
||||
$query .= "0,"; // deleted
|
||||
$query .= "NOW(),"; //date_entered
|
||||
$query .= "NOW(),"; //date_modified
|
||||
$query .= "'". $modified_user_id ."',"; //modified_user_id
|
||||
$query .= "'". $assigned_user_id ."',"; //assigned_user_id
|
||||
$query .= "'". $created_by ."',"; //created_by
|
||||
$query .= "'" . $number . "' ,"; // number
|
||||
$query .= "'" . $document_no . "' ,"; // document_no
|
||||
$query .= "'Accounts',"; // parent_type
|
||||
$query .= "'" . $parent_name . "',"; // parent_name
|
||||
$query .= "'" . $parent_id . "' ,"; // parent_id
|
||||
$query .= "'normal',"; // type
|
||||
$query .= "'" . $register_date . "',"; // register_date
|
||||
$query .= "'" . $sell_date . "',"; // sell_date
|
||||
$query .= "'" . $total_netto . "',"; // total_netto
|
||||
$query .= "'" . $total_brutto . "',"; // total_brutto
|
||||
$query .= "'" . $total_vat . "',"; // total_vat
|
||||
$query .= "'" . $parent_address_street . "',"; // parent_address_street
|
||||
$query .= "'" . $parent_address_city . "',"; // parent_address_city
|
||||
$query .= "'" . $parent_address_postalcode . "',"; // parent_address_postalcode
|
||||
$query .= "'" . $r['to_vatid'] . "',"; // parent_nip
|
||||
$query .= "'" . str_replace("-", '', $r['to_vatid']) . "',"; // parent_nip_unformated
|
||||
$query .= "'" . $currency_id . "',"; // currency_id
|
||||
$query .= "'" . $currency_value . "',"; // currency_value
|
||||
$query .= "'" . $currency_value . "',"; // currency_value
|
||||
$query .= "'" . $payment_date_days . "',"; // payment_date_days
|
||||
$query .= "'" . $payment_date . "',"; // payment_date$paid_val
|
||||
$query .= "'" . $paid_val . "',"; // paid_val
|
||||
$query .= "'" . $payment_method . "',"; // payment_method
|
||||
$query .= "'" . $nr_system . "',"; // sys_number
|
||||
$query .= "'" . $pdf_type . "',"; // sys_number
|
||||
$query .= "'" . $canceled . "',"; // canceled
|
||||
$query .= "'" . $idmagazynu . "',"; // payment_date
|
||||
$aa=explode('/',$document_no);
|
||||
preg_match('|\d+|',$aa[0],$matches);
|
||||
|
||||
$document_auto=date("Ymd",strtotime($register_date)).''.sprintf('%05d',(string)((int)$matches[0]));
|
||||
$query .= " 'pl_pl',"; // ecmlanguage
|
||||
$query .= "'" . $document_auto . "'"; // payment_date
|
||||
$query .= ");";
|
||||
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
echo $query . '<Br><br>';
|
||||
echo $mysqli->error;
|
||||
}
|
||||
foreach($row['LISTA_POZYCJI'] as $klucz => $wartosc){
|
||||
if(isset($nrmagazynu)){
|
||||
addProductLine($id, $klucz, $wartosc, $nrmagazynu);
|
||||
}else{
|
||||
addProductLine($id, $klucz, $wartosc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function addProductLine($id, $i, $r, $nrmagazynu=NULL) {
|
||||
|
||||
$jed=strtolower (str_replace('.','',$r['NAZWA_J_M']));
|
||||
$unit_id=array_search($jed, $jednostki);
|
||||
global $mysqli;
|
||||
$result = $mysqli->query("SELECT id FROM ecmproducts WHERE code ='" .ch($r['INDEKS']). "' and deleted='0'");
|
||||
$rr = $result->fetch_array(MYSQLI_ASSOC);
|
||||
$pid = $rr['id'];
|
||||
if ($rr['id'] == ''){
|
||||
|
||||
$result = $mysqli->query('SELECT id FROM ecmproducts WHERE code ="' .ch($r['INDEKS']) . '" and deleted="0"');
|
||||
$rr = $result->fetch_array(MYSQLI_ASSOC);
|
||||
$pid = $rr['id'];
|
||||
if ($rr['id'] == ''){
|
||||
$vats = array(
|
||||
"9b783d21-5548-6653-e1d6-49610eb3f9dd"=>0,
|
||||
"9c592a4a-2de0-1fa3-e082-494aeceb122c"=>22,
|
||||
"bf3a5fec-435f-af22-024a-4958b51863c8"=>7,
|
||||
"d7a2073e-44ca-7d52-cc02-5301eedef40f"=>'OO',
|
||||
"28079566-b825-e38f-9993-4ccc7b781de5"=>23,
|
||||
"49fa02ee-cdc2-9a51-0057-559a9f077708"=>'NP'
|
||||
);
|
||||
$oos=array(
|
||||
'38.11.55.0'=>1,
|
||||
'38.32.33.0'=>1,
|
||||
'38.32.29.0'=>1
|
||||
);
|
||||
$jednostki =
|
||||
array (
|
||||
1 => 'kg',
|
||||
2 => 'szt',
|
||||
3 => 'kpl',
|
||||
4 => 'mb',
|
||||
5 => 'm',
|
||||
6 => 't',
|
||||
7 => 'm2',
|
||||
8 => 'doba',
|
||||
9 => 'kmpl',
|
||||
'6275f1de-dbd1-7c7f-f722-556daf14780d' => 'l'
|
||||
);
|
||||
$vats=array(
|
||||
'9b783d21-5548-6653-e1d6-49610eb3f9dd'=>'0',
|
||||
'28079566-b825-e38f-9993-4ccc7b781de5'=>'23',
|
||||
'66fc9dba-818c-d321-2a55-524d13f8b0c2'=>'8'
|
||||
|
||||
);
|
||||
$jed=strtolower (str_replace('.','',$rowp['NAZWA_J_M']));
|
||||
$unit_id=array_search($jed, $jednostki);
|
||||
$vat=strtolower (str_replace('.','',$rowp['VAT']));
|
||||
$vat_id=array_search($vat, $vats);
|
||||
$oo=$oos[ch($rowp['PKWIU'])];
|
||||
|
||||
if(is_numeric($vat)){
|
||||
$vat_name=$vat.'%';
|
||||
$vat_value=$vat.'.00';
|
||||
} else {
|
||||
$vat_name=$vat;
|
||||
$vat_value=$vat.'.00';
|
||||
}
|
||||
$quer=('select * from dom_lists where dom_lists.key ="'.md5('ems').'" ');
|
||||
$res = $mysqli->query($quer);
|
||||
|
||||
//print_r($res->fetch_array(MYSQLI_ASSOC));
|
||||
if (empty($res->fetch_array(MYSQLI_ASSOC))) {
|
||||
print_r('done');
|
||||
$querr=('insert into dom_lists (id,lang,dom_name,dom_lists.key,dom_lists.value) Values("'.md5('ems1').'","pl_pl","ecmproducts_group_ks_dom","'.md5('ems').'","ems")');
|
||||
print_r($querr);
|
||||
$mysqli->query($querr);
|
||||
}
|
||||
|
||||
//dodanie produktu
|
||||
$q=('INSERT INTO ecmproducts (id,name,code,sys_ident,status,unit_id,vat_id,vat_name,vat_value,pkwiu,vendor_name,vendor_id,OO,ks_group)
|
||||
VALUES ("');
|
||||
$indeks=!empty(ch($r['INDEKS']))?ch($r['INDEKS']):'inne-'.date('y-m-d-s');
|
||||
$q.=create_guid().'","';
|
||||
$q.=ch($r['NAZWA']).'","';
|
||||
$q.=$indeks.'","';
|
||||
$q.=ch($r['NR_SYSTEM']).'","';
|
||||
$q.='active'.'","';
|
||||
$q.=$unit.'","';
|
||||
$q.=$vat_id.'","';
|
||||
$q.=$vat_name.'","';
|
||||
$q.=$vat_value.'","';
|
||||
$q.=ch($r['PKWIU']).'","';
|
||||
$q.='","';
|
||||
$q.='","';
|
||||
$q.=$oo.'","';
|
||||
$q.=md5('ems');
|
||||
|
||||
|
||||
$q.='")';
|
||||
print_r($q);
|
||||
$res=$mysqli->query($q);
|
||||
if (!$res) {
|
||||
echo $mysqli->error;
|
||||
echo $query . '<Br><br>';
|
||||
}
|
||||
//print_r($r);die();
|
||||
//$pid=getnr($r['INDEKS'], $nrmagazynu);
|
||||
}
|
||||
}
|
||||
$iid = create_guid();
|
||||
|
||||
//repair prices (remove ',')
|
||||
$r['CENA_SPRZ'] = trim(str_replace(",", ".", $r['CENA_SPRZ']));
|
||||
$r['CENA_POCZ'] = trim(str_replace(",", ".", $r['CENA_POCZ']));
|
||||
$r['WARTOSC'] = trim(str_replace(",", ".", $r['WARTOSC']));
|
||||
$r['RABAT'] = trim(str_replace(",", ".", $r['RABAT']));
|
||||
$r['CENA_EWID'] = trim(str_replace(",", ".", $r['CENA_EWID']));
|
||||
$subtotal = $r['WARTOSC'];
|
||||
$arr = array(
|
||||
"id" => $iid,
|
||||
"date_entered" => date("Y-m-d H:i:s"),
|
||||
"date_modified" => date("Y-m-d H:i:s"),
|
||||
"modified_user_id" => "eaa650d6-5a48-8a29-cd7c-554207f71255",
|
||||
"assigned_user_id" => "eaa650d6-5a48-8a29-cd7c-554207f71255",
|
||||
"created_by" => "eaa650d6-5a48-8a29-cd7c-554207f71255",
|
||||
"deleted" => 0,
|
||||
"ecminvoiceout_id" => $id,
|
||||
"ecmproduct_id" => $pid,
|
||||
"position" => $i,
|
||||
"code" => ch(str_replace("'", "", $r['INDEKS'])),
|
||||
"name" => ch(str_replace("'", "", $r['NAZWA'])),
|
||||
"quantity" => $r['ILOSC'],
|
||||
"price_start" => $r['CENA_POCZ'],
|
||||
"price_netto" => $r['CENA_SPRZ'],
|
||||
"price_brutto" => round($r['CENA_SPRZ']*strtolower (str_replace('.','',$r['VAT'])),2) + $r['CENA_SPRZ'],
|
||||
"discount" => $r['RABAT'],
|
||||
"total_netto" => $r['WARTOSC'],
|
||||
"total_brutto" => $r['WARTOSC'] + $r['POD_WART'],
|
||||
"total_vat" => $r['POD_WART'],
|
||||
"price_purchase" => round($r['CENA_EWID'] / $r['ILOSC'],2),
|
||||
"dd_unit_name" => $r['NAZWA_J_M'],
|
||||
"dd_unit_id" => md5($r['NAZWA_J_M']),
|
||||
"ecmvat_id" => md5($r['VAT'].'asd'),
|
||||
"ecmvat_value" => strtolower (str_replace('.','',$r['VAT'])),
|
||||
"ecmvat_name" => $r['VAT'] . "%",
|
||||
);
|
||||
foreach ($arr as $k => $v) {
|
||||
$in[] = $k . "='" . $v . "'";
|
||||
}
|
||||
$query = "insert into ecminvoiceoutitems set " . implode(",", $in) . ";\n";
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
echo $mysqli->error;
|
||||
echo $query . '<Br><br>';
|
||||
}
|
||||
}
|
||||
|
||||
function wczytajFaktury($path, $path2){
|
||||
//Naglowki faktur
|
||||
$dbf = new dbf_class($path);
|
||||
$num_rec = $dbf->dbf_num_rec;
|
||||
$dokumenty = array();
|
||||
echo $num_rec. '<br>';
|
||||
for ($i = 0; $i < $num_rec; $i++) {
|
||||
$row = $dbf->getRowAssoc($i);
|
||||
if(!$row){
|
||||
// echo 'Pominieto wiersz naglowka'.$i.' z '. $num_rec. ' '.$path.'<br>';
|
||||
continue;
|
||||
}
|
||||
if(strlen($row['NR_SYSTEM'])>0){
|
||||
$dokumenty[$row['NR_SYSTEM']] = array();
|
||||
//$dokumenty[$row['NR_SYSTEM']] = $row;
|
||||
foreach($row as $key => $value){
|
||||
if(strlen($value)>0){
|
||||
$dokumenty[$row['NR_SYSTEM']][$key] = $value;
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo 'BRAK NUMERU FAKTURY!<br>';
|
||||
// var_dump($row);
|
||||
echo '<br><br>';
|
||||
}
|
||||
}
|
||||
|
||||
//Pozycje faktur
|
||||
$dbfp = new dbf_class($path2);
|
||||
$num_recp = $dbfp->dbf_num_rec;
|
||||
for ($i = 0; $i < $num_recp; $i++) {
|
||||
$row = $dbfp->getRowAssoc($i);
|
||||
if(!$row){
|
||||
// echo 'Pominieto wiersz pozycji'.$i.' z '. $num_rec. ' ' .$path2. '<br>';
|
||||
continue;
|
||||
}
|
||||
if(isset($dokumenty[$row['NR_SYSTEM']])){
|
||||
if(isset($dokumenty[$row['NR_SYSTEM']]['LISTA_POZYCJI'])){
|
||||
$tmprow = array();
|
||||
foreach($row as $key => $value){
|
||||
if(strlen($value)>0){
|
||||
$tmprow[$key] = $value;
|
||||
}
|
||||
}
|
||||
$dokumenty[$row['NR_SYSTEM']]['LISTA_POZYCJI'][] = $tmprow;
|
||||
}else{
|
||||
$dokumenty[$row['NR_SYSTEM']]['LISTA_POZYCJI'] = array();
|
||||
$tmprow = array();
|
||||
foreach($row as $key => $value){
|
||||
if(strlen($value)>0){
|
||||
$tmprow[$key] = $value;
|
||||
}
|
||||
}
|
||||
$dokumenty[$row['NR_SYSTEM']]['LISTA_POZYCJI'][] = $tmprow;
|
||||
}
|
||||
}else{
|
||||
// var_dump($row);
|
||||
echo '<br><br>';
|
||||
}
|
||||
}
|
||||
return $dokumenty;
|
||||
}
|
||||
|
||||
// Obsluga importu
|
||||
$start = microtime_float();
|
||||
|
||||
echo 'Wczytywanie dokumentow...<br>';
|
||||
$re = $mysqli->query('SELECT id, dir FROM ecmstocks');
|
||||
while($magazyn = $re->fetch_array(MYSQLI_ASSOC)){
|
||||
|
||||
echo 'Magazyn: ' . $magazyn['name'] . '<br>';
|
||||
if($magazyn['dir']=='1'){
|
||||
$path2 = dirname(__FILE__).'/przemyslowka/1/_FK_LIST.DBF';
|
||||
$path = dirname(__FILE__).'/przemyslowka/1/_FK.DBF';;
|
||||
$dokumenty = wczytajFaktury($path , $path2);
|
||||
dodajFaktury($dokumenty, $magazyn['id']);
|
||||
} else {
|
||||
$path2 = dirname(__FILE__).'/przemyslowka/glowny/_FK_LIST.DBF';
|
||||
$path = dirname(__FILE__).'/przemyslowka/glowny/_FK.DBF';;
|
||||
$dokumenty = wczytajFaktury($path , $path2);
|
||||
dodajFaktury($dokumenty, $magazyn['id'], $magazyn['dir']);
|
||||
}
|
||||
}
|
||||
echo 'Zakonczono wczytywanie dokumentow<br>';
|
||||
//echo 'Dodawanie faktur...<br>';
|
||||
//aaaaaaaaa
|
||||
//echo 'Zakonczono dodawanie faktur<br>';
|
||||
|
||||
|
||||
$res2 = $mysqli->query("select * from ecminvoiceouts where type='normal'");
|
||||
|
||||
while($r = $res2->fetch_array(MYSQLI_ASSOC)){
|
||||
|
||||
$vats_summary = '';
|
||||
$total_netto = 0;
|
||||
$total_brutto = 0;
|
||||
$total_vat = 0;
|
||||
|
||||
$res = $mysqli->query( "select ROUND(sum(total_netto),2) AS total_netto,ROUND(sum((total_netto*ecmvat_value)/100),2) AS total_vat,
|
||||
ROUND(sum(((total_netto*ecmvat_value)/100)+total_netto),2) AS total_brutto,ecmvat_value,ecmvat_name
|
||||
from ecminvoiceoutitems where ecminvoiceout_id='" . $r['id'] . "' group by ecmvat_id" );
|
||||
while ( $cc=$res->fetch_array(MYSQLI_ASSOC) ) {
|
||||
$total_netto += $cc ['total_netto'];
|
||||
$total_brutto += $cc ['total_brutto'];
|
||||
$total_vat += $cc ['total_vat'];
|
||||
if($cc ['ecmvat_name']=='OO'){
|
||||
$cc ['ecmvat_value']=$cc ['ecmvat_name'];
|
||||
} else {
|
||||
$cc ['ecmvat_value']=$cc ['ecmvat_name'];
|
||||
}
|
||||
$vats_summary .= $cc ['ecmvat_value'] . ':' . $cc ['total_netto'] . ':' . $cc ['total_vat'] . ':' . $cc ['total_brutto'] . ',';
|
||||
}
|
||||
$res = $mysqli->query( "update ecminvoiceouts set vats_summary='" . $vats_summary . "',total_netto='" . $total_netto . "',total_vat='" . $total_vat . "',
|
||||
total_brutto='" . $total_brutto . "' where id='" .$r['id']. "'" );
|
||||
|
||||
}
|
||||
|
||||
$koniec = microtime_float();
|
||||
echo "<br><br>Czas trawania:".(($koniec - $start)/60)." minut<br>";
|
||||
$mysqli->close();
|
||||
|
||||
?>
|
||||
209
import/import/helper.php
Executable file
209
import/import/helper.php
Executable file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
function create_guid()
|
||||
{
|
||||
$microTime = microtime();
|
||||
list($a_dec, $a_sec) = explode(" ", $microTime);
|
||||
|
||||
$dec_hex = sprintf("%x", $a_dec* 1000000);
|
||||
$sec_hex = sprintf("%x", $a_sec);
|
||||
|
||||
ensure_length($dec_hex, 5);
|
||||
ensure_length($sec_hex, 6);
|
||||
|
||||
$guid = "";
|
||||
$guid .= $dec_hex;
|
||||
$guid .= create_guid_section(3);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section(4);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section(4);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section(4);
|
||||
$guid .= '-';
|
||||
$guid .= $sec_hex;
|
||||
$guid .= create_guid_section(6);
|
||||
|
||||
return $guid;
|
||||
|
||||
}
|
||||
|
||||
function create_guid_section($characters)
|
||||
{
|
||||
$return = "";
|
||||
for($i=0; $i<$characters; $i++)
|
||||
{
|
||||
$return .= sprintf("%x", mt_rand(0,15));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function ensure_length(&$string, $length)
|
||||
{
|
||||
$strlen = strlen($string);
|
||||
if($strlen < $length)
|
||||
{
|
||||
$string = str_pad($string,$length,"0");
|
||||
}
|
||||
else if($strlen > $length)
|
||||
{
|
||||
$string = substr($string, 0, $length);
|
||||
}
|
||||
}
|
||||
function ch($str){
|
||||
return iconv("CP852","UTF-8",$str);
|
||||
}
|
||||
function addPzBilans($name,$stock_id){
|
||||
|
||||
$id="bilans_otwarcia".$stock_id;
|
||||
$arr=array(
|
||||
"id"=>$id,
|
||||
"name"=>"Bilans otwarcia",
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"document_no"=>$name,
|
||||
"number"=>1,
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
//"parent_name"=>"E5 Polska Sp. z o. o.",
|
||||
"parent_id"=>36,
|
||||
"status"=>"accepted",
|
||||
"register_date"=>"2009-10-06",
|
||||
"parent_address_street"=>"Wąwozowa 11",
|
||||
"parent_address_city"=>"Warszawa",
|
||||
"parent_address_postalcode"=>"02-796",
|
||||
"subtotal"=>0,
|
||||
"total"=>0,
|
||||
"discount"=>0,
|
||||
"ecmlanguage"=>"pl_pl",
|
||||
"template_id"=>"1d178dc6-0904-3fa3-f51b-4a4b4698a173",
|
||||
"template_name"=>"E5 Polska Sp. z o. o.",
|
||||
"stock_id"=>$stock_id,
|
||||
"currency_id"=>"PLN",
|
||||
"correct_id"=>"",
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
//mysql_query("insert into ecmstockdocins set ".implode(",",$in));
|
||||
$a="insert into ecmstockdocins set ".implode(",",$in).";\n";
|
||||
echo $a;
|
||||
//echo $i." [".$row['NR_PZ']."]\n";
|
||||
if(mysql_error())echo mysql_error();
|
||||
return $id;
|
||||
}
|
||||
function addProductLinePZ($id,$i,$r,$index,$name){
|
||||
$vats=array(
|
||||
0=>"9b783d21-5548-6653-e1d6-49610eb3f9dd",
|
||||
22=>"9c592a4a-2de0-1fa3-e082-494aeceb122c",
|
||||
'OO'=>"d7a2073e-44ca-7d52-cc02-5301eedef40f",
|
||||
23=>"93295ab1-bc7d-74a3-5644-4d21770fa33b",
|
||||
7=>"bf3a5fec-435f-af22-024a-4958b51863c8",
|
||||
);
|
||||
$rr=mysql_fetch_array(mysql_query("select id from ecmproducts where code like '".$index."' and deleted='0'"));
|
||||
$pid=$rr['id'];
|
||||
if($pid==""){
|
||||
$pid=addProduct($index,$name);
|
||||
}
|
||||
$iid=create_guid();
|
||||
$arr=array(
|
||||
"id"=>$iid,
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"deleted"=>0,
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
"ecmstockdocin_id"=>$id,
|
||||
"ecmproduct_id"=>$pid,
|
||||
"position"=>$i,
|
||||
"code"=>str_replace("'",""",$index),
|
||||
"name"=>str_replace("'",""",$name),
|
||||
"quantity"=>round($r['ILOSC'],2),
|
||||
"price"=>$r['CENA_ZAK'],
|
||||
"discount"=>$r['RABAT'],
|
||||
"total"=>$r['CENA_ZAK']*$r['ILOSC'],
|
||||
"dd_unit_name"=>$r['NAZWA_J_M'],
|
||||
"dd_unit_id"=>1,
|
||||
"ecmvat_id"=>$vats[$r['VAT']],
|
||||
"ecmvat_value"=>$r['VAT'],
|
||||
"ecmvat_name"=>$r['VAT']."%",
|
||||
"currency_id"=>"PLN",
|
||||
"currency_name"=>"PLN",
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
// mysql_query("insert into ecmstockdocinitems set ".implode(",",$in));
|
||||
$a= "insert into ecmstockdocinitems set ".implode(",",$in).";\n";
|
||||
echo $a;
|
||||
if(mysql_error())echo mysql_error()."\n";
|
||||
return $iid;
|
||||
}
|
||||
function checkCharset($testString, $targetString){
|
||||
$out=false;
|
||||
$encoding=array("ASCII","ISO-8859-1","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-7","ISO-8859-9","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","KOI8-R","KOI8-U","KOI8-RU","CP1250","CP1251","CP1252","CP1253","CP1254","CP1257","CP850","CP866","Mac Roman","Mac CentralEurope","Mac Iceland","Mac Croatian","Mac Romania","Mac Cyrillic","Mac Ukraine","Mac Greek","Mac Turkish", "Macintosh","ISO-8859-6","ISO-8859-8", "CP1255","CP1256", "CP862","Mac Hebrew","Mac Arabic","EUC-JP", "SHIFT_JIS", "CP932", "ISO-2022-JP", "ISO-2022-JP-2", "ISO-2022-JP-1","EUC-CN","HZ","GBK","GB18030","EUC-TW","BIG5","CP950","BIG5-HKSCS","ISO-2022-CN","ISO-2022-CN-EXT","EUC-KR","CP949","ISO-2022-KR","JOHAB","ARMSCII-8","Georgian-Academy","Georgian-PS","KOI8-T","TIS-620","CP874","MacThai","MuleLao-1","CP1133","VISCII","TCVN","CP1258","HP-ROMAN8","NEXTSTEP","UTF-8","UCS-2","UCS-2BE","UCS-2LE","UCS-4","UCS-4BE","UCS-4LE","UTF-16","UTF-16BE","UTF-16LE","UTF-32","UTF-32BE","UTF-32LE","UTF-7","C99","JAVA","UCS-2-INTERNAL","UCS-4-INTERNAL","CP437","CP737","CP775","CP852","CP853","CP855","CP857","CP858","CP860","CP861","CP863","CP865","CP869","CP1125","CP864","EUC-JISX0213","Shift_JISX0213","ISO-2022-JP-3","TDS565","RISCOS-LATIN1");
|
||||
foreach($encoding as $v){
|
||||
if(iconv($v, "utf-8", $testString) === $targetString){$out=$v;}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
function addProduct($code,$name){
|
||||
$id=create_guid();
|
||||
if(!$name)$name=$code;
|
||||
$arr=array(
|
||||
"id"=>$id,
|
||||
"name"=>str_replace("'",""",$name),
|
||||
"index_dbf"=>str_replace("'",""",$code),
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"assigned_user_id"=>1,
|
||||
"modified_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
//mysql_query("insert into ecmproducts set ".implode(",",$in));
|
||||
$a="insert into ecmproducts set ".implode(",",$in).";\n";
|
||||
echo $a;
|
||||
return $id;
|
||||
}
|
||||
function addOperation($doc_id,$doc_name,$doc_type,$item_id,$index,$name,$qty,$price,$type,$stock_id,$stock_name){
|
||||
$rr=mysql_fetch_array(mysql_query("select id from ecmproducts where code='".str_replace("'",""",$index)."'"));
|
||||
$pid=$rr['id'];
|
||||
if($pid==""){
|
||||
$pid=addProduct($index,$name);
|
||||
}
|
||||
$oid=create_guid();
|
||||
|
||||
$arr=array(
|
||||
"id"=>$oid,
|
||||
"date_entered"=>date("Y-m-d H:i:s"),
|
||||
"date_modified"=>date("Y-m-d H:i:s"),
|
||||
"deleted"=>0,
|
||||
"modified_user_id"=>1,
|
||||
"assigned_user_id"=>1,
|
||||
"created_by"=>1,
|
||||
"stock_id"=>$stock_id,
|
||||
"stock_name"=>$stock_name,
|
||||
"product_id"=>$pid,
|
||||
"product_name"=>str_replace("'",""",$name),
|
||||
"product_code"=>str_replace("'",""",$index),
|
||||
"quantity"=>abs($qty),
|
||||
"price"=>$price,
|
||||
"parent_type"=>$doc_type,
|
||||
"parent_name"=>str_replace("'",""",$doc_name),
|
||||
"parent_id"=>$doc_id,
|
||||
"documentitem_id"=>$item_id,
|
||||
"type"=>$type,
|
||||
);
|
||||
foreach($arr as $k=>$v){
|
||||
$in[]=$k."='".$v."'";
|
||||
}
|
||||
//mysql_query("insert into ecmstockoperations set ".implode(",",$in));
|
||||
$a="insert into ecmstockoperations set ".implode(",",$in).";\n";
|
||||
echo $a;
|
||||
return $oid;
|
||||
}
|
||||
?>
|
||||
127
import/import/imp_trans_w.php
Executable file
127
import/import/imp_trans_w.php
Executable file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
include_once("class.dbf.php");
|
||||
include_once("../config.php");
|
||||
include_once("helper.php");
|
||||
global $sugar_config;
|
||||
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
||||
|
||||
mysql_query("set character set utf8;");
|
||||
|
||||
$path = dirname(__FILE__).'/ekomer/_DOSTAW.DBF';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$sugar_fields = array ('id','index_dbf','name','billing_address_postalcode','billing_address_street','to_vatid','phone_office','phone_fax','description','email');
|
||||
|
||||
$insert = array();
|
||||
$count =0;
|
||||
//for($i=0;$i<$num_recp;$i++){
|
||||
$j=0;
|
||||
for($i=$num_recp;$i>0;$i--){
|
||||
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
//print_r($rowp);
|
||||
//echo '<br>'.$rowp['ALBANIA'].'a<br>';
|
||||
//echo $back.' '.$rowp['FASTECH_SH'].'<br>';
|
||||
//echo 'lol';
|
||||
|
||||
$row = array (
|
||||
addslashes(create_guid()), //id
|
||||
addslashes(ch($rowp['NR_EWIDENC'])), //nazwa
|
||||
addslashes(ch($rowp['NAZWA'])),
|
||||
addslashes(ch($rowp['NIPBK'])),
|
||||
|
||||
|
||||
|
||||
);
|
||||
//echo 'add<br>';
|
||||
array_push($insert, $row);
|
||||
// echo ch($rowp['NAZWA']);
|
||||
|
||||
//echo $a.'a<br>';
|
||||
//END ROW ARRAY
|
||||
|
||||
}
|
||||
|
||||
//CREATE QUERY
|
||||
//echo sizeof($insert).'';
|
||||
|
||||
///////////////
|
||||
$path = dirname(__FILE__).'/ekomer/_wn.dbf';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$sugar_fields = array ('id','index_dbf','name','billing_address_postalcode','billing_address_street','to_vatid','phone_office','phone_fax','description','email');
|
||||
|
||||
$insert2 = array();
|
||||
$count =0;
|
||||
//for($i=0;$i<$num_recp;$i++){
|
||||
$j=0;
|
||||
for($i=$num_recp;$i>0;$i--){
|
||||
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
//print_r($rowp);
|
||||
//echo '<br>'.$rowp['ALBANIA'].'a<br>';
|
||||
//echo $back.' '.$rowp['FASTECH_SH'].'<br>';
|
||||
//echo 'lol';
|
||||
|
||||
$row = array (
|
||||
addslashes(create_guid()), //id
|
||||
addslashes(ch($rowp['NR_SYSTEM'])), //nazwa
|
||||
addslashes(ch($rowp['KWOTA'])),
|
||||
addslashes(ch($rowp['OPIS'])),
|
||||
addslashes(ch($rowp['ROZL'])),
|
||||
addslashes(ch($rowp['DATA'])),
|
||||
addslashes(ch($rowp['SYM_DOK']." ".$rowp['NR_DOK'])),
|
||||
|
||||
|
||||
);
|
||||
//echo 'add<br>';
|
||||
array_push($insert2, $row);
|
||||
// echo ch($rowp['NAZWA']);
|
||||
|
||||
//echo $a.'a<br>';
|
||||
//END ROW ARRAY
|
||||
|
||||
}
|
||||
|
||||
for ($i=0; $i<count($insert2); $i++) {
|
||||
|
||||
|
||||
$zapyt=mysql_query("SELECT id,name from ekomer.accounts where index_dbf= '".$insert2[$i][1]."'");
|
||||
$zapyt2=mysql_query("SELECT id,name from ekomer.ecminvoiceouts where name = '".$insert2[$i][6]."'");
|
||||
$dane2=mysql_fetch_array($zapyt2);
|
||||
if(mysql_num_rows($zapyt2)>0){
|
||||
$record_type='EcmInvoiceOuts';
|
||||
}
|
||||
//echo "SELECT id,name from ekomer.accounts where index_dbf='".$insert2[$i][1]."'".'<br>';
|
||||
$dane=mysql_fetch_array($zapyt);
|
||||
$acc=mysql_num_rows($zapyt);
|
||||
if($insert2[$i][2]=="") continue;
|
||||
|
||||
//print_r($dane);
|
||||
$licznik++;
|
||||
$rok=substr($insert2[$i][5],0,4);
|
||||
$miech=substr($insert2[$i][5],4,2);
|
||||
$dzien=substr($insert2[$i][5],6,2);
|
||||
$dzien=substr($insert2[$i][5],6,2);
|
||||
|
||||
if($insert2[$i][4]=="T"){$payd=1; } else { $payd=0; }
|
||||
//echo "SELECT id,name from ekomer.accounts where name='".$insert[$ia][2]."'";
|
||||
echo "INSERT INTO ekomer.ecmtransactions(id,name,date_entered,date_modified,modified_user_id,created_by,description,deleted,assigned_user_id,value,parent_name,parent_id,payment_date,type,paid,register_date,record_type,record_id)VALUES('".$insert2[$i][0]."','".$insert2[$i][3]."','".$rok."-".$miech."-".$dzien."','".$rok."-".$miech."-".$dzien."','1','1','1','0','1','".$insert2[$i][2]."','".$dane['name']."','".$dane['id']."','".$rok."-".$miech."-".$dzien."','0','".$payd."','".$rok."-".$miech."-".$dzien."','".$record_type."','".$dane2['id']."');\n";
|
||||
//echo $query;
|
||||
//mysql_query(ch($query));
|
||||
|
||||
|
||||
//echo implode("','",$insert[$i]);
|
||||
//PRODUCT INSERT
|
||||
//
|
||||
//if (mysql_error()) echo 'Database error: '.mysql_error().'';
|
||||
|
||||
} echo $licznik;
|
||||
mysql_close($sql);
|
||||
|
||||
?>
|
||||
139
import/import/importDocuments.php
Executable file
139
import/import/importDocuments.php
Executable file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
include_once ("/var/www/html/e5new/config.php");
|
||||
global $sugar_config;
|
||||
$db = mysql_connect ( $sugar_config ['dbconfig'] ['db_host_name'], $sugar_config ['dbconfig'] ['db_user_name'], $sugar_config ['dbconfig'] ['db_password'] );
|
||||
|
||||
mysql_query ( "USE e5crm" );
|
||||
$docs = mysql_query ( "SELECT * FROM ecmdocs" );
|
||||
|
||||
//naprawa plików
|
||||
while ($d = mysql_fetch_array($docs)) {
|
||||
$f = mysql_fetch_array(mysql_query("SELECT * FROM ecmfiles_versions WHERE file_id='".$d['file_id']."'"));
|
||||
$tmp = pathinfo($f['filename']);
|
||||
$old = '/var/www/html/e5new/upload/'.$tmp['basename'];
|
||||
$new = '/var/www/html/e5new/upload/'.$d['file_id'];
|
||||
|
||||
$w = rename($old, $new);
|
||||
if ($w == false)
|
||||
echo 'Error: '.$old.' ------ '.$new.'
|
||||
';
|
||||
}
|
||||
|
||||
|
||||
die();
|
||||
//import dokumentów
|
||||
// users id array
|
||||
// old_id => new_id
|
||||
$users = array (
|
||||
// kl
|
||||
'4' => '40e80a1d-6fd9-83d1-e61e-5236e3e39979',
|
||||
// mf
|
||||
'5' => 'be5b7acb-cb35-186b-7229-523818723665',
|
||||
// jj
|
||||
'3' => '755927dd-4c7e-24de-38b1-524ad5c47b89',
|
||||
// mz
|
||||
'f1963700-4249-2022-1022-4e393326a7b4' => '1',
|
||||
// s8 - bg
|
||||
'812d6ca4-77c8-8908-f695-4c0cec0f8a56' => 'b5810ca7-fa8f-8aef-b694-5236e3c983c9',
|
||||
// s2 - pg
|
||||
'dbf183f4-70da-2e17-1745-4acb40d0294b' => 'c054ae2d-7d94-5a74-28a0-5236e3d1493e',
|
||||
// s1 - s1
|
||||
'c06124a2-9623-5020-dcd8-4f718387a989' => '41949394-ef36-a332-df4f-524418147444',
|
||||
// s7 - s7
|
||||
'adb13cf1-6db5-7032-6086-4c0cec9d6386' => '231e3dc2-c567-33e7-1aae-52441966e742',
|
||||
// s4 - ja
|
||||
'657e23f8-dc76-a0b2-89b1-515aa91fa90e' => '1051daeb-d468-f7eb-89a1-52381821bc8d',
|
||||
// l.lisinska - ll
|
||||
'12a80231-c3a6-52a3-aed1-51a47dfcf849' => 'e3a315cd-5752-4e83-aa73-5236e2a2d39c',
|
||||
// d.piotrowska - dp
|
||||
'408fb7aa-98f4-ff78-0efd-4bc8007660e5' => 'c397ef4d-ddad-ea86-3161-5236e3b16caf',
|
||||
// a.drozdowska - ad
|
||||
'ca868d4a-9821-9707-d59c-51112661e4f9' => '54eb00ac-d71a-1749-1111-524ad6b2886a',
|
||||
// magazyn - magazyn
|
||||
'94e62fc0-3c5b-fbd9-d61e-4923f30ba6ea' => '6cb17cef-cf4c-e5db-57bc-52455441b1c1',
|
||||
// magazyn1 - finanse
|
||||
'ce224fce-3a28-d3aa-f005-4923f36fcaf2' => 'b991adbb-ddad-5d5d-8a49-52455568184a',
|
||||
// r.kubiak - rk
|
||||
'23cae697-a9ad-69b0-a305-51932bb22ca2' => '74279c89-5ef5-01da-7018-524553519e26',
|
||||
// grafik - ba
|
||||
'84bbd698-5424-2991-369e-4b9e5441d77e' => '76a7515b-8584-64fc-105e-524554ceecd7'
|
||||
);
|
||||
|
||||
$other_user = '82d4af6b-f416-7ede-57f6-524ad799b1d7'; // Pan Import
|
||||
|
||||
$types = array (
|
||||
'6fa1b8bd-7bc7-0f39-5416-47c273ce19be' => 'invoice', // fv
|
||||
'1c3546ce-6d8b-ffca-dabe-47c273bfb198' => 'other', // inne
|
||||
'9d540666-7015-922c-8827-4cc694b125d1' => 'compain_note', // nota rek
|
||||
'b86592e8-fa0c-7b50-bc3e-4cc694d68c94' => 'return_note', // nota zw
|
||||
'4bd90c14-4268-113e-7eea-51e3d258cfc2' => 'production', // produkcja
|
||||
'5b3771ef-37b9-8c7f-7091-48e2575eaa9c' => 'contract', // umowa
|
||||
'ea347e3c-3ba2-5a46-3428-48ca32bb4fa6' => 'bank_statement' //wyciąg bankowy
|
||||
|
||||
|
||||
);// wyciąg bankowy
|
||||
$queries = array();
|
||||
|
||||
while ( $d = mysql_fetch_array ( $docs ) ) {
|
||||
//get file info
|
||||
$file = mysql_fetch_array(mysql_query("SELECT * FROM ecmfiles WHERE id='".$d['file_id']."'"));
|
||||
//document
|
||||
$user = $other_user;
|
||||
if (array_key_exists($d['modified_user_id'], $users)) $user=$users[$d['modified_user_id']];
|
||||
if (!$user && $user=='') $user = $other_user;
|
||||
|
||||
$cat = $types[$d['group_id']];
|
||||
if (!$cat && $cat=='') $cat = 'other';
|
||||
|
||||
$q = "INSERT INTO documents VALUES (
|
||||
'" . $d ['id'] . "',
|
||||
'" . $d ['date_entered'] . "',
|
||||
'".$d['date_modified']."',
|
||||
'".$user."',
|
||||
'".$user."',
|
||||
'".mysql_real_escape_string($d['description'])."',
|
||||
'0',
|
||||
'".$file['name']."',
|
||||
'".substr($d['date_entered'], 0,10)."',
|
||||
'',
|
||||
'".$cat."',
|
||||
'',
|
||||
'Active',
|
||||
'".$d['file_id']."',
|
||||
'',
|
||||
'',
|
||||
'0',
|
||||
'',
|
||||
'".$d['account_id']."',
|
||||
'".$d['account_name']."',
|
||||
'".$d['value']."'
|
||||
)";
|
||||
$queries[] = $q;
|
||||
|
||||
$t = pathinfo($file['name']);
|
||||
if (array_key_exists('extension', $t))
|
||||
$ext = $t['extension'];
|
||||
else
|
||||
$ext = '';
|
||||
//file query
|
||||
$q = "INSERT INTO document_revisions VALUES (
|
||||
'".$file['id']."',
|
||||
'',
|
||||
'".$d['id']."',
|
||||
'".$d['date_entered']."',
|
||||
'".$user."',
|
||||
'".$file['name']."',
|
||||
'".$ext."',
|
||||
'',
|
||||
'1',
|
||||
'0',
|
||||
'".$d['date_modified']."'
|
||||
)";
|
||||
$queries[] = $q;
|
||||
}
|
||||
|
||||
//insert!
|
||||
mysql_query("USE crm");
|
||||
foreach ($queries as $query)
|
||||
mysql_query($query);
|
||||
?>
|
||||
26
import/import/import_b2b_product.php
Executable file
26
import/import/import_b2b_product.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
error_reporting(E_ERROR);
|
||||
include_once("class.dbf.php");
|
||||
include_once("/var/www/crm/config.php");
|
||||
include_once("helper.php");
|
||||
global $sugar_config;
|
||||
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
||||
mysql_query("set character set utf8;");
|
||||
$path = dirname(__FILE__).'/_stany.dbf';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$b2b_product_1 = array();
|
||||
$b2b_product_0 = array();
|
||||
for($i=0;$i<$num_recp;$i++){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
if ($rowp['KOD_KOLORU']=='1') array_push($b2b_product_1, addslashes($rowp['INDEKS']));
|
||||
if ($rowp['KOD_KOLORU']=='0') array_push($b2b_product_0, addslashes($rowp['INDEKS']));
|
||||
}
|
||||
|
||||
mysql_query("UPDATE ecmproducts set b2b_product='1' where index_dod IN ('".implode("','", $b2b_product_1)."')");
|
||||
mysql_query("UPDATE ecmproducts set b2b_product='0' where index_dod IN ('".implode("','", $b2b_product_0)."')");
|
||||
?>
|
||||
9
import/import/import_bsl_start.php
Normal file
9
import/import/import_bsl_start.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
include 'import_kontrahentow.php';
|
||||
include 'import_kontrahentow_dostaw.php';
|
||||
include 'nowy_import.php';
|
||||
include 'fk.php';
|
||||
include 'kfms.php';
|
||||
include 'pz_bsl.php';
|
||||
include 'import_transakcji.php';
|
||||
?>
|
||||
160
import/import/import_cenniki.php
Executable file
160
import/import/import_cenniki.php
Executable file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
include_once("class.dbf.php");
|
||||
include_once("/var/www/crm/config.php");
|
||||
include_once("helper.php");
|
||||
global $sugar_config;
|
||||
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
||||
|
||||
|
||||
//get actual id's
|
||||
$ids = array();
|
||||
$res = mysql_query("SELECT id, index_dbf FROM ecmpricebooks");
|
||||
while ($row = mysql_fetch_array($res))
|
||||
$ids[$row['index_dbf']] = $row['id'];
|
||||
|
||||
//var_dump($ids);
|
||||
|
||||
mysql_query("truncate ecmpricebooks");
|
||||
mysql_query("truncate ecmpricebooks_ecmproducts");
|
||||
mysql_query("set character set utf8;");
|
||||
|
||||
$path = dirname(__FILE__).'/_ceny.dbf';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$pricebooks = array();
|
||||
|
||||
for($i=0;$i<$num_recp;$i++){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
if (($rowp['KOD_CENYQ']=='')) continue;
|
||||
|
||||
if (!isset($pricebooks[$rowp['KOD_CENYQ']]))
|
||||
$pricebooks[$rowp['KOD_CENYQ']]= array();
|
||||
|
||||
$pricebooks[$rowp['KOD_CENYQ']]['products'][$rowp['NR_SYSTEMQ']] = $rowp['CENAENYQ'];
|
||||
}
|
||||
|
||||
|
||||
//get pricebooks names
|
||||
$path = dirname(__FILE__).'/_kursy.dbf';
|
||||
$dbfp = new dbf_class($path);
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
for($i=0;$i<$num_recp;$i++){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
foreach ($pricebooks as $k=>$v)
|
||||
if (intval($k)*(-1)==intval($rowp['KOD'])) {
|
||||
$pricebooks[$k]['name']=$rowp['NAZWA'];
|
||||
$pricebooks[$k]['currency_value']=$rowp['KURS'];
|
||||
$pricebooks[$k]['date_modified']=$rowp['DATA_AKT'];
|
||||
$pricebooks[$k]['exchange_rate_name']=$rowp['SYMBOL'];
|
||||
$pricebooks[$k]['active']=$rowp['UZYTY'];
|
||||
}
|
||||
}
|
||||
|
||||
$path = dirname(__FILE__).'/_naz_cen.dbf';
|
||||
$dbfp = new dbf_class($path);
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
for($i=0;$i<$num_recp;$i++){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
foreach ($pricebooks as $k=>$v)
|
||||
if (intval($k)==intval($rowp['KOD'])) {
|
||||
$pricebooks[$k]['name']=$rowp['NAZWA'];
|
||||
$pricebooks[$k]['currency_value']=$rowp['KURS'];
|
||||
$pricebooks[$k]['date_modified']=$rowp['DATA_AKT'];
|
||||
$pricebooks[$k]['exchange_rate_name']=$rowp['SYMBOL'];
|
||||
$pricebooks[$k]['active']=$rowp['UZYTY'];
|
||||
}
|
||||
}
|
||||
|
||||
//foreach ($pricebooks as $k=>$v)
|
||||
|
||||
//if ((!isset($v['active'])) || ($v['active']!='1')) unset($pricebooks[$k]);
|
||||
|
||||
|
||||
//insert to db
|
||||
//get ecmproducts id's
|
||||
global $ecmproducts;
|
||||
|
||||
$ecmproducts = array();
|
||||
$res = mysql_query("SELECT product_id, nr_system FROM ecmstockstates");
|
||||
while ($row = mysql_fetch_array($res))
|
||||
$ecmproducts[trim($row['nr_system'])] = $row['product_id'];
|
||||
|
||||
$braki = array();
|
||||
$i=0;
|
||||
foreach ($pricebooks as $k=>$v) {
|
||||
$i++;
|
||||
echo $i.'
|
||||
';
|
||||
|
||||
if (isset($ids[$k]))
|
||||
$ecmpricebook_id = $ids[$k];
|
||||
else
|
||||
$ecmpricebook_id = create_guid();
|
||||
|
||||
$date = $v['date_modified'];
|
||||
|
||||
$fields = array ('id', 'name', 'date_entered', 'date_modified', 'modified_user_id', 'assigned_user_id', 'created_by', 'deleted', 'active', 'exchange_rate_name','currency_value', 'index_dbf');
|
||||
$row = array (
|
||||
addslashes($ecmpricebook_id),
|
||||
addslashes($v['name']),
|
||||
addslashes($date),
|
||||
addslashes($date),
|
||||
addslashes("cf3a00c2-807d-8e12-592e-4fe88f59cbf6"),
|
||||
addslashes("cf3a00c2-807d-8e12-592e-4fe88f59cbf6"),
|
||||
addslashes("cf3a00c2-807d-8e12-592e-4fe88f59cbf6"),
|
||||
addslashes("0"),
|
||||
addslashes($v['active']),
|
||||
addslashes($v['exchange_rate_name']),
|
||||
addslashes($v['currency_value']),
|
||||
addslashes($k),
|
||||
);
|
||||
|
||||
$query = "INSERT INTO ecmpricebooks (".implode(",", $fields).") VALUES ('".implode("','", $row)."')";
|
||||
|
||||
mysql_query(ch($query));
|
||||
if (mysql_error()) echo 'Database error: '.mysql_error().'
|
||||
';
|
||||
|
||||
//insert products
|
||||
foreach ($v['products'] as $nr_system => $price) {
|
||||
|
||||
//$ecmproduct_id = $ecmproducts[trim($nr_system)];
|
||||
|
||||
if (isset($ecmproducts[trim($nr_system)]))
|
||||
$ecmproduct_id=$ecmproducts[trim($nr_system)];
|
||||
else {
|
||||
$braki[trim($nr_system)]=true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$fields = array('id','ecmpricebook_id','ecmproduct_id','deleted','price','created_by','date_entered','date_modified','modified_user_id');
|
||||
|
||||
$row = array(
|
||||
addslashes(create_guid()),
|
||||
addslashes($ecmpricebook_id),
|
||||
addslashes($ecmproduct_id),
|
||||
addslashes("0"),
|
||||
addslashes($price),
|
||||
addslashes("cf3a00c2-807d-8e12-592e-4fe88f59cbf6"),
|
||||
addslashes($date),
|
||||
addslashes($date),
|
||||
addslashes("cf3a00c2-807d-8e12-592e-4fe88f59cbf6"),
|
||||
);
|
||||
|
||||
$query = "INSERT INTO ecmpricebooks_ecmproducts (".implode(",", $fields).") VALUES ('".implode("','", $row)."')";
|
||||
|
||||
mysql_query(ch($query));
|
||||
if (mysql_error()) echo 'Database error: '.mysql_error().'
|
||||
';
|
||||
}
|
||||
}
|
||||
mysql_close($sql);
|
||||
?>
|
||||
67
import/import/import_kategorie_produktow.php
Executable file
67
import/import/import_kategorie_produktow.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
mb_internal_encoding("UTF-8");
|
||||
include_once("class.dbf.php");
|
||||
include_once("../../config.php");
|
||||
include_once("helper.php");
|
||||
global $sugar_config;
|
||||
|
||||
$mysqli = new mysqli($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password'], $sugar_config['dbconfig']['db_name']);
|
||||
if (!$mysqli->set_charset("utf8")) {
|
||||
printf("Error loading character set utf8: %s\n", $mysqli->error);
|
||||
} else {
|
||||
printf("Current character set: %s\n", $mysqli->character_set_name());
|
||||
}
|
||||
|
||||
$mysqli2 = new mysqli($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password'], $sugar_config['dbconfig']['db_name']);
|
||||
if (!$mysqli2->set_charset("utf8")) {
|
||||
printf("Error loading character set utf8: %s\n", $mysqli2->error);
|
||||
} else {
|
||||
printf("Current character set: %s\n", $mysqli2->character_set_name());
|
||||
}
|
||||
|
||||
$path = dirname(__FILE__).'/E-m-s/_INDEKSY.DBF';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$sugar_fields = array ('id','vendor_name','name','code','serial_no','purchase_price','usage_unit_name','usage_unit_id','unit_id','vat_id','vat_name','vat_value','country_of_origin','kod_k_wys','status');
|
||||
|
||||
$insert = array();
|
||||
$count =0;
|
||||
//for($i=0;$i<$num_recp;$i++){
|
||||
$j=0;
|
||||
|
||||
$array=array();
|
||||
$stmt=$mysqli2->prepare("select id from ecmproductcategories where name=?");
|
||||
$stmt->bind_param("s", $szukam);
|
||||
for($i=$num_recp;$i>0;$i--){
|
||||
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
$array[]=ch($rowp['GRUPA_KS']);
|
||||
|
||||
}
|
||||
$kategorie=array_unique($array);
|
||||
$stmt2=$mysqli->prepare("INSERT INTO ecmproductcategories (id,name,to_module) VALUES (?,?,?)");
|
||||
$stmt2->bind_param('sss',$cid,$naz,$kat);
|
||||
foreach ($kategorie as $kategoria){
|
||||
if($kategoria!=''){
|
||||
|
||||
$szukam=$kategoria;
|
||||
$stmt->execute();
|
||||
$stmt->store_result();
|
||||
$numrows = $stmt->num_rows;
|
||||
if($numrows==0){
|
||||
$cid=create_guid();
|
||||
$kat='EcmProducts';
|
||||
$naz=$kategoria;
|
||||
echo "kurwo dodaje cie!";
|
||||
if (!$stmt2->execute()) {
|
||||
echo "Execute failed: (" . $stmt2->errno . ") " . $stmt2->error;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
74
import/import/import_kon_odb.php
Executable file
74
import/import/import_kon_odb.php
Executable file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
include_once("class.dbf.php");
|
||||
include_once("../config.php");
|
||||
include_once("helper.php");
|
||||
global $sugar_config;
|
||||
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
||||
|
||||
mysql_query("set character set utf8;");
|
||||
|
||||
$path = dirname(__FILE__).'/st/_ODBIOR.DBF';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$sugar_fields = array ('id','index_dbf2','name','billing_address_postalcode','billing_address_street','to_vatid','phone_office','phone_fax','description','email','index_dbf','ownership','currency_id','invoice_type','account_type');
|
||||
|
||||
$insert = array();
|
||||
$count =0;
|
||||
//for($i=0;$i<$num_recp;$i++){
|
||||
$j=0;
|
||||
for($i=$num_recp;$i>0;$i--){
|
||||
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
//print_r($rowp);
|
||||
//echo '<br>'.$rowp['ALBANIA'].'a<br>';
|
||||
//echo $back.' '.$rowp['FASTECH_SH'].'<br>';
|
||||
//echo 'lol';
|
||||
$nazwa=str_replace("'","",$rowp['NAZWA']);
|
||||
$row = array (
|
||||
addslashes(create_guid()), //id
|
||||
addslashes(ch($rowp['INDEKS'])), //nazwa
|
||||
addslashes(ch($nazwa)),
|
||||
|
||||
addslashes(ch($rowp['ADRES1'])), //kod pocz
|
||||
addslashes(ch($rowp['ADRES2'])), // ulica
|
||||
addslashes(ch($rowp['NIPBK'])),
|
||||
addslashes(ch($rowp['TEL'])), // TEL
|
||||
addslashes($rowp['FAX']), //kraj
|
||||
addslashes(ch($rowp['OPIS1']).' '.ch($rowp['OPIS2']).' '.ch($rowp['OPIS3']).' '.ch($rowp['OPIS4']).' '.ch($rowp['OPIS5']).' '.ch($rowp['ADRES1']).' '.ch($rowp['ADRES2']).' '.ch($rowp['UWAGI'])),
|
||||
addslashes(ch($rowp['EMAIL'])),
|
||||
addslashes(ch($rowp['NR_EWIDENC'])),
|
||||
addslashes(ch($rowp['DYR_WL'])),
|
||||
addslashes(ch('db82ba73-d907-3db3-560c-519364a3586e')),
|
||||
addslashes(ch('K')),
|
||||
addslashes(ch('rec')),
|
||||
|
||||
|
||||
|
||||
);
|
||||
//echo 'add<br>';
|
||||
array_push($insert, $row);
|
||||
// echo ch($rowp['NAZWA']);
|
||||
|
||||
//echo $a.'a<br>';
|
||||
//END ROW ARRAY
|
||||
|
||||
}
|
||||
|
||||
//CREATE QUERY
|
||||
//echo sizeof($insert).'';
|
||||
|
||||
for ($i=0; $i<count($insert); $i++) {
|
||||
//echo implode("','",$insert[$i]);
|
||||
//PRODUCT INSERT
|
||||
$query = 'INSERT INTO ekomer.accounts ('.implode(",",$sugar_fields).',date_entered,date_modified,created_by,modified_user_id,assigned_user_id) VALUES (\''.implode("','",$insert[$i]).'\',\''.date("Y-m-d H:i:s").'\',\''.date("Y-m-d H:i:s").'\',\'cf3a00c2-807d-8e12-592e-4fe88f59cbf6\',\'cf3a00c2-807d-8e12-592e-4fe88f59cbf6\',\'cf3a00c2-807d-8e12-592e-4fe88f59cbf6\');';
|
||||
echo $query;
|
||||
//mysql_query(ch($query));
|
||||
if (mysql_error()) echo 'Database error: '.mysql_error().'
|
||||
';
|
||||
}
|
||||
mysql_close($sql);
|
||||
|
||||
?>
|
||||
131
import/import/import_kontrahentow.php
Executable file
131
import/import/import_kontrahentow.php
Executable file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
ini_set('display_errors',1);
|
||||
function countDigits($str) {
|
||||
$noDigits=0;
|
||||
for ($i=0;$i<strlen($str);$i++) {
|
||||
if (is_numeric($str{$i})) $noDigits++;
|
||||
}
|
||||
return $noDigits;
|
||||
}
|
||||
|
||||
include_once("class.dbf.php");
|
||||
|
||||
include_once("helper.php");
|
||||
|
||||
$sugar_config = array(
|
||||
'dbconfig' =>
|
||||
array(
|
||||
'db_host_name' => 'localhost',
|
||||
'db_user_name' => 'root',
|
||||
'db_password' => '%g7!@fG',
|
||||
'db_name' => 'sugarcrm',
|
||||
'db_type' => 'mysql',
|
||||
),
|
||||
);
|
||||
|
||||
$path = dirname(__FILE__).'/bsl/_ODBIOR.DBF';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$mysqli = new mysqli($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password'], 'preDb_45ab7160e7af49269e17044eaed9e0ba');
|
||||
if (!$mysqli->set_charset("utf8")) {
|
||||
printf("Error loading character set utf8: %s\n", $mysqli->error);
|
||||
} else {
|
||||
printf("Current character set: %s\n", $mysqli->character_set_name());
|
||||
}
|
||||
|
||||
/* check connection */
|
||||
if (mysqli_connect_errno()) {
|
||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||
exit();
|
||||
}
|
||||
|
||||
$sugar_fields = array ('id','index_dbf2','name','register_address_postalcode','register_address_street','to_vatid','phone_office','phone_fax','description','email','index_dbf','ownership','currency_id','invoice_type','account_type');
|
||||
|
||||
$insert = array();
|
||||
$count =0;
|
||||
//for($i=0;$i<$num_recp;$i++){
|
||||
$j=0;
|
||||
|
||||
|
||||
$mysqli->query("truncate accounts");
|
||||
$mysqli->query("delete from dom_lists where dom_name='account_type_dom'");
|
||||
$stmt=$mysqli->prepare("INSERT INTO dom_lists (id,lang,dom_name,`key`,`value`) VALUES (?,?,?,?,?)");
|
||||
$stmt->bind_param("sssss", $id,$lang,$dom_name,$key,$value);
|
||||
|
||||
for($i=$num_recp;$i>=0;$i--){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
|
||||
if(ch($rowp['PROFIL'])=='')continue;
|
||||
|
||||
$value=ch($rowp['PROFIL']);
|
||||
$key=md5(ch($rowp['PROFIL']));
|
||||
$id=md5(ch($rowp['PROFIL']).'asd');
|
||||
$lang='pl_pl';
|
||||
$dom_name='account_type_dom';
|
||||
if (!$stmt->execute()) {
|
||||
// echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
$a++;
|
||||
|
||||
}
|
||||
|
||||
$stmt=$mysqli->prepare("INSERT INTO accounts (id,name,register_address_street,register_address_city,register_address_state,register_address_postalcode,register_address_country,to_vatid
|
||||
,index_dbf,account_type,index_dbf2,ks_account,description,phone_office,phone_fax,currency_id,invoice_type) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
$stmt->bind_param("sssssssssssssssss", $id,$nazwa,$ulica,$miasto,$woj,$poczta,$panstwo,$nip,$indeks,$typ,$indeks2,$ks_account,$description,$tel,$fax,$wal,$pdf);
|
||||
|
||||
$a=1;
|
||||
// uzupełnianie listy profili
|
||||
|
||||
|
||||
for($i=$num_recp;$i>=0;$i--){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
if($rowp['NAZWA']!=''){
|
||||
$nazwa= $rowp['NAZWA'];
|
||||
if($rowp['NAZWA1']!=''){
|
||||
$nazwa.= ' '.$rowp['NAZWA1'];
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$indeks=ch($rowp['INDEKS']);
|
||||
$nazwa=ch($nazwa);
|
||||
$indeks2=ch($rowp['NR_EWIDENC']);
|
||||
$id=create_guid();
|
||||
$adres=explode(" ",ch($rowp['ADRES1']));
|
||||
$poczta=$adres[0];
|
||||
$ks_account=ch($rowp['KONTO']);
|
||||
$ulica=ch($rowp['ADRES2']);
|
||||
$miasto=$adres[1];
|
||||
$nip=ch($rowp['NR_IDENT']);
|
||||
$tel=ch($rowp['TEL']);
|
||||
$fax=ch($rowp['FAX']);
|
||||
$opis=ch($rowp['OPIS1']).' '.ch($rowp['OPIS2']).' '.ch($rowp['OPIS3']).' '.ch($rowp['OPIS4']).' '.ch($rowp['OPIS5']).' '.ch($rowp['ADRES1']).' '.ch($rowp['ADRES2']).' '.ch($rowp['UWAGI']);
|
||||
$emal=ch($rowp['EMAIL']);
|
||||
$dyr=ch($rowp['DYR_WLRK']);
|
||||
$wal=ch('PLN');
|
||||
$pdf=ch('K');
|
||||
$typ=md5(ch($rowp['PROFIL']));
|
||||
if(ch($rowp['PROFIL'])==''){
|
||||
$typ='423362fc935e50df2484c5cbd0067f48';
|
||||
}
|
||||
if(ch($rowp['BRAK_VAT'])!='F'){
|
||||
$vat_payer='1';
|
||||
} else {
|
||||
$vat_payer='0';
|
||||
}
|
||||
$typ2='ab54eee0-5782-a292-bcaf-54d11a78b153';
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
$a++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
106
import/import/import_kontrahentow_dostaw.php
Normal file
106
import/import/import_kontrahentow_dostaw.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
ini_set('display_errors',1);
|
||||
|
||||
include_once("class.dbf.php");
|
||||
|
||||
include_once("helper.php");
|
||||
|
||||
$sugar_config = array(
|
||||
'dbconfig' =>
|
||||
array(
|
||||
'db_host_name' => 'localhost',
|
||||
'db_user_name' => 'root',
|
||||
'db_password' => '%g7!@fG',
|
||||
'db_name' => 'sugarcrm',
|
||||
'db_type' => 'mysql',
|
||||
),
|
||||
);
|
||||
|
||||
$path = dirname(__FILE__).'/bsl/_dostaw.dbf';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$mysqli = new mysqli($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password'], 'preDb_45ab7160e7af49269e17044eaed9e0ba');
|
||||
if (!$mysqli->set_charset("utf8")) {
|
||||
printf("Error loading character set utf8: %s\n", $mysqli->error);
|
||||
} else {
|
||||
printf("Current character set: %s\n", $mysqli->character_set_name());
|
||||
}
|
||||
|
||||
/* check connection */
|
||||
if (mysqli_connect_errno()) {
|
||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||
exit();
|
||||
}
|
||||
|
||||
$sugar_fields = array ('id','index_dbf2','name','register_address_postalcode','register_address_street','to_vatid','phone_office','phone_fax','description','email','index_dbf','ownership','currency_id','invoice_type','account_type');
|
||||
|
||||
$insert = array();
|
||||
$count =0;
|
||||
//for($i=0;$i<$num_recp;$i++){
|
||||
$j=0;
|
||||
|
||||
|
||||
$stmt=$mysqli->query("INSERT INTO dom_lists (id,lang,dom_name,`key`,`value`) VALUES ('eeaeae','pl_pl','account_type_dom','321dea2','DOSTAWCA')");
|
||||
|
||||
|
||||
$stmt=$mysqli->prepare("INSERT INTO accounts (id,name,register_address_street,register_address_city,register_address_state,register_address_postalcode,register_address_country,to_vatid
|
||||
,index_dbf,account_type,index_dbf2,ks_account,description,phone_office,phone_fax,currency_id,invoice_type) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
$stmt->bind_param("sssssssssssssssss", $id,$nazwa,$ulica,$miasto,$woj,$poczta,$panstwo,$nip,$indeks,$typ,$indeks2,$ks_account,$description,$tel,$fax,$wal,$pdf);
|
||||
|
||||
$a=1;
|
||||
// uzupełnianie listy profili
|
||||
|
||||
|
||||
for($i=$num_recp;$i>=0;$i--){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
if($rowp['NAZWA']!=''){
|
||||
$nazwa= $rowp['NAZWA'];
|
||||
if($rowp['NAZWA1']!=''){
|
||||
$nazwa.= ' '.$rowp['NAZWA1'];
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$indeks=ch($rowp['INDEKS']);
|
||||
$nazwa=ch($nazwa);
|
||||
$indeks2=ch($rowp['NR_EWIDENC']);
|
||||
$id=create_guid();
|
||||
$adres=explode(" ",ch($rowp['ADRES1']));
|
||||
$poczta=$adres[0];
|
||||
$ks_account=ch($rowp['KONTO']);
|
||||
$ulica=ch($rowp['ADRES2']);
|
||||
$miasto=$adres[1];
|
||||
$nip=ch($rowp['NR_IDENT']);
|
||||
$tel=ch($rowp['TEL']);
|
||||
$fax=ch($rowp['FAX']);
|
||||
$opis=ch($rowp['OPIS1']).' '.ch($rowp['OPIS2']).' '.ch($rowp['OPIS3']).' '.ch($rowp['OPIS4']).' '.ch($rowp['OPIS5']).' '.ch($rowp['ADRES1']).' '.ch($rowp['ADRES2']).' '.ch($rowp['UWAGI']);
|
||||
$emal=ch($rowp['EMAIL']);
|
||||
$dyr=ch($rowp['DYR_WLRK']);
|
||||
$wal=ch('PLN');
|
||||
$pdf=ch('K');
|
||||
$typ=md5(ch($rowp['PROFIL']));
|
||||
if(ch($rowp['PROFIL'])==''){
|
||||
$typ='321dea2';
|
||||
} else {
|
||||
$typ='321dea2';
|
||||
}
|
||||
if(ch($rowp['BRAK_VAT'])!='F'){
|
||||
$vat_payer='1';
|
||||
} else {
|
||||
$vat_payer='0';
|
||||
}
|
||||
$typ2='ab54eee0-5782-a292-bcaf-54d11a78b153';
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
$a++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
348
import/import/import_kontrahentow_p.php
Executable file
348
import/import/import_kontrahentow_p.php
Executable file
@@ -0,0 +1,348 @@
|
||||
<?php
|
||||
ini_set('display_errors',1);
|
||||
function countDigits($str) {
|
||||
$noDigits=0;
|
||||
for ($i=0;$i<strlen($str);$i++) {
|
||||
if (is_numeric($str{$i})) $noDigits++;
|
||||
}
|
||||
return $noDigits;
|
||||
}
|
||||
|
||||
include_once("class.dbf.php");
|
||||
|
||||
include_once("helper.php");
|
||||
|
||||
$sugar_config = array(
|
||||
'dbconfig' =>
|
||||
array(
|
||||
'db_host_name' => 'localhost',
|
||||
'db_user_name' => 'root',
|
||||
'db_password' => '%g7!@fG',
|
||||
'db_name' => 'preDb_7561b7965a2f9cebf2cbca60a9a07064',
|
||||
'db_type' => 'mysql',
|
||||
),
|
||||
);
|
||||
|
||||
$path = dirname(__FILE__).'/przemyslowka/glowny/_ODBIOR.DBF';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$mysqli = new mysqli($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password'], 'preDb_7561b7965a2f9cebf2cbca60a9a07064');
|
||||
if (!$mysqli->set_charset("utf8")) {
|
||||
printf("Error loading character set utf8: %s\n", $mysqli->error);
|
||||
} else {
|
||||
printf("Current character set: %s\n", $mysqli->character_set_name());
|
||||
}
|
||||
|
||||
/* check connection */
|
||||
if (mysqli_connect_errno()) {
|
||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||
exit();
|
||||
}
|
||||
|
||||
$sugar_fields = array ('id','index_dbf2','name','register_address_postalcode','register_address_street','to_vatid','phone_office','phone_fax','description','email','index_dbf','ownership','currency_id','invoice_type','account_type');
|
||||
|
||||
$insert = array();
|
||||
$count =0;
|
||||
//for($i=0;$i<$num_recp;$i++){
|
||||
$j=0;
|
||||
|
||||
|
||||
$mysqli->query("truncate accounts");
|
||||
$mysqli->query("delete from dom_lists where dom_name='account_type_dom'");
|
||||
$stmt=$mysqli->prepare("INSERT INTO dom_lists (id,lang,dom_name,`key`,`value`) VALUES (?,?,?,?,?)");
|
||||
$stmt->bind_param("sssss", $id,$lang,$dom_name,$key,$value);
|
||||
$mysqli->query("INSERT INTO dom_lists (id,lang,dom_name,`key`,`value`) VALUES ('234e','pl_pl','account_type_dom','c37746a5-0f62-5173-9020-574edf44b054','Odbiorca')");
|
||||
$mysqli->query("INSERT INTO dom_lists (id,lang,dom_name,`key`,`value`) VALUES ('234e4','pl_pl','account_type_dom','8d34359a-7d53-eb64-c607-57611fb2b087','Dostawca')");
|
||||
for($i=$num_recp;$i>=0;$i--){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
|
||||
if(ch($rowp['PROFIL'])=='')continue;
|
||||
|
||||
$value=ch($rowp['PROFIL']);
|
||||
$key=md5(ch($rowp['PROFIL']));
|
||||
$id=md5(ch($rowp['PROFIL']).'asd');
|
||||
$lang='pl_pl';
|
||||
$dom_name='account_type_dom';
|
||||
if (!$stmt->execute()) {
|
||||
// echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
$a++;
|
||||
|
||||
}
|
||||
|
||||
$stmt=$mysqli->prepare("INSERT INTO accounts (id,name,register_address_street,register_address_city,register_address_state,register_address_postalcode,register_address_country,to_vatid
|
||||
,index_dbf,account_type,index_dbf2,ks_account,description,phone_office,phone_fax,currency_id,invoice_type,allow_prevent,allow_debt_collection) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
$stmt->bind_param("sssssssssssssssssss", $id,$nazwa,$ulica,$miasto,$woj,$poczta,$panstwo,$nip,$indeks,$typ,$indeks2,$ks_account,$description,$tel,$fax,$wal,$pdf,$sms_allow,$sms_allow2);
|
||||
|
||||
$a=1;
|
||||
// uzupełnianie listy profili
|
||||
|
||||
|
||||
for($i=$num_recp;$i>=0;$i--){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
if($rowp['NAZWA']!=''){
|
||||
$nazwa= $rowp['NAZWA'];
|
||||
if($rowp['NAZWA1']!=''){
|
||||
$nazwa.= ' '.$rowp['NAZWA1'];
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$indeks=ch($rowp['INDEKS']);
|
||||
$nazwa=ch($nazwa);
|
||||
$indeks2=ch($rowp['NR_EWIDENC']);
|
||||
$id=create_guid();
|
||||
$adres=explode(" ",ch($rowp['ADRES1']));
|
||||
$poczta=$adres[0];
|
||||
$ks_account=ch($rowp['KONTO']);
|
||||
$ulica=ch($rowp['ADRES2']);
|
||||
$miasto=$adres[1];
|
||||
$nip=ch($rowp['NR_IDENT']);
|
||||
$tel=ch($rowp['TEL']);
|
||||
$fax=ch($rowp['FAX']);
|
||||
$opis=ch($rowp['OPIS1']).' '.ch($rowp['OPIS2']).' '.ch($rowp['OPIS3']).' '.ch($rowp['OPIS4']).' '.ch($rowp['OPIS5']).' '.ch($rowp['ADRES1']).' '.ch($rowp['ADRES2']).' '.ch($rowp['UWAGI']);
|
||||
$emal=ch($rowp['EMAIL']);
|
||||
$dyr=ch($rowp['DYR_WLRK']);
|
||||
$wal=ch('PLN');
|
||||
$pdf=ch('K');
|
||||
$typ='c37746a5-0f62-5173-9020-574edf44b054';
|
||||
$sms_allow=0;
|
||||
$sms_allow2=0;
|
||||
if(ch($rowp['SMS1'])!='' || ch($rowp['SMS2'])!='' || ch($rowp['SMS3'])!=''){
|
||||
$sms_allow=1;
|
||||
$sms_allow2=1;
|
||||
}
|
||||
|
||||
if(ch($rowp['BRAK_VAT'])!='F'){
|
||||
$vat_payer='1';
|
||||
} else {
|
||||
$vat_payer='0';
|
||||
}
|
||||
$typ2='ab54eee0-5782-a292-bcaf-54d11a78b153';
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
|
||||
if(ch($rowp['SMS1'])!=''){
|
||||
$id2 = create_guid();
|
||||
$t = array(
|
||||
$id2,
|
||||
$id,
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
addslashes(ch($rowp['SMS1'])),
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
);
|
||||
$q = "INSERT INTO accounts_telephones VALUES ('".implode("','", $t)."')";
|
||||
$mysqli->query($q);
|
||||
}
|
||||
if(ch($rowp['SMS2'])!=''){
|
||||
$id2 = create_guid();
|
||||
$t = array(
|
||||
$id2,
|
||||
$id,
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
addslashes(ch($rowp['SMS2'])),
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
);
|
||||
$q = "INSERT INTO accounts_telephones VALUES ('".implode("','", $t)."')";
|
||||
$mysqli->query($q);
|
||||
}
|
||||
if(ch($rowp['SMS3'])!=''){
|
||||
$id2 = create_guid();
|
||||
$t = array(
|
||||
$id2,
|
||||
$id,
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
addslashes(ch($rowp['SMS3'])),
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
);
|
||||
$q = "INSERT INTO accounts_telephones VALUES ('".implode("','", $t)."')";
|
||||
$mysqli->query($q);
|
||||
}
|
||||
|
||||
$a++;
|
||||
|
||||
}
|
||||
// dostawcy
|
||||
|
||||
$path = dirname(__FILE__).'/przemyslowka/glowny/_DOSTAW.DBF';
|
||||
$dbfp = new dbf_class($path);
|
||||
|
||||
$num_recp=$dbfp->dbf_num_rec;
|
||||
|
||||
$mysqli = new mysqli($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password'], 'preDb_7561b7965a2f9cebf2cbca60a9a07064');
|
||||
if (!$mysqli->set_charset("utf8")) {
|
||||
printf("Error loading character set utf8: %s\n", $mysqli->error);
|
||||
} else {
|
||||
printf("Current character set: %s\n", $mysqli->character_set_name());
|
||||
}
|
||||
|
||||
/* check connection */
|
||||
if (mysqli_connect_errno()) {
|
||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||
exit();
|
||||
}
|
||||
|
||||
$sugar_fields = array ('id','index_dbf2','name','register_address_postalcode','register_address_street','to_vatid','phone_office','phone_fax','description','email','index_dbf','ownership','currency_id','invoice_type','account_type');
|
||||
|
||||
$insert = array();
|
||||
$count =0;
|
||||
//for($i=0;$i<$num_recp;$i++){
|
||||
$j=0;
|
||||
|
||||
|
||||
|
||||
|
||||
$stmt=$mysqli->prepare("INSERT INTO dom_lists (id,lang,dom_name,`key`,`value`) VALUES (?,?,?,?,?)");
|
||||
$stmt->bind_param("sssss", $id,$lang,$dom_name,$key,$value);
|
||||
|
||||
for($i=$num_recp;$i>=0;$i--){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
|
||||
if(ch($rowp['PROFIL'])=='')continue;
|
||||
|
||||
$value=ch($rowp['PROFIL']);
|
||||
$key=md5(ch($rowp['PROFIL']));
|
||||
$id=md5(ch($rowp['PROFIL']).'asd');
|
||||
$lang='pl_pl';
|
||||
$dom_name='account_type_dom';
|
||||
if (!$stmt->execute()) {
|
||||
// echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
$a++;
|
||||
|
||||
}
|
||||
|
||||
$stmt=$mysqli->prepare("INSERT INTO accounts (id,name,register_address_street,register_address_city,register_address_state,register_address_postalcode,register_address_country,to_vatid
|
||||
,index_dbf,account_type,index_dbf2,ks_account,description,phone_office,phone_fax,currency_id,invoice_type,allow_prevent,allow_debt_collection) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
$stmt->bind_param("sssssssssssssssssss", $id,$nazwa,$ulica,$miasto,$woj,$poczta,$panstwo,$nip,$indeks,$typ,$indeks2,$ks_account,$description,$tel,$fax,$wal,$pdf,$sms_allow,$sms_allow2);
|
||||
|
||||
$a=1;
|
||||
// uzupełnianie listy profili
|
||||
|
||||
|
||||
for($i=$num_recp;$i>=0;$i--){
|
||||
$rowp=$dbfp->getRowAssoc($i);
|
||||
|
||||
if($rowp['NAZWA']!=''){
|
||||
$nazwa= $rowp['NAZWA'];
|
||||
if($rowp['NAZWA1']!=''){
|
||||
$nazwa.= ' '.$rowp['NAZWA1'];
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$indeks=ch($rowp['INDEKS']);
|
||||
$nazwa=ch($nazwa);
|
||||
$indeks2=ch($rowp['NR_EWIDENC']);
|
||||
$id=create_guid();
|
||||
$adres=explode(" ",ch($rowp['ADRES1']));
|
||||
$poczta=$adres[0];
|
||||
$ks_account=ch($rowp['KONTO']);
|
||||
$ulica=ch($rowp['ADRES2']);
|
||||
$miasto=$adres[1];
|
||||
$nip=ch($rowp['NR_IDENT']);
|
||||
$tel=ch($rowp['TEL']);
|
||||
$fax=ch($rowp['FAX']);
|
||||
$opis=ch($rowp['OPIS1']).' '.ch($rowp['OPIS2']).' '.ch($rowp['OPIS3']).' '.ch($rowp['OPIS4']).' '.ch($rowp['OPIS5']).' '.ch($rowp['ADRES1']).' '.ch($rowp['ADRES2']).' '.ch($rowp['UWAGI']);
|
||||
$emal=ch($rowp['EMAIL']);
|
||||
$dyr=ch($rowp['DYR_WLRK']);
|
||||
$wal=ch('PLN');
|
||||
$pdf=ch('K');
|
||||
$typ='8d34359a-7d53-eb64-c607-57611fb2b087';
|
||||
$sms_allow=0;
|
||||
$sms_allow2=0;
|
||||
if(ch($rowp['SMS1'])!='' || ch($rowp['SMS2'])!='' || ch($rowp['SMS3'])!=''){
|
||||
$sms_allow=1;
|
||||
$sms_allow2=1;
|
||||
}
|
||||
|
||||
if(ch($rowp['BRAK_VAT'])!='F'){
|
||||
$vat_payer='1';
|
||||
} else {
|
||||
$vat_payer='0';
|
||||
}
|
||||
$typ2='ab54eee0-5782-a292-bcaf-54d11a78b153';
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
|
||||
if(ch($rowp['SMS1'])!=''){
|
||||
$id2 = create_guid();
|
||||
$t = array(
|
||||
$id2,
|
||||
$id,
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
addslashes(ch($rowp['SMS1'])),
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
);
|
||||
$q = "INSERT INTO accounts_telephones VALUES ('".implode("','", $t)."')";
|
||||
$mysqli->query($q);
|
||||
}
|
||||
if(ch($rowp['SMS2'])!=''){
|
||||
$id2 = create_guid();
|
||||
$t = array(
|
||||
$id2,
|
||||
$id,
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
addslashes(ch($rowp['SMS2'])),
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
);
|
||||
$q = "INSERT INTO accounts_telephones VALUES ('".implode("','", $t)."')";
|
||||
$mysqli->query($q);
|
||||
}
|
||||
if(ch($rowp['SMS3'])!=''){
|
||||
$id2 = create_guid();
|
||||
$t = array(
|
||||
$id2,
|
||||
$id,
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
addslashes(ch($rowp['SMS3'])),
|
||||
'0',
|
||||
date("Y-m-d H:i:s"),
|
||||
'0',
|
||||
);
|
||||
$q = "INSERT INTO accounts_telephones VALUES ('".implode("','", $t)."')";
|
||||
$mysqli->query($q);
|
||||
}
|
||||
|
||||
$a++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user