<commit_before><?php

class SowGiltsController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column1';

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
			'postOnly + delete', // we only allow deletion via POST request
		);
	}

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('index','view','AutocompleteEarNotch','Checksolddate','Checkexist','AutocompleteSireNotch','getdaysbtw','autocompleteSow','autocompleteDateBred','autocompleteSire','autocompleteService',
						'autocompleteComments','autocompletePass','autocompleteDue','autocompleteDays','CheckFarrowed'),
				'users'=>array('*'),
			),
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
				'actions'=>array('create','update'),
				'users'=>array('@'),
			),
			array('allow', // allow admin user to perform 'admin' and 'delete' actions
				'actions'=>array('admin','delete'),
				'users'=>array('admin'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

	/**
	 * Displays a particular model.
	 * @param integer $id the ID of the model to be displayed
	 */
	public function actionView($id)
	{
		$this->render('view',array(
			'model'=>$this->loadModel($id),
		));
	}

	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new SowGilts;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['SowGilts']))
		{


			$model->attributes=$_POST['SowGilts'];
			$autoChoresModel = new AutoChores();
			$choresModel = new Chores();
			$farm = preg_match("/^[0-9][a-z]/i",$model->sow_ear_notch,$match);
			$qtxt ="SELECT * FROM  auto_chores WHERE generated_by = 'B' AND (farm_herd = '".$match[0]."' OR farm_herd = 'A') AND disabled = 'N'";
			$command =Yii::app()->db->createCommand($qtxt);
			$res =$command->queryAll();
			//print_r($res);
			foreach ($res as $recCount=>$record) {
    			 $choresModel->description = $record['description'];
    			 $choresModel->farm_herd = $match[0];
    			 $choresModel->comments = $model->sow_ear_notch;
    			 $choresModel->date = date("m/d/Y",strtotime($model->date_bred)+($record['days_after'] * 24 * 3600));
    			 $currentdate = $choresModel->date;
    			 //$choresModel->date_modified = 'CURRENT_TIMESTAMP';
    			 if(!$choresModel->save()) {
    			  print_r($choresModel->errors);
    			  echo "Error";
    			 }
 			  for($i=2;$i <= $record['times_occur'];$i++) {
 			   $choresModel->setIsNewRecord(true);
 			   $choresModel->chores_id = NULL;
 			        $choresModel->date = date("m/d/Y",strtotime($choresModel->date)+($record['days_between'] * 24 * 3600));
 			        if(!$choresModel->save()) {
 			         print_r($choresModel->errors);
 			         echo "Error".$i;
 			        }
			  }
			}
			if($model->save()){
				$query = "Update herd SET bred_date = '".date("Ymd",strtotime($model->date_bred)) ."' WHERE ear_notch = '".$model->sow_ear_notch."' AND bred_date < '".date("Ymd",strtotime($model->date_bred)) ."'";
				$command =Yii::app()->db->createCommand($query);
				$command->query();
				if(!isset($_POST['savenew']))
					$this->redirect(array('admin'));
				else
					$this->redirect(array('create'));
			}
		}
<commit_msg>o fixes 3<commit_after><?php

class SowGiltsController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column1';

	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
			'postOnly + delete', // we only allow deletion via POST request
		);
	}

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('index','view','AutocompleteEarNotch','Checksolddate','Checkexist','AutocompleteSireNotch','getdaysbtw','autocompleteSow','autocompleteDateBred','autocompleteSire','autocompleteService',
						'autocompleteComments','autocompletePass','autocompleteDue','autocompleteDays','CheckFarrowed'),
				'users'=>array('*'),
			),
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
				'actions'=>array('create','update'),
				'users'=>array('@'),
			),
			array('allow', // allow admin user to perform 'admin' and 'delete' actions
				'actions'=>array('admin','delete'),
				'users'=>array('admin'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

	/**
	 * Displays a particular model.
	 * @param integer $id the ID of the model to be displayed
	 */
	public function actionView($id)
	{
		$this->render('view',array(
			'model'=>$this->loadModel($id),
		));
	}

	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new SowGilts;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['SowGilts']))
		{


			$model->attributes=$_POST['SowGilts'];
			$autoChoresModel = new AutoChores();

			$farm = preg_match("/^[0-9][a-z]/i",$model->sow_ear_notch,$match);
			$qtxt ="SELECT * FROM  auto_chores WHERE generated_by = 'B' AND (farm_herd = '".$match[0]."' OR farm_herd = 'A') AND disabled = 'N'";
			$command =Yii::app()->db->createCommand($qtxt);
			$res =$command->queryAll();
			//print_r($res);
			foreach ($res as $recCount=>$record) {
			     $choresModel = new Chores();
    			 $choresModel->description = $record['description'];
    			 $choresModel->farm_herd = $match[0];
    			 $choresModel->comments = $model->sow_ear_notch;
    			 $choresModel->date = date("m/d/Y",strtotime($model->date_bred)+($record['days_after'] * 24 * 3600));
    			 $currentdate = $choresModel->date;
    			 //$choresModel->date_modified = 'CURRENT_TIMESTAMP';
    			 if(!$choresModel->save()) {
    			  print_r($choresModel->errors);
    			  echo "Error";
    			 }
 			  for($i=2;$i <= $record['times_occur'];$i++) {
 			   $choresModel->setIsNewRecord(true);
 			   $choresModel->chores_id = NULL;
 			        $choresModel->date = date("m/d/Y",strtotime($choresModel->date)+($record['days_between'] * 24 * 3600));
 			        if(!$choresModel->save()) {
 			         print_r($choresModel->errors);
 			         echo "Error".$i;
 			        }
			  }
			}
			if($model->save()){
				$query = "Update herd SET bred_date = '".date("Ymd",strtotime($model->date_bred)) ."' WHERE ear_notch = '".$model->sow_ear_notch."' AND bred_date < '".date("Ymd",strtotime($model->date_bred)) ."'";
				$command =Yii::app()->db->createCommand($query);
				$command->query();
				if(!isset($_POST['savenew']))
					$this->redirect(array('admin'));
				else
					$this->redirect(array('create'));
			}
		}

{'fraction_non_alphanumeric': 0.1830065359477124, 'fraction_numerical': 0.005359477124183006, 'mean_word_length': 3.651063829787234, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5321443', 'n_tokens_mistral': 2925, 'n_tokens_neox': 2488, 'n_words': 506}