Пример #1
0
 /**
  * @param $name
  */
 public static function create($userId, $totalAmount)
 {
     $order = ORM::for_table(self::$table)->create();
     $order->user_id = $userId;
     $order->status = self::ORDER_STATUS_IN_PROGRESS;
     $order->date = DateHelper::getCurrentDateTime();
     $order->total = $totalAmount;
     $order->save();
     return $order;
 }
Пример #2
0
 /**
  * @param $userId
  * @param $totalAmount
  * @return $this
  */
 public static function create($orderId, $gatewayId, $paymentMethod)
 {
     $payment = ORM::for_table(self::$table)->create();
     $payment->type = $paymentMethod;
     $payment->date = DateHelper::getCurrentDateTime();
     $payment->status = self::PAYMENT_STATUS_PENDING;
     $payment->gateway_id = $gatewayId;
     $payment->order_id = $orderId;
     $payment->save();
     return $payment;
 }
Пример #3
0
 public function testIsPastDate()
 {
     $this->assertTrue(DateHelper::isPastDate('1990-01-18 00:00:00'));
     //past date
     $this->assertTrue(DateHelper::isPastDate('2012-06-18 00:00:00'));
     //past date
     $this->assertTrue(DateHelper::isPastDate('2012-06-18 25:15:00'));
     //past date
     $this->assertTrue(!DateHelper::isPastDate(date('Y-m-d H:i:s', time())));
     //same date
     $this->assertTrue(!DateHelper::isPastDate('2080-06-18 00:00:00'));
     //future date
 }
Пример #4
0
    while ($denied = mysql_fetch_object($deniedOffers)) {
        $notificationData = new stdClass();
        $notificationData->project_id = $rs_proj->pro_id;
        $not_user = Notification::create($denied->user_id, 'Tu oferta para el proyecto ' . $rs_pro->pro_tit . ' no fue seleccionada', Notification::TYPE_DENIED_OFFER, json_encode($notificationData));
    }
    // Enviar correo a fotografo
    $asunto = "Te han adjudicado un proyecto. ¡Felicidades!";
    $params = array('site_url' => FConfig::getUrl(), 'logo_url' => FConfig::getUrl('images/logo_footer.png'), 'check_url' => FConfig::getUrl('images/check_green.gif'), 'oferta_name' => $rs_oferta->name, 'oferta_lastname' => $rs_oferta->lastname, 'oferta_winner' => '$ ' . number_format($rs_oferta->bid, 2, ",", "."), 'proyecto_titulo' => $rs_proj->pro_tit, 'projecto_date' => DateHelper::getShortDate($rs_proj->pro_date), 'proyecto_url' => FConfig::getUrl('proyecto') . '?id=' . $id_pr, 'client_name' => $clientUser['name'] . ' ' . $clientUser['lastname'], 'client_email' => $clientUser['email'], 'client_phone' => $clientUser['movil'], 'client_location' => $clientUser['ciudad'] . ', ' . $clientUser['direccion']);
    $body = FMailer::replaceParameters($params, file_get_contents('../views/emails/adjudicarProyectosFotografoEmail.html'));
    $mailer = new FMailer();
    $receivers = array(array('email' => $rs_oferta->user));
    $mailer->setReceivers($receivers);
    $mailer->sendEmail($asunto, $body);
    // Enviar correo a cliente
    $asunto = "Has adjudicado un proyecto. ¡Buen Trabajo!";
    $params = array('site_url' => FConfig::getUrl(), 'logo_url' => FConfig::getUrl('images/logo_footer.png'), 'check_url' => FConfig::getUrl('images/check_green.gif'), 'client_name' => $clientUser['name'] . ' ' . $clientUser['lastname'], 'oferta_winner' => $rs_oferta->bid, 'proyecto_titulo' => $rs_proj->pro_tit, 'projecto_date' => DateHelper::getShortDate($rs_proj->pro_date), 'proyecto_url' => FConfig::getUrl('proyecto') . '?id=' . $id_pr, 'photograph_name' => $photographUser['name'] . ' ' . $photographUser['lastname'], 'photograph_email' => $photographUser['email'], 'photograph_phone' => $photographUser['movil'], 'photograph_location' => $photographUser['ciudad'] . ', ' . $photographUser['direccion']);
    $body = FMailer::replaceParameters($params, file_get_contents('../views/emails/adjudicarProyectosClienteEmail.html'));
    $mailer = new FMailer();
    $receivers = array(array('email' => $clientUser['email']));
    $mailer->setReceivers($receivers);
    $mailer->sendEmail($asunto, $body);
    // Event = Proyectos adjudicados
    $eventData = new stdClass();
    $eventData->user_id = $user_pro;
    $eventData->photograph_id = $photographUser['id'];
    $eventData->project_name = $rs_proj->pro_tit;
    $events = FAnalytics::getInstance();
    $events->trackEvent('Proyecto', 'Proyectos adjudicados', json_encode($eventData));
    $arreglo[] = array('resp' => "Se ha enviado la información");
    echo json_encode($arreglo);
}
Пример #5
0
 /**
  * Check if project can be qualified by the user given
  *
  * @param $project
  * @param $user
  * @return bool
  */
 public static function canBeQualified($project, $user)
 {
     //TODO chequear owner aqui?? o en otro lado??
     //Checkdates
     if (!DateHelper::isPastDate($project->pro_date)) {
         return false;
     }
     //TODO las calificaciones no deberian depender del estatus, se esta complicando esto, revisar
     //Check status
     if ($user->user_type == User::USER_TYPE_CLIENT) {
         if ($project->pro_status == self::PROJECT_STATUS_ADJUDICATED || $project->pro_status == self::PROJECT_STATUS_CLOSED_PHOTOGRAPHER) {
             return true;
         }
     }
     if ($user->user_type == User::USER_TYPE_PHOTOGRAPHER) {
         if ($project->pro_status == self::PROJECT_STATUS_ADJUDICATED || $project->pro_status == self::PROJECT_STATUS_CLOSED_CLIENT) {
             return true;
         }
     }
     return false;
 }
