<?php use_class('jng_sp'); $class_sp = new jng_sp(); $all_sp = $class_sp->retrieveList(); use_class('jng_sp_download'); $class_jd = new jng_sp_download(); use_class('jng_sp_orders'); $class_jo = new jng_sp_orders(); use_class('jng_sp_customers'); $class_jcust = new jng_sp_customers(); use_class('jng_sp_orders_xml'); $total_orders_created = 0; $daily_counter = array(); foreach ($all_sp as $sp_detail) { //initial setting $files_imported = 0; $orders_created = 0; $products_created = 0; $jng_sp_id = $sp_detail["jng_sp_id"]; $jng_sp_name = $sp_detail["name"]; $process_status = array('1' => 'D', '2' => 'R', '3' => 'R', '4' => 'R', '5' => 'R'); $xmlwithgpg = array('1'); if (array_key_exists($jng_sp_id, $process_status)) { $sp_detail = $class_sp->retrieveDetail($jng_sp_id); $jng_sp_id_with_no_external_xml_class = array('2', '4', '5'); if (!in_array($jng_sp_id, $jng_sp_id_with_no_external_xml_class)) { use_class('jng_sp_orders_xml_' . $jng_sp_id); } switch ($jng_sp_id) { case '1':
use_class('logger'); $logger = new logger('cron', 'tradebyte-orders-downloader'); use_class('Order'); use_class('tradebyte'); use_class('xml_tools'); use_class('products_ean'); use_class('jng_sp'); use_class('jng_sp_download'); use_class('jng_sp_orders'); use_class('jng_sp_customers'); use_class('logger'); $tb = new tradebyte(); $xmlt = new xml_tools(); $class_ean = new products_ean(); $class_sp = new jng_sp(); $class_jd = new jng_sp_download(); $class_jo = new jng_sp_orders(); $class_jcust = new jng_sp_customers(); $zade_prepayment_need_refreshed = false; function logThis($logdata) { global $logger; $logger->write($logdata); echo "{$logdata}<br />\n"; } ///////////////////////////// // STEP 1: DOWNLOAD ORDERS // ///////////////////////////// logThis('STEP 1: DOWNLOAD ORDERS'); //$tb->connect('NONSSL'); //$files = $tb->downloadFromDir(SP_TRADEBYTE_FTP_OUT_PATH, SP_TRADEBYTE_DOWNLOAD_ORDERS_PATH);
<?php use_class('logger'); use_class('jng_sp'); use_class('jng_sp_download'); use_class('Order'); use_class('Product'); $class_sp = new jng_sp(); $class_jd = new jng_sp_download(); $addhidemenu = $hidemenuscript == '' ? '' : '&hidemenu=true'; //FILE UPLOAD HANDLER - START $csv_seperator = ';'; $csv_data_wrapper = '"'; //PROCESS UPLOADED ORDERS FILE if (isset($_FILES['orders_file'])) { function closeOrderImport($order_id, $leadtime_start_date, $item_total, $total_price) { if ($order_id !== false) { $class_jcust = Order::getOldOrderFunctionSPCustomers(); $class_jcust->getFromOrder($order_id); $class_jo = Order::getOldOrderFunctionSP(); $class_jo->leadtimeSetStart($leadtime_start_date, '', $order_id); if ($item_total > 1) { Order::updateOrderItemTotal($order_id, $item_total); Order::updateOrderTotalPrice($order_id, $total_price); } } } function generateCustomerIDManually($postcode, $phone, $lastname, $firstname) { if ($phone != '') {
<?php //DOWNLOAD NEW ORDERS & INVOICES FROM NECKERMANN $mt_start = microtime(); global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; require_once '../functions-xml.php'; tep_db_connect(); use_class('jng_sp'); use_class('jng_sp_download'); use_class('jng_sp_orders'); use_class('jng_sp_customers'); $class_sp = new jng_sp(); $class_jd = new jng_sp_download(); $class_jo = new jng_sp_orders(); $class_jcust = new jng_sp_customers(); $jng_sp_id = '1'; $sp_detail = $class_sp->retrieveDetail($jng_sp_id); $download_status_to_decrypt = 'R'; $download_status_to_generate = 'D'; $timestamp = date('d.m.Y H:i:s'); $cron_result = array(); $cron_result[] = '>> ' . $timestamp; ///////////////////////////// // STEP 1: DOWNLOAD ORDERS // ///////////////////////////// $cron_result[] = 'STEP 1: DOWNLOAD ORDERS'; //initialize ftp settings and paths $ftp_server = SP_NECKERMANN_FTP_HOST;
/** * Description of orderscancelation * * @author IT TEAM BONOFACTUM * @created Nov 20, 2013 10:33:28 AM */ use_class('logger'); use_class('jng_sp'); use_class('jng_sp_orders'); use_class('jng_sp_download'); use_class('jng_sp_catalog'); use_class('products_minierp'); use_class('products_ean'); $class_sp = new jng_sp(); $class_jo = new jng_sp_orders(); $class_jd = new jng_sp_download(); $class_jc = new jng_sp_catalog(); $class_pm = new products_minierp(); $class_ean = new products_ean(); $whid = WAREHOUSE_ID_PRODUCTS_HAMBURG; if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'UPDATEOVERVIEW') { $jng_sp_id = tep_db_prepare_input($_POST['jng_sp_id']); $order_date = generateMysqlDateFromGerman($_POST['order_date']); $q = "SELECT SUM(joi.order_quantity) AS total_orders"; $q .= ", SUM(IF(joi.status NOT IN (10,12), joi.order_quantity, 0)) AS total_confirmed"; $q .= ", SUM(IF(joi.status IN (10,12), joi.order_quantity, 0)) AS total_cancels"; $q .= " FROM jng_sp_orders jo"; $q .= " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id"; $q .= " WHERE jo.jng_sp_id={$jng_sp_id} AND jo.order_date LIKE '{$order_date}%' AND jo.confirm_status='0'"; $r = tep_db_query($q);
function getAmazonNewOrders($with_header_message = true) { global $files; use_class('jng_sp_download'); $class_jd = new jng_sp_download(); $ready_path = SP_AMAZONEDE_DECRYPT_PATH; $archived_path = SP_AMAZONEDE_ARCHIVE_PATH; use_class('amazon/MarketplaceWebService/Client'); //MANDATORY CLASS use_class('amazon/MarketplaceWebService/Model/ErrorResponse'); //MANDATORY CLASS use_class('amazon/MarketplaceWebService/Model/GetReportRequest'); //FEED USED CLASS use_class('amazon/MarketplaceWebService/Model/GetReportResponse'); //FEED USED CLASS use_class('amazon/MarketplaceWebService/Model/GetReportListRequest'); //FEED USED CLASS use_class('amazon/MarketplaceWebService/Model/GetReportListResponse'); //FEED USED CLASS use_class('amazon/MarketplaceWebService/Model/TypeList'); //TYPE LIST CLASS $serviceUrl = "https://mws.amazonservices.de"; $aws_config = array('ServiceURL' => $serviceUrl, 'ProxyHost' => null, 'ProxyPort' => -1, 'MaxErrorRetry' => 3); $service = new MarketplaceWebService_Client(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, $aws_config, APPLICATION_NAME, APPLICATION_VERSION); $list = new MarketplaceWebService_Model_TypeList(); $list->setType('_GET_ORDERS_DATA_'); $report_from_date = new DateTime('-3 months', new DateTimeZone('UTC')); $report_to_date = new DateTime('now', new DateTimeZone('UTC')); $request = new MarketplaceWebService_Model_GetReportListRequest(); $request->setMerchant(MERCHANT_ID); $request->setMarketplace(MARKETPLACE_ID); $request->setAvailableToDate($report_to_date); $request->setAvailableFromDate($report_from_date); $request->setReportTypeList($list); $request->setAcknowledged(false); // echo"<pre>";var_dump($request);die(); $response = $service->getReportList($request); // echo"<pre>";var_dump($response);die(); if ($response->isSetGetReportListResult()) { if ($with_header_message) { echo "START DOWNLOADING NEW ORDERS FROM AMAZON PERIODE " . $report_from_date->format(DATE_ISO8601) . " TO " . $report_to_date->format(DATE_ISO8601) . "<br/>"; } $getReportListResult = $response->getGetReportListResult(); $reportInfoList = $getReportListResult->getReportInfoList(); if (count($reportInfoList) > 0) { $download_message = ' --- NO NEW ORDERS AVAILABLE ---<br/>'; foreach ($reportInfoList as $reportInfo) { if ($reportInfo->isSetReportId()) { $report_id = $reportInfo->getReportId(); $filename = date('Ymd') . '-' . $report_id . '.XML'; if (!$class_jd->isAlreadyDownloaded("jng_sp_id = 4 AND SUBSTRING_INDEX(filename, '-',-1) = '{$report_id}.XML'")) { $download_message = ''; echo " >> DOWNLOADING REPORT_ID: {$report_id} ... "; $fullpath_ready = $ready_path . $filename; $handle = fopen($fullpath_ready, 'w'); $request_report = new MarketplaceWebService_Model_GetReportRequest(); $request_report->setMarketplace(MARKETPLACE_ID); $request_report->setMerchant(MERCHANT_ID); $request_report->setReport($handle); $request_report->setReportId($report_id); $response_report = $service->getReport($request_report); echo "STREAMING XML {$filename} ... "; $archive_path_raw = $archived_path . 'raw/' . date('Y') . '/'; if (!file_exists($archive_path_raw)) { mkdir($archive_path_raw); } $fullpath_archive = $archive_path_raw . $filename; $class_jd->addDownload('4', 'ORDERS', $filename, 'R'); $files[] = $filename; fclose($handle); echo "PROCESS DONE<br/>"; } } } echo $download_message; } else { echo ' --- NO NEW ORDERS AVAILABLE ---<br/>'; } //LOOP MORE IF HAS NEXT NEW ORDERS if ($getReportListResult->isSetHasNext() && $getReportListResult->getHasNext()) { getAmazonNewOrders(false); } else { echo "DONE DOWNLOADING NEW ORDERS FROM AMAZON <br/>"; } } }
$sp_specsets = load_config('sp-specific-settings'); $po_pid_collection = array(); $file = $_FILES['amvdpo']; $columns = array(); $orders = array(); $orders_items = array(); //xlsx format not allowed if (($file['type'] == 'text/xml' || isFileTypeMSExcel($file['type'])) && $file['type'] != 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') { $logger->write('Loading xml file: ' . $file['name']); //$orders = amazonParsePOFiles($file['tmp_name'], $items_starting_row_id, $po_pid_collection); //$total_orders = count($orders); //if ($total_orders > 0) { $amazon_lastname = $amazon_id == $amazon_sample_id ? $amazon_sample_lastname : $amazon_refill_lastname; $import_date = date('Y-m-d H:i:s'); use_class('jng_sp_download'); $class_jd = new jng_sp_download(); $backup_path = SP_AMAZONVD_ARCHIVE_PATH . 'raw/' . date('Y') . '/'; if (!file_exists($backup_path)) { mkdir($backup_path); } //Give raw name also with $amazon_id to help cron order importer choose correct lastname $backup_name = "{$amazon_id}-{$file['name']}"; while (is_file($backup_path . $backup_name)) { $bn_split = explode('.', $backup_name); $bn_split_total = count($bn_split); $bn_split_ext = $bn_split_total - 1; $bn_split[$bn_split_total] = $bn_split[$bn_split_ext]; $bn_split[$bn_split_ext] = time(); $backup_name = implode('.', $bn_split); } $success_upload = false;
//DOWNLOAD NEW ORDERS FROM OTTO.DE global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; require_once '../functions-xml.php'; tep_db_connect(); use_class('logger'); $logger = new logger('cron', 'sp-2-orders-downloader'); use_class('jng_sp'); use_class('jng_sp_download'); use_class('jng_sp_orders'); use_class('jng_sp_customers'); $class_sp = new jng_sp(); $class_jd = new jng_sp_download(); $class_jo = new jng_sp_orders(); $class_jcust = new jng_sp_customers(); $jng_sp_id = '2'; $sp_detail = $class_sp->retrieveDetail($jng_sp_id); $download_status_to_generate = 'R'; $timestamp = date('d.m.Y H:i:s'); ///////////////////////////// // STEP 1: DOWNLOAD ORDERS // ///////////////////////////// $logger->write('STEP 1: DOWNLOAD ORDERS'); $shell = array(); $shell[] = 'cd ../../partners/otto.de/jms/'; $shell[] = './consume-order.sh'; $output = shell_exec(implode("\n", $shell)); $logger->write(trim($output));
/** * Download order files from tb server * @return Array of String contain filename that available on tb out folder */ public function downloadOrders() { use_class('jng_sp_download'); $class_jd = new jng_sp_download(); $result = false; $target_dir = TRADEBYTE_FTP_OUT_PATH; $local_dir = TRADEBYTE_DOWNLOAD_ORDERS_PATH; $dir_handle = $this->openDir($target_dir); $jng_sp_id = 0; //ALL DOWNLOADED ORDERS VIA TRADEBYTE WE USE 0 AS jng_sp_id "ONLY" ON TABLE jng_sp_download $download_status_to_generate = 'R'; while (($file = readdir($dir_handle)) !== false) { if ($file != '.' && $file != '..') { $downloaded_file = $this->downloadFile($target_dir . $file, $local_dir . $file); if ($downloaded_file !== false && $downloaded_file != -1) { $files[] = $downloaded_file; $class_jd->addDownload($jng_sp_id, 'ORDERS', basename($downloaded_file), $download_status_to_generate); $order_done_filename = TRADEBYTE_FTP_ARCHIVE_PATH . $this->getFilePrefixDone() . $file; ssh2_sftp_rename($this->sftp, $target_dir . $file, $order_done_filename); } } } if (is_array($files) && count($files) > 0) { $result = $files; } return $result; }