include('f_dbase.php');
/* Przekierowanie dla okreslonych stron na https i na http jezeli nie jest sie na zadnej z tych stron
* Wykomentowane poniewa? reguly zostaly dodane w .htaccess*/
function redirectToHTTPS($type) {
}
if(isset($_SERVER['REQUEST_URI'])) {
$str= str_replace('/sklep/eng/', '', $_SERVER['REQUEST_URI']);
$request= explode('?', $str);
$httpsPages= Array();
$httpsPages[]= 'logowanie.php';
$httpsPages[]= 'zamowienie.php';
$httpsPages[]= 'potwierdzenie.php';
$httpsPages[]= 'wyslij.php';
$httpsPages[]= 'konto.php';
$httpsPages[]= 'rejestracja.php';
$httpsPages[]= 'sciagaj.php';
$httpsPages[]= 'p24_ok.php';
$httpsPages[]= 'ecardok.php';
//if(in_array($request[0], $httpsPages)) {
// redirectToHTTPS("https");
//}
//else {
// redirectToHTTPS("http");
//}
redirectToHTTPS("https");
}
function cmp_tabelka2($a, $b){
if ($a['dostepn_dni'] == $b['dostepn_dni']) {
return 0;
}
return ($a['dostepn_dni'] < $b['dostepn_dni']) ? -1 : 1;
}
function safe($str){
$from = array(" ","±","¿","¡","æ","ñ","³","¶","ê","¡","¯","¬","Æ","£","¦","Ê","Ó","/","[","]","ó","%");
$to = array("-","a","z","z","c","n","l","s","e","A","Z","Z","C","L","S","E","O","-","-","-","o","-");
return urlencode(str_replace($from, $to,$str));
return str_replace($from, $to,$str);
}
function makelink($str){
$from = array("&");
$to = array("&");
return str_replace($from, $to,$str);
}
function album_link($id,$tytul,$wykonawcy,$img=0,$anps=''){
$w = array();
foreach($wykonawcy as $wn)$w[]=$wn['name'];
$wyk = substr(implode(" ",$w),0,25);
if($img==7){
return "";
} else if($img==6){
return "$tytul";
} else if($img==5){
return "albumik.php,alb_id,$id,rozmiar,".safe($anps).",".safe(substr($tytul,0,60)).",".safe($wyk);
} else if($img==4){
return "";
}else if($img==3){
//bialy, np w nowosciach
return "$tytul";
} else if($img==2){
//jak nie ma okladki
return "";
} else if($img==1){
//jak jest okladka
return "";
} else if($img==8){
return "albumik.php,alb_id,$id,".safe(substr($tytul,0,60)).",".safe($wyk);
} else {
//pogrubiony np w boxie promocje
return "$tytul";
}
}
function gatunki_link($gatunki){
$i=0;
$out = "";
foreach($gatunki as $ng) {
$i++;
$out .= "$ng[name_en]";
if($i != count($gatunki)) $out .= "/ ";
}
return $out;
}
function wykonawcy($wyk,$link=0){
$i=0;
$out = "";
foreach($wyk as $w){
$i++;
if($link=='1'){
$out .= "".$w['name']."";
} else if($link=='2'){
$out .= "$w[name]
";
} else if($link=='3'){
$out .= "".$w['name']."";
} else {
$out .= $w['name'];
}
if($i != count($wyk) and $link!='2') $out .= "/ ";
}
return $out;
}
function koszyk_link($id_nosnika,$id_albumu,$ticket,$id=0){
global $db;
$istnieje = $db->selectCell("select a.id_albumu from albumy a left join albumy_nosniki an on a.id_albumu=an.id_albumu where
a.aktywny='T' and an.aktywny='T' and a.id_albumu='$id_albumu' and an.id_nosnika='$id_nosnika'");
if(!$istnieje){
return "wyprzedany";
}
if($id==0){
return makelink("");
} else if($id==1){
return makelink("");
}
}
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function wytwornia_link($wytwornia){
$out = '';
if($wytwornia['nazwa'] != '') {
if($wytwornia['www_ofic'] != '') {
$out = "".$wytwornia['nazwa']."";
} elseif($wytwornia['www'] != '') {
$out = "".$wytwornia['nazwa']."";
} else {
$out = "".$wytwornia['nazwa']."";
}
$out .= ",";
}
return $out;
}
$starttime = getmicrotime();
function daj_ip() {
$ip_proxy='brak';$ip_hosta='brak';
if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){
$ip_hosta = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
$ip_hosta = $_SERVER["REMOTE_ADDR"];
}
$ip = $ip_hosta;
return $ip;
}
function get_perf($alb_id){
global $db;
$wyks = $db->selectTable("select p.name from albumy_perf ap left join performers p on ap.id_perf=p.id where id_albumu='$alb_id'");
$w = array();
foreach($wyks as $wyk){ $w[] = $wyk['name'];}
return implode(" & ",$w);
}
function get_access_code() {
global $db;
$kod = "";
while($kod == "") {
for($i=0;$i<8;$i++) {
$lc = mt_rand(0,1);
if($lc == 0) $znak = chr(mt_rand(65,90));
if($lc == 1) $znak = mt_rand(0,9);
$kod.=$znak;
}
$ile = $db->selectCell("select count(*) from transactions where access_code = '$kod'");
if($ile > 0) $kod = "";
} // wend
return $kod;
}
function send_mail($fromname,$fromaddr,$toname,$toaddr,$subject,$tekst,$tplfile='') {
include("func/smtp.php");
$boundary = md5(time());
$content = $tekst;
$headers = array(
"From: $fromname <$fromaddr>",
"To: $toname <$toaddr>",
"Subject: $subject",
'Date: '.date("r"),
'X-Mailser: Serpent Mailer',
'Sender-IP: '.$_SERVER["REMOTE_ADDR"],
"MIME-Version: 1.0",
// "Content-type: multipart/mixed; boundary=\"$boundary\"",
// "Content-Transfer-Encoding: 7bit",
// "--$boundary",
"Content-Type: text/html; charset=iso-8859-2",
"Content-Transfer-Encoding: 8bit",
//$content
// "--$boundary--"
);
$params['host'] = 'localhost';
$params['port'] = 25;
$params['helo'] = 'mail.serpent.pl';
$params['auth'] = TRUE;
$params['user'] = 'sklep@serpent.pl';
$params['pass'] = 'heyhol';
$mail = new Smtp($params);
$mail->headers = $headers;
$mail->recipients = array($toaddr);
$mail->from = 'sklep@serpent.pl';
//$mail->helo = $SET_shop_ip;
$mail->body = $content;
$mail->connect();
$mail->send();
if(count($mail->errors) > 1) trigger_error("Niepowodzenie przy wysy�aniu emaila: ".join(" ",$mail->errors),256);
}
function skroc($co,$doilu) {
if(strlen($co) > $doilu) {
$skrocone = trim(substr($co,0,$doilu))."...";
return $skrocone;
} else {
return $co;
}
}
function cena_al($id) {
global $db;
// $trc = $db->selectCell("select cena from payment_methods where dft = 'Y'");
// $ilt = $db->selectCell("select count(*) from tracks where album_id = '$id'");
$cena_al = $db->selectCell("select sum(cena) from tracks where album_id = '$id'");
// $cena_al = $trc * $ilt;
$cena_alb = $cena_al - (0.2 * $cena_al);
return $cena_alb;
}
function odmien_plyte($lr) {
if($lr == 1) { $prod = "album";
} elseif(($lr > 1) && ($lr < 5)) { $prod = "albumy";
} elseif(($lr > 4) && ($lr < 22)) { $prod = "album�w";
} else {
$lr_dl = strlen($lr);
$dzielnik = 10;
$ulamek = $lr/$dzielnik;
$t = explode(".",$ulamek);
if(count($t) > 1) {
$t2 = $t[1];
}
if(($t2 > 1) && ($t2 < 5)) $prod = "albumy";
if($t2 > 4) $prod = "album�w";
}
return $prod;
}
function odmien_utwor($lr) {
if($lr == 1) { $prod = "utw�r";
} elseif(($lr > 1) && ($lr < 5)) { $prod = "utwory";
} elseif(($lr > 4) && ($lr < 22)) { $prod = "utwor�w";
} else {
$lr_dl = strlen($lr);
$dzielnik = 10;
$ulamek = $lr/$dzielnik;
$t = explode(".",$ulamek);
$t2 = $t[1];
if(($t2 > 1) && ($t2 < 5)) $prod = "utwory";
if($t2 > 4) $prod = "utwor�w";
}
return $prod;
}
function odmien_pozycje($lr) {
if($lr == 1) { $prod = "pozycj�";
} elseif(($lr > 1) && ($lr < 5)) { $prod = "pozycje";
} elseif(($lr > 4) && ($lr < 22)) { $prod = "pozycji";
} else {
$lr_dl = strlen($lr);
$dzielnik = 10;
$ulamek = $lr/$dzielnik;
$t = explode(".",$ulamek);
$t2 = $t[1];
if(($t2 > 1) && ($t2 < 5)) $prod = "pozycje";
if($t2 > 4) $prod = "pozycji";
}
return $prod;
}
function wpiszdologu($metoda,$typ,$req = array()) {
$f = fopen("a_log.txt","a");
fwrite($f,"\r\n --- ".date("Y-m-d H:i:s")." --- ");
fwrite($f,"\r\n --- $metoda $typ $_SERVER[PHP_SELF] --- \r\n\r\n");
if(count($req) > 0) {
foreach($req as $v) {
fwrite($f,$v."\r\n");
}
}
fwrite($f,"\r\n --- END OF $metoda $typ --- \r\n");
fclose($f);
}
function wpiszdologudb($query) {
$f = fopen("a_dblog.txt","a");
fwrite($f,"\r\n".date("Y-m-d H:i:s")."|$_SERVER[PHP_SELF]| $query ");
fclose($f);
}
function katalog(){
$rev =strrev($_SERVER['SCRIPT_NAME']);
$pos = strpos($rev,"/");
$part = substr($rev,$pos);
return strrev($part);
}
function wykonaj_soap($url,$request) {
$headers = array("Content-Type: text/xml");
$cnf = curl_init();
curl_setopt($cnf,CURLOPT_URL,$url);
curl_setopt($cnf,CURLOPT_HTTPHEADER,$headers);
curl_setopt($cnf,CURLOPT_POST,1);
curl_setopt($cnf,CURLOPT_POSTFIELDS,$request);
ob_start();
@curl_exec($cnf);
if(curl_errno($cnf) != 0)
{
trigger_error("cURL: ".curl_error($cnf),256);
}
curl_close($cnf);
$response = ob_get_contents();
ob_clean();
$resp_lines = explode("\r\n",$response);
return $resp_lines;
}
function iso2utf($input)
{
$iso = array("'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'");
$utf = array("%C4%85","%C4%84","%C4%87","%C4%86","%C4%99","%C4%98","%C5%82","%C5%81","%C5%84","%C5%83","%C3%B3","%C3%93","%C5%9B","%C5%9A","%C5%BC","%C5%BB","%C5%BA","%C5%B9");
$output = preg_replace($iso,$utf,$input);
return $output;
}
function verifyEmail($email) {
$wholeexp = '/^(.+?)@(([a-z0-9\.-]+?)\.[a-z]{2,5})$/i';
$userexp = "/^[a-z0-9\~\!\#\$\%\&\(\)\-\_\+\=\[\]\;\:\'\"\,\.\/]+$/i";
if (preg_match($wholeexp, $email, $regs)) {
$username = $regs[1];
$host = $regs[2];
//checkdnsrr($host, 'MX')
if (1==1) {
if (preg_match($userexp, $username)) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
function ustal_koszt_przes($items,$forma,$kwota,$przes = 2,$id_kraju = 2)
{
global $db,$order_id;
$koszt = 0;
if($id_kraju == 2) //koszty przesylek dla Polski
{
if(($kwota <= 100) and ($kwota > 0)) //koszt przesylek dla kwoty < 100zl
{
if($forma == 1) {
$koszt = 13.9; //koszt przesylki za pobraniem
} else {
$koszt = 6.5; //koszt przesylki dla przelewu
}
if($przes == 1) {
if($forma==1){
$koszt = $koszt + 4; //doplata za priorytet przy pobraniu
} else {
$koszt = $koszt + 1.4; //doplata za priorytet przy przelewie
}
}
} elseif(($kwota > 100) and ($kwota <= 200)) //koszt przesylek dla kwoty >100 i <200
{
if($forma == 1) {
$koszt = 7.9; //koszt przesylki za pobraniem
} else {
$koszt = 3.9; //koszt przesylki dla przelewu
}
if($przes == 1){
if($forma==1){
$koszt = $koszt + 3; //doplata za priorytet przy pobraniu
} else {
$koszt = $koszt + 1.5; //doplata za priorytet przy przelewie
}
}
} elseif($kwota > 200) //koszt przesylek dla kwoty > 200zl
{
if($forma == 1) {
$koszt = 0; //koszt przesylki za pobraniem
} else {
$koszt = 0; //koszt przesylki dla przelewu
}
if($przes == 1){
if($forma==1){
$koszt = $koszt + 0; //doplata za priorytet przy pobraniu
} else {
$koszt = $koszt + 0; //doplata za priorytet przy przelewie
}
}
}
} else {
if($kwota > 0) {
$waga=0;
$waga_opakowania=0;
foreach($items as $el){
$w = $db->selectCell("select waga from albumy_nosniki where id_albumu = '".$el['id_albumu']."' and id_nosnika='".$el['id_nosnika']."'");
if (!$w) $w = $db->selectCell("select waga_domyslna from nosniki where id_nosnika='".$el['id_nosnika']."'");
$waga+=$w*$el['ilosc'];
if ($el['id_nosnika']==14||$el['id_nosnika']==21||$el['id_nosnika']==24) $waga_opakowania=1;
}
if ($waga_opakowania) $waga_opakowania = $db->selectCell("select wartosc from config where nazwa = 'waga_opakowania_1'");
else $waga_opakowania = $db->selectCell("select wartosc from config where nazwa = 'waga_opakowania'");
$waga+=(int)$waga_opakowania/1000;
$kraj = $db->selectRow("select * from countries where id_kraju = '$id_kraju'");
$ileplyt = count($items);
$id_strefy = $kraj['id_strefy'];
$koszt = $db->selectCell("select kwota from oplaty_poczt where id_strefy = '$id_strefy' and ilosc_plyt >= '$waga' order by ilosc_plyt asc limit 1");
}
if($order_id=='SLPWJNTJK') $koszt = 23;
if($order_id=='HTWOTVHQF') $koszt = 19;
}
return $koszt;
}
function daj_dostep($album_id,$nosnik_id,$ilosc_zam=0)
{
global $db;
$album = $db->selectRow("select * from albumy where id_albumu = '$album_id'");
$an = $db->selectRow("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$album_id' and an.id_nosnika = '$nosnik_id'");
if($an['stan'] > $ilosc_zam) {
$dostepn = array('opis_en'=>'in stock','ilosc_dni'=>0);
} else {
if(($an['data_premiery'] != '0000-00-00') and ($an['data_premiery'] > date("Y-m-d"))) {
$dostepn = array('opis_en'=>'available since'.$an['data_premiery']);
} elseif(($album['data_premiery'] != '0000-00-00') and ($album['data_premiery'] > date("Y-m-d"))) {
$dostepn = array('opis_en'=>'od'.$album['data_premiery']);
} else {
$id_dostepn = 0;
if($an['id_dostepn'] != 0) {
$id_dostepn = $an['id_dostepn'];
}
if(($id_dostepn == 0) and ($an['id_grupywyt']) != 0){
$grupywyt = $db->SelectRow("select id_dostepn,id_dystr from grupy_wytworni where id_grupy = '$an[id_grupywyt]'");
if($grupywyt['id_dostepn']!=0){
$id_dostepn = $grupywyt['id_dostepn'];
} else {
$id_dostepn = $db->selectCell("select id_dostepn from dystrybutorzy where id_dystryb = '$grupywyt[id_dystr]'");
}
}
if(($id_dostepn == 0) and ($an['id_wydawcy'] != 0)) {
$wytwornia = $db->SelectRow("select id_dostepn,id_grupy from wytwornie where id_wytworni = '".$an['id_wydawcy']."'");
if($wytwornia['id_dostepn'] != 0) {
$id_dostepn = $wytwornia['id_dostepn'];
} else {
$id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$wytwornia['id_grupy']."'");
}
}
if(($id_dostepn == 0) and ($album['grupa_wyt1'] != 0))
{
$id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$album['grupa_wyt1']."'");
}
if(($id_dostepn == 0) and ($album['grupa_wyt2'] != 0))
{
$id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$album['grupa_wyt2']."'");
}
if(($id_dostepn == 0) and ($album['id_wyt'] != 0)) {
$wytwornia = $db->SelectRow("select id_dostepn,id_grupy from wytwornie where id_wytworni = '".$album['id_wyt']."'");
if($wytwornia['id_dostepn'] != 0) {
$id_dostepn = $wytwornia['id_dostepn'];
} else {
$id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$wytwornia['id_grupy']."'");
}
}
if(($id_dostepn == 0) and ($an['id_dystryb'] != 0)) {
$id_dostepn = $db->SelectCell("select id_dostepn from dystrybutorzy where id_dystryb = '".$an['id_dystryb']."'");
}
if(($id_dostepn == 0) and ($album['id_dys_1'] != 0)) {
$id_dostepn = $db->SelectCell("select id_dostepn from dystrybutorzy where id_dystryb = '".$album['id_dys_1']."'");
}
if($id_dostepn == 0) {
$dostepn = array('opis_en'=> "Brak danych.",'ilosc_dni'=>365);
} else {
$dostepn = $db->SelectRow("select * from dostepnosci where id_dostepn = '$id_dostepn'");
}
}
}
return $dostepn;
} // end function
function daj_tid()
{
global $db;
//while ($tid == "") {
// for($i=0;$i<10;$i++) {
// if ($i<2) $tid=$tid.Chr(mt_rand(66,90));
// if ($i>=2) $tid=$tid.mt_rand(0,9);
// }
// $is = $db->selectCell("select count(*) from koszyk_pozycje where trans_id = '$tid' and 1=1",true);
// if($is > 0) {
// $tid = "";
// }
//}
$byle = $db->selectCell("select order_id from transactions where order_id REGEXP '^[0-9]+$' and order_id<999999999 order by CAST( order_id AS UNSIGNED ) desc",true);
$byle1 = $db->selectCell("select order_id from koszyk_zamowienia where order_id REGEXP '^[0-9]+$' and order_id<999999999 order by CAST( order_id AS UNSIGNED ) desc",true);
if ($byle1>$byle) $byle=$byle1;
$byle1 = $db->selectCell("select order_id from koszyk_pozycje where order_id REGEXP '^[0-9]+$' and order_id<999999999 order by CAST( order_id AS UNSIGNED ) desc",true);
if ($byle1>$byle) $byle=$byle1;
$tid=(int)$byle+1;
return $tid;
}
function generateTicket()
{
global $db;
$ticket = "";
while($ticket == "")
{
$ip = daj_ip();
$mtime = getmicrotime();
$tid = "";
for($i=0;$i<3;$i++)
{
$tid=$tid.Chr(mt_rand(66,90));
}
$ticket = md5($ip.$mtime.$tid);
// $is = $db->selectCell("select count(*) from koszyk_pozycje where ticket = '$ticket'");
if($is > 0)
{
$ticket = "";
}
}
return $ticket;
}
function multidimensionalArrayMap( $func, $arr )
{
$newArr = array();
foreach( $arr as $key => $value )
{
$newArr[ $key ] = ( is_array( $value ) ? multidimensionalArrayMap( $func, $value ) : $func( $value ) );
}
return $newArr;
}
function createRandomPassword() {
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
function przelicz_cene($cena,$code){
$kurs = daj_komorke("select rate from currency where code='{$code}'");
return $cena*$kurs;
}
function cena_nosnik_wyswietl($cena){
$cena = str_replace(",",".",$cena);
if(array_key_exists("currency",$_SESSION) && $_SESSION["currency"]=="USD"){
$cena_usd = przelicz_cene($cena,"USD");
$ret = number_format($cena_usd,2,",","")."$";
} else {
$cena_eur = przelicz_cene($cena,"EUR");
$ret = number_format($cena_eur,2,",","")."€";
}
return $ret;
}
/**
* Funkcja $db->selectTable zwraca tablic� wielowymiarow�, gdzie ka�dy wiersz zawiera tablic� z
* polami i ich warto�ciami dla danego rekordu. Gdy chcemy pobra� np. tylko tytu�y ze wszystkich
* wierszy u�yjemy tej funkcji
*
* @author Marcin S�gol, prot.pl
* @date 17.05.2012
*
* @param array $tablica: tablica z wierszami rkord�w
* @param string $pole: nazwa pola jakiego warto�ci chcemy pobra�
*
* @return array
*/
function pobierzWartosciPolaWszystkichWierszy($tablica, $pole) {
$wartosci= array(); //tablica przechowuj�ca warto�ci dla wskazanego pola
//sprawdz wszystkie wiersze i dodaj warto�� wybranego pola do tablicy $wartosci
if(count($tablica) > 0) {
foreach($tablica as $wiersz) {
$wiersz[$pole] ? $wartosci[]= $wiersz[$pole] : '';
}
} else {
return array();
}
return $wartosci;
}
$ticket = generateTicket();
?>
class Cart {
var $items;
var $tracks;
var $suma;
var $suma_sciezek;
var $rabat;
var $orderid;
var $tabelka;
var $tabelkasciezek;
var $forma;
var $przesylka;
var $id_kraju;
var $zakupplikow=false;
var $transakcja;
var $suma_teraz;
var $suma_skomplet;
var $koszt_skomplet;
var $koszt_teraz;
var $suma_ogolna_teraz;
var $suma_ogolna_skomplet;
var $inne_gotowe;
var $t_ready = array();
var $t_now = array();
var $all_now = true;
var $some_ready = false;
var $all_ready = true;
var $all_paid = true;
var $all_sent = true;
var $all_spak = true;
var $message=array();
var $wysylka_str;
var $status_str;
function Cart(&$db,&$customer)
{
global $oLang;
$this->lang = &$oLang;
$this->customer = &$customer;
$this->items = array();
$this->tracks = array();
$this->suma = 0;
$this->suma_sciezek = 0;
$this->rabat = 0;
$this->tabelka = array();
$this->tabelkasciezek = array();
$this->db = $db;
if($_REQUEST['order_id']){
$this->orderid = $_REQUEST['order_id'];
$this->items = $this->db->selectTable("select * from koszyk_pozycje where order_id = '".$this->orderid."' and potwierdzona = 'Y' order by dostepn_dni");
$this->forma=&$this->items[0]['forma'];
$this->przesylka=&$this->items[0]['przesylka'];
$this->id_kraju = $this->db->selectCell("select kraj from adresy where id_adresu = '".$this->items[0]['id_adresu']."' and usuniety!='T'");
if(!$this->id_kraju)
{
$this->id_kraju = $this->db->selectCell("select kraj from adresy where cust_id = '".$this->customer->cust_id."' and nazwa = 'Podstawowy' and usuniety!='T'");
}
if(!$this->id_kraju) $this->id_kraju = 2;
if($this->items[0]['id_sciezki'] != 0) $this->zakupplikow = true;
$this->getTransakcja();
//print_r($transakcja);
$transakcje_id="0";
foreach($this->items as $poz)
if ($poz['id_transakcji']){
$transakcje_id.=", ".$poz['id_transakcji'];
}
$this->suma_zaplacona=0;
if ($transakcje_id!="0")
{
$q = "select * from transactions where (id in (".$transakcje_id.") or order_id='".$this->orderid."') and paid='Y'";
$transakcje = $this->db->selectTable($q);
foreach($transakcje as $tran){$this->suma_zaplacona+=$tran['cash_amount'];}
}
//$this->suma_teraz = $this->dajSumeTerazByOid($this->orderid);
//$this->suma_skomplet = $this->dajSumeSkompletByOid($this->orderid);
//$this->koszt_teraz = ustal_koszt_przes($this->items,$this->forma,$this->suma_teraz,$this->przesylka,$this->id_kraju);
//$this->koszt_skomplet = ustal_koszt_przes($this->items,$this->forma,$this->suma_skomplet,$this->przesylka,$this->id_kraju);
//$this->suma_ogolna_teraz = $this->suma_teraz + $this->koszt_teraz;
//$this->suma_ogolna_skomplet = $this->suma_skomplet + $this->koszt_skomplet;
//$this->suma_ogolna = $this->suma_ogolna_teraz + $this->suma_ogolna_skomplet;
$this->suma_teraz = $this->dajSumeByOid($this->orderid);
$this->koszt_teraz = ustal_koszt_przes($this->items,$this->forma,$this->suma_teraz,$this->przesylka,$this->id_kraju);
$this->suma_ogolna_teraz = $this->suma_teraz + $this->koszt_teraz;
$this->suma_ogolna = round($this->suma_ogolna_teraz-$this->suma_zaplacona,2);
foreach($this->items as $k=>$p){
if($p['id_sciezki'] != 0) {
$this->items[$k]['track'] = $this->db->selectRow("select * from tracks where id = '".$p['id_sciezki']."'");
}
if($p['id_albumu'] != 0){
$this->items[$k]['album'] = $this->db->selectRow("select * from albumy where id_albumu = '".$p['id_albumu']."'");
}
if($p['id_nosnika'] != 0){
$this->items[$k]['nosnik'] = $this->db->selectCell("select nazwa_en from nosniki where id_nosnika = '".$p['id_nosnika']."'");
$this->items[$k]['a_n'] = $this->db->selectRow("select * from albumy_nosniki where id_albumu = '$p[id_albumu]' and id_nosnika = '$p[id_nosnika]' and aktywny='T'");
}
$this->items[$k]['dostepn_dni'] = daj_dostep($p['id_albumu'],$p['id_nosnika'],$p['ilosc']);
if($p['wyslana'] != 'Y') { $this->all_sent = false; }
if($p['spakowana'] != 'Y') { $this->all_spak = false; }
//Uzupelnianie pola Wysylka w statusie zamowienia
if($p['wysylka'] == 'teraz') {
//$this->items[$k]['wysylka_str'].='Od razu';
//if($p['zaplacona'] != 'Y') {
$this->t_now[] = $poz['id_pozycji'];
if($p['wyslana'] != 'Y') { $this->all_sent = false; }
if($p['spakowana'] != 'Y') { $this->all_spak = false; }
$this->items[$k]['wysylka_str'].="[Zmie�]";
//}
//if($p['zaplacona'] == 'Y') { $this->items[$k]['wysylka_str'].="
Paid"; }
} else if($p['wysylka'] == 'skomplet') {
$this->all_now = false;
$this->items[$k]['wysylka_str'].="When complete whole order";
if(($p['wyslana'] != 'Y') and ((($p['dostepn_dni'] == 0) and strtotime($this->items[$k]['a_n']['data_premiery'])