protected function afterSave() { parent::afterSave(); $images = CUploadedFile::getInstances($this, 'images'); if (isset($images) && count($images) > 0) { foreach ($images as $k => $img) { $imageName = md5(microtime()) . '.jpg'; if ($img->saveAs($this->getFolder() . $imageName)) { $advImg = new Image(); $advImg->goods_id = $this->getPrimaryKey(); $advImg->image = $imageName; $advImg->save(); } } } if ($this->isNewRecord) { $count = new Count(); $count->goods_id = $this->id; $count->count = $this->count; $count->size = $this->size; $count->color = $this->color; $count->save(); } else { Count::model()->updateAll(array('goods_id' => $this->id, 'count' => $this->count, 'size' => $this->size, 'color' => $this->color), 'goods_id=:goods_id', array(':goods_id' => $this->id)); } }
public function getFreeOrdersNumber($start) { $count = new Count($this->software, $start); $number2 = $count->getNumber(); $p = $this->number - $number2; if ($p < 30) { return 30 - $p; } else { return 0; } }
function test_makeCountMatch_singleLetter() { //Arrange $test_makeCountMatch = new Count(); $input_word = "a"; $input_string = ["a"]; //Act $result - $test_makeCountMatch->makeCountMatch($input_word, $input_string); //Assert $this->assertEquals(["1"], $result); }
function test_makeCount_multipleWord() { //arrange $test_Count = new Count(); $search_word = "and"; $sentence = "milk and eggs and budda"; //act $result = $test_Count->contains($search_word, $sentence); //assert $this->assertEquals(2, $result); }
/** @test */ public function compensateRemovesNumber() { $count = new Count(); $count->init(); $count->accumulate(1); $count->accumulate(1); $count->compensate(1); $this->assertEquals(1, $count->emit()); }
<?php require_once "../../lib/count.class.php"; $objCountInfo = new Count(); extract($_POST); //get a new id ///////////////////////////// $count_name = $_POST['count_name']; $getData = "'','{$count_name}'"; $objCountInfo->CreateCount($getData); echo "<b>Data Save Successsfull</b>"; include '../contents/create_count.php';
<?php require_once "../../../lib/count.class.php"; $count_id = $_GET['count_id']; $objCountInfo = new Count(); $CountById = $objCountInfo->retriveCountById($count_id); $count_name = $CountById[0]['count_name']; ?> <div id="note"> </div> <form id="lotForm" name="lotForm" method="post" action="includes/model/count_actions_update.php" > <?php require_once "../partials/_form_count.php"; ?> <div id="submit_set"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="right"> </td> <td> </td> <td align="left"> </td> </tr> <tr> <td width="40%" align="right"><input type="hidden" name="count_id" id="count_id" value="<?php echo $count_id; ?> "/></td> <td width="11%"><input class="button" name="Submit" type="submit" value="Update" id="Submit"/></td> <td width="49%" align="left"> </td> </tr> </table> </div>
<th width="10%">Action</th> @endif @endif </tr> </thead> <tbody> @foreach($requests as $request) <tr id="content" <?php $useroffice = Auth::user()->office_id; $doc = new Document(); $doc = DB::table('document')->where('pr_id', $request->id)->first(); $doc_id = $doc->id; $userx = Auth::User()->id; $counter = 0; $counter = Count::where('user_id', $userx)->where('doc_id', $doc_id)->count(); if ($counter != 0) { echo "class ='success'"; } ?> > <td><?php echo str_pad($request->controlNo, 5, '0', STR_PAD_LEFT); ?> </td> <td> <a data-toggle="tooltip" data-placement="top" class="purpose" href="{{ URL::to('purchaseRequest/vieweach/'. $request->id) }}" title="View Project Details"> {{ $request->projectPurpose; }} </a> </td> <?php
public function done() { $taskdetails_id = Input::get('taskdetails_id'); $taskd = TaskDetails::find($taskdetails_id); $taskd->status = "Done"; $docs = Document::find($taskd->doc_id); $id = $docs->pr_id; $delcount = Count::where('doc_id', $docs->id)->delete(); $users = User::get(); foreach ($users as $user) { $count = new Count(); $count->user_id = $user->id; $count->doc_id = $docs->id; $count->save(); } $birth = new DateTime($taskd->dateReceived); $today = new DateTime(); $diff = $birth->diff($today); $aDays = $diff->format('%d'); $taskd->daysOfAction = $aDays; $taskd->dateFinished = $today; $taskd->save(); date_default_timezone_set("Asia/Manila"); $upDate = date('Y-m-d H:i:s'); DB::table('purchase_request')->where('id', $id)->update(array('updated_at' => $upDate)); $tasknext = TaskDetails::find($taskdetails_id + 1); if ($tasknext->doc_id == $taskd->doc_id) { $counter = 1; $tasknext = TaskDetails::find($taskdetails_id + $counter); while ($tasknext->status == "Lock") { $counter = $counter + 1; $tasknext = TaskDetails::find($taskdetails_id + $counter); } $tasknext->status = "New"; $tasknext->save(); } else { $purchase = Purchase::find($docs->pr_id); $purchase->status = "Closed"; $purchase->save(); } $request_id = Input::get('pr_id'); return Redirect::to("purchaseRequest/vieweach/{$request_id}"); }
/** * @dataProvider getAlternativeRulesCountTestCases */ public function testAlternativeRulesTestCases($number, $expected) { $c = Count::createWithAlternativeSetOfRules(); $this->assertEquals($expected, $c->to($number)); }
<?php require_once "../../../lib/count.class.php"; $objCountListAll = new Count(); $CountListAll = $objCountListAll->retriveCountInfo(); $rowCountListAll = count($CountListAll); ?> <table width="100%" border="0"> <tr> <td> </td> <td> </td> <td align="right"><a class="thickbox" href="includes/contents/create_count.php?height=200&width=500" title="Count" >Back</a></td> </tr> <tr> <td width="140"><b>Count Name</b></td> <td width="57"> </td> <td width="67"> </td> </tr> <?php for ($i = 0; $i < $rowCountListAll; $i++) { if ($i % 2 == 0) { $bgc = "#F7F7F7"; } else { $bgc = "#F1F1F1"; } ?> <tr id ="stk_<?php echo $CountListAll["{$i}"]["count_id"]; ?>
/** * Get Item Count * * @param sentItems - optional - * If true, the API returns the number of items in user's Sent Items * otherwise it returns the number of the items in user's Inbox and Sent Items. * @param filter - optional - * all: return all items * expired: returns all expired items * unexpired: returns only unexpired items * @return The Count object containing the number of items or the error code and message * returned by the server. * */ public function getItemsCount($sentItems = '', $filter = '') { $parameters = array(); $urld = 'dpi/v1/item/count'; if ($sentItems !== '') { $parameters['sentItems'] = $sentItems; } if ($filter !== '') { $parameters['filter'] = $filter; } $this->response = $this->_restTransportInstance->sendRequest($urld, $parameters, 'GET', $this->_authToken); $responseBody = simplexml_load_string($this->response); $returnObject = new Count(); if ($responseBody === false) { $errorCode = 'N/A'; $errorMessage = 'The server has encountered an error, please try again.'; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } else { if (empty($responseBody->errorStatus)) { $itemCount = (string) $responseBody->itemCount; $returnObject->setItemCount($itemCount); } else { $errorCode = (string) $responseBody->errorStatus->code; $errorMessage = (string) $responseBody->errorStatus->message; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } } return $returnObject; }
<?php require_once "../../lib/count.class.php"; $objCountInfo = new Count(); extract($_POST); $count_name = $_POST['count_name']; $count_id = $_POST['count_id']; $objCountInfo->updateCount($count_id, $count_name); echo "<b>Data Save Successsfull<b>"; ?>
public function philgeps() { Session::put('goToChecklist', 'true'); //Initializations $referenceno = strip_tags(Input::get('referenceno')); $datepublished = Input::get('datepublished'); $enddate = Input::get('enddate'); $by = " " . strip_tags(Input::get('by')); $by = preg_replace('/\\s+/', ' ', $by); if ($by == " ") { $by = "None"; } $taskdetails_id = Input::get('taskdetails_id'); $check = 0; $taskd = TaskDetails::find($taskdetails_id); $docs = Document::find($taskd->doc_id); if ($taskd->status == "Done") { Session::put('errorchecklist', 'Saved failed. Task was already completed by another user.'); return Redirect::back(); } //Validation Process if (ctype_alnum(str_replace(array(' ', '-', '.', ',', 'ñ', 'Ñ'), '', $by))) { $check = $check + 1; } if (ctype_alnum(str_replace(array(' ', '-', '.'), '', $referenceno))) { $check = $check + 1; } if ($check == 2) { $id = $docs->pr_id; $delcount = Count::where('doc_id', $docs->id)->delete(); $userx = User::get(); foreach ($userx as $userv) { $count = new Count(); $count->user_id = $userv->id; $count->doc_id = $docs->id; $count->save(); } Session::put('successchecklist', 'Task completed.'); $taskd = TaskDetails::find($taskdetails_id); $taskd->status = "Done"; $taskd->custom1 = $referenceno; $taskd->custom2 = $datepublished; $taskd->custom3 = $enddate; $taskd->assignee = $by; $taskd->save(); $tasknext = TaskDetails::find($taskdetails_id + 1); $tasknextc = TaskDetails::where('id', $taskdetails_id + 1)->where('doc_id', $docs->pr_id)->count(); date_default_timezone_set("Asia/Manila"); $upDate = date('Y-m-d H:i:s'); DB::table('purchase_request')->where('id', $id)->update(array('updated_at' => $upDate)); DB::table('taskdetails')->where('id', $taskdetails_id)->update(array('dateFinished' => $upDate)); if ($tasknextc != 0) { //Project Type Filter $counter = 1; $tasknext = TaskDetails::find($taskdetails_id + $counter); while ($tasknext->status == "Lock" || $tasknext->status == "Done") { $counter = $counter + 1; $tasknext = TaskDetails::find($taskdetails_id + $counter); } $tasknext->status = "New"; $tasknext->save(); //End Project Type Filter } else { $purchase = Purchase::find($docs->pr_id); $purchase->status = "Closed"; $purchase->save(); $request_id = Input::get('pr_id'); return Redirect::to("purchaseRequest/vieweach/{$request_id}"); } } else { Session::put('errorchecklist', 'Invalid input.'); return Redirect::back()->withInput(); } return Redirect::back(); }
public function janisawesome() { function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; } function generateRandomAmount() { $length = rand(4, 8); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= rand(1, 9); } return $randomString; } $numLoop = 1; while ($numLoop < 301) { $purchase = new Purchase(); $document = new Document(); $purchase->projectPurpose = generateRandomString(); $purchase->sourceOfFund = generateRandomString(); $controlAmt = generateRandomAmount(); $controlAmt .= ".00"; $purchase->amount = number_format($controlAmt); $purchase->office = "1"; $purchase->requisitioner = "1"; $purchase->dateRequested = date('Y-m-d H:i:s'); $purchase->dateReceived = date('Y-m-d H:i:s'); $purchase->status = 'Active'; $purchase->otherType = " "; // Get latest control number $cn = 0; $purchase_controlNo = Purchase::orderBy('ControlNo', 'DESC')->first(); if (!$purchase_controlNo == NuLL) { $cn = $purchase_controlNo->controlNo; } $cn += 1; $purchase->controlNo = $cn; if (Input::get('otherType') == ' ') { $purchase->projectType = "None"; } else { $purchase->projectType = "None"; } // Set creator id $user_id = Auth::user()->id; $purchase->created_by = $user_id; $purchase_save = $purchase->save(); if ($purchase_save) { if ($controlAmt < 50000) { $amtControl = 1; } else { if ($controlAmt >= 50000 && $controlAmt <= 500000) { $amtControl = 2; } else { if ($controlAmt >= 500000) { $amtControl = 3; } } } $document->pr_id = $purchase->id; $document->work_id = $amtControl; $document_save = $document->save(); if ($document_save) { $doc_id = $document->id; $workflow = Workflow::find($document->work_id); $section = Section::where('workflow_id', $document->work_id)->orderBy('section_order_id', 'ASC')->get(); $firstnew = 0; // Set due date; $new_purchase = Purchase::find($purchase->id); $workflow_id = "1"; $workflow = Workflow::find($workflow_id); $addToDate = $workflow->totalDays; date_default_timezone_set("Asia/Manila"); $dueDate = date('Y-m-d H:i:s', strtotime("+{$addToDate} days")); $new_purchase->dueDate = $dueDate; $new_purchase->save(); $tasks = Task::where('wf_id', $document->work_id)->orderBy('section_id', 'ASC')->orderBy('order_id', 'ASC')->get(); foreach ($tasks as $task) { $task_details = new TaskDetails(); $task_details->task_id = $task->id; $stringamount = $new_purchase->amount; $stringamount = str_replace(str_split(','), '', $stringamount); $amount = (double) $stringamount; if ($firstnew == 0) { $task_details->status = "New"; } else { $task_details->status = "Pending"; } //Project Type if ($task->taskName == "PRE-PROCUREMENT CONFERENCE" || $task->taskName == "ADVERTISEMENT" || $task->taskName == "PRE-BID CONFERENCE") { $task_details->status = "Lock"; if ($new_purchase->projectType == "Goods/Services") { if ($task->taskName == "PRE-PROCUREMENT CONFERENCE" || $task->taskName == "ADVERTISEMENT") { if ($amount > 2000000) { $task_details->status = "Pending"; } } else { if ($task->taskName == "PRE-BID CONFERENCE") { if ($amount > 1000000) { $task_details->status = "Pending"; } } } } elseif ($new_purchase->projectType == "Infrastructure") { if ($task->taskName == "PRE-PROCUREMENT CONFERENCE" || $task->taskName == "ADVERTISEMENT") { if ($amount > 5000000) { $task_details->status = "Pending"; } } else { if ($task->taskName == "PRE-BID CONFERENCE") { if ($amount > 1000000) { $task_details->status = "Pending"; } } } } elseif ($new_purchase->projectType == "Consulting Services") { if ($amount > 1000000) { $task_details->status = "Pending"; } } } //End Project Type $firstnew = 1; $task_details->doc_id = $document->id; $task_details->save(); } $users = User::all(); foreach ($users as $user) { $count = new Count(); $count->user_id = $user->id; $count->doc_id = $doc_id; $count->save(); } $pr_id = Session::get('pr_id'); DB::table('attachments')->where('doc_id', $doc_id)->update(array('saved' => 1)); DB::table('attachments')->where('saved', '=', 0)->delete(); Session::forget('doc_id'); $connected = true; // $connected = @fsockopen("www.google.com", 80); //website, port (try 80 or 443) if (!$connected) { $sendee = DB::table('users')->where('id', $purchase->requisitioner)->first(); $email = $sendee->email; $fname = $sendee->firstname; $data = ['id' => $purchase->id]; Mail::send('emails.template', $data, function ($message) use($email, $fname) { $message->from('*****@*****.**', 'Procurement Tracking System Tarlac'); $message->to($email, $fname)->subject('Tarlac Procurement Tracking System: New Purchase Request Created'); }); $notice = "Purchase request created successfully. "; // Insert data to reports table $date_received = Input::get('dateReceived'); $date_received = substr($date_received, 0, strrpos($date_received, ' ')); $reports = Reports::whereDate($date_received)->first(); if ($reports == null) { $reports = new Reports(); $reports->date = $date_received; $reports->pRequestCount = 1; } else { $reports->pRequestCount = $reports->pRequestCount + 1; } $reports->save(); //End Reports } else { // Insert data to reports table $date_received = Input::get('dateReceived'); $date_received = substr($date_received, 0, strrpos($date_received, ' ')); $reports = Reports::whereDate($date_received)->first(); if ($reports == null) { $reports = new Reports(); $reports->date = $date_received; $reports->pRequestCount = 1; } else { $reports->pRequestCount = $reports->pRequestCount + 1; } $reports->save(); //End Reports $notice = "Purchase request created successfully. Email notice was not sent. "; } Session::put('notice', $notice); $office = Office::all(); $users = User::all(); $workflow = Workflow::all(); //return Redirect::to('purchaseRequest/view'); return Redirect::to('janisawesome'); Session::put('imgsuccess', 'Files uploaded.'); } else { $message = "Failed to create purchase request."; Session::put('main_error', $message); // Get Other Error Messages $error_projectPurpose = $purchase->validationErrors->first('projectPurpose'); $error_projectType = $purchase->validationErrors->first('projectType'); $error_sourceOfFund = $purchase->validationErrors->first('sourceOfFund'); $error_amount = $purchase->validationErrors->first('amount'); $error_office = $purchase->validationErrors->first('office'); $error_requisitioner = $purchase->validationErrors->first('requisitioner'); $error_dateRequested = $purchase->validationErrors->first('dateRequested'); $error_dateReceived = $purchase->validationErrors->first('dateReceived'); // Inserting Error Message To a Session Session::put('error_projectPurpose', $error_projectPurpose); Session::put('error_sourceOfFund', $error_sourceOfFund); Session::put('error_amount', $error_amount); Session::put('error_office', $error_office); Session::put('error_requisitioner', $error_requisitioner); Session::put('error_dateRequested', $error_dateRequested); Session::put('error_dateReceived', $error_dateReceived); Session::put('error_projectType', $error_projectType); if (Input::get('hide_modeOfProcurement') == "") { Session::put('m6', 'required'); } Session::put('imgsuccess', 'Files uploaded.'); return Redirect::back()->withInput(); } } else { // Set Main Error $message = "Failed to create purchase request."; Session::put('main_error', $message); // Get Other Error Messages $error_projectPurpose = $purchase->validationErrors->first('projectPurpose'); $error_projectType = $purchase->validationErrors->first('projectType'); $error_sourceOfFund = $purchase->validationErrors->first('sourceOfFund'); $error_amount = $purchase->validationErrors->first('amount'); $error_office = $purchase->validationErrors->first('office'); $error_requisitioner = $purchase->validationErrors->first('requisitioner'); $error_dateRequested = $purchase->validationErrors->first('dateRequested'); $error_dateReceived = $purchase->validationErrors->first('dateReceived'); // Inserting Error Message To a Session Session::put('error_projectPurpose', $error_projectPurpose); Session::put('error_sourceOfFund', $error_sourceOfFund); Session::put('error_amount', $error_amount); Session::put('error_office', $error_office); Session::put('error_requisitioner', $error_requisitioner); Session::put('error_dateRequested', $error_dateRequested); Session::put('error_dateReceived', $error_dateReceived); Session::put('error_projectType', $error_projectType); if (Input::get('hide_modeOfProcurement') == "") { Session::put('error_modeOfProcurement', 'required'); } if (Session::get('imgerror') && Input::hasfile('file')) { $failedpurchasecount = Purchase::where('id', $purchase->id)->count(); if ($failedpurchasecount != 0) { $failedpurchase = Purchase::find($purchase->id); $failedpurchase->delete(); } Session::forget('imgsuccess'); //Image Error Return $task_details = TaskDetails::where('doc_id', $document->id)->delete(); $document->delete(); $message = "Failed to create purchase request."; // Set Main Error $message = "Failed to save purchase request."; Session::put('main_error', $message); // Get Other Error Messages $error_projectPurpose = $purchase->validationErrors->first('projectPurpose'); $error_projectType = $purchase->validationErrors->first('projectType'); $error_sourceOfFund = $purchase->validationErrors->first('sourceOfFund'); $error_amount = $purchase->validationErrors->first('amount'); $error_office = $purchase->validationErrors->first('office'); $error_requisitioner = $purchase->validationErrors->first('requisitioner'); $error_dateRequested = $purchase->validationErrors->first('dateRequested'); $error_dateReceived = $purchase->validationErrors->first('dateReceived'); // Inserting Error Message To a Session Session::put('error_projectPurpose', $error_projectPurpose); Session::put('error_sourceOfFund', $error_sourceOfFund); Session::put('error_amount', $error_amount); Session::put('error_office', $error_office); Session::put('error_requisitioner', $error_requisitioner); Session::put('error_dateRequested', $error_dateRequested); Session::put('error_dateReceived', $error_dateReceived); Session::put('error_projectType', $error_projectType); } return Redirect::back()->withInput(); } $numLoop++; } }
$user_level = $_SESSION[user_level]; $stc_itm_id = $_GET['stc_itm_id']; $finishItemByID = $objStockGroupInfo->retriveFinishItemByid($stc_itm_id); $stock_item_id = $finishItemByID[0]['stock_item_id']; $StockGroupId = $finishItemByID[0]['stock_item_grp_id']; $StockUnitId = $finishItemByID[0]['stock_item_unit_id']; $StockAltUnitId = $finishItemByID[0]['stock_alt_unit']; $count = $finishItemByID[0]['count']; $lot = $finishItemByID[0]['lot']; //// Retrive Stock Group Name $StockGrpInfo = $objStockGroupInfo->retriveStockGroupUnderInfo(); $StockGrpInfo_options = options_for_select($StockGrpInfo, 'stock_group_id', 'stock_group_name', true, $StockGroupId); //// Retrive Stock Unit Name $unitName = options_for_select($stock->retriveStockUnit(), 'stock_item_unit_id', 'stock_item_unit_name', true, $StockUnitId); //Retrive Count $Count = new Count(); $countName = options_for_select($Count->retriveCountInfo(), 'count_id', 'count_name', true, $count); //Retrive Lot $Lot = new Lot(); $outputLot = options_for_select($Lot->retriveLotInfo(), 'lot_id', 'lot_name', true, $lot); ///////////////////////////////// $allStockItemUnit = $objStockGroupInfo->retriveStockUnit(); $rowStockItemUnit = count($allStockItemUnit); ?> <div id="test"> <form id="CreateStockItem" name="CreateStockItem" method="post" action="includes/model/finish_item_update_actions.php"><table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr>
<?php require_once "../../../lib/count.class.php"; $objCountListAll = new Count(); if (isset($_POST['delete'])) { echo $id = (int) $_POST['id']; if ($objCountListAll->deleteCount($id) > 0) { echo "U have Deleted Succesfully"; } else { echo "sorry record does not exists"; } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Goods the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Goods::model()->findByPk($id); $count = Count::model()->find('goods_id=:goods_id', array(':goods_id' => $id)); $model->count = $count->count; $model->size = $count->size; $model->color = $count->color; if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<!-- images section --> <div id="img-section" class="no-print"> <?php $docs = Document::where('pr_id', $purchase->id)->first(); $attachmentc = DB::table('attachments')->where('doc_id', $docs->id)->count(); if ($attachmentc != 0) { echo "<h3>" . "Attachments" . "</h3>"; } $luser = Auth::user()->id; $count = Count::where('doc_id', '=', $docs->id)->where('user_id', '=', $luser)->delete(); $attachments = DB::table('attachments')->where('doc_id', $docs->id)->get(); $srclink = "uploads\\"; ?> @foreach ($attachments as $attachment) <div class="image-container"> <a href="{{asset('uploads/'.$attachment->data)}}" data-lightbox="{{$attachment->data}}" title="{{$attachment->data}}"> <img class="img-thumbnail" src="{{asset('uploads/'.$attachment->data)}}" style="width: 100px; height: 100px;" /> </a> </div> @endforeach </div>
<?php /** * 统计下关键词不正常的数量 */ $count = new Count(); $count->run(); class Count { public function run() { $count = 0; $kid = 0; while (1) { $this->reConnect($kid); echo $kid . ",此刻不正常产品关键词数量为" . $count . "\n"; $mysqlRs = $this->online->findAll("select kid, is_edit from catsearch.cs_prokeywords where kid > '" . $kid . "' order by kid asc limit 100"); if (empty($mysqlRs)) { break; } foreach ($mysqlRs as $mysql) { $kid = $mysql['kid']; if ($mysql['is_edit'] >= 0) { continue; } $count++; } } } public function reConnect($k) {