예제 #1
0
파일: FilePeer.php 프로젝트: ratibus/Crew
 /**
  * @static
  * @param GitCommand $gitCommand
  * @param Branch $branch
  * @param string $lastBranchSynchronizationCommit
  * @return int 0 if succeed
  */
 public static function synchronize(GitCommand $gitCommand, Branch $branch, $lastBranchSynchronizationCommit = null)
 {
     $filesGit = $gitCommand->getDiffFilesFromBranch($branch->getRepository()->getGitDir(), $branch->getCommitReference(), $branch->getLastCommit());
     if (count($filesGit) > sfConfig::get('app_max_number_of_files_to_review', 4096)) {
         return count($filesGit);
     }
     $filesModel = FileQuery::create()->filterByBranchId($branch->getId())->find();
     if (count($filesModel) > 0) {
         $diffFilesFromLastSynch = $gitCommand->getDiffFilesFromBranch($branch->getRepository()->getGitDir(), !is_null($lastBranchSynchronizationCommit) ? $lastBranchSynchronizationCommit : $branch->getCommitReference(), $branch->getLastCommit(), false);
     }
     foreach ($filesModel as $fileModel) {
         /** @var $fileModel File */
         if (!array_key_exists($fileModel->getFilename(), $filesGit)) {
             $fileModel->delete();
         } else {
             $lastChangeCommit = $gitCommand->getLastModificationCommit($branch->getRepository()->getGitDir(), $branch->getName(), $fileModel->getFilename());
             if (isset($diffFilesFromLastSynch[$fileModel->getFilename()])) {
                 $fileModel->setReviewRequest(true)->setStatus(BranchPeer::A_TRAITER)->setCommitStatusChanged($lastChangeCommit);
             } else {
                 $fileModel->setReviewRequest(false);
             }
             if ($filesGit[$fileModel->getFilename()]['is-binary']) {
                 $fileModel->setIsBinary(true)->setNbAddedLines(0)->setNbDeletedLines(0);
             } else {
                 $fileModel->setIsBinary(false)->setNbAddedLines($filesGit[$fileModel->getFilename()]['added-lines'])->setNbDeletedLines($filesGit[$fileModel->getFilename()]['deleted-lines']);
             }
             $fileModel->setState($filesGit[$fileModel->getFilename()]['state'])->setLastChangeCommit($lastChangeCommit)->setCommitInfos($gitCommand->getCommitInfos($branch->getRepository()->getGitDir(), $lastChangeCommit, "%ce %s"))->setCommitReference($branch->getCommitReference())->save();
         }
         unset($filesGit[$fileModel->getFilename()]);
     }
     foreach ($filesGit as $fileGit) {
         $lastChangeCommit = $gitCommand->getLastModificationCommit($branch->getRepository()->getGitDir(), $branch->getName(), $fileGit['filename']);
         $file = new File();
         if ($fileGit['is-binary']) {
             $file->setIsBinary(true)->setNbAddedLines(0)->setNbDeletedLines(0);
         } else {
             $file->setIsBinary(false)->setNbAddedLines($fileGit['added-lines'])->setNbDeletedLines($fileGit['deleted-lines']);
         }
         $file->setFilename($fileGit['filename'])->setStatus(BranchPeer::A_TRAITER)->setState($fileGit['state'])->setBranchId($branch->getId())->setLastChangeCommit($lastChangeCommit)->setCommitInfos($gitCommand->getCommitInfos($branch->getRepository()->getGitDir(), $lastChangeCommit, "%ce %s"))->setCommitReference($branch->getCommitReference())->setReviewRequest(true)->save();
     }
     return 0;
 }