Пример #6
0
                </div>
                <div class="col-xs-2 text-center">
                    <?php 
    echo DateHelper::getShortDate($rs_proN->pro_date);
    ?>
                    <br/>
                    <?php 
    echo $rs_proN->pro_city;
    ?>
, <?php 
    echo utf8_encode($rs_proN->pro_country_name);
    ?>
                </div>
                <div class="col-xs-1 text-center">
                    <?php 
    echo DateHelper::getHoursLeft($rs_proN->pro_date_end);
    ?>
                </div>
                <div class="col-xs-1">

                    <?php 
    if (!isset($offers[$rs_proN->pro_id])) {
        ?>
                        <a class="btn btn-primary" href="<?php 
        echo UrlHelper::getProjectUrl($rs_proN->pro_id);
        ?>
">Oferta ya</a>
                    <?php 
    } else {
        ?>
                        <!-- TODO kill font18, fontW400, txtNaranja -->
Пример #7
0
 /**
  * @param $id
  * @return object
  */
 public static function loadProjectById($id)
 {
     $project = ORM::for_table(self::$table)->select('*')->where('pro_id', $id)->find_one();
     $project->days_left = DateHelper::getHoursLeft($project->pro_date_end);
     return $project;
 }
Пример #8
0
function getUserInfo($id)
{
    $usr_info = mysql_fetch_object(listAll("user", "WHERE id = '{$id}'"));
    $descripcion = getUserData($id, "2");
    $user_img = getUserData($id, "1");
    $direccion = getUserData($id, "3");
    $ciudad = getUserData($id, "10");
    $cp = getUserData($id, "4");
    $pais = getUserData($id, "5");
    $telefono = getUserData($id, "6");
    $movil = getUserData($id, "7");
    $exp = getUserData($id, "14");
    $cam = getUserData($id, "11");
    $lentes = getUserData($id, "12");
    $equip = getUserData($id, "13");
    $cover = getUserData($id, "16");
    $user_pago = getUserData($id, "17");
    $escuelaFotografia = getUserData($id, "18");
    $masEducacion = getUserData($id, "19");
    $experienciaLaboral = getRecentUserData($id, "20");
    $idiomas = getUserData($id, "22");
    $habilidades = getUserData($id, "21");
    $rut = getUserData($id, "23");
    if ($usr_info->gender == "H") {
        $gender = "Hombre";
    } else {
        $gender = "Mujer";
    }
    $paisf = listAll("paises", "WHERE iso = '{$pais->description}'");
    $rs_paisf = mysql_fetch_object($paisf);
    $user['id'] = $usr_info->id;
    $user['user_type'] = $usr_info->user_type;
    $user['email'] = $usr_info->user;
    $user['new_email'] = $usr_info->new_email;
    $user['new_email_code'] = $usr_info->new_email_code;
    $user['descripcion'] = $descripcion->description;
    $user['user_img'] = $user_img->description;
    $user["name"] = $usr_info->name;
    $user['lastname'] = $usr_info->lastname;
    $user['dob'] = DateHelper::getLongDate($usr_info->dob);
    $user['user_dob'] = DateHelper::getShortDate($usr_info->dob, 'd/m/Y');
    $user['sex'] = $gender;
    $user['act'] = $usr_info->act;
    $dob = explode("-", $usr_info->dob);
    $user['ano'] = $dob[0];
    $user['mes'] = $dob[1];
    $user['dia'] = $dob[2];
    $user['direccion'] = $direccion->description;
    $user['ciudad'] = $ciudad->description;
    $user['cp'] = $cp->description;
    $user['pais'] = utf8_encode($rs_paisf->nombre);
    $user['pais_ab'] = utf8_encode($rs_paisf->iso);
    $user['telefono'] = $telefono->description;
    $user['movil'] = $movil->description;
    $user['exp'] = $exp->description;
    $user['escuela-fotografia'] = $escuelaFotografia->description;
    $user['mas-educacion'] = $masEducacion->description;
    $user['experiencia-laboral'] = json_decode($experienciaLaboral->description);
    $user['idiomas'] = json_decode($idiomas->description);
    $user['habilidades'] = json_decode($habilidades->description);
    $user['rut'] = $rut->description;
    $user['cam'] = json_decode($cam->description);
    $user['lentes'] = json_decode($lentes->description);
    $user['equip'] = json_decode($equip->description);
    $user["act_code"] = $usr_info->act_code;
    $user["profile_completed"] = $usr_info->profile_completed;
    $user["wizard_completed"] = $usr_info->wizard_completed;
    $user["wizard_contact_creative_completed"] = $usr_info->wizard_contact_creative_completed;
    $user['user_cover'] = $cover->description;
    $user['user_pago'] = $user_pago->description;
    $user['full_name'] = ucwords($user["name"] . " " . $user['lastname']);
    //TODO make it an external function
    //TODO set a default image if file does not exists
    if (file_exists(FConfig::getBasePath() . "/profiles/" . sha1($usr_info->id) . "/profile.jpg")) {
        $user['profile_image_url'] = "profiles/" . sha1($usr_info->id) . "/profile.jpg";
    } else {
        if ($user['user_type'] == User::USER_TYPE_PHOTOGRAPHER) {
            $user['profile_image_url'] = "images/profile_default_photographer.jpg";
        } else {
            $user['profile_image_url'] = "images/profile_default_client.jpg";
        }
    }
    if (file_exists(FConfig::getBasePath() . "/profiles/" . sha1($usr_info->id) . "/cover.jpg")) {
        $user['cover_image_url'] = "profiles/" . sha1($usr_info->id) . "/cover.jpg";
    } else {
        $user['cover_image_url'] = "images/cover_default.jpg";
    }
    return $user;
}
Пример #9
0
        } else {
            echo $estadoPro;
        }
        ?>
