<td><strong>Product name</strong></td> <td><strong>Provider (normal days*)</strong></td> <td><strong>Date ordered (days* left)</strong></td> <td><strong>Amount arrived</strong></td> </tr> <?php if (mysql_num_rows($sql_result) > 0) { while ($row = mysql_fetch_assoc($sql_result)) { if ($row['supplier'] == 'DIL' or $row['supplier'] == 'JAG' or $row['supplier'] == 'GALA') { $days = 6; } if ($row['supplier'] == 'EU-tln' or $row['supplier'] == 'TE-tln') { $days = 2; } $date = $row['date']; $days_ago = getWorkingDays("{$date}", "{$date_now}", $holidays); $days_left = $days - $days_ago; $span = ""; $span_end = ""; if ($days_left < 0) { $span = "<span style=\"color:red;font-weight: bold;\">"; $span_end = "</span>"; } if ($days_left == 0) { $span = "<span style=\"font-weight: bold;\">"; $span_end = "</span>"; } echo "<tr>\n <td>" . $row['sku'] . "</td>\n <td>" . $row['name'] . "</td>\n <td>" . $row['supplier'] . " (" . $days . " working days)</td>\n <td>" . $row['date'] . $span . " (" . $days_left . " days)" . $span_end . "</td>\n <td><form action=\"ordered.php\" method=\"get\">\n <input type=\"tel\" size=\"1\" name=\"stock_in\" value=\"" . $row['ordered'] . "\" />\n <input type=\"hidden\" value=\"" . $row['name'] . "\" name=\"name\">\n <input type=\"hidden\" value=\"" . $row['ordered'] . "\" name=\"ordered\">\n <input type=\"hidden\" value=\"" . $row['qty'] . "\" name=\"qty\">\n <input type=\"submit\" value=\"Add>>\" name=\"add\">\n </form></td>\n </tr>\n "; $style = ""; } } else {
$no_remaining_days--; if ($the_last_day_of_week == 6) { // if the end date is a Saturday, then we subtract another day $no_remaining_days--; } } else { // the start date was a Saturday (or earlier), and the end date was (Mon..Fri) // so we skip an entire weekend and subtract 2 days $no_remaining_days -= 2; } } //The no. of business days is: (number of weeks between the two dates) * (5 working days) + the remainder //---->february in none leap years gave a remainder of 0 but still calculated weekends between first and last day, this is one way to fix it $workingDays = $no_full_weeks * 5; if ($no_remaining_days > 0) { $workingDays += $no_remaining_days; } //We subtract the holidays foreach ($holidays as $holiday) { $time_stamp = strtotime($holiday); //If the holiday doesn't fall in weekend if ($startDate <= $time_stamp && $time_stamp <= $endDate && date("N", $time_stamp) != 6 && date("N", $time_stamp) != 7) { $workingDays--; } } return $workingDays; } //Example: $holidays = array("2008-12-25", "2008-12-26", "2009-01-01"); echo getWorkingDays("2008-12-22", "2009-01-02", $holidays);
function cw_product_stages_date_in_future($period, $since_date = 0) { if (!$since_date) { $since_date = time(); } $safety_cnt = 1000; $endDate = $since_date; $bd_period = 0; while ($period > $bd_period && $safety_cnt > 0) { $bd_period = getWorkingDays($since_date, $endDate, array()); $endDate += 24 * 60 * 60; $safety_cnt--; } return $endDate; // return ($since_date + $period*24*60*60); }
<?php include_once 'connectdb.php'; if (isset($_POST['submit'])) { $projectTitle = trim($_POST['projectTitle']); $clientID = $_POST['clientID']; $payOrder = $_POST['payOrder']; $startDate = $_POST['startDate']; $endDate = $_POST['endDate']; $sumWH = $_POST['sumWH']; $comments = trim($_POST['comments']); $username = $_POST['username']; //Maths section include 'countWorkDays.php'; include 'holidaysArray.php'; $workPeriod = getWorkingDays($startDate, $endDate, $holidays); $dayWH = ceil($sumWH / $workPeriod); //Adding Project to Database $posting = "INSERT INTO projects " . "(`title`, `startdate`, `enddate`, `clientid`, `sumwh`, `whperday`, `payorder`, `comments`, `username`)" . " VALUES ('" . $projectTitle . "', '" . $startDate . "', '" . $endDate . "', '" . $clientID . "', '" . $sumWH . "', '" . $dayWH . "', '" . $payOrder . "', '" . $comments . "', '" . $username . "')"; if (!mysqli_query($link, $posting)) { $notepop = '<div class="col-xs-6">' . '<div class="alert alert-dismissible alert-danger">' . '<button type="button" class="close" data-dismiss="alert">×</button>' . '<strong>Oh snap!</strong><br><a href="#" class="alert-link">Make sure you put the right things in the inputs</a>' . ' and try submitting again.' . '<br>Please avoid the use of quotation marks of any sort, forward slashes, back slashes and any other symbols' . '<br>This issue should be fixed soon by the web admins' . '</div>' . '</div>'; } else { $notepop = '<div class="col-xs-6"> <div class="alert alert-dismissible alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>' . $projectTitle . '</strong><br>has been successfully added. </div> </div>'; } }
function getStafflyWorkHoursList() { $query = "\n\t\t\tSELECT staff.name AS staff_name,SUM(IF(hours_checked IS NULL,hours_own,hours_checked)) AS sum,\n\t\t\t\tROUND(SUM(IF(hours_checked IS NULL,hours_own,hours_checked))/" . getWorkingDays(option('date_range/from'), option('date_range/to'), getHolidays(), getOvertimedays(), false) . ",2) AS avg\n\t\t\tFROM schedule INNER JOIN people staff ON staff.id=schedule.uid\n\t\t\tWHERE completed=1 AND schedule.display=1\n\t\t"; $query = $this->dateRange($query, 'start', true); $query .= "\tGROUP BY schedule.uid\n\t\t"; $query = $this->orderBy($query, 'sum', 'DESC'); return $this->db->query($query)->result_array(); }
foreach($val as $key2 => $val2) { $table .= '</tr><tr><td class="num">'.($key2+1).'</td><td class="name">'.$val[$key2]['name'].'</td><td class="quantity">'.$val[$key2]['quantity'].'</td><td class="price">'.$val[$key2]['price'].'</td><td class="currensy">р.</td><td class="price">'.$val[$key2]['summ'].'</td><td class="currensy">р.</td>'; $itogo += (float)$val[$key2]['summ']; $nds += round(($val[$key2]['summ']/118*18), 2); } $table .= '</tr>'; $table .= '<tr class="bold_font"><td colspan="5">Итого с НДС</td><td class="price">'.number_format($itogo,"2",".",'').'</td><td class="currensy">р.</td></tr>'; $table .= '<tr class="bold_font"><td colspan="5">Из них НДС (18%)</td><td class="price">'.number_format($nds,"2",".",'').'</td><td class="currensy">р.</td></tr>'; $table .= '</table>'; $date_arr = explode('-',$val[0]['date']); $specification_date =$date_arr[2].' '.$month_day_name_arr[(int)$date_arr[1]].' '.$date_arr[0] .' г.'; $production_term_in_days = getWorkingDays($val[0]['date']." 00:00:00",$specifications_arr[$key][0]['shipping_date_time']); $production_term_in_days_word = (trim((int)$production_term_in_days)==0)? 'ноль' : trim(num_word_transfer((int)$production_term_in_days)); list($first_part,$second_part) = explode('-',number_format($itogo,2,'-','')); $for_pay = num_word_transfer($first_part); $for_pay = strtr($for_pay,$desjatichn_word_transfer_arr); list($first_part_nds,$second_part_nds) = explode('-',number_format($nds,2,'-','')); //$for_pay_nds = num_word_transfer($first_part_nds); //$for_pay_nds = strtr($for_pay_nds,$desjatichn_word_transfer_arr); $for_pay = '('.$for_pay.' рублей '.$second_part.' коп.), в т.ч. НДС 18% '.$first_part_nds.' руб. '.$second_part_nds.' коп.'; $for_pay = strtr($for_pay,$change_word_ending_arr_I); $for_pay = strtr($for_pay,$change_word_ending_arr_II); $for_pay = strtr($for_pay,$change_word_ending_arr_III);
} if ($h_1['appointment_start_date'] > $sem25_end) { $first_25 = 0; } $first_25 = $first_25 * $day_rate; $sem2 = getWorkingDays($sem_2_start, $sem_2_end, 0); if ($h_1['appointment_start_date'] > $sem_2_end || $h_1['appointment_end_date'] < $sem_2_start) { $sem2 = 0; } $sem2 = $sem2 * $day_rate; $sem3 = getWorkingDays($sem_3_start, $sem_3_end, 0); if ($h_1['appointment_start_date'] > $sem_3_end || $h_1['appointment_end_date'] < $sem_3_start) { $sem3 = 0; } $sem3 = $sem3 * $day_rate; $sem75 = getWorkingDays($sem75_start, $sem75_end, 0); if ($h_1['appointment_start_date'] > $sem75_end || $h_1['appointment_end_date'] < $sem75_start) { $sem75 = 0; } $sem75 = $sem75 * $day_rate; // echo " ".$sem75_end." "; if ($h_1['appointment_end_date'] < $sem75_end && $h_1['appointment_end_date'] > $sem25_start || $h_1['appointment_start_date'] > $sem25_start && $h_1['appointment_start_date'] < $sem75_end || $flag_all) { //$end_ time = $h_1['appointment_end_date'] < $sem75_end && $h_1['appointment_end_date'] > $sem25_start $subtot1 += $first_25; $subtot2 += $sem2; $subtot3 += $sem3; $subtot4 += $sem75; $subtot5 += $h_1['total_salary']; $h_1['salary_step'] = $extra_step + $h_1['salary_step']; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo "<tr class=\"warning\"><td>" . $h_1['department'] . "</td><td>" . $hint_info['FirstName'] . " " . $hint_info['LastName'] . "</td><td>" . $h_1['appointment_start_date'] . "</td><td>" . $h_1['appointment_end_date'] . "</td><td>" . $h_1['type_of_appointment'] . "</td>" . "</td><td>" . $h_1['salary_step'] . "</td><td>" . $h_1['percentage_of_full_time'] . "</td><td> Budget Actual </td><td>" . $h_1['total_salary'] . "<br>" . $hint_info2['AnnualSalary'] . "</td><td>" . $h_1['salary'] . "</td><td>" . $first_25 . "</td><td>" . $sem2 . "</td><td>" . $sem3 . "</td><td>" . $sem75 . "</td><td>" . $h_1['total_salary'] . "</td>" . "</tr>";
public function get_working_days_left() { $start_date = date_create('now', timezone_open('UTC')); // We substract 1 here to be able to 'chase the target' rather than 'working ahead' return getWorkingDays(date_format($start_date, 'Y-m-d'), date_format($this->end_date, 'Y-m-d')) - 1; }