public function addNew($job, $data, $file)
 {
     if (!($contractor = \Contractor::getContractor())) {
         throw new \Exception("Current user is not a contractor.", 1);
         return;
     }
     if (!is_null($file) && $data['timesheet_type'] === 'file') {
         $uploader = new FileUploader();
         $location = 'uploads/contractors/' . $contractor->id . '/timesheet/' . date('m') . '/';
         try {
             $uploadedFile = $uploader->upload($file, $location, 'resume');
         } catch (\Exception $e) {
             throw new \Exception($e->getMessage(), 1);
             return;
         }
     }
     $model = $this->getModel();
     if ($data['timesheet_type'] === 'data') {
         $startDate = Carbon::createFromFormat('Y-m-d', $data['timesheet_date_from']);
         $endDate = Carbon::createFromFormat('Y-m-d', $data['timesheet_date_to']);
     }
     $model->fill(['contractor_id' => $contractor->id, 'job_id' => $job->id, 'auth_company' => false, 'auth_agency' => is_null($job->agency_id) ? true : false, 'name' => $data['timesheet_name'], 'type' => $data['timesheet_type'], 'file' => $data['timesheet_type'] === 'file' ? $uploadedFile : null, 'report' => $data['timesheet_type'] === 'data' ? $data['report_time'] : null, 'hours' => $data['timesheet_type'] === 'data' ? $data['num_hours'] : null, 'start_date' => isset($startDate) ? $startDate : null, 'end_date' => isset($endDate) ? $endDate : null]);
     if ($model->save()) {
         return $model;
     } else {
         throw new \Exception("Something wrong when saving data.", 1);
         return;
     }
 }
 public function addNew($job, $data, $file)
 {
     if (!($contractor = \Contractor::getContractor())) {
         throw new \Exception("Current user is not a contractor.", 1);
         return;
     }
     if (!is_null($file)) {
         $uploader = new FileUploader();
         $location = 'uploads/contractors/' . $contractor->id . '/expense/' . date('m') . '/';
         try {
             $uploadedFile = $uploader->upload($file, $location, 'expense');
         } catch (\Exception $e) {
             throw new \Exception($e->getMessage(), 1);
             return;
         }
     }
     $model = $this->getModel();
     $model->fill(['contractor_id' => $contractor->id, 'job_id' => $job->id, 'auth_company' => false, 'auth_agency' => is_null($job->agency_id) ? true : false, 'title' => $data['title'], 'amount' => $data['amount'], 'type' => $data['type'], 'file' => isset($uploadedFile) ? $uploadedFile : null, 'description' => $data['description'] !== '' ? $data['description'] : null]);
     if ($model->save()) {
         return $model;
     } else {
         throw new \Exception("Something wrong when saving data.", 1);
         return;
     }
 }
Пример #3
0
 public static function toBase($company_id = false)
 {
     if (isset($_POST['Contractor'])) {
         if (!$_POST['Contractor']['id']) {
             unset($_POST['Contractor']['id']);
         }
         if (!isset($_POST['Contractor']['company_id']) && $company_id) {
             $_POST['Contractor']['company_id'] = $company_id;
         }
         $arContractorCity = $_POST['Contractor']['city'];
         unset($_POST['Contractor']['city']);
         $contractor_id = SaveData::model('Contractor', $_POST['Contractor']);
         $logo_name = UploadFile::save('Contractor', $contractor_id, 'contractor-logo');
         $tContractor = Contractor::model()->findByPk($contractor_id);
         $tContractor->logo = $logo_name;
         $tContractor->update();
         /* сохраняем города */
         if ($arContractorCity) {
             foreach ($arContractorCity as $city_id) {
                 $arLink = array('city_id' => $city_id, 'contractor_id' => $contractor_id);
                 $link_id = SaveData::model('LinkCityContractor', $arLink);
             }
         }
         return $contractor_id;
     }
     return false;
 }
 public function doLogin()
 {
     $userName = trim($_POST["userName"]);
     $password = trim($_POST["password"]);
     if (empty($userName)) {
         echo "User name required";
         return;
     }
     if (empty($password)) {
         echo "Password required";
         return;
     }
     // get login
     FilemakerDB::setup("174.3.224.247", "CSISched", "webuser", "webpassword");
     try {
         $contractor = Contractor::getByEmail($userName);
     } catch (Exception $ex) {
     }
     ob_end_clean();
     // if login couldn't be found, break.
     if (empty($contractor) || $contractor->Email != $userName) {
         echo "Wrong Email and password combination.";
         return;
     }
     // if password is invalid, break
     if ($contractor->Password != $password) {
         echo "Wrong Email and password combination.";
         return;
     }
     self::login($contractor);
     echo "OK";
 }