</div>
			 </div>
			 <div class="left listProyectosCenter">
			 <span class="txtAzul font18 titProyecto"><a class="txtAzul" href="proyecto?id=<?php 
        echo $rs_proj->pro_id;
        ?>
"><?php 
        echo ucfirst($rs_proj->pro_tit);
        ?>
</a></span><br><span class=" font12"><?php 
        if ($rs_proj->pro_status != "A") {
            echo DateHelper::getLongDate($rs_proj->pro_date);
        }
        ?>
</span>
			 <p align="justify"><?php 
        echo substr($rs_proj->pro_descripcion, "0", "350");
        if (strlen($rs_proj->pro_descripcion) > 350) {
            ?>
... <a class="see-more" href="proyecto?id=<?php 
            echo $rs_proj->pro_id;
            ?>
">Ver más >></a><?php 
        }
        ?>
</p></div>
			 
Пример #10
0
 public static function emailProjectOwner($offer, $winner, $project, $projectOwner)
 {
     // Enviar correo a cliente
     $asunto = "Has adjudicado un proyecto. ¡Buen Trabajo!";
     $params = array('site_url' => UrlHelper::getUrl(), 'logo_url' => UrlHelper::getUrl('images/logo_footer.png'), 'check_url' => UrlHelper::getUrl('images/check_green.gif'), 'client_name' => $projectOwner['full_name'], 'oferta_winner' => $offer->bid, 'proyecto_titulo' => $project->pro_tit, 'projecto_date' => DateHelper::getShortDate($project->pro_date), 'proyecto_url' => UrlHelper::getProjectUrl($project->pro_id), 'photograph_name' => $winner['full_name'], 'photograph_email' => $winner['email'], 'photograph_phone' => $winner['movil'], 'photograph_location' => $winner['ciudad'] . ', ' . $winner['direccion']);
     $mailer = new FMailer();
     $body = $mailer->replaceParameters($params, file_get_contents(UrlHelper::getBasePath() . '/views/emails/adjudicarProyectosClienteEmail.html'));
     $receivers = array(array('email' => $projectOwner['email']));
     $mailer->setReceivers($receivers);
     $mailer->setBCC(array(array('email' => FConfig::getValue('contacto_email'))));
     $mailer->sendEmail($asunto, $body);
 }
