예제 #1
0
function make_job($ticket, $values)
{
    $CI =& get_instance();
    $product = $ticket['product'];
    $to = $values['to'];
    if ($product['cate'] == 1 && (!is_numeric($to) || strlen($to) != 11)) {
        return 'INVALID_NUMBER';
    }
    if ($product['cate'] == 2 && (!is_numeric($to) || strlen($to) < 5)) {
        return 'INVALID_NUMBER';
    }
    if ($product['cate'] == 3 && !$to) {
        return 'INVALID_NUMBER';
    }
    return create_job($ticket, $values);
}
예제 #2
0
<?php

include dirname(__FILE__) . '/../../bootstrap/Propel.php';
$t = new lime_test(3);
$t->comment('->getCompanySlug()');
$job = JobeetJobPeer::doSelectOne(new Criteria());
$t->is($job->getCompanySlug(), Jobeet::slugify($job->getCompany()), '->getCompanySlug() return the slug for the company');
$t->comment('->save()');
$job = create_job();
$job->save();
$expiresAt = date('Y-m-d', time() + 86400 * sfConfig::get('app_active_days'));
$t->is($job->getExpiresAt('Y-m-d'), $expiresAt, '->save() updates expires_at if not set');
$job = create_job(array('expires_at' => '2008-08-08'));
$job->save();
$t->is($job->getExpiresAt('Y-m-d'), '2008-08-08', '->save() does not update expires_at if set');
function create_job($defaults = array())
{
    static $category = null;
    if (is_null($category)) {
        $category = JobeetCategoryPeer::doSelectOne(new Criteria());
    }
    $job = new JobeetJob();
    $job->fromArray(array_merge(array('category_id' => $category->getId(), 'company' => 'Sensio Labs', 'position' => 'Senior Tester', 'location' => 'Paris, France', 'description' => 'Testing is fun', 'how_to_apply' => 'Send e-Mail', 'email' => '*****@*****.**', 'token' => rand(1111, 9999), 'is_activated' => true), $defaults), BasePeer::TYPE_FIELDNAME);
    return $job;
}
예제 #3
0
            } elseif ($j == 1) {
                //Name
                $recipient->name = $sheets[0]['cells'][$i][$j];
            } elseif ($j == 2) {
                //Message
                $obj->message = $sheets[0]['cells'][$i][$j];
            } elseif ($j == 3) {
                if ($sheets[0]['cells'][$i][$j] == "Y") {
                    $obj->frequency = "I";
                } else {
                    $obj->frequency = "O";
                }
                //Other Time
            } elseif ($j == 4) {
                $obj->start_date = date("Y-m-d", ($sheets[0]['cells'][$i][4] - 25569) * 86400);
                //die ( "".date( "Y-m-d H:i:s" , $obj->start_date ) );
            } elseif ($j == 5) {
                $obj->start_date = $obj->start_date . " " . $sheets[0]['cells'][$i][$j] . ":00";
            }
        }
    }
    $obj->job_name = "Schedule through file upload";
    $obj->recipients = array($recipient);
    $obj->param_days = array();
    $obj->param_months = array();
    $obj->param_dates = array();
    $obj->recur = 1;
    $job = create_job($obj);
    array_push($jobs, $job);
}
echo json_encode(array("jobs" => $jobs));
예제 #4
0
$t->comment('->save()');
$job = create_job();
$job->save();
$expiresAt = date('Y-m-d', time() + 86400 * sfConfig::get('app_active_days'));
$t->is($job->getDateTimeObject('expires_at')->format('Y-m-d'), $expiresAt, '->save() updates expires_at if not set');
$job = create_job(array('expires_at' => '2008-08-08'));
$job->save();
$t->is($job->getDateTimeObject('expires_at')->format('Y-m-d'), '2008-08-08', '->save() does not update expires_at if set');
function create_job($defaults = array())
{
    static $category = null;
    if (is_null($category)) {
        $category = Doctrine_Core::getTable('JobeetCategory')->createQuery()->limit(1)->fetchOne();
    }
    $job = new JobeetJob();
    $job->fromArray(array_merge(array('category_id' => $category->getId(), 'company' => 'Sensio Labs', 'position' => 'Senior Tester', 'location' => 'Paris, France', 'description' => 'Testing is fun', 'how_to_apply' => 'Send e-Mail', 'email' => '*****@*****.**', 'token' => rand(1111, 9999), 'is_activated' => true), $defaults));
    return $job;
}
$t->comment('->getForLuceneQuery()');
$job = create_job(array('position' => 'foobar', 'is_activated' => false));
$job->save();
$jobs = Doctrine_Core::getTable('JobeetJob')->getForLuceneQuery('position:foobar');
$t->is(count($jobs), 0, '::getForLuceneQuery() does not return non activated jobs');
$job = create_job(array('position' => 'foobar', 'is_activated' => true));
$job->save();
$jobs = Doctrine_Core::getTable('JobeetJob')->getForLuceneQuery('position:foobar');
$t->is(count($jobs), 1, '::getForLuceneQuery() returns jobs matching the criteria');
$t->is($jobs[0]->getId(), $job->getId(), '::getForLuceneQuery() returns jobs matching the criteria');
$job->delete();
$jobs = Doctrine_Core::getTable('JobeetJob')->getForLuceneQuery('position:foobar');
$t->is(count($jobs), 0, '::getForLuceneQuery() does not return deleted jobs');
예제 #5
0
	{
		days : [1,2,3,4,5,6,7] , //Sunday = 1 , Monday = 2 , Tuesday = 3 , etc....
		months : [1,2,3.....12] , //January = 1 , February = 2, March = 3..... December = 12
		dates : [1,2,3,4......31] //Dates of that month	
	}
	*/
/* Definitions */
$days = array("", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
$months = array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$data = json_decode("{}");
if (isset($_POST['data'])) {
    $data = json_decode($_POST['data']);
}
//Decode JSON data
if (isset($data->job_name)) {
    echo json_encode(create_job($data));
}
//Send data json if set
function create_job($obj)
{
    global $data;
    $data = $obj;
    $job_name = $data->job_name;
    $frequency = $data->frequency;
    $message = $data->message;
    $recipients = $data->recipients;
    $params = json_decode("{}");
    $params->days = $data->param_days;
    $params->dates = $data->param_dates;
    $params->months = $data->param_months;
    //$params = $data->parameters;