3
require_once("./import_base.php");
7
/*********************************************
11
*********************************************/
13
class InfiniumProcessor extends Processor {
15
protected $create_new_people = null;
16
public function __construct($file) {
17
parent::__construct($file);
20
protected function mapData() {
21
$mapped_data = parent::mapData();
25
protected function getExpectedHeaders() {
27
'province'=>'province',
28
'district'=>'district',
29
'chiefdom'=>'chiefdom',
32
protected static $required_cols_by_transaction = array(
33
'NE'=>array('chiefdom')
37
protected $effective_date;
38
protected function _processRow() {
39
if (!$this->verifyData()) {
44
$persID = $this->addChiefdom();
50
function verifyData() {
52
$missing_cols = array();
53
foreach (self::$required_cols_by_transaction["NE"] as $required_col) {
54
if ($this->mapped_data[$required_col] === false || (is_string($this->mapped_data[$required_col]) && strlen($this->mapped_data[$required_col]) == 0)) {
55
$missing_cols[] = $required_col;
58
if (count($missing_cols) > 0) {
59
$this->addBadRecord("Missing required columns " . implode(" ",$missing_cols));
60
$codearr=explode("-",$this->mapped_data["CHECK_NO"]);
63
$_SESSION["depcode"]=trim($codearr[0]);
70
function addChiefdom() {
71
$countyObj = $this->ff->createContainer('county');
72
$countyObj->name = ucwords(strtolower(trim($this->mapped_data['chiefdom'])));
73
$countyObj->getField("district")->setFromDB($this->mapped_data['district']);
74
$this->save($countyObj,false);
78
/*********************************************
82
*********************************************/
85
if (count($arg_files) != 1) {
86
usage("Please specify the name of a spreadsheet to process");
90
$file = current($arg_files);
92
$file = realpath($file);
94
$file = realpath($dir. '/' . $file);
96
if (!is_readable($file)) {
97
usage("Please specify the name of a spreadsheet to import: " . $file . " is not readable");
100
I2CE::raiseMessage("Loading from $file");
103
$processor = new InfiniumProcessor($file);
106
echo "Processing Statistics:\n";
107
print_r( $processor->getStats());