Пример #5
0
 public static function fromContractor($id)
 {
     $contractor = Contractor::model()->findByPk($id);
     if ($contractor) {
         return self::$objects[$contractor->category_id];
     } else {
         return false;
     }
 }
Пример #6
0
 public function actionDelete($id)
 {
     $service = Service::model()->findAll('contractor_id=' . $id);
     if ($service) {
         foreach ($service as $serv) {
             WrapServTransport::Del($serv->id);
             ServCulture::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             $food = ServFood::model()->findAll('service_id=' . $serv->id);
             if ($food) {
                 foreach ($food as $mFood) {
                     LinkFoodServ::model()->deleteAllByAttributes(array('serv_food_id' => $mFood->id));
                 }
             }
             ServFood::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             ServIntensiv::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             ServOther::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             $personal = ServPersonal::model()->findAll('service_id=' . $serv->id);
             if ($personal) {
                 foreach ($personal as $mPers) {
                     LinkPersonalLanguage::model()->deleteAllByAttributes(array('serv_personal_id' => $mPers->id));
                 }
             }
             ServPersonal::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             ServPlatform::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             ServProgram::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             ServTicket::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             $live = ServLive::model()->findAll('service_id=' . $serv->id);
             if ($live) {
                 foreach ($live as $mLive) {
                     ServLiveRoom::model()->deleteAllByAttributes(array('serv_live_id' => $mLive->id));
                 }
             }
             ServLive::model()->deleteAllByAttributes(array('service_id' => $serv->id));
             Photo::model()->deleteAllByAttributes(array('service_id' => $serv->id));
         }
     }
     Service::model()->deleteAllByAttributes(array('contractor_id' => $id));
     Comment::model()->deleteAllByAttributes(array('contractor_id' => $id));
     LinkCityContractor::model()->deleteAllByAttributes(array('contractor_id' => $id));
     Contractor::model()->deleteByPk($id);
     echo "ok";
 }
 public function removeContractorFromJob($job, $contractor)
 {
     try {
         if (!$job->contractors->contains($contractor->id)) {
             throw new \Exception("This contractor has never applied to this job.", 1);
             return;
         }
         $job->contractors()->detach($contractor->id);
         $notificationData = ['contractor_id' => $contractor->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Removed from ' . $job->title, 'description' => 'You have been removed from ' . $job->title, 'url' => null];
         $notification = \Contractor::addNotification($contractor, $notificationData);
         if ($job->status === 'taken' && $job->contractors()->count() <= 0) {
             $job->status = 'open';
             $job->save();
         }
         return $job;
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage(), 1);
         return;
     }
 }
<?php

require_once dirname(__FILE__) . "/../../ProtectionApiClient.class.php";
require_once dirname(__FILE__) . "/../config.php";
$client = new ProtectionApiClient(INVIPAY_API_URL, INVIPAY_API_KEY, INVIPAY_SIGNATURE_KEY, INVIPAY_PARTNER_API_KEY, INVIPAY_PARTNER_SIGNATURE_KEY);
$request = array();
$contractor = new Contractor();
$contractor->setTaxPayerNumber('9671343097');
$contractor->setEmail('*****@*****.**');
$document = new FileData();
$document->setFromFile(dirname(__FILE__) . '/../test.pdf');
$data = new CommonTransactionData();
$data->setExId(1);
$data->setDocumentNumber('TRANSACTION/1');
$data->setIssueDate(date('Y-m-d', time()));
$data->setDueDate(date('Y-m-d', time() + 24 * 60 * 60 * 7));
$data->setPriceGross(102);
$data->setContractor($contractor);
$data->setDocument($document);
$request[] = $data;
// Logger::info("Calculating protection costs");
// $calculations = $client->calculateProtectionCost($request);
// Logger::info('Result: {0}', $calculations);
// ////////////////////////////////////////////////////////
Logger::info("Requesting transactions protection");
$result = $client->protect($request);
Logger::info('Result: {0}', $result);
// $max_retries = 10;
// while ($result->getItemsLeft() > 0 && --$max_retries > 0)
// {
// 	Logger::info('Checking if results are available. Checks left: {0}.', $max_retries);
Пример #9
0
 public function jsonSerialize()
 {
     $this->__load();
     return parent::jsonSerialize();
 }
