$datefrom = $_SESSION['end_date']; function last_monday($date) { if (!is_numeric($date)) { $date = strtotime($date); } if (date('w', $date) == 1) { return $date; } elseif (date('w', $date) == 0) { return strtotime('next monday', $date); } else { return strtotime('last monday', $date); } } //echo 'Last Monday is: =====> ';echo date('j F,Y', last_monday($_SESSION['start_date'])); $starting = date('Y-m-d H:i:s', last_monday($dateto)); //echo '<br/>'; $date_last = strtotime($datefrom); $nextSunday = date("j F,Y", strtotime('next sunday', $date_last)); //echo 'Next Sunday is: =====> '.$nextSunday; $end = date("Y-m-d H:i:s", strtotime('next sunday', $date_last)); //echo '<br/>'; $date1 = new DateTime($starting); $date2 = new DateTime($end); $interval = $date1->diff($date2); //echo '<br/>'; echo "difference " . $interval->days . " days "; echo '<br/>'; $aaa = date("Y-m-d", strtotime($starting)); $bbb = date("Y-m-d", strtotime($nextSunday)); $date_plus7 = $starting; $date_plus7 = strtotime($date_plus7); $date_plus7 = strtotime("+7 day", $date_plus7);
function add_distribution_center($content) { //echo '<pre>'; print_r($content); die; $current_orderid = $content['myorderid']; $item_count = count($content['itemid']); //echo $item_count; die; // ------------------------ Getting admin email address (START) ------------------------------------ $sql = "SELECT order_email from sitesetting"; $adminemail = $this->dbobject->get_name_using_id($sql); // ------------------------ Getting admin email address (END) ------------------------------------ // ------------------------ Getting order data (START) ------------------------------------ $sql = "SELECT * from " . ORDERS_MASTER_TABLE . " WHERE id=" . $current_orderid . ""; $query = mysql_query($sql); $data = mysql_fetch_array($query); //echo '<pre>'; print_r($data); // ------------------------ Getting order data (START) ------------------------------------ // ------------------------ Getting User information (START) ------------------------------------ $sql_user = "******" . $data['email'] . "'"; $user_query = mysql_query($sql_user); $user_information = mysql_fetch_array($user_query); $email = $user_information['email']; //echo '<pre>'; print_r($user_information); die; // ------------------------ Getting User information (START) ------------------------------------ if ($item_count > 0) { for ($i = 0; $i < $item_count; $i++) { //echo 'Item Id is ==> '. $content['itemid'][$i]; echo '<br/>'; $id = $content['itemid'][$i]; // Get item DC $prev_DC = $this->dbobject->get_name_using_id("select distribution_center from " . ORDERS_DETAILS_TABLE . " where itemid='" . $id . "' AND orderid='" . $current_orderid . "'"); $whopur = $this->dbobject->get_name_using_id("select who_purchase from " . ORDERS_DETAILS_TABLE . " where itemid='" . $id . "' AND orderid='" . $current_orderid . "'"); if ($whopur == 'self') { $service = "SHIPPING ONLY"; } else { $service = "BUY and SHIP"; } $userid = $this->dbobject->get_name_using_id("select userid from " . ORDERS_DETAILS_TABLE . " where itemid='" . $id . "'"); $username = $this->dbobject->get_name_using_id("select firstname from users where id='" . $userid . "'"); $lastname = $this->dbobject->get_name_using_id("select lastname from users where id='" . $userid . "'"); $content['status'][$i]; $AddArray = array("item_status" => $content['item_status'][$i]); $where = "itemid='" . $id . "' AND orderid='" . $current_orderid . "'"; $usaddress = ''; //echo '<pre>'; print_r($AddArray); die; $usaddress = $this->dbobject->get_name_using_id("select usaddress from " . ADMINISTRATOR_TABLE); //echo 'Current Item Status =='.$prev_status; echo '<br/>'; echo 'Selected Item Status ==> '.$content['item_status'][$i]; echo '<br/>'; if ($prev_DC != $content['distribution_center'][$i] && ($content['distribution_center'][$i] == 'Select DC' || $content['distribution_center'][$i] == 'DC 1' || $content['distribution_center'][$i] == 'DC 2' || $content['distribution_center'][$i] == 'DC 3')) { ##################################################### ADD ITEM STATUS ############################################# $date = date('Y-m-d H:i:s'); function last_monday($date) { if (!is_numeric($date)) { $date = strtotime($date); } if (date('w', $date) == 1) { return $date; } elseif (date('w', $date) == 0) { return strtotime('next monday', $date); } else { return strtotime('last monday', $date); } } //echo 'Last Monday is: =====> ';echo date('j F,Y', last_monday($date)); $starting = date('d-m-Y', last_monday($date)); //echo '<br/>'; $date_last = strtotime($date); $nextSunday = date("j F,Y", strtotime('next sunday', $date_last)); //echo 'Next Sunday is: =====> '.$nextSunday; $end = date("d-m-Y", strtotime('next sunday', $date_last)); //echo '<br/>'; $week_range = $starting . '-' . $end; //die; $month_assigned = date('m'); //echo '=========> '. $month_assigned; //die; //echo $prev_status; //echo '<br/>'; //echo $content['item_status'][$i]; // ------------ Update item status in "orders_details" table (START)----------------------- $update_item_status = array("distribution_center" => $content['distribution_center'][$i], "dc_assigned_date" => date('Y-m-d H:i:s'), "week_assigned" => $week_range, "month_assigned" => $week_range); $where = "orderid='" . $current_orderid . "' AND itemid='" . $id . "'"; //echo '<pre>'; print_r($update_item_status); die; $this->dbobject->update_record(ORDERS_DETAILS_TABLE, $update_item_status, $where, '', $query_echo = ''); // ------------ Update item status in "orders_details" table (END)----------------------- } } } }