Пример #11
0
 public static function getUserInfo($id, $fields = array())
 {
     $usr_info = ORM::for_table(self::$table)->find_one($id);
     if ($usr_info == null) {
         return false;
     }
     $user = array();
     //User table fields
     $user['id'] = $usr_info->id;
     $user['user_type'] = $usr_info->user_type;
     $user['email'] = $usr_info->user;
     $user['new_email'] = $usr_info->new_email;
     $user['new_email_code'] = $usr_info->new_email_code;
     $user["name"] = $usr_info->name;
     $user['lastname'] = $usr_info->lastname;
     $user['user_dob'] = DateHelper::getShortDate($usr_info->dob, 'd/m/Y');
     $user['act'] = $usr_info->act;
     $user["act_code"] = $usr_info->act_code;
     $user["profile_completed"] = $usr_info->profile_completed;
     $user["wizard_completed"] = $usr_info->wizard_completed;
     $user["wizard_contact_creative_completed"] = $usr_info->wizard_contact_creative_completed;
     $user['full_name'] = ucwords($user["name"] . " " . $user['lastname']);
     //Gender
     if ($usr_info->gender == "H") {
         $gender = "Hombre";
     } else {
         $gender = "Mujer";
     }
     $user['sex'] = $gender;
     //        $user['dob']= DateHelper::getLongDate($usr_info->dob);
     //Process only desired fields
     if (in_array('*', $fields) || in_array('descripcion', $fields)) {
         $descripcion = self::getUserData($id, "2");
         $user['descripcion'] = $descripcion->description;
     }
     if (in_array('*', $fields) || in_array('user_img', $fields)) {
         $user_img = self::getUserData($id, "1");
         $user['user_img'] = $user_img->description;
     }
     if (in_array('*', $fields) || in_array('direccion', $fields)) {
         $direccion = self::getUserData($id, "3");
         $user['direccion'] = $direccion->description;
     }
     if (in_array('*', $fields) || in_array('ciudad', $fields)) {
         $ciudad = self::getUserData($id, "10");
         $user['ciudad'] = $ciudad->description;
     }
     if (in_array('*', $fields) || in_array('cp', $fields)) {
         $cp = self::getUserData($id, "4");
         $user['cp'] = $cp->description;
     }
     if (in_array('*', $fields) || in_array('pais', $fields)) {
         $pais = self::getUserData($id, "5");
         $rs_paisf = Country::loadCountriesByIso($pais->description);
         $user['pais'] = utf8_encode($rs_paisf->nombre);
         $user['pais_ab'] = utf8_encode($rs_paisf->iso);
     }
     if (in_array('*', $fields) || in_array('telefono', $fields)) {
         $telefono = self::getUserData($id, "6");
         $user['telefono'] = $telefono->description;
     }
     if (in_array('*', $fields) || in_array('movil', $fields)) {
         $movil = self::getUserData($id, "7");
         $user['movil'] = $movil->description;
     }
     //Todocheck  if in use
     //        if (in_array('*', $fields) || in_array('exp', $fields)) {
     //            $exp = self::getUserData($id, "14");
     //            $user['exp'] = $exp->description;
     //        }
     if (in_array('*', $fields) || in_array('cam', $fields)) {
         $cam = self::getUserData($id, "11");
         $user['cam'] = json_decode($cam->description);
     }
     if (in_array('*', $fields) || in_array('rut', $fields)) {
         $rut = self::getUserData($id, "23");
         $user['rut'] = $rut->description;
     }
     if (in_array('*', $fields) || in_array('lentes', $fields)) {
         $lentes = self::getUserData($id, "12");
         $user['lentes'] = json_decode($lentes->description);
     }
     if (in_array('*', $fields) || in_array('', $fields)) {
         $equip = self::getUserData($id, "13");
         $user['equip'] = json_decode($equip->description);
     }
     //Deprecated
     //        if (in_array('*', $fields) || in_array('user_cover', $fields)) {
     //            $cover = self::getUserData($id, "16");
     //            $user['user_cover'] = $cover->description;
     //        }
     //TODO Used for paypal account, check if needed
     if (in_array('*', $fields) || in_array('user_pago', $fields)) {
         $user_pago = self::getUserData($id, "17");
         $user['user_pago'] = $user_pago->description;
     }
     if (in_array('*', $fields) || in_array('escuela-fotografia', $fields)) {
         $escuelaFotografia = self::getUserData($id, "18");
         $user['escuela-fotografia'] = $escuelaFotografia->description;
     }
     if (in_array('*', $fields) || in_array('mas-educacion', $fields)) {
         $masEducacion = self::getUserData($id, "19");
         $user['mas-educacion'] = $masEducacion->description;
     }
     if (in_array('*', $fields) || in_array('experiencia-laboral', $fields)) {
         $experienciaLaboral = self::getRecentUserData($id, "20");
         $user['experiencia-laboral'] = json_decode($experienciaLaboral->description);
     }
     if (in_array('*', $fields) || in_array('idiomas', $fields)) {
         $idiomas = self::getUserData($id, "22");
         $user['idiomas'] = json_decode($idiomas->description);
     }
     if (in_array('*', $fields) || in_array('habilidades', $fields)) {
         $habilidades = self::getUserData($id, "21");
         $user['habilidades'] = json_decode($habilidades->description);
     }
     //Cover and profile image fields
     if (file_exists(FConfig::getBasePath() . "/profiles/" . sha1($usr_info->id) . "/profile.jpg")) {
         $user['profile_image_url'] = "profiles/" . sha1($usr_info->id) . "/profile.jpg";
     } else {
         if ($user['user_type'] == User::USER_TYPE_PHOTOGRAPHER) {
             $user['profile_image_url'] = "images/profile_default_photographer.jpg";
         } else {
             $user['profile_image_url'] = "images/profile_default_client.jpg";
         }
     }
     if (file_exists(FConfig::getBasePath() . "/profiles/" . sha1($usr_info->id) . "/cover.jpg")) {
         $user['cover_image_url'] = "profiles/" . sha1($usr_info->id) . "/cover.jpg";
     } else {
         $user['cover_image_url'] = "images/cover_default.jpg";
     }
     return $user;
 }
