public function zpracujobjednavkuAction() { $_t = new Zend_Translate('csv', CESTA . '/preklad/mfpshop.cs.csv', 'cs'); $_t->addTranslation(CESTA . '/preklad/mfpshop.sk.csv', 'sk'); $_t->addTranslation(CESTA . '/preklad/mfpshop.en.csv', 'en'); // Create a log instance $writer_preklad = new Zend_Log_Writer_Stream(CESTA . '/logy/preklad.log'); $log_preklad = new Zend_Log($writer_preklad); /* firma, osoba, datum, doprava, platba, poznamka, cena_celkem, cena_celkem_DPH */ #zjisteni celkove ceny $soucet = 0; $soucet_dph = 0; foreach ($_SESSION['kosik'] as $r) { $soucet += (double) $r['cena_radek']; $soucet_dph += (double) $r['cena_radek_dph']; } $sleva_obj = $soucet * (double) $_SESSION['objemova_sleva'] / 100; $sleva_obj_dph = $soucet_dph * (double) $_SESSION['objemova_sleva'] / 100; $cena_obj = $soucet - $sleva_obj; $cena_obj_dph = $soucet_dph - $sleva_obj_dph; $sleva_kupon = $cena_obj * (double) $_SESSION['objednavka']['kupon']['sleva'] / 100; $sleva_kupon_dph = $cena_obj_dph * (double) $_SESSION['objednavka']['kupon']['sleva'] / 100; $cena_kupon = $cena_obj - $sleva_kupon; $cena_kupon_dph = $cena_obj_dph - $sleva_kupon_dph; $_SESSION['objednavka']['doprava']['kod'] = isset($_SESSION['objednavka']['doprava']['kod']) ? $_SESSION['objednavka']['doprava']['kod'] : ''; $_SESSION['objednavka']['platba']['kod'] = isset($_SESSION['objednavka']['platba']['kod']) ? $_SESSION['objednavka']['platba']['kod'] : ''; $vysl = readData('objednavka_hl', array('firma' => $_SESSION['uzivatel']['firma'], 'osoba' => $_SESSION['uzivatel']['jmeno'], 'doprava' => $_SESSION['objednavka']['doprava']['kod'], 'platba' => $_SESSION['objednavka']['platba']['kod'], 'cena_celkem' => $cena_kupon, 'cena_celkem_dph' => $cena_kupon_dph, 'poznamka' => $_SESSION['objednavka']['ostatni']['poznamky'], 'objemova_sleva' => $_SESSION['objemova_sleva'], 'kupon' => $_SESSION['objednavka']['kupon']['cislo'], 'kupon_sleva' => $_SESSION['objednavka']['kupon']['sleva'])); #Firma, Poradi, Polozka, Produkt, Mj, Mj_v_bal, Mnozstvi, Cena_cenik, Sleva_proc, Cena_celkem, Cena_celkem_DPH #neplneni polozek objednavky - vzdy vlozeni do objednavky $rozpis = ''; #rozpis objednavky do mailu $rozpis_obch = ''; #rozpis objednavky do mailu $rozpis .= "=================================================================================================\r\n"; $rozpis .= sprintf('|%-15s|%-50s|%6s|%10s|%10s|' . "\r\n", "Produkt", iconv('UTF-8', 'iso-8859-2//TRANSLIT', "Název"), iconv('UTF-8', 'iso-8859-2//TRANSLIT', "Počet"), "Cena", "Cena s DPH"); $rozpis .= "=================================================================================================\r\n"; foreach ($_SESSION['kosik'] as $r) { $vysl_pol = readData('objednavka_pol', array('firma' => $_SESSION['uzivatel']['firma'], 'poradi' => (int) $vysl->o->row->cobj, 'produkt' => $r['produkt'], 'mj' => $r['mj'], 'mj_v_bal' => '1', 'mnozstvi' => $r['mj_evid'], 'zakl_cena' => $r['zakl_cena'], 'cena' => $r['cena'], 'sleva_proc' => $r['sleva'], 'cena_celkem' => $r['cena_radek'], 'cena_celkem_dph' => $r['cena_radek_dph'])); $rozpis .= sprintf('|%-15s|%-50s|%6.0F|%10.2F|%10.2F|' . "\r\n", iconv('UTF-8', 'iso-8859-2//TRANSLIT', $r['produkt']), iconv('UTF-8', 'iso-8859-2//TRANSLIT', $r['nazev']), $r['mj_evid'], $r['cena_radek'], $r['cena_radek_dph']); } // dokonceni objednavky - rozpusteni slev $vysl_pol = readData('dokonci_objednavku', array('firma' => $_SESSION['uzivatel']['firma'], 'poradi' => (int) $vysl->o->row->cobj)); $rozpis .= "=================================================================================================\r\n"; $rozpis .= sprintf('|%-73s|%10.2F|%10.2F|' . "\r\n", "Celkem", $soucet, $soucet_dph); if ((double) $_SESSION['objemova_sleva'] != 0) { $rozpis .= "=================================================================================================\r\n"; $rozpis .= sprintf('|%-73s|%10.2F|%10.2F|' . "\r\n", iconv('UTF-8', 'iso-8859-2//TRANSLIT', "Objemová sleva: ") . $_SESSION['objemova_sleva'] . "%", $sleva_obj, $sleva_obj_dph); } if ((double) $_SESSION['objednavka']['kupon']['sleva'] != 0) { $rozpis .= "=================================================================================================\r\n"; $rozpis .= sprintf('|%-73s|%10.2F|%10.2F|' . "\r\n", iconv('UTF-8', 'iso-8859-2//TRANSLIT', "Slevový kupon ") . $_SESSION['objednavka']['kupon']['cislo'] . ': ' . $_SESSION['objednavka']['kupon']['sleva'] . "%", $sleva_kupon, $sleva_kupon_dph); } $rozpis .= "=================================================================================================\r\n"; $rozpis .= sprintf('|%-73s|%10.2F|%10.2F|' . "\r\n", iconv('UTF-8', 'iso-8859-2//TRANSLIT', "Výsledná cena"), $cena_kupon, $cena_kupon_dph); $rozpis .= "=================================================================================================\r\n"; //$rozpis = ($rozpis); $rozpis .= "Doprava: " . iconv('UTF-8', 'iso-8859-2//TRANSLIT', $_SESSION['objednavka']['doprava']['popis']) . ", " . "cena: " . number_format($_SESSION['objednavka']['doprava']['cena'], 2, ',', ' ') . iconv('UTF-8', 'iso-8859-2//TRANSLIT', " Kč\r\n"); $rozpis .= "Platba: " . iconv('UTF-8', 'iso-8859-2//TRANSLIT', $_SESSION['objednavka']['platba']['popis']) . ", " . "cena: " . number_format($_SESSION['objednavka']['platba']['cena'], 2, ',', ' ') . iconv('UTF-8', 'iso-8859-2//TRANSLIT', " Kč\r\n"); $rozpis .= "=================================================================================================\r\n"; if (trim($_SESSION['objednavka']['ostatni']['poznamky']) != '') { $rozpis .= iconv('UTF-8', 'iso-8859-2//TRANSLIT', "Poznámky:\r\n" . $_SESSION['objednavka']['ostatni']['poznamky'] . "\r\n"); $rozpis .= "=================================================================================================\r\n"; } $rozpis_obch .= "Objednal:\r\n"; foreach ($_SESSION['objednavka']['osoba'] as $k => $h) { $rozpis_obch .= iconv('UTF-8', 'iso-8859-2//TRANSLIT', $_t->_($k) . ": {$h}\r\n"); } $rozpis_obch .= "=================================================================================================\r\n"; $rozpis_obch .= "Objednatel:\r\n"; foreach ($_SESSION['objednavka']['firma'] as $k => $h) { $rozpis_obch .= iconv('UTF-8', 'iso-8859-2//TRANSLIT', $_t->_($k) . ": {$h}\r\n"); } $rozpis_obch .= "=================================================================================================\r\n"; $rozpis_obch .= iconv('UTF-8', 'iso-8859-2//TRANSLIT', "Dodací místo:\r\n"); foreach ($_SESSION['objednavka']['doruceni'] as $k => $h) { $rozpis_obch .= iconv('UTF-8', 'iso-8859-2//TRANSLIT', $_t->_($k) . ": {$h}\r\n"); } $rozpis_obch .= "=================================================================================================\r\n"; //zjisteni textu a odeslani mailu $texty = zpracujTexty(readData('texty', array('jazyk' => $_SESSION['jazyk'], 'kody' => "'obj_zak','obj_obch'"))); #print_r($texty); #a nakonec vyprazdneni kosiku //echo "<pre>\n";die(str_replace('#COBJ#', (string) $vysl->o->row->cobj, str_replace('#ROZPIS#', $rozpis, $texty['obj_obch']))); //die(str_replace('#COBJ#', (string) $vysl->o->row->cobj, str_replace('#ROZPIS#', $rozpis, iconv('UTF-8', 'iso-8859-2//TRANSLIT', $texty['obj_zak'])))); //die("<pre>\n" . str_replace('#ROZPIS#', $rozpis . $rozpis_obch, iconv('UTF-8', 'iso-8859-2//TRANSLIT', $texty['obj_zak']))); @mailuj($_SESSION['uzivatel']['e_mail'], 'MFP shop - potvrzeni objednavky', str_replace('#COBJ#', (string) $vysl->o->row->cobj, str_replace('#ROZPIS#', $rozpis . $rozpis_obch, iconv('UTF-8', 'iso-8859-2//TRANSLIT', $texty['obj_zak']))), 'iso-8859-2'); @mailuj(EMAIL_OBCHODNIK, 'MFP shop - nova objednavka', str_replace('#COBJ#', (string) $vysl->o->row->cobj, str_replace('#ROZPIS#', $rozpis . $rozpis_obch, iconv('UTF-8', 'iso-8859-2//TRANSLIT', $texty['obj_obch']))), 'iso-8859-2'); //vyprazdnit klientsky kosik $_SESSION['kosik'] = array(); $_SESSION['objednavka'] = array(); //a jeste kosik na serveru readData('vysyp_kosik', array('osoba' => $_SESSION['uzivatel']['jmeno'])); unset($_t); unset($writer_preklad); unset($log_preklad); #$this->_Redirect(THIS_SERVER . '/katalog/index/index'); $this->_Redirect('/katalog/index/index'); #echo '<h1>Cislo objednavky: ' . (string) $vysl->o->row->cobj . '</h2>'; #echo '<pre>';print_r($_SESSION['objednavka']);echo "\n\n";print_r($_SESSION['kosik']);echo "\n\n";print_r($_SESSION['uzivatel']);echo '</pre>';die(); }
public function zpracujeditaciAction() { //overim, jestli firma neexistuje $data = array(); foreach ($_POST as $k => $h) { $data[$k] = textToDB($h); } #print_r($data); #die(); //ted nactu puvodni udaje: $vysl = readData('uzivatel_info', array('firma' => $_SESSION['uzivatel']['firma'], 'osoba' => $_SESSION['uzivatel']['jmeno'])); $puv = array('nazev_firmy' => trim((string) $vysl->f->row->nazev_firmy), 'ulice' => trim((string) $vysl->f->row->ulice), 'psc' => trim((string) $vysl->f->row->psc), 'mesto' => trim((string) $vysl->f->row->mesto), 'stat' => trim((string) $vysl->f->row->stat), 'telefon' => trim((string) $vysl->f->row->telefon), 'ico' => trim((string) $vysl->f->row->ico), 'dic' => trim((string) $vysl->f->row->dic), 'ujmeno' => trim((string) $vysl->f->row->ujmeno), 'osoba' => trim((string) $vysl->f->row->osoba), 'email' => trim((string) $vysl->f->row->u_e_mail), 'doruceni_nazev_firmy' => trim((string) $vysl->f->row->dodani_nazev_firmy), 'doruceni_ulice' => trim((string) $vysl->f->row->dodani_ulice), 'doruceni_psc' => trim((string) $vysl->f->row->dodani_psc), 'doruceni_mesto' => trim((string) $vysl->f->row->dodani_mesto)); $pars = array('skupina_oprav' => WEB_SKUPINA); $pars['xfirma'] = $_SESSION['uzivatel']['firma']; if (trim($_POST['firma']) == '') { $pars['nazev_firmy'] = textToDB(trim($_POST['jmeno'])); } else { $pars['nazev_firmy'] = textToDB(trim($_POST['firma'])); } $pars['ujmeno'] = $_SESSION['uzivatel']['login']; $pars['ulice'] = textToDB(trim($_POST['ulice'])); $pars['mesto'] = textToDB(trim($_POST['mesto'])); $pars['psc'] = textToDB(trim($_POST['psc'])); $pars['adresa'] = $pars['ulice'] . ' ' . $pars['psc'] . ' ' . $pars['mesto']; switch (trim($_POST['stat'])) { case 'sk': $pars['stat'] = 'Slovenská republika'; break; default: $pars['stat'] = 'Česká republika'; break; } $pars['telefon'] = textToDB(trim($_POST['telefon'])); $pars['email'] = textToDB(trim($_POST['email'])); $pars['ic'] = textToDB(trim($_POST['ic'])); $pars['dic'] = textToDB(trim($_POST['dic'])); $pars['osoba'] = textToDB(trim($_POST['jmeno'])); $pars['heslo'] = textToDB(trim($_POST['heslo'])); if (trim($_POST['firma2']) == '') { $pars['dodani_nazev_firmy'] = textToDB(trim($_POST['jmeno2'])); } else { $pars['dodani_nazev_firmy'] = textToDB(trim($_POST['firma2'])); } $pars['dodani_ulice'] = textToDB(trim($_POST['ulice2'])); $pars['dodani_mesto'] = textToDB(trim($_POST['mesto2'])); $pars['dodani_psc'] = textToDB(trim($_POST['psc2'])); $pars['dodani_adresa'] = $pars['dodani_ulice'] . ' ' . $pars['dodani_psc'] . ' ' . $pars['dodani_mesto']; #print_r($pars);die(); $vysl = readData('edituj_firmu', $pars); #a jeste musim opravit udaje v session $_SESSION['uzivatel']['nazev_firmy'] = $pars['nazev_firmy']; $_SESSION['uzivatel']['jmeno'] = $pars['osoba']; $_SESSION['uzivatel']['e_mail'] = $pars['email']; #echo "<pre>\nPars:\n";print_r($pars); #echo "\nzalozeno firem: " . (string) $vysl->f->row->pocet_firem; #echo "\nzalozeno uzivatelu: " . (string) $vysl->f->row->pocet_uzivatelu; #odeslani mailu se zpravou o zmene $zprava = 'Došlo ke změně údajů partnera.' . "\r\n\r\n"; $zprava .= "Původní údaje:\r\n"; $zprava .= "==============\r\n"; foreach ($puv as $k => $h) { $zprava .= "{$k}: {$h}\r\n"; } $zprava .= "\r\nNové údaje:\r\n"; $zprava .= "===========\r\n"; foreach ($pars as $k => $h) { $zprava .= "{$k}: {$h}\r\n"; } @mailuj(EMAIL_OBCHODNIK, 'MFP Shop - zmena udaju zakaznika', iconv('UTF-8', 'iso-8859-2//TRANSLIT', $zprava), 'iso-8859-2'); unset($pars); unset($puv); if (isset($_POST['fromobj']) && trim(strtolower($_POST['fromobj'])) == 'ano') { $this->_Redirect('/obchod/kosik/doruceni'); } else { $this->_Redirect('/'); } #echo "\n\n<pre>POST:\n";print_r($_POST); #die(); }