예제 #2
0
     }
 } else {
     if ($_POST['type'] == "delete") {
         try {
             $branch = new Branch($_POST['key']);
             $branch->delete();
         } catch (fExpectedException $e) {
             echo $e->printMessage();
         }
     } else {
         if ($_POST['type'] == "add") {
             try {
                 $branch = new Branch();
                 $branch->populate();
                 $branch->store();
                 $theId = $branch->getId();
                 $ids = Inv_item::findIdUB($db);
                 foreach ($ids as $id) {
                     $stock = new Inv_stock();
                     $stock->setBranchId($theId);
                     $stock->setItemId($id);
                     $stock->setQuantity(0);
                     $stock->store();
                 }
             } catch (fExpectedException $e) {
                 echo $e->printMessage();
             }
         } else {
             if ($_POST['type'] == "name") {
                 $branch = new Branch($_POST['key']);
                 echo $branch->prepareName();
예제 #3
0
 /**
  * Filter the query by a related Branch object
  *
  * @param     Branch|PropelCollection $branch The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    CommentQuery The current query, for fluid interface
  */
 public function filterByBranch($branch, $comparison = null)
 {
     if ($branch instanceof Branch) {
         return $this->addUsingAlias(CommentPeer::BRANCH_ID, $branch->getId(), $comparison);
     } elseif ($branch instanceof PropelCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CommentPeer::BRANCH_ID, $branch->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByBranch() only accepts arguments of type Branch or PropelCollection');
     }
 }
예제 #4
0
 public function executeBulkupload()
 {
     if ($this->getRequest()->getFileName('csvfile')) {
         $fileName = md5($this->getRequest()->getFileName('csvfile') . time() . rand(0, 99999));
         $ext = $this->getRequest()->getFileExtension('csvfile');
         $this->getRequest()->moveFile('csvfile', sfConfig::get('sf_upload_dir') . "//csvfiles//" . $fileName . ".csv");
         $fullname = $fileName . ".csv";
         //$fullpath = '/uploads/csvfiles/'.$fullname;
         $fp = sfConfig::get('sf_upload_dir') . "//csvfiles//" . $fileName . ".csv";
         $reader = new sfCsvReader($fp, ',', '"');
         $reader->open();
         $i = 1;
         $exist;
         $ignore;
         $log;
         $ignoreflag = 0;
         $success = 0;
         while ($data = $reader->read()) {
             $name[] = array();
             $name = explode(' ', $data[0]);
             $roll = $data[1];
             $enrol = $data[2];
             $branch = $data[3];
             $degree = $data[4];
             $year = $data[5];
             $c = new Criteria();
             $c->add(UserPeer::ENROLMENT, $enrol);
             $user = UserPeer::doSelectOne($c);
             if (!$user) {
                 $c = new Criteria();
                 $c->add(BranchPeer::CODE, $branch);
                 $br = BranchPeer::doSelectOne($c);
                 if (!$br) {
                     $br = new Branch();
                     $br->setName($branch);
                     $br->setCode($branch);
                     $br->save();
                 }
                 $c = new Criteria();
                 $c->add(DegreePeer::NAME, $degree);
                 $dg = DegreePeer::doSelectOne($c);
                 if (!$dg) {
                     $dg = new Degree();
                     $dg->setName($degree);
                     $dg->save();
                 }
                 $user = new User();
                 if ($roll) {
                     $user->setRoll($roll);
                     $user->setRollflag(sfConfig::get('app_defaultprivacy_roll'));
                 }
                 if ($enrol) {
                     $user->setEnrolment($enrol);
                     $user->setEnrolflag(sfConfig::get('app_defaultprivacy_enrol'));
                 } else {
                     $ignoreflag = 1;
                 }
                 if ($year) {
                     $user->setGraduationyear($year);
                     $user->setGraduationyearflag(sfConfig::get('app_defaultprivacy_year'));
                 }
                 $user->setBranchId($br->getId());
                 $user->setBranchflag(sfConfig::get('app_defaultprivacy_branch'));
                 $user->setDegreeId($dg->getId());
                 $user->setDegreeflag(sfConfig::get('app_defaultprivacy_degree'));
                 $user->setIslocked(sfConfig::get('app_islocked_unclaimed'));
                 $user->setUsertype(sfConfig::get('app_usertypecode_Alumni'));
                 $lastname = '';
                 $personal = new Personal();
                 $name[0] = str_replace('.', '', $name[0]);
                 $personal->setFirstname($name[0]);
                 if ($name[3]) {
                     $name[1] = str_replace('.', '', $name[1]);
                     $name[2] = str_replace('.', '', $name[2]);
                     $name[3] = str_replace('.', '', $name[3]);
                     $midname = $name[1] . " " . $name[2];
                     $personal->setMiddlename($midname);
                     $personal->setLastname($name[3]);
                     $lastname = $name[3];
                 } elseif ($name[2]) {
                     $name[1] = str_replace('.', '', $name[1]);
                     $name[2] = str_replace('.', '', $name[2]);
                     $personal->setMiddlename($name[1]);
                     $personal->setLastname($name[2]);
                     $lastname = $name[2];
                 } elseif ($name[1]) {
                     $name[1] = str_replace('.', '', $name[1]);
                     $personal->setLastname($name[1]);
                     $lastname = $name[1];
                 }
                 $uname_suffix = $branch . substr($year, -2);
                 if ($lastname) {
                     $username = $name[0] . '.' . $lastname . '@';
                 } else {
                     $username = $name[0] . '@';
                 }
                 $temp = 1;
                 $tempusername = $username;
                 while ($this->uniqueuser($tempusername . $uname_suffix)) {
                     $tempusername = $username . $temp;
                     $temp++;
                 }
                 $tempusername = $tempusername . $uname_suffix;
                 $user->setUsername($tempusername);
                 if ($ignoreflag == 0) {
                     $e = $user->save();
                     $personal->setUserId($user->getId());
                     $personal->save();
                     $success++;
                     $log[$i][0] = $e == 1 ? "{$i}) Uploaded Successfully" : $e;
                     $log[$i][1] = $data[0];
                 } else {
                     $ignore[] = $i;
                     $ignoreflag = 0;
                     $log[$i][0] = "{$i}) NO enrolment number";
                     $log[$i][1] = $data[0];
                 }
             } else {
                 $exist[] = $i;
                 $log[$i][0] = "{$i}) In Database as " . $user->getFullname() . ", " . $user->getBranchname() . " " . $user->getGraduationyear();
                 $log[$i][1] = $data[0];
             }
             $i++;
         }
         // while ($data = $reader->read()) ends here
         $reader->close();
         $this->log = $log;
         $this->success = $success;
         $this->ignored = $ignore;
         $this->exists = $exist;
     }
 }
		<label for="branch_id">From Branch </label>
				<?php 
        $fromBranch = new Branch($mattrans->getBranchFrom());
        echo $fromBranch->prepareName();
        ?>
		<label for="branch_id"> To Branch </label>
			<?php 
        $toBranch = new Branch($mattrans->getBranchTo());
        echo $toBranch->prepareName();
        ?>
<br />
		<table id="formContent">
			<thead>
				<tr><th>No</th>
					<th>Item Code</th><th width="300px">Description</th><th>Quantity</th><th>UOM</th><th>Remarks</th><th>In <?php 
        echo $fromBranch->getId();
        ?>
</th><th width="75px">Receiver</th></tr>
			</thead>
			<tbody>
				<?php 
        $counter = 1;
        foreach ($mattrans_details as $mattrans_detail) {
            echo "<tr class=\"jsonRow\"><td>" . $counter . "</td><td class=\"itemCode\">" . $mattrans_detail->prepareItemId() . "<input class=\"itemId\" type=\"hidden\" value=\"" . $mattrans_detail->getId() . "\"></input></td>";
            $item = new Inv_item($mattrans_detail->getItemId());
            echo "<td>" . $item->prepareDescription() . "</td><td class=\"itemQuan\">" . $mattrans_detail->prepareQuantity() . "</td>\n\t\t\t\t\t\t\t \t<td>" . $item->prepareUnitOfMeasure() . "</td><td>" . $mattrans_detail->prepareRemark() . "</td>";
            $tempRecords = Inv_stock::findStockByBranch($mattrans_detail->getItemId(), $mattrans->getBranchFrom());
            $quanRow = 0;
            foreach ($tempRecords as $tempRecord) {
                $quanRow = $tempRecord->getQuantity();
            }
예제 #6
0
 /**
  * Exclude object from result
  *
  * @param     Branch $branch Object to remove from the list of results
  *
  * @return    BranchQuery The current query, for fluid interface
  */
 public function prune($branch = null)
 {
     if ($branch) {
         $this->addUsingAlias(BranchPeer::ID, $branch->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
예제 #7
0
파일: BaseFile.php 프로젝트: ratibus/Crew
 /**
  * Declares an association between this object and a Branch object.
  *
  * @param      Branch $v
  * @return     File The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setBranch(Branch $v = null)
 {
     if ($v === null) {
         $this->setBranchId(NULL);
     } else {
         $this->setBranchId($v->getId());
     }
     $this->aBranch = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Branch object, it will not be re-added.
     if ($v !== null) {
         $v->addFile($this);
     }
     return $this;
 }