Пример #10
0
		<?php 
echo $form->error($model, 'barcode');
?>
                <?php 
if ($model->isNewRecord) {
    echo CHtml::ajaxLink($text = 'Получить ШК', $url = '/new-inventory/index.php?r=device/barcode', $ajaxOptions = array('type' => 'POST', 'data' => 'request=1', 'success' => 'function(html){ jQuery("#Device_barcode").val(html); }'), $htmlOptions = array());
}
?>
	</div>
        
        <div class="row">
		<?php 
echo $form->labelEx($model, 'contractor_id');
?>
		<?php 
echo $form->dropDownList($model, 'contractor_id', Contractor::getList());
?>
            	<?php 
echo $form->error($model, 'contractor_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'parent_id');
?>
		<?php 
echo $form->textField($model, 'parent_id');
?>
		<?php 
echo $form->error($model, 'parent_id');
Пример #11
0
<?php 
$cont = Contractor::model()->findByPk($contractor);
?>

<div class="panel panel-default comment service">
  <div class="panel-heading">
  
 
  	<div class="row">
		<div class="col-md-36 ">
		
			<label class="subCatHeader">Комментарий</label>

<!--
			<div class="pull-right butBlockService">
				<a class="btn btn-default btn-lg windowControl copyService"><span class="glyphicon glyphicon-plus "></span></a>
				<a class="btn btn-default btn-lg windowControl"><span class="glyphicon glyphicon-remove"></span></a>
			</div>
-->		


		</div>
	</div>

  
  
  
  </div>
  <div class="panel-body" id="windowComment">
Пример #12
0
// 	print_separator();
// }
// // getAccountData by nip
// {
// 	$result = $client->getAccountData(null, '9114272913');
// 	Logger::info('Result is: {0}', $result);
// 	print_separator();
// }
// // getAccountApiKeys by nip
// {
// 	$result = $client->getAccountApiKeys('00000000-0000-0000-0000-0000000000b5');
// 	Logger::info('Result is: {0}', $result);
// 	print_separator();
// }
$createAccountOperationId = null;
$contractor = new Contractor();
$contractor->setName('Test contractor ' . uniqid());
$contractor->setTaxPayerNumber('5271711106');
$contractor->setEmail('*****@*****.**');
$contractor->setFax('12312123');
$contractor->setPhone('234234234');
$contractor->setWww('www.esr24.pl');
$employees = array();
$employee = new EmployeeData();
$employee->setFirstName('Jan');
$employee->setLastName('Kowalski');
$employee->setEmail('*****@*****.**');
$employee->setPhone('123123123');
$employees[] = $employee;
$data = new AccountData();
$data->setExId('exAccount' . uniqid());
 public function postMarkNotif()
 {
     if (!($contractor = \Contractor::getContractor())) {
         return \Response::json(['type' => 'danger', 'message' => 'Not a contractor account']);
     }
     $contractor->notifications()->where('has_read', 0)->update(['has_read' => 1]);
     return \Response::json(['type' => 'success', 'message' => 'All notifications has been marked as "read"']);
 }
 public function postRemoveExpense()
 {
     $_hash = new Hash();
     $_hash = $_hash->getHasher();
     try {
         $contractor = \Contractor::getContractor();
         $id = $_hash->decode(\Input::get('i'));
         \Contractor::removeExpense($contractor, $id);
         return \Response::json(['type' => 'success', 'message' => 'Expense data removed from this job.']);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
     }
 }
 public function postContractorBan()
 {
     if (!($id = \Input::get('i')) || !($ban = \Input::get('ban'))) {
         return \Response::json(['type' => 'danger', 'message' => 'Data incomplete']);
     }
     try {
         \Contractor::banContractor($id, $ban);
         return \Response::json(['type' => 'success', 'message' => $ban === 'true' ? 'Contractor banned.' : 'Contractor unbanned.']);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
     }
 }
Пример #16
0
 public static function getAllRecords()
 {
     $sources = array(Contractor::where('status', '!=', 'deleted')->get(), Review::where('status', '!=', 'deleted')->get(), Service_request::all(), Lead::where('status', '!=', 'deleted')->get(), User::where('status', '!=', 'deleted')->get());
     $sources_array = array();
     $names_arr = array();
     foreach ($sources as $source) {
         $source->last()->latest = 'Latest ' . get_class($source->last());
         foreach ($source as $record) {
             All::formatRecord($record);
         }
         // $source->first()->classname = get_class($source->first());
         array_push($sources_array, json_decode($source, TRUE));
         array_push($names_arr, get_class($source->first()));
     }
     $big_arr = array_merge($sources_array[0], $sources_array[1], $sources_array[2], $sources_array[3], $sources_array[4]);
     // return $names_arr;
     return $big_arr;
 }
Пример #17
0
$pdf->setFromFile(dirname(__FILE__) . '/../test.pdf');
$request->setDocument($pdf);
$result = $client->createOrder($request);
Logger::info('Result is: {0}', $result);
print_separator();
Logger::info('Creating new invoice');
$request = new InvoiceData();
$request->setDocumentNumber('Test/' . uniqid());
$request->setIssueDate(date('Y-m-d', time()));
$request->setDueDate(date('Y-m-d', time() + 7 * 24 * 60 * 60));
// Due date == issue date + 7 days
$request->setPriceGross(123);
$request->setCurrency('PLN');
$request->setNote('Test transaction from API');
$request->setNoRisk(true);
$contractor = new Contractor();
$contractor->setName('Test contractor ' . uniqid());
$contractor->setTaxPayerNumber('8429067910');
$contractor->setCompanyGovId('146665640');
$contractor->setEmail('*****@*****.**');
$contractor->setFax('12312123');
$contractor->setPhone('234234234');
$contractor->setWww('www.esr24.pl');
$contractorAccount = new BankAccount();
$contractorAccount->setBankName('Test bank');
$contractorAccount->setNumber('PL123123123123123123123');
$contractor->setAccount($contractorAccount);
$contractorAddress = new AddressData();
$contractorAddress->setStreet('Test street 1/2');
$contractorAddress->setCity('Testville');
$contractorAddress->setPostCode('00-111');
 public function updateExpense($id, $agency, $status)
 {
     if (!($expense = \Contractor::findExpenseById($id))) {
         throw new \Exception("Expense not found", 1);
         return;
     }
     $job = $expense->job;
     if ($agency->id !== $job->agency_id) {
         throw new \Exception("Expense does not belong to the agency.", 1);
         return;
     }
     if ($status) {
         $expense->auth_agency = true;
         $expense->save();
         if ($contractor = $expense->contractor) {
             $notificationData = ['contractor_id' => $contractor->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Your expense "' . $expense->title . '" for "' . $job->title . '" has been accepted.', 'description' => 'Accepted by ' . $agency->name, 'url' => '#'];
             \Contractor::addNotification($contractor, $notificationData);
         }
         if (!is_null($job->company_id)) {
             $_hash = new Hash();
             $_hash = $_hash->getHasher();
             if ($company = \Company::findCompanyById($job->company_id)) {
                 $notificationData = ['company_id' => $company->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Expense "' . $expense->title . '" for "' . $job->title . '" has been accepted.', 'description' => 'Accepted by ' . $agency->name, 'url' => route('company.job.detail') . '?i=' . $_hash->encode($job->id)];
                 \Company::addNotification($company, $notificationData);
             }
         }
     } else {
         $expense->auth_agency = true;
         $expense->save();
         if ($contractor = $expense->contractor) {
             $notificationData = ['contractor_id' => $contractor->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Your expense "' . $expense->title . '" for "' . $job->title . '" has been de-authorized.', 'description' => 'De-authorize by ' . $agency->name, 'url' => '#'];
             \Contractor::addNotification($contractor, $notificationData);
         }
         if (!is_null($job->company_id)) {
             if ($company = \Company::findCompanyById($job->company_id)) {
                 $_hash = new Hash();
                 $_hash = $_hash->getHasher();
                 $notificationData = ['company_id' => $company->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Expense "' . $expense->title . '" for "' . $job->title . '" has been de-authorized.', 'description' => 'De-authorize by ' . $agency->name, 'url' => route('agency.job.detail') . '?i=' . $_hash->encode($job->id)];
                 \Company::addNotification($company, $notificationData);
             }
         }
     }
     return $expense;
 }
<?php

if (\User::check()) {
    $user = \User::getUser();
    if ($user->hasAccess('contractor')) {
        $contractor = \Contractor::getContractor();
    } elseif ($user->hasAccess('company')) {
        $company = \Company::getCompany();
    } elseif ($user->hasAccess('agency')) {
        $agency = \Agency::getAgency();
    }
}
$resources = \Site::getAllResources();
?>
	
@extends('front.app')

@section('title')
Free Resources | Programme Chameleon
@stop

@section('content')
<div id="wrapper">
	@include('front.include.header')
	<div class="container">
		<div id="free-resources-container">
			<h2 class="page-header">Free Resources</h2>
			<div class="tab-resources">
				<ul class="nav nav-tabs" role="tablist">
					<li role="presentation" class="active">
						<a href="#res-project" aria-controls="res-initiation" role="tab" data-toggle="tab">Project Management</a>
									</li>
								@else
									<li>
										<p>This contractor has incomplete information</p>
									</li>
								@endif
							@endforeach
						@else
							<li>
								<span class="alert alert-danger">No contractors found, try a different search.</span>
							</li>
						@endif
					</ul>
				@else
					<?php 
$contractors = \Contractor::getAllContractors();
$contractors = $contractors->paginate(15);
?>
					<ul class="list-unstyled list-result">
						@if ($contractors->count() > 0)
							@foreach ($contractors as $contractor)
								@if ($cUser = $contractor->user)
									<li>
										<div class="media">
											<a href="#" class="media-left">
												@if (is_null($contractor->image))
													<img data-src="holder.js/100x100?random=yes&text=no-image">
												@else
													<img src="{{ asset($contractor->image) }}" width="100" />
												@endif
											</a>
 /**
  * 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 Contractor the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Contractor::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
$client = new ContractorsApiClient(INVIPAY_API_URL, INVIPAY_API_KEY, INVIPAY_SIGNATURE_KEY, INVIPAY_PARTNER_API_KEY, INVIPAY_PARTNER_SIGNATURE_KEY);
Logger::info('Calculating verification cost');
$list = array();
$contractor = new Contractor();
$contractor->setName('Test contractor ' . uniqid());
$contractor->setTaxPayerNumber('8429067910');
$contractor->setEmail('*****@*****.**');
$contractor->setFax('12312123');
$contractor->setPhone('234234234');
$contractor->setWww('www.esr24.pl');
$list[] = $contractor;
$result = $client->calculateVerificationCost($list);
Logger::info('Result is: {0}', $result);
print_separator();
$operationId = null;
Logger::info('Starting contractor verification');
$contractor = new Contractor();
$contractor->setName('Test contractor ' . uniqid());
$contractor->setTaxPayerNumber('5270103391');
$contractor->setEmail('*****@*****.**');
$contractor->setFax('12312123');
$contractor->setPhone('234234234');
$contractor->setWww('www.esr24.pl');
$result = $client->verifyContractor($contractor);
Logger::info('Result is: {0}', $result);
print_separator();
$operationId = $result->getOperationId();
Logger::info('Getting contractor verification result');
$result = $client->getVerificationResult($operationId);
Logger::info('Result is: {0}', $result);
print_separator();