public function run() { DB::table('users')->delete(); $faker = Faker\Factory::create(); $user = new User(); $user->first_name = 'Admin'; $user->last_name = 'Joe'; $user->email = '*****@*****.**'; $user->password = Hash::make('password'); $user->birth_date = '1980-04-19'; $user->is_helper = '0'; $user->is_admin = '1'; $user->street = $faker->streetAddress; $user->city = $faker->city; $user->state = $faker->state; $user->zip = $faker->postcode; $user->save(); $user = new User(); $user->first_name = 'Johnny'; $user->last_name = 'Helper'; $user->email = '*****@*****.**'; $user->password = Hash::make('password'); $user->birth_date = '2001-02-19'; $user->gender = 'M'; $user->bio = "My name is Johnny and I am hard worker. I am saving up to buy a new bicycle"; $user->is_helper = '1'; $user->is_admin = '0'; $user->street = $faker->streetAddress; $user->city = 'San Antonio'; $user->state = 'TX'; $user->zip = $faker->postcode; $user->parent_email = $faker->freeEmail; $user->parent_phone = $faker->phoneNumber; $user->parent_first_name = $faker->firstName; $user->parent_last_name = $faker->lastName; $user->save(); $user = new User(); $user->first_name = 'Grandma'; $user->last_name = 'Peggy'; $user->email = '*****@*****.**'; $user->password = Hash::make('password'); $user->birth_date = '1946-04-19'; $user->is_helper = '0'; $user->is_admin = '0'; $user->street = $faker->streetAddress; $user->city = 'San Antonio'; $user->state = 'TX'; $user->zip = $faker->postcode; $user->save(); function check_in_range($start_date, $end_date, $date_from_user) { return $date_from_user >= $start_date && $date_from_user <= $end_date; } for ($i = 0; $i < 50; $i++) { $user = new User(); $user->gender = rand(0, 1) ? 'male' : 'female'; if ($user->gender == 'male') { $user->first_name = $faker->firstNameMale; } else { $user->first_name = $faker->firstNameFemale; } $user->last_name = $faker->lastName; $user->email = $faker->freeEmail; $user->password = Hash::make('password'); $user->birth_date = rand(0, 1) ? $faker->dateTimeBetween('-80 years', '-60 years') : $faker->dateTimeBetween('-18 years', '-12 years'); $user->bio = $faker->sentence(100); // to determine role based on age $start_date = '1930-01-01'; $end_date = '1970-01-01'; $date_from_user = $user->birth_date; $isUserOld = check_in_range($start_date, $end_date, $date_from_user); if ($isUserOld) { $user->is_helper = 0; } else { $user->is_helper = 1; } $user->is_admin = '0'; $user->street = $faker->streetAddress; $user->city = "{$faker->city}"; $user->state = "TX"; $user->zip = $faker->postcode; if ($user->is_helper == 1) { $user->parent_email = $faker->freeEmail; $user->parent_phone = $faker->phoneNumber; $user->parent_first_name = $faker->firstName; $user->parent_last_name = $faker->lastName; } $user->save(); } }
function format_agreements_data($agg) { $fagg = array(); foreach ($agg as $a) { $ff = format_files($a[10]); if (check_in_range($a[2], $a[3], time())) { $decorate1 = '<b>'; $decorate2 = '</b>'; } else { $decorate1 = $decorate2 = ""; } $fa = array($a[0], $decorate1 . $a[1][1] . ' (' . $a[1][2] . ', ' . $a[1][3] . ')' . $decorate2, $a[2], $a[3], $a[4], $a[5][1], BSCMGRPHD($a[6], $a[7], $a[8]), $a[9], $ff); $fagg[] = $fa; } return $fagg; }
array_push($errMsgs, "Aliases Invalid"); } } if (isset($_POST['uNation']) && trim($_POST['uNation'], " ") != "") { $nation = $_POST['uNation']; array_push($labelArr, "NATIONALITY"); array_push($dataArr, $nation); } else { array_push($errMsgs, "Nationality Empty"); } if (isset($_POST['uDOB']) && trim($_POST['uDOB'], " ") != "") { $start_date = '1916-01-01'; $time = strtotime("-1 month", time()); $end_date = date("Y-m-d", $time); $dob = $_POST['uDOB']; if (check_in_range($start_date, $end_date, $dob)) { array_push($labelArr, "DOB"); array_push($dataArr, $dob); } else { array_push($errMsgs, "Date Not In Range (1916 - Present)"); } } else { array_push($errMsgs, "Date of Birth Empty"); } if ($securimage->check($_POST['captcha_code']) == false) { // the code was incorrect // you should handle the error so that the form processor doesn't continue // or you can use the following code if there is no validation or you do not know how array_push($errMsgs, "The security code entered was incorrect."); } if (count($errMsgs) <= 0) {
$all_sales_fetch = Db::fetch("sales", array("user_id" => $user_id, "salesman_id" => $salesman_id), array("=", "="), "DESC"); //array to store all the sales id which are between FROM & To date $sales_id_array = array(); $total_item_sold_to_customers = 0; //Fetch thought all the sales and get the sales which is between from and to date //and store its sales id in $sales_id_array foreach ($all_sales_fetch as $sales_fetch) { //GET THE CURRENT SALES DATE //Replace "/" with "-" on current date $current_date = str_replace("/", "-", $sales_fetch["date"]); $current_sales_id = $sales_fetch["id"]; /* CHECK CURRENT Date is IN BETWEEN FROM AND TO DATE if yes store its sales_id in $sales_id_array */ if (check_in_range($from_date, $to_date, $current_date)) { //Store SALES_ID in Sales_id_array $sales_id_array[] = $current_sales_id; //increment $total_item_sold_to_customers $total_item_sold_to_customers++; } } //FETCH sales info with the help of sales_id which is stored in sales_id_array //check Sales_id_array is not empty if (count($sales_id_array) >= 1) { //Varaiable to store Total costprice , Total selling price, total quantity $total_costprice = 0; $total_sellingprice = 0; $total_quanity = 0; //Get all the sales foreach ($sales_id_array as $sales_id) {