Пример #12
0
 /**
  * Used to create a new credit.
  * @return bool|int
  */
 public static function newCredit($userId, $reasignedCreditId = null)
 {
     if ($userId == null) {
         return false;
     }
     $credit = ORM::for_table(self::CREDIT_TABLE)->create();
     $credit->user_id = $userId;
     $credit->date = DateHelper::getCurrentDateTime();
     $credit->reasigned_credit_id = $reasignedCreditId;
     $credit->save();
     if ($credit->id) {
         return $credit->id;
     } else {
         return false;
     }
 }
Пример #13
0
use Fototea\Models\Order;
use Fototea\Models\OrderProduct;
use Fototea\Models\Payment;
use Fototea\Models\PaymentManager;
use Fototea\Models\Product;
use Fototea\Models\Project;
use Fototea\Models\PuntoPagos;
use Fototea\Models\AdjudicationManager;
//var_dump($app->getRequest()->server());
//var_dump($app->getRequest()->headers('cache-control'));
//TODO Importante blindar este método!!!!! varias fugas
//die();
// INIT - ONLY FOR TEST PURPOSES
$file = 'puntopago.txt';
$content = "-----------------------------------------------------------------------------------------\n";
$content .= DateHelper::getCurrentDateTime();
$content .= "-----------------------------------------------------------------------------------------\n";
$content .= "\nGET\n";
$content .= json_encode($_GET);
$content .= "\n\nPOST\n";
$content .= json_encode($_POST);
$content .= "\n\n";
//file_put_contents($file, $content, FILE_APPEND);
// END - ONLY FOR TEST PURPOSES
$token = $app->getRequest()->get('token');
$processResult = 00;
if (empty($token)) {
    $processResult = 99;
} else {
    //TODO falta validar la firma....
    $paymentMethod = new PaymentManager($app, PuntoPagos::PAYMENT_METHOD_TYPE);
Пример #14
0
        ?>
" id="cid_<?php 
        echo $rs_comment->id;
        ?>
">
                                         <div class="comentarioUser left font12"><a class="txtAzul font14" href="perfil?us=<?php 
        echo $userComment['act_code'];
        ?>
"><?php 
        echo $userComment['name'] . " " . $userComment['lastname'];
        ?>
</a> <br> <a nohref title="<?php 
        echo DateHelper::getLongDate($rs_comment->cdate, true);
        ?>
"><i class="time-since"><?php 
        echo DateHelper::getTimeSince($rs_comment->cdate);
        ?>
</i></a></div>
                                         <div class="comentarioC left"><?php 
        echo $rs_comment->comment;
        ?>
</div>
                                     </div>
                                     <?php 
        $i++;
        if ($i > 1) {
            $i = 0;
        }
    }
    ?>
                             </div>
Пример #15
0
"><?php 
        echo ucfirst($rs_proj->pro_tit);
        ?>
</a></div>
			 <div class="left ofertasPro">		
			 
			 <?php 
        $ads = listAll("ofertas", "WHERE pro_id ='{$rs_proj->pro_id}'");
        $ad = mysql_num_rows($ads);
        ?>
			 
			 
			 </div>
			 <div class=" left font12 pubPro ">
			<?php 
        echo DateHelper::getLongDate($rs_proj->pro_cdate) . "<br>";
        echo '<span class="txtNaranja">' . $diasRest[2];
        ?>
 d&iacute;as para adjudicar</span></div>
			<div class="left desdePro alignCenter"><?php 
        if ($oferta_user == false) {
            ?>
<div class="btn_naranja"><a href="proyecto?id=<?php 
            echo $rs_proj->pro_id;
            ?>
">Oferta ya</a></div><?php 
        } else {
            ?>
<div class="alignCenter">Tu ofertaste por<br><span class="font18 fontW400 txtNaranja">$ <?php 
            echo $oferta_user['monto'];
            ?>